Implemented the add text element function
This commit is contained in:
4 files changed
+107
-12
No files matched your search
+12
-9
@@ -37,8 +37,8 @@
|
||||
this.listTextElements = new System.Windows.Forms.ListBox();
|
||||
this.textBoxFilter = new System.Windows.Forms.TextBox();
|
||||
this.labelFilter = new System.Windows.Forms.Label();
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.labelSectionPath = new System.Windows.Forms.Label();
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.tableLayout.SuspendLayout();
|
||||
this.flowLayoutToolbar.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@@ -90,6 +90,7 @@
|
||||
this.buttonAdd.TabIndex = 0;
|
||||
this.toolTip.SetToolTip(this.buttonAdd, "Add text element to selected section");
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||
//
|
||||
// buttonRemove
|
||||
//
|
||||
@@ -103,6 +104,7 @@
|
||||
this.buttonRemove.TabIndex = 2;
|
||||
this.toolTip.SetToolTip(this.buttonRemove, "Delete this text element");
|
||||
this.buttonRemove.UseVisualStyleBackColor = true;
|
||||
this.buttonRemove.Click += new System.EventHandler(this.buttonRemove_Click);
|
||||
//
|
||||
// buttonRename
|
||||
//
|
||||
@@ -116,6 +118,7 @@
|
||||
this.buttonRename.TabIndex = 1;
|
||||
this.toolTip.SetToolTip(this.buttonRename, "Rename this text element");
|
||||
this.buttonRename.UseVisualStyleBackColor = true;
|
||||
this.buttonRename.Click += new System.EventHandler(this.buttonRename_Click);
|
||||
//
|
||||
// listTextElements
|
||||
//
|
||||
@@ -150,14 +153,6 @@
|
||||
this.labelFilter.Text = "Filter:";
|
||||
this.labelFilter.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// toolTip
|
||||
//
|
||||
this.toolTip.AutoPopDelay = 30000;
|
||||
this.toolTip.InitialDelay = 500;
|
||||
this.toolTip.ReshowDelay = 100;
|
||||
this.toolTip.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;
|
||||
this.toolTip.ToolTipTitle = "Help";
|
||||
//
|
||||
// labelSectionPath
|
||||
//
|
||||
this.labelSectionPath.AutoSize = true;
|
||||
@@ -171,6 +166,14 @@
|
||||
this.labelSectionPath.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.toolTip.SetToolTip(this.labelSectionPath, "The path of the currently selected section");
|
||||
//
|
||||
// toolTip
|
||||
//
|
||||
this.toolTip.AutoPopDelay = 30000;
|
||||
this.toolTip.InitialDelay = 500;
|
||||
this.toolTip.ReshowDelay = 100;
|
||||
this.toolTip.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;
|
||||
this.toolTip.ToolTipTitle = "Help";
|
||||
//
|
||||
// TextElements
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using DataModel.Database.Common;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Processor;
|
||||
using UI_WinForms.Dialogs;
|
||||
|
||||
namespace UI_WinForms.Components;
|
||||
|
||||
@@ -55,10 +56,51 @@ public partial class TextElements : UserControl
|
||||
{
|
||||
var item = new ListViewItem(textElement.Name)
|
||||
{
|
||||
Tag = textElement
|
||||
Tag = textElement.Code,
|
||||
};
|
||||
|
||||
this.listTextElements.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private async void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if(this.DesignMode)
|
||||
return;
|
||||
|
||||
var result = InputDialog.Show(new InputDialog.Options(
|
||||
Message: "Please type the desired text element's name.",
|
||||
Title: "Add a text element",
|
||||
Placeholder: "My text element",
|
||||
ShowQuestionCheckbox: false
|
||||
));
|
||||
|
||||
if(result.DialogResult == DialogResult.Cancel)
|
||||
return;
|
||||
|
||||
// Add the text element to the database into the current section:
|
||||
var newTextElement = await TextElementProcessor.AddTextElement(this.db, this.currentSection?.DataKey, result.Text);
|
||||
newTextElement.ProcessError();
|
||||
|
||||
if(!newTextElement.Successful)
|
||||
return;
|
||||
|
||||
// Add the text element to the list:
|
||||
var item = new ListViewItem(newTextElement.Result!.Name)
|
||||
{
|
||||
Tag = newTextElement.Result.Code,
|
||||
};
|
||||
|
||||
this.listTextElements.Items.Add(item);
|
||||
}
|
||||
|
||||
private void buttonRemove_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void buttonRename_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -60,4 +60,10 @@
|
||||
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
Reference in new issue
Block a user