Implemented the culture delete function

This commit is contained in:
tsommer committed 2022-08-02 20:43:58 +02:00
1 parent fee963f8bd
commit 0c53c97a48
7 files changed
+94

No files matched your search

@@ -35,6 +35,8 @@
this.panelSettings = new System.Windows.Forms.Panel();
this.flowLayoutToolbar = new System.Windows.Forms.FlowLayoutPanel();
this.buttonAddCulture = new System.Windows.Forms.Button();
this.buttonDeleteCulture = new System.Windows.Forms.Button();
this.contextMenuDelete = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.tableLayout.SuspendLayout();
this.flowLayoutToolbar.SuspendLayout();
@@ -97,6 +99,7 @@
//
this.tableLayout.SetColumnSpan(this.flowLayoutToolbar, 2);
this.flowLayoutToolbar.Controls.Add(this.buttonAddCulture);
this.flowLayoutToolbar.Controls.Add(this.buttonDeleteCulture);
this.flowLayoutToolbar.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutToolbar.Location = new System.Drawing.Point(0, 315);
this.flowLayoutToolbar.Margin = new System.Windows.Forms.Padding(0);
@@ -117,6 +120,27 @@
this.buttonAddCulture.UseVisualStyleBackColor = true;
this.buttonAddCulture.Click += new System.EventHandler(this.buttonAddCulture_Click);
//
// buttonDeleteCulture
//
this.buttonDeleteCulture.ContextMenuStrip = this.contextMenuDelete;
this.buttonDeleteCulture.FlatAppearance.BorderSize = 0;
this.buttonDeleteCulture.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonDeleteCulture.Image = global::UI_WinForms.Resources.Icons.icons8_trash_can_512;
this.buttonDeleteCulture.Location = new System.Drawing.Point(69, 3);
this.buttonDeleteCulture.Name = "buttonDeleteCulture";
this.buttonDeleteCulture.Size = new System.Drawing.Size(60, 60);
this.buttonDeleteCulture.TabIndex = 0;
this.toolTip.SetToolTip(this.buttonDeleteCulture, "Delete a culture");
this.buttonDeleteCulture.UseVisualStyleBackColor = true;
this.buttonDeleteCulture.Click += new System.EventHandler(this.buttonDeleteCulture_Click);
//
// contextMenuDelete
//
this.contextMenuDelete.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.contextMenuDelete.ImageScalingSize = new System.Drawing.Size(20, 20);
this.contextMenuDelete.Name = "contextMenuDelete";
this.contextMenuDelete.Size = new System.Drawing.Size(211, 32);
//
// toolTip
//
this.toolTip.AutoPopDelay = 30000;
@@ -149,5 +173,7 @@
private FlowLayoutPanel flowLayoutToolbar;
private ToolTip toolTip;
private Button buttonAddCulture;
private Button buttonDeleteCulture;
private ContextMenuStrip contextMenuDelete;
}
}
@@ -28,4 +28,33 @@ public partial class Settings : UserControl
// Reload all settings:
await this.LoadAllSettings();
}
private async void buttonDeleteCulture_Click(object sender, EventArgs e)
{
// Read all cultures:
var cultures = await AppSettings.GetCultureInfos();
// Populate the delete button's menu strip with all cultures:
this.contextMenuDelete.Items.Clear();
foreach (var culture in cultures)
{
var item = new ToolStripMenuItem($"{culture.Index}. Culture: {culture.Code}");
item.Tag = culture.Index;
item.Click += async (senderObj, args) =>
{
if (senderObj is not ToolStripMenuItem toolStripMenuItem)
return;
// Delete the culture:
await AppSettings.DeleteCulture((int)toolStripMenuItem.Tag);
// Reload all settings:
await this.LoadAllSettings();
};
this.contextMenuDelete.Items.Add(item);
}
this.contextMenuDelete.Show((Button)sender, new Point(0, (this.contextMenuDelete.Height + this.buttonDeleteCulture.Height / 2) * -1));
}
}
@@ -60,4 +60,7 @@
<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="contextMenuDelete.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>122, 17</value>
</metadata>
</root>