From 7722340560e8d9b3ecc25f52bd90a80b87e54e68 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 10 May 2020 11:34:45 +0100 Subject: [PATCH] Clean-up --- LinearAppLauncher.csproj | 1 - RyzStudio/Windows/Forms/FlatButton.cs | 14 ++++- RyzStudio/Windows/ThemedForms/ButtonState.cs | 9 ---- RyzStudio/Windows/ThemedForms/ButtonStyle.cs | 25 --------- .../{TextButtonBox.cs => ButtonTextBox.cs} | 8 +-- ....designer.cs => ButtonTextBox.designer.cs} | 2 +- ...{TextButtonBox.resx => ButtonTextBox.resx} | 0 RyzStudio/Windows/ThemedForms/PickerBox.cs | 4 +- RyzStudio/Windows/ThemedForms/TextBox.cs | 4 +- RyzStudio/Windows/ThemedForms/ThemeStyle.cs | 34 ------------- RyzStudio/Windows/ThemedForms/UserControl.cs | 51 +++++++++++++++---- Windows/Forms/Tile/AddTileForm.cs | 8 +-- Windows/Forms/Tile/EditTileForm.cs | 8 +-- 13 files changed, 70 insertions(+), 98 deletions(-) delete mode 100644 RyzStudio/Windows/ThemedForms/ButtonState.cs delete mode 100644 RyzStudio/Windows/ThemedForms/ButtonStyle.cs rename RyzStudio/Windows/ThemedForms/{TextButtonBox.cs => ButtonTextBox.cs} (95%) rename RyzStudio/Windows/ThemedForms/{TextButtonBox.designer.cs => ButtonTextBox.designer.cs} (98%) rename RyzStudio/Windows/ThemedForms/{TextButtonBox.resx => ButtonTextBox.resx} (100%) delete mode 100644 RyzStudio/Windows/ThemedForms/ThemeStyle.cs diff --git a/LinearAppLauncher.csproj b/LinearAppLauncher.csproj index 95f690c..d79493d 100644 --- a/LinearAppLauncher.csproj +++ b/LinearAppLauncher.csproj @@ -122,7 +122,6 @@ TextButtonBox.cs - UserControl diff --git a/RyzStudio/Windows/Forms/FlatButton.cs b/RyzStudio/Windows/Forms/FlatButton.cs index 35c3e40..9864c47 100644 --- a/RyzStudio/Windows/Forms/FlatButton.cs +++ b/RyzStudio/Windows/Forms/FlatButton.cs @@ -106,7 +106,19 @@ namespace RyzStudio.Windows.Forms [Browsable(false)] public Style StyleDefault { get; set; } = new Style(); - public void PerformClick() => this.OnClick(null); + public void PerformClick() + { + if (this.InvokeRequired) + { + this.Invoke(new MethodInvoker(() => { + this.OnClick(null); + })); + } + else + { + this.OnClick(null); + } + } } } diff --git a/RyzStudio/Windows/ThemedForms/ButtonState.cs b/RyzStudio/Windows/ThemedForms/ButtonState.cs deleted file mode 100644 index 9ca2060..0000000 --- a/RyzStudio/Windows/ThemedForms/ButtonState.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace RyzStudio.Windows.ThemedForms -{ - public enum ButtonState - { - Normal = 0, - Hover, - Down - } -} diff --git a/RyzStudio/Windows/ThemedForms/ButtonStyle.cs b/RyzStudio/Windows/ThemedForms/ButtonStyle.cs deleted file mode 100644 index 57c7cb5..0000000 --- a/RyzStudio/Windows/ThemedForms/ButtonStyle.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace RyzStudio.Windows.ThemedForms -{ - using System.Drawing; - - public class ButtonStyle - { - public Color BackColour { get; set; } - public Color PenColour { get; set; } - public Image ForeImage { get; set; } = null; - - public ButtonStyle(Color backColour, Color penColour) - { - this.BackColour = backColour; - this.PenColour = penColour; - this.ForeImage = null; - } - - public ButtonStyle(Color backColour, Color penColour, Image foreImage) - { - this.BackColour = backColour; - this.PenColour = penColour; - this.ForeImage = foreImage; - } - } -} diff --git a/RyzStudio/Windows/ThemedForms/TextButtonBox.cs b/RyzStudio/Windows/ThemedForms/ButtonTextBox.cs similarity index 95% rename from RyzStudio/Windows/ThemedForms/TextButtonBox.cs rename to RyzStudio/Windows/ThemedForms/ButtonTextBox.cs index 1fd4ba7..a362faa 100644 --- a/RyzStudio/Windows/ThemedForms/TextButtonBox.cs +++ b/RyzStudio/Windows/ThemedForms/ButtonTextBox.cs @@ -6,11 +6,11 @@ using System.Drawing; using System.Windows.Forms; - public partial class TextButtonBox : RyzStudio.Windows.ThemedForms.UserControl + public partial class ButtonTextBox : RyzStudio.Windows.ThemedForms.UserControl { protected readonly Padding textboxPadding = new Padding(6, 6, 6, 6); - public TextButtonBox() : base() + public ButtonTextBox() : base() { InitializeComponent(); @@ -63,7 +63,7 @@ break; case Keys.Escape: - tryClose(); + close(); break; default: break; } @@ -112,7 +112,7 @@ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] public new Padding Margin { get { return base.Margin; } set { base.Margin = value; } } - protected override void updateBackground(Graphics g, ThemeStyle style) + protected override void updateBackground(Graphics g, Style style) { int b = (styleActive.BorderWidth + 1) + styleActive.BorderPadding; diff --git a/RyzStudio/Windows/ThemedForms/TextButtonBox.designer.cs b/RyzStudio/Windows/ThemedForms/ButtonTextBox.designer.cs similarity index 98% rename from RyzStudio/Windows/ThemedForms/TextButtonBox.designer.cs rename to RyzStudio/Windows/ThemedForms/ButtonTextBox.designer.cs index 9a15b4c..e42c10b 100644 --- a/RyzStudio/Windows/ThemedForms/TextButtonBox.designer.cs +++ b/RyzStudio/Windows/ThemedForms/ButtonTextBox.designer.cs @@ -1,6 +1,6 @@ namespace RyzStudio.Windows.ThemedForms { - partial class TextButtonBox + partial class ButtonTextBox { /// /// Required designer variable. diff --git a/RyzStudio/Windows/ThemedForms/TextButtonBox.resx b/RyzStudio/Windows/ThemedForms/ButtonTextBox.resx similarity index 100% rename from RyzStudio/Windows/ThemedForms/TextButtonBox.resx rename to RyzStudio/Windows/ThemedForms/ButtonTextBox.resx diff --git a/RyzStudio/Windows/ThemedForms/PickerBox.cs b/RyzStudio/Windows/ThemedForms/PickerBox.cs index 74cb07f..94ad28c 100644 --- a/RyzStudio/Windows/ThemedForms/PickerBox.cs +++ b/RyzStudio/Windows/ThemedForms/PickerBox.cs @@ -50,7 +50,7 @@ break; case Keys.Escape: - tryClose(); + close(); break; default: break; } @@ -83,7 +83,7 @@ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] public new Padding Margin { get => base.Margin; set => base.Margin = value; } - protected override void updateBackground(Graphics g, ThemeStyle style) + protected override void updateBackground(Graphics g, Style style) { int b = (styleActive.BorderWidth + 1) + styleActive.BorderPadding; diff --git a/RyzStudio/Windows/ThemedForms/TextBox.cs b/RyzStudio/Windows/ThemedForms/TextBox.cs index 2671771..5e276ae 100644 --- a/RyzStudio/Windows/ThemedForms/TextBox.cs +++ b/RyzStudio/Windows/ThemedForms/TextBox.cs @@ -49,7 +49,7 @@ break; case Keys.Escape: - tryClose(); + close(); break; default: break; } @@ -82,7 +82,7 @@ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] public new Padding Margin { get { return base.Margin; } set { base.Margin = value; } } - protected override void updateBackground(Graphics g, ThemeStyle style) + protected override void updateBackground(Graphics g, Style style) { int b = (styleActive.BorderWidth + 1) + styleActive.BorderPadding; diff --git a/RyzStudio/Windows/ThemedForms/ThemeStyle.cs b/RyzStudio/Windows/ThemedForms/ThemeStyle.cs deleted file mode 100644 index 71d1dee..0000000 --- a/RyzStudio/Windows/ThemedForms/ThemeStyle.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace RyzStudio.Windows.ThemedForms -{ - using System.Drawing; - - public struct ThemeStyle - { - public int BorderWidth; - public int BorderRadius; - public int BorderPadding; - public Color BorderColour; - public Color BackColour; - public Color ForeColour; - - public ThemeStyle(int borderWidth, int borderRadius, int borderPadding, Color borderColour, Color backColour) - { - this.BorderWidth = borderWidth; - this.BorderRadius = borderRadius; - this.BorderPadding = borderPadding; - this.BorderColour = borderColour; - this.BackColour = backColour; - this.ForeColour = Color.Black; - } - - public ThemeStyle(int borderWidth, int borderRadius, int borderPadding, Color borderColour, Color backColour, Color foreColour) - { - this.BorderWidth = borderWidth; - this.BorderRadius = borderRadius; - this.BorderPadding = borderPadding; - this.BorderColour = borderColour; - this.BackColour = backColour; - this.ForeColour = foreColour; - } - } -} diff --git a/RyzStudio/Windows/ThemedForms/UserControl.cs b/RyzStudio/Windows/ThemedForms/UserControl.cs index babfbde..72670e7 100644 --- a/RyzStudio/Windows/ThemedForms/UserControl.cs +++ b/RyzStudio/Windows/ThemedForms/UserControl.cs @@ -1,15 +1,44 @@ -namespace RyzStudio.Windows.ThemedForms -{ - using System; - using System.Drawing; - using System.Windows.Forms; - using RyzStudio.Drawing; - using System.ComponentModel; +using System; +using System.Drawing; +using System.Windows.Forms; +using RyzStudio.Drawing; +using System.ComponentModel; +namespace RyzStudio.Windows.ThemedForms +{ public partial class UserControl : System.Windows.Forms.UserControl { - //protected ThemeStyle styleActive = new ThemeStyle(1, 3, 2, Color.FromArgb(112, 112, 112), Color.White); - protected ThemeStyle styleActive = new ThemeStyle(1, 3, 2, Color.FromArgb(212, 212, 212), Color.White); + public class Style + { + public int BorderWidth; + public int BorderRadius; + public int BorderPadding; + public Color BorderColour; + public Color BackColour; + public Color ForeColour; + + public Style(int borderWidth, int borderRadius, int borderPadding, Color borderColour, Color backColour) + { + this.BorderWidth = borderWidth; + this.BorderRadius = borderRadius; + this.BorderPadding = borderPadding; + this.BorderColour = borderColour; + this.BackColour = backColour; + this.ForeColour = Color.Black; + } + + public Style(int borderWidth, int borderRadius, int borderPadding, Color borderColour, Color backColour, Color foreColour) + { + this.BorderWidth = borderWidth; + this.BorderRadius = borderRadius; + this.BorderPadding = borderPadding; + this.BorderColour = borderColour; + this.BackColour = backColour; + this.ForeColour = foreColour; + } + } + + protected Style styleActive = new Style(1, 3, 2, Color.FromArgb(212, 212, 212), Color.White); public UserControl() { @@ -39,7 +68,7 @@ [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] public new Padding Padding { get => base.Padding; set => base.Padding = value; } - protected virtual void updateBackground(Graphics g, ThemeStyle style) + protected virtual void updateBackground(Graphics g, Style style) { int b = (styleActive.BorderWidth + 1) + styleActive.BorderPadding; @@ -50,7 +79,7 @@ g.DrawPath(new Pen(new SolidBrush(style.BorderColour), style.BorderWidth), area.ToGraphicsPath()); } - protected virtual void tryClose() + protected virtual void close() { if (this.Parent == null) { diff --git a/Windows/Forms/Tile/AddTileForm.cs b/Windows/Forms/Tile/AddTileForm.cs index 9aa8bd1..c7188a2 100644 --- a/Windows/Forms/Tile/AddTileForm.cs +++ b/Windows/Forms/Tile/AddTileForm.cs @@ -23,9 +23,9 @@ namespace AppLauncher.Windows.Forms private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label1; - private TextButtonBox textBox2; + private ButtonTextBox textBox2; private TextBox textBox3; - private TextButtonBox textBox4; + private ButtonTextBox textBox4; private Button button1; private PickerBox pickerBox1; private PickerBox pickerBox2; @@ -63,9 +63,9 @@ namespace AppLauncher.Windows.Forms this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); - this.textBox2 = new RyzStudio.Windows.ThemedForms.TextButtonBox(); + this.textBox2 = new RyzStudio.Windows.ThemedForms.ButtonTextBox(); this.textBox3 = new RyzStudio.Windows.ThemedForms.TextBox(); - this.textBox4 = new RyzStudio.Windows.ThemedForms.TextButtonBox(); + this.textBox4 = new RyzStudio.Windows.ThemedForms.ButtonTextBox(); this.button1 = new RyzStudio.Windows.ThemedForms.Button(); this.pickerBox1 = new RyzStudio.Windows.ThemedForms.PickerBox(); this.pickerBox2 = new RyzStudio.Windows.ThemedForms.PickerBox(); diff --git a/Windows/Forms/Tile/EditTileForm.cs b/Windows/Forms/Tile/EditTileForm.cs index 8198f34..1482fb0 100644 --- a/Windows/Forms/Tile/EditTileForm.cs +++ b/Windows/Forms/Tile/EditTileForm.cs @@ -19,9 +19,9 @@ namespace AppLauncher.Windows.Forms private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label1; - private TextButtonBox textBox2; + private ButtonTextBox textBox2; private TextBox textBox3; - private TextButtonBox textBox4; + private ButtonTextBox textBox4; private Button button1; private PickerBox pickerBox1; private PickerBox pickerBox2; @@ -56,9 +56,9 @@ namespace AppLauncher.Windows.Forms this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); - this.textBox2 = new RyzStudio.Windows.ThemedForms.TextButtonBox(); + this.textBox2 = new RyzStudio.Windows.ThemedForms.ButtonTextBox(); this.textBox3 = new RyzStudio.Windows.ThemedForms.TextBox(); - this.textBox4 = new RyzStudio.Windows.ThemedForms.TextButtonBox(); + this.textBox4 = new RyzStudio.Windows.ThemedForms.ButtonTextBox(); this.button1 = new RyzStudio.Windows.ThemedForms.Button(); this.pickerBox1 = new RyzStudio.Windows.ThemedForms.PickerBox(); this.pickerBox2 = new RyzStudio.Windows.ThemedForms.PickerBox();