From 67b25beaa17f048b1138a183890988fa4cd882bf Mon Sep 17 00:00:00 2001 From: Robert DeForrest Reynolds Date: Tue, 5 Dec 2023 13:46:37 -0800 Subject: [PATCH] Font Sizing, and Custom Controls Implemented Font Sizing, Doesn't Really Work, And Figured Out Custom Controls --- EditorSettings.Designer.cs | 98 ++++++++++++++++++ EditorSettings.cs | 30 ++++++ EditorSettings.resx | 120 ++++++++++++++++++++++ Forms/ApplicationSettingsForm.Designer.cs | 53 +++++++++- Forms/ApplicationSettingsForm.cs | 10 ++ Forms/MainForm.Designer.cs | 10 +- 6 files changed, 314 insertions(+), 7 deletions(-) create mode 100644 EditorSettings.Designer.cs create mode 100644 EditorSettings.cs create mode 100644 EditorSettings.resx diff --git a/EditorSettings.Designer.cs b/EditorSettings.Designer.cs new file mode 100644 index 0000000..073bd1d --- /dev/null +++ b/EditorSettings.Designer.cs @@ -0,0 +1,98 @@ +namespace Recipsio +{ + partial class EditorSettings + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + FontSizeLabel = new System.Windows.Forms.Label(); + FontSizeControl = new System.Windows.Forms.NumericUpDown(); + tableLayoutPanel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)FontSizeControl).BeginInit(); + SuspendLayout(); + // + // tableLayoutPanel1 + // + tableLayoutPanel1.ColumnCount = 2; + tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 27.833F)); + tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 72.167F)); + tableLayoutPanel1.Controls.Add(FontSizeLabel, 0, 0); + tableLayoutPanel1.Controls.Add(FontSizeControl, 1, 0); + tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + tableLayoutPanel1.Name = "tableLayoutPanel1"; + tableLayoutPanel1.RowCount = 3; + tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); + tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); + tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + tableLayoutPanel1.Size = new System.Drawing.Size(503, 466); + tableLayoutPanel1.TabIndex = 0; + // + // FontSizeLabel + // + FontSizeLabel.AutoSize = true; + FontSizeLabel.Dock = System.Windows.Forms.DockStyle.Fill; + FontSizeLabel.Location = new System.Drawing.Point(3, 0); + FontSizeLabel.Name = "FontSizeLabel"; + FontSizeLabel.Size = new System.Drawing.Size(133, 30); + FontSizeLabel.TabIndex = 0; + FontSizeLabel.Text = "Application Font Size"; + FontSizeLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // FontSizeControl + // + FontSizeControl.DecimalPlaces = 2; + FontSizeControl.Location = new System.Drawing.Point(142, 3); + FontSizeControl.Maximum = new decimal(new int[] { 13, 0, 0, 0 }); + FontSizeControl.Minimum = new decimal(new int[] { 5, 0, 0, 0 }); + FontSizeControl.Name = "FontSizeControl"; + FontSizeControl.Size = new System.Drawing.Size(52, 23); + FontSizeControl.TabIndex = 3; + FontSizeControl.Value = new decimal(new int[] { 5, 0, 0, 0 }); + FontSizeControl.ValueChanged += Font_Size_Changed; + // + // ApplicationSettings + // + AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + BackColor = System.Drawing.Color.FromArgb(252, 245, 229); + Controls.Add(tableLayoutPanel1); + Name = "ApplicationSettings"; + Size = new System.Drawing.Size(503, 466); + tableLayoutPanel1.ResumeLayout(false); + tableLayoutPanel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)FontSizeControl).EndInit(); + ResumeLayout(false); + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.Label FontSizeLabel; + private System.Windows.Forms.NumericUpDown FontSizeControl; + } +} diff --git a/EditorSettings.cs b/EditorSettings.cs new file mode 100644 index 0000000..c7c7000 --- /dev/null +++ b/EditorSettings.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Recipsio +{ + public partial class EditorSettings : UserControl + { + public MainForm MF; + public Toolbox TB; + public EditorSettings(MainForm MF, Toolbox TB) + { + this.MF = MF; + this.TB = TB; + InitializeComponent(); + FontSizeControl.Value = Convert.ToDecimal(MF.Font.Size); + } + + private void Font_Size_Changed(object sender, EventArgs e) + { + MF.Font = new Font("Arial", (float)FontSizeControl.Value); + } + } +} diff --git a/EditorSettings.resx b/EditorSettings.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/EditorSettings.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Forms/ApplicationSettingsForm.Designer.cs b/Forms/ApplicationSettingsForm.Designer.cs index 8e43c3f..212b402 100644 --- a/Forms/ApplicationSettingsForm.Designer.cs +++ b/Forms/ApplicationSettingsForm.Designer.cs @@ -29,25 +29,74 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ApplicationSettingsForm)); + SettingsLayout = new System.Windows.Forms.TableLayoutPanel(); + ApplicationSettingsButton = new System.Windows.Forms.Button(); + EditorSettingsButton = new System.Windows.Forms.Button(); + SettingsLayout.SuspendLayout(); SuspendLayout(); // - // SettingsForm + // SettingsLayout + // + SettingsLayout.ColumnCount = 2; + SettingsLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 15.9502258F)); + SettingsLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 84.0497742F)); + SettingsLayout.Controls.Add(ApplicationSettingsButton, 0, 0); + SettingsLayout.Controls.Add(EditorSettingsButton, 0, 1); + SettingsLayout.Dock = System.Windows.Forms.DockStyle.Fill; + SettingsLayout.Location = new System.Drawing.Point(0, 0); + SettingsLayout.Name = "SettingsLayout"; + SettingsLayout.RowCount = 3; + SettingsLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 45F)); + SettingsLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 45F)); + SettingsLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + SettingsLayout.Size = new System.Drawing.Size(884, 811); + SettingsLayout.TabIndex = 0; + // + // ApplicationSettingsButton + // + ApplicationSettingsButton.Dock = System.Windows.Forms.DockStyle.Fill; + ApplicationSettingsButton.Location = new System.Drawing.Point(3, 3); + ApplicationSettingsButton.Name = "ApplicationSettingsButton"; + ApplicationSettingsButton.Size = new System.Drawing.Size(135, 39); + ApplicationSettingsButton.TabIndex = 0; + ApplicationSettingsButton.Text = "Application"; + ApplicationSettingsButton.UseVisualStyleBackColor = true; + ApplicationSettingsButton.Click += Load_Application_Settings; + // + // EditorSettingsButton + // + EditorSettingsButton.Dock = System.Windows.Forms.DockStyle.Fill; + EditorSettingsButton.Location = new System.Drawing.Point(3, 48); + EditorSettingsButton.Name = "EditorSettingsButton"; + EditorSettingsButton.Size = new System.Drawing.Size(135, 39); + EditorSettingsButton.TabIndex = 1; + EditorSettingsButton.Text = "Editor"; + EditorSettingsButton.UseVisualStyleBackColor = true; + EditorSettingsButton.Click += Load_Editor_Settings; + // + // ApplicationSettingsForm // AutoScaleDimensions = new System.Drawing.SizeF(6F, 14F); AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; BackColor = System.Drawing.Color.FromArgb(252, 245, 229); BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; ClientSize = new System.Drawing.Size(884, 811); + Controls.Add(SettingsLayout); Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon"); - Name = "SettingsForm"; + Name = "ApplicationSettingsForm"; StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; Text = "Settings"; KeyDown += Form_KeyDown; + SettingsLayout.ResumeLayout(false); ResumeLayout(false); } #endregion + + private System.Windows.Forms.TableLayoutPanel SettingsLayout; + private System.Windows.Forms.Button ApplicationSettingsButton; + private System.Windows.Forms.Button EditorSettingsButton; } } \ No newline at end of file diff --git a/Forms/ApplicationSettingsForm.cs b/Forms/ApplicationSettingsForm.cs index 50a9fac..27b5e67 100644 --- a/Forms/ApplicationSettingsForm.cs +++ b/Forms/ApplicationSettingsForm.cs @@ -21,5 +21,15 @@ private void Form_KeyDown(object Sender, KeyEventArgs KeyEvent) Close(); } } + + private void Load_Application_Settings(object sender, System.EventArgs e) + { + } + private void Load_Editor_Settings(object sender, System.EventArgs e) + { + EditorSettings ES = new(MF, TB); + SettingsLayout.Controls.Add(ES, 1, 0); + SettingsLayout.SetRowSpan(ES, SettingsLayout.RowCount); + } } } diff --git a/Forms/MainForm.Designer.cs b/Forms/MainForm.Designer.cs index 27e6b53..27c93d5 100644 --- a/Forms/MainForm.Designer.cs +++ b/Forms/MainForm.Designer.cs @@ -369,7 +369,7 @@ private void InitializeComponent() // RecipeDescription // RecipeDescription.Dock = System.Windows.Forms.DockStyle.Fill; - RecipeDescription.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + RecipeDescription.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); RecipeDescription.Location = new System.Drawing.Point(97, 3); RecipeDescription.Margin = new System.Windows.Forms.Padding(2, 3, 2, 3); RecipeDescription.Name = "RecipeDescription"; @@ -431,9 +431,9 @@ private void InitializeComponent() // RecipeIngredients // RecipeIngredients.Dock = System.Windows.Forms.DockStyle.Fill; - RecipeIngredients.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + RecipeIngredients.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); RecipeIngredients.FormattingEnabled = true; - RecipeIngredients.ItemHeight = 16; + RecipeIngredients.ItemHeight = 15; RecipeIngredients.Location = new System.Drawing.Point(98, 194); RecipeIngredients.Name = "RecipeIngredients"; RecipeIngredients.Size = new System.Drawing.Size(835, 185); @@ -443,9 +443,9 @@ private void InitializeComponent() // RecipeDirections // RecipeDirections.Dock = System.Windows.Forms.DockStyle.Fill; - RecipeDirections.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + RecipeDirections.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); RecipeDirections.FormattingEnabled = true; - RecipeDirections.ItemHeight = 16; + RecipeDirections.ItemHeight = 15; RecipeDirections.Location = new System.Drawing.Point(98, 385); RecipeDirections.Name = "RecipeDirections"; RecipeDirections.Size = new System.Drawing.Size(835, 186);