Implemented adding of additional cultures

This commit is contained in:
Thorsten Sommer 2022-07-30 23:34:45 +02:00
parent 9419642525
commit 38416cb675
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
6 changed files with 84 additions and 8 deletions

View File

@ -28,11 +28,16 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.tableLayout = new System.Windows.Forms.TableLayoutPanel();
this.labelHeadIcon = new System.Windows.Forms.Label();
this.labelHead = new System.Windows.Forms.Label();
this.panelSettings = new System.Windows.Forms.Panel();
this.flowLayoutToolbar = new System.Windows.Forms.FlowLayoutPanel();
this.buttonAddCulture = new System.Windows.Forms.Button();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.tableLayout.SuspendLayout();
this.flowLayoutToolbar.SuspendLayout();
this.SuspendLayout();
//
// tableLayout
@ -43,12 +48,14 @@
this.tableLayout.Controls.Add(this.labelHeadIcon, 0, 0);
this.tableLayout.Controls.Add(this.labelHead, 1, 0);
this.tableLayout.Controls.Add(this.panelSettings, 0, 1);
this.tableLayout.Controls.Add(this.flowLayoutToolbar, 0, 2);
this.tableLayout.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayout.Location = new System.Drawing.Point(0, 0);
this.tableLayout.Name = "tableLayout";
this.tableLayout.RowCount = 2;
this.tableLayout.RowCount = 3;
this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 66F));
this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 66F));
this.tableLayout.Size = new System.Drawing.Size(1001, 381);
this.tableLayout.TabIndex = 1;
//
@ -83,9 +90,41 @@
this.panelSettings.Location = new System.Drawing.Point(0, 66);
this.panelSettings.Margin = new System.Windows.Forms.Padding(0);
this.panelSettings.Name = "panelSettings";
this.panelSettings.Size = new System.Drawing.Size(1001, 315);
this.panelSettings.Size = new System.Drawing.Size(1001, 249);
this.panelSettings.TabIndex = 2;
//
// flowLayoutToolbar
//
this.tableLayout.SetColumnSpan(this.flowLayoutToolbar, 2);
this.flowLayoutToolbar.Controls.Add(this.buttonAddCulture);
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);
this.flowLayoutToolbar.Name = "flowLayoutToolbar";
this.flowLayoutToolbar.Size = new System.Drawing.Size(1001, 66);
this.flowLayoutToolbar.TabIndex = 3;
//
// buttonAddCulture
//
this.buttonAddCulture.FlatAppearance.BorderSize = 0;
this.buttonAddCulture.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.buttonAddCulture.Image = global::UI_WinForms.Resources.Icons.icons8_collectibles_512;
this.buttonAddCulture.Location = new System.Drawing.Point(3, 3);
this.buttonAddCulture.Name = "buttonAddCulture";
this.buttonAddCulture.Size = new System.Drawing.Size(60, 60);
this.buttonAddCulture.TabIndex = 0;
this.toolTip.SetToolTip(this.buttonAddCulture, "Add another culture");
this.buttonAddCulture.UseVisualStyleBackColor = true;
this.buttonAddCulture.Click += new System.EventHandler(this.buttonAddCulture_Click);
//
// 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";
//
// Settings
//
this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F);
@ -96,6 +135,7 @@
this.Size = new System.Drawing.Size(1001, 381);
this.tableLayout.ResumeLayout(false);
this.tableLayout.PerformLayout();
this.flowLayoutToolbar.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -106,5 +146,8 @@
private Label labelHeadIcon;
private Label labelHead;
private Panel panelSettings;
private FlowLayoutPanel flowLayoutToolbar;
private ToolTip toolTip;
private Button buttonAddCulture;
}
}

View File

@ -1,14 +1,31 @@
namespace UI_WinForms.Components;
using Processor;
namespace UI_WinForms.Components;
public partial class Settings : UserControl
{
public Settings()
{
this.InitializeComponent();
this.Load += async (sender, args) =>
{
foreach (var setting in Setting.GetAllSettings())
this.panelSettings.Controls.Add(await setting);
};
this.Load += async (sender, args) => await this.LoadAllSettings();
}
private async Task LoadAllSettings()
{
this.panelSettings.Controls.Clear();
foreach (var setting in Setting.GetAllSettings())
this.panelSettings.Controls.Add(await setting);
}
private async void buttonAddCulture_Click(object sender, EventArgs e)
{
// Get the current number of cultures:
var numberCultures = await AppSettings.GetNumberCultures();
// Add a new culture:
await AppSettings.SetCultureCode(++numberCultures, string.Empty);
// Reload all settings:
await this.LoadAllSettings();
}
}

View File

@ -57,4 +57,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<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>

View File

@ -120,6 +120,16 @@ namespace UI_WinForms.Resources {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icons8_collectibles_512 {
get {
object obj = ResourceManager.GetObject("icons8_collectibles_512", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@ -136,6 +136,9 @@
<data name="icons8_cancel_512" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>icons8-cancel-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8_collectibles_512" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>icons8-collectibles-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icons8_delete_folder_512" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>icons8-delete-folder-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB