diff --git a/.gitignore b/.gitignore index 663f9df3..280cc22b 100644 --- a/.gitignore +++ b/.gitignore @@ -68,6 +68,7 @@ StyleCopReport.xml *_i.c *_p.c *_h.h +*.cache *.ilk *.meta *.obj diff --git a/.nuspec b/.nuspec index 2851f241..8547675e 100644 --- a/.nuspec +++ b/.nuspec @@ -2,9 +2,9 @@ MaterialSkin.2 - 2.1.2 + 2.3.1 MaterialSkin 2 - leocb, IgnaceMaes + leocb, IgnaceMaes, orapps44 leocb MIT https://github.com/leocb/MaterialSkin @@ -12,15 +12,15 @@ false Google's Material Design for your windows forms. see github page for release notes - Copyright Leonardo C Bottaro © 2020 + Copyright Leonardo C Bottaro © 2021 material design materialdesign google forms theme skin - The MaterialSkin 2 is a Google's Material Design skin for you windows forms app. this updated version brings new user controls, unified theming and consistency. This package superseeds the MaterialSkin package By IgnaceMaes. Example app and documentation is available on the project site. Have a quick question? Join our Slack! + The MaterialSkin 2 is a Google's Material Design skin for you windows forms app. this updated version brings new user controls, unified theming and consistency. This package superseeds the MaterialSkin package By IgnaceMaes. Example app and documentation is available on the project site. - \ No newline at end of file + diff --git a/MaterialSkin.sln b/MaterialSkin.sln index 081e6042..140bfb4f 100644 --- a/MaterialSkin.sln +++ b/MaterialSkin.sln @@ -1,10 +1,7 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.136 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30717.126 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MaterialSkinExample", "MaterialSkinExample\MaterialSkinExample.csproj", "{47409AA5-62AE-4189-8E83-C471502DF5E9}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MaterialSkin", "MaterialSkin\MaterialSkin.csproj", "{8EB7611B-68CD-4B8B-987A-11717E2B250C}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{17028688-3699-4BC7-849F-A6B0F6E766BC}" @@ -12,20 +9,34 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MaterialSkinCore", "MaterialSkin\MaterialSkinCore.csproj", "{031DCCA6-79CD-41F0-AA5A-09FDE1C1D308}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MaterialSkinExample.RTL", "MaterialSkinExample.RTL\MaterialSkinExample.RTL.csproj", "{8E08A8CF-A5DB-41DF-B486-E0E5DE552697}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MaterialSkinExample", "MaterialSkinExample\MaterialSkinExample.csproj", "{47409AA5-62AE-4189-8E83-C471502DF5E9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {47409AA5-62AE-4189-8E83-C471502DF5E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {47409AA5-62AE-4189-8E83-C471502DF5E9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {47409AA5-62AE-4189-8E83-C471502DF5E9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {47409AA5-62AE-4189-8E83-C471502DF5E9}.Release|Any CPU.Build.0 = Release|Any CPU {8EB7611B-68CD-4B8B-987A-11717E2B250C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8EB7611B-68CD-4B8B-987A-11717E2B250C}.Debug|Any CPU.Build.0 = Debug|Any CPU {8EB7611B-68CD-4B8B-987A-11717E2B250C}.Release|Any CPU.ActiveCfg = Release|Any CPU {8EB7611B-68CD-4B8B-987A-11717E2B250C}.Release|Any CPU.Build.0 = Release|Any CPU + {031DCCA6-79CD-41F0-AA5A-09FDE1C1D308}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {031DCCA6-79CD-41F0-AA5A-09FDE1C1D308}.Debug|Any CPU.Build.0 = Debug|Any CPU + {031DCCA6-79CD-41F0-AA5A-09FDE1C1D308}.Release|Any CPU.ActiveCfg = Release|Any CPU + {031DCCA6-79CD-41F0-AA5A-09FDE1C1D308}.Release|Any CPU.Build.0 = Release|Any CPU + {8E08A8CF-A5DB-41DF-B486-E0E5DE552697}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E08A8CF-A5DB-41DF-B486-E0E5DE552697}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E08A8CF-A5DB-41DF-B486-E0E5DE552697}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E08A8CF-A5DB-41DF-B486-E0E5DE552697}.Release|Any CPU.Build.0 = Release|Any CPU + {47409AA5-62AE-4189-8E83-C471502DF5E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {47409AA5-62AE-4189-8E83-C471502DF5E9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {47409AA5-62AE-4189-8E83-C471502DF5E9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {47409AA5-62AE-4189-8E83-C471502DF5E9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/MaterialSkin/ColorHelper.cs b/MaterialSkin/ColorHelper.cs index 22f02460..7c77d7b3 100644 --- a/MaterialSkin/ColorHelper.cs +++ b/MaterialSkin/ColorHelper.cs @@ -138,5 +138,25 @@ public static Color FromHsl(int alpha, float hue, float saturation, float lighti return Color.FromArgb(alpha, iMax, iMid, iMin); } } + + /// + /// Removes alpha value without changing Color. + /// + /// The foreground color. + /// The background color. + /// + public static Color RemoveAlpha(Color foreground, Color background) + { + if (foreground.A == 255) + return foreground; + + var alpha = foreground.A / 255.0; + var diff = 1.0 - alpha; + return Color.FromArgb(255, + (byte)(foreground.R * alpha + background.R * diff), + (byte)(foreground.G * alpha + background.G * diff), + (byte)(foreground.B * alpha + background.B * diff)); + } + } -} \ No newline at end of file +} diff --git a/MaterialSkin/ColorScheme.cs b/MaterialSkin/ColorScheme.cs index 1c286772..af25baf4 100644 --- a/MaterialSkin/ColorScheme.cs +++ b/MaterialSkin/ColorScheme.cs @@ -1,4 +1,4 @@ -namespace MaterialSkin +namespace MaterialSkin { using System.Drawing; @@ -10,6 +10,10 @@ public class ColorScheme public readonly Brush PrimaryBrush, DarkPrimaryBrush, LightPrimaryBrush, AccentBrush, TextBrush; + public ColorScheme() : this(Primary.Indigo500, Primary.Indigo700, Primary.Indigo100, Accent.Pink200, TextShade.WHITE) + { + } + public ColorScheme(Primary primary, Primary darkPrimary, Primary lightPrimary, Accent accent, TextShade textShade) { //Color @@ -34,6 +38,30 @@ public ColorScheme(Primary primary, Primary darkPrimary, Primary lightPrimary, A TextBrush = new SolidBrush(TextColor); } + public ColorScheme(int primary, int darkPrimary, int lightPrimary, int accent, TextShade textShade) + { + //Color + PrimaryColor = ((int)primary).ToColor(); + DarkPrimaryColor = ((int)darkPrimary).ToColor(); + LightPrimaryColor = ((int)lightPrimary).ToColor(); + AccentColor = ((int)accent).ToColor(); + TextColor = ((int)textShade).ToColor(); + + //Pen + PrimaryPen = new Pen(PrimaryColor); + DarkPrimaryPen = new Pen(DarkPrimaryColor); + LightPrimaryPen = new Pen(LightPrimaryColor); + AccentPen = new Pen(AccentColor); + TextPen = new Pen(TextColor); + + //Brush + PrimaryBrush = new SolidBrush(PrimaryColor); + DarkPrimaryBrush = new SolidBrush(DarkPrimaryColor); + LightPrimaryBrush = new SolidBrush(LightPrimaryColor); + AccentBrush = new SolidBrush(AccentColor); + TextBrush = new SolidBrush(TextColor); + } + public ColorScheme(Color primary, Color darkPrimary, Color lightPrimary, Color accent, TextShade textShade) { //Color @@ -327,4 +355,4 @@ public enum Accent DeepOrange400 = 0xFF3D00, DeepOrange700 = 0xDD2C00 } -} \ No newline at end of file +} diff --git a/MaterialSkin/Controls/BaseTextBox.cs b/MaterialSkin/Controls/BaseTextBox.cs new file mode 100644 index 00000000..0a6d46e9 --- /dev/null +++ b/MaterialSkin/Controls/BaseTextBox.cs @@ -0,0 +1,241 @@ +namespace MaterialSkin.Controls +{ + using System; + using System.ComponentModel; + using System.Drawing; + using System.Windows.Forms; + + [ToolboxItem(false)] + public class BaseTextBox : TextBox, IMaterialControl + { + #region "Public Properties" + + //Properties for managing the material design properties + [Browsable(false)] + public int Depth { get; set; } + + [Browsable(false)] + public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; + + [Browsable(false)] + public MouseState MouseState { get; set; } + + private string hint = string.Empty; + public string Hint + { + get { return hint; } + set + { + hint = value; + Invalidate(); + } + } + + public new void SelectAll() + { + BeginInvoke((MethodInvoker)delegate () + { + base.Focus(); + base.SelectAll(); + }); + } + + #endregion + + public BaseTextBox() + { + } + + + protected override void OnGotFocus(EventArgs e) + { + base.OnGotFocus(e); + Invalidate(); + } + + protected override void OnLostFocus(EventArgs e) + { + base.OnLostFocus(e); + Invalidate(); + } + + private const int WM_ENABLE = 0x0A; + private const int WM_PAINT = 0xF; + private const UInt32 WM_USER = 0x0400; + private const UInt32 EM_SETBKGNDCOLOR = (WM_USER + 67); + private const UInt32 WM_KILLFOCUS = 0x0008; + protected override void WndProc(ref Message m) + { + base.WndProc(ref m); + + + if (m.Msg == WM_PAINT) + { + if (m.Msg == WM_ENABLE) + { + Graphics g = Graphics.FromHwnd(Handle); + Rectangle bounds = new Rectangle(0, 0, Width, Height); + g.FillRectangle(SkinManager.BackgroundDisabledBrush, bounds); + } + } + + if (m.Msg == WM_PAINT && String.IsNullOrEmpty(Text) && !Focused) + { + using (NativeTextRenderer NativeText = new NativeTextRenderer(Graphics.FromHwnd(m.HWnd))) + { + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + NativeText.DrawTransparentText( + Hint, + SkinManager.getFontByType(MaterialSkinManager.fontType.Subtitle1,RightToLeft), + Enabled ? + ColorHelper.RemoveAlpha(SkinManager.TextMediumEmphasisColor, BackColor) : // not focused + ColorHelper.RemoveAlpha(SkinManager.TextDisabledOrHintColor, BackColor), // Disabled + ClientRectangle.Location, + ClientRectangle.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Top); + } + } + + if (m.Msg == EM_SETBKGNDCOLOR) + { + Invalidate(); + } + + if (m.Msg == WM_KILLFOCUS) //set border back to normal on lost focus + { + Invalidate(); + } + + } + + } + + [ToolboxItem(false)] + public class BaseMaskedTextBox : MaskedTextBox, IMaterialControl + { + //Properties for managing the material design properties + [Browsable(false)] + public int Depth { get; set; } + + [Browsable(false)] + public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; + + [Browsable(false)] + public MouseState MouseState { get; set; } + + private string hint = string.Empty; + public string Hint + { + get { return hint; } + set + { + hint = value; + Invalidate(); + } + } + + public new void SelectAll() + { + BeginInvoke((MethodInvoker)delegate () + { + base.Focus(); + base.SelectAll(); + }); + } + + + public BaseMaskedTextBox() + { + } + + protected override void OnGotFocus(EventArgs e) + { + base.OnGotFocus(e); + Invalidate(); + } + + protected override void OnLostFocus(EventArgs e) + { + base.OnLostFocus(e); + Invalidate(); + } + + private const int WM_ENABLE = 0x0A; + private const int WM_PAINT = 0xF; + private const UInt32 WM_USER = 0x0400; + private const UInt32 EM_SETBKGNDCOLOR = (WM_USER + 67); + private const UInt32 WM_KILLFOCUS = 0x0008; + protected override void WndProc(ref Message m) + { + base.WndProc(ref m); + + + if (m.Msg == WM_PAINT) + { + if (m.Msg == WM_ENABLE) + { + Graphics g = Graphics.FromHwnd(Handle); + Rectangle bounds = new Rectangle(0, 0, Width, Height); + g.FillRectangle(SkinManager.BackgroundDisabledBrush, bounds); + } + } + + if (m.Msg == WM_PAINT && String.IsNullOrEmpty(Text) && !Focused) + { + using (NativeTextRenderer NativeText = new NativeTextRenderer(Graphics.FromHwnd(m.HWnd))) + { + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + NativeText.DrawTransparentText( + Hint, + SkinManager.getFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft), + Enabled ? + ColorHelper.RemoveAlpha(SkinManager.TextMediumEmphasisColor, BackColor) : // not focused + ColorHelper.RemoveAlpha(SkinManager.TextDisabledOrHintColor, BackColor), // Disabled + ClientRectangle.Location, + ClientRectangle.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Top); + } + } + + if (m.Msg == EM_SETBKGNDCOLOR) + { + Invalidate(); + } + + if (m.Msg == WM_KILLFOCUS) //set border back to normal on lost focus + { + Invalidate(); + } + + } + } + + [ToolboxItem(false)] + public class BaseTextBoxContextMenuStrip : MaterialContextMenuStrip + { + public readonly ToolStripItem undo = new MaterialToolStripMenuItem { Text = "Undo" }; + public readonly ToolStripItem seperator1 = new ToolStripSeparator(); + public readonly ToolStripItem cut = new MaterialToolStripMenuItem { Text = "Cut" }; + public readonly ToolStripItem copy = new MaterialToolStripMenuItem { Text = "Copy" }; + public readonly ToolStripItem paste = new MaterialToolStripMenuItem { Text = "Paste" }; + public readonly ToolStripItem delete = new MaterialToolStripMenuItem { Text = "Delete" }; + public readonly ToolStripItem seperator2 = new ToolStripSeparator(); + public readonly ToolStripItem selectAll = new MaterialToolStripMenuItem { Text = "Select All" }; + + public BaseTextBoxContextMenuStrip() + { + Items.AddRange(new[] + { + undo, + seperator1, + cut, + copy, + paste, + delete, + seperator2, + selectAll + }); + } + } + +} diff --git a/MaterialSkin/Controls/FlexibleMaterialDialog.cs b/MaterialSkin/Controls/FlexibleMaterialDialog.cs index 3c4caae2..91d527db 100644 --- a/MaterialSkin/Controls/FlexibleMaterialDialog.cs +++ b/MaterialSkin/Controls/FlexibleMaterialDialog.cs @@ -1,786 +1,970 @@ -using System; -using System.Diagnostics; -using System.Drawing; -using System.Globalization; -using System.Linq; -using System.Windows.Forms; - -namespace MaterialSkin.Controls -{ - /// - /// The form to show the customized message box. - /// It is defined as an internal class to keep the public interface of the FlexibleMessageBox clean. - /// - public class FlexibleMaterialForm : MaterialForm, IMaterialControl - { +using System; +using System.ComponentModel; +using System.Diagnostics; +using System.Drawing; +using System.Globalization; +using System.Linq; +using System.Windows.Forms; + +namespace MaterialSkin.Controls +{ + /// + /// The form to show the customized message box. + /// It is defined as an internal class to keep the public interface of the FlexibleMessageBox clean. + /// + public class FlexibleMaterialForm : MaterialForm, IMaterialControl + { private readonly MaterialSkinManager materialSkinManager; - - /// - /// Defines the font for all FlexibleMessageBox instances. - /// - /// Default is: SystemFonts.MessageBoxFont - /// - public static Font FONT; - - /// - /// Defines the maximum width for all FlexibleMessageBox instances in percent of the working area. - /// - /// Allowed values are 0.2 - 1.0 where: - /// 0.2 means: The FlexibleMessageBox can be at most half as wide as the working area. - /// 1.0 means: The FlexibleMessageBox can be as wide as the working area. - /// - /// Default is: 70% of the working area width. - /// - public static double MAX_WIDTH_FACTOR = 0.7; - - /// - /// Defines the maximum height for all FlexibleMessageBox instances in percent of the working area. - /// - /// Allowed values are 0.2 - 1.0 where: - /// 0.2 means: The FlexibleMessageBox can be at most half as high as the working area. - /// 1.0 means: The FlexibleMessageBox can be as high as the working area. - /// - /// Default is: 90% of the working area height. - /// - public static double MAX_HEIGHT_FACTOR = 0.9; - - private MaterialMultiLineTextBox richTextBoxMessage; - - /// - /// Erforderliche Designervariable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Verwendete Ressourcen bereinigen. - /// - /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - /// - /// Erforderliche Methode für die Designerunterstützung. - /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.leftButton = new MaterialSkin.Controls.MaterialButton(); - this.FlexibleMaterialFormBindingSource = new System.Windows.Forms.BindingSource(this.components); - this.messageContainer = new System.Windows.Forms.Panel(); - this.pictureBoxForIcon = new System.Windows.Forms.PictureBox(); - this.richTextBoxMessage = new MaterialSkin.Controls.MaterialMultiLineTextBox(); - this.middleButton = new MaterialSkin.Controls.MaterialButton(); - this.rightButton = new MaterialSkin.Controls.MaterialButton(); - ((System.ComponentModel.ISupportInitialize)(this.FlexibleMaterialFormBindingSource)).BeginInit(); - this.messageContainer.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxForIcon)).BeginInit(); - this.SuspendLayout(); - // - // leftButton - // - this.leftButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.leftButton.AutoSize = false; - this.leftButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.leftButton.Depth = 0; - this.leftButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.leftButton.DrawShadows = true; - this.leftButton.HighEmphasis = false; - this.leftButton.Icon = null; - this.leftButton.Location = new System.Drawing.Point(44, 163); - this.leftButton.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); - this.leftButton.MinimumSize = new System.Drawing.Size(0, 24); - this.leftButton.MouseState = MaterialSkin.MouseState.HOVER; - this.leftButton.Name = "leftButton"; - this.leftButton.Size = new System.Drawing.Size(108, 36); - this.leftButton.TabIndex = 2; - this.leftButton.Text = "OK"; - this.leftButton.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Text; - this.leftButton.UseAccentColor = false; - this.leftButton.UseVisualStyleBackColor = true; - this.leftButton.Visible = false; - // - // messageContainer - // - this.messageContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.messageContainer.BackColor = System.Drawing.Color.White; - this.messageContainer.Controls.Add(this.pictureBoxForIcon); - this.messageContainer.Controls.Add(this.richTextBoxMessage); - this.messageContainer.Location = new System.Drawing.Point(0, 65); - this.messageContainer.Name = "messageContainer"; - this.messageContainer.Size = new System.Drawing.Size(388, 81); - this.messageContainer.TabIndex = 1; - // - // pictureBoxForIcon - // - this.pictureBoxForIcon.BackColor = System.Drawing.Color.Transparent; - this.pictureBoxForIcon.Location = new System.Drawing.Point(15, 19); - this.pictureBoxForIcon.Name = "pictureBoxForIcon"; - this.pictureBoxForIcon.Size = new System.Drawing.Size(32, 32); - this.pictureBoxForIcon.TabIndex = 8; - this.pictureBoxForIcon.TabStop = false; - // - // richTextBoxMessage - // - this.richTextBoxMessage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.richTextBoxMessage.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(237)))), ((int)(((byte)(237)))), ((int)(((byte)(237))))); - this.richTextBoxMessage.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.richTextBoxMessage.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.FlexibleMaterialFormBindingSource, "MessageText", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); - this.richTextBoxMessage.Depth = 0; - this.richTextBoxMessage.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.richTextBoxMessage.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.richTextBoxMessage.Hint = ""; - this.richTextBoxMessage.Location = new System.Drawing.Point(47, 2); - this.richTextBoxMessage.Margin = new System.Windows.Forms.Padding(0); - this.richTextBoxMessage.MouseState = MaterialSkin.MouseState.HOVER; - this.richTextBoxMessage.Name = "richTextBoxMessage"; - this.richTextBoxMessage.ReadOnly = true; - this.richTextBoxMessage.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical; - this.richTextBoxMessage.Size = new System.Drawing.Size(338, 78); - this.richTextBoxMessage.TabIndex = 0; - this.richTextBoxMessage.TabStop = false; - this.richTextBoxMessage.Text = ""; - this.richTextBoxMessage.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.richTextBoxMessage_LinkClicked); - // - // middleButton - // - this.middleButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.middleButton.AutoSize = false; - this.middleButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.middleButton.Depth = 0; - this.middleButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.middleButton.DrawShadows = true; - this.middleButton.HighEmphasis = true; - this.middleButton.Icon = null; - this.middleButton.Location = new System.Drawing.Point(160, 163); - this.middleButton.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); - this.middleButton.MinimumSize = new System.Drawing.Size(0, 24); - this.middleButton.MouseState = MaterialSkin.MouseState.HOVER; - this.middleButton.Name = "middleButton"; - this.middleButton.Size = new System.Drawing.Size(102, 36); - this.middleButton.TabIndex = 3; - this.middleButton.Text = "OK"; - this.middleButton.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Text; - this.middleButton.UseAccentColor = false; - this.middleButton.UseVisualStyleBackColor = true; - this.middleButton.Visible = false; - // - // rightButton - // - this.rightButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.rightButton.AutoSize = false; - this.rightButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.rightButton.Depth = 0; - this.rightButton.DialogResult = System.Windows.Forms.DialogResult.OK; - this.rightButton.DrawShadows = true; - this.rightButton.HighEmphasis = true; - this.rightButton.Icon = null; - this.rightButton.Location = new System.Drawing.Point(270, 163); - this.rightButton.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); - this.rightButton.MinimumSize = new System.Drawing.Size(0, 24); - this.rightButton.MouseState = MaterialSkin.MouseState.HOVER; - this.rightButton.Name = "rightButton"; - this.rightButton.Size = new System.Drawing.Size(106, 36); - this.rightButton.TabIndex = 0; - this.rightButton.Text = "OK"; - this.rightButton.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; - this.rightButton.UseAccentColor = false; - this.rightButton.UseVisualStyleBackColor = true; - this.rightButton.Visible = false; - // - // FlexibleMaterialForm - // - this.BackColor = System.Drawing.Color.White; - this.ClientSize = new System.Drawing.Size(388, 208); - this.Controls.Add(this.rightButton); - this.Controls.Add(this.middleButton); - this.Controls.Add(this.messageContainer); - this.Controls.Add(this.leftButton); - this.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.FlexibleMaterialFormBindingSource, "CaptionText", true)); - this.MaximizeBox = false; - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(276, 140); - this.Name = "FlexibleMaterialForm"; - this.ShowIcon = false; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = ""; - this.Load += new System.EventHandler(this.FlexibleMaterialForm_Load); - this.Shown += new System.EventHandler(this.FlexibleMaterialForm_Shown); - ((System.ComponentModel.ISupportInitialize)(this.FlexibleMaterialFormBindingSource)).EndInit(); - this.messageContainer.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxForIcon)).EndInit(); - this.ResumeLayout(false); - } - - private MaterialButton leftButton; - - /// - /// Defines the FlexibleMaterialFormBindingSource - /// - private System.Windows.Forms.BindingSource FlexibleMaterialFormBindingSource; - - /// - /// Defines the panel1 - /// - private System.Windows.Forms.Panel messageContainer; - - /// - /// Defines the pictureBoxForIcon - /// - private System.Windows.Forms.PictureBox pictureBoxForIcon; - - private MaterialButton middleButton; - private MaterialButton rightButton; - - //These separators are used for the "copy to clipboard" standard operation, triggered by Ctrl + C (behavior and clipboard format is like in a standard MessageBox) - /// - /// Defines the STANDARD_MESSAGEBOX_SEPARATOR_LINES - /// - private static readonly String STANDARD_MESSAGEBOX_SEPARATOR_LINES = "---------------------------\n"; - - /// - /// Defines the STANDARD_MESSAGEBOX_SEPARATOR_SPACES - /// - private static readonly String STANDARD_MESSAGEBOX_SEPARATOR_SPACES = " "; - - //These are the possible buttons (in a standard MessageBox) - private enum ButtonID - { /// - /// Defines the OK - /// + + /// + /// Defines the font for all FlexibleMessageBox instances. + /// + /// Default is: SystemFonts.MessageBoxFont + /// + public static Font FONT; + + /// + /// Defines the maximum width for all FlexibleMessageBox instances in percent of the working area. + /// + /// Allowed values are 0.2 - 1.0 where: + /// 0.2 means: The FlexibleMessageBox can be at most half as wide as the working area. + /// 1.0 means: The FlexibleMessageBox can be as wide as the working area. + /// + /// Default is: 70% of the working area width. + /// + public static double MAX_WIDTH_FACTOR = 0.7; + + /// + /// Defines the maximum height for all FlexibleMessageBox instances in percent of the working area. + /// + /// Allowed values are 0.2 - 1.0 where: + /// 0.2 means: The FlexibleMessageBox can be at most half as high as the working area. + /// 1.0 means: The FlexibleMessageBox can be as high as the working area. + /// + /// Default is: 90% of the working area height. + /// + public static double MAX_HEIGHT_FACTOR = 0.9; + + private MaterialMultiLineTextBox richTextBoxMessage; + private MaterialLabel materialLabel1; + private MaterialButton leftButton; + private MaterialButton middleButton; + private MaterialButton rightButton; + + [Browsable(false)] + /// + /// Defines position of buttons in Dialog window. By default, ButtonStyle is Fill + /// + public enum ButtonsPosition + { + Fill, + Left, + Right, + Center + } + + public ButtonsPosition ButtonsPositionEnum { get; set; } = FlexibleMaterialForm.ButtonsPosition.Right; + + /// + /// Erforderliche Designervariable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Verwendete Ressourcen bereinigen. + /// + /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + /// + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.FlexibleMaterialFormBindingSource = new System.Windows.Forms.BindingSource(this.components); + this.messageContainer = new System.Windows.Forms.Panel(); + this.materialLabel1 = new MaterialSkin.Controls.MaterialLabel(); + this.pictureBoxForIcon = new System.Windows.Forms.PictureBox(); + this.richTextBoxMessage = new MaterialSkin.Controls.MaterialMultiLineTextBox(); + this.leftButton = new MaterialSkin.Controls.MaterialButton(); + this.middleButton = new MaterialSkin.Controls.MaterialButton(); + this.rightButton = new MaterialSkin.Controls.MaterialButton(); + ((System.ComponentModel.ISupportInitialize)(this.FlexibleMaterialFormBindingSource)).BeginInit(); + this.messageContainer.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxForIcon)).BeginInit(); + this.SuspendLayout(); + // + // messageContainer + // + this.messageContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.messageContainer.BackColor = System.Drawing.Color.White; + this.messageContainer.Controls.Add(this.materialLabel1); + this.messageContainer.Controls.Add(this.pictureBoxForIcon); + this.messageContainer.Controls.Add(this.richTextBoxMessage); + this.messageContainer.Location = new System.Drawing.Point(1, 65); + this.messageContainer.Name = "messageContainer"; + this.messageContainer.Size = new System.Drawing.Size(382, 89); + this.messageContainer.TabIndex = 1; + // + // materialLabel1 + // + this.materialLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.materialLabel1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.FlexibleMaterialFormBindingSource, "MessageText", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); + this.materialLabel1.Depth = 0; + this.materialLabel1.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel1.Location = new System.Drawing.Point(56, 12); + this.materialLabel1.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel1.Name = "materialLabel1"; + this.materialLabel1.Size = new System.Drawing.Size(314, 65); + this.materialLabel1.TabIndex = 9; + this.materialLabel1.Text = ""; + this.materialLabel1.Visible = false; + // + // pictureBoxForIcon + // + this.pictureBoxForIcon.BackColor = System.Drawing.Color.Transparent; + this.pictureBoxForIcon.Location = new System.Drawing.Point(12, 12); + this.pictureBoxForIcon.Name = "pictureBoxForIcon"; + this.pictureBoxForIcon.Size = new System.Drawing.Size(32, 32); + this.pictureBoxForIcon.TabIndex = 8; + this.pictureBoxForIcon.TabStop = false; + // + // richTextBoxMessage + // + this.richTextBoxMessage.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.richTextBoxMessage.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + this.richTextBoxMessage.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.richTextBoxMessage.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.FlexibleMaterialFormBindingSource, "MessageText", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)); + this.richTextBoxMessage.Depth = 0; + this.richTextBoxMessage.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.richTextBoxMessage.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.richTextBoxMessage.Location = new System.Drawing.Point(56, 12); + this.richTextBoxMessage.Margin = new System.Windows.Forms.Padding(0); + this.richTextBoxMessage.MouseState = MaterialSkin.MouseState.HOVER; + this.richTextBoxMessage.Name = "richTextBoxMessage"; + this.richTextBoxMessage.ReadOnly = true; + this.richTextBoxMessage.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical; + this.richTextBoxMessage.Size = new System.Drawing.Size(314, 65); + this.richTextBoxMessage.TabIndex = 0; + this.richTextBoxMessage.TabStop = false; + this.richTextBoxMessage.Text = ""; + this.richTextBoxMessage.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.richTextBoxMessage_LinkClicked); + // + // leftButton + // + this.leftButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.leftButton.AutoSize = false; + this.leftButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.leftButton.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; + this.leftButton.Depth = 0; + this.leftButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.leftButton.HighEmphasis = false; + this.leftButton.Icon = null; + this.leftButton.Location = new System.Drawing.Point(32, 163); + this.leftButton.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); + this.leftButton.MinimumSize = new System.Drawing.Size(0, 24); + this.leftButton.MouseState = MaterialSkin.MouseState.HOVER; + this.leftButton.Name = "leftButton"; + this.leftButton.Size = new System.Drawing.Size(108, 36); + this.leftButton.TabIndex = 14; + this.leftButton.Text = "OK"; + this.leftButton.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Text; + this.leftButton.UseAccentColor = false; + this.leftButton.UseVisualStyleBackColor = true; + this.leftButton.Visible = false; + // + // middleButton + // + this.middleButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.middleButton.AutoSize = false; + this.middleButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.middleButton.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; + this.middleButton.Depth = 0; + this.middleButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.middleButton.HighEmphasis = true; + this.middleButton.Icon = null; + this.middleButton.Location = new System.Drawing.Point(148, 163); + this.middleButton.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); + this.middleButton.MinimumSize = new System.Drawing.Size(0, 24); + this.middleButton.MouseState = MaterialSkin.MouseState.HOVER; + this.middleButton.Name = "middleButton"; + this.middleButton.Size = new System.Drawing.Size(102, 36); + this.middleButton.TabIndex = 15; + this.middleButton.Text = "OK"; + this.middleButton.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Text; + this.middleButton.UseAccentColor = false; + this.middleButton.UseVisualStyleBackColor = true; + this.middleButton.Visible = false; + // + // rightButton + // + this.rightButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom; + this.rightButton.AutoSize = false; + this.rightButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.rightButton.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; + this.rightButton.Depth = 0; + this.rightButton.DialogResult = System.Windows.Forms.DialogResult.OK; + this.rightButton.HighEmphasis = true; + this.rightButton.Icon = null; + this.rightButton.Location = new System.Drawing.Point(258, 163); + this.rightButton.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); + this.rightButton.MinimumSize = new System.Drawing.Size(0, 24); + this.rightButton.MouseState = MaterialSkin.MouseState.HOVER; + this.rightButton.Name = "rightButton"; + this.rightButton.Size = new System.Drawing.Size(106, 36); + this.rightButton.TabIndex = 13; + this.rightButton.Text = "OK"; + this.rightButton.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; + this.rightButton.UseAccentColor = false; + this.rightButton.UseVisualStyleBackColor = true; + this.rightButton.Visible = false; + // + // FlexibleMaterialForm + // + this.BackColor = System.Drawing.Color.White; + this.ClientSize = new System.Drawing.Size(384, 208); + this.Controls.Add(this.leftButton); + this.Controls.Add(this.middleButton); + this.Controls.Add(this.rightButton); + this.Controls.Add(this.messageContainer); + this.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.FlexibleMaterialFormBindingSource, "CaptionText", true)); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(276, 140); + this.Name = "FlexibleMaterialForm"; + this.ShowIcon = false; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = ""; + this.Load += new System.EventHandler(this.FlexibleMaterialForm_Load); + this.Shown += new System.EventHandler(this.FlexibleMaterialForm_Shown); + ((System.ComponentModel.ISupportInitialize)(this.FlexibleMaterialFormBindingSource)).EndInit(); + this.messageContainer.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxForIcon)).EndInit(); + this.ResumeLayout(false); + + } + + /// + /// Defines the FlexibleMaterialFormBindingSource + /// + private System.Windows.Forms.BindingSource FlexibleMaterialFormBindingSource; + + /// + /// Defines the panel1 + /// + private System.Windows.Forms.Panel messageContainer; + + /// + /// Defines the pictureBoxForIcon + /// + private System.Windows.Forms.PictureBox pictureBoxForIcon; + + //These separators are used for the "copy to clipboard" standard operation, triggered by Ctrl + C (behavior and clipboard format is like in a standard MessageBox) + /// + /// Defines the STANDARD_MESSAGEBOX_SEPARATOR_LINES + /// + private static readonly String STANDARD_MESSAGEBOX_SEPARATOR_LINES = "---------------------------\n"; + + /// + /// Defines the STANDARD_MESSAGEBOX_SEPARATOR_SPACES + /// + private static readonly String STANDARD_MESSAGEBOX_SEPARATOR_SPACES = " "; + + //These are the possible buttons (in a standard MessageBox) + private enum ButtonID + { /// + /// Defines the OK + /// OK = 0, - - /// - /// Defines the CANCEL - /// + + /// + /// Defines the CANCEL + /// CANCEL, - - /// - /// Defines the YES - /// + + /// + /// Defines the YES + /// YES, - - /// - /// Defines the NO - /// + + /// + /// Defines the NO + /// NO, - - /// - /// Defines the ABORT - /// + + /// + /// Defines the ABORT + /// ABORT, - - /// - /// Defines the RETRY - /// + + /// + /// Defines the RETRY + /// RETRY, - - /// - /// Defines the IGNORE - /// - IGNORE - }; - - //These are the buttons texts for different languages. - //If you want to add a new language, add it here and in the GetButtonText-Function - private enum TwoLetterISOLanguageID - { /// - /// Defines the en - /// + + /// + /// Defines the IGNORE + /// + IGNORE + }; + + //These are the buttons texts for different languages. + //If you want to add a new language, add it here and in the GetButtonText-Function + private enum TwoLetterISOLanguageID + { /// + /// Defines the en + /// en, - - /// - /// Defines the de - /// + + /// + /// Defines the de + /// de, - - /// - /// Defines the es - /// + + /// + /// Defines the es + /// es, - - /// - /// Defines the it - /// - it - }; - - /// - /// Defines the BUTTON_TEXTS_ENGLISH_EN - /// - private static readonly String[] BUTTON_TEXTS_ENGLISH_EN = { "OK", "Cancel", "&Yes", "&No", "&Abort", "&Retry", "&Ignore" };//Note: This is also the fallback language - - /// - /// Defines the BUTTON_TEXTS_GERMAN_DE - /// - private static readonly String[] BUTTON_TEXTS_GERMAN_DE = { "OK", "Abbrechen", "&Ja", "&Nein", "&Abbrechen", "&Wiederholen", "&Ignorieren" }; - - /// - /// Defines the BUTTON_TEXTS_SPANISH_ES - /// - private static readonly String[] BUTTON_TEXTS_SPANISH_ES = { "Aceptar", "Cancelar", "&Sí", "&No", "&Abortar", "&Reintentar", "&Ignorar" }; - - /// - /// Defines the BUTTON_TEXTS_ITALIAN_IT - /// - private static readonly String[] BUTTON_TEXTS_ITALIAN_IT = { "OK", "Annulla", "&Sì", "&No", "&Interrompi", "&Riprova", "&Ignora" }; - - /// - /// Defines the defaultButton - /// - private MessageBoxDefaultButton defaultButton; - - /// - /// Defines the visibleButtonsCount - /// - private int visibleButtonsCount; - - /// - /// Defines the languageID - /// - private TwoLetterISOLanguageID languageID = TwoLetterISOLanguageID.en; - - /// - /// Prevents a default instance of the class from being created. - /// - private FlexibleMaterialForm() - { - InitializeComponent(); - - //Try to evaluate the language. If this fails, the fallback language English will be used - Enum.TryParse(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName, out this.languageID); - - this.KeyPreview = true; - this.KeyUp += FlexibleMaterialForm_KeyUp; - - materialSkinManager = MaterialSkinManager.Instance; - materialSkinManager.AddFormToManage(this); - FONT = materialSkinManager.getFontByType(MaterialSkinManager.fontType.Body1); - } - - /// - /// Gets the string rows. - /// - /// The message. - /// The string rows as 1-dimensional array - private static string[] GetStringRows(string message) - { - if (string.IsNullOrEmpty(message)) - { - return null; - } - - var messageRows = message.Split(new char[] { '\n' }, StringSplitOptions.None); - return messageRows; - } - - /// - /// Gets the button text for the CurrentUICulture language. - /// Note: The fallback language is English - /// - /// The ID of the button. - /// The button text - private string GetButtonText(ButtonID buttonID) - { - var buttonTextArrayIndex = Convert.ToInt32(buttonID); - - switch (this.languageID) - { - case TwoLetterISOLanguageID.de: return BUTTON_TEXTS_GERMAN_DE[buttonTextArrayIndex]; - case TwoLetterISOLanguageID.es: return BUTTON_TEXTS_SPANISH_ES[buttonTextArrayIndex]; - case TwoLetterISOLanguageID.it: return BUTTON_TEXTS_ITALIAN_IT[buttonTextArrayIndex]; - - default: return BUTTON_TEXTS_ENGLISH_EN[buttonTextArrayIndex]; - } - } - - /// - /// Ensure the given working area factor in the range of 0.2 - 1.0 where: - /// - /// 0.2 means: 20 percent of the working area height or width. - /// 1.0 means: 100 percent of the working area height or width. - /// - /// The given working area factor. - /// The corrected given working area factor. - private static double GetCorrectedWorkingAreaFactor(double workingAreaFactor) - { - const double MIN_FACTOR = 0.2; - const double MAX_FACTOR = 1.0; - - if (workingAreaFactor < MIN_FACTOR) - { - return MIN_FACTOR; - } - - if (workingAreaFactor > MAX_FACTOR) - { - return MAX_FACTOR; - } - - return workingAreaFactor; - } - - /// - /// Set the dialogs start position when given. - /// Otherwise center the dialog on the current screen. - /// - /// The FlexibleMessageBox dialog. - /// The owner. - private static void SetDialogStartPosition(FlexibleMaterialForm FlexibleMaterialForm, IWin32Window owner) - { - //If no owner given: Center on current screen - if (owner == null) - { - var screen = Screen.FromPoint(Cursor.Position); - FlexibleMaterialForm.StartPosition = FormStartPosition.Manual; - FlexibleMaterialForm.Left = screen.Bounds.Left + screen.Bounds.Width / 2 - FlexibleMaterialForm.Width / 2; - FlexibleMaterialForm.Top = screen.Bounds.Top + screen.Bounds.Height / 2 - FlexibleMaterialForm.Height / 2; - } - } - - /// - /// Calculate the dialogs start size (Try to auto-size width to show longest text row). - /// Also set the maximum dialog size. - /// - /// The FlexibleMessageBox dialog. - /// The text (the longest text row is used to calculate the dialog width). - /// The caption - private static void SetDialogSizes(FlexibleMaterialForm FlexibleMaterialForm, string text, string caption) - { - //First set the bounds for the maximum dialog size - FlexibleMaterialForm.MaximumSize = new Size(Convert.ToInt32(SystemInformation.WorkingArea.Width * FlexibleMaterialForm.GetCorrectedWorkingAreaFactor(MAX_WIDTH_FACTOR)), - Convert.ToInt32(SystemInformation.WorkingArea.Height * FlexibleMaterialForm.GetCorrectedWorkingAreaFactor(MAX_HEIGHT_FACTOR))); - - //Get rows. Exit if there are no rows to render... - var stringRows = GetStringRows(text); - if (stringRows == null) - { - return; - } - - //Calculate whole text height - var textHeight = Math.Min(TextRenderer.MeasureText(text, FONT).Height, 600); - - //Calculate width for longest text line - const int SCROLLBAR_WIDTH_OFFSET = 15; - var longestTextRowWidth = stringRows.Max(textForRow => TextRenderer.MeasureText(textForRow, FONT).Width); - var captionWidth = TextRenderer.MeasureText(caption, SystemFonts.CaptionFont).Width; - var textWidth = Math.Max(longestTextRowWidth + SCROLLBAR_WIDTH_OFFSET, captionWidth); - - //Calculate margins - var marginWidth = FlexibleMaterialForm.Width - FlexibleMaterialForm.richTextBoxMessage.Width; - var marginHeight = FlexibleMaterialForm.Height - FlexibleMaterialForm.richTextBoxMessage.Height; - - //Set calculated dialog size (if the calculated values exceed the maximums, they were cut by windows forms automatically) - FlexibleMaterialForm.Size = new Size(textWidth + marginWidth, - textHeight + marginHeight); - } - - /// - /// Set the dialogs icon. - /// When no icon is used: Correct placement and width of rich text box. - /// - /// The FlexibleMessageBox dialog. - /// The MessageBoxIcon. - private static void SetDialogIcon(FlexibleMaterialForm FlexibleMaterialForm, MessageBoxIcon icon) - { - switch (icon) - { - case MessageBoxIcon.Information: - FlexibleMaterialForm.pictureBoxForIcon.Image = SystemIcons.Information.ToBitmap(); - break; - - case MessageBoxIcon.Warning: - FlexibleMaterialForm.pictureBoxForIcon.Image = SystemIcons.Warning.ToBitmap(); - break; - - case MessageBoxIcon.Error: - FlexibleMaterialForm.pictureBoxForIcon.Image = SystemIcons.Error.ToBitmap(); - break; - - case MessageBoxIcon.Question: - FlexibleMaterialForm.pictureBoxForIcon.Image = SystemIcons.Question.ToBitmap(); - break; - - default: - //When no icon is used: Correct placement and width of rich text box. - FlexibleMaterialForm.pictureBoxForIcon.Visible = false; - FlexibleMaterialForm.richTextBoxMessage.Left -= FlexibleMaterialForm.pictureBoxForIcon.Width; - FlexibleMaterialForm.richTextBoxMessage.Width += FlexibleMaterialForm.pictureBoxForIcon.Width; - break; - } - } - - /// - /// Set dialog buttons visibilities and texts. - /// Also set a default button. - /// - /// The FlexibleMessageBox dialog. - /// The buttons. - /// The default button. - private static void SetDialogButtons(FlexibleMaterialForm FlexibleMaterialForm, MessageBoxButtons buttons, MessageBoxDefaultButton defaultButton) - { - //Set the buttons visibilities and texts - switch (buttons) - { - case MessageBoxButtons.AbortRetryIgnore: - FlexibleMaterialForm.visibleButtonsCount = 3; - - FlexibleMaterialForm.leftButton.Visible = true; - FlexibleMaterialForm.leftButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.ABORT); - FlexibleMaterialForm.leftButton.DialogResult = DialogResult.Abort; - - FlexibleMaterialForm.middleButton.Visible = true; - FlexibleMaterialForm.middleButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.RETRY); - FlexibleMaterialForm.middleButton.DialogResult = DialogResult.Retry; - - FlexibleMaterialForm.rightButton.Visible = true; - FlexibleMaterialForm.rightButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.IGNORE); - FlexibleMaterialForm.rightButton.DialogResult = DialogResult.Ignore; - - FlexibleMaterialForm.ControlBox = false; - break; - - case MessageBoxButtons.OKCancel: - FlexibleMaterialForm.visibleButtonsCount = 2; - - FlexibleMaterialForm.middleButton.Visible = true; - FlexibleMaterialForm.middleButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.CANCEL); - FlexibleMaterialForm.middleButton.DialogResult = DialogResult.Cancel; - - FlexibleMaterialForm.rightButton.Visible = true; - FlexibleMaterialForm.rightButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.OK); - FlexibleMaterialForm.rightButton.DialogResult = DialogResult.OK; - - FlexibleMaterialForm.CancelButton = FlexibleMaterialForm.middleButton; - break; - - case MessageBoxButtons.RetryCancel: - FlexibleMaterialForm.visibleButtonsCount = 2; - - FlexibleMaterialForm.middleButton.Visible = true; - FlexibleMaterialForm.middleButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.CANCEL); - FlexibleMaterialForm.middleButton.DialogResult = DialogResult.Cancel; - - FlexibleMaterialForm.rightButton.Visible = true; - FlexibleMaterialForm.rightButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.RETRY); - FlexibleMaterialForm.rightButton.DialogResult = DialogResult.Retry; - - FlexibleMaterialForm.CancelButton = FlexibleMaterialForm.middleButton; - break; - - case MessageBoxButtons.YesNo: - FlexibleMaterialForm.visibleButtonsCount = 2; - - FlexibleMaterialForm.middleButton.Visible = true; - FlexibleMaterialForm.middleButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.NO); - FlexibleMaterialForm.middleButton.DialogResult = DialogResult.No; - - FlexibleMaterialForm.rightButton.Visible = true; - FlexibleMaterialForm.rightButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.YES); - FlexibleMaterialForm.rightButton.DialogResult = DialogResult.Yes; - - FlexibleMaterialForm.ControlBox = false; - break; - - case MessageBoxButtons.YesNoCancel: - FlexibleMaterialForm.visibleButtonsCount = 3; - - FlexibleMaterialForm.rightButton.Visible = true; - FlexibleMaterialForm.rightButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.YES); - FlexibleMaterialForm.rightButton.DialogResult = DialogResult.Yes; - - FlexibleMaterialForm.middleButton.Visible = true; - FlexibleMaterialForm.middleButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.NO); - FlexibleMaterialForm.middleButton.DialogResult = DialogResult.No; - - FlexibleMaterialForm.leftButton.Visible = true; - FlexibleMaterialForm.leftButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.CANCEL); - FlexibleMaterialForm.leftButton.DialogResult = DialogResult.Cancel; - - FlexibleMaterialForm.CancelButton = FlexibleMaterialForm.leftButton; - break; - - case MessageBoxButtons.OK: - default: - FlexibleMaterialForm.visibleButtonsCount = 1; - FlexibleMaterialForm.rightButton.Visible = true; - FlexibleMaterialForm.rightButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.OK); - FlexibleMaterialForm.rightButton.DialogResult = DialogResult.OK; - - FlexibleMaterialForm.CancelButton = FlexibleMaterialForm.rightButton; - break; - } - - //Set default button (used in FlexibleMaterialForm_Shown) - FlexibleMaterialForm.defaultButton = defaultButton; - } - - /// - /// Handles the Shown event of the FlexibleMaterialForm control. - /// - /// The source of the event. - /// The instance containing the event data. - private void FlexibleMaterialForm_Shown(object sender, EventArgs e) - { - int buttonIndexToFocus = 1; - Button buttonToFocus; - - //Set the default button... - switch (this.defaultButton) - { - case MessageBoxDefaultButton.Button1: - default: - buttonIndexToFocus = 1; - break; - - case MessageBoxDefaultButton.Button2: - buttonIndexToFocus = 2; - break; - - case MessageBoxDefaultButton.Button3: - buttonIndexToFocus = 3; - break; - } - - if (buttonIndexToFocus > this.visibleButtonsCount) - { - buttonIndexToFocus = this.visibleButtonsCount; - } - - if (buttonIndexToFocus == 3) - { - buttonToFocus = this.rightButton; - } - else if (buttonIndexToFocus == 2) - { - buttonToFocus = this.middleButton; - } - else - { - buttonToFocus = this.leftButton; - } - - buttonToFocus.Focus(); - } - - /// - /// Handles the LinkClicked event of the richTextBoxMessage control. - /// - /// The source of the event. - /// The instance containing the event data. - private void richTextBoxMessage_LinkClicked(object sender, LinkClickedEventArgs e) - { - try - { - Cursor.Current = Cursors.WaitCursor; - Process.Start(e.LinkText); - } - catch (Exception) - { - //Let the caller of FlexibleMaterialForm decide what to do with this exception... - throw; - } - finally - { - Cursor.Current = Cursors.Default; - } - } - - /// - /// Handles the KeyUp event of the richTextBoxMessage control. - /// - /// The source of the event. - /// The instance containing the event data. - internal void FlexibleMaterialForm_KeyUp(object sender, KeyEventArgs e) - { - //Handle standard key strikes for clipboard copy: "Ctrl + C" and "Ctrl + Insert" - if (e.Control && (e.KeyCode == Keys.C || e.KeyCode == Keys.Insert)) - { - var buttonsTextLine = (this.leftButton.Visible ? this.leftButton.Text + STANDARD_MESSAGEBOX_SEPARATOR_SPACES : string.Empty) - + (this.middleButton.Visible ? this.middleButton.Text + STANDARD_MESSAGEBOX_SEPARATOR_SPACES : string.Empty) - + (this.rightButton.Visible ? this.rightButton.Text + STANDARD_MESSAGEBOX_SEPARATOR_SPACES : string.Empty); - - //Build same clipboard text like the standard .Net MessageBox - var textForClipboard = STANDARD_MESSAGEBOX_SEPARATOR_LINES - + this.Text + Environment.NewLine - + STANDARD_MESSAGEBOX_SEPARATOR_LINES - + this.richTextBoxMessage.Text + Environment.NewLine - + STANDARD_MESSAGEBOX_SEPARATOR_LINES - + buttonsTextLine.Replace("&", string.Empty) + Environment.NewLine - + STANDARD_MESSAGEBOX_SEPARATOR_LINES; - - //Set text in clipboard - Clipboard.SetText(textForClipboard); - } - } - - /// - /// Gets or sets the CaptionText - /// The text that is been used for the heading. - /// - public string CaptionText { get; set; } - - /// - /// Gets or sets the MessageText - /// The text that is been used in the FlexibleMaterialForm. - /// - public string MessageText { get; set; } - - /// - /// Shows the specified message box. - /// - /// The owner. - /// The text. - /// The caption. - /// The buttons. - /// The icon. - /// The default button. - /// The dialog result. - public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton) - { - //Create a new instance of the FlexibleMessageBox form - var FlexibleMaterialForm = new FlexibleMaterialForm(); - FlexibleMaterialForm.ShowInTaskbar = false; - - //Bind the caption and the message text - FlexibleMaterialForm.CaptionText = caption; - FlexibleMaterialForm.MessageText = text; - FlexibleMaterialForm.FlexibleMaterialFormBindingSource.DataSource = FlexibleMaterialForm; - - //Set the buttons visibilities and texts. Also set a default button. - SetDialogButtons(FlexibleMaterialForm, buttons, defaultButton); - - //Set the dialogs icon. When no icon is used: Correct placement and width of rich text box. - SetDialogIcon(FlexibleMaterialForm, icon); - - //Set the font for all controls - FlexibleMaterialForm.Font = FONT; - FlexibleMaterialForm.richTextBoxMessage.Font = FONT; - - //Calculate the dialogs start size (Try to auto-size width to show longest text row). Also set the maximum dialog size. - SetDialogSizes(FlexibleMaterialForm, text, caption); - - //Set the dialogs start position when given. Otherwise center the dialog on the current screen. - SetDialogStartPosition(FlexibleMaterialForm, owner); - - //Show the dialog - return FlexibleMaterialForm.ShowDialog(owner); - } - - private void FlexibleMaterialForm_Load(object sender, EventArgs e) - { - } - } -} \ No newline at end of file + + /// + /// Defines the it + /// + it, + + /// + /// Defines the fr + /// + fr, + + /// + /// Defines the ro + /// + ro, + + /// + /// Defines the pl + /// + pl, + /// + /// Defines the fa + /// + fa + }; + + /// + /// Defines the BUTTON_TEXTS_ENGLISH_EN + /// + private static readonly String[] BUTTON_TEXTS_ENGLISH_EN = { "OK", "Cancel", "&Yes", "&No", "&Abort", "&Retry", "&Ignore" };//Note: This is also the fallback language + + /// + /// Defines the BUTTON_TEXTS_GERMAN_DE + /// + private static readonly String[] BUTTON_TEXTS_GERMAN_DE = { "OK", "Abbrechen", "&Ja", "&Nein", "&Abbrechen", "&Wiederholen", "&Ignorieren" }; + + /// + /// Defines the BUTTON_TEXTS_SPANISH_ES + /// + private static readonly String[] BUTTON_TEXTS_SPANISH_ES = { "Aceptar", "Cancelar", "&Sí", "&No", "&Abortar", "&Reintentar", "&Ignorar" }; + + /// + /// Defines the BUTTON_TEXTS_ITALIAN_IT + /// + private static readonly String[] BUTTON_TEXTS_ITALIAN_IT = { "OK", "Annulla", "&Sì", "&No", "&Interrompi", "&Riprova", "&Ignora" }; + + /// + /// Defines the BUTTON_TEXTS_FRENCH_FR + /// + private static readonly String[] BUTTON_TEXTS_FRENCH_FR = { "OK", "Annuler", "&Oui", "&Non", "&Interrompre", "&Recommencer", "&Ignorer" }; + + /// + /// Defines the BUTTON_TEXTS_ROMANIAN_RO + /// + private static readonly String[] BUTTON_TEXTS_ROMANIAN_RO = { "Acceptă", "Anulează", "&Da", "&Nu", "&Întrerupe", "&Reîncearcă", "&Ignoră" }; + + /// + /// Defines the BUTTON_TEXTS_ROMANIAN_PL + /// + private static readonly String[] BUTTON_TEXTS_POLISH_PL = { "OK", "Anuluj", "Tak", "Nie", "Opuść", "Powtórz", "Ignoruj" }; + + /// + /// Defines the BUTTON_TEXTS_ROMANIAN_PL + /// + private static readonly String[] BUTTON_TEXTS_PERSIAN_FA = { "حله", "انصراف", "بله", "خیر", "بیخیال", "دوباره", "رد‌ کن" };//Note: This is also the fallback language + + /// + /// Defines the defaultButton + /// + private MessageBoxDefaultButton defaultButton; + + /// + /// Defines the visibleButtonsCount + /// + private int visibleButtonsCount; + + /// + /// Defines the languageID + /// + private TwoLetterISOLanguageID languageID = TwoLetterISOLanguageID.en; + + /// + /// Prevents a default instance of the class from being created. + /// + private FlexibleMaterialForm(RightToLeft rightToLeft) :base(rightToLeft) + { + InitializeComponent(); + + //Try to evaluate the language. If this fails, the fallback language English will be used + Enum.TryParse(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName, out this.languageID); + + this.KeyPreview = true; + this.KeyUp += FlexibleMaterialForm_KeyUp; + + materialSkinManager = MaterialSkinManager.Instance; + materialSkinManager.AddFormToManage(this); + FONT = materialSkinManager.getFontByType(MaterialSkinManager.fontType.Body1, rightToLeft); + messageContainer.BackColor = this.BackColor; + } + + /// + /// Gets the string rows. + /// + /// The message. + /// The string rows as 1-dimensional array + private static string[] GetStringRows(string message) + { + if (string.IsNullOrEmpty(message)) + { + return null; + } + + var messageRows = message.Split(new char[] { '\n' }, StringSplitOptions.None); + return messageRows; + } + + /// + /// Gets the button text for the CurrentUICulture language. + /// Note: The fallback language is English + /// + /// The ID of the button. + /// The button text + private string GetButtonText(ButtonID buttonID) + { + var buttonTextArrayIndex = Convert.ToInt32(buttonID); + + switch (this.languageID) + { + case TwoLetterISOLanguageID.de: return BUTTON_TEXTS_GERMAN_DE[buttonTextArrayIndex]; + case TwoLetterISOLanguageID.es: return BUTTON_TEXTS_SPANISH_ES[buttonTextArrayIndex]; + case TwoLetterISOLanguageID.it: return BUTTON_TEXTS_ITALIAN_IT[buttonTextArrayIndex]; + case TwoLetterISOLanguageID.fr: return BUTTON_TEXTS_FRENCH_FR[buttonTextArrayIndex]; + case TwoLetterISOLanguageID.ro: return BUTTON_TEXTS_ROMANIAN_RO[buttonTextArrayIndex]; + case TwoLetterISOLanguageID.pl: return BUTTON_TEXTS_POLISH_PL[buttonTextArrayIndex]; + case TwoLetterISOLanguageID.fa: return BUTTON_TEXTS_PERSIAN_FA[buttonTextArrayIndex]; + + default: return BUTTON_TEXTS_ENGLISH_EN[buttonTextArrayIndex]; + } + } + + /// + /// Ensure the given working area factor in the range of 0.2 - 1.0 where: + /// + /// 0.2 means: 20 percent of the working area height or width. + /// 1.0 means: 100 percent of the working area height or width. + /// + /// The given working area factor. + /// The corrected given working area factor. + private static double GetCorrectedWorkingAreaFactor(double workingAreaFactor) + { + const double MIN_FACTOR = 0.2; + const double MAX_FACTOR = 1.0; + + if (workingAreaFactor < MIN_FACTOR) + { + return MIN_FACTOR; + } + + if (workingAreaFactor > MAX_FACTOR) + { + return MAX_FACTOR; + } + + return workingAreaFactor; + } + + /// + /// Set the dialogs start position when given. + /// Otherwise center the dialog on the current screen. + /// + /// The FlexibleMessageBox dialog. + /// The owner. + private static void SetDialogStartPosition(FlexibleMaterialForm FlexibleMaterialForm, IWin32Window owner) + { + //If no owner given: Center on current screen + if (owner == null) + { + var screen = Screen.FromPoint(Cursor.Position); + FlexibleMaterialForm.StartPosition = FormStartPosition.Manual; + FlexibleMaterialForm.Left = screen.Bounds.Left + screen.Bounds.Width / 2 - FlexibleMaterialForm.Width / 2; + FlexibleMaterialForm.Top = screen.Bounds.Top + screen.Bounds.Height / 2 - FlexibleMaterialForm.Height / 2; + } + } + + /// + /// Calculate the dialogs start size (Try to auto-size width to show longest text row). + /// Also set the maximum dialog size. + /// + /// The FlexibleMessageBox dialog. + /// The text (the longest text row is used to calculate the dialog width). + /// The caption + private static void SetDialogSizes(FlexibleMaterialForm FlexibleMaterialForm, string text, string caption) + { + //First set the bounds for the maximum dialog size + FlexibleMaterialForm.MaximumSize = new Size(Convert.ToInt32(SystemInformation.WorkingArea.Width * FlexibleMaterialForm.GetCorrectedWorkingAreaFactor(MAX_WIDTH_FACTOR)), + Convert.ToInt32(SystemInformation.WorkingArea.Height * FlexibleMaterialForm.GetCorrectedWorkingAreaFactor(MAX_HEIGHT_FACTOR))); + + //Get rows. Exit if there are no rows to render... + var stringRows = GetStringRows(text); + if (stringRows == null) + { + return; + } + + //Calculate whole text height + var textHeight = Math.Min(TextRenderer.MeasureText(text, FONT).Height, 600); + + //Calculate width for longest text line + const int SCROLLBAR_WIDTH_OFFSET = 15; + var longestTextRowWidth = stringRows.Max(textForRow => TextRenderer.MeasureText(textForRow, FONT).Width); + var captionWidth = TextRenderer.MeasureText(caption, SystemFonts.CaptionFont).Width; + var textWidth = Math.Max(longestTextRowWidth + SCROLLBAR_WIDTH_OFFSET, captionWidth); + + //Calculate margins + var marginWidth = FlexibleMaterialForm.Width - FlexibleMaterialForm.richTextBoxMessage.Width; + var marginHeight = FlexibleMaterialForm.Height - FlexibleMaterialForm.richTextBoxMessage.Height; + + var minimumHeight = FlexibleMaterialForm.messageContainer.Top + (FlexibleMaterialForm.pictureBoxForIcon.Height + 2 * 8) + 54; + if (marginHeight < minimumHeight) marginHeight = minimumHeight; + + //Set calculated dialog size (if the calculated values exceed the maximums, they were cut by windows forms automatically) + FlexibleMaterialForm.Size = new Size(textWidth + marginWidth, + textHeight + marginHeight); + } + + /// + /// Set the dialogs icon. + /// When no icon is used: Correct placement and width of rich text box. + /// + /// The FlexibleMessageBox dialog. + /// The MessageBoxIcon. + private static void SetDialogIcon(FlexibleMaterialForm FlexibleMaterialForm, MessageBoxIcon icon) + { + switch (icon) + { + case MessageBoxIcon.Information: + FlexibleMaterialForm.pictureBoxForIcon.Image = SystemIcons.Information.ToBitmap(); + break; + + case MessageBoxIcon.Warning: + FlexibleMaterialForm.pictureBoxForIcon.Image = SystemIcons.Warning.ToBitmap(); + break; + + case MessageBoxIcon.Error: + FlexibleMaterialForm.pictureBoxForIcon.Image = SystemIcons.Error.ToBitmap(); + break; + + case MessageBoxIcon.Question: + FlexibleMaterialForm.pictureBoxForIcon.Image = SystemIcons.Question.ToBitmap(); + break; + + default: + //When no icon is used: Correct placement and width of rich text box. + FlexibleMaterialForm.pictureBoxForIcon.Visible = false; + FlexibleMaterialForm.richTextBoxMessage.Left -= FlexibleMaterialForm.pictureBoxForIcon.Width; + FlexibleMaterialForm.richTextBoxMessage.Width += FlexibleMaterialForm.pictureBoxForIcon.Width; + break; + } + } + + /// + /// Set dialog buttons visibilities and texts. + /// Also set a default button. + /// + /// The FlexibleMessageBox dialog. + /// The buttons. + /// The default button. + private static void SetDialogButtons(FlexibleMaterialForm FlexibleMaterialForm, MessageBoxButtons buttons, MessageBoxDefaultButton defaultButton, ButtonsPosition buttonsPosition) + { + //Set the buttons visibilities and texts + switch (buttons) + { + case MessageBoxButtons.AbortRetryIgnore: + FlexibleMaterialForm.visibleButtonsCount = 3; + + FlexibleMaterialForm.leftButton.Visible = true; + FlexibleMaterialForm.leftButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.ABORT); + FlexibleMaterialForm.leftButton.DialogResult = DialogResult.Abort; + + FlexibleMaterialForm.middleButton.Visible = true; + FlexibleMaterialForm.middleButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.RETRY); + FlexibleMaterialForm.middleButton.DialogResult = DialogResult.Retry; + + FlexibleMaterialForm.rightButton.Visible = true; + FlexibleMaterialForm.rightButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.IGNORE); + FlexibleMaterialForm.rightButton.DialogResult = DialogResult.Ignore; + + FlexibleMaterialForm.ControlBox = false; + break; + + case MessageBoxButtons.OKCancel: + FlexibleMaterialForm.visibleButtonsCount = 2; + + FlexibleMaterialForm.middleButton.Visible = true; + FlexibleMaterialForm.middleButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.CANCEL); + FlexibleMaterialForm.middleButton.DialogResult = DialogResult.Cancel; + + FlexibleMaterialForm.rightButton.Visible = true; + FlexibleMaterialForm.rightButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.OK); + FlexibleMaterialForm.rightButton.DialogResult = DialogResult.OK; + + FlexibleMaterialForm.CancelButton = FlexibleMaterialForm.middleButton; + break; + + case MessageBoxButtons.RetryCancel: + FlexibleMaterialForm.visibleButtonsCount = 2; + + FlexibleMaterialForm.middleButton.Visible = true; + FlexibleMaterialForm.middleButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.CANCEL); + FlexibleMaterialForm.middleButton.DialogResult = DialogResult.Cancel; + + FlexibleMaterialForm.rightButton.Visible = true; + FlexibleMaterialForm.rightButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.RETRY); + FlexibleMaterialForm.rightButton.DialogResult = DialogResult.Retry; + + FlexibleMaterialForm.CancelButton = FlexibleMaterialForm.middleButton; + break; + + case MessageBoxButtons.YesNo: + FlexibleMaterialForm.visibleButtonsCount = 2; + + FlexibleMaterialForm.middleButton.Visible = true; + FlexibleMaterialForm.middleButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.NO); + FlexibleMaterialForm.middleButton.DialogResult = DialogResult.No; + + FlexibleMaterialForm.rightButton.Visible = true; + FlexibleMaterialForm.rightButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.YES); + FlexibleMaterialForm.rightButton.DialogResult = DialogResult.Yes; + + //FlexibleMaterialForm.ControlBox = false; + break; + + case MessageBoxButtons.YesNoCancel: + FlexibleMaterialForm.visibleButtonsCount = 3; + + FlexibleMaterialForm.rightButton.Visible = true; + FlexibleMaterialForm.rightButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.YES); + FlexibleMaterialForm.rightButton.DialogResult = DialogResult.Yes; + + FlexibleMaterialForm.middleButton.Visible = true; + FlexibleMaterialForm.middleButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.NO); + FlexibleMaterialForm.middleButton.DialogResult = DialogResult.No; + + FlexibleMaterialForm.leftButton.Visible = true; + FlexibleMaterialForm.leftButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.CANCEL); + FlexibleMaterialForm.leftButton.DialogResult = DialogResult.Cancel; + + FlexibleMaterialForm.CancelButton = FlexibleMaterialForm.leftButton; + break; + + case MessageBoxButtons.OK: + default: + FlexibleMaterialForm.visibleButtonsCount = 1; + FlexibleMaterialForm.rightButton.Visible = true; + FlexibleMaterialForm.rightButton.Text = FlexibleMaterialForm.GetButtonText(ButtonID.OK); + FlexibleMaterialForm.rightButton.DialogResult = DialogResult.OK; + + FlexibleMaterialForm.CancelButton = FlexibleMaterialForm.rightButton; + break; + } + + //Set default button (used in FlexibleMaterialForm_Shown) + FlexibleMaterialForm.defaultButton = defaultButton; + + SetButtonsPosition(FlexibleMaterialForm, buttonsPosition); + } + + /// + /// Handles the Shown event of the FlexibleMaterialForm control. + /// + /// The source of the event. + /// The instance containing the event data. + private void FlexibleMaterialForm_Shown(object sender, EventArgs e) + { + int buttonIndexToFocus = 1; + Button buttonToFocus; + + //Set the default button... + switch (this.defaultButton) + { + case MessageBoxDefaultButton.Button1: + default: + buttonIndexToFocus = 1; + break; + + case MessageBoxDefaultButton.Button2: + buttonIndexToFocus = 2; + break; + + case MessageBoxDefaultButton.Button3: + buttonIndexToFocus = 3; + break; + } + + if (buttonIndexToFocus > this.visibleButtonsCount) + { + buttonIndexToFocus = this.visibleButtonsCount; + } + + if (buttonIndexToFocus == 3) + { + buttonToFocus = this.rightButton; + } + else if (buttonIndexToFocus == 2) + { + buttonToFocus = this.middleButton; + } + else + { + buttonToFocus = this.leftButton; + } + + buttonToFocus.Focus(); + } + + /// + /// Handles the LinkClicked event of the richTextBoxMessage control. + /// + /// The source of the event. + /// The instance containing the event data. + private void richTextBoxMessage_LinkClicked(object sender, LinkClickedEventArgs e) + { + try + { + Cursor.Current = Cursors.WaitCursor; + Process.Start(e.LinkText); + } + catch (Exception) + { + //Let the caller of FlexibleMaterialForm decide what to do with this exception... + throw; + } + finally + { + Cursor.Current = Cursors.Default; + } + } + + /// + /// Handles the KeyUp event of the richTextBoxMessage control. + /// + /// The source of the event. + /// The instance containing the event data. + internal void FlexibleMaterialForm_KeyUp(object sender, KeyEventArgs e) + { + //Handle standard key strikes for clipboard copy: "Ctrl + C" and "Ctrl + Insert" + if (e.Control && (e.KeyCode == Keys.C || e.KeyCode == Keys.Insert)) + { + var buttonsTextLine = (this.leftButton.Visible ? this.leftButton.Text + STANDARD_MESSAGEBOX_SEPARATOR_SPACES : string.Empty) + + (this.middleButton.Visible ? this.middleButton.Text + STANDARD_MESSAGEBOX_SEPARATOR_SPACES : string.Empty) + + (this.rightButton.Visible ? this.rightButton.Text + STANDARD_MESSAGEBOX_SEPARATOR_SPACES : string.Empty); + + //Build same clipboard text like the standard .Net MessageBox + var textForClipboard = STANDARD_MESSAGEBOX_SEPARATOR_LINES + + this.Text + Environment.NewLine + + STANDARD_MESSAGEBOX_SEPARATOR_LINES + + this.richTextBoxMessage.Text + Environment.NewLine + + STANDARD_MESSAGEBOX_SEPARATOR_LINES + + buttonsTextLine.Replace("&", string.Empty) + Environment.NewLine + + STANDARD_MESSAGEBOX_SEPARATOR_LINES; + + //Set text in clipboard + Clipboard.SetText(textForClipboard); + } + } + + /// + /// Gets or sets the CaptionText + /// The text that is been used for the heading. + /// + public string CaptionText { get; set; } + + /// + /// Gets or sets the MessageText + /// The text that is been used in the FlexibleMaterialForm. + /// + public string MessageText { get; set; } + + /// + /// Shows the specified message box. + /// + /// The owner. + /// The text. + /// The caption. + /// The buttons. + /// The icon. + /// The default button. + /// The dialog result. + public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, bool UseRichTextBox = true, ButtonsPosition buttonsPosition = ButtonsPosition.Right,RightToLeft RightToLeft=RightToLeft.No) + { + //Create a new instance of the FlexibleMessageBox form + var FlexibleMaterialForm = new FlexibleMaterialForm(RightToLeft); + FlexibleMaterialForm.ShowInTaskbar = false; + FlexibleMaterialForm.Sizable = false; + + //Bind the caption and the message text + FlexibleMaterialForm.CaptionText = caption; + FlexibleMaterialForm.MessageText = text; + FlexibleMaterialForm.FlexibleMaterialFormBindingSource.DataSource = FlexibleMaterialForm; + + + //Set the dialogs icon. When no icon is used: Correct placement and width of rich text box. + SetDialogIcon(FlexibleMaterialForm, icon); + + //Set the font for all controls + FlexibleMaterialForm.Font = FONT; + FlexibleMaterialForm.richTextBoxMessage.Font = FONT; + FlexibleMaterialForm.richTextBoxMessage.Visible = UseRichTextBox; + FlexibleMaterialForm.materialLabel1.Font = FONT; + FlexibleMaterialForm.materialLabel1.Visible = !UseRichTextBox; + + //Calculate the dialogs start size (Try to auto-size width to show longest text row). Also set the maximum dialog size. + SetDialogSizes(FlexibleMaterialForm, text, caption); + + //Set the dialogs start position when given. Otherwise center the dialog on the current screen. + SetDialogStartPosition(FlexibleMaterialForm, owner); + + + //Set the buttons visibilities and texts. Also set a default button. + //Moved after SetDialogSizes() because it needs Dialog.Width property set. + SetDialogButtons(FlexibleMaterialForm, buttons, defaultButton, buttonsPosition); + //Show the dialog + return FlexibleMaterialForm.ShowDialog(owner); + } + + private void FlexibleMaterialForm_Load(object sender, EventArgs e) + { + } + + private static void SetButtonsPosition(FlexibleMaterialForm fMF, ButtonsPosition buttonsPosition) + { + const int padding = 10; + int visibleButtonsWidth = 0; + switch (buttonsPosition) + { + case ButtonsPosition.Center: + switch (fMF.visibleButtonsCount) + { + case 3: + fMF.middleButton.Left = fMF.Width / 2 - fMF.middleButton.Width / 2; + fMF.leftButton.Left = fMF.middleButton.Left - fMF.leftButton.Width - padding * 2; + fMF.rightButton.Left = fMF.middleButton.Right + padding * 2; + visibleButtonsWidth = fMF.leftButton.Width + fMF.middleButton.Width + fMF.rightButton.Width + padding * 6; + break; + case 2: + fMF.middleButton.Left = fMF.Width / 2 - fMF.middleButton.Width - padding; + fMF.rightButton.Left = fMF.Width / 2 + padding; + visibleButtonsWidth = fMF.middleButton.Width + fMF.rightButton.Width + padding * 4; + break; + case 1: + fMF.rightButton.Left = fMF.Width / 2 - fMF.rightButton.Width / 2; + visibleButtonsWidth = fMF.rightButton.Width + padding * 2; + break; + default: + break; + } + break; + case ButtonsPosition.Left: + switch (fMF.visibleButtonsCount) + { + case 3: + fMF.leftButton.Left = padding; + fMF.middleButton.Left = fMF.leftButton.Right + padding * 2; + fMF.rightButton.Left = fMF.middleButton.Right + padding * 2; + visibleButtonsWidth = fMF.leftButton.Width + fMF.middleButton.Width + fMF.rightButton.Width + padding * 6; + break; + case 2: + fMF.middleButton.Left = padding; + fMF.rightButton.Left = fMF.middleButton.Right + padding * 2; + visibleButtonsWidth = fMF.middleButton.Width + fMF.rightButton.Width + padding * 4; + break; + case 1: + fMF.rightButton.Left = padding; + visibleButtonsWidth = fMF.rightButton.Width + padding * 2; + break; + default: + break; + } + break; + case ButtonsPosition.Right: + // This alignment is simplest, in this alignment doesn't care how many buttons are visible. + // Always the buttons visibility order is right, right + middle, right + middle + left + fMF.rightButton.Left = fMF.Width - fMF.rightButton.Width - padding; + fMF.middleButton.Left = fMF.rightButton.Left - fMF.middleButton.Width - padding * 2; + fMF.leftButton.Left = fMF.middleButton.Left - fMF.leftButton.Width - padding * 2; + switch (fMF.visibleButtonsCount) + { + case 3: + visibleButtonsWidth = fMF.leftButton.Width + fMF.middleButton.Width + fMF.rightButton.Width + padding * 6; + break; + case 2: + visibleButtonsWidth = fMF.middleButton.Width + fMF.rightButton.Width + padding * 4; + break; + case 1: + visibleButtonsWidth = fMF.rightButton.Width + padding * 2; + break; + default: + break; + } + break; + case ButtonsPosition.Fill: + switch (fMF.visibleButtonsCount) + { + case 3: + fMF.leftButton.Left = padding; + fMF.middleButton.Left = fMF.Width / 2 - fMF.middleButton.Width / 2; + fMF.rightButton.Left = fMF.Width - fMF.rightButton.Width - padding * 2; + visibleButtonsWidth = fMF.leftButton.Width + fMF.middleButton.Width + fMF.rightButton.Width + padding * 6; + break; + case 2: + fMF.middleButton.Left = padding; + fMF.rightButton.Left = fMF.Width - fMF.rightButton.Width - padding * 2; + visibleButtonsWidth = fMF.middleButton.Width + fMF.rightButton.Width + padding * 4; + break; + case 1: + fMF.rightButton.Left = fMF.Width / 2 - fMF.middleButton.Width / 2; + visibleButtonsWidth = fMF.rightButton.Width + padding * 2; + break; + default: + break; + } + break; + } + fMF.Width = Math.Max(fMF.Width, visibleButtonsWidth); + } + } +} diff --git a/MaterialSkin/Controls/MaterialButton.cs b/MaterialSkin/Controls/MaterialButton.cs index bfda5089..2ed50adf 100644 --- a/MaterialSkin/Controls/MaterialButton.cs +++ b/MaterialSkin/Controls/MaterialButton.cs @@ -1,468 +1,682 @@ -namespace MaterialSkin.Controls -{ - using MaterialSkin.Animations; - using System; - using System.ComponentModel; - using System.Drawing; - using System.Drawing.Drawing2D; - using System.Drawing.Text; - using System.Windows.Forms; - - /// - /// Defines the - /// - public class MaterialButton : Button, IMaterialControl - { - /// - /// Gets or sets the Depth - /// - [Browsable(false)] - public int Depth { get; set; } - - /// - /// Gets the SkinManager - /// - [Browsable(false)] - public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; - - /// - /// Gets or sets the MouseState - /// - [Browsable(false)] - public MouseState MouseState { get; set; } - - public enum MaterialButtonType - { - Text, - Outlined, - Contained - } - - public bool UseAccentColor - { - get { return useAccentColor; } - set { useAccentColor = value; Invalidate(); } - } - - /// - /// Gets or sets a value indicating whether HighEmphasis - /// - public bool HighEmphasis - { - get { return highEmphasis; } - set { highEmphasis = value; Invalidate(); } - } - - public bool DrawShadows - { - get { return drawShadows; } - set { drawShadows = value; Invalidate(); } - } - - /// - /// Gets or sets a value indicating whether HighEmphasis - /// - public MaterialButtonType Type - { - get { return type; } - set { type = value; Invalidate(); } - } - - protected override void InitLayout() - { - base.InitLayout(); - Invalidate(); - LocationChanged += (sender, e) => { if (DrawShadows) Parent?.Invalidate(); }; - } - - protected override void OnParentChanged(EventArgs e) - { - base.OnParentChanged(e); - if (drawShadows && Parent != null) AddShadowPaintEvent(Parent, drawShadowOnParent); - if (_oldParent != null) RemoveShadowPaintEvent(_oldParent, drawShadowOnParent); - _oldParent = Parent; - } - - private Control _oldParent; - - protected override void OnVisibleChanged(EventArgs e) - { - base.OnVisibleChanged(e); - if (Parent == null) return; - if (Visible) - AddShadowPaintEvent(Parent, drawShadowOnParent); - else - RemoveShadowPaintEvent(Parent, drawShadowOnParent); - } - +namespace MaterialSkin.Controls +{ + using MaterialSkin.Animations; + using System; + using System.ComponentModel; + using System.Drawing; + using System.Drawing.Drawing2D; + using System.Drawing.Imaging; + using System.Drawing.Text; + using System.Globalization; + using System.Windows.Forms; + + /// + /// Defines the + /// + public class MaterialButton : Button, IMaterialControl + { + + private const int ICON_SIZE = 24; + private const int MINIMUMWIDTH = 64; + private const int MINIMUMWIDTHICONONLY = 36; //64; + private const int HEIGHTDEFAULT = 36; + private const int HEIGHTDENSE = 32; + + // icons + private TextureBrush iconsBrushes; + + /// + /// Gets or sets the Depth + /// + [Browsable(false)] + public int Depth { get; set; } + + /// + /// Gets the SkinManager + /// + [Browsable(false)] + public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; + + /// + /// Gets or sets the MouseState + /// + [Browsable(false)] + public MouseState MouseState { get; set; } + + public enum MaterialButtonType + { + Text, + Outlined, + Contained + } + + public enum MaterialButtonDensity + { + Default, + Dense + } + + [Browsable(false)] + public Color NoAccentTextColor { get; set; } + + [Category("Material Skin")] + public bool UseAccentColor + { + get { return useAccentColor; } + set { useAccentColor = value; Invalidate(); } + } + + [Category("Material Skin")] + /// + /// Gets or sets a value indicating whether HighEmphasis + /// + public bool HighEmphasis + { + get { return highEmphasis; } + set { highEmphasis = value; Invalidate(); } + } + + [DefaultValue(true)] + [Category("Material Skin")] + [Description("Draw Shadows around control")] + public bool DrawShadows + { + get { return drawShadows; } + set { drawShadows = value; Invalidate(); } + } + + [Category("Material Skin")] + public MaterialButtonType Type + { + get { return type; } + set { type = value; preProcessIcons(); Invalidate(); } + } + + [Category("Material Skin")] + /// + /// Gets or sets a value indicating button density + /// + public MaterialButtonDensity Density + { + get { return _density; } + set + { + _density = value; + if (_density== MaterialButtonDensity.Dense) + Size = new Size(Size.Width, HEIGHTDENSE); + else + Size = new Size(Size.Width, HEIGHTDEFAULT); + Invalidate(); + } + } + + public enum CharacterCasingEnum + { + Normal, + Lower, + Upper, + Title + } + + public CharacterCasingEnum _cc; + [Category("Behavior"), DefaultValue(CharacterCasingEnum.Upper), Description("Change capitalization of Text property")] + public CharacterCasingEnum CharacterCasing + { + get => _cc; + set + { + _cc = value; + Invalidate(); + } + } + protected override void InitLayout() + { + base.InitLayout(); + Invalidate(); + LocationChanged += (sender, e) => { if (DrawShadows) Parent?.Invalidate(); }; + } + + protected override void OnParentChanged(EventArgs e) + { + base.OnParentChanged(e); + if (drawShadows && Parent != null) AddShadowPaintEvent(Parent, drawShadowOnParent); + if (_oldParent != null) RemoveShadowPaintEvent(_oldParent, drawShadowOnParent); + _oldParent = Parent; + } + + private Control _oldParent; + + protected override void OnVisibleChanged(EventArgs e) + { + base.OnVisibleChanged(e); + if (Parent == null) return; + if (Visible) + AddShadowPaintEvent(Parent, drawShadowOnParent); + else + RemoveShadowPaintEvent(Parent, drawShadowOnParent); + } + + protected override void OnEnabledChanged(EventArgs e) + { + base.OnEnabledChanged(e); + Invalidate(); + } + private bool _shadowDrawEventSubscribed = false; - - private void AddShadowPaintEvent(Control control, PaintEventHandler shadowPaintEvent) - { - if (_shadowDrawEventSubscribed) return; - control.Paint += shadowPaintEvent; - control.Invalidate(); - _shadowDrawEventSubscribed = true; + + private void AddShadowPaintEvent(Control control, PaintEventHandler shadowPaintEvent) + { + if (_shadowDrawEventSubscribed) return; + control.Paint += shadowPaintEvent; + control.Invalidate(); + _shadowDrawEventSubscribed = true; + } + + private void RemoveShadowPaintEvent(Control control, PaintEventHandler shadowPaintEvent) + { + if (!_shadowDrawEventSubscribed) return; + control.Paint -= shadowPaintEvent; + control.Invalidate(); + _shadowDrawEventSubscribed = false; + } + + private readonly AnimationManager _hoverAnimationManager = null; + private readonly AnimationManager _focusAnimationManager = null; + private readonly AnimationManager _animationManager = null; + + /// + /// Defines the _textSize + /// + private SizeF _textSize; + + /// + /// Defines the _icon + /// + private Image _icon; + + private bool drawShadows; + private bool highEmphasis; + private bool useAccentColor; + private MaterialButtonType type; + private MaterialButtonDensity _density; + + [Category("Material Skin")] + /// + /// Gets or sets the Icon + /// + public Image Icon + { + get { return _icon; } + set + { + _icon = value; + preProcessIcons(); + + if (AutoSize) + { + Refresh(); + } + + Invalidate(); + } + } + + [DefaultValue(true)] + public override bool AutoSize + { + get => base.AutoSize; + set => base.AutoSize = value; + } + + /// + /// Initializes a new instance of the class. + /// + public MaterialButton() + { + DrawShadows = true; + HighEmphasis = true; + UseAccentColor = false; + Type = MaterialButtonType.Contained; + Density = MaterialButtonDensity.Default; + NoAccentTextColor = Color.Empty; + CharacterCasing = CharacterCasingEnum.Upper; + + _animationManager = new AnimationManager(false) + { + Increment = 0.03, + AnimationType = AnimationType.EaseOut + }; + _hoverAnimationManager = new AnimationManager + { + Increment = 0.12, + AnimationType = AnimationType.Linear + }; + _focusAnimationManager = new AnimationManager + { + Increment = 0.12, + AnimationType = AnimationType.Linear + }; + SkinManager.ColorSchemeChanged += sender => + { + preProcessIcons(); + }; + + SkinManager.ThemeChanged += sender => + { + preProcessIcons(); + }; + + _hoverAnimationManager.OnAnimationProgress += sender => Invalidate(); + _focusAnimationManager.OnAnimationProgress += sender => Invalidate(); + _animationManager.OnAnimationProgress += sender => Invalidate(); + + AutoSizeMode = AutoSizeMode.GrowAndShrink; + AutoSize = true; + Margin = new Padding(4, 6, 4, 6); + Padding = new Padding(0); + } + + /// + /// Gets or sets the Text + /// + public override string Text + { + get { return base.Text; } + set + { + base.Text = value; + if (!String.IsNullOrEmpty(value)) + _textSize = CreateGraphics().MeasureString(value.ToUpper(), SkinManager.getFontByType(MaterialSkinManager.fontType.Button, RightToLeft)); + else + { + _textSize.Width = 0; + _textSize.Height = 0; + } + + if (AutoSize) + { + Refresh(); + } + + Invalidate(); + } + } + + private void drawShadowOnParent(object sender, PaintEventArgs e) + { + if (Parent == null) + { + RemoveShadowPaintEvent((Control)sender, drawShadowOnParent); + return; + } + + if (!DrawShadows || Type != MaterialButtonType.Contained || Parent == null) return; + + // paint shadow on parent + Graphics gp = e.Graphics; + Rectangle rect = new Rectangle(Location, ClientRectangle.Size); + gp.SmoothingMode = SmoothingMode.AntiAlias; + DrawHelper.DrawSquareShadow(gp, rect); + } + + private void preProcessIcons() + { + if (Icon == null) return; + + int newWidth, newHeight; + //Resize icon if greater than ICON_SIZE + if (Icon.Width> ICON_SIZE || Icon.Height > ICON_SIZE) + { + //calculate aspect ratio + float aspect = Icon.Width / (float)Icon.Height; + + //calculate new dimensions based on aspect ratio + newWidth = (int)(ICON_SIZE * aspect); + newHeight = (int)(newWidth / aspect); + + //if one of the two dimensions exceed the box dimensions + if (newWidth > ICON_SIZE || newHeight > ICON_SIZE) + { + //depending on which of the two exceeds the box dimensions set it as the box dimension and calculate the other one based on the aspect ratio + if (newWidth > newHeight) + { + newWidth = ICON_SIZE; + newHeight = (int)(newWidth / aspect); + } + else + { + newHeight = ICON_SIZE; + newWidth = (int)(newHeight * aspect); + } + } + } + else + { + newWidth = Icon.Width; + newHeight = Icon.Height; + } + + Bitmap IconResized = new Bitmap(Icon, newWidth, newHeight); + + // Calculate lightness and color + float l = (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT & (highEmphasis == false | Enabled == false | Type != MaterialButtonType.Contained)) ? 0f : 1.5f; + + // Create matrices + float[][] matrixGray = { + new float[] { 0, 0, 0, 0, 0}, // Red scale factor + new float[] { 0, 0, 0, 0, 0}, // Green scale factor + new float[] { 0, 0, 0, 0, 0}, // Blue scale factor + new float[] { 0, 0, 0, Enabled ? .7f : .3f, 0}, // alpha scale factor + new float[] { l, l, l, 0, 1}};// offset + + + ColorMatrix colorMatrixGray = new ColorMatrix(matrixGray); + + ImageAttributes grayImageAttributes = new ImageAttributes(); + + // Set color matrices + grayImageAttributes.SetColorMatrix(colorMatrixGray, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); + + // Image Rect + Rectangle destRect = new Rectangle(0, 0, ICON_SIZE, ICON_SIZE); + + // Create a pre-processed copy of the image (GRAY) + Bitmap bgray = new Bitmap(destRect.Width, destRect.Height); + using (Graphics gGray = Graphics.FromImage(bgray)) + { + gGray.DrawImage(IconResized, + new Point[] { + new Point(0, 0), + new Point(destRect.Width, 0), + new Point(0, destRect.Height), + }, + destRect, GraphicsUnit.Pixel, grayImageAttributes); + } + + // added processed image to brush for drawing + TextureBrush textureBrushGray = new TextureBrush(bgray); + + textureBrushGray.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; + + // Translate the brushes to the correct positions + var iconRect = new Rectangle(8, (Height/2 - ICON_SIZE / 2), ICON_SIZE, ICON_SIZE); + + textureBrushGray.TranslateTransform(iconRect.X + iconRect.Width / 2 - IconResized.Width / 2, + iconRect.Y + iconRect.Height / 2 - IconResized.Height / 2); + + iconsBrushes = textureBrushGray; + } + + /// + /// The OnPaint + /// + /// The pevent + protected override void OnPaint(PaintEventArgs pevent) + { + var g = pevent.Graphics; + + g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; + g.SmoothingMode = SmoothingMode.AntiAlias; + + double hoverAnimProgress = _hoverAnimationManager.GetProgress(); + double focusAnimProgress = _focusAnimationManager.GetProgress(); + + g.Clear(Parent.BackColor); + + // button rectand path + RectangleF buttonRectF = new RectangleF(ClientRectangle.Location, ClientRectangle.Size); + buttonRectF.X -= 0.5f; + buttonRectF.Y -= 0.5f; + GraphicsPath buttonPath = DrawHelper.CreateRoundRect(buttonRectF, 4); + + // button shadow (blend with form shadow) + DrawHelper.DrawSquareShadow(g, ClientRectangle); + + if (Type == MaterialButtonType.Contained) + { + // draw button rect + // Disabled + if (!Enabled) + { + using (SolidBrush disabledBrush = new SolidBrush(DrawHelper.BlendColor(Parent.BackColor, SkinManager.BackgroundDisabledColor, SkinManager.BackgroundDisabledColor.A))) + { + g.FillPath(disabledBrush, buttonPath); + } + } + // High emphasis + else if (HighEmphasis) + { + g.FillPath(UseAccentColor ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush, buttonPath); + } + // Mormal + else + { + using (SolidBrush normalBrush = new SolidBrush(SkinManager.BackgroundColor)) + { + g.FillPath(normalBrush, buttonPath); + } + } + } + else + { + g.Clear(Parent.BackColor); + } + + //Hover + if (hoverAnimProgress > 0) + { + using (SolidBrush hoverBrush = new SolidBrush(Color.FromArgb( + (int)(HighEmphasis && Type == MaterialButtonType.Contained ? hoverAnimProgress * 80 : hoverAnimProgress * SkinManager.BackgroundHoverColor.A), (UseAccentColor ? (HighEmphasis && Type == MaterialButtonType.Contained ? + SkinManager.ColorScheme.AccentColor.Lighten(0.5f) : // Contained with Emphasis - with accent + SkinManager.ColorScheme.AccentColor) : // Not Contained Or Low Emphasis - with accent + (Type == MaterialButtonType.Contained && HighEmphasis ? SkinManager.ColorScheme.LightPrimaryColor : // Contained with Emphasis without accent + SkinManager.ColorScheme.PrimaryColor)).RemoveAlpha()))) // Normal or Emphasis without accent + { + g.FillPath(hoverBrush, buttonPath); + } + } + + //Focus + if (focusAnimProgress > 0) + { + using (SolidBrush focusBrush = new SolidBrush(Color.FromArgb( + (int)(HighEmphasis && Type == MaterialButtonType.Contained ? focusAnimProgress * 80 : focusAnimProgress * SkinManager.BackgroundFocusColor.A), (UseAccentColor ? (HighEmphasis && Type == MaterialButtonType.Contained ? + SkinManager.ColorScheme.AccentColor.Lighten(0.5f) : // Contained with Emphasis - with accent + SkinManager.ColorScheme.AccentColor) : // Not Contained Or Low Emphasis - with accent + (Type == MaterialButtonType.Contained && HighEmphasis ? SkinManager.ColorScheme.LightPrimaryColor : // Contained with Emphasis without accent + SkinManager.ColorScheme.PrimaryColor)).RemoveAlpha()))) // Normal or Emphasis without accent + { + g.FillPath(focusBrush, buttonPath); + } + } + + if (Type == MaterialButtonType.Outlined) + { + using (Pen outlinePen = new Pen(Enabled ? SkinManager.DividersAlternativeColor : SkinManager.DividersColor, 1)) + { + buttonRectF.X += 0.5f; + buttonRectF.Y += 0.5f; + g.DrawPath(outlinePen, buttonPath); + } + } + + //Ripple + if (_animationManager.IsAnimating()) + { + g.Clip = new Region(buttonRectF); + for (var i = 0; i < _animationManager.GetAnimationCount(); i++) + { + var animationValue = _animationManager.GetProgress(i); + var animationSource = _animationManager.GetSource(i); + + using (Brush rippleBrush = new SolidBrush( + Color.FromArgb((int)(100 - (animationValue * 100)), // Alpha animation + (Type == MaterialButtonType.Contained && HighEmphasis ? (UseAccentColor ? + SkinManager.ColorScheme.AccentColor.Lighten(0.5f) : // Emphasis with accent + SkinManager.ColorScheme.LightPrimaryColor) : // Emphasis + (UseAccentColor ? SkinManager.ColorScheme.AccentColor : // Normal with accent + SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? SkinManager.ColorScheme.PrimaryColor : SkinManager.ColorScheme.LightPrimaryColor))))) // Normal + { + var rippleSize = (int)(animationValue * Width * 2); + g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize)); + } + } + g.ResetClip(); + } + + //Text + var textRect = ClientRectangle; + if (Icon != null) + { + textRect.Width -= 8 + ICON_SIZE + 4 + 8; // left padding + icon width + space between Icon and Text + right padding + textRect.X += 8 + ICON_SIZE + 4; // left padding + icon width + space between Icon and Text + } + + Color textColor = Enabled ? (HighEmphasis ? (Type == MaterialButtonType.Text || Type == MaterialButtonType.Outlined) ? + UseAccentColor ? SkinManager.ColorScheme.AccentColor : // Outline or Text and accent and emphasis + NoAccentTextColor == Color.Empty ? + SkinManager.ColorScheme.PrimaryColor : // Outline or Text and emphasis + NoAccentTextColor : // User defined Outline or Text and emphasis + SkinManager.ColorScheme.TextColor : // Contained and Emphasis + SkinManager.TextHighEmphasisColor) : // Cointained and accent + SkinManager.TextDisabledOrHintColor; // Disabled + + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + NativeText.DrawMultilineTransparentText( + CharacterCasing == CharacterCasingEnum.Upper ? base.Text.ToUpper() : CharacterCasing == CharacterCasingEnum.Lower ? base.Text.ToLower() : + CharacterCasing == CharacterCasingEnum.Title ? CultureInfo.CurrentCulture.TextInfo.ToTitleCase(base.Text.ToLower()) : base.Text, + SkinManager.getLogFontByType(MaterialSkinManager.fontType.Button,RightToLeft), + textColor, + textRect.Location, + textRect.Size, + NativeTextRenderer.TextAlignFlags.Center | NativeTextRenderer.TextAlignFlags.Middle); + } + + //Icon + var iconRect = new Rectangle(8, (Height / 2) - (ICON_SIZE / 2), ICON_SIZE, ICON_SIZE); + + if (string.IsNullOrEmpty(Text)) + { + // Center Icon + iconRect.X += 2; + } + + if (Icon != null) + { + g.FillRectangle(iconsBrushes, iconRect); + } + } + + /// + /// The GetPreferredSize + /// + /// The + private Size GetPreferredSize() + { + return GetPreferredSize(Size); + } + + /// + /// The GetPreferredSize + /// + /// The proposedSize + /// The + public override Size GetPreferredSize(Size proposedSize) + { + Size s = base.GetPreferredSize(proposedSize); + + // Provides extra space for proper padding for content + var extra = 16; + + if (Icon != null) + { + // 24 is for icon size + // 4 is for the space between icon & text + extra += ICON_SIZE + 4; + } + + if (AutoSize) + { + s.Width = (int)Math.Ceiling(_textSize.Width); + s.Width += extra; + s.Height = HEIGHTDEFAULT; + } + else + { + s.Width += extra; + s.Height = HEIGHTDEFAULT; + } + if (Icon != null && Text.Length==0 && s.Width < MINIMUMWIDTHICONONLY) s.Width = MINIMUMWIDTHICONONLY; + else if (s.Width < MINIMUMWIDTH) s.Width = MINIMUMWIDTH; + + return s; + } + + /// + /// The OnCreateControl + /// + protected override void OnCreateControl() + { + base.OnCreateControl(); + // before checking DesignMode property, as long as we need see Icon in proper position + Resize += (sender, args) => { preProcessIcons(); Invalidate(); }; + + if (DesignMode) + { + return; + } + + MouseState = MouseState.OUT; + MouseEnter += (sender, args) => + { + MouseState = MouseState.HOVER; + _hoverAnimationManager.StartNewAnimation(AnimationDirection.In); + Invalidate(); + }; + MouseLeave += (sender, args) => + { + MouseState = MouseState.OUT; + _hoverAnimationManager.StartNewAnimation(AnimationDirection.Out); + Invalidate(); + }; + MouseDown += (sender, args) => + { + if (args.Button == MouseButtons.Left) + { + MouseState = MouseState.DOWN; + + _animationManager.StartNewAnimation(AnimationDirection.In, args.Location); + Invalidate(); + } + }; + MouseUp += (sender, args) => + { + MouseState = MouseState.HOVER; + + Invalidate(); + }; + + GotFocus += (sender, args) => + { + _focusAnimationManager.StartNewAnimation(AnimationDirection.In); + Invalidate(); + }; + LostFocus += (sender, args) => + { + MouseState = MouseState.OUT; + _focusAnimationManager.StartNewAnimation(AnimationDirection.Out); + Invalidate(); + }; + + PreviewKeyDown += (object sender, PreviewKeyDownEventArgs e) => + { + if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Space) + { + _animationManager.StartNewAnimation(AnimationDirection.In, new Point(ClientRectangle.Width >> 1, ClientRectangle.Height >> 1)); + Invalidate(); + } + }; } - - private void RemoveShadowPaintEvent(Control control, PaintEventHandler shadowPaintEvent) - { - if (!_shadowDrawEventSubscribed) return; - control.Paint -= shadowPaintEvent; - control.Invalidate(); - _shadowDrawEventSubscribed = false; - } - - private readonly AnimationManager _hoverAnimationManager = null; - private readonly AnimationManager _animationManager = null; - - /// - /// Defines the _textSize - /// - private SizeF _textSize; - - /// - /// Defines the _icon - /// - private Image _icon; - - private bool drawShadows; - private bool highEmphasis; - private bool useAccentColor; - private MaterialButtonType type; - - /// - /// Gets or sets the Icon - /// - public Image Icon - { - get { return _icon; } - set - { - _icon = value; - if (AutoSize) - { - Refresh(); - } - - Invalidate(); - } - } - - [DefaultValue(true)] - public override bool AutoSize - { - get => base.AutoSize; - set => base.AutoSize = value; - } - - /// - /// Initializes a new instance of the class. - /// - public MaterialButton() - { - DrawShadows = true; - HighEmphasis = true; - UseAccentColor = false; - Type = MaterialButtonType.Contained; - - _animationManager = new AnimationManager(false) - { - Increment = 0.03, - AnimationType = AnimationType.EaseOut - }; - _hoverAnimationManager = new AnimationManager - { - Increment = 0.12, - AnimationType = AnimationType.Linear - }; - - _hoverAnimationManager.OnAnimationProgress += sender => Invalidate(); - _animationManager.OnAnimationProgress += sender => Invalidate(); - - AutoSizeMode = AutoSizeMode.GrowAndShrink; - AutoSize = true; - Margin = new Padding(4, 6, 4, 6); - Padding = new Padding(0); - } - - /// - /// Gets or sets the Text - /// - public override string Text - { - get { return base.Text; } - set - { - base.Text = value; - _textSize = CreateGraphics().MeasureString(value.ToUpper(), SkinManager.getFontByType(MaterialSkinManager.fontType.Button)); - if (AutoSize) - { - Refresh(); - } - - Invalidate(); - } - } - - private void drawShadowOnParent(object sender, PaintEventArgs e) - { - if (Parent == null) - { - RemoveShadowPaintEvent((Control)sender, drawShadowOnParent); - return; - } - - if (!DrawShadows || Type != MaterialButtonType.Contained || Parent == null) return; - - // paint shadow on parent - Graphics gp = e.Graphics; - Rectangle rect = new Rectangle(Location, ClientRectangle.Size); - gp.SmoothingMode = SmoothingMode.AntiAlias; - DrawHelper.DrawSquareShadow(gp, rect); - } - - /// - /// The OnPaint - /// - /// The pevent - protected override void OnPaint(PaintEventArgs pevent) - { - var g = pevent.Graphics; - - g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; - g.SmoothingMode = SmoothingMode.AntiAlias; - - double hoverAnimProgress = _hoverAnimationManager.GetProgress(); - - g.Clear(Parent.BackColor); - - // button rectand path - RectangleF buttonRectF = new RectangleF(ClientRectangle.Location, ClientRectangle.Size); - buttonRectF.X -= 0.5f; - buttonRectF.Y -= 0.5f; - GraphicsPath buttonPath = DrawHelper.CreateRoundRect(buttonRectF, 4); - - // button shadow (blend with form shadow) - DrawHelper.DrawSquareShadow(g, ClientRectangle); - - if (Type == MaterialButtonType.Contained) - { - // draw button rect - // Disabled - if (!Enabled) - { - using (SolidBrush disabledBrush = new SolidBrush(DrawHelper.BlendColor(Parent.BackColor, SkinManager.BackgroundDisabledColor, SkinManager.BackgroundDisabledColor.A))) - { - g.FillPath(disabledBrush, buttonPath); - } - } - // High emphasis - else if (HighEmphasis) - { - g.FillPath(UseAccentColor ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush, buttonPath); - } - // Mormal - else - { - using (SolidBrush normalBrush = new SolidBrush(SkinManager.BackgroundColor)) - { - g.FillPath(normalBrush, buttonPath); - } - } - } - else - { - g.Clear(Parent.BackColor); - } - - //Hover - using (SolidBrush hoverBrush = new SolidBrush(Color.FromArgb( - (int)(hoverAnimProgress * SkinManager.BackgroundFocusColor.A), (UseAccentColor ? (HighEmphasis && Type == MaterialButtonType.Contained ? - SkinManager.ColorScheme.AccentColor.Lighten(0.5f) : // Contained with Emphasis - with accent - SkinManager.ColorScheme.AccentColor) : // Not Contained Or Low Emphasis - with accent - (Type == MaterialButtonType.Contained && HighEmphasis ? SkinManager.ColorScheme.LightPrimaryColor : // Contained with Emphasis without accent - SkinManager.ColorScheme.PrimaryColor)).RemoveAlpha()))) // Normal or Emphasis without accent - { - g.FillPath(hoverBrush, buttonPath); - } - - if (Type == MaterialButtonType.Outlined) - { - using (Pen outlinePen = new Pen(Enabled ? SkinManager.DividersAlternativeColor : SkinManager.DividersColor, 1)) - { - buttonRectF.X += 0.5f; - buttonRectF.Y += 0.5f; - g.DrawPath(outlinePen, buttonPath); - } - } - - //Ripple - if (_animationManager.IsAnimating()) - { - g.Clip = new Region(buttonRectF); - for (var i = 0; i < _animationManager.GetAnimationCount(); i++) - { - var animationValue = _animationManager.GetProgress(i); - var animationSource = _animationManager.GetSource(i); - - using (Brush rippleBrush = new SolidBrush( - Color.FromArgb((int)(100 - (animationValue * 100)), // Alpha animation - (Type == MaterialButtonType.Contained && HighEmphasis ? (UseAccentColor ? - SkinManager.ColorScheme.AccentColor.Lighten(0.5f) : // Emphasis with accent - SkinManager.ColorScheme.LightPrimaryColor) : // Emphasis - (UseAccentColor ? SkinManager.ColorScheme.AccentColor : // Normal with accent - SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? SkinManager.ColorScheme.PrimaryColor : SkinManager.ColorScheme.LightPrimaryColor))))) // Normal - { - var rippleSize = (int)(animationValue * Width * 2); - g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize)); - } - } - g.ResetClip(); - } - - //Icon - var iconRect = new Rectangle(8, 6, 24, 24); - - if (string.IsNullOrEmpty(Text)) - { - // Center Icon - iconRect.X += 2; - } - - if (Icon != null) - { - g.DrawImage(Icon, iconRect); - } - - //Text - var textRect = ClientRectangle; - if (Icon != null) - { - textRect.Width -= 8 + 24 + 4 + 8; // left padding + icon width + space between Icon and Text + right padding - textRect.X += 8 + 24 + 4; // left padding + icon width + space between Icon and Text - } - - Color textColor = Enabled ? (HighEmphasis ? (Type == MaterialButtonType.Text || Type == MaterialButtonType.Outlined) ? - (UseAccentColor ? SkinManager.ColorScheme.AccentColor : // Outline or Text and accent and emphasis - SkinManager.ColorScheme.PrimaryColor) : // Outline or Text and emphasis - SkinManager.ColorScheme.TextColor : // Contained and Emphasis - SkinManager.TextHighEmphasisColor) : // Cointained and accent - SkinManager.TextDisabledOrHintColor; // Disabled - - using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) - { - NativeText.DrawTransparentText(Text.ToUpper(), SkinManager.getLogFontByType(MaterialSkinManager.fontType.Button), - textColor, - textRect.Location, - textRect.Size, - NativeTextRenderer.TextAlignFlags.Center | NativeTextRenderer.TextAlignFlags.Middle); - } - } - - /// - /// The GetPreferredSize - /// - /// The - private Size GetPreferredSize() - { - return GetPreferredSize(Size); - } - - /// - /// The GetPreferredSize - /// - /// The proposedSize - /// The - public override Size GetPreferredSize(Size proposedSize) - { - Size s = base.GetPreferredSize(proposedSize); - - // Provides extra space for proper padding for content - var extra = 16; - - if (Icon != null) - { - // 24 is for icon size - // 4 is for the space between icon & text - extra += 24 + 4; - } - - if (AutoSize) - { - s.Width = (int)Math.Ceiling(_textSize.Width); - s.Width += extra; - s.Height = 36; - } - else - { - s.Width += extra; - s.Height = 36; - } - - return s; - } - - /// - /// The OnCreateControl - /// - protected override void OnCreateControl() - { - base.OnCreateControl(); - if (DesignMode) - { - return; - } - - MouseState = MouseState.OUT; - MouseEnter += (sender, args) => - { - MouseState = MouseState.HOVER; - _hoverAnimationManager.StartNewAnimation(AnimationDirection.In); - Invalidate(); - }; - MouseLeave += (sender, args) => - { - MouseState = MouseState.OUT; - _hoverAnimationManager.StartNewAnimation(AnimationDirection.Out); - Invalidate(); - }; - MouseDown += (sender, args) => - { - if (args.Button == MouseButtons.Left) - { - MouseState = MouseState.DOWN; - - _animationManager.StartNewAnimation(AnimationDirection.In, args.Location); - Invalidate(); - } - }; - MouseUp += (sender, args) => - { - MouseState = MouseState.HOVER; - - Invalidate(); - }; - - GotFocus += (sender, args) => - { - _hoverAnimationManager.StartNewAnimation(AnimationDirection.In); - Invalidate(); - }; - LostFocus += (sender, args) => - { - _hoverAnimationManager.StartNewAnimation(AnimationDirection.Out); - Invalidate(); - }; - - KeyDown += (object sender, KeyEventArgs e) => - { - if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Space) - { - _animationManager.StartNewAnimation(AnimationDirection.In, new Point(ClientRectangle.Width >> 1, ClientRectangle.Height >> 1)); - Invalidate(); - } - }; - } - } -} \ No newline at end of file + } +} diff --git a/MaterialSkin/Controls/MaterialCard.cs b/MaterialSkin/Controls/MaterialCard.cs index f72aea07..19b6334c 100644 --- a/MaterialSkin/Controls/MaterialCard.cs +++ b/MaterialSkin/Controls/MaterialCard.cs @@ -1,118 +1,118 @@ -namespace MaterialSkin.Controls -{ - using System; - using System.ComponentModel; - using System.Drawing; - using System.Drawing.Drawing2D; - using System.Windows.Forms; - - public class MaterialCard : Panel, IMaterialControl - { - [Browsable(false)] - public int Depth { get; set; } - - [Browsable(false)] - public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; - - [Browsable(false)] - public MouseState MouseState { get; set; } - - public MaterialCard() - { - SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); - Paint += new PaintEventHandler(paintControl); - BackColor = SkinManager.BackgroundColor; - ForeColor = SkinManager.TextHighEmphasisColor; - Margin = new Padding(SkinManager.FORM_PADDING); - Padding = new Padding(SkinManager.FORM_PADDING); - } - - private void drawShadowOnParent(object sender, PaintEventArgs e) - { - if (Parent == null) - { - RemoveShadowPaintEvent((Control)sender, drawShadowOnParent); - return; - } - - // paint shadow on parent - Graphics gp = e.Graphics; - Rectangle rect = new Rectangle(Location, ClientRectangle.Size); - gp.SmoothingMode = SmoothingMode.AntiAlias; - DrawHelper.DrawSquareShadow(gp, rect); - } - - protected override void InitLayout() - { - LocationChanged += (sender, e) => { Parent?.Invalidate(); }; - ForeColor = SkinManager.TextHighEmphasisColor; - } - - protected override void OnParentChanged(EventArgs e) - { - base.OnParentChanged(e); - if (Parent != null) AddShadowPaintEvent(Parent, drawShadowOnParent); - if (_oldParent != null) RemoveShadowPaintEvent(_oldParent, drawShadowOnParent); - _oldParent = Parent; - } - - private Control _oldParent; - - protected override void OnVisibleChanged(EventArgs e) - { - base.OnVisibleChanged(e); - if (Parent == null) return; - if (Visible) - AddShadowPaintEvent(Parent, drawShadowOnParent); - else - RemoveShadowPaintEvent(Parent, drawShadowOnParent); - } - +namespace MaterialSkin.Controls +{ + using System; + using System.ComponentModel; + using System.Drawing; + using System.Drawing.Drawing2D; + using System.Windows.Forms; + + public class MaterialCard : Panel, IMaterialControl + { + [Browsable(false)] + public int Depth { get; set; } + + [Browsable(false)] + public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; + + [Browsable(false)] + public MouseState MouseState { get; set; } + + public MaterialCard() + { + SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); + Paint += new PaintEventHandler(paintControl); + BackColor = SkinManager.BackgroundColor; + ForeColor = SkinManager.TextHighEmphasisColor; + Margin = new Padding(SkinManager.FORM_PADDING); + Padding = new Padding(SkinManager.FORM_PADDING); + } + + private void drawShadowOnParent(object sender, PaintEventArgs e) + { + if (Parent == null) + { + RemoveShadowPaintEvent((Control)sender, drawShadowOnParent); + return; + } + + // paint shadow on parent + Graphics gp = e.Graphics; + Rectangle rect = new Rectangle(Location, ClientRectangle.Size); + gp.SmoothingMode = SmoothingMode.AntiAlias; + DrawHelper.DrawSquareShadow(gp, rect); + } + + protected override void InitLayout() + { + LocationChanged += (sender, e) => { Parent?.Invalidate(); }; + ForeColor = SkinManager.TextHighEmphasisColor; + } + + protected override void OnParentChanged(EventArgs e) + { + base.OnParentChanged(e); + if (Parent != null) AddShadowPaintEvent(Parent, drawShadowOnParent); + if (_oldParent != null) RemoveShadowPaintEvent(_oldParent, drawShadowOnParent); + _oldParent = Parent; + } + + private Control _oldParent; + + protected override void OnVisibleChanged(EventArgs e) + { + base.OnVisibleChanged(e); + if (Parent == null) return; + if (Visible) + AddShadowPaintEvent(Parent, drawShadowOnParent); + else + RemoveShadowPaintEvent(Parent, drawShadowOnParent); + } + private bool _shadowDrawEventSubscribed = false; - - private void AddShadowPaintEvent(Control control, PaintEventHandler shadowPaintEvent) - { - if (_shadowDrawEventSubscribed) return; - control.Paint += shadowPaintEvent; - control.Invalidate(); - _shadowDrawEventSubscribed = true; + + private void AddShadowPaintEvent(Control control, PaintEventHandler shadowPaintEvent) + { + if (_shadowDrawEventSubscribed) return; + control.Paint += shadowPaintEvent; + control.Invalidate(); + _shadowDrawEventSubscribed = true; + } + + private void RemoveShadowPaintEvent(Control control, PaintEventHandler shadowPaintEvent) + { + if (!_shadowDrawEventSubscribed) return; + control.Paint -= shadowPaintEvent; + control.Invalidate(); + _shadowDrawEventSubscribed = false; + } + + protected override void OnBackColorChanged(EventArgs e) + { + base.OnBackColorChanged(e); + BackColor = SkinManager.BackgroundColor; + } + + private void paintControl(Object sender, PaintEventArgs e) + { + Graphics g = e.Graphics; + g.SmoothingMode = SmoothingMode.AntiAlias; + + g.Clear(Parent.BackColor); + + // card rectangle path + RectangleF cardRectF = new RectangleF(ClientRectangle.Location, ClientRectangle.Size); + cardRectF.X -= 0.5f; + cardRectF.Y -= 0.5f; + GraphicsPath cardPath = DrawHelper.CreateRoundRect(cardRectF, 4); + + // button shadow (blend with form shadow) + DrawHelper.DrawSquareShadow(g, ClientRectangle); + + // Draw card + using (SolidBrush normalBrush = new SolidBrush(BackColor)) + { + g.FillPath(normalBrush, cardPath); + } } - - private void RemoveShadowPaintEvent(Control control, PaintEventHandler shadowPaintEvent) - { - if (!_shadowDrawEventSubscribed) return; - control.Paint -= shadowPaintEvent; - control.Invalidate(); - _shadowDrawEventSubscribed = false; - } - - protected override void OnBackColorChanged(EventArgs e) - { - base.OnBackColorChanged(e); - BackColor = SkinManager.BackgroundColor; - } - - private void paintControl(Object sender, PaintEventArgs e) - { - Graphics g = e.Graphics; - g.SmoothingMode = SmoothingMode.AntiAlias; - - g.Clear(Parent.BackColor); - - // card rectangle path - RectangleF cardRectF = new RectangleF(ClientRectangle.Location, ClientRectangle.Size); - cardRectF.X -= 0.5f; - cardRectF.Y -= 0.5f; - GraphicsPath cardPath = DrawHelper.CreateRoundRect(cardRectF, 4); - - // button shadow (blend with form shadow) - DrawHelper.DrawSquareShadow(g, ClientRectangle); - - // Draw card - using (SolidBrush normalBrush = new SolidBrush(BackColor)) - { - g.FillPath(normalBrush, cardPath); - } - } - } + } } \ No newline at end of file diff --git a/MaterialSkin/Controls/MaterialCheckBox.cs b/MaterialSkin/Controls/MaterialCheckBox.cs index 06e5fb18..7a776912 100644 --- a/MaterialSkin/Controls/MaterialCheckBox.cs +++ b/MaterialSkin/Controls/MaterialCheckBox.cs @@ -10,6 +10,7 @@ public class MaterialCheckbox : CheckBox, IMaterialControl { + #region Public properties [Browsable(false)] public int Depth { get; set; } @@ -42,6 +43,11 @@ public bool Ripple } } + [Browsable(true)] + public bool ReadOnly { get; set; } + #endregion + + #region Private fields private readonly AnimationManager _checkAM; private readonly AnimationManager _rippleAM; private readonly AnimationManager _hoverAM; @@ -51,7 +57,12 @@ public bool Ripple private const int CHECKBOX_SIZE = 18; private const int CHECKBOX_SIZE_HALF = CHECKBOX_SIZE / 2; private int _boxOffset; + private static readonly Point[] CheckmarkLine = { new Point(3, 8), new Point(7, 12), new Point(14, 5) }; + private bool hovered = false; + private CheckState _oldCheckState; + #endregion + #region Constructor public MaterialCheckbox() { _checkAM = new AnimationManager @@ -83,7 +94,9 @@ public MaterialCheckbox() Height = HEIGHT_RIPPLE; MouseLocation = new Point(-1, -1); } + #endregion + #region Overridden events protected override void OnSizeChanged(EventArgs e) { base.OnSizeChanged(e); @@ -97,15 +110,13 @@ public override Size GetPreferredSize(Size proposedSize) using (NativeTextRenderer NativeText = new NativeTextRenderer(CreateGraphics())) { - strSize = NativeText.MeasureLogString(Text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1)); + strSize = NativeText.MeasureLogString(Text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1, RightToLeft)); } int w = _boxOffset + TEXT_OFFSET + strSize.Width; return Ripple ? new Size(w, HEIGHT_RIPPLE) : new Size(w, HEIGHT_NO_RIPPLE); } - private static readonly Point[] CheckmarkLine = { new Point(3, 8), new Point(7, 12), new Point(14, 5) }; - protected override void OnPaint(PaintEventArgs pevent) { Graphics g = pevent.Graphics; @@ -115,8 +126,9 @@ protected override void OnPaint(PaintEventArgs pevent) // clear the control g.Clear(Parent.BackColor); - int CHECKBOX_CENTER = _boxOffset + CHECKBOX_SIZE_HALF - 1; - Point animationSource = new Point(CHECKBOX_CENTER, CHECKBOX_CENTER); + int CHECKBOX_CENTER_X = RightToLeft==RightToLeft.Yes?Width - (_boxOffset + CHECKBOX_SIZE_HALF +1) : _boxOffset + CHECKBOX_SIZE_HALF - 1; + int CHECKBOX_CENTER_Y = _boxOffset + CHECKBOX_SIZE_HALF - 1; + Point animationSource = new Point(CHECKBOX_CENTER_X, CHECKBOX_CENTER_Y); double animationProgress = _checkAM.GetProgress(); int colorAlpha = Enabled ? (int)(animationProgress * 255.0) : SkinManager.CheckBoxOffDisabledColor.A; @@ -154,8 +166,9 @@ protected override void OnPaint(PaintEventArgs pevent) } } - Rectangle checkMarkLineFill = new Rectangle(_boxOffset, _boxOffset, (int)(CHECKBOX_SIZE * animationProgress), CHECKBOX_SIZE); - using (GraphicsPath checkmarkPath = DrawHelper.CreateRoundRect(_boxOffset - 0.5f, _boxOffset - 0.5f, CHECKBOX_SIZE, CHECKBOX_SIZE, 1)) + var boxOffset_x = RightToLeft == RightToLeft.Yes ? Width - CHECKBOX_SIZE - _boxOffset : _boxOffset; + Rectangle checkMarkLineFill = new Rectangle(boxOffset_x , _boxOffset, (int)(CHECKBOX_SIZE * animationProgress), CHECKBOX_SIZE); + using (GraphicsPath checkmarkPath = DrawHelper.CreateRoundRect(boxOffset_x - 0.5f, _boxOffset - 0.5f, CHECKBOX_SIZE, CHECKBOX_SIZE, 1)) { if (Enabled) { @@ -177,16 +190,18 @@ protected override void OnPaint(PaintEventArgs pevent) g.DrawImageUnscaledAndClipped(DrawCheckMarkBitmap(), checkMarkLineFill); } - + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; // draw checkbox text using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) { - Rectangle textLocation = new Rectangle(_boxOffset + TEXT_OFFSET, 0, Width - (_boxOffset + TEXT_OFFSET), HEIGHT_RIPPLE); - NativeText.DrawTransparentText(Text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1), + var x = RightToLeft == RightToLeft.Yes ? 0 : _boxOffset + TEXT_OFFSET; + var w = RightToLeft == RightToLeft.Yes ? Width - (_boxOffset + TEXT_OFFSET) : Width; + Rectangle textLocation = new Rectangle(x, 0, w, HEIGHT_RIPPLE); + NativeText.DrawTransparentText(Text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1,RightToLeft), Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor, textLocation.Location, textLocation.Size, - NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); } // dispose used paint objects @@ -194,23 +209,6 @@ protected override void OnPaint(PaintEventArgs pevent) brush.Dispose(); } - private Bitmap DrawCheckMarkBitmap() - { - Bitmap checkMark = new Bitmap(CHECKBOX_SIZE, CHECKBOX_SIZE); - Graphics g = Graphics.FromImage(checkMark); - - // clear everything, transparent - g.Clear(Color.Transparent); - - // draw the checkmark lines - using (Pen pen = new Pen(Parent.BackColor, 2)) - { - g.DrawLines(pen, CheckmarkLine); - } - - return checkMark; - } - public override bool AutoSize { get { return base.AutoSize; } @@ -224,13 +222,6 @@ public override bool AutoSize } } - private bool IsMouseInCheckArea() - { - return ClientRectangle.Contains(MouseLocation); - } - - private bool hovered = false; - protected override void OnCreateControl() { base.OnCreateControl(); @@ -265,6 +256,7 @@ protected override void OnCreateControl() // _hoverAM.StartNewAnimation(AnimationDirection.In, new object[] { Checked }); // hovered = true; //} + _oldCheckState = CheckState; }; MouseLeave += (sender, args) => @@ -286,6 +278,7 @@ protected override void OnCreateControl() _rippleAM.SecondaryIncrement = 0; _rippleAM.StartNewAnimation(AnimationDirection.InOutIn, new object[] { Checked }); } + if (ReadOnly) CheckState = _oldCheckState; }; KeyDown += (sender, args) => @@ -295,6 +288,7 @@ protected override void OnCreateControl() _rippleAM.SecondaryIncrement = 0; _rippleAM.StartNewAnimation(AnimationDirection.InOutIn, new object[] { Checked }); } + if (ReadOnly) CheckState = _oldCheckState; }; MouseUp += (sender, args) => @@ -306,6 +300,7 @@ protected override void OnCreateControl() _hoverAM.StartNewAnimation(AnimationDirection.Out, new object[] { Checked }); hovered = false; } + if (ReadOnly) CheckState = _oldCheckState; }; KeyUp += (sender, args) => @@ -315,6 +310,7 @@ protected override void OnCreateControl() MouseState = MouseState.HOVER; _rippleAM.SecondaryIncrement = 0.08; } + if (ReadOnly) CheckState = _oldCheckState; }; MouseMove += (sender, args) => @@ -323,5 +319,30 @@ protected override void OnCreateControl() Cursor = IsMouseInCheckArea() ? Cursors.Hand : Cursors.Default; }; } + #endregion + + #region Private events and methods + private Bitmap DrawCheckMarkBitmap() + { + Bitmap checkMark = new Bitmap(CHECKBOX_SIZE, CHECKBOX_SIZE); + Graphics g = Graphics.FromImage(checkMark); + + // clear everything, transparent + g.Clear(Color.Transparent); + + // draw the checkmark lines + using (Pen pen = new Pen(Parent.BackColor, 2)) + { + g.DrawLines(pen, CheckmarkLine); + } + + return checkMark; + } + + private bool IsMouseInCheckArea() + { + return ClientRectangle.Contains(MouseLocation); + } + #endregion } } \ No newline at end of file diff --git a/MaterialSkin/Controls/MaterialCheckedListBox.cs b/MaterialSkin/Controls/MaterialCheckedListBox.cs index eabc44ec..81bd372f 100644 --- a/MaterialSkin/Controls/MaterialCheckedListBox.cs +++ b/MaterialSkin/Controls/MaterialCheckedListBox.cs @@ -71,6 +71,7 @@ public void Add(string text, bool defaultValue) Add(cb); cb.Checked = defaultValue; cb.Text = text; + cb.RightToLeft = RightToLeft.Inherit; } public new void Add(MaterialSkin.Controls.MaterialCheckbox value) diff --git a/MaterialSkin/Controls/MaterialComboBox.cs b/MaterialSkin/Controls/MaterialComboBox.cs index 6599fe2a..7f2482af 100644 --- a/MaterialSkin/Controls/MaterialComboBox.cs +++ b/MaterialSkin/Controls/MaterialComboBox.cs @@ -1,342 +1,405 @@ -namespace MaterialSkin.Controls -{ - using MaterialSkin.Animations; - using System; - using System.ComponentModel; - using System.Drawing; - using System.Linq; - using System.Windows.Forms; - - public class MaterialComboBox : ComboBox, IMaterialControl - { - // For some reason, even when overriding the AutoSize property, it doesn't appear on the properties panel, so we have to create a new one. +namespace MaterialSkin.Controls +{ + using MaterialSkin.Animations; + using System; + using System.ComponentModel; + using System.Drawing; + using System.Linq; + using System.Data; + using System.Windows.Forms; + + public class MaterialComboBox : ComboBox, IMaterialControl + { + // For some reason, even when overriding the AutoSize property, it doesn't appear on the properties panel, so we have to create a new one. [Browsable(true), EditorBrowsable(EditorBrowsableState.Always), Category("Layout")] - private bool _AutoResize; - - public bool AutoResize - { - get { return _AutoResize; } - set - { - _AutoResize = value; - recalculateAutoSize(); - } - } - - //Properties for managing the material design properties - [Browsable(false)] - public int Depth { get; set; } - - [Browsable(false)] - public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; - - [Browsable(false)] - public MouseState MouseState { get; set; } - + private bool _AutoResize; + + public bool AutoResize + { + get { return _AutoResize; } + set + { + _AutoResize = value; + recalculateAutoSize(); + } + } + + //Properties for managing the material design properties + [Browsable(false)] + public int Depth { get; set; } + + [Browsable(false)] + public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; + + [Browsable(false)] + public MouseState MouseState { get; set; } + private bool _UseTallSize; - - [Category("Material Skin"), DefaultValue(true), Description("Using a larger size enables the hint to always be visible")] - public bool UseTallSize - { - get { return _UseTallSize; } - set - { - _UseTallSize = value; - setHeightVars(); - Invalidate(); - } - } - - [Category("Material Skin"), DefaultValue(true)] - public bool UseAccent { get; set; } - + + [Category("Material Skin"), DefaultValue(true), Description("Using a larger size enables the hint to always be visible")] + public bool UseTallSize + { + get { return _UseTallSize; } + set + { + _UseTallSize = value; + setHeightVars(); + Invalidate(); + } + } + + [Category("Material Skin"), DefaultValue(true)] + public bool UseAccent { get; set; } + private string _hint = string.Empty; - - [Category("Material Skin"), DefaultValue("")] - public string Hint - { - get { return _hint; } - set - { - _hint = value; - hasHint = !String.IsNullOrEmpty(Hint); - Invalidate(); - } - } - - private const int TEXT_SMALL_SIZE = 18; - private const int TEXT_SMALL_Y = 4; - private const int BOTTOM_PADDING = 3; - private int HEIGHT = 50; - private int LINE_Y; - - private bool hasHint; - - private readonly AnimationManager _animationManager; - - public MaterialComboBox() - { - SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); - - // Material Properties - Hint = ""; - UseAccent = true; - UseTallSize = true; - MaxDropDownItems = 4; - - Font = SkinManager.getFontByType(MaterialSkinManager.fontType.Subtitle2); - BackColor = SkinManager.BackgroundColor; - ForeColor = SkinManager.TextHighEmphasisColor; - DrawMode = DrawMode.OwnerDrawVariable; - DropDownStyle = ComboBoxStyle.DropDownList; - DropDownWidth = Width; - - // Animations - _animationManager = new AnimationManager(true) - { - Increment = 0.08, - AnimationType = AnimationType.EaseInOut - }; - _animationManager.OnAnimationProgress += sender => Invalidate(); - - DropDownClosed += (sender, args) => - { - MouseState = MouseState.OUT; - if (SelectedIndex < 0 && !Focused) _animationManager.StartNewAnimation(AnimationDirection.Out); - }; - LostFocus += (sender, args) => - { - MouseState = MouseState.OUT; - if (SelectedIndex < 0) _animationManager.StartNewAnimation(AnimationDirection.Out); - }; - DropDown += (sender, args) => - { - _animationManager.StartNewAnimation(AnimationDirection.In); - }; - GotFocus += (sender, args) => - { - _animationManager.StartNewAnimation(AnimationDirection.In); - }; - MouseEnter += (sender, args) => - { - MouseState = MouseState.HOVER; - Invalidate(); - }; - MouseLeave += (sender, args) => - { - MouseState = MouseState.OUT; - Invalidate(); - }; - } - - protected override void OnPaint(PaintEventArgs pevent) - { - Graphics g = pevent.Graphics; - - g.Clear(Parent.BackColor); - g.FillRectangle(Enabled ? Focused ? - SkinManager.BackgroundFocusBrush : // Focused - MouseState == MouseState.HOVER ? - SkinManager.BackgroundHoverBrush : // Hover - SkinManager.BackgroundAlternativeBrush : // normal - SkinManager.BackgroundDisabledBrush // Disabled - , ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, LINE_Y); - - // Create and Draw the arrow - System.Drawing.Drawing2D.GraphicsPath pth = new System.Drawing.Drawing2D.GraphicsPath(); - PointF TopRight = new PointF(this.Width - 0.5f - SkinManager.FORM_PADDING, (this.Height >> 1) - 2.5f); - PointF MidBottom = new PointF(this.Width - 4.5f - SkinManager.FORM_PADDING, (this.Height >> 1) + 2.5f); - PointF TopLeft = new PointF(this.Width - 8.5f - SkinManager.FORM_PADDING, (this.Height >> 1) - 2.5f); - pth.AddLine(TopLeft, TopRight); - pth.AddLine(TopRight, MidBottom); - - g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; - g.FillPath((SolidBrush)(DroppedDown || Focused ? UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush : SkinManager.TextHighEmphasisBrush), pth); - g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; - - // HintText - bool userTextPresent = SelectedIndex >= 0; - Rectangle hintRect = new Rectangle(SkinManager.FORM_PADDING, ClientRectangle.Y, Width, LINE_Y); - int hintTextSize = 16; - - // bottom line base - g.FillRectangle(SkinManager.DividersAlternativeBrush, 0, LINE_Y, Width, 1); - - if (!_animationManager.IsAnimating()) - { - // No animation - if (hasHint && UseTallSize && (DroppedDown || Focused || SelectedIndex >= 0)) - { - // hint text - hintRect = new Rectangle(SkinManager.FORM_PADDING, TEXT_SMALL_Y, Width, TEXT_SMALL_SIZE); - hintTextSize = 12; - } - - // bottom line - if (DroppedDown || Focused) - { - g.FillRectangle(UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush, 0, LINE_Y, Width, 2); - } - } - else - { - // Animate - Focus got/lost - double animationProgress = _animationManager.GetProgress(); - - // hint Animation - if (hasHint && UseTallSize) - { - hintRect = new Rectangle( - SkinManager.FORM_PADDING, - userTextPresent && !_animationManager.IsAnimating() ? (TEXT_SMALL_Y) : ClientRectangle.Y + (int)((TEXT_SMALL_Y - ClientRectangle.Y) * animationProgress), - Width, - userTextPresent && !_animationManager.IsAnimating() ? (TEXT_SMALL_SIZE) : (int)(LINE_Y + (TEXT_SMALL_SIZE - LINE_Y) * animationProgress)); - hintTextSize = userTextPresent && !_animationManager.IsAnimating() ? 12 : (int)(16 + (12 - 16) * animationProgress); - } - - // Line Animation - int LineAnimationWidth = (int)(Width * animationProgress); - int LineAnimationX = (Width / 2) - (LineAnimationWidth / 2); - g.FillRectangle(UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush, LineAnimationX, LINE_Y, LineAnimationWidth, 2); - } - - // Calc text Rect - Rectangle textRect = new Rectangle( - SkinManager.FORM_PADDING, - hasHint && UseTallSize ? (hintRect.Y + hintRect.Height) - 2 : ClientRectangle.Y, - ClientRectangle.Width - SkinManager.FORM_PADDING * 3 - 8, - hasHint && UseTallSize ? LINE_Y - (hintRect.Y + hintRect.Height) : LINE_Y); - - g.Clip = new Region(textRect); - - using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) - { - // Draw user text - NativeText.DrawTransparentText( - Text, - SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1), - Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor, - textRect.Location, - textRect.Size, - NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); - } - - g.ResetClip(); - - // Draw hint text - if (hasHint && (UseTallSize || String.IsNullOrEmpty(Text))) - { - using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) - { - NativeText.DrawTransparentText( - Hint, - SkinManager.getTextBoxFontBySize(hintTextSize), - Enabled ? DroppedDown || Focused ? UseAccent ? - SkinManager.ColorScheme.AccentColor : // Focus Accent - SkinManager.ColorScheme.PrimaryColor : // Focus Primary - SkinManager.TextMediumEmphasisColor : // not focused - SkinManager.TextDisabledOrHintColor, // Disabled - hintRect.Location, - hintRect.Size, - NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); - } - } - } - - private void CustomMeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) - { - e.ItemHeight = HEIGHT - 7; - } - - private void CustomDrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) - { - if (e.Index < 0 || e.Index > Items.Count || !Focused) return; - - Graphics g = e.Graphics; - - // Draw the background of the item. - g.FillRectangle(SkinManager.BackgroundBrush, e.Bounds); - - // Hover - if (e.State.HasFlag(DrawItemState.Focus)) // Focus == hover - { - g.FillRectangle(SkinManager.BackgroundHoverBrush, e.Bounds); - } - - string Text = ""; - if (!string.IsNullOrWhiteSpace(DisplayMember)) - { - Text = Items[e.Index].GetType().GetProperty(DisplayMember).GetValue(Items[e.Index], null).ToString(); - } - else - { - Text = Items[e.Index].ToString(); - } - - using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) - { - NativeText.DrawTransparentText( - Text, - SkinManager.getFontByType(MaterialSkinManager.fontType.Subtitle1), - SkinManager.TextHighEmphasisColor, - new Point(e.Bounds.Location.X + SkinManager.FORM_PADDING, e.Bounds.Location.Y), - new Size(e.Bounds.Size.Width - SkinManager.FORM_PADDING * 2, e.Bounds.Size.Height), - NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); ; - } - } - - protected override void OnCreateControl() - { - base.OnCreateControl(); - MouseState = MouseState.OUT; - MeasureItem += CustomMeasureItem; - DrawItem += CustomDrawItem; - DropDownStyle = ComboBoxStyle.DropDownList; - DrawMode = DrawMode.OwnerDrawVariable; - recalculateAutoSize(); - setHeightVars(); - } - - protected override void OnResize(EventArgs e) - { - base.OnResize(e); - recalculateAutoSize(); - setHeightVars(); - } - - private void setHeightVars() - { - HEIGHT = UseTallSize ? 50 : 36; - Size = new Size(Size.Width, HEIGHT); - LINE_Y = HEIGHT - BOTTOM_PADDING; - ItemHeight = HEIGHT - 7; - DropDownHeight = ItemHeight * MaxDropDownItems + 2; - } - - public void recalculateAutoSize() - { - if (!AutoResize) return; - - int w = DropDownWidth; - int padding = SkinManager.FORM_PADDING * 3; - int vertScrollBarWidth = (Items.Count > MaxDropDownItems) ? SystemInformation.VerticalScrollBarWidth : 0; - - Graphics g = CreateGraphics(); - using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) - { - var itemsList = this.Items.Cast().Select(item => item.ToString()); - foreach (string s in itemsList) - { - int newWidth = NativeText.MeasureLogString(s, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1)).Width + vertScrollBarWidth + padding; - if (w < newWidth) w = newWidth; - } - } - - if (Width != w) - { - DropDownWidth = w; - Width = w; - } - } - } -} \ No newline at end of file + + [Category("Material Skin"), DefaultValue(""), Localizable(true)] + public string Hint + { + get { return _hint; } + set + { + _hint = value; + hasHint = !String.IsNullOrEmpty(Hint); + Invalidate(); + } + } + + private int _startIndex; + public int StartIndex + { + get => _startIndex; + set + { + _startIndex = value; + try + { + base.SelectedIndex = value; + } + catch + { + } + Invalidate(); + } + } + + private const int TEXT_SMALL_SIZE = 18; + private const int TEXT_SMALL_Y = 4; + private const int BOTTOM_PADDING = 3; + private int HEIGHT = 50; + private int LINE_Y; + + private bool hasHint; + + private readonly AnimationManager _animationManager; + + public MaterialComboBox() + { + SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); + + // Material Properties + Hint = ""; + UseAccent = true; + UseTallSize = true; + MaxDropDownItems = 4; + + Font = SkinManager.getFontByType(MaterialSkinManager.fontType.Subtitle2, RightToLeft); + BackColor = SkinManager.BackgroundColor; + ForeColor = SkinManager.TextHighEmphasisColor; + DrawMode = DrawMode.OwnerDrawVariable; + DropDownStyle = ComboBoxStyle.DropDownList; + DropDownWidth = Width; + + // Animations + _animationManager = new AnimationManager(true) + { + Increment = 0.08, + AnimationType = AnimationType.EaseInOut + }; + _animationManager.OnAnimationProgress += sender => Invalidate(); + _animationManager.OnAnimationFinished += sender => _animationManager.SetProgress(0); + DropDownClosed += (sender, args) => + { + MouseState = MouseState.OUT; + if (SelectedIndex < 0 && !Focused) _animationManager.StartNewAnimation(AnimationDirection.Out); + }; + LostFocus += (sender, args) => + { + MouseState = MouseState.OUT; + if (SelectedIndex < 0) _animationManager.StartNewAnimation(AnimationDirection.Out); + }; + DropDown += (sender, args) => + { + _animationManager.StartNewAnimation(AnimationDirection.In); + }; + GotFocus += (sender, args) => + { + _animationManager.StartNewAnimation(AnimationDirection.In); + Invalidate(); + }; + MouseEnter += (sender, args) => + { + MouseState = MouseState.HOVER; + Invalidate(); + }; + MouseLeave += (sender, args) => + { + MouseState = MouseState.OUT; + Invalidate(); + }; + SelectedIndexChanged += (sender, args) => + { + Invalidate(); + }; + KeyUp += (sender, args) => + { + if (Enabled && DropDownStyle == ComboBoxStyle.DropDownList && (args.KeyCode == Keys.Delete || args.KeyCode == Keys.Back)) + { + SelectedIndex = -1; + Invalidate(); + } + }; + } + + protected override void OnPaint(PaintEventArgs pevent) + { + Graphics g = pevent.Graphics; + + + g.Clear(Parent.BackColor); + g.FillRectangle(Enabled ? Focused ? + SkinManager.BackgroundFocusBrush : // Focused + MouseState == MouseState.HOVER ? + SkinManager.BackgroundHoverBrush : // Hover + SkinManager.BackgroundAlternativeBrush : // normal + SkinManager.BackgroundDisabledBrush // Disabled + , ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, LINE_Y); + + //Set color and brush + Color SelectedColor = new Color(); + if (UseAccent) + SelectedColor = SkinManager.ColorScheme.AccentColor; + else + SelectedColor = SkinManager.ColorScheme.PrimaryColor; + SolidBrush SelectedBrush = new SolidBrush(SelectedColor); + + // Create and Draw the arrow + System.Drawing.Drawing2D.GraphicsPath pth = new System.Drawing.Drawing2D.GraphicsPath(); + var TopRight_X= RightToLeft == RightToLeft.Yes ? 0.5f + SkinManager.FORM_PADDING : Width - 0.5f - SkinManager.FORM_PADDING; + PointF TopRight = new PointF(TopRight_X, (this.Height >> 1) - 2.5f); + var MidBottom_X = RightToLeft == RightToLeft.Yes ? 4.5f + SkinManager.FORM_PADDING : Width - 4.5f - SkinManager.FORM_PADDING; + PointF MidBottom = new PointF(MidBottom_X , (this.Height >> 1) + 2.5f); + var TopLeft_X = RightToLeft == RightToLeft.Yes ? 8.5f + SkinManager.FORM_PADDING : Width - 8.5f - SkinManager.FORM_PADDING; + PointF TopLeft = new PointF(TopLeft_X, (this.Height >> 1) - 2.5f); + pth.AddLine(TopLeft, TopRight); + pth.AddLine(TopRight, MidBottom); + + g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; + g.FillPath((SolidBrush)(Enabled ? DroppedDown || Focused ? + SelectedBrush : //DroppedDown or Focused + SkinManager.TextHighEmphasisBrush : //Not DroppedDown and not Focused + new SolidBrush(DrawHelper.BlendColor(SkinManager.TextHighEmphasisColor, SkinManager.SwitchOffDisabledThumbColor, 197)) //Disabled + ), pth); + g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; + + // HintText + bool userTextPresent = SelectedIndex >= 0; + var RectangleWidth = RightToLeft == RightToLeft.Yes ? Width - (SkinManager.FORM_PADDING * 2) : Width; + Rectangle hintRect = new Rectangle(SkinManager.FORM_PADDING, ClientRectangle.Y, RectangleWidth, LINE_Y); + int hintTextSize = 16; + + // bottom line base + g.FillRectangle(SkinManager.DividersAlternativeBrush, 0, LINE_Y, Width, 1); + + if (!_animationManager.IsAnimating()) + { + // No animation + if (hasHint && UseTallSize && (DroppedDown || Focused || SelectedIndex >= 0)) + { + // hint text + hintRect = new Rectangle(SkinManager.FORM_PADDING, TEXT_SMALL_Y, RectangleWidth, TEXT_SMALL_SIZE); + hintTextSize = 12; + } + + // bottom line + if (DroppedDown || Focused) + { + g.FillRectangle(SelectedBrush, 0, LINE_Y, Width, 2); + } + } + else + { + // Animate - Focus got/lost + double animationProgress = _animationManager.GetProgress(); + + // hint Animation + if (hasHint && UseTallSize) + { + hintRect = new Rectangle( + SkinManager.FORM_PADDING, + userTextPresent && !_animationManager.IsAnimating() ? (TEXT_SMALL_Y) : ClientRectangle.Y + (int)((TEXT_SMALL_Y - ClientRectangle.Y) * animationProgress), + RectangleWidth, + userTextPresent && !_animationManager.IsAnimating() ? (TEXT_SMALL_SIZE) : (int)(LINE_Y + (TEXT_SMALL_SIZE - LINE_Y) * animationProgress)); + hintTextSize = userTextPresent && !_animationManager.IsAnimating() ? 12 : (int)(16 + (12 - 16) * animationProgress); + } + + // Line Animation + int LineAnimationWidth = (int)(Width * animationProgress); + int LineAnimationX = (Width / 2) - (LineAnimationWidth / 2); + g.FillRectangle(SelectedBrush, LineAnimationX, LINE_Y, LineAnimationWidth, 2); + } + + + + // Calc text Rect + RectangleWidth = RightToLeft == RightToLeft.Yes ? ClientRectangle.Width - SkinManager.FORM_PADDING - (SkinManager.FORM_PADDING * 3 - 8) : ClientRectangle.Width - SkinManager.FORM_PADDING * 3 - 8; + var RectangleX= RightToLeft == RightToLeft.Yes ? SkinManager.FORM_PADDING * 3 - 8 : SkinManager.FORM_PADDING; + Rectangle textRect = new Rectangle( + RectangleX, + hasHint && UseTallSize ? (hintRect.Y + hintRect.Height) - 2 : ClientRectangle.Y, + RectangleWidth, + hasHint && UseTallSize ? LINE_Y - (hintRect.Y + hintRect.Height) : LINE_Y); + + g.Clip = new Region(textRect); + using (NativeTextRenderer nativeText = new NativeTextRenderer(g)) + { + // Draw user text + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + nativeText.DrawTransparentText( + Text, + SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft), + Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor, + textRect.Location, + textRect.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + + g.ResetClip(); + + // Draw hint text + if (hasHint && (UseTallSize || string.IsNullOrEmpty(Text))) + { + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + using (NativeTextRenderer nativeText = new NativeTextRenderer(g)) + { + nativeText.DrawTransparentText( + Hint, + SkinManager.getTextBoxFontBySize(hintTextSize,RightToLeft), + Enabled ? DroppedDown || Focused ? + SelectedColor : // Focus + SkinManager.TextMediumEmphasisColor : // not focused + SkinManager.TextDisabledOrHintColor, // Disabled + hintRect.Location, + hintRect.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + } + } + + private void CustomMeasureItem(object sender, System.Windows.Forms.MeasureItemEventArgs e) + { + e.ItemHeight = HEIGHT - 7; + } + + private void CustomDrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) + { + if (e.Index < 0 || e.Index > Items.Count || !Focused) return; + + Graphics g = e.Graphics; + + // Draw the background of the item. + g.FillRectangle(SkinManager.BackgroundBrush, e.Bounds); + + // Hover + if (e.State.HasFlag(DrawItemState.Focus)) // Focus == hover + { + g.FillRectangle(SkinManager.BackgroundHoverBrush, e.Bounds); + } + + string Text = ""; + if (!string.IsNullOrWhiteSpace(DisplayMember)) + { + if (Items[e.Index].GetType() != typeof(DataRowView)) + { + var item = Items[e.Index].GetType().GetProperty(DisplayMember)?.GetValue(Items[e.Index]); + Text = item?.ToString(); + } + else + { + var table = ((DataRow)Items[e.Index].GetType().GetProperty("Row")?.GetValue(Items[e.Index]))?.Table; + Text = table?.Rows[e.Index][DisplayMember].ToString(); + } + } + else + { + Text = Items[e.Index].ToString(); + } + + using (NativeTextRenderer nativeText = new NativeTextRenderer(g)) + { + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + nativeText.DrawTransparentText( + Text, + SkinManager.getFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft), + SkinManager.TextHighEmphasisNoAlphaColor, + new Point(e.Bounds.Location.X + SkinManager.FORM_PADDING, e.Bounds.Location.Y), + new Size(e.Bounds.Size.Width - SkinManager.FORM_PADDING * 2, e.Bounds.Size.Height), + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + } + + protected override void OnCreateControl() + { + base.OnCreateControl(); + MouseState = MouseState.OUT; + MeasureItem += CustomMeasureItem; + DrawItem += CustomDrawItem; + DropDownStyle = ComboBoxStyle.DropDownList; + DrawMode = DrawMode.OwnerDrawVariable; + recalculateAutoSize(); + setHeightVars(); + } + + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + recalculateAutoSize(); + setHeightVars(); + } + + private void setHeightVars() + { + HEIGHT = UseTallSize ? 50 : 36; + Size = new Size(Size.Width, HEIGHT); + LINE_Y = HEIGHT - BOTTOM_PADDING; + ItemHeight = HEIGHT - 7; + DropDownHeight = ItemHeight * MaxDropDownItems + 2; + } + + public void recalculateAutoSize() + { + if (!AutoResize) return; + + int w = DropDownWidth; + int padding = SkinManager.FORM_PADDING * 3; + int vertScrollBarWidth = (Items.Count > MaxDropDownItems) ? SystemInformation.VerticalScrollBarWidth : 0; + + Graphics g = CreateGraphics(); + using (NativeTextRenderer nativeText = new NativeTextRenderer(g)) + { + var itemsList = this.Items.Cast().Select(item => item.ToString()); + foreach (string s in itemsList) + { + int newWidth = nativeText.MeasureLogString(s, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft)).Width + vertScrollBarWidth + padding; + if (w < newWidth) w = newWidth; + } + } + + if (Width != w) + { + DropDownWidth = w; + Width = w; + } + } + } +} diff --git a/MaterialSkin/Controls/MaterialContextMenuStrip.cs b/MaterialSkin/Controls/MaterialContextMenuStrip.cs index a3989815..f2316469 100644 --- a/MaterialSkin/Controls/MaterialContextMenuStrip.cs +++ b/MaterialSkin/Controls/MaterialContextMenuStrip.cs @@ -7,6 +7,7 @@ using System.Drawing.Text; using System.Windows.Forms; + [ToolboxItem(false)] public class MaterialContextMenuStrip : ContextMenuStrip, IMaterialControl { //Properties for managing the material design properties @@ -29,7 +30,8 @@ public class MaterialContextMenuStrip : ContextMenuStrip, IMaterialControl public MaterialContextMenuStrip() { - Renderer = new MaterialToolStripRender(); + + Renderer = new MaterialToolStripRender(RightToLeft); AnimationManager = new AnimationManager(false) { @@ -80,7 +82,7 @@ public class MaterialToolStripMenuItem : ToolStripMenuItem public MaterialToolStripMenuItem() { AutoSize = false; - Size = new Size(120, 30); + Size = new Size(128, 32); } protected override ToolStripDropDown CreateDefaultDropDown() @@ -97,9 +99,16 @@ protected override ToolStripDropDown CreateDefaultDropDown() internal class MaterialToolStripRender : ToolStripProfessionalRenderer, IMaterialControl { + private const int LEFT_PADDING = 16; + private const int RIGHT_PADDING = 8; + //Properties for managing the material design properties public int Depth { get; set; } - + public RightToLeft RightToLeft; + public MaterialToolStripRender(RightToLeft _RightToLeft) + { + RightToLeft = _RightToLeft; + } public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; public MouseState MouseState { get; set; } @@ -110,11 +119,11 @@ protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; var itemRect = GetItemRect(e.Item); - var textRect = new Rectangle(24, itemRect.Y, itemRect.Width - (24 + 16), itemRect.Height); + var textRect = new Rectangle(LEFT_PADDING, itemRect.Y, itemRect.Width - (LEFT_PADDING + RIGHT_PADDING), itemRect.Height); using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) { - NativeText.DrawTransparentText(e.Text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body2), + NativeText.DrawTransparentText(e.Text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body2, RightToLeft), e.Item.Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor, textRect.Location, textRect.Size, @@ -125,11 +134,11 @@ protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) { var g = e.Graphics; - g.Clear(SkinManager.BackdropColor); + g.Clear(SkinManager.BackgroundColor); //Draw background var itemRect = GetItemRect(e.Item); - g.FillRectangle(e.Item.Selected && e.Item.Enabled ? SkinManager.BackgroundFocusBrush : SkinManager.BackdropBrush, itemRect); + g.FillRectangle(e.Item.Selected && e.Item.Enabled ? SkinManager.BackgroundFocusBrush : SkinManager.BackgroundBrush, itemRect); //Ripple animation var toolStrip = e.ToolStrip as MaterialContextMenuStrip; @@ -158,7 +167,7 @@ protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e) { var g = e.Graphics; - g.FillRectangle(SkinManager.BackdropBrush, e.Item.Bounds); + g.FillRectangle(SkinManager.BackgroundBrush, e.Item.Bounds); g.DrawLine( new Pen(SkinManager.DividersColor), new Point(e.Item.Bounds.Left, e.Item.Bounds.Height / 2), @@ -167,11 +176,7 @@ protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e) protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) { - var g = e.Graphics; - - g.DrawRectangle( - new Pen(SkinManager.DividersColor), - new Rectangle(e.AffectedBounds.X, e.AffectedBounds.Y, e.AffectedBounds.Width - 1, e.AffectedBounds.Height - 1)); + e.ToolStrip.BackColor = SkinManager.BackgroundColor; } protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) @@ -196,7 +201,7 @@ protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) private Rectangle GetItemRect(ToolStripItem item) { - return new Rectangle(0, item.ContentRectangle.Y, item.ContentRectangle.Width + 4, item.ContentRectangle.Height); + return new Rectangle(0, item.ContentRectangle.Y, item.ContentRectangle.Width , item.ContentRectangle.Height); } } -} \ No newline at end of file +} diff --git a/MaterialSkin/Controls/MaterialDialog.cs b/MaterialSkin/Controls/MaterialDialog.cs new file mode 100644 index 00000000..c5fa7b59 --- /dev/null +++ b/MaterialSkin/Controls/MaterialDialog.cs @@ -0,0 +1,326 @@ +namespace MaterialSkin.Controls +{ + using MaterialSkin.Animations; + using System; + using System.ComponentModel; + using System.Drawing; + using System.Drawing.Drawing2D; + using System.Windows.Forms; + using System.Runtime.InteropServices; + + public class MaterialDialog : MaterialForm + { + + private const int LEFT_RIGHT_PADDING = 24; + private const int BUTTON_PADDING = 8; + private const int BUTTON_HEIGHT = 36; + private const int TEXT_TOP_PADDING = 17; + private const int TEXT_BOTTOM_PADDING = 28; + private int _header_Height = 40; + + private MaterialButton _validationButton = new MaterialButton(); + private MaterialButton _cancelButton = new MaterialButton(); + private AnimationManager _AnimationManager; + private bool CloseAnimation = false; + private Form _formOverlay; + private String _text; + private String _title; + + /// + /// The Collection for the Buttons + /// + //public ObservableCollection Buttons { get; set; } + + [DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")] + private static extern IntPtr CreateRoundRectRgn + ( + int nLeftRect, // x-coordinate of upper-left corner + int nTopRect, // y-coordinate of upper-left corner + int nRightRect, // x-coordinate of lower-right corner + int nBottomRect, // y-coordinate of lower-right corner + int nWidthEllipse, // width of ellipse + int nHeightEllipse // height of ellipse + ); + + /// + /// Constructer Setting up the Layout + /// + public MaterialDialog( + Form ParentForm, string Title, + string Text, string ValidationButtonText, + bool ShowCancelButton, + string CancelButtonText, + bool UseAccentColor, + RightToLeft rightToLeft = RightToLeft.No) :base(rightToLeft) + { + _formOverlay = new Form + { + BackColor = Color.Black, + Opacity = 0.5, + MinimizeBox = false, + MaximizeBox = false, + Text = "", + ShowIcon = false, + ControlBox = false, + FormBorderStyle = FormBorderStyle.None, + Size = new Size(ParentForm.Width, ParentForm.Height), + ShowInTaskbar = false, + Owner = ParentForm, + Visible = true, + Location = new Point(ParentForm.Location.X, ParentForm.Location.Y), + Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom, + }; + + _title = Title; + if (Title.Length == 0) + _header_Height = 0; + else + _header_Height = 40; + + _text = Text; + ShowInTaskbar = false; + Sizable = false; + + BackColor = SkinManager.BackgroundColor; + FormStyle = FormStyles.StatusAndActionBar_None; + + _AnimationManager = new AnimationManager(); + _AnimationManager.AnimationType = AnimationType.EaseOut; + _AnimationManager.Increment = 0.03; + _AnimationManager.OnAnimationProgress += _AnimationManager_OnAnimationProgress; + + _validationButton = new MaterialButton + { + AutoSize = false, + DialogResult = DialogResult.OK, + DrawShadows = false, + Type = MaterialButton.MaterialButtonType.Text, + UseAccentColor = UseAccentColor, + Text = ValidationButtonText + }; + _cancelButton = new MaterialButton + { + AutoSize = false, + DialogResult = DialogResult.Cancel, + DrawShadows = false, + Type = MaterialButton.MaterialButtonType.Text, + UseAccentColor = UseAccentColor, + Visible = ShowCancelButton, + Text = CancelButtonText + }; + + this.AcceptButton = _validationButton; + this.CancelButton = _cancelButton; + + if (!Controls.Contains(_validationButton)) + Controls.Add(_validationButton); + if (!Controls.Contains(_cancelButton)) + Controls.Add(_cancelButton); + + Width = 560; + int TextWidth = TextRenderer.MeasureText(_text, SkinManager.getFontByType(MaterialSkinManager.fontType.Body1, RightToLeft)).Width; + int RectWidth = Width - (2 * LEFT_RIGHT_PADDING) - BUTTON_PADDING; + int RectHeight = ((TextWidth / RectWidth) + 1) * 19; + Rectangle textRect = new Rectangle( + LEFT_RIGHT_PADDING, + _header_Height + TEXT_TOP_PADDING, + RectWidth, + RectHeight + 9); + + Height = _header_Height + TEXT_TOP_PADDING + textRect.Height + TEXT_BOTTOM_PADDING + 52; //560; + Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 6, 6)); + + int _buttonWidth = ((TextRenderer.MeasureText(ValidationButtonText, SkinManager.getFontByType(MaterialSkinManager.fontType.Button, RightToLeft))).Width + 32); + Rectangle _validationbuttonBounds = new Rectangle((Width) - BUTTON_PADDING - _buttonWidth, Height - BUTTON_PADDING - BUTTON_HEIGHT, _buttonWidth, BUTTON_HEIGHT); + _validationButton.Width = _validationbuttonBounds.Width; + _validationButton.Height = _validationbuttonBounds.Height; + _validationButton.Top = _validationbuttonBounds.Top; + _validationButton.Left = _validationbuttonBounds.Left; //Button minimum width management + _validationButton.Visible = true; + + _buttonWidth = ((TextRenderer.MeasureText(CancelButtonText, SkinManager.getFontByType(MaterialSkinManager.fontType.Button, RightToLeft))).Width + 32); + Rectangle _cancelbuttonBounds = new Rectangle((_validationbuttonBounds.Left) - BUTTON_PADDING - _buttonWidth, Height - BUTTON_PADDING - BUTTON_HEIGHT, _buttonWidth, BUTTON_HEIGHT); + _cancelButton.Width = _cancelbuttonBounds.Width; + _cancelButton.Height = _cancelbuttonBounds.Height; + _cancelButton.Top = _cancelbuttonBounds.Top; + _cancelButton.Left = _cancelbuttonBounds.Left; //Button minimum width management + + + //this.ShowDialog(); + //this Dispose(); + //return materialDialogResult; + } + + public MaterialDialog(Form ParentForm,RightToLeft rightToLeft = RightToLeft.No) : this(ParentForm, "Title", "Dialog box", "OK", false, "Cancel", false, rightToLeft) + { + } + + public MaterialDialog(Form ParentForm, string Text, RightToLeft rightToLeft = RightToLeft.No) : this(ParentForm, "Title", Text, "OK", false, "Cancel", false, rightToLeft) + { + } + + public MaterialDialog(Form ParentForm, string Title, string Text, RightToLeft rightToLeft = RightToLeft.No) : this(ParentForm, Title, Text, "OK", false, "Cancel", false, rightToLeft) + { + } + + public MaterialDialog(Form ParentForm, string Title, string Text, string ValidationButtonText, RightToLeft rightToLeft = RightToLeft.No) : this(ParentForm, Title, Text, ValidationButtonText, false, "Cancel", false, rightToLeft) + { + } + + public MaterialDialog(Form ParentForm, string Title, string Text, bool ShowCancelButton, RightToLeft rightToLeft = RightToLeft.No) : this(ParentForm, Title, Text, "OK", ShowCancelButton, "Cancel", false, rightToLeft) + { + } + + public MaterialDialog(Form ParentForm, string Title, string Text, bool ShowCancelButton, string CancelButtonText, RightToLeft rightToLeft = RightToLeft.No) : this(ParentForm, Title, Text, "OK", ShowCancelButton, CancelButtonText, false, rightToLeft) + { + } + + public MaterialDialog(Form ParentForm, string Title, string Text, string ValidationButtonText, bool ShowCancelButton, string CancelButtonText, RightToLeft rightToLeft = RightToLeft.No) : this(ParentForm, Title, Text, ValidationButtonText, ShowCancelButton, CancelButtonText, false, rightToLeft) + { + } + + + /// + /// Sets up the Starting Location and starts the Animation + /// + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + + Location = new Point(Convert.ToInt32(Owner.Location.X + (Owner.Width / 2) - (Width / 2)), Convert.ToInt32(Owner.Location.Y + (Owner.Height/2) - (Height / 2))); + _AnimationManager.StartNewAnimation(AnimationDirection.In); + } + + /// + /// Animates the Form slides + /// + void _AnimationManager_OnAnimationProgress(object sender) + { + if (CloseAnimation) + { + Opacity = _AnimationManager.GetProgress(); + } + } + + /// + /// Ovverides the Paint to create the solid colored backcolor + /// + protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) + { + + Graphics g = e.Graphics; + g.SmoothingMode = SmoothingMode.AntiAlias; + + e.Graphics.Clear(BackColor); + + + // Calc title Rect + Rectangle titleRect = new Rectangle( + LEFT_RIGHT_PADDING, + 0, + Width - (2 * LEFT_RIGHT_PADDING) , + _header_Height); + + //Draw title + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + // Draw header text + NativeText.DrawTransparentText( + _title, + SkinManager.getLogFontByType(MaterialSkinManager.fontType.H6, RightToLeft), + SkinManager.TextHighEmphasisColor, + titleRect.Location, + titleRect.Size, + NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Bottom); + } + + // Calc text Rect + + int TextWidth = TextRenderer.MeasureText(_text, SkinManager.getFontByType(MaterialSkinManager.fontType.Body1, RightToLeft)).Width; + int RectWidth = Width - (2 * LEFT_RIGHT_PADDING) - BUTTON_PADDING; + int RectHeight = ((TextWidth / RectWidth) + 1) * 19; + + Rectangle textRect = new Rectangle( + LEFT_RIGHT_PADDING, + _header_Height+17, + RectWidth, + RectHeight +19); + + //Draw Text + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + // Draw header text + NativeText.DrawMultilineTransparentText( + _text, + SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1, RightToLeft), + SkinManager.TextHighEmphasisColor, + textRect.Location, + textRect.Size, + NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); + } + + } + + /// + /// Overrides the Closing Event to Animate the Slide Out + /// + protected override void OnClosing(System.ComponentModel.CancelEventArgs e) + { + _formOverlay.Visible = false; + _formOverlay.Close(); + _formOverlay.Dispose(); + + DialogResult res = this.DialogResult; + + base.OnClosing(e); + } + + /// + /// Closes the Form after the pull out animation + /// + void _AnimationManager_OnAnimationFinished(object sender) + { + Close(); + } + + protected override bool ProcessDialogKey(Keys keyData) + { + if (Form.ModifierKeys == Keys.None && keyData == Keys.Escape) + { + this.Close(); + return true; + } + return base.ProcessDialogKey(keyData); + } + + private void InitializeComponent() + { + this.SuspendLayout(); + this.ClientSize = new System.Drawing.Size(560, 182); + this.Name = "Dialog"; + this.ResumeLayout(false); + + } + + /// + /// Prevents the Form from beeing dragged + /// + protected override void WndProc(ref Message message) + { + const int WM_SYSCOMMAND = 0x0112; + const int SC_MOVE = 0xF010; + + switch (message.Msg) + { + case WM_SYSCOMMAND: + int command = message.WParam.ToInt32() & 0xfff0; + if (command == SC_MOVE) + return; + break; + } + + base.WndProc(ref message); + } + + } +} diff --git a/MaterialSkin/Controls/MaterialDrawer.cs b/MaterialSkin/Controls/MaterialDrawer.cs index c4fcd7f2..29e78914 100644 --- a/MaterialSkin/Controls/MaterialDrawer.cs +++ b/MaterialSkin/Controls/MaterialDrawer.cs @@ -1,665 +1,788 @@ -namespace MaterialSkin.Controls -{ - using MaterialSkin.Animations; - using System; - using System.Collections.Generic; - using System.ComponentModel; - using System.Drawing; - using System.Drawing.Drawing2D; - using System.Drawing.Imaging; - using System.Drawing.Text; - using System.Windows.Forms; - - public class MaterialDrawer : Control, IMaterialControl - { - // TODO: Invalidate when changing custom properties - - private bool _showIconsWhenHidden; - - [Category("Drawer")] - public bool ShowIconsWhenHidden - { - get - { - return _showIconsWhenHidden; - } - set - { - if (_showIconsWhenHidden != value) - { - _showIconsWhenHidden = value; - UpdateTabRects(); - preProcessIcons(); - showHideAnimation(); - Paint(new PaintEventArgs(CreateGraphics(), ClientRectangle)); - DrawerShowIconsWhenHiddenChanged?.Invoke(this); - } - } - } - - private bool _isOpen; - - [Category("Drawer")] - public bool IsOpen - { - get - { - return _isOpen; - } - set - { - _isOpen = value; - if (value) - Show(); - else - Hide(); - } - } - - [Category("Drawer")] - public bool AutoHide { get; set; } - - [Category("Drawer")] - private bool _useColors; - - public bool UseColors - { - get - { - return _useColors; - } - set - { - _useColors = value; - preProcessIcons(); - Invalidate(); - } - } - - [Category("Drawer")] - private bool _highlightWithAccent; - - public bool HighlightWithAccent - { - get - { - return _highlightWithAccent; - } - set - { - _highlightWithAccent = value; - preProcessIcons(); - Invalidate(); - } - } - - [Category("Drawer")] - private bool _backgroundWithAccent; - - public bool BackgroundWithAccent - { - get - { - return _backgroundWithAccent; - } - set - { - _backgroundWithAccent = value; - Invalidate(); - } - } - - [Category("Drawer")] - public int IndicatorWidth { get; set; } - - [Browsable(false)] - public int Depth { get; set; } - - [Browsable(false)] - public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; - - [Browsable(false)] - public MouseState MouseState { get; set; } - - public delegate void DrawerStateHandler(object sender); +namespace MaterialSkin.Controls +{ + using MaterialSkin.Animations; + using System; + using System.Collections.Generic; + using System.ComponentModel; + using System.Drawing; + using System.Drawing.Drawing2D; + using System.Drawing.Imaging; + using System.Drawing.Text; + using System.Windows.Forms; + + public class MaterialDrawer : Control, IMaterialControl + { + // TODO: Invalidate when changing custom properties + + private bool _showIconsWhenHidden; + public new RightToLeft RightToLeft; + + [Category("Drawer")] + public bool ShowIconsWhenHidden + { + get + { + return _showIconsWhenHidden; + } + set + { + if (_showIconsWhenHidden != value) + { + _showIconsWhenHidden = value; + UpdateTabRects(); + preProcessIcons(); + showHideAnimation(); + Paint(new PaintEventArgs(CreateGraphics(), ClientRectangle)); + DrawerShowIconsWhenHiddenChanged?.Invoke(this); + } + } + } + + private bool _isOpen; + + [Category("Drawer")] + public bool IsOpen + { + get + { + return _isOpen; + } + set + { + _isOpen = value; + if (value) + Show(); + else + Hide(); + } + } + + [Category("Drawer")] + public bool AutoHide { get; set; } + + [Category("Drawer")] + public bool AutoShow { get; set; } + + [Category("Drawer")] + private bool _useColors; + + public bool UseColors + { + get + { + return _useColors; + } + set + { + _useColors = value; + preProcessIcons(); + Invalidate(); + } + } + + [Category("Drawer")] + private bool _highlightWithAccent; + + public bool HighlightWithAccent + { + get + { + return _highlightWithAccent; + } + set + { + _highlightWithAccent = value; + preProcessIcons(); + Invalidate(); + } + } + + [Category("Drawer")] + private bool _backgroundWithAccent; + + public bool BackgroundWithAccent + { + get + { + return _backgroundWithAccent; + } + set + { + _backgroundWithAccent = value; + Invalidate(); + } + } + + [Category("Drawer")] + public int IndicatorWidth { get; set; } + + [Browsable(false)] + public int Depth { get; set; } + + [Browsable(false)] + public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; + + [Browsable(false)] + public MouseState MouseState { get; set; } + + public delegate void DrawerStateHandler(object sender); public event DrawerStateHandler DrawerStateChanged; - + public event DrawerStateHandler DrawerBeginOpen; - + public event DrawerStateHandler DrawerEndOpen; - + public event DrawerStateHandler DrawerBeginClose; - + public event DrawerStateHandler DrawerEndClose; - - public event DrawerStateHandler DrawerShowIconsWhenHiddenChanged; - - // icons - private Dictionary iconsBrushes; - - private Dictionary iconsSelectedBrushes; - private Dictionary iconsSize; - private int prevLocation; - - private int rippleSize = 0; - - private MaterialTabControl _baseTabControl; - - [Category("Behavior")] - public MaterialTabControl BaseTabControl - { - get { return _baseTabControl; } - set - { - _baseTabControl = value; - if (_baseTabControl == null) - return; - - UpdateTabRects(); - preProcessIcons(); - - // Other helpers - - _previousSelectedTabIndex = _baseTabControl.SelectedIndex; - _baseTabControl.Deselected += (sender, args) => - { - _previousSelectedTabIndex = _baseTabControl.SelectedIndex; - }; - _baseTabControl.SelectedIndexChanged += (sender, args) => - { - _clickAnimManager.SetProgress(0); - _clickAnimManager.StartNewAnimation(AnimationDirection.In); - }; - _baseTabControl.ControlAdded += delegate - { - Invalidate(); - }; - _baseTabControl.ControlRemoved += delegate - { - Invalidate(); - }; - } - } - - private void preProcessIcons() - { - // pre-process and pre-allocate texture brushes (icons) - if (_baseTabControl == null || _baseTabControl.TabCount == 0 || _baseTabControl.ImageList == null || _drawerItemRects == null || _drawerItemRects.Count == 0) - return; - - // Calculate lightness and color - float l = UseColors ? SkinManager.ColorScheme.TextColor.R / 255 : SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? 0f : 1f; - float r = (_highlightWithAccent ? SkinManager.ColorScheme.AccentColor.R : SkinManager.ColorScheme.PrimaryColor.R) / 255f; - float g = (_highlightWithAccent ? SkinManager.ColorScheme.AccentColor.G : SkinManager.ColorScheme.PrimaryColor.G) / 255f; - float b = (_highlightWithAccent ? SkinManager.ColorScheme.AccentColor.B : SkinManager.ColorScheme.PrimaryColor.B) / 255f; - - // Create matrices - float[][] matrixGray = { - new float[] { 0, 0, 0, 0, 0}, // Red scale factor - new float[] { 0, 0, 0, 0, 0}, // Green scale factor - new float[] { 0, 0, 0, 0, 0}, // Blue scale factor - new float[] { 0, 0, 0, .7f, 0}, // alpha scale factor - new float[] { l, l, l, 0, 1}};// offset - - float[][] matrixColor = { - new float[] { 0, 0, 0, 0, 0}, // Red scale factor - new float[] { 0, 0, 0, 0, 0}, // Green scale factor - new float[] { 0, 0, 0, 0, 0}, // Blue scale factor - new float[] { 0, 0, 0, 1, 0}, // alpha scale factor - new float[] { r, g, b, 0, 1}};// offset - - ColorMatrix colorMatrixGray = new ColorMatrix(matrixGray); - ColorMatrix colorMatrixColor = new ColorMatrix(matrixColor); - - ImageAttributes grayImageAttributes = new ImageAttributes(); - ImageAttributes colorImageAttributes = new ImageAttributes(); - - // Set color matrices - grayImageAttributes.SetColorMatrix(colorMatrixGray, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); - colorImageAttributes.SetColorMatrix(colorMatrixColor, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); - - // Create brushes - iconsBrushes = new Dictionary(_baseTabControl.TabPages.Count); - iconsSelectedBrushes = new Dictionary(_baseTabControl.TabPages.Count); - iconsSize = new Dictionary(_baseTabControl.TabPages.Count); - - foreach (TabPage tabPage in _baseTabControl.TabPages) - { - // skip items without image - if (String.IsNullOrEmpty(tabPage.ImageKey) || _drawerItemRects == null) - continue; - - // Image Rect - Rectangle destRect = new Rectangle(0, 0, _baseTabControl.ImageList.Images[tabPage.ImageKey].Width, _baseTabControl.ImageList.Images[tabPage.ImageKey].Height); - - // Create a pre-processed copy of the image (GRAY) - Bitmap bgray = new Bitmap(destRect.Width, destRect.Height); - using (Graphics gGray = Graphics.FromImage(bgray)) - { - gGray.DrawImage(_baseTabControl.ImageList.Images[tabPage.ImageKey], - new Point[] { - new Point(0, 0), - new Point(destRect.Width, 0), - new Point(0, destRect.Height), - }, - destRect, GraphicsUnit.Pixel, grayImageAttributes); - } - - // Create a pre-processed copy of the image (PRIMARY COLOR) - Bitmap bcolor = new Bitmap(destRect.Width, destRect.Height); - using (Graphics gColor = Graphics.FromImage(bcolor)) - { - gColor.DrawImage(_baseTabControl.ImageList.Images[tabPage.ImageKey], - new Point[] { - new Point(0, 0), - new Point(destRect.Width, 0), - new Point(0, destRect.Height), - }, - destRect, GraphicsUnit.Pixel, colorImageAttributes); - } - - // added processed image to brush for drawing - TextureBrush textureBrushGray = new TextureBrush(bgray); - TextureBrush textureBrushColor = new TextureBrush(bcolor); - - textureBrushGray.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; - textureBrushColor.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; - - // Translate the brushes to the correct positions - var currentTabIndex = _baseTabControl.TabPages.IndexOf(tabPage); - - Rectangle iconRect = new Rectangle( - _drawerItemRects[currentTabIndex].X + (drawerItemHeight / 2) - (_baseTabControl.ImageList.Images[tabPage.ImageKey].Width / 2), - _drawerItemRects[currentTabIndex].Y + (drawerItemHeight / 2) - (_baseTabControl.ImageList.Images[tabPage.ImageKey].Height / 2), - _baseTabControl.ImageList.Images[tabPage.ImageKey].Width, _baseTabControl.ImageList.Images[tabPage.ImageKey].Height); - - textureBrushGray.TranslateTransform(iconRect.X + iconRect.Width / 2 - _baseTabControl.ImageList.Images[tabPage.ImageKey].Width / 2, - iconRect.Y + iconRect.Height / 2 - _baseTabControl.ImageList.Images[tabPage.ImageKey].Height / 2); - textureBrushColor.TranslateTransform(iconRect.X + iconRect.Width / 2 - _baseTabControl.ImageList.Images[tabPage.ImageKey].Width / 2, - iconRect.Y + iconRect.Height / 2 - _baseTabControl.ImageList.Images[tabPage.ImageKey].Height / 2); - - // add to dictionary - iconsBrushes.Add(tabPage.ImageKey, textureBrushGray); - iconsSelectedBrushes.Add(tabPage.ImageKey, textureBrushColor); - iconsSize.Add(tabPage.ImageKey, new Rectangle(0, 0, iconRect.Width, iconRect.Height)); - } - } - - private int _previousSelectedTabIndex; - - private Point _animationSource; - - private readonly AnimationManager _clickAnimManager; - - private readonly AnimationManager _showHideAnimManager; - - private List _drawerItemRects; - private List _drawerItemPaths; - - private const int TAB_HEADER_PADDING = 24; - - private int drawerItemHeight; - + + public event DrawerStateHandler DrawerShowIconsWhenHiddenChanged; + + public event EventHandler CursorUpdate; + + // icons + private Dictionary iconsBrushes; + + private Dictionary iconsSelectedBrushes; + private Dictionary iconsSize; + private int prevLocation; + + private int rippleSize = 0; + + private MaterialTabControl _baseTabControl; + + [Category("Behavior")] + public MaterialTabControl BaseTabControl + { + get { return _baseTabControl; } + set + { + _baseTabControl = value; + if (_baseTabControl == null) + return; + + UpdateTabRects(); + preProcessIcons(); + + // Other helpers + + _previousSelectedTabIndex = _baseTabControl.SelectedIndex; + _baseTabControl.Deselected += (sender, args) => + { + _previousSelectedTabIndex = _baseTabControl.SelectedIndex; + }; + _baseTabControl.SelectedIndexChanged += (sender, args) => + { + _clickAnimManager.SetProgress(0); + _clickAnimManager.StartNewAnimation(AnimationDirection.In); + }; + _baseTabControl.ControlAdded += delegate + { + Invalidate(); + }; + _baseTabControl.ControlRemoved += delegate + { + Invalidate(); + }; + } + } + + private void preProcessIcons() + { + // pre-process and pre-allocate texture brushes (icons) + if (_baseTabControl == null || _baseTabControl.TabCount == 0 || _baseTabControl.ImageList == null || _drawerItemRects == null || _drawerItemRects.Count == 0) + return; + + // Calculate lightness and color + float l = UseColors ? SkinManager.ColorScheme.TextColor.R / 255 : SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? 0f : 1f; + float r = (_highlightWithAccent ? SkinManager.ColorScheme.AccentColor.R : SkinManager.ColorScheme.PrimaryColor.R) / 255f; + float g = (_highlightWithAccent ? SkinManager.ColorScheme.AccentColor.G : SkinManager.ColorScheme.PrimaryColor.G) / 255f; + float b = (_highlightWithAccent ? SkinManager.ColorScheme.AccentColor.B : SkinManager.ColorScheme.PrimaryColor.B) / 255f; + + // Create matrices + float[][] matrixGray = { + new float[] { 0, 0, 0, 0, 0}, // Red scale factor + new float[] { 0, 0, 0, 0, 0}, // Green scale factor + new float[] { 0, 0, 0, 0, 0}, // Blue scale factor + new float[] { 0, 0, 0, .7f, 0}, // alpha scale factor + new float[] { l, l, l, 0, 1}};// offset + + float[][] matrixColor = { + new float[] { 0, 0, 0, 0, 0}, // Red scale factor + new float[] { 0, 0, 0, 0, 0}, // Green scale factor + new float[] { 0, 0, 0, 0, 0}, // Blue scale factor + new float[] { 0, 0, 0, 1, 0}, // alpha scale factor + new float[] { r, g, b, 0, 1}};// offset + + ColorMatrix colorMatrixGray = new ColorMatrix(matrixGray); + ColorMatrix colorMatrixColor = new ColorMatrix(matrixColor); + + ImageAttributes grayImageAttributes = new ImageAttributes(); + ImageAttributes colorImageAttributes = new ImageAttributes(); + + // Set color matrices + grayImageAttributes.SetColorMatrix(colorMatrixGray, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); + colorImageAttributes.SetColorMatrix(colorMatrixColor, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); + + // Create brushes + iconsBrushes = new Dictionary(_baseTabControl.TabPages.Count); + iconsSelectedBrushes = new Dictionary(_baseTabControl.TabPages.Count); + iconsSize = new Dictionary(_baseTabControl.TabPages.Count); + + foreach (TabPage tabPage in _baseTabControl.TabPages) + { + // skip items without image + if (String.IsNullOrEmpty(tabPage.ImageKey) || _drawerItemRects == null) + continue; + + // Image Rect + Rectangle destRect = new Rectangle(0, 0, _baseTabControl.ImageList.Images[tabPage.ImageKey].Width, _baseTabControl.ImageList.Images[tabPage.ImageKey].Height); + + // Create a pre-processed copy of the image (GRAY) + Bitmap bgray = new Bitmap(destRect.Width, destRect.Height); + using (Graphics gGray = Graphics.FromImage(bgray)) + { + gGray.DrawImage(_baseTabControl.ImageList.Images[tabPage.ImageKey], + new Point[] { + new Point(0, 0), + new Point(destRect.Width, 0), + new Point(0, destRect.Height), + }, + destRect, GraphicsUnit.Pixel, grayImageAttributes); + } + + // Create a pre-processed copy of the image (PRIMARY COLOR) + Bitmap bcolor = new Bitmap(destRect.Width, destRect.Height); + using (Graphics gColor = Graphics.FromImage(bcolor)) + { + gColor.DrawImage(_baseTabControl.ImageList.Images[tabPage.ImageKey], + new Point[] { + new Point(0, 0), + new Point(destRect.Width, 0), + new Point(0, destRect.Height), + }, + destRect, GraphicsUnit.Pixel, colorImageAttributes); + } + + // added processed image to brush for drawing + TextureBrush textureBrushGray = new TextureBrush(bgray); + TextureBrush textureBrushColor = new TextureBrush(bcolor); + + textureBrushGray.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; + textureBrushColor.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; + + // Translate the brushes to the correct positions + var currentTabIndex = _baseTabControl.TabPages.IndexOf(tabPage); + var rectangleX = RightToLeft == RightToLeft.Yes ? Width - ((_baseTabControl.ImageList.Images[tabPage.ImageKey].Width / 2) * 2) - (_drawerItemRects[currentTabIndex].X + (drawerItemHeight / 2) - (_baseTabControl.ImageList.Images[tabPage.ImageKey].Width / 2)) + : (_drawerItemRects[currentTabIndex].X + (drawerItemHeight / 2) - (_baseTabControl.ImageList.Images[tabPage.ImageKey].Width / 2)); + Rectangle iconRect = new Rectangle( + rectangleX, + _drawerItemRects[currentTabIndex].Y + (drawerItemHeight / 2) - (_baseTabControl.ImageList.Images[tabPage.ImageKey].Height / 2), + _baseTabControl.ImageList.Images[tabPage.ImageKey].Width , _baseTabControl.ImageList.Images[tabPage.ImageKey].Height); + + textureBrushGray.TranslateTransform(iconRect.X + iconRect.Width / 2 - _baseTabControl.ImageList.Images[tabPage.ImageKey].Width / 2, + iconRect.Y + iconRect.Height / 2 - _baseTabControl.ImageList.Images[tabPage.ImageKey].Height / 2); + textureBrushColor.TranslateTransform(iconRect.X + iconRect.Width / 2 - _baseTabControl.ImageList.Images[tabPage.ImageKey].Width / 2, + iconRect.Y + iconRect.Height / 2 - _baseTabControl.ImageList.Images[tabPage.ImageKey].Height / 2); + + // add to dictionary + iconsBrushes.Add(tabPage.ImageKey, textureBrushGray); + iconsSelectedBrushes.Add(tabPage.ImageKey, textureBrushColor); + iconsSize.Add(tabPage.ImageKey, new Rectangle(0, 0, iconRect.Width*3, iconRect.Height)); + } + } + + private int _previousSelectedTabIndex; + + private Point _animationSource; + + private readonly AnimationManager _clickAnimManager; + + private readonly AnimationManager _showHideAnimManager; + + private List _drawerItemRects; + private List _drawerItemPaths; + + private const int TAB_HEADER_PADDING = 24; + private const int BORDER_WIDTH = 7; + + private int drawerItemHeight; + public int MinWidth; - - public MaterialDrawer() - { - SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); - Height = 120; - Width = 250; - IndicatorWidth = 0; - _isOpen = true; - ShowIconsWhenHidden = false; - AutoHide = false; - HighlightWithAccent = true; - BackgroundWithAccent = false; - - _showHideAnimManager = new AnimationManager - { - AnimationType = AnimationType.EaseInOut, - Increment = 0.04 - }; - _showHideAnimManager.OnAnimationProgress += sender => - { - Invalidate(); - showHideAnimation(); - }; - _showHideAnimManager.OnAnimationFinished += sender => - { - if (_baseTabControl != null && _drawerItemRects.Count > 0) - rippleSize = _drawerItemRects[_baseTabControl.SelectedIndex].Width; - if (_isOpen) - { - DrawerEndOpen?.Invoke(this); - } - else - { - DrawerEndClose?.Invoke(this); - } - }; - - SkinManager.ColorSchemeChanged += sender => - { - preProcessIcons(); - }; - - SkinManager.ThemeChanged += sender => - { - preProcessIcons(); - }; - - _clickAnimManager = new AnimationManager - { - AnimationType = AnimationType.EaseOut, - Increment = 0.04 - }; - _clickAnimManager.OnAnimationProgress += sender => Invalidate(); - } - - [EditorBrowsable(EditorBrowsableState.Advanced)] - protected override void InitLayout() - { - drawerItemHeight = TAB_HEADER_PADDING * 2 - SkinManager.FORM_PADDING / 2; - MinWidth = (int)(SkinManager.FORM_PADDING * 1.5 + drawerItemHeight); - _showHideAnimManager.SetProgress(_isOpen ? 0 : 1); - showHideAnimation(); - Invalidate(); - - base.InitLayout(); - } - - private void showHideAnimation() - { - var showHideAnimProgress = _showHideAnimManager.GetProgress(); - if (_showHideAnimManager.IsAnimating()) - { - if (ShowIconsWhenHidden) - { - Location = new Point((int)((-Width + MinWidth) * showHideAnimProgress), Location.Y); - } - else - { - Location = new Point((int)(-Width * showHideAnimProgress), Location.Y); - } - } - else - { - if (_isOpen) - { - Location = new Point(0, Location.Y); - } - else - { - if (ShowIconsWhenHidden) - { - Location = new Point((int)(-Width + MinWidth), Location.Y); - } - else - { - Location = new Point(-Width, Location.Y); - } - } - } - UpdateTabRects(); - } - - protected override void OnPaint(PaintEventArgs e) - { - Paint(e); - } - - private new void Paint(PaintEventArgs e) - { - var g = e.Graphics; - g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; - - // redraw stuff - g.Clear(UseColors ? SkinManager.ColorScheme.PrimaryColor : SkinManager.BackdropColor); - - if (_baseTabControl == null) - return; - - if (!_clickAnimManager.IsAnimating() || _drawerItemRects == null || _drawerItemRects.Count != _baseTabControl.TabCount) - UpdateTabRects(); - - if (_drawerItemRects == null || _drawerItemRects.Count != _baseTabControl.TabCount) - return; - - // Click Animation - var clickAnimProgress = _clickAnimManager.GetProgress(); - // Show/Hide Drawer Animation - var showHideAnimProgress = _showHideAnimManager.GetProgress(); - var rSize = (int)(clickAnimProgress * rippleSize * 1.75); - - int dx = prevLocation - Location.X; - prevLocation = Location.X; - - // Ripple - if (_clickAnimManager.IsAnimating()) - { - var rippleBrush = new SolidBrush(Color.FromArgb((int)(70 - (clickAnimProgress * 70)), - UseColors ? SkinManager.ColorScheme.AccentColor : // Using colors - SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? SkinManager.ColorScheme.PrimaryColor : // light theme - SkinManager.ColorScheme.LightPrimaryColor)); // dark theme - - g.SetClip(_drawerItemPaths[_baseTabControl.SelectedIndex]); - g.FillEllipse(rippleBrush, new Rectangle(_animationSource.X + dx - (rSize / 2), _animationSource.Y - rSize / 2, rSize, rSize)); - g.ResetClip(); - rippleBrush.Dispose(); - } - - // Draw menu items - foreach (TabPage tabPage in _baseTabControl.TabPages) - { - var currentTabIndex = _baseTabControl.TabPages.IndexOf(tabPage); - - // Background - Brush bgBrush = new SolidBrush(Color.FromArgb(CalculateAlpha(60, 0, currentTabIndex, clickAnimProgress, 1 - showHideAnimProgress), - UseColors ? _backgroundWithAccent ? SkinManager.ColorScheme.AccentColor : SkinManager.ColorScheme.LightPrimaryColor : // using colors - _backgroundWithAccent ? SkinManager.ColorScheme.AccentColor : // defaul accent - SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? SkinManager.ColorScheme.PrimaryColor : // default light - SkinManager.ColorScheme.LightPrimaryColor)); // default dark - g.FillPath(bgBrush, _drawerItemPaths[currentTabIndex]); - bgBrush.Dispose(); - - // Text - Color textColor = Color.FromArgb(CalculateAlphaZeroWhenClosed(SkinManager.TextHighEmphasisColor.A, UseColors ? SkinManager.TextMediumEmphasisColor.A : 255, currentTabIndex, clickAnimProgress, 1 - showHideAnimProgress), // alpha - UseColors ? (currentTabIndex == _baseTabControl.SelectedIndex ? (_highlightWithAccent ? SkinManager.ColorScheme.AccentColor : SkinManager.ColorScheme.PrimaryColor) // Use colors - selected - : SkinManager.ColorScheme.TextColor) : // Use colors - not selected - (currentTabIndex == _baseTabControl.SelectedIndex ? (_highlightWithAccent ? SkinManager.ColorScheme.AccentColor : SkinManager.ColorScheme.PrimaryColor) : // selected - SkinManager.TextHighEmphasisColor)); - - IntPtr textFont = SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle2); - - Rectangle textRect = _drawerItemRects[currentTabIndex]; - textRect.X += _baseTabControl.ImageList != null ? drawerItemHeight : (int)(SkinManager.FORM_PADDING * 0.75); - textRect.Width -= SkinManager.FORM_PADDING << 2; - - using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) - { - NativeText.DrawTransparentText(tabPage.Text, textFont, textColor, textRect.Location, textRect.Size, NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); - } - - // Icons - if (_baseTabControl.ImageList != null && !String.IsNullOrEmpty(tabPage.ImageKey)) - { - Rectangle iconRect = new Rectangle( - _drawerItemRects[currentTabIndex].X + (drawerItemHeight >> 1) - (iconsSize[tabPage.ImageKey].Width >> 1), - _drawerItemRects[currentTabIndex].Y + (drawerItemHeight >> 1) - (iconsSize[tabPage.ImageKey].Height >> 1), - iconsSize[tabPage.ImageKey].Width, iconsSize[tabPage.ImageKey].Height); - - if (ShowIconsWhenHidden) - { - iconsBrushes[tabPage.ImageKey].TranslateTransform(dx, 0); - iconsSelectedBrushes[tabPage.ImageKey].TranslateTransform(dx, 0); - } - - g.FillRectangle(currentTabIndex == _baseTabControl.SelectedIndex ? iconsSelectedBrushes[tabPage.ImageKey] : iconsBrushes[tabPage.ImageKey], iconRect); - } - } - - // Draw divider if not using colors - if (!UseColors) - { - using (Pen dividerPen = new Pen(SkinManager.DividersColor, 1)) - { - g.DrawLine(dividerPen, Width - 1, 0, Width - 1, Height); - } - } - - // Animate tab indicator - var previousSelectedTabIndexIfHasOne = _previousSelectedTabIndex == -1 ? _baseTabControl.SelectedIndex : _previousSelectedTabIndex; - var previousActiveTabRect = _drawerItemRects[previousSelectedTabIndexIfHasOne]; - var activeTabPageRect = _drawerItemRects[_baseTabControl.SelectedIndex]; - - var y = previousActiveTabRect.Y + (int)((activeTabPageRect.Y - previousActiveTabRect.Y) * clickAnimProgress); - var x = ShowIconsWhenHidden ? -Location.X : 0; - var height = drawerItemHeight; - - g.FillRectangle(SkinManager.ColorScheme.AccentBrush, x, y, IndicatorWidth, height); - } - - public new void Show() - { - _isOpen = true; - DrawerStateChanged?.Invoke(this); - DrawerBeginOpen?.Invoke(this); - _showHideAnimManager.StartNewAnimation(AnimationDirection.Out); - } - - public new void Hide() - { - _isOpen = false; - DrawerStateChanged?.Invoke(this); - DrawerBeginClose?.Invoke(this); - _showHideAnimManager.StartNewAnimation(AnimationDirection.In); - } - - public void Toggle() - { - if (_isOpen) - Hide(); - else - Show(); - } - - private int CalculateAlphaZeroWhenClosed(int primaryA, int secondaryA, int tabIndex, double clickAnimProgress, double showHideAnimProgress) - { - // Drawer is closed - if (!_isOpen && !_showHideAnimManager.IsAnimating()) - { - return 0; - } - // Active menu (no change) - if (tabIndex == _baseTabControl.SelectedIndex && (!_clickAnimManager.IsAnimating() || _showHideAnimManager.IsAnimating())) - { - return (int)(primaryA * showHideAnimProgress); - } - // Previous menu (changing) - if (tabIndex == _previousSelectedTabIndex && !_showHideAnimManager.IsAnimating()) - { - return primaryA - (int)((primaryA - secondaryA) * clickAnimProgress); - } - // Inactive menu (no change) - if (tabIndex != _baseTabControl.SelectedIndex) - { - return (int)(secondaryA * showHideAnimProgress); - } - // Active menu (changing) - return secondaryA + (int)((primaryA - secondaryA) * clickAnimProgress); - } - - private int CalculateAlpha(int primaryA, int secondaryA, int tabIndex, double clickAnimProgress, double showHideAnimProgress) - { - if (tabIndex == _baseTabControl.SelectedIndex && !_clickAnimManager.IsAnimating()) - { - return (int)(primaryA); - } - if (tabIndex != _previousSelectedTabIndex && tabIndex != _baseTabControl.SelectedIndex) - { - return secondaryA; - } - if (tabIndex == _previousSelectedTabIndex) - { - return primaryA - (int)((primaryA - secondaryA) * clickAnimProgress); - } - return secondaryA + (int)((primaryA - secondaryA) * clickAnimProgress); - } - - protected override void OnMouseClick(MouseEventArgs e) - { - base.OnMouseClick(e); - - if (_drawerItemRects == null) - UpdateTabRects(); - for (var i = 0; i < _drawerItemRects.Count; i++) - { - if (_drawerItemRects[i].Contains(e.Location)) - { - _baseTabControl.SelectedIndex = i; - if (AutoHide) - Hide(); - } - } - - _animationSource = e.Location; - } - - protected override void OnMouseMove(MouseEventArgs e) - { - base.OnMouseMove(e); - - if (DesignMode) - return; - - if (_drawerItemRects == null) - UpdateTabRects(); - for (var i = 0; i < _drawerItemRects.Count; i++) - { - if (_drawerItemRects[i].Contains(e.Location)) - { - Cursor = Cursors.Hand; - return; - } - } - Cursor = Cursors.Arrow; - } - - private void UpdateTabRects() - { - //If there isn't a base tab control, the rects shouldn't be calculated - //or if there aren't tab pages in the base tab control, the list should just be empty - if (_baseTabControl == null || _baseTabControl.TabCount == 0 || SkinManager == null || _drawerItemRects == null) - { - _drawerItemRects = new List(); - _drawerItemPaths = new List(); - return; - } - - if (_drawerItemRects.Count != _baseTabControl.TabCount) - { - _drawerItemRects = new List(_baseTabControl.TabCount); - _drawerItemPaths = new List(_baseTabControl.TabCount); - - for (var i = 0; i < _baseTabControl.TabCount; i++) - { - _drawerItemRects.Add(new Rectangle()); - _drawerItemPaths.Add(new GraphicsPath()); - } + private int _lastMouseY; + private int _lastLocationY; + + public MaterialDrawer(RightToLeft rightToLeft) + { + RightToLeft = rightToLeft; + SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); + Height = 120; + Width = 250; + IndicatorWidth = 0; + _isOpen = false; + ShowIconsWhenHidden = false; + AutoHide = false; + AutoShow = false; + HighlightWithAccent = true; + BackgroundWithAccent = false; + + _showHideAnimManager = new AnimationManager + { + AnimationType = AnimationType.EaseInOut, + Increment = 0.04 + }; + _showHideAnimManager.OnAnimationProgress += sender => + { + Invalidate(); + showHideAnimation(); + }; + _showHideAnimManager.OnAnimationFinished += sender => + { + if (_baseTabControl != null && _drawerItemRects.Count > 0) + rippleSize = _drawerItemRects[_baseTabControl.SelectedIndex].Width; + if (_isOpen) + { + DrawerEndOpen?.Invoke(this); + } + else + { + DrawerEndClose?.Invoke(this); + } + }; + + SkinManager.ColorSchemeChanged += sender => + { + preProcessIcons(); + }; + + SkinManager.ThemeChanged += sender => + { + preProcessIcons(); + }; + + _clickAnimManager = new AnimationManager + { + AnimationType = AnimationType.EaseOut, + Increment = 0.04 + }; + _clickAnimManager.OnAnimationProgress += sender => Invalidate(); + + MouseWheel += MaterialDrawer_MouseWheel; + } + + private void MaterialDrawer_MouseWheel(object sender, MouseEventArgs e) + { + int step = 20; + if (e.Delta > 0) + { + if (Location.Y < 0) + { + Location = new Point(Location.X, Location.Y + step > 0 ? 0 : Location.Y + step); + Height = Location.Y + step > 0 ? Parent.Height : Height - step; + } + } + else + { + if (Height < (8 + drawerItemHeight) * _drawerItemRects.Count) + { + Location = new Point(Location.X, Location.Y - step); + Height += step; + } + } + } + + [EditorBrowsable(EditorBrowsableState.Advanced)] + protected override void InitLayout() + { + drawerItemHeight = TAB_HEADER_PADDING * 2 - SkinManager.FORM_PADDING / 2; + MinWidth = (int)(SkinManager.FORM_PADDING * 1.5 + drawerItemHeight); + _showHideAnimManager.SetProgress(_isOpen ? 0 : 1); + showHideAnimation(); + Invalidate(); + + base.InitLayout(); + } + + private void showHideAnimation() + { + var showHideAnimProgress = _showHideAnimManager.GetProgress(); + if (_showHideAnimManager.IsAnimating()) + { + var rtlDir = RightToLeft == RightToLeft.Yes ? -1 : 1; + if (ShowIconsWhenHidden) + { + Location = new Point((int)((-Width + MinWidth) * showHideAnimProgress) * rtlDir, Location.Y); + } + else + { + Location = new Point((int)(-Width * showHideAnimProgress) * rtlDir, Location.Y); + } + } + else + { + if (_isOpen) + { + Location = new Point(0, Location.Y); + } + else + { + var rtlDir = RightToLeft == RightToLeft.Yes ? -1 : 1; + if (ShowIconsWhenHidden) + { + Location = new Point((int)(-Width + MinWidth) * rtlDir, Location.Y); + } + else + { + Location = new Point(-Width * rtlDir, Location.Y); + } + } + } + UpdateTabRects(); + } + + protected override void OnPaint(PaintEventArgs e) + { + Paint(e); + } + + private new void Paint(PaintEventArgs e) + { + var g = e.Graphics; + g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; + + // redraw stuff + g.Clear(UseColors ? SkinManager.ColorScheme.PrimaryColor : SkinManager.BackdropColor); + + if (_baseTabControl == null) + return; + + if (!_clickAnimManager.IsAnimating() || _drawerItemRects == null || _drawerItemRects.Count != _baseTabControl.TabCount) + UpdateTabRects(); + + if (_drawerItemRects == null || _drawerItemRects.Count != _baseTabControl.TabCount) + return; + + // Click Animation + var clickAnimProgress = _clickAnimManager.GetProgress(); + // Show/Hide Drawer Animation + var showHideAnimProgress = _showHideAnimManager.GetProgress(); + var rSize = (int)(clickAnimProgress * rippleSize * 1.75); + + int dx = prevLocation - Location.X; + prevLocation = Location.X; + + // Ripple + if (_clickAnimManager.IsAnimating()) + { + var rippleBrush = new SolidBrush(Color.FromArgb((int)(70 - (clickAnimProgress * 70)), + UseColors ? SkinManager.ColorScheme.AccentColor : // Using colors + SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? SkinManager.ColorScheme.PrimaryColor : // light theme + SkinManager.ColorScheme.LightPrimaryColor)); // dark theme + + g.SetClip(_drawerItemPaths[_baseTabControl.SelectedIndex]); + g.FillEllipse(rippleBrush, new Rectangle(_animationSource.X + dx - (rSize / 2), _animationSource.Y - rSize / 2, rSize, rSize)); + g.ResetClip(); + rippleBrush.Dispose(); + } + + // Draw menu items + foreach (TabPage tabPage in _baseTabControl.TabPages) + { + var currentTabIndex = _baseTabControl.TabPages.IndexOf(tabPage); + + // Background + Brush bgBrush = new SolidBrush(Color.FromArgb(CalculateAlpha(60, 0, currentTabIndex, clickAnimProgress, 1 - showHideAnimProgress), + UseColors ? _backgroundWithAccent ? SkinManager.ColorScheme.AccentColor : SkinManager.ColorScheme.LightPrimaryColor : // using colors + _backgroundWithAccent ? SkinManager.ColorScheme.AccentColor : // defaul accent + SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? SkinManager.ColorScheme.PrimaryColor : // default light + SkinManager.ColorScheme.LightPrimaryColor)); // default dark + g.FillPath(bgBrush, _drawerItemPaths[currentTabIndex]); + bgBrush.Dispose(); + + // Text + Color textColor = Color.FromArgb(CalculateAlphaZeroWhenClosed(SkinManager.TextHighEmphasisColor.A, UseColors ? SkinManager.TextMediumEmphasisColor.A : 255, currentTabIndex, clickAnimProgress, 1 - showHideAnimProgress), // alpha + UseColors ? (currentTabIndex == _baseTabControl.SelectedIndex ? (_highlightWithAccent ? SkinManager.ColorScheme.AccentColor : SkinManager.ColorScheme.PrimaryColor) // Use colors - selected + : SkinManager.ColorScheme.TextColor) : // Use colors - not selected + (currentTabIndex == _baseTabControl.SelectedIndex ? (_highlightWithAccent ? SkinManager.ColorScheme.AccentColor : SkinManager.ColorScheme.PrimaryColor) : // selected + SkinManager.TextHighEmphasisColor)); + + IntPtr textFont = SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle2, RightToLeft); + + Rectangle textRect = _drawerItemRects[currentTabIndex]; + var textRectX = RightToLeft == RightToLeft.Yes ? SkinManager.FORM_PADDING - Location.X : _baseTabControl.ImageList != null ? drawerItemHeight : (int)(SkinManager.FORM_PADDING * 0.75); + textRect.X += textRectX; + textRect.Width -= SkinManager.FORM_PADDING << 2; + + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + var direction = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right | NativeTextRenderer.TextAlignFlags.Middle : NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle; + NativeText.DrawTransparentText(tabPage.Text, textFont, textColor, textRect.Location, textRect.Size, direction); + } + + // Icons + if (_baseTabControl.ImageList != null && !String.IsNullOrEmpty(tabPage.ImageKey)) + { + var rectangleX = RightToLeft == RightToLeft.Yes ? Width - Location.X - ((_baseTabControl.ImageList.Images[tabPage.ImageKey].Width/2)*2) - _drawerItemRects[currentTabIndex].X + (drawerItemHeight >> 1) - (iconsSize[tabPage.ImageKey].Width >> 1) : + _drawerItemRects[currentTabIndex].X + (drawerItemHeight >> 1) - (iconsSize[tabPage.ImageKey].Width >> 1); + Rectangle iconRect = new Rectangle( + rectangleX, + _drawerItemRects[currentTabIndex].Y + (drawerItemHeight >> 1) - (iconsSize[tabPage.ImageKey].Height >> 1), + iconsSize[tabPage.ImageKey].Width, iconsSize[tabPage.ImageKey].Height); + + if (ShowIconsWhenHidden) + { + iconsBrushes[tabPage.ImageKey].TranslateTransform(dx, 0); + iconsSelectedBrushes[tabPage.ImageKey].TranslateTransform(dx, 0); + } + + g.FillRectangle(currentTabIndex == _baseTabControl.SelectedIndex ? iconsSelectedBrushes[tabPage.ImageKey] : iconsBrushes[tabPage.ImageKey], iconRect); + } + } + + // Draw divider if not using colors + if (!UseColors) + { + using (Pen dividerPen = new Pen(SkinManager.DividersColor, 1)) + { + var lineX = RightToLeft == RightToLeft.Yes ? 0 : Width - 1; + g.DrawLine(dividerPen, lineX, 0, lineX, Height); + } + } + + // Animate tab indicator + var previousSelectedTabIndexIfHasOne = _previousSelectedTabIndex == -1 ? _baseTabControl.SelectedIndex : _previousSelectedTabIndex; + var previousActiveTabRect = _drawerItemRects[previousSelectedTabIndexIfHasOne]; + var activeTabPageRect = _drawerItemRects[_baseTabControl.SelectedIndex]; + var y = previousActiveTabRect.Y + (int)((activeTabPageRect.Y - previousActiveTabRect.Y) * clickAnimProgress); + var offset = RightToLeft == RightToLeft.Yes ? Width - IndicatorWidth:0; + var x = ShowIconsWhenHidden ? offset - Location.X : 0; + var height = drawerItemHeight; + + g.FillRectangle(SkinManager.ColorScheme.AccentBrush, x, y, IndicatorWidth, height); + } + + public new void Show() + { + _isOpen = true; + DrawerStateChanged?.Invoke(this); + DrawerBeginOpen?.Invoke(this); + _showHideAnimManager.StartNewAnimation(AnimationDirection.Out); + } + + public new void Hide() + { + _isOpen = false; + DrawerStateChanged?.Invoke(this); + DrawerBeginClose?.Invoke(this); + _showHideAnimManager.StartNewAnimation(AnimationDirection.In); + } + + public void Toggle() + { + if (_isOpen) + Hide(); + else + Show(); + } + + private int CalculateAlphaZeroWhenClosed(int primaryA, int secondaryA, int tabIndex, double clickAnimProgress, double showHideAnimProgress) + { + // Drawer is closed + if (!_isOpen && !_showHideAnimManager.IsAnimating()) + { + return 0; + } + // Active menu (no change) + if (tabIndex == _baseTabControl.SelectedIndex && (!_clickAnimManager.IsAnimating() || _showHideAnimManager.IsAnimating())) + { + return (int)(primaryA * showHideAnimProgress); + } + // Previous menu (changing) + if (tabIndex == _previousSelectedTabIndex && !_showHideAnimManager.IsAnimating()) + { + return primaryA - (int)((primaryA - secondaryA) * clickAnimProgress); + } + // Inactive menu (no change) + if (tabIndex != _baseTabControl.SelectedIndex) + { + return (int)(secondaryA * showHideAnimProgress); + } + // Active menu (changing) + return secondaryA + (int)((primaryA - secondaryA) * clickAnimProgress); + } + + private int CalculateAlpha(int primaryA, int secondaryA, int tabIndex, double clickAnimProgress, double showHideAnimProgress) + { + if (tabIndex == _baseTabControl.SelectedIndex && !_clickAnimManager.IsAnimating()) + { + return (int)(primaryA); + } + if (tabIndex != _previousSelectedTabIndex && tabIndex != _baseTabControl.SelectedIndex) + { + return secondaryA; + } + if (tabIndex == _previousSelectedTabIndex) + { + return primaryA - (int)((primaryA - secondaryA) * clickAnimProgress); + } + return secondaryA + (int)((primaryA - secondaryA) * clickAnimProgress); + } + + protected override void OnMouseClick(MouseEventArgs e) + { + base.OnMouseClick(e); + + if (_drawerItemRects == null) + UpdateTabRects(); + for (var i = 0; i < _drawerItemRects.Count; i++) + { + if (_drawerItemRects[i].Contains(e.Location) && _lastLocationY == Location.Y) + { + _baseTabControl.SelectedIndex = i; + if (AutoHide && !AutoShow) + Hide(); + } + } + + _animationSource = e.Location; + } + + protected override void OnMouseDown(MouseEventArgs e) + { + _lastMouseY = e.Y; + _lastLocationY = Location.Y; // memorize Y location of drawer + base.OnMouseDown(e); + if (DesignMode) + return; + MouseState = MouseState.DOWN; + } + + protected override void OnMouseUp(MouseEventArgs e) + { + base.OnMouseUp(e); + if (DesignMode) + return; + MouseState = MouseState.OUT; + } + + protected override void OnMouseMove(MouseEventArgs e) + { + if (DesignMode) + return; + + if (e.Button == MouseButtons.Left && e.Y != _lastMouseY && (Location.Y < 0 || Height < (8 + drawerItemHeight) * _drawerItemRects.Count)) + { + int diff = e.Y - _lastMouseY; + if (diff > 0) + { + if (Location.Y < 0) + { + Location = new Point(Location.X, Location.Y + diff > 0 ? 0 : Location.Y + diff); + Height = Parent.Height + Math.Abs(Location.Y); + } + } + else + { + if (Height < (8 + drawerItemHeight) * _drawerItemRects.Count) + { + Location = new Point(Location.X, Location.Y + diff); + Height = Parent.Height + Math.Abs(Location.Y); + } + } + //return; + } + + base.OnMouseMove(e); + + if (_drawerItemRects == null) + UpdateTabRects(); + + Cursor previousCursor = Cursor; + + if (e.Location.X + this.Location.X < BORDER_WIDTH) + { + if (e.Location.Y > this.Height - BORDER_WIDTH) + Cursor = Cursors.SizeNESW; //Bottom Left + else + Cursor = Cursors.SizeWE; //Left + } + else if (e.Location.Y > this.Height - BORDER_WIDTH) + { + Cursor = Cursors.SizeNS; //Bottom + } + else + { + if (e.Location.Y < _drawerItemRects[_drawerItemRects.Count - 1].Bottom && (e.Location.X + this.Location.X) >= BORDER_WIDTH) + Cursor = Cursors.Hand; + else + Cursor = Cursors.Default; + } + + if (previousCursor != Cursor) CursorUpdate?.Invoke(this, Cursor); + + } + + protected override void OnMouseEnter(EventArgs e) + { + base.OnMouseEnter(e); + if (AutoShow && _isOpen==false) + { + Show(); + } + } + + protected override void OnMouseLeave(EventArgs e) + { + base.OnMouseLeave(e); + + if (MouseState != MouseState.DOWN) + { + Cursor = Cursors.Default; + CursorUpdate?.Invoke(this, Cursor); + } + + if (AutoShow) + { + Hide(); + } + } + + private void UpdateTabRects() + { + //If there isn't a base tab control, the rects shouldn't be calculated + //or if there aren't tab pages in the base tab control, the list should just be empty + if (_baseTabControl == null || _baseTabControl.TabCount == 0 || SkinManager == null || _drawerItemRects == null) + { + _drawerItemRects = new List(); + _drawerItemPaths = new List(); + return; + } + + if (_drawerItemRects.Count != _baseTabControl.TabCount) + { + _drawerItemRects = new List(_baseTabControl.TabCount); + _drawerItemPaths = new List(_baseTabControl.TabCount); + + for (var i = 0; i < _baseTabControl.TabCount; i++) + { + _drawerItemRects.Add(new Rectangle()); + _drawerItemPaths.Add(new GraphicsPath()); + } } //Calculate the bounds of each tab header specified in the base tab control - for (int i = 0; i < _baseTabControl.TabPages.Count; i++) - { - _drawerItemRects[i] = (new Rectangle( - (int)(SkinManager.FORM_PADDING * 0.75) - (ShowIconsWhenHidden ? Location.X : 0), - (TAB_HEADER_PADDING * 2) * i + (int)(SkinManager.FORM_PADDING >> 1), - (Width + (ShowIconsWhenHidden ? Location.X : 0)) - (int)(SkinManager.FORM_PADDING * 1.5) - 1, - drawerItemHeight)); - - _drawerItemPaths[i] = DrawHelper.CreateRoundRect(new RectangleF(_drawerItemRects[i].X - 0.5f, _drawerItemRects[i].Y - 0.5f, _drawerItemRects[i].Width, _drawerItemRects[i].Height), 4); - } - } - } -} \ No newline at end of file + for (int i = 0; i < _baseTabControl.TabPages.Count; i++) + { + var LocationX = this.RightToLeft == RightToLeft.Yes ? 0 : Location.X; + _drawerItemRects[i] = (new Rectangle( + (int)(SkinManager.FORM_PADDING * 0.75) - (ShowIconsWhenHidden ? LocationX : 0), + (TAB_HEADER_PADDING * 2) * i + (int)(SkinManager.FORM_PADDING >> 1), + (Width + (ShowIconsWhenHidden ? LocationX : 0)) - (int)(SkinManager.FORM_PADDING * 1.5) - 1, + drawerItemHeight)); + var drawerItemRectWidth = this.RightToLeft == RightToLeft.Yes ? _drawerItemRects[i].Width - Location.X: _drawerItemRects[i].Width; + _drawerItemPaths[i] = DrawHelper.CreateRoundRect(new RectangleF(_drawerItemRects[i].X - 0.5f, _drawerItemRects[i].Y - 0.5f, drawerItemRectWidth, _drawerItemRects[i].Height), 4); + } + } + } +} diff --git a/MaterialSkin/Controls/MaterialExpansionPanel.cs b/MaterialSkin/Controls/MaterialExpansionPanel.cs new file mode 100644 index 00000000..64d3a5bd --- /dev/null +++ b/MaterialSkin/Controls/MaterialExpansionPanel.cs @@ -0,0 +1,669 @@ +using MaterialSkin.Animations; +using System; +using System.Configuration; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Text; +using System.Windows.Forms; + + +namespace MaterialSkin.Controls +{ + public class MaterialExpansionPanel : Panel, IMaterialControl + { + + #region "Private members" + + private MaterialButton _validationButton; + private MaterialButton _cancelButton; + + private const int _expansionPanelDefaultPadding = 16; + private const int _leftrightPadding = 24; + private const int _buttonPadding = 8; + private const int _expandcollapsbuttonsize = 24; + private const int _textHeaderHeight = 24; + private const int _headerHeightCollapse = 48; + private const int _headerHeightExpand = 64; + private const int _footerHeight = 68; + private const int _footerButtonHeight = 36; + private const int _minHeight = 200; + private int _headerHeight; + + private bool _collapse; + private bool _useAccentColor; + private int _expandHeight; + + + private string _titleHeader; + private string _descriptionHeader; + private string _validationButtonText; + private string _cancelButtonText; + + + + private bool _showValidationButtons; + private bool _showCollapseExpand; + private bool _drawShadows; + private bool _shadowDrawEventSubscribed = false; + private Rectangle _headerBounds; + private Rectangle _expandcollapseBounds; + private Rectangle _savebuttonBounds; + private Rectangle _cancelbuttonBounds; + private bool _savebuttonEnable; + + private enum ButtonState + { + SaveOver, + CancelOver, + ColapseExpandOver, + HeaderOver, + None + } + + private ButtonState _buttonState = ButtonState.None; + + + #endregion + + + #region "Public Properties" + + [Browsable(false)] + public int Depth { get; set; } + [Browsable(false)] + public MaterialSkinManager SkinManager { get { return MaterialSkinManager.Instance; } } + [Browsable(false)] + public MouseState MouseState { get; set; } + + [Category("Material Skin"), DefaultValue(false), DisplayName("Use Accent Color")] + public bool UseAccentColor + { + get { return _useAccentColor; } + set { _useAccentColor = value; UpdateRects(); Invalidate(); } + } + + [DefaultValue(false)] + [Description("Collapses the control when set to true")] + [Category("Material Skin")] + public bool Collapse + { + get { return _collapse; } + set + { + _collapse = value; + CollapseOrExpand(); + Invalidate(); + } + } + + [DefaultValue("Title")] + [Category("Material Skin"), DisplayName("Title")] + [Description("Title to show in expansion panel's header")] + public string Title + { + get { return _titleHeader; } + set + { + _titleHeader = value; + Invalidate(); + } + } + + [DefaultValue("Description")] + [Category("Material Skin"), DisplayName("Description")] + [Description("Description to show in expansion panel's header")] + public string Description + { + get { return _descriptionHeader; } + set + { + _descriptionHeader = value; + Invalidate(); + } + } + + [DefaultValue(true)] + [Category("Material Skin"), DisplayName("Draw Shadows")] + [Description("Draw Shadows around control")] + public bool DrawShadows + { + get { return _drawShadows; } + set { _drawShadows = value; Invalidate(); } + } + + [DefaultValue(240)] + [Category("Material Skin"), DisplayName("Expand Height")] + [Description("Define control height when expanded")] + public int ExpandHeight + { + get { return _expandHeight; } + set { if (value < _minHeight) value = _minHeight; _expandHeight = value; Invalidate(); } + } + + [DefaultValue(true)] + [Category("Material Skin"), DisplayName("Show collapse/expand")] + [Description("Show collapse/expand indicator")] + public bool ShowCollapseExpand + { + get { return _showCollapseExpand; } + set { _showCollapseExpand = value; Invalidate(); } + } + + [DefaultValue(true)] + [Category("Material Skin"), DisplayName("Show validation buttons")] + [Description("Show save/cancel button")] + public bool ShowValidationButtons + { + get { return _showValidationButtons; } + set { _showValidationButtons = value; UpdateRects(); Invalidate(); } + } + + [DefaultValue("SAVE")] + [Category("Material Skin"), DisplayName("Validation button text")] + [Description("Set Validation button text")] + public string ValidationButtonText + { + get { return _validationButtonText; } + set { _validationButtonText = value; UpdateRects(); Invalidate(); } + } + + [DefaultValue("CANCEL")] + [Category("Material Skin"), DisplayName("Cancel button text")] + [Description("Set Cancel button text")] + public string CancelButtonText + { + get { return _cancelButtonText; } + set { _cancelButtonText = value; UpdateRects(); Invalidate(); } + } + + [DefaultValue(false)] + [Category("Material Skin"), DisplayName("Validation button enable")] + [Description("Enable validation button")] + public bool ValidationButtonEnable + { + get { return _savebuttonEnable; } + set { _savebuttonEnable = value; UpdateRects(); Invalidate(); } + } + + + #endregion + + + #region "Events" + + [Category("Action")] + [Description("Fires when Save button is clicked")] + public event EventHandler SaveClick; + + [Category("Action")] + [Description("Fires when Cancel button is clicked")] + public event EventHandler CancelClick; + + [Category("Disposition")] + [Description("Fires when Panel Collapse")] + public event EventHandler PanelCollapse; + + [Category("Disposition")] + [Description("Fires when Panel Expand")] + public event EventHandler PanelExpand; + + + #endregion + + public MaterialExpansionPanel() + { + ShowValidationButtons = true; + ValidationButtonEnable = false; + ValidationButtonText = "SAVE"; + CancelButtonText = "CANCEL"; + ShowCollapseExpand = true; + Collapse = false; + Title = "Title"; + Description = "Description"; + DrawShadows = true; + ExpandHeight = 240; + AutoScroll = false; + + SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); + BackColor = SkinManager.BackgroundColor; + ForeColor = SkinManager.TextHighEmphasisColor; + + Padding = new Padding(24, 64, 24, 16); + Margin = new Padding(3, 16, 3, 16); + Size = new Size(480, ExpandHeight); + + //CollapseOrExpand(); + + _validationButton = new MaterialButton + { + DrawShadows = false, + Type = MaterialButton.MaterialButtonType.Text, + UseAccentColor = _useAccentColor, + Enabled = ValidationButtonEnable, + Visible = _showValidationButtons, + Text = "SAVE" + }; + _cancelButton = new MaterialButton + { + DrawShadows = false, + Type = MaterialButton.MaterialButtonType.Text, + UseAccentColor = _useAccentColor, + Visible = _showValidationButtons, + Text = "CANCEL" + }; + + if (!Controls.Contains(_validationButton)) + { + Controls.Add(_validationButton); + } + if (!Controls.Contains(_cancelButton)) + { + Controls.Add(_cancelButton); + } + + _validationButton.Click += _validationButton_Click; + _cancelButton.Click += _cancelButton_Click; + + UpdateRects(); + } + + private void _cancelButton_Click(object sender, EventArgs e) + { + //throw new NotImplementedException(); + CancelClick?.Invoke(this, new EventArgs()); + Collapse = true; + CollapseOrExpand(); + + } + + private void _validationButton_Click(object sender, EventArgs e) + { + //throw new NotImplementedException(); + SaveClick?.Invoke(this, new EventArgs()); + Collapse = true; + CollapseOrExpand(); + + } + + + protected override void OnCreateControl() + { + base.OnCreateControl(); + Font = SkinManager.getFontByType(MaterialSkinManager.fontType.Body1, RightToLeft); + } + + protected override void InitLayout() + { + LocationChanged += (sender, e) => { Parent?.Invalidate(); }; + ForeColor = SkinManager.TextHighEmphasisColor; + } + + protected override void OnParentChanged(EventArgs e) + { + base.OnParentChanged(e); + if (Parent != null) AddShadowPaintEvent(Parent, drawShadowOnParent); + if (_oldParent != null) RemoveShadowPaintEvent(_oldParent, drawShadowOnParent); + _oldParent = Parent; + } + + private Control _oldParent; + + protected override void OnVisibleChanged(EventArgs e) + { + base.OnVisibleChanged(e); + if (Parent == null) return; + if (Visible) + AddShadowPaintEvent(Parent, drawShadowOnParent); + else + RemoveShadowPaintEvent(Parent, drawShadowOnParent); + } + + private void drawShadowOnParent(object sender, PaintEventArgs e) + { + if (Parent == null) + { + RemoveShadowPaintEvent((Control)sender, drawShadowOnParent); + return; + } + + if (!_drawShadows || Parent == null) return; + + // paint shadow on parent + Graphics gp = e.Graphics; + Rectangle rect = new Rectangle(Location, ClientRectangle.Size); + gp.SmoothingMode = SmoothingMode.AntiAlias; + DrawHelper.DrawSquareShadow(gp, rect); + } + + + private void AddShadowPaintEvent(Control control, PaintEventHandler shadowPaintEvent) + { + if (_shadowDrawEventSubscribed) return; + control.Paint += shadowPaintEvent; + control.Invalidate(); + _shadowDrawEventSubscribed = true; + } + + private void RemoveShadowPaintEvent(Control control, PaintEventHandler shadowPaintEvent) + { + if (!_shadowDrawEventSubscribed) return; + control.Paint -= shadowPaintEvent; + control.Invalidate(); + _shadowDrawEventSubscribed = false; + } + + protected override void OnBackColorChanged(EventArgs e) + { + base.OnBackColorChanged(e); + BackColor = SkinManager.BackgroundColor; + } + + protected override void OnResize(EventArgs e) + { + if (!_collapse) + { + if (DesignMode) + { + _expandHeight = Height; + } + if (Height < _minHeight) Height = _minHeight; + } + else + { + Height = _headerHeightCollapse; + } + + base.OnResize(e); + + _headerBounds = new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, _headerHeight); + var RectangleX=(RightToLeft==RightToLeft.Yes)? _leftrightPadding : (Width) - _leftrightPadding - _expandcollapsbuttonsize; + _expandcollapseBounds = new Rectangle( + RectangleX, + (int)((_headerHeight - _expandcollapsbuttonsize) / 2) + , _expandcollapsbuttonsize, + _expandcollapsbuttonsize); + + UpdateRects(); + + if (Parent != null) + { + RemoveShadowPaintEvent(Parent, drawShadowOnParent); + AddShadowPaintEvent(Parent, drawShadowOnParent); + } + } + + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + + if (DesignMode) + return; + + var oldState = _buttonState; + + if (_savebuttonBounds.Contains(e.Location)) + _buttonState = ButtonState.SaveOver; + else if (_cancelbuttonBounds.Contains(e.Location)) + _buttonState = ButtonState.CancelOver; + else if (_expandcollapseBounds.Contains(e.Location)) + { + Cursor = Cursors.Hand; + _buttonState = ButtonState.ColapseExpandOver; + } + else if (_headerBounds.Contains(e.Location)) + { + Cursor = Cursors.Hand; + _buttonState = ButtonState.HeaderOver; + } + else + { + Cursor = Cursors.Default; + _buttonState = ButtonState.None; + } + + if (oldState != _buttonState) Invalidate(); + + } + + protected override void OnMouseDown(MouseEventArgs e) + { + if (Enabled && (_buttonState == ButtonState.HeaderOver | _buttonState == ButtonState.ColapseExpandOver)) + { + Collapse = !Collapse; + CollapseOrExpand(); + } + else + { + if (DesignMode) + return; + } + + base.OnMouseDown(e); + } + + protected override void OnMouseLeave(EventArgs e) + { + base.OnMouseLeave(e); + if (DesignMode) + return; + + Cursor = Cursors.Arrow; + _buttonState = ButtonState.None; + Invalidate(); + } + + + protected override void OnPaint(PaintEventArgs e) + { + var g = e.Graphics; + g.TextRenderingHint = TextRenderingHint.AntiAlias; + + g.Clear(Parent.BackColor); + + // card rectangle path + RectangleF expansionPanelRectF = new RectangleF(ClientRectangle.Location, ClientRectangle.Size); + expansionPanelRectF.X -= 0.5f; + expansionPanelRectF.Y -= 0.5f; + GraphicsPath expansionPanelPath = DrawHelper.CreateRoundRect(expansionPanelRectF, 2); + + // button shadow (blend with form shadow) + DrawHelper.DrawSquareShadow(g, ClientRectangle); + + // Draw expansion panel + // Disabled + if (!Enabled) + { + using (SolidBrush disabledBrush = new SolidBrush(DrawHelper.BlendColor(Parent.BackColor, SkinManager.BackgroundDisabledColor, SkinManager.BackgroundDisabledColor.A))) + { + g.FillPath(disabledBrush, expansionPanelPath); + } + } + // Mormal + else + { + if ((_buttonState == ButtonState.HeaderOver | _buttonState == ButtonState.ColapseExpandOver) && _collapse) + { + RectangleF expansionPanelBorderRectF = new RectangleF(ClientRectangle.X + 1, ClientRectangle.Y + 1, ClientRectangle.Width - 2, ClientRectangle.Height - 2); + expansionPanelBorderRectF.X -= 0.5f; + expansionPanelBorderRectF.Y -= 0.5f; + GraphicsPath expansionPanelBoarderPath = DrawHelper.CreateRoundRect(expansionPanelBorderRectF, 2); + + g.FillPath(SkinManager.ExpansionPanelFocusBrush, expansionPanelBoarderPath); + } + else + { + using (SolidBrush normalBrush = new SolidBrush(SkinManager.BackgroundColor)) + { + g.FillPath(normalBrush, expansionPanelPath); + } + } + } + + // Calc text Rect + var RectangleX = (RightToLeft == RightToLeft.Yes) ? Width - (TextRenderer.MeasureText(_titleHeader, Font).Width + _expansionPanelDefaultPadding + _leftrightPadding) : _leftrightPadding; + Rectangle headerRect = new Rectangle( + RectangleX, + (_headerHeight - _textHeaderHeight) / 2, + TextRenderer.MeasureText(_titleHeader, Font).Width + _expansionPanelDefaultPadding, + _textHeaderHeight); + + //Draw headers + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + // Draw header text + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + NativeText.DrawTransparentText( + _titleHeader, + SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1, RightToLeft), + Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor, + headerRect.Location, + headerRect.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + + if (!String.IsNullOrEmpty(_descriptionHeader)) + { + //Draw description header text + RectangleX = (RightToLeft == RightToLeft.Yes) ? _leftrightPadding + _expansionPanelDefaultPadding : headerRect.Right + _expansionPanelDefaultPadding; + var RectangleW = (RightToLeft == RightToLeft.Yes) ? headerRect.Left - _expansionPanelDefaultPadding - _expansionPanelDefaultPadding : _expandcollapseBounds.Left - (headerRect.Right + _expansionPanelDefaultPadding) - _expansionPanelDefaultPadding; + Rectangle headerDescriptionRect = new Rectangle( + RectangleX, + (_headerHeight - _textHeaderHeight) / 2, + RectangleW, + _textHeaderHeight); + + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + // Draw description header text + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + NativeText.DrawTransparentText( + _descriptionHeader, + SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1, RightToLeft), + SkinManager.TextDisabledOrHintColor, + headerDescriptionRect.Location, + headerDescriptionRect.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + } + + if (_showCollapseExpand == true) + { + using (var formButtonsPen = new Pen(_useAccentColor && Enabled ? SkinManager.ColorScheme.AccentColor : SkinManager.TextDisabledOrHintColor, 2)) + { + if (_collapse) + { + //Draw Expand button + System.Drawing.Drawing2D.GraphicsPath pth = new System.Drawing.Drawing2D.GraphicsPath(); + PointF TopLeft = new PointF(_expandcollapseBounds.X + 6, _expandcollapseBounds.Y + 9); + PointF MidBottom = new PointF(_expandcollapseBounds.X + 12, _expandcollapseBounds.Y + 15); + PointF TopRight = new PointF(_expandcollapseBounds.X + 18, _expandcollapseBounds.Y + 9); + pth.AddLine(TopLeft, MidBottom); + pth.AddLine(TopRight, MidBottom); + g.DrawPath(formButtonsPen, pth); + } + else + { + // Draw Collapse button + System.Drawing.Drawing2D.GraphicsPath pth = new System.Drawing.Drawing2D.GraphicsPath(); + PointF BottomLeft = new PointF(_expandcollapseBounds.X + 6, _expandcollapseBounds.Y + 15); + PointF MidTop = new PointF(_expandcollapseBounds.X + 12, _expandcollapseBounds.Y + 9); + PointF BottomRight = new PointF(_expandcollapseBounds.X + 18, _expandcollapseBounds.Y + 15); + pth.AddLine(BottomLeft, MidTop); + pth.AddLine(BottomRight, MidTop); + g.DrawPath(formButtonsPen, pth); + } + } + } + + if (!_collapse && _showValidationButtons) + { + //Draw divider + g.DrawLine(new Pen(SkinManager.DividersColor, 1), new Point(0, Height - _footerHeight), new Point(Width, Height - _footerHeight)); + } + } + + private void CollapseOrExpand() + { + //if (!useAnimation) + //{ + if (_collapse) + { + _headerHeight = _headerHeightCollapse; + this.Height = _headerHeightCollapse; + Margin = new Padding(16, 1, 16, 0); + + // Is the event registered? + if (PanelCollapse != null) + // Raise the event + this.PanelCollapse(this, new EventArgs()); + } + else + { + _headerHeight = _headerHeightExpand; + this.Height = _expandHeight; + Margin = new Padding(16, 16, 16, 16); + + // Is the event registered? + if (PanelExpand != null) + // Raise the event + this.PanelExpand(this, new EventArgs()); + } + + Refresh(); + } + + private void UpdateRects() + { + if (!_collapse && _showValidationButtons) + { + int _buttonWidth = ((TextRenderer.MeasureText(ValidationButtonText, SkinManager.getFontByType(MaterialSkinManager.fontType.Button, RightToLeft))).Width + 32); + var savebuttonBoundsX=(RightToLeft==RightToLeft.Yes)? _buttonPadding : (Width) - _buttonPadding - _buttonWidth; + _savebuttonBounds = new Rectangle( + savebuttonBoundsX, + Height - _expansionPanelDefaultPadding - _footerButtonHeight, + _buttonWidth, + _footerButtonHeight); + _buttonWidth = ((TextRenderer.MeasureText(CancelButtonText, SkinManager.getFontByType(MaterialSkinManager.fontType.Button, RightToLeft))).Width + 32); + var cancelbuttonBoundsX= (RightToLeft == RightToLeft.Yes) ? _savebuttonBounds.Right + _buttonPadding : _savebuttonBounds.Left - _buttonPadding - _buttonWidth; + _cancelbuttonBounds = new Rectangle( + cancelbuttonBoundsX, + Height - _expansionPanelDefaultPadding - _footerButtonHeight, + _buttonWidth, + _footerButtonHeight); + + if (_validationButton != null) + { + var validationButtonLeft= (RightToLeft == RightToLeft.Yes) ? _buttonPadding : Width - _buttonPadding - _validationButton.Width; + _validationButton.Width = _savebuttonBounds.Width; + _validationButton.Left = validationButtonLeft; //Button minimum width management + _validationButton.Top = _savebuttonBounds.Top; + _validationButton.Height = _savebuttonBounds.Height; + _validationButton.Text = _validationButtonText; + _validationButton.Enabled = _savebuttonEnable; + _validationButton.UseAccentColor = _useAccentColor; + } + if (_cancelButton != null) + { + var cancelButtonLeft = (RightToLeft == RightToLeft.Yes) ? _validationButton.Right + _buttonPadding : _validationButton.Left - _buttonPadding - _cancelbuttonBounds.Width; + _cancelButton.Width = _cancelbuttonBounds.Width; + _cancelButton.Left = cancelButtonLeft; //Button minimum width management + _cancelButton.Top = _cancelbuttonBounds.Top; + _cancelButton.Height = _cancelbuttonBounds.Height; + _cancelButton.Text = _cancelButtonText; + _cancelButton.UseAccentColor = _useAccentColor; + } + } + if (_validationButton != null) + { + _validationButton.Visible = _showValidationButtons; + } + if (_cancelButton != null) + { + _cancelButton.Visible = _showValidationButtons; + } + } + + } +} diff --git a/MaterialSkin/Controls/MaterialFloatingActionButton.cs b/MaterialSkin/Controls/MaterialFloatingActionButton.cs index 411a2abb..4a589c25 100644 --- a/MaterialSkin/Controls/MaterialFloatingActionButton.cs +++ b/MaterialSkin/Controls/MaterialFloatingActionButton.cs @@ -1,245 +1,297 @@ -namespace MaterialSkin.Controls -{ - using MaterialSkin.Animations; - using System; - using System.ComponentModel; - using System.Drawing; - using System.Drawing.Drawing2D; - using System.Windows.Forms; - - public class MaterialFloatingActionButton : Button, IMaterialControl - { - [Browsable(false)] - public int Depth { get; set; } - - [Browsable(false)] - public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; - - [Browsable(false)] - public MouseState MouseState { get; set; } - - private const int FAB_SIZE = 56; - private const int FAB_MINI_SIZE = 40; - private const int FAB_ICON_MARGIN = 16; - private const int FAB_MINI_ICON_MARGIN = 8; - private const int FAB_ICON_SIZE = 24; - - public bool DrawShadows { get; set; } - - public bool Mini - { - get { return _mini; } - set - { - if (Parent != null) - Parent.Invalidate(); - setSize(value); - } - } - - private bool _mini = false; - - public bool AnimateShowHideButton - { - get { return _animateShowButton; } - set { _animateShowButton = value; } - } - - private bool _animateShowButton; - - public Image Icon - { - get { return _icon; } - set { _icon = value; } - } - - private Image _icon; - - private bool _isHiding = false; - - private readonly AnimationManager _animationManager; - - private readonly AnimationManager _showAnimationManager; - - public MaterialFloatingActionButton() - { - DrawShadows = true; - SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); - - Size = new Size(FAB_SIZE, FAB_SIZE); - _animationManager = new AnimationManager(false) - { - Increment = 0.03, - AnimationType = AnimationType.EaseOut - }; - _animationManager.OnAnimationProgress += sender => Invalidate(); - - _showAnimationManager = new AnimationManager(true) - { - Increment = 0.1, - AnimationType = AnimationType.EaseOut - }; - _showAnimationManager.OnAnimationProgress += sender => Invalidate(); - _showAnimationManager.OnAnimationFinished += _showAnimationManager_OnAnimationFinished; - } - - protected override void InitLayout() - { - LocationChanged += (sender, e) => { if (DrawShadows) Parent?.Invalidate(); }; - } - - protected override void OnParentChanged(EventArgs e) - { - base.OnParentChanged(e); - if (DrawShadows && Parent != null) AddShadowPaintEvent(Parent, drawShadowOnParent); - if (_oldParent != null) RemoveShadowPaintEvent(_oldParent, drawShadowOnParent); - _oldParent = Parent; - } - - private Control _oldParent; - - protected override void OnVisibleChanged(EventArgs e) - { - base.OnVisibleChanged(e); - if (Parent == null) return; - if (Visible) - AddShadowPaintEvent(Parent, drawShadowOnParent); - else - RemoveShadowPaintEvent(Parent, drawShadowOnParent); - } - +namespace MaterialSkin.Controls +{ + using MaterialSkin.Animations; + using System; + using System.ComponentModel; + using System.Drawing; + using System.Drawing.Drawing2D; + using System.Windows.Forms; + + public class MaterialFloatingActionButton : Button, IMaterialControl + { + [Browsable(false)] + public int Depth { get; set; } + + [Browsable(false)] + public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; + + [Browsable(false)] + public MouseState MouseState { get; set; } + + private const int FAB_SIZE = 56; + private const int FAB_MINI_SIZE = 40; + private const int FAB_ICON_MARGIN = 16; + private const int FAB_MINI_ICON_MARGIN = 8; + private const int FAB_ICON_SIZE = 24; + + private Boolean _mouseHover = false; + + [DefaultValue(true)] + [Category("Material Skin"), DisplayName("Draw Shadows")] + [Description("Draw Shadows around control")] + public bool DrawShadows { get; set; } + + [DefaultValue(false)] + [Category("Material Skin"), DisplayName("Size Mini")] + [Description("Set control size to default or mini")] + public bool Mini + { + get { return _mini; } + set + { + if (Parent != null) + Parent.Invalidate(); + setSize(value); + } + } + + private bool _mini ; + + [DefaultValue(false)] + [Category("Material Skin"), DisplayName("Animate Show HideButton")] + public bool AnimateShowHideButton + { + get { return _animateShowButton; } + set { _animateShowButton = value; Refresh(); } + } + + private bool _animateShowButton; + + [DefaultValue(false)] + [Category("Material Skin")] + [Description("Define icon to display")] + public Image Icon + { + get { return _icon; } + set { _icon = value; Refresh(); } + } + + private Image _icon; + + private bool _isHiding = false; + + private readonly AnimationManager _animationManager; + + private readonly AnimationManager _showAnimationManager; + + public MaterialFloatingActionButton() + { + AnimateShowHideButton = false; + Mini = false; + DrawShadows = true; + SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); + + Size = new Size(FAB_SIZE, FAB_SIZE); + _animationManager = new AnimationManager(false) + { + Increment = 0.03, + AnimationType = AnimationType.EaseOut + }; + _animationManager.OnAnimationProgress += sender => Invalidate(); + + _showAnimationManager = new AnimationManager(true) + { + Increment = 0.1, + AnimationType = AnimationType.EaseOut + }; + _showAnimationManager.OnAnimationProgress += sender => Invalidate(); + _showAnimationManager.OnAnimationFinished += _showAnimationManager_OnAnimationFinished; + } + + protected override void InitLayout() + { + LocationChanged += (sender, e) => { if (DrawShadows) Parent?.Invalidate(); }; + } + + protected override void OnParentChanged(EventArgs e) + { + base.OnParentChanged(e); + if (DrawShadows && Parent != null) AddShadowPaintEvent(Parent, drawShadowOnParent); + if (_oldParent != null) RemoveShadowPaintEvent(_oldParent, drawShadowOnParent); + _oldParent = Parent; + } + + private Control _oldParent; + + protected override void OnVisibleChanged(EventArgs e) + { + base.OnVisibleChanged(e); + if (Parent == null) return; + if (Visible) + AddShadowPaintEvent(Parent, drawShadowOnParent); + else + RemoveShadowPaintEvent(Parent, drawShadowOnParent); + } + private bool _shadowDrawEventSubscribed = false; - - private void AddShadowPaintEvent(Control control, PaintEventHandler shadowPaintEvent) - { - if (_shadowDrawEventSubscribed) return; - control.Paint += shadowPaintEvent; - control.Invalidate(); - _shadowDrawEventSubscribed = true; - } - - private void RemoveShadowPaintEvent(Control control, PaintEventHandler shadowPaintEvent) - { - if (!_shadowDrawEventSubscribed) return; - control.Paint -= shadowPaintEvent; - control.Invalidate(); - _shadowDrawEventSubscribed = false; - } - - private void setSize(bool mini) - { - _mini = mini; - Size = _mini ? new Size(FAB_MINI_SIZE, FAB_MINI_SIZE) : new Size(FAB_SIZE, FAB_SIZE); - fabBounds = _mini ? new Rectangle(0, 0, FAB_MINI_SIZE, FAB_MINI_SIZE) : new Rectangle(0, 0, FAB_SIZE, FAB_SIZE); - fabBounds.Width -= 1; - fabBounds.Height -= 1; - } - - private void _showAnimationManager_OnAnimationFinished(object sender) - { - if (_isHiding) - { - Visible = false; - _isHiding = false; - } - } - - private void drawShadowOnParent(object sender, PaintEventArgs e) - { - if (Parent == null) - { - RemoveShadowPaintEvent((Control)sender, drawShadowOnParent); - return; - } - - // paint shadow on parent - Graphics gp = e.Graphics; - Rectangle rect = new Rectangle(Location, fabBounds.Size); - gp.SmoothingMode = SmoothingMode.AntiAlias; - DrawHelper.DrawRoundShadow(gp, rect); - } - + + private void AddShadowPaintEvent(Control control, PaintEventHandler shadowPaintEvent) + { + if (_shadowDrawEventSubscribed) return; + control.Paint += shadowPaintEvent; + control.Invalidate(); + _shadowDrawEventSubscribed = true; + } + + private void RemoveShadowPaintEvent(Control control, PaintEventHandler shadowPaintEvent) + { + if (!_shadowDrawEventSubscribed) return; + control.Paint -= shadowPaintEvent; + control.Invalidate(); + _shadowDrawEventSubscribed = false; + } + + private void setSize(bool mini) + { + _mini = mini; + Size = _mini ? new Size(FAB_MINI_SIZE, FAB_MINI_SIZE) : new Size(FAB_SIZE, FAB_SIZE); + fabBounds = _mini ? new Rectangle(0, 0, FAB_MINI_SIZE, FAB_MINI_SIZE) : new Rectangle(0, 0, FAB_SIZE, FAB_SIZE); + fabBounds.Width -= 1; + fabBounds.Height -= 1; + } + + private void _showAnimationManager_OnAnimationFinished(object sender) + { + if (_isHiding) + { + Visible = false; + _isHiding = false; + } + } + + private void drawShadowOnParent(object sender, PaintEventArgs e) + { + if (Parent == null) + { + RemoveShadowPaintEvent((Control)sender, drawShadowOnParent); + return; + } + + // paint shadow on parent + Graphics gp = e.Graphics; + Rectangle rect = new Rectangle(Location, fabBounds.Size); + gp.SmoothingMode = SmoothingMode.AntiAlias; + DrawHelper.DrawRoundShadow(gp, rect); + } + private Rectangle fabBounds; - - protected override void OnPaint(PaintEventArgs pevent) - { - var g = pevent.Graphics; - - g.Clear(Parent.BackColor); - g.SmoothingMode = SmoothingMode.AntiAlias; - - // Paint shadow on element to blend with the parent shadow - DrawHelper.DrawRoundShadow(g, fabBounds); - - // draw fab - g.FillEllipse(SkinManager.ColorScheme.AccentBrush, fabBounds); - - if (_animationManager.IsAnimating()) - { - GraphicsPath regionPath = new GraphicsPath(); - regionPath.AddEllipse(new Rectangle(fabBounds.X - 1, fabBounds.Y - 1, fabBounds.Width + 3, fabBounds.Height + 2)); - Region fabRegion = new Region(regionPath); - - GraphicsContainer gcont = g.BeginContainer(); - g.SetClip(fabRegion, CombineMode.Replace); - - for (int i = 0; i < _animationManager.GetAnimationCount(); i++) - { - var animationValue = _animationManager.GetProgress(i); - var animationSource = _animationManager.GetSource(i); - var rippleBrush = new SolidBrush(Color.FromArgb((int)(51 - (animationValue * 50)), Color.White)); - var rippleSize = (int)(animationValue * Width * 2); - g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize)); - } - - g.EndContainer(gcont); - } - - if (Icon != null) - { - g.DrawImage(Icon, new Rectangle(fabBounds.Width / 2 - 11, fabBounds.Height / 2 - 11, 24, 24)); - } - - if (_showAnimationManager.IsAnimating()) - { - int target = Convert.ToInt32((_mini ? FAB_MINI_SIZE : FAB_SIZE) * _showAnimationManager.GetProgress()); - fabBounds.Width = target == 0 ? 1 : target; - fabBounds.Height = target == 0 ? 1 : target; - fabBounds.X = Convert.ToInt32(((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) - (((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) * _showAnimationManager.GetProgress())); - fabBounds.Y = Convert.ToInt32(((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) - (((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) * _showAnimationManager.GetProgress())); - } - - // Clip to a round shape with a 1px padding - GraphicsPath clipPath = new GraphicsPath(); - clipPath.AddEllipse(new Rectangle(fabBounds.X - 1, fabBounds.Y - 1, fabBounds.Width + 3, fabBounds.Height + 3)); - Region = new Region(clipPath); - } - - protected override void OnMouseClick(MouseEventArgs mevent) - { - base.OnMouseClick(mevent); - _animationManager.StartNewAnimation(AnimationDirection.In, mevent.Location); - } - - private Point origin; - - public new void Hide() - { - if (Visible) - { - _isHiding = true; - _showAnimationManager.StartNewAnimation(AnimationDirection.Out); - } - } - - public new void Show() - { - if (!Visible) - { - origin = Location; - _showAnimationManager.StartNewAnimation(AnimationDirection.In); - Visible = true; - } - } - } -} \ No newline at end of file + + protected override void OnPaint(PaintEventArgs pevent) + { + var g = pevent.Graphics; + + g.Clear(Parent.BackColor); + g.SmoothingMode = SmoothingMode.AntiAlias; + + // Paint shadow on element to blend with the parent shadow + DrawHelper.DrawRoundShadow(g, fabBounds); + + // draw fab + g.FillEllipse(Enabled ? _mouseHover ? + new SolidBrush(SkinManager.ColorScheme.AccentColor.Lighten(0.25f)) : + SkinManager.ColorScheme.AccentBrush : + new SolidBrush(DrawHelper.BlendColor(SkinManager.ColorScheme.AccentColor, SkinManager.SwitchOffDisabledThumbColor, 197)), + fabBounds); + + if (_animationManager.IsAnimating()) + { + GraphicsPath regionPath = new GraphicsPath(); + regionPath.AddEllipse(new Rectangle(fabBounds.X - 1, fabBounds.Y - 1, fabBounds.Width + 3, fabBounds.Height + 2)); + Region fabRegion = new Region(regionPath); + + GraphicsContainer gcont = g.BeginContainer(); + g.SetClip(fabRegion, CombineMode.Replace); + + for (int i = 0; i < _animationManager.GetAnimationCount(); i++) + { + var animationValue = _animationManager.GetProgress(i); + var animationSource = _animationManager.GetSource(i); + var rippleBrush = new SolidBrush(Color.FromArgb((int)(51 - (animationValue * 50)), Color.White)); + var rippleSize = (int)(animationValue * Width * 2); + g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize)); + } + + g.EndContainer(gcont); + } + + if (Icon != null) + { + g.DrawImage(Icon, new Rectangle(fabBounds.Width / 2 - 11, fabBounds.Height / 2 - 11, 24, 24)); + } + + if (_showAnimationManager.IsAnimating()) + { + int target = Convert.ToInt32((_mini ? FAB_MINI_SIZE : FAB_SIZE) * _showAnimationManager.GetProgress()); + fabBounds.Width = target == 0 ? 1 : target; + fabBounds.Height = target == 0 ? 1 : target; + fabBounds.X = Convert.ToInt32(((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) - (((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) * _showAnimationManager.GetProgress())); + fabBounds.Y = Convert.ToInt32(((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) - (((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) * _showAnimationManager.GetProgress())); + } + + // Clip to a round shape with a 1px padding + GraphicsPath clipPath = new GraphicsPath(); + clipPath.AddEllipse(new Rectangle(fabBounds.X - 1, fabBounds.Y - 1, fabBounds.Width + 3, fabBounds.Height + 3)); + Region = new Region(clipPath); + } + + protected override void OnMouseClick(MouseEventArgs mevent) + { + base.OnMouseClick(mevent); + _animationManager.StartNewAnimation(AnimationDirection.In, mevent.Location); + } + + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + + if (DesignMode) + return; + + _mouseHover = ClientRectangle.Contains(e.Location); + Invalidate(); + } + + protected override void OnMouseLeave(EventArgs e) + { + base.OnMouseLeave(e); + if (DesignMode) + return; + + _mouseHover = false; + Invalidate(); + } + + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + + if (DrawShadows && Parent != null) + { + RemoveShadowPaintEvent(Parent, drawShadowOnParent); + AddShadowPaintEvent(Parent, drawShadowOnParent); + } + } + + + private Point origin; + + public new void Hide() + { + if (Visible) + { + _isHiding = true; + _showAnimationManager.StartNewAnimation(AnimationDirection.Out); + } + } + + public new void Show() + { + if (!Visible) + { + origin = Location; + _showAnimationManager.StartNewAnimation(AnimationDirection.In); + Visible = true; + } + } + } +} diff --git a/MaterialSkin/Controls/MaterialForm.cs b/MaterialSkin/Controls/MaterialForm.cs index 890b3805..6414f885 100644 --- a/MaterialSkin/Controls/MaterialForm.cs +++ b/MaterialSkin/Controls/MaterialForm.cs @@ -1,988 +1,1299 @@ -namespace MaterialSkin.Controls -{ - using MaterialSkin.Animations; - using System; - using System.Collections.Generic; - using System.ComponentModel; - using System.Drawing; - using System.Drawing.Text; - using System.Linq; - using System.Runtime.InteropServices; - using System.Windows.Forms; - - public class MaterialForm : Form, IMaterialControl - { - [Browsable(false)] - public int Depth { get; set; } - - [Browsable(false)] - public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; - - [Browsable(false)] - public MouseState MouseState { get; set; } - - public new FormBorderStyle FormBorderStyle - { - get { return base.FormBorderStyle; } - set { base.FormBorderStyle = value; } - } - - [Category("Layout")] - public bool Sizable { get; set; } - - [DllImport("user32.dll")] - public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); - - [DllImport("user32.dll")] - public static extern bool ReleaseCapture(); - - [DllImport("user32.dll")] - public static extern int TrackPopupMenuEx(IntPtr hmenu, uint fuFlags, int x, int y, IntPtr hwnd, IntPtr lptpm); - - [DllImport("user32.dll")] - public static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert); - - [DllImport("user32.dll")] - public static extern IntPtr MonitorFromWindow(IntPtr hwnd, uint dwFlags); - - [DllImport("User32.dll", CharSet = CharSet.Auto)] - public static extern bool GetMonitorInfo(HandleRef hmonitor, [In, Out] MONITORINFOEX info); - - public const int WM_NCLBUTTONDOWN = 0xA1; - public const int HT_CAPTION = 0x2; - public const int WM_MOUSEMOVE = 0x0200; - public const int WM_LBUTTONDOWN = 0x0201; - public const int WM_LBUTTONUP = 0x0202; - public const int WM_LBUTTONDBLCLK = 0x0203; - public const int WM_RBUTTONDOWN = 0x0204; - private const int HTBOTTOMLEFT = 16; - private const int HTBOTTOMRIGHT = 17; - private const int HTLEFT = 10; - private const int HTRIGHT = 11; - private const int HTBOTTOM = 15; - private const int HTTOP = 12; - private const int HTTOPLEFT = 13; - private const int HTTOPRIGHT = 14; - private const int BORDER_WIDTH = 7; - - private ResizeDirection _resizeDir; - private ButtonState _buttonState = ButtonState.None; - - private const int WMSZ_TOP = 3; - private const int WMSZ_TOPLEFT = 4; - private const int WMSZ_TOPRIGHT = 5; - private const int WMSZ_LEFT = 1; - private const int WMSZ_RIGHT = 2; - private const int WMSZ_BOTTOM = 6; - private const int WMSZ_BOTTOMLEFT = 7; - private const int WMSZ_BOTTOMRIGHT = 8; - - private readonly Dictionary _resizingLocationsToCmd = new Dictionary - { - {HTTOP, WMSZ_TOP}, - {HTTOPLEFT, WMSZ_TOPLEFT}, - {HTTOPRIGHT, WMSZ_TOPRIGHT}, - {HTLEFT, WMSZ_LEFT}, - {HTRIGHT, WMSZ_RIGHT}, - {HTBOTTOM, WMSZ_BOTTOM}, - {HTBOTTOMLEFT, WMSZ_BOTTOMLEFT}, - {HTBOTTOMRIGHT, WMSZ_BOTTOMRIGHT} - }; - - private const int STATUS_BAR_BUTTON_WIDTH = STATUS_BAR_HEIGHT; - private const int STATUS_BAR_HEIGHT = 24; - private const int ACTION_BAR_HEIGHT = 40; - private const uint TPM_LEFTALIGN = 0x0000; - private const uint TPM_RETURNCMD = 0x0100; - private const int WM_SYSCOMMAND = 0x0112; - private const int WS_MINIMIZEBOX = 0x20000; - private const int WS_SYSMENU = 0x00080000; - private const int MONITOR_DEFAULTTONEAREST = 2; - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 4)] - public class MONITORINFOEX - { - public int cbSize = Marshal.SizeOf(typeof(MONITORINFOEX)); - public RECT rcMonitor = new RECT(); - public RECT rcWork = new RECT(); - public int dwFlags = 0; - - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - public char[] szDevice = new char[32]; - } - - [StructLayout(LayoutKind.Sequential)] - public struct RECT - { - public int left; - public int top; - public int right; - public int bottom; - - public int Width() - { - return right - left; - } - - public int Height() - { - return bottom - top; - } - } - - private enum ResizeDirection - { - BottomLeft, - Left, - Right, - BottomRight, - Bottom, - None - } - - private enum ButtonState - { - XOver, - MaxOver, - MinOver, - XDown, - MaxDown, - MinDown, - None - } - - private readonly Cursor[] _resizeCursors = { Cursors.SizeNESW, Cursors.SizeWE, Cursors.SizeNWSE, Cursors.SizeWE, Cursors.SizeNS }; - - private Rectangle _minButtonBounds; - private Rectangle _maxButtonBounds; - private Rectangle _xButtonBounds; - private Rectangle _actionBarBounds; - - public Rectangle UserArea - { - get - { - return new Rectangle(0, STATUS_BAR_HEIGHT + ACTION_BAR_HEIGHT, Width, Height - (STATUS_BAR_HEIGHT + ACTION_BAR_HEIGHT)); - } - } - - private Rectangle _statusBarBounds; - private bool _maximized; - private Size _previousSize; - private Point _previousLocation; - private bool _headerMouseDown; - - private Padding originalPadding; - - public MaterialForm() - { - DrawerWidth = 200; - DrawerIsOpen = false; - DrawerShowIconsWhenHidden = false; - DrawerAutoHide = true; - DrawerIndicatorWidth = 0; - DrawerHighlightWithAccent = true; - DrawerBackgroundWithAccent = false; - - FormBorderStyle = FormBorderStyle.None; - Sizable = true; - DoubleBuffered = true; - SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); - - // This enables the form to trigger the MouseMove event even when mouse is over another control - Application.AddMessageFilter(new MouseMessageFilter()); - MouseMessageFilter.MouseMove += OnGlobalMouseMove; - - _clickAnimManager = new AnimationManager() - { - AnimationType = AnimationType.EaseOut, - Increment = 0.04 - }; - _clickAnimManager.OnAnimationProgress += sender => Invalidate(); - - // Drawer - Shown += (sender, e) => - { - if (DesignMode || IsDisposed) - return; - AddDrawerOverlayForm(); - }; - } - - // Drawer overlay and speed improvements - private bool _drawerShowIconsWhenHidden; - - [Category("Drawer")] - public bool DrawerShowIconsWhenHidden - { - get { return _drawerShowIconsWhenHidden; } - set - { - _drawerShowIconsWhenHidden = value; - if (drawerControl != null) - { - drawerControl.ShowIconsWhenHidden = _drawerShowIconsWhenHidden; - drawerControl.Refresh(); - } - } - } - - [Category("Drawer")] - public int DrawerWidth { get; set; } - - [Category("Drawer")] - public bool DrawerAutoHide { get; set; } - - [Category("Drawer")] - public int DrawerIndicatorWidth { get; set; } - +namespace MaterialSkin.Controls +{ + using MaterialSkin.Animations; + using System; + using System.ComponentModel; + using System.Drawing; + using System.Drawing.Text; + using System.Linq; + using System.Runtime.InteropServices; + using System.Windows.Forms; + +#if NETFRAMEWORK + using System.Runtime.Remoting.Channels; +#endif + + public class MaterialForm : Form, IMaterialControl + { + #region Public Properties + [Browsable(false)] + public int Depth { get; set; } + + [Browsable(false)] + public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; + + [Browsable(false)] + public MouseState MouseState { get; set; } + + [Category("Layout")] + public bool Sizable { get; set; } + + [Category("Material Skin"), Browsable(true), DisplayName("Form Style"), DefaultValue(FormStyles.ActionBar_40)] + public FormStyles FormStyle + { + get => _formStyle; + set + { + if (_formStyle == value) return; + + _formStyle = value; + RecalculateFormBoundaries(); + } + } + + [Category("Drawer")] + public bool DrawerShowIconsWhenHidden + { + get => _drawerShowIconsWhenHidden; + set + { + if (_drawerShowIconsWhenHidden == value) return; + + _drawerShowIconsWhenHidden = value; + + if (drawerControl == null) return; + + drawerControl.ShowIconsWhenHidden = _drawerShowIconsWhenHidden; + drawerControl.Refresh(); + } + } + + [Category("Drawer")] + public int DrawerWidth { get; set; } + + [Category("Drawer")] + public bool DrawerAutoHide + { + get => _drawerAutoHide; + set => drawerControl.AutoHide = _drawerAutoHide = value; + } + + [Category("Drawer")] + public bool DrawerAutoShow + { + get => _drawerAutoShow; + set => drawerControl.AutoShow = _drawerAutoShow = value; + } + + [Category("Drawer")] + public int DrawerIndicatorWidth { get; set; } + + [Category("Drawer")] + public bool DrawerIsOpen + { + get => _drawerIsOpen; + set + { + if (_drawerIsOpen == value) return; + + _drawerIsOpen = value; + + if (value) + drawerControl?.Show(); + else + drawerControl?.Hide(); + } + } + + [Category("Drawer")] + public bool DrawerUseColors + { + get => _drawerUseColors; + set + { + if (_drawerUseColors == value) return; + + _drawerUseColors = value; + + if (drawerControl == null) return; + + drawerControl.UseColors = value; + drawerControl.Refresh(); + } + } + + [Category("Drawer")] + public bool DrawerHighlightWithAccent + { + get => _drawerHighlightWithAccent; + set + { + if (_drawerHighlightWithAccent == value) return; + + _drawerHighlightWithAccent = value; + + if (drawerControl == null) return; + + drawerControl.HighlightWithAccent = value; + drawerControl.Refresh(); + } + } + + [Category("Drawer")] + public bool DrawerBackgroundWithAccent + { + get => _backgroundWithAccent; + set + { + if (_backgroundWithAccent == value) return; + + _backgroundWithAccent = value; + + if (drawerControl == null) return; + + drawerControl.BackgroundWithAccent = value; + drawerControl.Refresh(); + } + } + + [Category("Drawer")] + public MaterialTabControl DrawerTabControl { get; set; } + + public override string Text + { + get { return base.Text; } + set { base.Text = value; Invalidate(); } + } + + public new FormWindowState WindowState + { + get { return base.WindowState; } + set { base.WindowState = value; } + } + + public new FormBorderStyle FormBorderStyle + { + get { return base.FormBorderStyle; } + set { base.FormBorderStyle = value; } + } + + public Rectangle UserArea + { + get + { + return new Rectangle(ClientRectangle.X, ClientRectangle.Y + STATUS_BAR_HEIGHT + ACTION_BAR_HEIGHT, ClientSize.Width, ClientSize.Height - (STATUS_BAR_HEIGHT + ACTION_BAR_HEIGHT)); + } + } + #endregion + + #region Enums + /// + /// Various options to control the top caption of a window + /// + public enum FormStyles + { + StatusAndActionBar_None, + ActionBar_None, + ActionBar_40, + ActionBar_48, + ActionBar_56, + ActionBar_64, + } + + /// + /// Various directions the form can be resized in + /// + private enum ResizeDirection + { + BottomLeft, + Left, + Right, + BottomRight, + Bottom, + Top, + TopLeft, + TopRight, + None + } + + /// + /// The states a button can be in + /// + private enum ButtonState + { + XOver, + MaxOver, + MinOver, + DrawerOver, + XDown, + MaxDown, + MinDown, + DrawerDown, + None + } + + /// + /// Window Messages + /// + /// + private enum WM + { + /// + /// WM_NCCALCSIZE + /// + NonClientCalcSize = 0x0083, + /// + /// WM_NCACTIVATE + /// + NonClientActivate = 0x0086, + /// + /// WM_NCLBUTTONDOWN + /// + NonClientLeftButtonDown = 0x00A1, + /// + /// WM_SYSCOMMAND + /// + SystemCommand = 0x0112, + /// + /// WM_MOUSEMOVE + /// + MouseMove = 0x0200, + /// + /// WM_LBUTTONDOWN + /// + LeftButtonDown = 0x0201, + /// + /// WM_LBUTTONUP + /// + LeftButtonUp = 0x0202, + /// + /// WM_LBUTTONDBLCLK + /// + LeftButtonDoubleClick = 0x0203, + /// + /// WM_RBUTTONDOWN + /// + RightButtonDown = 0x0204, + } + + /// + /// Hit Test Results + /// + /// + private enum HT + { + /// + /// HTNOWHERE - Nothing under cursor + /// + None = 0, + /// + /// HTCAPTION - Titlebar + /// + Caption = 2, + /// + /// HTLEFT - Left border + /// + Left = 10, + /// + /// HTRIGHT - Right border + /// + Right = 11, + /// + /// HTTOP - Top border + /// + Top = 12, + /// + /// HTTOPLEFT - Top left corner + /// + TopLeft = 13, + /// + /// HTTOPRIGHT - Top right corner + /// + TopRight = 14, + /// + /// HTBOTTOM - Bottom border + /// + Bottom = 15, + /// + /// HTBOTTOMLEFT - Bottom left corner + /// + BottomLeft = 16, + /// + /// HTBOTTOMRIGHT - Bottom right corner + /// + BottomRight = 17, + } + + /// + /// Window Styles + /// + /// + private enum WS + { + /// + /// WS_MINIMIZEBOX - Allow minimizing from taskbar + /// + MinimizeBox = 0x20000, + /// + /// WS_SIZEFRAME - Required for Aero Snapping + /// + SizeFrame = 0x40000, + /// + /// WS_SYSMENU - Trigger the creation of the system menu + /// + SysMenu = 0x80000, + } + + /// + /// Track Popup Menu Flags + /// + /// + private enum TPM + { + /// + /// TPM_LEFTALIGN + /// + LeftAlign = 0x0000, + /// + /// TPM_RETURNCMD + /// + ReturnCommand = 0x0100, + } + #endregion + + #region Constants + // Form Constants + private const int BORDER_WIDTH = 7; + private const int STATUS_BAR_BUTTON_WIDTH = 24; + private const int STATUS_BAR_HEIGHT_DEFAULT = 24; + private const int ICON_SIZE = 24; + private const int PADDING_MINIMUM = 3; + private const int TITLE_LEFT_PADDING = 72; + private const int ACTION_BAR_PADDING = 16; + private const int ACTION_BAR_HEIGHT_DEFAULT = 40; + #endregion + + #region Private Fields + private readonly Cursor[] _resizeCursors = { Cursors.SizeNESW, Cursors.SizeWE, Cursors.SizeNWSE, Cursors.SizeWE, Cursors.SizeNS }; + + private ResizeDirection _resizeDir; + private ButtonState _buttonState = ButtonState.None; + private FormStyles _formStyle; + private Rectangle _minButtonBounds => new Rectangle(ClientSize.Width - 3 * STATUS_BAR_BUTTON_WIDTH, ClientRectangle.Y, STATUS_BAR_BUTTON_WIDTH, STATUS_BAR_HEIGHT); + private Rectangle _maxButtonBounds => new Rectangle(ClientSize.Width - 2 * STATUS_BAR_BUTTON_WIDTH, ClientRectangle.Y, STATUS_BAR_BUTTON_WIDTH, STATUS_BAR_HEIGHT); + private Rectangle _xButtonBounds => new Rectangle(ClientSize.Width - STATUS_BAR_BUTTON_WIDTH, ClientRectangle.Y, STATUS_BAR_BUTTON_WIDTH, STATUS_BAR_HEIGHT); + private Rectangle _actionBarBounds => new Rectangle(ClientRectangle.X, ClientRectangle.Y + STATUS_BAR_HEIGHT, ClientSize.Width, ACTION_BAR_HEIGHT); + private Rectangle _drawerButtonBounds => new Rectangle(ClientRectangle.X + (SkinManager.FORM_PADDING / 2) + 3, STATUS_BAR_HEIGHT + (ACTION_BAR_HEIGHT / 2) - (ACTION_BAR_HEIGHT_DEFAULT / 2), ACTION_BAR_HEIGHT_DEFAULT, ACTION_BAR_HEIGHT_DEFAULT); + private Rectangle _statusBarBounds => new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientSize.Width, STATUS_BAR_HEIGHT); + private Rectangle _drawerIconRect; + + private bool Maximized + { + get => WindowState == FormWindowState.Maximized; + set + { + if (!MaximizeBox || !ControlBox) return; + + if (value) + WindowState = FormWindowState.Maximized; + else + WindowState = FormWindowState.Normal; + } + } + private Point _animationSource; + private Padding originalPadding; + + private Form drawerOverlay = new Form(); + private MaterialDrawerForm drawerForm = new MaterialDrawerForm(); + + // Drawer overlay and speed improvements + private bool _drawerShowIconsWhenHidden; + private bool _drawerAutoHide; + private bool _drawerAutoShow; private bool _drawerIsOpen; - - [Category("Drawer")] - public bool DrawerIsOpen - { - get - { - return _drawerIsOpen; - } - set - { - _drawerIsOpen = value; - if (drawerControl != null) - { - if (value) - drawerControl.Show(); - else - drawerControl.Hide(); - } - } - } - private bool _drawerUseColors; - - [Category("Drawer")] - public bool DrawerUseColors - { - get - { - return _drawerUseColors; - } - set - { - _drawerUseColors = value; - if (drawerControl != null) - { - drawerControl.UseColors = value; - drawerControl.Refresh(); - } - } - } - private bool _drawerHighlightWithAccent; - - [Category("Drawer")] - public bool DrawerHighlightWithAccent - { - get - { - return _drawerHighlightWithAccent; - } - set - { - _drawerHighlightWithAccent = value; - if (drawerControl != null) - { - drawerControl.HighlightWithAccent = value; - drawerControl.Refresh(); - } - } - } - private bool _backgroundWithAccent; - - [Category("Drawer")] - public bool DrawerBackgroundWithAccent - { - get - { - return _backgroundWithAccent; - } - set - { - _backgroundWithAccent = value; - if (drawerControl != null) - { - drawerControl.BackgroundWithAccent = value; - drawerControl.Refresh(); - } - } - } - - private MaterialDrawer drawerControl = new MaterialDrawer(); - - [Category("Drawer")] - public MaterialTabControl DrawerTabControl { get; set; } - - private AnimationManager _drawerShowHideAnimManager; - - protected void AddDrawerOverlayForm() - { - Form drawerOverlay = new Form(); - Form drawerForm = new Form(); - - if (DrawerTabControl == null) - return; - - // Form opacity fade animation; - _drawerShowHideAnimManager = new AnimationManager - { - AnimationType = AnimationType.EaseInOut, - Increment = 0.04 - }; - - _drawerShowHideAnimManager.OnAnimationProgress += (sender) => - { - drawerOverlay.Opacity = (float)(_drawerShowHideAnimManager.GetProgress() * 0.55f); - }; - - int H = Size.Height - _statusBarBounds.Height - _actionBarBounds.Height; - int Y = Location.Y + _statusBarBounds.Height + _actionBarBounds.Height; - - // Drawer Form definitions - drawerForm.BackColor = Color.LimeGreen; - drawerForm.TransparencyKey = Color.LimeGreen; - drawerForm.MinimizeBox = false; - drawerForm.MaximizeBox = false; - drawerForm.Text = ""; - drawerForm.ShowIcon = false; - drawerForm.ControlBox = false; - drawerForm.FormBorderStyle = FormBorderStyle.None; - drawerForm.Visible = true; - drawerForm.Size = new Size(DrawerWidth, H); - drawerForm.Location = new Point(Location.X, Y); - drawerForm.ShowInTaskbar = false; - drawerForm.Owner = drawerOverlay; - drawerForm.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; - - // Add drawer to overlay form - drawerForm.Controls.Add(drawerControl); - drawerControl.Location = new Point(0, 0); - drawerControl.Size = new Size(DrawerWidth, H); - drawerControl.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom); - drawerControl.BaseTabControl = DrawerTabControl; - drawerControl.ShowIconsWhenHidden = true; - // Init Options - drawerControl.IsOpen = DrawerIsOpen; - drawerControl.ShowIconsWhenHidden = DrawerShowIconsWhenHidden; - drawerControl.AutoHide = DrawerAutoHide; - drawerControl.IndicatorWidth = DrawerIndicatorWidth; - drawerControl.HighlightWithAccent = DrawerHighlightWithAccent; - drawerControl.BackgroundWithAccent = DrawerBackgroundWithAccent; - - // Changing colors or theme - SkinManager.ThemeChanged += sender => - { - drawerForm.Refresh(); - }; - SkinManager.ColorSchemeChanged += sender => - { - drawerForm.Refresh(); - }; - - // Overlay Form definitions - drawerOverlay.BackColor = Color.Black; - drawerOverlay.Opacity = 0; - drawerOverlay.MinimizeBox = false; - drawerOverlay.MaximizeBox = false; - drawerOverlay.Text = ""; - drawerOverlay.ShowIcon = false; - drawerOverlay.ControlBox = false; - drawerOverlay.FormBorderStyle = FormBorderStyle.None; - drawerOverlay.Visible = true; - drawerOverlay.Size = new Size(Size.Width, H); - drawerOverlay.Location = new Point(Location.X, Y); - drawerOverlay.ShowInTaskbar = false; - drawerOverlay.Owner = this; - drawerOverlay.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; - - // Visible, Resize and move events - VisibleChanged += (sender, e) => - { - drawerForm.Visible = Visible; - drawerOverlay.Visible = Visible; - }; - - Resize += (sender, e) => - { - H = Size.Height - _statusBarBounds.Height - _actionBarBounds.Height; - drawerForm.Size = new Size(DrawerWidth, H); - drawerOverlay.Size = new Size(Size.Width, H); - }; - - Move += (sender, e) => - { - Point pos = new Point(Location.X, Location.Y + _statusBarBounds.Height + _actionBarBounds.Height); - drawerForm.Location = pos; - drawerOverlay.Location = pos; - }; - - // Close when click outside menu - drawerOverlay.Click += (sender, e) => - { - drawerControl.Hide(); - }; - - // Animation and visibility - drawerControl.DrawerBeginOpen += (sender) => - { - _drawerShowHideAnimManager.StartNewAnimation(AnimationDirection.In); - }; - - drawerControl.DrawerBeginClose += (sender) => - { - _drawerShowHideAnimManager.StartNewAnimation(AnimationDirection.Out); - }; - - // Form Padding corrections - - if (Padding.Top < (_statusBarBounds.Height + _actionBarBounds.Height)) - Padding = new Padding(Padding.Left, (_statusBarBounds.Height + _actionBarBounds.Height), Padding.Right, Padding.Bottom); - - originalPadding = Padding; - - drawerControl.DrawerShowIconsWhenHiddenChanged += FixFormPadding; - FixFormPadding(this); - } - - private void FixFormPadding(object sender) - { - if (drawerControl.ShowIconsWhenHidden && - Padding.Left < drawerControl.MinWidth) Padding = new Padding(drawerControl.MinWidth, originalPadding.Top, originalPadding.Right, originalPadding.Bottom); - else - Padding = originalPadding; - } - - protected override void WndProc(ref Message m) - { - base.WndProc(ref m); - if (DesignMode || IsDisposed) - return; - - // Drawer - if (DrawerTabControl != null && (m.Msg == WM_LBUTTONDOWN || m.Msg == WM_LBUTTONDBLCLK) && _drawerIconRect.Contains(PointToClient(Cursor.Position))) - { - drawerControl.Toggle(); - _clickAnimManager.SetProgress(0); - _clickAnimManager.StartNewAnimation(AnimationDirection.In); - _animationSource = (PointToClient(Cursor.Position)); - } - // Double click to maximize - else if (m.Msg == WM_LBUTTONDBLCLK) - { - MaximizeWindow(!_maximized); - } - // move a maximized window - else if (m.Msg == WM_MOUSEMOVE && _maximized && - (_statusBarBounds.Contains(PointToClient(Cursor.Position)) || _actionBarBounds.Contains(PointToClient(Cursor.Position))) && - !(_minButtonBounds.Contains(PointToClient(Cursor.Position)) || _maxButtonBounds.Contains(PointToClient(Cursor.Position)) || _xButtonBounds.Contains(PointToClient(Cursor.Position)))) - { - if (_headerMouseDown) - { - _maximized = false; - _headerMouseDown = false; - - var mousePoint = PointToClient(Cursor.Position); - if (mousePoint.X < Width / 2) - Location = mousePoint.X < _previousSize.Width / 2 ? - new Point(Cursor.Position.X - mousePoint.X, Cursor.Position.Y - mousePoint.Y) : - new Point(Cursor.Position.X - _previousSize.Width / 2, Cursor.Position.Y - mousePoint.Y); - else - Location = Width - mousePoint.X < _previousSize.Width / 2 ? - new Point(Cursor.Position.X - _previousSize.Width + Width - mousePoint.X, Cursor.Position.Y - mousePoint.Y) : - new Point(Cursor.Position.X - _previousSize.Width / 2, Cursor.Position.Y - mousePoint.Y); - - Size = _previousSize; - ReleaseCapture(); - SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0); - } - } - // Status bar buttons - else if (m.Msg == WM_LBUTTONDOWN && - (_statusBarBounds.Contains(PointToClient(Cursor.Position)) || _actionBarBounds.Contains(PointToClient(Cursor.Position))) && - !(_minButtonBounds.Contains(PointToClient(Cursor.Position)) || _maxButtonBounds.Contains(PointToClient(Cursor.Position)) || _xButtonBounds.Contains(PointToClient(Cursor.Position)))) - { - if (!_maximized) - { - ReleaseCapture(); - SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0); - } - else - { - _headerMouseDown = true; - } - } - // Default context menu - else if (m.Msg == WM_RBUTTONDOWN) - { - Point cursorPos = PointToClient(Cursor.Position); - - if (_statusBarBounds.Contains(cursorPos) && !_minButtonBounds.Contains(cursorPos) && - !_maxButtonBounds.Contains(cursorPos) && !_xButtonBounds.Contains(cursorPos)) - { - // Show default system menu when right clicking titlebar - var id = TrackPopupMenuEx(GetSystemMenu(Handle, false), TPM_LEFTALIGN | TPM_RETURNCMD, Cursor.Position.X, Cursor.Position.Y, Handle, IntPtr.Zero); - - // Pass the command as a WM_SYSCOMMAND message - SendMessage(Handle, WM_SYSCOMMAND, id, 0); - } - } - else if (m.Msg == WM_NCLBUTTONDOWN) - { - // This re-enables resizing by letting the application know when the - // user is trying to resize a side. This is disabled by default when using WS_SYSMENU. - if (!Sizable) - return; - - byte bFlag = 0; - - // Get which side to resize from - if (_resizingLocationsToCmd.ContainsKey((int)m.WParam)) - bFlag = (byte)_resizingLocationsToCmd[(int)m.WParam]; - - if (bFlag != 0) - SendMessage(Handle, WM_SYSCOMMAND, 0xF000 | bFlag, (int)m.LParam); - } - else if (m.Msg == WM_LBUTTONUP) - { - _headerMouseDown = false; - } - } - - protected override CreateParams CreateParams - { - get - { - var par = base.CreateParams; - // WS_SYSMENU: Trigger the creation of the system menu - // WS_MINIMIZEBOX: Allow minimizing from taskbar - par.Style = par.Style | WS_MINIMIZEBOX | WS_SYSMENU; // Turn on the WS_MINIMIZEBOX style flag - return par; - } - } - - protected override void OnMouseDown(MouseEventArgs e) - { - if (DesignMode) - return; - UpdateButtons(e); - - if (e.Button == MouseButtons.Left && !_maximized) - ResizeForm(_resizeDir); - base.OnMouseDown(e); - } - - protected override void OnMouseLeave(EventArgs e) - { - base.OnMouseLeave(e); - if (DesignMode) - return; - _buttonState = ButtonState.None; - Invalidate(); - } - - protected override void OnMouseMove(MouseEventArgs e) - { - base.OnMouseMove(e); - - if (DesignMode) - return; - - if (Sizable) - { - //True if the mouse is hovering over a child control - var isChildUnderMouse = GetChildAtPoint(e.Location) != null; - - if (e.Location.X < BORDER_WIDTH && e.Location.Y > Height - BORDER_WIDTH && !isChildUnderMouse && !_maximized) - { - _resizeDir = ResizeDirection.BottomLeft; - Cursor = Cursors.SizeNESW; - } - else if (e.Location.X < BORDER_WIDTH && !isChildUnderMouse && !_maximized) - { - _resizeDir = ResizeDirection.Left; - Cursor = Cursors.SizeWE; - } - else if (e.Location.X > Width - BORDER_WIDTH && e.Location.Y > Height - BORDER_WIDTH && !isChildUnderMouse && !_maximized) - { - _resizeDir = ResizeDirection.BottomRight; - Cursor = Cursors.SizeNWSE; - } - else if (e.Location.X > Width - BORDER_WIDTH && !isChildUnderMouse && !_maximized) - { - _resizeDir = ResizeDirection.Right; - Cursor = Cursors.SizeWE; - } - else if (e.Location.Y > Height - BORDER_WIDTH && !isChildUnderMouse && !_maximized) - { - _resizeDir = ResizeDirection.Bottom; - Cursor = Cursors.SizeNS; - } - else - { - _resizeDir = ResizeDirection.None; - - //Only reset the cursor when needed, this prevents it from flickering when a child control changes the cursor to its own needs - if (_resizeCursors.Contains(Cursor)) - { - Cursor = Cursors.Default; - } - } - } - - UpdateButtons(e); - } - - protected void OnGlobalMouseMove(object sender, MouseEventArgs e) - { - if (IsDisposed) - return; - // Convert to client position and pass to Form.MouseMove - var clientCursorPos = PointToClient(e.Location); - var newE = new MouseEventArgs(MouseButtons.None, 0, clientCursorPos.X, clientCursorPos.Y, 0); - OnMouseMove(newE); - } - - private void UpdateButtons(MouseEventArgs e, bool up = false) - { - if (DesignMode) - return; - var oldState = _buttonState; - bool showMin = MinimizeBox && ControlBox; - bool showMax = MaximizeBox && ControlBox; - - if (e.Button == MouseButtons.Left && !up) - { - if (showMin && !showMax && _maxButtonBounds.Contains(e.Location)) - _buttonState = ButtonState.MinDown; - else if (showMin && showMax && _minButtonBounds.Contains(e.Location)) - _buttonState = ButtonState.MinDown; - else if (showMax && _maxButtonBounds.Contains(e.Location)) - _buttonState = ButtonState.MaxDown; - else if (ControlBox && _xButtonBounds.Contains(e.Location)) - _buttonState = ButtonState.XDown; - else - _buttonState = ButtonState.None; - } - else - { - if (showMin && !showMax && _maxButtonBounds.Contains(e.Location)) - { - _buttonState = ButtonState.MinOver; - - if (oldState == ButtonState.MinDown && up) - WindowState = FormWindowState.Minimized; - } - else if (showMin && showMax && _minButtonBounds.Contains(e.Location)) - { - _buttonState = ButtonState.MinOver; - - if (oldState == ButtonState.MinDown && up) - WindowState = FormWindowState.Minimized; - } - else if (MaximizeBox && ControlBox && _maxButtonBounds.Contains(e.Location)) - { - _buttonState = ButtonState.MaxOver; - - if (oldState == ButtonState.MaxDown && up) - MaximizeWindow(!_maximized); - } - else if (ControlBox && _xButtonBounds.Contains(e.Location)) - { - _buttonState = ButtonState.XOver; - - if (oldState == ButtonState.XDown && up) - Close(); - } - else - _buttonState = ButtonState.None; - } - - if (oldState != _buttonState) - Invalidate(); - } - - private void MaximizeWindow(bool maximize) - { - if (!MaximizeBox || !ControlBox) - return; - - _maximized = maximize; - - if (maximize) - { - var monitorHandle = MonitorFromWindow(Handle, MONITOR_DEFAULTTONEAREST); - var monitorInfo = new MONITORINFOEX(); - GetMonitorInfo(new HandleRef(null, monitorHandle), monitorInfo); - _previousSize = Size; - _previousLocation = Location; - Size = new Size(monitorInfo.rcWork.Width(), monitorInfo.rcWork.Height()); - Location = new Point(monitorInfo.rcWork.left, monitorInfo.rcWork.top); - } - else - { - Size = _previousSize; - Location = _previousLocation; - } - } - - protected override void OnMouseUp(MouseEventArgs e) - { - if (DesignMode) - return; - UpdateButtons(e, true); - - base.OnMouseUp(e); - ReleaseCapture(); - } - - private void ResizeForm(ResizeDirection direction) - { - if (DesignMode) - return; - var dir = -1; - switch (direction) - { - case ResizeDirection.BottomLeft: - dir = HTBOTTOMLEFT; - break; - - case ResizeDirection.Left: - dir = HTLEFT; - break; - - case ResizeDirection.Right: - dir = HTRIGHT; - break; - - case ResizeDirection.BottomRight: - dir = HTBOTTOMRIGHT; - break; - - case ResizeDirection.Bottom: - dir = HTBOTTOM; - break; - } - - ReleaseCapture(); - if (dir != -1) - { - SendMessage(Handle, WM_NCLBUTTONDOWN, dir, 0); - } - } - - protected override void OnResize(EventArgs e) - { - base.OnResize(e); - - _minButtonBounds = new Rectangle((Width) - 3 * STATUS_BAR_BUTTON_WIDTH, 0, STATUS_BAR_BUTTON_WIDTH, STATUS_BAR_HEIGHT); - _maxButtonBounds = new Rectangle((Width) - 2 * STATUS_BAR_BUTTON_WIDTH, 0, STATUS_BAR_BUTTON_WIDTH, STATUS_BAR_HEIGHT); - _xButtonBounds = new Rectangle((Width) - STATUS_BAR_BUTTON_WIDTH, 0, STATUS_BAR_BUTTON_WIDTH, STATUS_BAR_HEIGHT); - _statusBarBounds = new Rectangle(0, 0, Width, STATUS_BAR_HEIGHT); - _actionBarBounds = new Rectangle(0, STATUS_BAR_HEIGHT, Width, ACTION_BAR_HEIGHT); - } - - protected override void OnPaint(PaintEventArgs e) - { - var g = e.Graphics; - g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; - - g.Clear(SkinManager.BackdropColor); - g.FillRectangle(SkinManager.ColorScheme.DarkPrimaryBrush, _statusBarBounds); - g.FillRectangle(SkinManager.ColorScheme.PrimaryBrush, _actionBarBounds); - - //Draw border - using (var borderPen = new Pen(SkinManager.DividersColor, 1)) - { - g.DrawLine(borderPen, new Point(0, _actionBarBounds.Bottom), new Point(0, Height - 2)); - g.DrawLine(borderPen, new Point(Width - 1, _actionBarBounds.Bottom), new Point(Width - 1, Height - 2)); - g.DrawLine(borderPen, new Point(0, Height - 1), new Point(Width - 1, Height - 1)); - } - - // Determine whether or not we even should be drawing the buttons. - bool showMin = MinimizeBox && ControlBox; - bool showMax = MaximizeBox && ControlBox; - var hoverBrush = SkinManager.BackgroundHoverBrush; - var downBrush = SkinManager.BackgroundFocusBrush; - - // When MaximizeButton == false, the minimize button will be painted in its place - if (_buttonState == ButtonState.MinOver && showMin) - g.FillRectangle(hoverBrush, showMax ? _minButtonBounds : _maxButtonBounds); - - if (_buttonState == ButtonState.MinDown && showMin) - g.FillRectangle(downBrush, showMax ? _minButtonBounds : _maxButtonBounds); - - if (_buttonState == ButtonState.MaxOver && showMax) - g.FillRectangle(hoverBrush, _maxButtonBounds); - - if (_buttonState == ButtonState.MaxDown && showMax) - g.FillRectangle(downBrush, _maxButtonBounds); - - if (_buttonState == ButtonState.XOver && ControlBox) - g.FillRectangle(hoverBrush, _xButtonBounds); - - if (_buttonState == ButtonState.XDown && ControlBox) - g.FillRectangle(downBrush, _xButtonBounds); - - using (var formButtonsPen = new Pen(SkinManager.ColorScheme.TextColor, 2)) - { - // Minimize button. - if (showMin) - { - int x = showMax ? _minButtonBounds.X : _maxButtonBounds.X; - int y = showMax ? _minButtonBounds.Y : _maxButtonBounds.Y; - - g.DrawLine( - formButtonsPen, - x + (int)(_minButtonBounds.Width * 0.33), - y + (int)(_minButtonBounds.Height * 0.66), - x + (int)(_minButtonBounds.Width * 0.66), - y + (int)(_minButtonBounds.Height * 0.66) - ); - } - - // Maximize button - if (showMax) - { - g.DrawRectangle( - formButtonsPen, - _maxButtonBounds.X + (int)(_maxButtonBounds.Width * 0.33), - _maxButtonBounds.Y + (int)(_maxButtonBounds.Height * 0.36), - (int)(_maxButtonBounds.Width * 0.39), - (int)(_maxButtonBounds.Height * 0.31) - ); - } - - // Close button - if (ControlBox) - { - g.DrawLine( - formButtonsPen, - _xButtonBounds.X + (int)(_xButtonBounds.Width * 0.33), - _xButtonBounds.Y + (int)(_xButtonBounds.Height * 0.33), - _xButtonBounds.X + (int)(_xButtonBounds.Width * 0.66), - _xButtonBounds.Y + (int)(_xButtonBounds.Height * 0.66) - ); - - g.DrawLine( - formButtonsPen, - _xButtonBounds.X + (int)(_xButtonBounds.Width * 0.66), - _xButtonBounds.Y + (int)(_xButtonBounds.Height * 0.33), - _xButtonBounds.X + (int)(_xButtonBounds.Width * 0.33), - _xButtonBounds.Y + (int)(_xButtonBounds.Height * 0.66)); - } - } - - // Drawer Icon - if (DrawerTabControl != null) - { - _drawerIconRect = new Rectangle(SkinManager.FORM_PADDING / 2, STATUS_BAR_HEIGHT, 24 + SkinManager.FORM_PADDING + SkinManager.FORM_PADDING / 2, ACTION_BAR_HEIGHT); - // Ripple - if (_clickAnimManager.IsAnimating()) - { - var clickAnimProgress = _clickAnimManager.GetProgress(); - - var rippleBrush = new SolidBrush(Color.FromArgb((int)(51 - (clickAnimProgress * 50)), Color.White)); - var rippleSize = (int)(clickAnimProgress * _drawerIconRect.Width * 1.75); - - g.SetClip(_drawerIconRect); - g.FillEllipse(rippleBrush, new Rectangle(_animationSource.X - rippleSize / 2, _animationSource.Y - rippleSize / 2, rippleSize, rippleSize)); - g.ResetClip(); - rippleBrush.Dispose(); - } - - using (var formButtonsPen = new Pen(SkinManager.ColorScheme.TextColor, 2)) - { - // Middle line - g.DrawLine( - formButtonsPen, - _drawerIconRect.X + (int)(SkinManager.FORM_PADDING), - _drawerIconRect.Y + (int)(ACTION_BAR_HEIGHT / 2), - _drawerIconRect.X + (int)(SkinManager.FORM_PADDING) + 18, - _drawerIconRect.Y + (int)(ACTION_BAR_HEIGHT / 2)); - - // Bottom line - g.DrawLine( - formButtonsPen, - _drawerIconRect.X + (int)(SkinManager.FORM_PADDING), - _drawerIconRect.Y + (int)(ACTION_BAR_HEIGHT / 2) - 6, - _drawerIconRect.X + (int)(SkinManager.FORM_PADDING) + 18, - _drawerIconRect.Y + (int)(ACTION_BAR_HEIGHT / 2) - 6); - - // Top line - g.DrawLine( - formButtonsPen, - _drawerIconRect.X + (int)(SkinManager.FORM_PADDING), - _drawerIconRect.Y + (int)(ACTION_BAR_HEIGHT / 2) + 6, - _drawerIconRect.X + (int)(SkinManager.FORM_PADDING) + 18, - _drawerIconRect.Y + (int)(ACTION_BAR_HEIGHT / 2) + 6); - } - } - - //Form title - using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) - { - Rectangle textLocation = new Rectangle(SkinManager.FORM_PADDING + (DrawerTabControl != null ? 24 + (int)(SkinManager.FORM_PADDING * 1.5) : 0), STATUS_BAR_HEIGHT, Width, ACTION_BAR_HEIGHT); - NativeText.DrawTransparentText(Text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.H6), - SkinManager.ColorScheme.TextColor, - textLocation.Location, - textLocation.Size, - NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); - } - } - - private readonly AnimationManager _clickAnimManager; - - private Rectangle _drawerIconRect; - - private Point _animationSource; - - private void InitializeComponent() - { - this.SuspendLayout(); - // - // MaterialForm - // - this.ClientSize = new System.Drawing.Size(284, 261); - this.MinimumSize = new System.Drawing.Size(300, 200); - this.Name = "MaterialForm"; - this.Padding = new System.Windows.Forms.Padding(3, 64, 3, 3); - this.Load += new System.EventHandler(this.MaterialForm_Load); - this.ResumeLayout(false); - } - - private void MaterialForm_Load(object sender, EventArgs e) - { - } - } - - public class MouseMessageFilter : IMessageFilter - { - private const int WM_MOUSEMOVE = 0x0200; - - public static event MouseEventHandler MouseMove; - - public bool PreFilterMessage(ref Message m) - { - if (m.Msg == WM_MOUSEMOVE) - { - if (MouseMove != null) - { - int x = Control.MousePosition.X, y = Control.MousePosition.Y; - - MouseMove(null, new MouseEventArgs(MouseButtons.None, 0, x, y, 0)); - } - } - return false; - } - } -} \ No newline at end of file + private MaterialDrawer drawerControl; + private AnimationManager _drawerShowHideAnimManager; + private readonly AnimationManager _clickAnimManager; + + private int STATUS_BAR_HEIGHT = 24; + private int ACTION_BAR_HEIGHT = 40; + #endregion + + public MaterialForm() : this(RightToLeft.No) + { + + } + public MaterialForm(RightToLeft rightToLeft) + { + this.RightToLeft = rightToLeft; + if (rightToLeft == RightToLeft.Yes) + this.RightToLeftLayout = true; + InitializeComponent(); + drawerControl = new MaterialDrawer(RightToLeft); + DrawerWidth = 200; + DrawerIsOpen = false; + DrawerShowIconsWhenHidden = false; + DrawerAutoHide = true; + DrawerAutoShow = false; + DrawerIndicatorWidth = 0; + DrawerHighlightWithAccent = true; + DrawerBackgroundWithAccent = false; + + FormBorderStyle = FormBorderStyle.None; + Sizable = true; + DoubleBuffered = true; + SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); + FormStyle = FormStyles.ActionBar_40; + + Padding = new Padding(PADDING_MINIMUM, STATUS_BAR_HEIGHT + ACTION_BAR_HEIGHT, PADDING_MINIMUM, PADDING_MINIMUM); //Keep space for resize by mouse + + _clickAnimManager = new AnimationManager() + { + AnimationType = AnimationType.EaseOut, + Increment = 0.04 + }; + _clickAnimManager.OnAnimationProgress += sender => Invalidate(); + + // Drawer + Shown += (sender, e) => + { + if (DesignMode || IsDisposed) + return; + AddDrawerOverlayForm(); + }; + } + + #region Private Methods + protected void AddDrawerOverlayForm() + { + if (DrawerTabControl == null) + return; + + // Form opacity fade animation; + _drawerShowHideAnimManager = new AnimationManager + { + AnimationType = AnimationType.EaseInOut, + Increment = 0.04 + }; + + _drawerShowHideAnimManager.OnAnimationProgress += (sender) => + { + drawerOverlay.Opacity = (float)(_drawerShowHideAnimManager.GetProgress() * 0.55f); + }; + + int H = ClientSize.Height - _statusBarBounds.Height - _actionBarBounds.Height; + int Y = PointToScreen(Point.Empty).Y + _statusBarBounds.Height + _actionBarBounds.Height; + + // Overlay Form definitions + drawerOverlay.BackColor = Color.Black; + drawerOverlay.RightToLeft = RightToLeft; + + drawerOverlay.Opacity = 0; + drawerOverlay.MinimizeBox = false; + drawerOverlay.MaximizeBox = false; + drawerOverlay.Text = ""; + drawerOverlay.ShowIcon = false; + drawerOverlay.ControlBox = false; + drawerOverlay.FormBorderStyle = FormBorderStyle.None; + drawerOverlay.Visible = true; + drawerOverlay.Size = new Size(ClientSize.Width, H); + int locationY = Location.Y + _statusBarBounds.Height + _actionBarBounds.Height; + int locationX = RightToLeft == RightToLeft.Yes ? Location.X + (Width - DrawerWidth) : Location.X; + drawerOverlay.Location = new Point(Location.X, locationY); + drawerOverlay.ShowInTaskbar = false; + drawerOverlay.Owner = this; + drawerOverlay.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; + + // Drawer Form definitions + drawerForm.BackColor = Color.LimeGreen; + drawerForm.TransparencyKey = Color.LimeGreen; + drawerForm.MinimizeBox = false; + drawerForm.MaximizeBox = false; + drawerForm.Text = ""; + drawerForm.ShowIcon = false; + drawerForm.ControlBox = false; + drawerForm.FormBorderStyle = FormBorderStyle.None; + drawerForm.Visible = true; + drawerForm.Size = new Size(DrawerWidth, H); + + drawerForm.Location = new Point(locationX, locationY); + drawerForm.ShowInTaskbar = false; + drawerForm.Owner = drawerOverlay; + drawerForm.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; + drawerForm.RightToLeft = RightToLeft; + + // Add drawer to overlay form + drawerForm.Controls.Add(drawerControl); + drawerControl.Location = new Point(0, 0); + drawerControl.Size = new Size(DrawerWidth, H); + drawerControl.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom); + drawerControl.BaseTabControl = DrawerTabControl; + drawerControl.ShowIconsWhenHidden = true; + + // Init Options + drawerControl.IsOpen = DrawerIsOpen; + drawerControl.ShowIconsWhenHidden = DrawerShowIconsWhenHidden; + drawerControl.AutoHide = DrawerAutoHide; + drawerControl.AutoShow = DrawerAutoShow; + drawerControl.IndicatorWidth = DrawerIndicatorWidth; + drawerControl.HighlightWithAccent = DrawerHighlightWithAccent; + drawerControl.BackgroundWithAccent = DrawerBackgroundWithAccent; + + // Changing colors or theme + SkinManager.ThemeChanged += sender => + { + drawerForm.Refresh(); + }; + SkinManager.ColorSchemeChanged += sender => + { + drawerForm.Refresh(); + }; + + // Visible, Resize and move events + VisibleChanged += (sender, e) => + { + drawerForm.Visible = Visible; + drawerOverlay.Visible = Visible; + }; + + Resize += (sender, e) => + { + H = ClientSize.Height - _statusBarBounds.Height - _actionBarBounds.Height; + drawerForm.Size = new Size(DrawerWidth, H); + drawerOverlay.Size = new Size(ClientSize.Width, H); + }; + + Move += (sender, e) => + { + locationY = Location.Y + _statusBarBounds.Height + _actionBarBounds.Height; + locationX = RightToLeft == RightToLeft.Yes ? Location.X + (Width - DrawerWidth) : Location.X; + drawerForm.Location = new Point(locationX, locationY); + drawerOverlay.Location = new Point(Location.X, locationY); + }; + + // Close when click outside menu + drawerOverlay.Click += (sender, e) => + { + drawerControl.Hide(); + }; + + //Resize form when mouse over drawer + drawerControl.MouseDown += (sender, e) => + { + ResizeForm(_resizeDir); + }; + + // Animation and visibility + drawerControl.DrawerBeginOpen += (sender) => + { + _drawerShowHideAnimManager.StartNewAnimation(AnimationDirection.In); + }; + + drawerControl.DrawerBeginClose += (sender) => + { + _drawerShowHideAnimManager.StartNewAnimation(AnimationDirection.Out); + }; + drawerControl.CursorUpdate += (sender, drawerCursor) => + { + if (Sizable && !Maximized) + { + if (drawerCursor == Cursors.SizeNESW) + _resizeDir = ResizeDirection.BottomLeft; + else if (drawerCursor == Cursors.SizeWE) + _resizeDir = ResizeDirection.Left; + else if (drawerCursor == Cursors.SizeNS) + _resizeDir = ResizeDirection.Bottom; + else + _resizeDir = ResizeDirection.None; + } + else + _resizeDir = ResizeDirection.None; + Cursor = drawerCursor; + }; + + // Form Padding corrections + + if (Padding.Top < (_statusBarBounds.Height + _actionBarBounds.Height)) + Padding = new Padding(Padding.Left, (_statusBarBounds.Height + _actionBarBounds.Height), Padding.Right, Padding.Bottom); + + originalPadding = Padding; + + drawerControl.DrawerShowIconsWhenHiddenChanged += FixFormPadding; + FixFormPadding(this); + + // Fix Closing the Drawer or Overlay form with Alt+F4 not exiting the app + drawerOverlay.FormClosed += TerminateOnClose; + drawerForm.FormClosed += TerminateOnClose; + drawerForm.Attach(drawerControl); + } + + private void TerminateOnClose(object sender, FormClosedEventArgs e) + { + Application.Exit(); + } + + private void FixFormPadding(object sender) + { + if (drawerControl.ShowIconsWhenHidden) + Padding = new Padding(Padding.Left < drawerControl.MinWidth ? drawerControl.MinWidth : Padding.Left, originalPadding.Top, originalPadding.Right, originalPadding.Bottom); + else + Padding = new Padding(PADDING_MINIMUM, originalPadding.Top, originalPadding.Right, originalPadding.Bottom); + } + + private void UpdateButtons(MouseButtons button, Point location, bool up = false) + { + if (DesignMode) return; + + var oldState = _buttonState; + bool showMin = MinimizeBox && ControlBox; + bool showMax = MaximizeBox && ControlBox; + + if (button == MouseButtons.Left && !up) + { + if (showMin && !showMax && _maxButtonBounds.Contains(location)) + _buttonState = ButtonState.MinDown; + else if (showMin && showMax && _minButtonBounds.Contains(location)) + _buttonState = ButtonState.MinDown; + else if (showMax && _maxButtonBounds.Contains(location)) + _buttonState = ButtonState.MaxDown; + else if (ControlBox && _xButtonBounds.Contains(location)) + _buttonState = ButtonState.XDown; + else if (_drawerButtonBounds.Contains(location)) + _buttonState = ButtonState.DrawerDown; + else + _buttonState = ButtonState.None; + } + else + { + if (showMin && !showMax && _maxButtonBounds.Contains(location)) + { + _buttonState = ButtonState.MinOver; + + if (oldState == ButtonState.MinDown && up) + WindowState = FormWindowState.Minimized; + } + else if (showMin && showMax && _minButtonBounds.Contains(location)) + { + _buttonState = ButtonState.MinOver; + + if (oldState == ButtonState.MinDown && up) + WindowState = FormWindowState.Minimized; + } + else if (showMax && _maxButtonBounds.Contains(location)) + { + _buttonState = ButtonState.MaxOver; + + if (oldState == ButtonState.MaxDown && up) + Maximized = !Maximized; + } + else if (ControlBox && _xButtonBounds.Contains(location)) + { + _buttonState = ButtonState.XOver; + + if (oldState == ButtonState.XDown && up) + Close(); + } + else if (_drawerButtonBounds.Contains(location)) + { + _buttonState = ButtonState.DrawerOver; + } + else + { + _buttonState = ButtonState.None; + } + } + + if (oldState != _buttonState) + Invalidate(); + } + + private void ResizeForm(ResizeDirection direction) + { + if (DesignMode) + return; + var dir = -1; + switch (direction) + { + case ResizeDirection.BottomLeft: + dir = (int)HT.BottomLeft; + Cursor = Cursors.SizeNESW; + break; + + case ResizeDirection.Left: + dir = (int)HT.Left; + Cursor = Cursors.SizeWE; + break; + + case ResizeDirection.Right: + dir = (int)HT.Right; + break; + + case ResizeDirection.BottomRight: + dir = (int)HT.BottomRight; + break; + + case ResizeDirection.Bottom: + dir = (int)HT.Bottom; + break; + + case ResizeDirection.Top: + dir = (int)HT.Top; + break; + + case ResizeDirection.TopLeft: + dir = (int)HT.TopLeft; + break; + + case ResizeDirection.TopRight: + dir = (int)HT.TopRight; + break; + } + + ReleaseCapture(); + if (dir != -1) + { + SendMessage(Handle, (int)WM.NonClientLeftButtonDown, dir, 0); + } + } + + private void RecalculateFormBoundaries() + { + switch (_formStyle) + { + case FormStyles.StatusAndActionBar_None: + ACTION_BAR_HEIGHT = 0; + STATUS_BAR_HEIGHT = 0; + break; + case FormStyles.ActionBar_None: + ACTION_BAR_HEIGHT = 0; + STATUS_BAR_HEIGHT = STATUS_BAR_HEIGHT_DEFAULT; + break; + case FormStyles.ActionBar_40: + ACTION_BAR_HEIGHT = ACTION_BAR_HEIGHT_DEFAULT; + STATUS_BAR_HEIGHT = STATUS_BAR_HEIGHT_DEFAULT; + break; + case FormStyles.ActionBar_48: + ACTION_BAR_HEIGHT = 48; + STATUS_BAR_HEIGHT = STATUS_BAR_HEIGHT_DEFAULT; + break; + case FormStyles.ActionBar_56: + ACTION_BAR_HEIGHT = 56; + STATUS_BAR_HEIGHT = STATUS_BAR_HEIGHT_DEFAULT; + break; + case FormStyles.ActionBar_64: + ACTION_BAR_HEIGHT = 64; + STATUS_BAR_HEIGHT = STATUS_BAR_HEIGHT_DEFAULT; + break; + default: + ACTION_BAR_HEIGHT = ACTION_BAR_HEIGHT_DEFAULT; + STATUS_BAR_HEIGHT = STATUS_BAR_HEIGHT_DEFAULT; + break; + } + + Padding = new Padding(_drawerShowIconsWhenHidden ? drawerControl.MinWidth : PADDING_MINIMUM, STATUS_BAR_HEIGHT + ACTION_BAR_HEIGHT, Padding.Right, Padding.Bottom); + originalPadding = Padding; + + if (DrawerTabControl != null) + { + int locationY = Location.Y + STATUS_BAR_HEIGHT + ACTION_BAR_HEIGHT; + int locationX = RightToLeft == RightToLeft.Yes ? Location.X + (Width - DrawerWidth) : Location.X; + var height = ClientSize.Height - (STATUS_BAR_HEIGHT + ACTION_BAR_HEIGHT); + drawerOverlay.Size = new Size(ClientSize.Width, height); + drawerOverlay.Location = new Point(Location.X, locationY); + drawerForm.Size = new Size(DrawerWidth, height); + drawerForm.Location = new Point(locationX, locationY); + } + + Invalidate(); + } + #endregion + + #region WinForms Methods + protected override CreateParams CreateParams + { + get + { + var par = base.CreateParams; + par.Style |= (int)WS.MinimizeBox | (int)WS.SysMenu; + return par; + } + } + + protected override void OnCreateControl() + { + base.OnCreateControl(); + + // Sets the Window Style for having a Size Frame after the form is created + // This prevents unexpected sizing while still allowing for Aero Snapping + var flags = GetWindowLongPtr(Handle, -16).ToInt64(); + SetWindowLongPtr(Handle, -16, (IntPtr)(flags | (int)WS.SizeFrame)); + } + + protected override void WndProc(ref Message m) + { + var message = (WM)m.Msg; + // Prevent the base class from receiving the message + if (message == WM.NonClientCalcSize) return; + + // https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-ncactivate?redirectedfrom=MSDN#parameters + // "If this parameter is set to -1, DefWindowProc does not repaint the nonclient area to reflect the state change." + if (message == WM.NonClientActivate) + { + m.Result = new IntPtr(-1); + return; + } + + base.WndProc(ref m); + if (DesignMode || IsDisposed) + return; + + var cursorPos = PointToClient(Cursor.Position); + var isOverCaption = (_statusBarBounds.Contains(cursorPos) || _actionBarBounds.Contains(cursorPos)) && + !(_minButtonBounds.Contains(cursorPos) || _maxButtonBounds.Contains(cursorPos) || _xButtonBounds.Contains(cursorPos)); + + // Drawer + if (DrawerTabControl != null && (message == WM.LeftButtonDown || message == WM.LeftButtonDoubleClick) && _drawerIconRect.Contains(cursorPos)) + { + drawerControl.Toggle(); + _clickAnimManager.SetProgress(0); + _clickAnimManager.StartNewAnimation(AnimationDirection.In); + _animationSource = cursorPos; + } + // Double click to maximize + else if (message == WM.LeftButtonDoubleClick && isOverCaption) + { + Maximized = !Maximized; + } + // Treat the Caption as if it was Non-Client + else if (message == WM.LeftButtonDown && isOverCaption) + { + ReleaseCapture(); + SendMessage(Handle, (int)WM.NonClientLeftButtonDown, (int)HT.Caption, 0); + } + // Default context menu + else if (message == WM.RightButtonDown) + { + if (_statusBarBounds.Contains(cursorPos) && !_minButtonBounds.Contains(cursorPos) && + !_maxButtonBounds.Contains(cursorPos) && !_xButtonBounds.Contains(cursorPos)) + { + // Temporary disable user defined ContextMenuStrip + var user_cms = base.ContextMenuStrip; + base.ContextMenuStrip = null; + + // Show default system menu when right clicking titlebar + var id = TrackPopupMenuEx(GetSystemMenu(Handle, false), (int)TPM.LeftAlign | (int)TPM.ReturnCommand, Cursor.Position.X, Cursor.Position.Y, Handle, IntPtr.Zero); + + // Pass the command as a WM_SYSCOMMAND message + SendMessage(Handle, (int)WM.SystemCommand, id, 0); + + // restore user defined ContextMenuStrip + base.ContextMenuStrip = user_cms; + } + } + } + + protected override void OnMove(EventArgs e) + { + // Empty Point ensures the screen maximizes to the top left of the current screen + MaximizedBounds = new Rectangle(Point.Empty, Screen.GetWorkingArea(Location).Size); + base.OnMove(e); + } + + protected override void OnMouseDown(MouseEventArgs e) + { + if (DesignMode) + return; + UpdateButtons(e.Button, e.Location); + + if (e.Button == MouseButtons.Left && !Maximized && _resizeCursors.Contains(Cursor)) + ResizeForm(_resizeDir); + base.OnMouseDown(e); + } + + protected override void OnMouseEnter(EventArgs e) + { + base.OnMouseEnter(e); + Cursor = Cursors.Default; + } + + protected override void OnMouseLeave(EventArgs e) + { + base.OnMouseLeave(e); + if (DesignMode) + return; + _buttonState = ButtonState.None; + _resizeDir = ResizeDirection.None; + //Only reset the cursor when needed + if (_resizeCursors.Contains(Cursor)) + { + Cursor = Cursors.Default; + } + + Invalidate(); + } + + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + + if (DesignMode) return; + + var coords = e.Location; + + UpdateButtons(e.Button, coords); + + if (!Sizable) return; + + //True if the mouse is hovering over a child control + var isChildUnderMouse = GetChildAtPoint(coords) != null; + + if (!isChildUnderMouse && !Maximized && coords.Y < BORDER_WIDTH && coords.X > BORDER_WIDTH && coords.X < ClientSize.Width - BORDER_WIDTH) + { + _resizeDir = ResizeDirection.Top; + Cursor = Cursors.SizeNS; + } + else if (!isChildUnderMouse && !Maximized && coords.X <= BORDER_WIDTH && coords.Y < BORDER_WIDTH) + { + _resizeDir = ResizeDirection.TopLeft; + Cursor = Cursors.SizeNWSE; + } + else if (!isChildUnderMouse && !Maximized && coords.X >= ClientSize.Width - BORDER_WIDTH && coords.Y < BORDER_WIDTH) + { + _resizeDir = ResizeDirection.TopRight; + Cursor = Cursors.SizeNESW; + } + else if (!isChildUnderMouse && !Maximized && coords.X <= BORDER_WIDTH && coords.Y >= ClientSize.Height - BORDER_WIDTH) + { + _resizeDir = ResizeDirection.BottomLeft; + Cursor = Cursors.SizeNESW; + } + else if ((!isChildUnderMouse || DrawerTabControl != null) && !Maximized && coords.X <= BORDER_WIDTH) + { + _resizeDir = ResizeDirection.Left; + Cursor = Cursors.SizeWE; + } + else if (!isChildUnderMouse && !Maximized && coords.X >= ClientSize.Width - BORDER_WIDTH && coords.Y >= ClientSize.Height - BORDER_WIDTH) + { + _resizeDir = ResizeDirection.BottomRight; + Cursor = Cursors.SizeNWSE; + } + else if (!isChildUnderMouse && !Maximized && coords.X >= ClientSize.Width - BORDER_WIDTH) + { + _resizeDir = ResizeDirection.Right; + Cursor = Cursors.SizeWE; + } + else if (!isChildUnderMouse && !Maximized && coords.Y >= ClientSize.Height - BORDER_WIDTH) + { + _resizeDir = ResizeDirection.Bottom; + Cursor = Cursors.SizeNS; + } + else + { + _resizeDir = ResizeDirection.None; + + //Only reset the cursor when needed, this prevents it from flickering when a child control changes the cursor to its own needs + if (_resizeCursors.Contains(Cursor)) + Cursor = Cursors.Default; + } + } + + protected override void OnMouseUp(MouseEventArgs e) + { + if (DesignMode) + return; + UpdateButtons(e.Button, e.Location, true); + + base.OnMouseUp(e); + ReleaseCapture(); + } + + protected override void OnPaint(PaintEventArgs e) + { + var hoverBrush = SkinManager.BackgroundHoverBrush; + var downBrush = SkinManager.BackgroundFocusBrush; + var g = e.Graphics; + g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; + + g.Clear(SkinManager.BackdropColor); + + //Draw border + using (var borderPen = new Pen(SkinManager.DividersColor, 1)) + { + g.DrawLine(borderPen, new Point(0, _actionBarBounds.Bottom), new Point(0, ClientSize.Height - 2)); + g.DrawLine(borderPen, new Point(ClientSize.Width - 1, _actionBarBounds.Bottom), new Point(ClientSize.Width - 1, ClientSize.Height - 2)); + g.DrawLine(borderPen, new Point(0, ClientSize.Height - 1), new Point(ClientSize.Width - 1, ClientSize.Height - 1)); + } + + if (_formStyle != FormStyles.StatusAndActionBar_None) + { + if (ControlBox) + { + g.FillRectangle(SkinManager.ColorScheme.DarkPrimaryBrush, _statusBarBounds); + g.FillRectangle(SkinManager.ColorScheme.PrimaryBrush, _actionBarBounds); + } + + // Determine whether or not we even should be drawing the buttons. + bool showMin = MinimizeBox && ControlBox; + bool showMax = MaximizeBox && ControlBox; + + // When MaximizeButton == false, the minimize button will be painted in its place + if (_buttonState == ButtonState.MinOver && showMin) + g.FillRectangle(hoverBrush, showMax ? _minButtonBounds : _maxButtonBounds); + + if (_buttonState == ButtonState.MinDown && showMin) + g.FillRectangle(downBrush, showMax ? _minButtonBounds : _maxButtonBounds); + + if (_buttonState == ButtonState.MaxOver && showMax) + g.FillRectangle(hoverBrush, _maxButtonBounds); + + if (_buttonState == ButtonState.MaxDown && showMax) + g.FillRectangle(downBrush, _maxButtonBounds); + + if (_buttonState == ButtonState.XOver && ControlBox) + g.FillRectangle(SkinManager.BackgroundHoverRedBrush, _xButtonBounds); + + if (_buttonState == ButtonState.XDown && ControlBox) + g.FillRectangle(SkinManager.BackgroundDownRedBrush, _xButtonBounds); + + using (var formButtonsPen = new Pen(SkinManager.ColorScheme.TextColor, 2)) + { + // Minimize button. + if (showMin) + { + int x = showMax ? _minButtonBounds.X : _maxButtonBounds.X; + int y = showMax ? _minButtonBounds.Y : _maxButtonBounds.Y; + + g.DrawLine( + formButtonsPen, + x + (int)(_minButtonBounds.Width * 0.33), + y + (int)(_minButtonBounds.Height * 0.66), + x + (int)(_minButtonBounds.Width * 0.66), + y + (int)(_minButtonBounds.Height * 0.66) + ); + } + + // Maximize button + if (showMax) + { + if (WindowState != FormWindowState.Maximized) + { + g.DrawRectangle( + formButtonsPen, + _maxButtonBounds.X + (int)(_maxButtonBounds.Width * 0.33), + _maxButtonBounds.Y + (int)(_maxButtonBounds.Height * 0.36), + (int)(_maxButtonBounds.Width * 0.39), + (int)(_maxButtonBounds.Height * 0.31) + ); + } + else + { + // Change position of square + g.DrawRectangle( + formButtonsPen, + _maxButtonBounds.X + (int)(_maxButtonBounds.Width * 0.30), + _maxButtonBounds.Y + (int)(_maxButtonBounds.Height * 0.42), + (int)(_maxButtonBounds.Width * 0.40), + (int)(_maxButtonBounds.Height * 0.32) + ); + // Draw lines for background square + g.DrawLine(formButtonsPen, + _maxButtonBounds.X + (int)(_maxButtonBounds.Width * 0.42), + _maxButtonBounds.Y + (int)(_maxButtonBounds.Height * 0.30), + _maxButtonBounds.X + (int)(_maxButtonBounds.Width * 0.42), + _maxButtonBounds.Y + (int)(_maxButtonBounds.Height * 0.38) + ); + g.DrawLine(formButtonsPen, + _maxButtonBounds.X + (int)(_maxButtonBounds.Width * 0.40), + _maxButtonBounds.Y + (int)(_maxButtonBounds.Height * 0.30), + _maxButtonBounds.X + (int)(_maxButtonBounds.Width * 0.86), + _maxButtonBounds.Y + (int)(_maxButtonBounds.Width * 0.30) + ); + g.DrawLine(formButtonsPen, + _maxButtonBounds.X + (int)(_maxButtonBounds.Width * 0.82), + _maxButtonBounds.Y + (int)(_maxButtonBounds.Height * 0.28), + _maxButtonBounds.X + (int)(_maxButtonBounds.Width * 0.82), + _maxButtonBounds.Y + (int)(_maxButtonBounds.Width * 0.64) + ); + g.DrawLine(formButtonsPen, + _maxButtonBounds.X + (int)(_maxButtonBounds.Width * 0.70), + _maxButtonBounds.Y + (int)(_maxButtonBounds.Height * 0.62), + _maxButtonBounds.X + (int)(_maxButtonBounds.Width * 0.84), + _maxButtonBounds.Y + (int)(_maxButtonBounds.Width * 0.62) + ); + } + } + + // Close button + if (ControlBox) + { + g.DrawLine( + formButtonsPen, + _xButtonBounds.X + (int)(_xButtonBounds.Width * 0.33), + _xButtonBounds.Y + (int)(_xButtonBounds.Height * 0.33), + _xButtonBounds.X + (int)(_xButtonBounds.Width * 0.66), + _xButtonBounds.Y + (int)(_xButtonBounds.Height * 0.66) + ); + + g.DrawLine( + formButtonsPen, + _xButtonBounds.X + (int)(_xButtonBounds.Width * 0.66), + _xButtonBounds.Y + (int)(_xButtonBounds.Height * 0.33), + _xButtonBounds.X + (int)(_xButtonBounds.Width * 0.33), + _xButtonBounds.Y + (int)(_xButtonBounds.Height * 0.66)); + } + } + } + + // Drawer Icon + if (DrawerTabControl != null && _formStyle != FormStyles.ActionBar_None && _formStyle != FormStyles.StatusAndActionBar_None) + { + if (_buttonState == ButtonState.DrawerOver) + g.FillRectangle(hoverBrush, _drawerButtonBounds); + + if (_buttonState == ButtonState.DrawerDown) + g.FillRectangle(downBrush, _drawerButtonBounds); + + _drawerIconRect = new Rectangle(SkinManager.FORM_PADDING / 2, STATUS_BAR_HEIGHT, ACTION_BAR_HEIGHT_DEFAULT, ACTION_BAR_HEIGHT); + // Ripple + if (_clickAnimManager.IsAnimating()) + { + var clickAnimProgress = _clickAnimManager.GetProgress(); + + var rippleBrush = new SolidBrush(Color.FromArgb((int)(51 - (clickAnimProgress * 50)), Color.White)); + var rippleSize = (int)(clickAnimProgress * _drawerIconRect.Width * 1.75); + + g.SetClip(_drawerIconRect); + g.FillEllipse(rippleBrush, new Rectangle(_animationSource.X - rippleSize / 2, _animationSource.Y - rippleSize / 2, rippleSize, rippleSize)); + g.ResetClip(); + rippleBrush.Dispose(); + } + + using (var formButtonsPen = new Pen(SkinManager.ColorScheme.TextColor, 2)) + { + // Middle line + g.DrawLine( + formButtonsPen, + _drawerIconRect.X + (int)(SkinManager.FORM_PADDING), + _drawerIconRect.Y + (int)(ACTION_BAR_HEIGHT / 2), + _drawerIconRect.X + (int)(SkinManager.FORM_PADDING) + 18, + _drawerIconRect.Y + (int)(ACTION_BAR_HEIGHT / 2)); + + // Bottom line + g.DrawLine( + formButtonsPen, + _drawerIconRect.X + (int)(SkinManager.FORM_PADDING), + _drawerIconRect.Y + (int)(ACTION_BAR_HEIGHT / 2) - 6, + _drawerIconRect.X + (int)(SkinManager.FORM_PADDING) + 18, + _drawerIconRect.Y + (int)(ACTION_BAR_HEIGHT / 2) - 6); + + // Top line + g.DrawLine( + formButtonsPen, + _drawerIconRect.X + (int)(SkinManager.FORM_PADDING), + _drawerIconRect.Y + (int)(ACTION_BAR_HEIGHT / 2) + 6, + _drawerIconRect.X + (int)(SkinManager.FORM_PADDING) + 18, + _drawerIconRect.Y + (int)(ACTION_BAR_HEIGHT / 2) + 6); + } + } + + if (ControlBox == true && _formStyle != FormStyles.ActionBar_None && _formStyle != FormStyles.StatusAndActionBar_None) + { + //Form title + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + Rectangle textLocation = new Rectangle(DrawerTabControl != null ? TITLE_LEFT_PADDING : TITLE_LEFT_PADDING - (ICON_SIZE + (ACTION_BAR_PADDING * 2)), STATUS_BAR_HEIGHT, ClientSize.Width, ACTION_BAR_HEIGHT); + NativeText.DrawTransparentText(Text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.H6, RightToLeft), + SkinManager.ColorScheme.TextColor, + textLocation.Location, + textLocation.Size, + NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); + } + } + } + #endregion + + #region Low Level Windows Methods + /// + /// Provides a single method to call either the 32-bit or 64-bit method based on the size of an for getting the + /// Window Style flags.
+ /// GetWindowLongPtr + ///
+ private static IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex) + { + if (IntPtr.Size == 8) + return GetWindowLongPtr64(hWnd, nIndex); + else + return GetWindowLong(hWnd, nIndex); + } + + /// + /// Provides a single method to call either the 32-bit or 64-bit method based on the size of an for setting the + /// Window Style flags.
+ /// SetWindowLongPtr + ///
+ private static IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong) + { + if (IntPtr.Size == 8) + return SetWindowLongPtr64(hWnd, nIndex, dwNewLong); + else + return SetWindowLong(hWnd, nIndex, dwNewLong.ToInt32()); + } + + [DllImport("user32.dll", EntryPoint = "GetWindowLong")] + private static extern IntPtr GetWindowLong(IntPtr hWnd, int nIndex); + + [DllImport("user32.dll", EntryPoint = "GetWindowLongPtr")] + private static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex); + + [DllImport("user32.dll", EntryPoint = "SetWindowLong")] + private static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); + + [DllImport("user32.dll", EntryPoint = "SetWindowLongPtr")] + private static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, int nIndex, IntPtr dwNewLong); + + [DllImport("user32.dll")] + private static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); + + [DllImport("user32.dll")] + private static extern bool ReleaseCapture(); + + [DllImport("user32.dll")] + private static extern int TrackPopupMenuEx(IntPtr hmenu, uint fuFlags, int x, int y, IntPtr hwnd, IntPtr lptpm); + + [DllImport("user32.dll")] + private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert); + #endregion + + private void InitializeComponent() + { + this.SuspendLayout(); + // + // MaterialForm + // + this.ClientSize = new System.Drawing.Size(284, 261); + this.Name = "MaterialForm"; + this.Load += new System.EventHandler(this.MaterialForm_Load); + this.ResumeLayout(false); + + } + + private void MaterialForm_Load(object sender, EventArgs e) + { + + } + } + + public class MaterialDrawerForm : Form + { + public MouseWheelRedirector MouseWheelRedirector; + + public MaterialDrawerForm() + { + MouseWheelRedirector = new MouseWheelRedirector(); + SetStyle(ControlStyles.Selectable | ControlStyles.OptimizedDoubleBuffer | ControlStyles.EnableNotifyMessage, true); + } + + public void Attach(Control control) + { + MouseWheelRedirector.Attach(control); + } + + public void Detach(Control control) + { + MouseWheelRedirector.Detach(control); + } + } +} diff --git a/MaterialSkin/Controls/MaterialLabel.cs b/MaterialSkin/Controls/MaterialLabel.cs index a816e50a..fd05396c 100644 --- a/MaterialSkin/Controls/MaterialLabel.cs +++ b/MaterialSkin/Controls/MaterialLabel.cs @@ -1,161 +1,162 @@ -namespace MaterialSkin.Controls -{ - using System.ComponentModel; - using System.Drawing; - using System.Windows.Forms; - - public class MaterialLabel : Label, IMaterialControl - { - [Browsable(false)] - public int Depth { get; set; } - - [Browsable(false)] - public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; - - [Browsable(false)] - public MouseState MouseState { get; set; } - +namespace MaterialSkin.Controls +{ + using System.ComponentModel; + using System.Drawing; + using System.Windows.Forms; + + public class MaterialLabel : Label, IMaterialControl + { + [Browsable(false)] + public int Depth { get; set; } + + [Browsable(false)] + public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; + + [Browsable(false)] + public MouseState MouseState { get; set; } + private ContentAlignment _TextAlign = ContentAlignment.TopLeft; - - [DefaultValue(typeof(ContentAlignment), "TopLeft")] + + [DefaultValue(typeof(ContentAlignment), "TopLeft")] public override ContentAlignment TextAlign - { - get - { - return _TextAlign; - } - set - { - _TextAlign = value; - updateAligment(); - Invalidate(); - } - } - - [Category("Material Skin"), - DefaultValue(false)] - public bool HighEmphasis { get; set; } - + { + get + { + return _TextAlign; + } + set + { + _TextAlign = value; + updateAligment(); + Invalidate(); + } + } + [Category("Material Skin"), - DefaultValue(false)] - public bool UseAccent { get; set; } - + DefaultValue(false)] + public bool HighEmphasis { get; set; } + + [Category("Material Skin"), + DefaultValue(false)] + public bool UseAccent { get; set; } + private MaterialSkinManager.fontType _fontType = MaterialSkinManager.fontType.Body1; - - [Category("Material Skin"), - DefaultValue(typeof(MaterialSkinManager.fontType), "Body1")] - public MaterialSkinManager.fontType FontType - { - get - { - return _fontType; - } - set - { - _fontType = value; - Font = SkinManager.getFontByType(_fontType); - Refresh(); - } - } - - public MaterialLabel() - { - FontType = MaterialSkinManager.fontType.Body1; - TextAlign = ContentAlignment.TopLeft; - } - - public override Size GetPreferredSize(Size proposedSize) - { - if (AutoSize) - { - Size strSize; - using (NativeTextRenderer NativeText = new NativeTextRenderer(CreateGraphics())) - { - strSize = NativeText.MeasureLogString(Text, SkinManager.getLogFontByType(_fontType)); - strSize.Width += 1; // necessary to avoid a bug when autosize = true - } - return strSize; - } - else - { - return proposedSize; - } - } - + + [Category("Material Skin"), + DefaultValue(typeof(MaterialSkinManager.fontType), "Body1")] + public MaterialSkinManager.fontType FontType + { + get + { + return _fontType; + } + set + { + _fontType = value; + Font = SkinManager.getFontByType(_fontType, RightToLeft); + Refresh(); + } + } + + public MaterialLabel() + { + FontType = MaterialSkinManager.fontType.Body1; + TextAlign = ContentAlignment.TopLeft; + } + + public override Size GetPreferredSize(Size proposedSize) + { + if (AutoSize) + { + Size strSize; + using (NativeTextRenderer NativeText = new NativeTextRenderer(CreateGraphics())) + { + strSize = NativeText.MeasureLogString(Text, SkinManager.getLogFontByType(_fontType, RightToLeft)); + strSize.Width += 1; // necessary to avoid a bug when autosize = true + } + return strSize; + } + else + { + return proposedSize; + } + } + private NativeTextRenderer.TextAlignFlags Alignment; - - private void updateAligment() - { - switch (_TextAlign) - { - case ContentAlignment.TopLeft: - Alignment = NativeTextRenderer.TextAlignFlags.Top | NativeTextRenderer.TextAlignFlags.Left; - break; - - case ContentAlignment.TopCenter: - Alignment = NativeTextRenderer.TextAlignFlags.Top | NativeTextRenderer.TextAlignFlags.Center; - break; - - case ContentAlignment.TopRight: - Alignment = NativeTextRenderer.TextAlignFlags.Top | NativeTextRenderer.TextAlignFlags.Right; - break; - - case ContentAlignment.MiddleLeft: - Alignment = NativeTextRenderer.TextAlignFlags.Middle | NativeTextRenderer.TextAlignFlags.Left; - break; - - case ContentAlignment.MiddleCenter: - Alignment = NativeTextRenderer.TextAlignFlags.Middle | NativeTextRenderer.TextAlignFlags.Center; - break; - - case ContentAlignment.MiddleRight: - Alignment = NativeTextRenderer.TextAlignFlags.Middle | NativeTextRenderer.TextAlignFlags.Right; - break; - - case ContentAlignment.BottomLeft: - Alignment = NativeTextRenderer.TextAlignFlags.Bottom | NativeTextRenderer.TextAlignFlags.Left; - break; - - case ContentAlignment.BottomCenter: - Alignment = NativeTextRenderer.TextAlignFlags.Bottom | NativeTextRenderer.TextAlignFlags.Center; - break; - - case ContentAlignment.BottomRight: - Alignment = NativeTextRenderer.TextAlignFlags.Bottom | NativeTextRenderer.TextAlignFlags.Right; - break; - - default: - Alignment = NativeTextRenderer.TextAlignFlags.Top | NativeTextRenderer.TextAlignFlags.Left; - break; - } - } - - protected override void OnPaint(PaintEventArgs e) - { - Graphics g = e.Graphics; - g.Clear(Parent.BackColor); - - // Draw Text - using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) - { - NativeText.DrawMultilineTransparentText( - Text, - SkinManager.getLogFontByType(_fontType), - Enabled ? HighEmphasis ? UseAccent ? - SkinManager.ColorScheme.AccentColor : // High emphasis, accent - SkinManager.ColorScheme.PrimaryColor : // High emphasis, primary - SkinManager.TextHighEmphasisColor : // Normal - SkinManager.TextDisabledOrHintColor, // Disabled - ClientRectangle.Location, - ClientRectangle.Size, - Alignment); - } - } - - protected override void InitLayout() - { - Font = SkinManager.getFontByType(_fontType); - BackColorChanged += (sender, args) => Refresh(); - } - } -} \ No newline at end of file + + private void updateAligment() + { + switch (_TextAlign) + { + case ContentAlignment.TopLeft: + Alignment = NativeTextRenderer.TextAlignFlags.Top | NativeTextRenderer.TextAlignFlags.Left; + break; + + case ContentAlignment.TopCenter: + Alignment = NativeTextRenderer.TextAlignFlags.Top | NativeTextRenderer.TextAlignFlags.Center; + break; + + case ContentAlignment.TopRight: + Alignment = NativeTextRenderer.TextAlignFlags.Top | NativeTextRenderer.TextAlignFlags.Right; + break; + + case ContentAlignment.MiddleLeft: + Alignment = NativeTextRenderer.TextAlignFlags.Middle | NativeTextRenderer.TextAlignFlags.Left; + break; + + case ContentAlignment.MiddleCenter: + Alignment = NativeTextRenderer.TextAlignFlags.Middle | NativeTextRenderer.TextAlignFlags.Center; + break; + + case ContentAlignment.MiddleRight: + Alignment = NativeTextRenderer.TextAlignFlags.Middle | NativeTextRenderer.TextAlignFlags.Right; + break; + + case ContentAlignment.BottomLeft: + Alignment = NativeTextRenderer.TextAlignFlags.Bottom | NativeTextRenderer.TextAlignFlags.Left; + break; + + case ContentAlignment.BottomCenter: + Alignment = NativeTextRenderer.TextAlignFlags.Bottom | NativeTextRenderer.TextAlignFlags.Center; + break; + + case ContentAlignment.BottomRight: + Alignment = NativeTextRenderer.TextAlignFlags.Bottom | NativeTextRenderer.TextAlignFlags.Right; + break; + + default: + Alignment = NativeTextRenderer.TextAlignFlags.Top | NativeTextRenderer.TextAlignFlags.Left; + break; + } + } + + protected override void OnPaint(PaintEventArgs e) + { + Graphics g = e.Graphics; + g.Clear(Parent.BackColor); + + // Draw Text + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + NativeText.DrawMultilineTransparentText( + Text, + SkinManager.getLogFontByType(_fontType, RightToLeft), + Enabled ? HighEmphasis ? UseAccent ? + SkinManager.ColorScheme.AccentColor : // High emphasis, accent + (SkinManager.Theme == MaterialSkin.MaterialSkinManager.Themes.LIGHT) ? + SkinManager.ColorScheme.PrimaryColor : // High emphasis, primary Light theme + SkinManager.ColorScheme.PrimaryColor.Lighten(0.25f) : // High emphasis, primary Dark theme + SkinManager.TextHighEmphasisColor : // Normal + SkinManager.TextDisabledOrHintColor, // Disabled + ClientRectangle.Location, + ClientRectangle.Size, + Alignment); + } + } + + protected override void InitLayout() + { + Font = SkinManager.getFontByType(_fontType, RightToLeft); + } + } +} diff --git a/MaterialSkin/Controls/MaterialListBox.cs b/MaterialSkin/Controls/MaterialListBox.cs new file mode 100644 index 00000000..cb7f8c85 --- /dev/null +++ b/MaterialSkin/Controls/MaterialListBox.cs @@ -0,0 +1,857 @@ +#region Imports + +using System; +using System.Drawing; +using System.Drawing.Design; +using System.Drawing.Text; +using System.Windows.Forms; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.InteropServices; + +#endregion + +namespace MaterialSkin.Controls +{ + + #region MaterialListBox + + [DefaultProperty("Items")] + [DefaultEvent("SelectedIndexChanged")] + [ComVisible(true)] + public class MaterialListBox : Control, IMaterialControl + { + #region Internal Vars + + private ObservableCollection _items = new ObservableCollection(); + private List _selectedItems; + private List _indicates; + private bool _multiSelect; + private int _selectedIndex; + private MaterialListBoxItem _selectedItem; + private string _selectedText; + private bool _showScrollBar; + private bool _multiKeyDown; + private int _hoveredItem; + private MaterialScrollBar _scrollBar; + private object _selectedValue; + + private bool _updating = false; + private int _itemHeight; + private bool _showBorder; + private Color _borderColor; + private Font _primaryFont; + private Font _secondaryFont; + + private const int _leftrightPadding = 16; + private int _primaryTextBottomPadding = 0; + private int _secondaryTextTopPadding = 0; + private int _secondaryTextBottomPadding = 0; + + public enum ListBoxStyle + { + SingleLine, + TwoLine, + ThreeLine + } + private ListBoxStyle _style = ListBoxStyle.SingleLine; + + public enum MaterialItemDensity + { + Default, + Dense + } + + private MaterialItemDensity _density; + + #endregion Internal Vars + + + #region Properties + + //Properties for managing the material design properties + [Browsable(false)] + public int Depth { get; set; } + + [Browsable(false)] + public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; + + [Browsable(false)] + public MouseState MouseState { get; set; } + + private bool useAccentColor; + + [Category("Material Skin"), DefaultValue(false), DisplayName("Use Accent Color")] + public bool UseAccentColor + { + get { return useAccentColor; } + set { useAccentColor = value; _scrollBar.UseAccentColor = value; Invalidate(); } + } + + [TypeConverter(typeof(CollectionConverter))] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + [Editor(typeof(MaterialItemCollectionEditor), typeof(UITypeEditor))] + [Category("Material Skin"), Description("Gets the items of the ListBox.")] + public ObservableCollection Items => _items; + + [Browsable(false)] + [Category("Material Skin"), Description("Gets a collection containing the currently selected items in the ListBox.")] + public List SelectedItems => _selectedItems; + + [Browsable(false), Category("Material Skin"), Description("Gets or sets the currently selected item in the ListBox.")] + public MaterialListBoxItem SelectedItem + { + get => _selectedItem; + set + { + _selectedItem = value; + _selectedIndex = _items.IndexOf(_selectedItem); + update_selection(); + Invalidate(); + } + } + + [Browsable(false), Category("Material Skin"), + Description("Gets the currently selected Text in the ListBox.")] + public string SelectedText + { + get => _selectedText; + //set + //{ + // _selectedText = value; + // Invalidate(); + //} + } + + [Browsable(false), Category("Material Skin"), Description("Gets or sets the zero-based index of the currently selected item in a ListBox.")] + public int SelectedIndex + { + get => _selectedIndex; + set + { + _selectedIndex = value; + update_selection(); + Invalidate(); + } + } + + [Browsable(true), Category("Material Skin"), Description("Gets the value of the member property specified by the ValueMember property.")] + public object SelectedValue + { + get => _selectedValue; + //set + //{ + // _selectedValue = value; + // Invalidate(); + //} + } + + [Category("Material Skin"), DefaultValue(false), Description("Gets or sets a value indicating whether the ListBox supports multiple rows.")] + public bool MultiSelect + { + get => _multiSelect; + set + { + _multiSelect = value; + + if (_selectedItems.Count > 1) + { + _selectedItems.RemoveRange(1, _selectedItems.Count - 1); + } + + Invalidate(); + } + } + + [Browsable(false)] + public int Count => _items.Count; + + [Category("Material Skin"), DefaultValue(false), Description("Gets or sets a value indicating whether the vertical scroll bar be shown or not.")] + public bool ShowScrollBar + { + get => _showScrollBar; + set + { + _showScrollBar = value; + _scrollBar.Visible = value; + Invalidate(); + } + } + + [Category("Material Skin"), DefaultValue(true), Description("Gets or sets a value indicating whether the border shown or not.")] + public bool ShowBorder + { + get => _showBorder; + set + { + _showBorder = value; + Refresh(); + } + } + + [Category("Material Skin"), Description("Gets or sets backcolor used by the control.")] + public override Color BackColor { get; set; } + + [Category("Material Skin"), Description("Gets or sets forecolor used by the control.")] + public override Color ForeColor { get; set; } + + [Browsable(false)] + [EditorBrowsable(EditorBrowsableState.Never)] + public override string Text { get => base.Text; set => base.Text = value; } + + [Category("Material Skin"), Description("Gets or sets border color used by the control.")] + public Color BorderColor + { + get => _borderColor; + set + { + _borderColor = value; + Refresh(); + } + } + + [Category("Material Skin"), DefaultValue(ListBoxStyle.SingleLine)] + [Description("Gets or sets the control style.")] + public ListBoxStyle Style + { + get => _style; + set + { + _style = value; + UpdateItemSpecs(); + + InvalidateScroll(this, null); + Refresh(); + } + } + + [Category("Material Skin"), DefaultValue(MaterialItemDensity.Dense)] + [Description("Gets or sets list density")] + public MaterialItemDensity Density + { + get { return _density; } + set + { + _density = value; + UpdateItemSpecs(); + Invalidate(); + } + } + + #endregion Properties + + #region Constructors + public MaterialListBox() : this(RightToLeft.No) { } + public MaterialListBox(RightToLeft RightToLeft) + { + this.RightToLeft = RightToLeft; + SetStyle + ( + ControlStyles.UserPaint | + ControlStyles.AllPaintingInWmPaint | + ControlStyles.Selectable | + ControlStyles.ResizeRedraw | + ControlStyles.OptimizedDoubleBuffer | + ControlStyles.SupportsTransparentBackColor, + true + ); + UpdateStyles(); + base.BackColor = Color.Transparent; + base.Font = SkinManager.getFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft); + _secondaryFont = SkinManager.getFontByType(MaterialSkinManager.fontType.Body1, RightToLeft); + SetDefaults(); + ShowBorder = true; + ShowScrollBar = false; + MultiSelect = false; + UseAccentColor = false; + ForeColor = SkinManager.TextHighEmphasisColor; // Color.Black; + BackColor = Color.White; + BorderColor = Color.LightGray; + UpdateProperties(); + } + + private void SetDefaults() + { + SelectedIndex = -1; + _hoveredItem = -1; + _showScrollBar = false; + _items.CollectionChanged += InvalidateScroll; + _selectedItems = new List(); + _indicates = new List(); + _multiKeyDown = false; + _scrollBar = new MaterialScrollBar() + { + Orientation = MaterialScrollOrientation.Vertical, + Size = new Size(12, Height), + Maximum = _items.Count * _itemHeight, + SmallChange = _itemHeight, + LargeChange = _itemHeight + }; + _scrollBar.Scroll += HandleScroll; + _scrollBar.MouseDown += VS_MouseDown; + _scrollBar.BackColor = Color.Transparent; + if (!Controls.Contains(_scrollBar)) + { + Controls.Add(_scrollBar); + } + + Style = ListBoxStyle.SingleLine; + Density = MaterialItemDensity.Dense; + } + + #endregion Constructors + + #region ApplyTheme + + + private void UpdateProperties() + { + Invalidate(); + } + + private void UpdateItemSpecs() + { + if (_style == ListBoxStyle.TwoLine) + { + _secondaryTextTopPadding = 4; + if (_density == MaterialItemDensity.Dense) + { + _itemHeight = 60; + _secondaryTextBottomPadding = 10; + _primaryTextBottomPadding = 2; + _primaryFont = SkinManager.getFontByType(MaterialSkinManager.fontType.Body1, RightToLeft); + _secondaryFont = SkinManager.getFontByType(MaterialSkinManager.fontType.Body2, RightToLeft); + } + else + { + _itemHeight = 72; + _secondaryTextBottomPadding = 16; + _primaryTextBottomPadding = 4; + _primaryFont = SkinManager.getFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft); + _secondaryFont = SkinManager.getFontByType(MaterialSkinManager.fontType.Body1, RightToLeft); + } + } + else if (_style == ListBoxStyle.ThreeLine) + { + _primaryTextBottomPadding = 4; + _secondaryTextTopPadding = 4; + if (_density == MaterialItemDensity.Dense) + { + _itemHeight = 76; + _secondaryTextBottomPadding = 16; + _primaryFont = SkinManager.getFontByType(MaterialSkinManager.fontType.Body1, RightToLeft); + _secondaryFont = SkinManager.getFontByType(MaterialSkinManager.fontType.Body2, RightToLeft); + } + else + { + _itemHeight = 88; + _secondaryTextBottomPadding = 12; + _primaryFont = SkinManager.getFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft); + _secondaryFont = SkinManager.getFontByType(MaterialSkinManager.fontType.Body1, RightToLeft); + } + } + else + { + //SingleLine + if (_density == MaterialItemDensity.Dense) + _itemHeight = 40; + else + _itemHeight = 48; + _primaryFont = SkinManager.getFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft); + _secondaryFont = SkinManager.getFontByType(MaterialSkinManager.fontType.Body1, RightToLeft); + } + + } + + #endregion ApplyTheme + + #region Draw Control + + protected override void OnPaint(PaintEventArgs e) + { + if (_updating == true) return; + + Graphics g = e.Graphics; + g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; + Rectangle mainRect = new Rectangle(0, 0, Width - (ShowBorder ? 1 : 0), Height - (ShowBorder ? 1 : 0)); + + int lastItem = (_scrollBar.Value / _itemHeight) + (Height / _itemHeight) + 1 > Items.Count ? Items.Count : (_scrollBar.Value / _itemHeight) + (Height / _itemHeight) + 1; + int firstItem = _scrollBar.Value / _itemHeight < 0 ? 0 : (_scrollBar.Value / _itemHeight); + + g.FillRectangle(Enabled ? SkinManager.BackgroundBrush : SkinManager.BackgroundDisabledBrush, mainRect); + + //Set TextAlignFlags + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + NativeTextRenderer.TextAlignFlags primaryTextAlignFlags; + NativeTextRenderer.TextAlignFlags secondaryTextAlignFlags = textAlignFlag | NativeTextRenderer.TextAlignFlags.Top; + if (_style == ListBoxStyle.TwoLine || _style == ListBoxStyle.ThreeLine) + { + primaryTextAlignFlags = textAlignFlag | NativeTextRenderer.TextAlignFlags.Bottom; + } + else + { + //SingleLine + primaryTextAlignFlags = textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle; + } + + //Set color and brush + Color SelectedColor = new Color(); + if (UseAccentColor) + SelectedColor = SkinManager.ColorScheme.AccentColor; + else + SelectedColor = SkinManager.ColorScheme.PrimaryColor; + SolidBrush SelectedBrush = new SolidBrush(SelectedColor); + + //Draw items + for (int i = firstItem; i < lastItem; i++) + { + string itemText = Items[i].Text; + string itemSecondaryText = Items[i].SecondaryText; + + Rectangle itemRect = new Rectangle(0, (i - firstItem) * _itemHeight, Width - (_showScrollBar && _scrollBar.Visible ? _scrollBar.Width : 0), _itemHeight); + + if (MultiSelect && _indicates.Count != 0) + { + if (i == _hoveredItem && !_indicates.Contains(i)) + { + g.FillRectangle(SkinManager.BackgroundHoverBrush, itemRect); + } + else if (_indicates.Contains(i)) + { + g.FillRectangle(Enabled ? + SelectedBrush : + new SolidBrush(DrawHelper.BlendColor(SelectedColor, SkinManager.SwitchOffDisabledThumbColor, 197)), + itemRect); + } + } + else + { + if (i == _hoveredItem && i != SelectedIndex) + { + g.FillRectangle(SkinManager.BackgroundHoverBrush, itemRect); + } + else if (i == SelectedIndex) + { + g.FillRectangle(Enabled ? + SelectedBrush : + new SolidBrush(DrawHelper.BlendColor(SelectedColor, SkinManager.SwitchOffDisabledThumbColor, 197)), + itemRect); + } + } + + //Define primary & secondary Text Rect + Rectangle primaryTextRect = new Rectangle(itemRect.X + _leftrightPadding, itemRect.Y, itemRect.Width - (2 * _leftrightPadding), itemRect.Height); + Rectangle secondaryTextRect = new Rectangle(); + + if (_style == ListBoxStyle.TwoLine) + { + primaryTextRect.Height = (primaryTextRect.Height / 2) - _primaryTextBottomPadding; + } + else if (_style == ListBoxStyle.ThreeLine) + { + if (_density == MaterialItemDensity.Default) + { + primaryTextRect.Height = 36 - _primaryTextBottomPadding; + } + else + { + primaryTextRect.Height = 30 - _primaryTextBottomPadding; + } + } + secondaryTextRect = new Rectangle(primaryTextRect.X, primaryTextRect.Y + primaryTextRect.Height + (_primaryTextBottomPadding + _secondaryTextTopPadding), primaryTextRect.Width, _itemHeight - _secondaryTextBottomPadding - primaryTextRect.Height - (_primaryTextBottomPadding + _secondaryTextTopPadding)); + + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + NativeText.DrawTransparentText( + itemText, + _primaryFont, + Enabled ? (i != SelectedIndex || UseAccentColor) ? + SkinManager.TextHighEmphasisColor : + SkinManager.ColorScheme.TextColor : + SkinManager.TextDisabledOrHintColor, // Disabled + primaryTextRect.Location, + primaryTextRect.Size, + primaryTextAlignFlags); + if (_style == ListBoxStyle.TwoLine) + { + NativeText.DrawTransparentText( + itemSecondaryText, + _secondaryFont, + Enabled ? (i != SelectedIndex || UseAccentColor) ? + SkinManager.TextDisabledOrHintColor : + SkinManager.ColorScheme.TextColor.Darken(0.25f) : + SkinManager.TextDisabledOrHintColor, // Disabled + secondaryTextRect.Location, + secondaryTextRect.Size, + secondaryTextAlignFlags); + } + else if (_style == ListBoxStyle.ThreeLine) + { + NativeText.DrawMultilineTransparentText( + itemSecondaryText, + _secondaryFont, + Enabled ? (i != SelectedIndex || UseAccentColor) ? + SkinManager.TextDisabledOrHintColor : + SkinManager.ColorScheme.TextColor.Darken(0.25f) : + SkinManager.TextDisabledOrHintColor, // Disabled + secondaryTextRect.Location, + secondaryTextRect.Size, + secondaryTextAlignFlags); + } + } + + } + if (ShowBorder) + { + g.DrawRectangle(Pens.LightGray, mainRect); + } + } + + #endregion Draw Control + + #region Methods + + public void AddItem(MaterialListBoxItem newItem) + { + _items.Add(newItem); + InvalidateScroll(this, null); + ItemsCountChanged?.Invoke(this, new EventArgs()); + } + + public void AddItem(string newItem) + { + MaterialListBoxItem _newitemMLBI = new MaterialListBoxItem(newItem); + _items.Add(_newitemMLBI); + InvalidateScroll(this, null); + ItemsCountChanged?.Invoke(this, new EventArgs()); + } + + public void AddItems(MaterialListBoxItem[] newItems) + { + _updating = true; + foreach (MaterialListBoxItem str in newItems) + { + AddItem(str); + } + _updating = false; + + InvalidateScroll(this, null); + ItemsCountChanged?.Invoke(this, new EventArgs()); + } + + public void AddItems(string[] newItems) + { + _updating = true; + foreach (string str in newItems) + { + AddItem(str); + } + _updating = false; + + InvalidateScroll(this, null); + ItemsCountChanged?.Invoke(this, new EventArgs()); + } + + public void RemoveItemAt(int index) + { + if (index <= _selectedIndex) + { + _selectedIndex -= 1; + update_selection(); + } + _items.RemoveAt(index); + InvalidateScroll(this, null); + ItemsCountChanged?.Invoke(this, new EventArgs()); + } + + public void RemoveItem(MaterialListBoxItem item) + { + if (_items.IndexOf(item) <= _selectedIndex) + { + _selectedIndex -= 1; + update_selection(); + } + _items.Remove(item); + InvalidateScroll(this, null); + ItemsCountChanged?.Invoke(this, new EventArgs()); + } + + public int IndexOf(MaterialListBoxItem value) + { + return _items.IndexOf(value); + } + + public void RemoveItems(MaterialListBoxItem[] itemsToRemove) + { + _updating = true; + foreach (MaterialListBoxItem item in itemsToRemove) + { + if (_items.IndexOf(item) <= _selectedIndex) + { + _selectedIndex -= 1; + update_selection(); + } + _items.Remove(item); + } + _updating = false; + + InvalidateScroll(this, null); + ItemsCountChanged?.Invoke(this, new EventArgs()); + } + + private void update_selection() + { + if (_selectedIndex >= 0) + { + _selectedItem = _items[_selectedIndex]; + _selectedValue = _items[_selectedIndex]; + _selectedText = _items[_selectedIndex].ToString(); + } + else + { + _selectedItem = null; + _selectedValue = null; + _selectedText = null; + } + } + + public void Clear() + { + _updating = true; + for (int i = _items.Count - 1; i >= 0; i += -1) + { + _items.RemoveAt(i); + } + _updating = false; + _selectedIndex = -1; + update_selection(); + + InvalidateScroll(this, null); + ItemsCountChanged?.Invoke(this, new EventArgs()); + } + + public void BeginUpdate() + { + _updating = true; + } + + public void EndUpdate() + { + _updating = false; + } + + #endregion Methods + + #region Events + + [Category("Behavior")] + [Description("Occurs when selected index change.")] + public event SelectedIndexChangedEventHandler SelectedIndexChanged; + + public delegate void SelectedIndexChangedEventHandler(object sender, MaterialListBoxItem selectedItem); + + [Category("Behavior")] + [Description("Occurs when selected value change.")] + public event SelectedValueEventHandler SelectedValueChanged; + + public delegate void SelectedValueEventHandler(object sender, MaterialListBoxItem selectedItem); + + [Category("Behavior")] + [Description("Occurs when item is added or removed.")] + public event EventHandler ItemsCountChanged; + + #endregion Events + + protected override void OnSizeChanged(EventArgs e) + { + InvalidateScroll(this, e); + InvalidateLayout(); + base.OnSizeChanged(e); + } + + protected override void OnMouseDown(MouseEventArgs e) + { + Focus(); + if (e.Button == MouseButtons.Left) + { + int index = _scrollBar.Value / _itemHeight + e.Location.Y / _itemHeight; + if (index >= 0 && index < _items.Count) + { + if (MultiSelect && _multiKeyDown) + { + _indicates.Add(index); + _selectedItems.Add(Items[index]); + } + else + { + _indicates.Clear(); + _selectedItems.Clear(); + _selectedItem = Items[index]; + _selectedIndex = index; + _selectedValue = Items[index]; + _selectedText = Items[index].ToString(); + SelectedIndexChanged?.Invoke(this, _selectedItem); + SelectedValueChanged?.Invoke(this, _selectedItem); + } + } + Invalidate(); + } + base.OnMouseDown(e); + } + + private void HandleScroll(object sender, ScrollEventArgs e) + { + if (_scrollBar.Maximum < _scrollBar.Value + Height) _scrollBar.Value = _scrollBar.Maximum - Height; + Invalidate(); + } + + private void InvalidateScroll(object sender, EventArgs e) + { + _scrollBar.Maximum = _items.Count * _itemHeight; + _scrollBar.SmallChange = _itemHeight; + _scrollBar.LargeChange = Height; + _scrollBar.Visible = (_items.Count * _itemHeight) > Height; + if (_items.Count == 0) + { _scrollBar.Value = 0; } + Invalidate(); + } + + private void VS_MouseDown(object sender, MouseEventArgs e) + { + Focus(); + } + + private void InvalidateLayout() + { + _scrollBar.Size = new Size(12, Height - (ShowBorder ? 2 : 0)); + var PointX = (RightToLeft == RightToLeft.Yes) ? 0 : Width - (_scrollBar.Width + (ShowBorder ? 1 : 0)); + _scrollBar.Location = new Point(PointX, ShowBorder ? 1 : 0); + Invalidate(); + } + + protected override void OnMouseWheel(MouseEventArgs e) + { + if (_scrollBar.Visible == true) + { + if (_scrollBar.Minimum > _scrollBar.Value - e.Delta / 2) + _scrollBar.Value = _scrollBar.Minimum; + else if (_scrollBar.Maximum < _scrollBar.Value + Height) + { + if (e.Delta > 0) + _scrollBar.Value -= e.Delta / 2; + else + { } //Do nothing, maximum reached + } + else + _scrollBar.Value -= e.Delta / 2; + + _updateHoveredItem(e); + + Invalidate(); + base.OnMouseWheel(e); + ((HandledMouseEventArgs)e).Handled = true; + } + } + + protected override bool IsInputKey(Keys keyData) + { + switch (keyData) + { + case Keys.Down: + try + { + _selectedItems.Remove(_items[SelectedIndex]); + SelectedIndex += 1; + _selectedItems.Add(_items[SelectedIndex]); + } + catch + { + // + } + break; + + case Keys.Up: + try + { + _selectedItems.Remove(_items[SelectedIndex]); + SelectedIndex -= 1; + _selectedItems.Add(_items[SelectedIndex]); + } + catch + { + // + } + break; + } + Invalidate(); + return base.IsInputKey(keyData); + } + + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + Cursor = Cursors.Hand; + _updateHoveredItem(e); + + Invalidate(); + } + + private void _updateHoveredItem(MouseEventArgs e) + { + int index = _scrollBar.Value / _itemHeight + e.Location.Y / _itemHeight; + + if (index >= Items.Count) + { + index = -1; + } + + if (index >= 0 && index < Items.Count) + { + _hoveredItem = index; + } + + } + + protected override void OnMouseLeave(EventArgs e) + { + _hoveredItem = -1; + Cursor = Cursors.Default; + Invalidate(); + base.OnMouseLeave(e); + } + + protected override void OnHandleCreated(EventArgs e) + { + base.OnHandleCreated(e); + _scrollBar.Size = new Size(12, Height - (ShowBorder ? 2 : 0)); + _scrollBar.Location = new Point(Width - (_scrollBar.Width + (ShowBorder ? 1 : 0)), ShowBorder ? 1 : 0); + InvalidateScroll(this, e); + } + + public const int WM_SETCURSOR = 0x0020; + public const int IDC_HAND = 32649; + + [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] + public static extern IntPtr LoadCursor(IntPtr hInstance, int lpCursorName); + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + public static extern IntPtr SetCursor(IntPtr hCursor); + + protected override void WndProc(ref Message m) + { + if (m.Msg == WM_SETCURSOR) + { + SetCursor(LoadCursor(IntPtr.Zero, IDC_HAND)); + m.Result = IntPtr.Zero; + return; + } + base.WndProc(ref m); + } + } + + #endregion + +} diff --git a/MaterialSkin/Controls/MaterialListView.cs b/MaterialSkin/Controls/MaterialListView.cs index 51633f9d..cc6103d3 100644 --- a/MaterialSkin/Controls/MaterialListView.cs +++ b/MaterialSkin/Controls/MaterialListView.cs @@ -1,215 +1,224 @@ -namespace MaterialSkin.Controls -{ - using System; - using System.ComponentModel; - using System.Drawing; - using System.Windows.Forms; - - public class MaterialListView : ListView, IMaterialControl - { - [Browsable(false)] - public int Depth { get; set; } - - [Browsable(false)] - public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; - - [Browsable(false)] - public MouseState MouseState { get; set; } - - [Browsable(false)] - public Point MouseLocation { get; set; } - +namespace MaterialSkin.Controls +{ + using System; + using System.ComponentModel; + using System.Drawing; + using System.Windows.Forms; + + public class MaterialListView : ListView, IMaterialControl + { + [Browsable(false)] + public int Depth { get; set; } + + [Browsable(false)] + public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; + + [Browsable(false)] + public MouseState MouseState { get; set; } + + [Browsable(false)] + public Point MouseLocation { get; set; } + private bool _autoSizeTable; - - [Category("Appearance"), Browsable(true)] + + [Category("Appearance"), Browsable(true)] public bool AutoSizeTable - { + { get - { - return _autoSizeTable; - } + { + return _autoSizeTable; + } set - { - _autoSizeTable = value; - Scrollable = !value; - } - } - - [Browsable(false)] - private ListViewItem HoveredItem { get; set; } - - private const int PAD = 16; - private const int ITEMS_HEIGHT = 52; - - public MaterialListView() - { - GridLines = false; - FullRowSelect = true; - View = View.Details; - OwnerDraw = true; - ResizeRedraw = true; - BorderStyle = BorderStyle.None; - MinimumSize = new Size(200, 100); - - SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer, true); - BackColor = SkinManager.BackgroundColor; - - // Fix for hovers, by default it doesn't redraw - MouseLocation = new Point(-1, -1); - MouseState = MouseState.OUT; - MouseEnter += delegate - { - MouseState = MouseState.HOVER; - }; - MouseLeave += delegate - { - MouseState = MouseState.OUT; - MouseLocation = new Point(-1, -1); - HoveredItem = null; - Invalidate(); - }; - MouseDown += delegate - { - MouseState = MouseState.DOWN; - }; - MouseUp += delegate - { - MouseState = MouseState.HOVER; - }; - MouseMove += delegate (object sender, MouseEventArgs args) - { - MouseLocation = args.Location; - var currentHoveredItem = GetItemAt(MouseLocation.X, MouseLocation.Y); - if (HoveredItem != currentHoveredItem) - { - HoveredItem = currentHoveredItem; - Invalidate(); - } - }; - } - - protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e) - { - Graphics g = e.Graphics; - - g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; - - g.FillRectangle(new SolidBrush(BackColor), e.Bounds); - // Draw Text - using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) - { - NativeText.DrawTransparentText( - e.Header.Text, - SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle2), - Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor, - new Point(e.Bounds.Location.X + PAD, e.Bounds.Location.Y), - new Size(e.Bounds.Size.Width - PAD * 2, e.Bounds.Size.Height), - NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); - } - } - - protected override void OnDrawItem(DrawListViewItemEventArgs e) - { - Graphics g = e.Graphics; - - g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; - - // Always draw default background - g.FillRectangle(SkinManager.BackgroundBrush, e.Bounds); - - if (e.Item.Selected) - { - // Selected background - g.FillRectangle(SkinManager.BackgroundFocusBrush, e.Bounds); - } - else if (e.Bounds.Contains(MouseLocation) && MouseState == MouseState.HOVER) - { - // Hover background - g.FillRectangle(SkinManager.BackgroundHoverBrush, e.Bounds); - } - - // Draw separator line - g.DrawLine(new Pen(SkinManager.DividersColor), e.Bounds.Left, e.Bounds.Y, e.Bounds.Right, e.Bounds.Y); - - foreach (ListViewItem.ListViewSubItem subItem in e.Item.SubItems) - { - // Draw Text - using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) - { - NativeText.DrawTransparentText( - subItem.Text, - SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body2), - Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor, - new Point(subItem.Bounds.X + PAD, subItem.Bounds.Y), - new Size(subItem.Bounds.Width - PAD * 2, subItem.Bounds.Height), - NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); - } - } - } - - // Resize - protected override void OnColumnWidthChanging(ColumnWidthChangingEventArgs e) - { - base.OnColumnWidthChanging(e); - AutoResize(); - } - - protected override void OnColumnWidthChanged(ColumnWidthChangedEventArgs e) - { - base.OnColumnWidthChanged(e); - AutoResize(); + { + _autoSizeTable = value; + Scrollable = !value; + } } - - protected override void OnResize(EventArgs e) - { - base.OnResize(e); - AutoResize(); - } - - private void AutoResize() - { - if (!AutoSizeTable) return; - - // Width - int w = 0; - foreach (ColumnHeader col in Columns) - { - w += col.Width; - } - - // Height - int h = 50; //Header size - if (Items.Count > 0) h = TopItem.Bounds.Top; - foreach (ListViewItem item in Items) - { - h += item.Bounds.Height; - } - - Size = new Size(w, h); - } - - protected override void InitLayout() - { - base.InitLayout(); - - // enforce settings - GridLines = false; - FullRowSelect = true; - View = View.Details; - OwnerDraw = true; - ResizeRedraw = true; - BorderStyle = BorderStyle.None; + + [Browsable(false)] + private ListViewItem HoveredItem { get; set; } + + private const int PAD = 16; + private const int ITEMS_HEIGHT = 52; + + public MaterialListView() : this(RightToLeft.Yes) + { } + + public MaterialListView(RightToLeft RightToLeft) + { + this.RightToLeft = RightToLeft; + GridLines = false; + FullRowSelect = true; + View = View.Details; + OwnerDraw = true; + ResizeRedraw = true; + BorderStyle = BorderStyle.None; + MinimumSize = new Size(200, 100); + + SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer, true); + BackColor = SkinManager.BackgroundColor; + + // Fix for hovers, by default it doesn't redraw + MouseLocation = new Point(-1, -1); + MouseState = MouseState.OUT; + MouseEnter += delegate + { + MouseState = MouseState.HOVER; + }; + MouseLeave += delegate + { + MouseState = MouseState.OUT; + MouseLocation = new Point(-1, -1); + HoveredItem = null; + Invalidate(); + }; + MouseDown += delegate + { + MouseState = MouseState.DOWN; + }; + MouseUp += delegate + { + MouseState = MouseState.HOVER; + }; + MouseMove += delegate (object sender, MouseEventArgs args) + { + MouseLocation = args.Location; + var currentHoveredItem = GetItemAt(MouseLocation.X, MouseLocation.Y); + if (HoveredItem != currentHoveredItem) + { + HoveredItem = currentHoveredItem; + Invalidate(); + } + }; } - - protected override void OnCreateControl() - { - base.OnCreateControl(); - } - - protected override void OnBackColorChanged(EventArgs e) - { - base.OnBackColorChanged(e); - BackColor = SkinManager.BackgroundColor; - } - } -} \ No newline at end of file + + protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e) + { + Graphics g = e.Graphics; + + g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; + + g.FillRectangle(new SolidBrush(BackColor), e.Bounds); + // Draw Text + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + NativeText.DrawTransparentText( + e.Header.Text, + SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle2, RightToLeft), + Enabled ? SkinManager.TextHighEmphasisNoAlphaColor : SkinManager.TextDisabledOrHintColor, + new Point(e.Bounds.Location.X + PAD, e.Bounds.Location.Y), + new Size(e.Bounds.Size.Width - PAD * 2, e.Bounds.Size.Height), + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + } + + protected override void OnDrawItem(DrawListViewItemEventArgs e) + { + Graphics g = e.Graphics; + + g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; + + // Always draw default background + g.FillRectangle(SkinManager.BackgroundBrush, e.Bounds); + + if (e.Item.Selected) + { + // Selected background + g.FillRectangle(SkinManager.BackgroundFocusBrush, e.Bounds); + } + else if (e.Bounds.Contains(MouseLocation) && MouseState == MouseState.HOVER) + { + // Hover background + g.FillRectangle(SkinManager.BackgroundHoverBrush, e.Bounds); + } + + // Draw separator line + var gx1 = (RightToLeft == RightToLeft.Yes) ? e.Bounds.Right : e.Bounds.Left; + var gx2 = (RightToLeft == RightToLeft.Yes) ? e.Bounds.Left : e.Bounds.Right; + g.DrawLine(new Pen(SkinManager.DividersColor), gx1, e.Bounds.Y, gx2, e.Bounds.Y); + + foreach (ListViewItem.ListViewSubItem subItem in e.Item.SubItems) + { + // Draw Text + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + NativeText.DrawTransparentText( + subItem.Text, + SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body2, RightToLeft), + Enabled ? SkinManager.TextHighEmphasisNoAlphaColor : SkinManager.TextDisabledOrHintColor, + new Point(subItem.Bounds.X + PAD, subItem.Bounds.Y), + new Size(subItem.Bounds.Width - PAD * 2, subItem.Bounds.Height), + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + } + } + + // Resize + protected override void OnColumnWidthChanging(ColumnWidthChangingEventArgs e) + { + base.OnColumnWidthChanging(e); + AutoResize(); + } + + protected override void OnColumnWidthChanged(ColumnWidthChangedEventArgs e) + { + base.OnColumnWidthChanged(e); + AutoResize(); + } + + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + AutoResize(); + } + + private void AutoResize() + { + if (!AutoSizeTable) return; + + // Width + int w = 0; + foreach (ColumnHeader col in Columns) + { + w += col.Width; + } + + // Height + int h = 50; //Header size + if (Items.Count > 0) h = TopItem.Bounds.Top; + foreach (ListViewItem item in Items) + { + h += item.Bounds.Height; + } + + Size = new Size(w, h); + } + + protected override void InitLayout() + { + base.InitLayout(); + + // enforce settings + GridLines = false; + FullRowSelect = true; + View = View.Details; + OwnerDraw = true; + ResizeRedraw = true; + BorderStyle = BorderStyle.None; + RightToLeft = RightToLeft; + } + + protected override void OnCreateControl() + { + base.OnCreateControl(); + } + + protected override void OnBackColorChanged(EventArgs e) + { + base.OnBackColorChanged(e); + BackColor = SkinManager.BackgroundColor; + } + } +} diff --git a/MaterialSkin/Controls/MaterialMaskedTextBox.cs b/MaterialSkin/Controls/MaterialMaskedTextBox.cs new file mode 100644 index 00000000..b78389c8 --- /dev/null +++ b/MaterialSkin/Controls/MaterialMaskedTextBox.cs @@ -0,0 +1,2056 @@ +namespace MaterialSkin.Controls +{ + using System; + using System.Collections.Generic; + using System.ComponentModel; + using System.Drawing; + using System.Drawing.Imaging; + using System.Windows.Forms; + using MaterialSkin.Animations; + + public class MaterialMaskedTextBox : Control, IMaterialControl + { + + MaterialContextMenuStrip cms = new BaseTextBoxContextMenuStrip(); + ContextMenuStrip _lastContextMenuStrip = new ContextMenuStrip(); + + //Properties for managing the material design properties + [Browsable(false)] + public int Depth { get; set; } + + [Browsable(false)] + public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; + + [Browsable(false)] + public MouseState MouseState { get; set; } + + //Unused properties + [Browsable(false)] + public override System.Drawing.Image BackgroundImage { get; set; } + + [Browsable(false)] + public override System.Windows.Forms.ImageLayout BackgroundImageLayout { get; set; } + + [Browsable(false)] + public string SelectedText { get { return baseTextBox.SelectedText; } set { baseTextBox.SelectedText = value; } } + + [Browsable(false)] + public int SelectionStart { get { return baseTextBox.SelectionStart; } set { baseTextBox.SelectionStart = value; } } + + [Browsable(false)] + public int SelectionLength { get { return baseTextBox.SelectionLength; } set { baseTextBox.SelectionLength = value; } } + + [Browsable(false)] + public int TextLength { get { return baseTextBox.TextLength; } } + + [Browsable(false)] + public override System.Drawing.Color ForeColor { get; set; } + + + //Material Skin properties + + private bool _UseTallSize; + + [Category("Material Skin"), DefaultValue(true), Description("Using a larger size enables the hint to always be visible")] + public bool UseTallSize + { + get { return _UseTallSize; } + set + { + _UseTallSize = value; + UpdateHeight(); + UpdateRects(); + Invalidate(); + } + } + + private bool _showAssistiveText; + [Category("Material Skin"), DefaultValue(false), Description("Assistive elements provide additional detail about text entered into text fields. Could be Helper text or Error message.")] + public bool ShowAssistiveText + { + get { return _showAssistiveText; } + set + { + _showAssistiveText = value; + if (_showAssistiveText) + _helperTextHeight = HELPER_TEXT_HEIGHT; + else + _helperTextHeight = 0; + UpdateHeight(); + //UpdateRects(); + Invalidate(); + } + } + + private string _helperText; + + [Category("Material Skin"), DefaultValue(""), Localizable(true), Description("Helper text conveys additional guidance about the input field, such as how it will be used.")] + public string HelperText + { + get { return _helperText; } + set + { + _helperText = value; + Invalidate(); + } + } + + private string _errorMessage; + + [Category("Material Skin"), DefaultValue(""), Localizable(true), Description("When text input isn't accepted, an error message can display instructions on how to fix it. Error messages are displayed below the input line, replacing helper text until fixed.")] + public string ErrorMessage + { + get { return _errorMessage; } + set + { + _errorMessage = value; + Invalidate(); + } + } + + [Category("Material Skin"), DefaultValue(""), Localizable(true)] + public string Hint + { + get { return baseTextBox.Hint; } + set + { + baseTextBox.Hint = value; + hasHint = !String.IsNullOrEmpty(baseTextBox.Hint); + UpdateRects(); + Invalidate(); + } + } + + [Category("Material Skin"), DefaultValue(true)] + public bool UseAccent { get; set; } + + private Image _leadingIcon; + + [Category("Material Skin"), Browsable(true), Localizable(false)] + /// + /// Gets or sets the leading Icon + /// + public Image LeadingIcon + { + get { return _leadingIcon; } + set + { + _leadingIcon = value; + UpdateRects(); + preProcessIcons(); + Invalidate(); + } + } + + private Image _trailingIcon; + + [Category("Material Skin"), Browsable(true), Localizable(false)] + /// + /// Gets or sets the trailing Icon + /// + public Image TrailingIcon + { + get { return _trailingIcon; } + set + { + _trailingIcon = value; + UpdateRects(); + preProcessIcons(); + Invalidate(); + } + } + + public enum PrefixSuffixTypes + { + None, + Prefix, + Suffix, + } + + private PrefixSuffixTypes _prefixsuffix; + [Category("Material Skin"), DefaultValue(PrefixSuffixTypes.None), Description("Set Prefix/Suffix/None")] + public PrefixSuffixTypes PrefixSuffix + { + get { return _prefixsuffix; } + set + { + _prefixsuffix = value; + UpdateRects(); //Génére une nullref exception + if (_prefixsuffix == PrefixSuffixTypes.Suffix) + RightToLeft = RightToLeft.Yes; + else + RightToLeft = RightToLeft.No; + Invalidate(); + } + } + + private string _prefixsuffixText; + [Category("Material Skin"), DefaultValue(""), Localizable(true), Description("Set Prefix or Suffix text")] + public string PrefixSuffixText + { + get { return _prefixsuffixText; } + set + { + //if (_prefixsuffixText != value) + //{ + _prefixsuffixText = value; + UpdateRects(); + Invalidate(); + //} + } + } + + //TextBox properties + + public override ContextMenuStrip ContextMenuStrip + { + get { return baseTextBox.ContextMenuStrip; } + set + { + if (value != null) + { + baseTextBox.ContextMenuStrip = value; + base.ContextMenuStrip = value; + } + else + { + baseTextBox.ContextMenuStrip = cms; + base.ContextMenuStrip = cms; + } + _lastContextMenuStrip = base.ContextMenuStrip; + } + } + + [Browsable(false)] + public override Color BackColor { get { return Parent == null ? SkinManager.BackgroundColor : Parent.BackColor; } } + + public override string Text { get { return baseTextBox.Text; } set { baseTextBox.Text = value; } } + + [Category("Appearance")] + public HorizontalAlignment TextAlign { get { return baseTextBox.TextAlign; } set { baseTextBox.TextAlign = value; } } + + [Category("Appearance")] + public Char PromptChar { get { return baseTextBox.PromptChar; } set { baseTextBox.PromptChar = value; } } + + //[Category("Behavior")] + //public CharacterCasing CharacterCasing { get { return baseTextBox.CharacterCasing; } set { baseTextBox.CharacterCasing = value; } } + + [Category("Behavior")] + public bool HideSelection { get { return baseTextBox.HideSelection; } set { baseTextBox.HideSelection = value; } } + + [Category("Behavior")] + public bool AllowPromptAsInput { get { return baseTextBox.AllowPromptAsInput; } set { baseTextBox.AllowPromptAsInput = value; } } + + [Category("Behavior")] + public bool AsciiOnly { get { return baseTextBox.AsciiOnly; } set { baseTextBox.AsciiOnly = value; } } + + [Category("Behavior")] + public bool BeepOnError { get { return baseTextBox.BeepOnError; } set { baseTextBox.BeepOnError = value; } } + + [Category("Behavior")] + public MaskFormat CutCopyMaskFormat { get { return baseTextBox.CutCopyMaskFormat; } set { baseTextBox.CutCopyMaskFormat = value; } } + + [Category("Behavior")] + public bool HidePromptOnLeave { get { return baseTextBox.HidePromptOnLeave; } set { baseTextBox.HidePromptOnLeave = value; } } + + [Category("Behavior")] + public InsertKeyMode InsertKeyMode { get { return baseTextBox.InsertKeyMode; } set { baseTextBox.InsertKeyMode = value; } } + + [Category("Behavior")] + public string Mask { get { return baseTextBox.Mask; } set { baseTextBox.Mask = value; } } + + [Category("Behavior")] + public int MaxLength { get { return baseTextBox.MaxLength; } set { baseTextBox.MaxLength = value; } } + + [Category("Behavior")] + public char PasswordChar { get { return baseTextBox.PasswordChar; } set { baseTextBox.PasswordChar = value; } } + + [Category("Behavior")] + public bool RejectInputOnFirstFailure { get { return baseTextBox.RejectInputOnFirstFailure; } set { baseTextBox.RejectInputOnFirstFailure = value; } } + + [Category("Behavior")] + public bool ResetOnPrompt { get { return baseTextBox.ResetOnPrompt; } set { baseTextBox.ResetOnPrompt = value; } } + + [Category("Behavior")] + public bool ResetOnSpace { get { return baseTextBox.ResetOnSpace; } set { baseTextBox.ResetOnSpace = value; } } + + [Category("Behavior")] + public bool ShortcutsEnabled + { + get + { return baseTextBox.ShortcutsEnabled; } + set + { + baseTextBox.ShortcutsEnabled = value; + if (value == false) + { + baseTextBox.ContextMenuStrip = null; + base.ContextMenuStrip = null; + } + else + { + baseTextBox.ContextMenuStrip = _lastContextMenuStrip; + base.ContextMenuStrip = _lastContextMenuStrip; + } + } + } + + [Category("Behavior")] + public bool SkipLiterals { get { return baseTextBox.SkipLiterals; } set { baseTextBox.SkipLiterals = value; } } + + [Category("Behavior")] + public MaskFormat TextMaskFormat { get { return baseTextBox.TextMaskFormat; } set { baseTextBox.TextMaskFormat = value; } } + + [Category("Behavior")] + public bool UseSystemPasswordChar { get { return baseTextBox.UseSystemPasswordChar; } set { baseTextBox.UseSystemPasswordChar = value; } } + + [Browsable(false)] + public Type ValidatingType { get { return baseTextBox.ValidatingType; } set { baseTextBox.ValidatingType = value; } } + + public new object Tag { get { return baseTextBox.Tag; } set { baseTextBox.Tag = value; } } + + private bool _readonly; + [Category("Behavior")] + public bool ReadOnly + { + get { return _readonly; } + set + { + _readonly = value; + if (Enabled == true) + { + baseTextBox.ReadOnly = _readonly; + } + this.Invalidate(); + } + } + + private bool _animateReadOnly; + + [Category("Material Skin")] + [Browsable(true)] + public bool AnimateReadOnly + { + get => _animateReadOnly; + set + { + _animateReadOnly = value; + Invalidate(); + } + } + + private bool _leaveOnEnterKey; + + [Category("Material Skin"), DefaultValue(false), Description("Select next control which have TabStop property set to True when enter key is pressed.")] + public bool LeaveOnEnterKey + { + get => _leaveOnEnterKey; + set + { + _leaveOnEnterKey = value; + if (value) + { + baseTextBox.KeyDown += new KeyEventHandler(LeaveOnEnterKey_KeyDown); + } + else + { + baseTextBox.KeyDown -= LeaveOnEnterKey_KeyDown; + } + Invalidate(); + } + } + + public void SelectAll() { baseTextBox.SelectAll(); } + + public void Clear() { baseTextBox.Clear(); } + + public void Copy() { baseTextBox.Copy(); } + + public void Cut() { baseTextBox.Cut(); } + + public void Undo() { baseTextBox.Undo(); } + + public void Paste() { baseTextBox.Paste(); } + + #region "Events" + + [Category("Action")] + [Description("Fires when Leading Icon is clicked")] + public event EventHandler LeadingIconClick; + + [Category("Action")] + [Description("Fires when Trailing Icon is clicked")] + public event EventHandler TrailingIconClick; + + #endregion + + # region Forwarding events to baseTextBox + + public event EventHandler AcceptsTabChanged + { + add + { + baseTextBox.AcceptsTabChanged += value; + } + remove + { + baseTextBox.AcceptsTabChanged -= value; + } + } + + public new event EventHandler AutoSizeChanged + { + add + { + baseTextBox.AutoSizeChanged += value; + } + remove + { + baseTextBox.AutoSizeChanged -= value; + } + } + + public new event EventHandler BackgroundImageChanged + { + add + { + baseTextBox.BackgroundImageChanged += value; + } + remove + { + baseTextBox.BackgroundImageChanged -= value; + } + } + + public new event EventHandler BackgroundImageLayoutChanged + { + add + { + baseTextBox.BackgroundImageLayoutChanged += value; + } + remove + { + baseTextBox.BackgroundImageLayoutChanged -= value; + } + } + + public new event EventHandler BindingContextChanged + { + add + { + baseTextBox.BindingContextChanged += value; + } + remove + { + baseTextBox.BindingContextChanged -= value; + } + } + + public event EventHandler BorderStyleChanged + { + add + { + baseTextBox.BorderStyleChanged += value; + } + remove + { + baseTextBox.BorderStyleChanged -= value; + } + } + + public new event EventHandler CausesValidationChanged + { + add + { + baseTextBox.CausesValidationChanged += value; + } + remove + { + baseTextBox.CausesValidationChanged -= value; + } + } + + public new event UICuesEventHandler ChangeUICues + { + add + { + baseTextBox.ChangeUICues += value; + } + remove + { + baseTextBox.ChangeUICues -= value; + } + } + + public new event EventHandler Click + { + add + { + baseTextBox.Click += value; + } + remove + { + baseTextBox.Click -= value; + } + } + + public new event EventHandler ClientSizeChanged + { + add + { + baseTextBox.ClientSizeChanged += value; + } + remove + { + baseTextBox.ClientSizeChanged -= value; + } + } + +#if NETFRAMEWORK + public new event EventHandler ContextMenuChanged + { + add + { + baseTextBox.ContextMenuChanged += value; + } + remove + { + baseTextBox.ContextMenuChanged -= value; + } + } +#endif + + public new event EventHandler ContextMenuStripChanged + { + add + { + baseTextBox.ContextMenuStripChanged += value; + } + remove + { + baseTextBox.ContextMenuStripChanged -= value; + } + } + + public new event ControlEventHandler ControlAdded + { + add + { + baseTextBox.ControlAdded += value; + } + remove + { + baseTextBox.ControlAdded -= value; + } + } + + public new event ControlEventHandler ControlRemoved + { + add + { + baseTextBox.ControlRemoved += value; + } + remove + { + baseTextBox.ControlRemoved -= value; + } + } + + public new event EventHandler CursorChanged + { + add + { + baseTextBox.CursorChanged += value; + } + remove + { + baseTextBox.CursorChanged -= value; + } + } + + public new event EventHandler Disposed + { + add + { + baseTextBox.Disposed += value; + } + remove + { + baseTextBox.Disposed -= value; + } + } + + public new event EventHandler DockChanged + { + add + { + baseTextBox.DockChanged += value; + } + remove + { + baseTextBox.DockChanged -= value; + } + } + + public new event EventHandler DoubleClick + { + add + { + baseTextBox.DoubleClick += value; + } + remove + { + baseTextBox.DoubleClick -= value; + } + } + + public new event DragEventHandler DragDrop + { + add + { + baseTextBox.DragDrop += value; + } + remove + { + baseTextBox.DragDrop -= value; + } + } + + public new event DragEventHandler DragEnter + { + add + { + baseTextBox.DragEnter += value; + } + remove + { + baseTextBox.DragEnter -= value; + } + } + + public new event EventHandler DragLeave + { + add + { + baseTextBox.DragLeave += value; + } + remove + { + baseTextBox.DragLeave -= value; + } + } + + public new event DragEventHandler DragOver + { + add + { + baseTextBox.DragOver += value; + } + remove + { + baseTextBox.DragOver -= value; + } + } + + public new event EventHandler EnabledChanged + { + add + { + baseTextBox.EnabledChanged += value; + } + remove + { + baseTextBox.EnabledChanged -= value; + } + } + + public new event EventHandler Enter + { + add + { + baseTextBox.Enter += value; + } + remove + { + baseTextBox.Enter -= value; + } + } + + public new event EventHandler FontChanged + { + add + { + baseTextBox.FontChanged += value; + } + remove + { + baseTextBox.FontChanged -= value; + } + } + + public new event EventHandler ForeColorChanged + { + add + { + baseTextBox.ForeColorChanged += value; + } + remove + { + baseTextBox.ForeColorChanged -= value; + } + } + + public new event GiveFeedbackEventHandler GiveFeedback + { + add + { + baseTextBox.GiveFeedback += value; + } + remove + { + baseTextBox.GiveFeedback -= value; + } + } + + public new event EventHandler GotFocus + { + add + { + baseTextBox.GotFocus += value; + } + remove + { + baseTextBox.GotFocus -= value; + } + } + + public new event EventHandler HandleCreated + { + add + { + baseTextBox.HandleCreated += value; + } + remove + { + baseTextBox.HandleCreated -= value; + } + } + + public new event EventHandler HandleDestroyed + { + add + { + baseTextBox.HandleDestroyed += value; + } + remove + { + baseTextBox.HandleDestroyed -= value; + } + } + + public new event HelpEventHandler HelpRequested + { + add + { + baseTextBox.HelpRequested += value; + } + remove + { + baseTextBox.HelpRequested -= value; + } + } + + public event EventHandler HideSelectionChanged + { + add + { + baseTextBox.HideSelectionChanged += value; + } + remove + { + baseTextBox.HideSelectionChanged -= value; + } + } + + public new event EventHandler ImeModeChanged + { + add + { + baseTextBox.ImeModeChanged += value; + } + remove + { + baseTextBox.ImeModeChanged -= value; + } + } + + public new event InvalidateEventHandler Invalidated + { + add + { + baseTextBox.Invalidated += value; + } + remove + { + baseTextBox.Invalidated -= value; + } + } + + public event EventHandler IsOverwriteModeChanged + { + add + { + baseTextBox.IsOverwriteModeChanged += value; + } + remove + { + baseTextBox.IsOverwriteModeChanged -= value; + } + } + + public new event KeyEventHandler KeyDown + { + add + { + baseTextBox.KeyDown += value; + } + remove + { + baseTextBox.KeyDown -= value; + } + } + + public new event KeyPressEventHandler KeyPress + { + add + { + baseTextBox.KeyPress += value; + } + remove + { + baseTextBox.KeyPress -= value; + } + } + + public new event KeyEventHandler KeyUp + { + add + { + baseTextBox.KeyUp += value; + } + remove + { + baseTextBox.KeyUp -= value; + } + } + + public new event LayoutEventHandler Layout + { + add + { + baseTextBox.Layout += value; + } + remove + { + baseTextBox.Layout -= value; + } + } + + public new event EventHandler Leave + { + add + { + baseTextBox.Leave += value; + } + remove + { + baseTextBox.Leave -= value; + } + } + + public new event EventHandler LocationChanged + { + add + { + baseTextBox.LocationChanged += value; + } + remove + { + baseTextBox.LocationChanged -= value; + } + } + + public new event EventHandler LostFocus + { + add + { + baseTextBox.LostFocus += value; + } + remove + { + baseTextBox.LostFocus -= value; + } + } + + public event EventHandler MaskChanged + { + add + { + baseTextBox.MaskChanged += value; + } + remove + { + baseTextBox.MaskChanged -= value; + } + } + + public new event EventHandler MarginChanged + { + add + { + baseTextBox.MarginChanged += value; + } + remove + { + baseTextBox.MarginChanged -= value; + } + } + + public event MaskInputRejectedEventHandler MaskInputRejected + { + add + { + baseTextBox.MaskInputRejected += value; + } + remove + { + baseTextBox.MaskInputRejected -= value; + } + } + + public event EventHandler ModifiedChanged + { + add + { + baseTextBox.ModifiedChanged += value; + } + remove + { + baseTextBox.ModifiedChanged -= value; + } + } + + public new event EventHandler MouseCaptureChanged + { + add + { + baseTextBox.MouseCaptureChanged += value; + } + remove + { + baseTextBox.MouseCaptureChanged -= value; + } + } + + public new event MouseEventHandler MouseClick + { + add + { + baseTextBox.MouseClick += value; + } + remove + { + baseTextBox.MouseClick -= value; + } + } + + public new event MouseEventHandler MouseDoubleClick + { + add + { + baseTextBox.MouseDoubleClick += value; + } + remove + { + baseTextBox.MouseDoubleClick -= value; + } + } + + public new event MouseEventHandler MouseDown + { + add + { + baseTextBox.MouseDown += value; + } + remove + { + baseTextBox.MouseDown -= value; + } + } + + public new event EventHandler MouseEnter + { + add + { + baseTextBox.MouseEnter += value; + } + remove + { + baseTextBox.MouseEnter -= value; + } + } + + public new event EventHandler MouseHover + { + add + { + baseTextBox.MouseHover += value; + } + remove + { + baseTextBox.MouseHover -= value; + } + } + + public new event EventHandler MouseLeave + { + add + { + baseTextBox.MouseLeave += value; + } + remove + { + baseTextBox.MouseLeave -= value; + } + } + + public new event MouseEventHandler MouseMove + { + add + { + baseTextBox.MouseMove += value; + } + remove + { + baseTextBox.MouseMove -= value; + } + } + + public new event MouseEventHandler MouseUp + { + add + { + baseTextBox.MouseUp += value; + } + remove + { + baseTextBox.MouseUp -= value; + } + } + + public new event MouseEventHandler MouseWheel + { + add + { + baseTextBox.MouseWheel += value; + } + remove + { + baseTextBox.MouseWheel -= value; + } + } + + public new event EventHandler Move + { + add + { + baseTextBox.Move += value; + } + remove + { + baseTextBox.Move -= value; + } + } + + public event EventHandler MultilineChanged + { + add + { + baseTextBox.MultilineChanged += value; + } + remove + { + baseTextBox.MultilineChanged -= value; + } + } + + public new event EventHandler PaddingChanged + { + add + { + baseTextBox.PaddingChanged += value; + } + remove + { + baseTextBox.PaddingChanged -= value; + } + } + + public new event PaintEventHandler Paint + { + add + { + baseTextBox.Paint += value; + } + remove + { + baseTextBox.Paint -= value; + } + } + + public new event EventHandler ParentChanged + { + add + { + baseTextBox.ParentChanged += value; + } + remove + { + baseTextBox.ParentChanged -= value; + } + } + + public new event PreviewKeyDownEventHandler PreviewKeyDown + { + add + { + baseTextBox.PreviewKeyDown += value; + } + remove + { + baseTextBox.PreviewKeyDown -= value; + } + } + + public new event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp + { + add + { + baseTextBox.QueryAccessibilityHelp += value; + } + remove + { + baseTextBox.QueryAccessibilityHelp -= value; + } + } + + public new event QueryContinueDragEventHandler QueryContinueDrag + { + add + { + baseTextBox.QueryContinueDrag += value; + } + remove + { + baseTextBox.QueryContinueDrag -= value; + } + } + + public event EventHandler ReadOnlyChanged + { + add + { + baseTextBox.ReadOnlyChanged += value; + } + remove + { + baseTextBox.ReadOnlyChanged -= value; + } + } + + public new event EventHandler RegionChanged + { + add + { + baseTextBox.RegionChanged += value; + } + remove + { + baseTextBox.RegionChanged -= value; + } + } + + public new event EventHandler Resize + { + add + { + baseTextBox.Resize += value; + } + remove + { + baseTextBox.Resize -= value; + } + } + + public new event EventHandler RightToLeftChanged + { + add + { + baseTextBox.RightToLeftChanged += value; + } + remove + { + baseTextBox.RightToLeftChanged -= value; + } + } + + public new event EventHandler SizeChanged + { + add + { + baseTextBox.SizeChanged += value; + } + remove + { + baseTextBox.SizeChanged -= value; + } + } + + public new event EventHandler StyleChanged + { + add + { + baseTextBox.StyleChanged += value; + } + remove + { + baseTextBox.StyleChanged -= value; + } + } + + public new event EventHandler SystemColorsChanged + { + add + { + baseTextBox.SystemColorsChanged += value; + } + remove + { + baseTextBox.SystemColorsChanged -= value; + } + } + + public new event EventHandler TabIndexChanged + { + add + { + baseTextBox.TabIndexChanged += value; + } + remove + { + baseTextBox.TabIndexChanged -= value; + } + } + + public new event EventHandler TabStopChanged + { + add + { + baseTextBox.TabStopChanged += value; + } + remove + { + baseTextBox.TabStopChanged -= value; + } + } + + public event EventHandler TextAlignChanged + { + add + { + baseTextBox.TextAlignChanged += value; + } + remove + { + baseTextBox.TextAlignChanged -= value; + } + } + + public new event EventHandler TextChanged + { + add + { + baseTextBox.TextChanged += value; + } + remove + { + baseTextBox.TextChanged -= value; + } + } + + public event TypeValidationEventHandler TypeValidationCompleted + { + add + { + baseTextBox.TypeValidationCompleted += value; + } + remove + { + baseTextBox.TypeValidationCompleted -= value; + } + } + + public new event EventHandler Validated + { + add + { + baseTextBox.Validated += value; + } + remove + { + baseTextBox.Validated -= value; + } + } + + public new event CancelEventHandler Validating + { + add + { + baseTextBox.Validating += value; + } + remove + { + baseTextBox.Validating -= value; + } + } + + public new event EventHandler VisibleChanged + { + add + { + baseTextBox.VisibleChanged += value; + } + remove + { + baseTextBox.VisibleChanged -= value; + } + } + # endregion + + private readonly AnimationManager _animationManager; + + public bool isFocused = false; + private const int PREFIX_SUFFIX_PADDING = 4; + private const int ICON_SIZE = 24; + private const int HINT_TEXT_SMALL_SIZE = 18; + private const int HINT_TEXT_SMALL_Y = 4; + private const int TOP_PADDING = 8; //10; + private const int BOTTOM_PADDING = 8; //10; + private const int LEFT_PADDING = 16; + private const int RIGHT_PADDING = 12; + private const int ACTIVATION_INDICATOR_HEIGHT = 2; + private const int HELPER_TEXT_HEIGHT = 16; + private const int FONT_HEIGHT = 20; + + private int HEIGHT = 48; + + private int LINE_Y; + private bool hasHint; + private bool _errorState = false; + private int _left_padding; + private int _right_padding; + private int _prefix_padding; + private int _suffix_padding; + private int _helperTextHeight; + private Rectangle _leadingIconBounds; + private Rectangle _trailingIconBounds; + + private Dictionary iconsBrushes; + private Dictionary iconsErrorBrushes; + + protected readonly BaseMaskedTextBox baseTextBox; + public MaterialMaskedTextBox():this(RightToLeft.No) + { + } + public MaterialMaskedTextBox(RightToLeft RightToLeft) + { + // Material Properties + UseAccent = true; + MouseState = MouseState.OUT; + + SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.DoubleBuffer, true); + + // Animations + _animationManager = new AnimationManager + { + Increment = 0.06, + AnimationType = AnimationType.EaseInOut, + InterruptAnimation = false + }; + _animationManager.OnAnimationProgress += sender => Invalidate(); + + SkinManager.ColorSchemeChanged += sender => + { + preProcessIcons(); + }; + + SkinManager.ThemeChanged += sender => + { + preProcessIcons(); + }; + + Font = SkinManager.getFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft); + + baseTextBox = new BaseMaskedTextBox + { + BorderStyle = BorderStyle.None, + Font = base.Font, + ForeColor = SkinManager.TextHighEmphasisColor, + Multiline = false, + Location = new Point(LEFT_PADDING, HEIGHT / 2 - FONT_HEIGHT / 2), + Width = Width - (LEFT_PADDING + RIGHT_PADDING), + Height = FONT_HEIGHT, + RightToLeft = RightToLeft + }; + + Enabled = true; + ReadOnly = false; + Size = new Size(250, HEIGHT); + + UseTallSize = true; + PrefixSuffix = PrefixSuffixTypes.None; + ShowAssistiveText = false; + HelperText = string.Empty; + ErrorMessage = string.Empty; + + if (!Controls.Contains(baseTextBox) && !DesignMode) + { + Controls.Add(baseTextBox); + } + + baseTextBox.GotFocus += (sender, args) => + { + if (Enabled) + { + isFocused = true; + _animationManager.StartNewAnimation(AnimationDirection.In); + } + else + base.Focus(); + UpdateRects(); + }; + baseTextBox.LostFocus += (sender, args) => + { + isFocused = false; + _animationManager.StartNewAnimation(AnimationDirection.Out); + UpdateRects(); + }; + + baseTextBox.TextChanged += new EventHandler(Redraw); + baseTextBox.BackColorChanged += new EventHandler(Redraw); + + baseTextBox.TabStop = true; + this.TabStop = false; + + cms.Opening += ContextMenuStripOnOpening; + cms.OnItemClickStart += ContextMenuStripOnItemClickStart; + ContextMenuStrip = cms; + + } + + private void Redraw(object sencer, EventArgs e) + { + SuspendLayout(); + Invalidate(); + ResumeLayout(false); + } + + protected override void OnPaint(PaintEventArgs pevent) + { + var g = pevent.Graphics; + g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; + g.Clear(Parent.BackColor); + SolidBrush backBrush = new SolidBrush(DrawHelper.BlendColor(Parent.BackColor, SkinManager.BackgroundAlternativeColor, SkinManager.BackgroundAlternativeColor.A)); + + //backColor + g.FillRectangle( + !Enabled ? SkinManager.BackgroundDisabledBrush : // Disabled + isFocused ? SkinManager.BackgroundFocusBrush : // Focused + MouseState == MouseState.HOVER && (!ReadOnly || (ReadOnly && !AnimateReadOnly)) ? SkinManager.BackgroundHoverBrush : // Hover + backBrush, // Normal + ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, LINE_Y); + + baseTextBox.BackColor = !Enabled ? ColorHelper.RemoveAlpha(SkinManager.BackgroundDisabledColor, BackColor) : //Disabled + isFocused ? DrawHelper.BlendColor(BackColor, SkinManager.BackgroundFocusColor, SkinManager.BackgroundFocusColor.A) : //Focused + MouseState == MouseState.HOVER && (!ReadOnly || (ReadOnly && !AnimateReadOnly)) ? DrawHelper.BlendColor(BackColor, SkinManager.BackgroundHoverColor, SkinManager.BackgroundHoverColor.A) : // Hover + DrawHelper.BlendColor(BackColor, SkinManager.BackgroundAlternativeColor, SkinManager.BackgroundAlternativeColor.A); // Normal + + //Leading Icon + if (LeadingIcon != null) + { + if (_errorState) + g.FillRectangle(iconsErrorBrushes["_leadingIcon"], _leadingIconBounds); + else + g.FillRectangle(iconsBrushes["_leadingIcon"], _leadingIconBounds); + } + + //Trailing Icon + if (TrailingIcon != null) + { + if (_errorState) + g.FillRectangle(iconsErrorBrushes["_trailingIcon"], _trailingIconBounds); + else + g.FillRectangle(iconsBrushes["_trailingIcon"], _trailingIconBounds); + } + + // HintText + bool userTextPresent = !String.IsNullOrEmpty(Text); + Rectangle helperTextRect = new Rectangle(LEFT_PADDING - _prefix_padding, LINE_Y + ACTIVATION_INDICATOR_HEIGHT, Width - (LEFT_PADDING - _prefix_padding) - _right_padding, HELPER_TEXT_HEIGHT); + Rectangle hintRect = new Rectangle(_left_padding - _prefix_padding, HINT_TEXT_SMALL_Y, Width - (_left_padding - _prefix_padding) - _right_padding, HINT_TEXT_SMALL_SIZE); + int hintTextSize = 12; + + // bottom line base + g.FillRectangle(SkinManager.DividersAlternativeBrush, 0, LINE_Y, Width, 1); + + if (ReadOnly == false || (ReadOnly && AnimateReadOnly)) + { + if (!_animationManager.IsAnimating()) + { + // No animation + + // bottom line + if (isFocused) + { + g.FillRectangle(_errorState ? SkinManager.BackgroundHoverRedBrush : isFocused ? UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush : SkinManager.DividersBrush, 0, LINE_Y, Width, isFocused ? 2 : 1); + } + } + else + { + // Animate - Focus got/lost + double animationProgress = _animationManager.GetProgress(); + + // Line Animation + int LineAnimationWidth = (int)(Width * animationProgress); + int LineAnimationX = (Width / 2) - (LineAnimationWidth / 2); + g.FillRectangle(UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush, LineAnimationX, LINE_Y, LineAnimationWidth, 2); + } + } + + // Prefix: + if (_prefixsuffix == PrefixSuffixTypes.Prefix && _prefixsuffixText != null && _prefixsuffixText.Length > 0 && (isFocused || userTextPresent || !hasHint)) + { + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + Rectangle prefixRect = new Rectangle( + _left_padding - _prefix_padding, + hasHint && UseTallSize ? (hintRect.Y + hintRect.Height) - 2 : ClientRectangle.Y, + _prefix_padding, + hasHint && UseTallSize ? LINE_Y - (hintRect.Y + hintRect.Height) : LINE_Y); + + // Draw Prefix text + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + NativeText.DrawTransparentText( + _prefixsuffixText, + SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft), + Enabled ? SkinManager.TextMediumEmphasisColor : SkinManager.TextDisabledOrHintColor, + prefixRect.Location, + prefixRect.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + } + + // Suffix: + if (_prefixsuffix == PrefixSuffixTypes.Suffix && _prefixsuffixText != null && _prefixsuffixText.Length > 0 && (isFocused || userTextPresent || !hasHint)) + { + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + Rectangle suffixRect = new Rectangle( + Width - _right_padding, + hasHint && UseTallSize ? (hintRect.Y + hintRect.Height) - 2 : ClientRectangle.Y, + _suffix_padding, + hasHint && UseTallSize ? LINE_Y - (hintRect.Y + hintRect.Height) : LINE_Y); + + // Draw Suffix text + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Left: NativeTextRenderer.TextAlignFlags.Right; + NativeText.DrawTransparentText( + _prefixsuffixText, + SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft), + Enabled ? SkinManager.TextMediumEmphasisColor : SkinManager.TextDisabledOrHintColor, + suffixRect.Location, + suffixRect.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + } + + // Draw hint text + if (hasHint && UseTallSize && (isFocused || userTextPresent)) + { + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + NativeText.DrawTransparentText( + Hint, + SkinManager.getTextBoxFontBySize(hintTextSize, RightToLeft), + Enabled ? !_errorState || (!userTextPresent && !isFocused) ? isFocused ? UseAccent ? + SkinManager.ColorScheme.AccentColor : // Focus Accent + SkinManager.ColorScheme.PrimaryColor : // Focus Primary + SkinManager.TextMediumEmphasisColor : // not focused + SkinManager.BackgroundHoverRedColor : // error state + SkinManager.TextDisabledOrHintColor, // Disabled + hintRect.Location, + hintRect.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + } + + // Draw helper text + if (_showAssistiveText && isFocused && !_errorState) + { + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + NativeText.DrawTransparentText( + HelperText, + SkinManager.getTextBoxFontBySize(hintTextSize, RightToLeft), + Enabled ? !_errorState || (!userTextPresent && !isFocused) ? isFocused ? UseAccent ? + SkinManager.ColorScheme.AccentColor : // Focus Accent + SkinManager.ColorScheme.PrimaryColor : // Focus Primary + SkinManager.TextMediumEmphasisColor : // not focused + SkinManager.BackgroundHoverRedColor : // error state + SkinManager.TextDisabledOrHintColor, // Disabled + helperTextRect.Location, + helperTextRect.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + } + + // Draw error message + if (_showAssistiveText && _errorState && ErrorMessage != null) + { + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + NativeText.DrawTransparentText( + ErrorMessage, + SkinManager.getTextBoxFontBySize(hintTextSize, RightToLeft), + Enabled ? + SkinManager.BackgroundHoverRedColor : // error state + SkinManager.TextDisabledOrHintColor, // Disabled + helperTextRect.Location, + helperTextRect.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + } + + } + + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + + if (DesignMode) + return; + + if (LeadingIcon != null && _leadingIconBounds.Contains(e.Location) && LeadingIconClick != null) + { + Cursor = Cursors.Hand; + } + else if (TrailingIcon != null && _trailingIconBounds.Contains(e.Location) && TrailingIconClick != null) + { + Cursor = Cursors.Hand; + } + else + { + Cursor = Cursors.IBeam; + } + + } + + protected override void OnMouseDown(MouseEventArgs e) + { + if (DesignMode) + return; + + if (LeadingIcon != null && _leadingIconBounds.Contains(e.Location)) + { + LeadingIconClick?.Invoke(this, new EventArgs()); + } + else if (TrailingIcon != null && _trailingIconBounds.Contains(e.Location)) + { + TrailingIconClick?.Invoke(this, new EventArgs()); + } + else + { + baseTextBox?.Focus(); + } + base.OnMouseDown(e); + + } + + protected override void OnMouseEnter(EventArgs e) + { + if (DesignMode) + return; + + base.OnMouseEnter(e); + MouseState = MouseState.HOVER; + Invalidate(); + } + + protected override void OnMouseLeave(EventArgs e) + { + if (DesignMode) + return; + + if (this.ClientRectangle.Contains(this.PointToClient(Control.MousePosition))) + return; + else + { + base.OnMouseLeave(e); + MouseState = MouseState.OUT; + Invalidate(); + } + } + + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + + UpdateRects(); + preProcessIcons(); + + Size = new Size(Width, HEIGHT); + LINE_Y = HEIGHT - ACTIVATION_INDICATOR_HEIGHT - _helperTextHeight; + + } + + protected override void OnCreateControl() + { + base.OnCreateControl(); + + // events + MouseState = MouseState.OUT; + + } + + #region Icon + private static Size ResizeIcon(Image Icon) + { + int newWidth, newHeight; + //Resize icon if greater than ICON_SIZE + if (Icon.Width > ICON_SIZE || Icon.Height > ICON_SIZE) + { + //calculate aspect ratio + float aspect = Icon.Width / (float)Icon.Height; + + //calculate new dimensions based on aspect ratio + newWidth = (int)(ICON_SIZE * aspect); + newHeight = (int)(newWidth / aspect); + + //if one of the two dimensions exceed the box dimensions + if (newWidth > ICON_SIZE || newHeight > ICON_SIZE) + { + //depending on which of the two exceeds the box dimensions set it as the box dimension and calculate the other one based on the aspect ratio + if (newWidth > newHeight) + { + newWidth = ICON_SIZE; + newHeight = (int)(newWidth / aspect); + } + else + { + newHeight = ICON_SIZE; + newWidth = (int)(newHeight * aspect); + } + } + } + else + { + newWidth = Icon.Width; + newHeight = Icon.Height; + } + + return new Size() + { + Height = newHeight, + Width = newWidth + }; + } + + private void preProcessIcons() + { + if (_trailingIcon == null && _leadingIcon == null) return; + + // Calculate lightness and color + float l = (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT) ? 0f : 1f; + + // Create matrices + float[][] matrixGray = { + new float[] { 0, 0, 0, 0, 0}, // Red scale factor + new float[] { 0, 0, 0, 0, 0}, // Green scale factor + new float[] { 0, 0, 0, 0, 0}, // Blue scale factor + new float[] { 0, 0, 0, Enabled ? .7f : .3f, 0}, // alpha scale factor + new float[] { l, l, l, 0, 1}};// offset + + float[][] matrixRed = { + new float[] { 0, 0, 0, 0, 0}, // Red scale factor + new float[] { 0, 0, 0, 0, 0}, // Green scale factor + new float[] { 0, 0, 0, 0, 0}, // Blue scale factor + new float[] { 0, 0, 0, 1, 0}, // alpha scale factor + new float[] { 1, 0, 0, 0, 1}};// offset + + ColorMatrix colorMatrixGray = new ColorMatrix(matrixGray); + ColorMatrix colorMatrixRed = new ColorMatrix(matrixRed); + + ImageAttributes grayImageAttributes = new ImageAttributes(); + ImageAttributes redImageAttributes = new ImageAttributes(); + + // Set color matrices + grayImageAttributes.SetColorMatrix(colorMatrixGray, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); + redImageAttributes.SetColorMatrix(colorMatrixRed, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); + + // Create brushes + iconsBrushes = new Dictionary(2); + iconsErrorBrushes = new Dictionary(2); + + // Image Rect + Rectangle destRect = new Rectangle(0, 0, ICON_SIZE, ICON_SIZE); + + if (_leadingIcon != null) + { + // ******************** + // *** _leadingIcon *** + // ******************** + + //Resize icon if greater than ICON_SIZE + Size newSize_leadingIcon = ResizeIcon(_leadingIcon); + Bitmap _leadingIconIconResized = new Bitmap(_leadingIcon, newSize_leadingIcon.Width, newSize_leadingIcon.Height); + + // Create a pre-processed copy of the image (GRAY) + Bitmap bgray = new Bitmap(destRect.Width, destRect.Height); + using (Graphics gGray = Graphics.FromImage(bgray)) + { + gGray.DrawImage(_leadingIconIconResized, + new Point[] { + new Point(0, 0), + new Point(destRect.Width, 0), + new Point(0, destRect.Height), + }, + destRect, GraphicsUnit.Pixel, grayImageAttributes); + } + + //Create a pre - processed copy of the image(RED) + Bitmap bred = new Bitmap(destRect.Width, destRect.Height); + using (Graphics gred = Graphics.FromImage(bred)) + { + gred.DrawImage(_leadingIconIconResized, + new Point[] { + new Point(0, 0), + new Point(destRect.Width, 0), + new Point(0, destRect.Height), + }, + destRect, GraphicsUnit.Pixel, redImageAttributes); + } + + // added processed image to brush for drawing + TextureBrush textureBrushGray = new TextureBrush(bgray); + TextureBrush textureBrushRed = new TextureBrush(bred); + + textureBrushGray.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; + textureBrushRed.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; + + var iconRect = _leadingIconBounds; + + textureBrushGray.TranslateTransform(iconRect.X + iconRect.Width / 2 - _leadingIconIconResized.Width / 2, + iconRect.Y + iconRect.Height / 2 - _leadingIconIconResized.Height / 2); + textureBrushRed.TranslateTransform(iconRect.X + iconRect.Width / 2 - _leadingIconIconResized.Width / 2, + iconRect.Y + iconRect.Height / 2 - _leadingIconIconResized.Height / 2); + + // add to dictionary + iconsBrushes.Add("_leadingIcon", textureBrushGray); + + iconsErrorBrushes.Add("_leadingIcon", textureBrushRed); + + } + + if (_trailingIcon != null) + { + // ********************* + // *** _trailingIcon *** + // ********************* + + //Resize icon if greater than ICON_SIZE + Size newSize_trailingIcon = ResizeIcon(_trailingIcon); + Bitmap _trailingIconResized = new Bitmap(_trailingIcon, newSize_trailingIcon.Width, newSize_trailingIcon.Height); + + // Create a pre-processed copy of the image (GRAY) + Bitmap bgray = new Bitmap(destRect.Width, destRect.Height); + using (Graphics gGray = Graphics.FromImage(bgray)) + { + gGray.DrawImage(_trailingIconResized, + new Point[] { + new Point(0, 0), + new Point(destRect.Width, 0), + new Point(0, destRect.Height), + }, + destRect, GraphicsUnit.Pixel, grayImageAttributes); + } + + //Create a pre - processed copy of the image(RED) + Bitmap bred = new Bitmap(destRect.Width, destRect.Height); + using (Graphics gred = Graphics.FromImage(bred)) + { + gred.DrawImage(_trailingIconResized, + new Point[] { + new Point(0, 0), + new Point(destRect.Width, 0), + new Point(0, destRect.Height), + }, + destRect, GraphicsUnit.Pixel, redImageAttributes); + } + + + // added processed image to brush for drawing + TextureBrush textureBrushGray = new TextureBrush(bgray); + TextureBrush textureBrushRed = new TextureBrush(bred); + + textureBrushGray.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; + textureBrushRed.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; + + var iconRect = _trailingIconBounds; + + textureBrushGray.TranslateTransform(iconRect.X + iconRect.Width / 2 - _trailingIconResized.Width / 2, + iconRect.Y + iconRect.Height / 2 - _trailingIconResized.Height / 2); + textureBrushRed.TranslateTransform(iconRect.X + iconRect.Width / 2 - _trailingIconResized.Width / 2, + iconRect.Y + iconRect.Height / 2 - _trailingIconResized.Height / 2); + + // add to dictionary + iconsBrushes.Add("_trailingIcon", textureBrushGray); + //iconsSelectedBrushes.Add(0, textureBrushColor); + iconsErrorBrushes.Add("_trailingIcon", textureBrushRed); + } + } + #endregion + + private void UpdateHeight() + { + HEIGHT = _UseTallSize ? 48 : 36; + HEIGHT += _helperTextHeight; + Size = new Size(Size.Width, HEIGHT); + } + + private void UpdateRects() + { + if (LeadingIcon != null) + _left_padding = LEFT_PADDING + ICON_SIZE; + else + _left_padding = LEFT_PADDING; + + if (_trailingIcon != null) + _right_padding = RIGHT_PADDING + ICON_SIZE; + else + _right_padding = RIGHT_PADDING; + + if (_prefixsuffix == PrefixSuffixTypes.Prefix && _prefixsuffixText != null && _prefixsuffixText.Length > 0) + { + using (NativeTextRenderer NativeText = new NativeTextRenderer(CreateGraphics())) + { + _prefix_padding = NativeText.MeasureLogString(_prefixsuffixText, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft)).Width + PREFIX_SUFFIX_PADDING; + _left_padding += _prefix_padding; + } + } + else + _prefix_padding = 0; + if (_prefixsuffix == PrefixSuffixTypes.Suffix && _prefixsuffixText != null && _prefixsuffixText.Length > 0) + { + using (NativeTextRenderer NativeText = new NativeTextRenderer(CreateGraphics())) + { + _suffix_padding = NativeText.MeasureLogString(_prefixsuffixText, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft)).Width + PREFIX_SUFFIX_PADDING; + _right_padding += _suffix_padding; + } + } + else + _suffix_padding = 0; + + if (hasHint && UseTallSize && (isFocused || !String.IsNullOrEmpty(Text))) + { + baseTextBox.Location = new Point(_left_padding, 22); + baseTextBox.Width = Width - (_left_padding + _right_padding); + baseTextBox.Height = FONT_HEIGHT; + } + else + { + baseTextBox.Location = new Point(_left_padding, (LINE_Y + ACTIVATION_INDICATOR_HEIGHT) / 2 - FONT_HEIGHT / 2); + baseTextBox.Width = Width - (_left_padding + _right_padding); + baseTextBox.Height = FONT_HEIGHT; + } + + _leadingIconBounds = new Rectangle(8, ((LINE_Y + ACTIVATION_INDICATOR_HEIGHT) / 2) - (ICON_SIZE / 2), ICON_SIZE, ICON_SIZE); + _trailingIconBounds = new Rectangle(Width - (ICON_SIZE + 8), ((LINE_Y + ACTIVATION_INDICATOR_HEIGHT) / 2) - (ICON_SIZE / 2), ICON_SIZE, ICON_SIZE); + } + + public void SetErrorState(bool ErrorState) + { + _errorState = ErrorState; + if (_errorState) + baseTextBox.ForeColor = SkinManager.BackgroundHoverRedColor; + else + baseTextBox.ForeColor = SkinManager.TextHighEmphasisColor; + baseTextBox.Invalidate(); + Invalidate(); + } + + public bool GetErrorState() + { + return _errorState; + } + + private void ContextMenuStripOnItemClickStart(object sender, ToolStripItemClickedEventArgs toolStripItemClickedEventArgs) + { + switch (toolStripItemClickedEventArgs.ClickedItem.Text) + { + case "Undo": + Undo(); + break; + case "Cut": + Cut(); + break; + case "Copy": + Copy(); + break; + case "Paste": + Paste(); + break; + case "Delete": + SelectedText = string.Empty; + break; + case "Select All": + SelectAll(); + break; + } + } + + private void ContextMenuStripOnOpening(object sender, CancelEventArgs cancelEventArgs) + { + var strip = sender as BaseTextBoxContextMenuStrip; + if (strip != null) + { + strip.undo.Enabled = baseTextBox.CanUndo && !ReadOnly; + strip.cut.Enabled = !string.IsNullOrEmpty(SelectedText) && !ReadOnly; + strip.copy.Enabled = !string.IsNullOrEmpty(SelectedText); + strip.paste.Enabled = Clipboard.ContainsText() && !ReadOnly; + strip.delete.Enabled = !string.IsNullOrEmpty(SelectedText) && !ReadOnly; + strip.selectAll.Enabled = !string.IsNullOrEmpty(Text); + } + } + + private void LeaveOnEnterKey_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyData == Keys.Enter) + { + e.Handled = true; + e.SuppressKeyPress = true; + SendKeys.Send("{TAB}"); + } + } + } +} diff --git a/MaterialSkin/Controls/MaterialMessageBox.cs b/MaterialSkin/Controls/MaterialMessageBox.cs index e6070612..a3b9f216 100644 --- a/MaterialSkin/Controls/MaterialMessageBox.cs +++ b/MaterialSkin/Controls/MaterialMessageBox.cs @@ -1,74 +1,80 @@ using System.ComponentModel; using System.Drawing; -using System.Windows.Forms; +using System.Windows.Forms; namespace MaterialSkin.Controls { - ///TODO: Break this out into a MaterialDialog then extend into the MaterialMsgBox + ///TODO: Break this out into a MaterialDialog then extend into the MaterialMsgBox ///Adapted from http://www.codeproject.com/Articles/601900/FlexibleMessageBox - public class MaterialMessageBox : IMaterialControl - { - [Browsable(false)] - public int Depth { get; set; } - - [Browsable(false)] - public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; - - [Browsable(false)] - public MouseState MouseState { get; set; } - - [Browsable(false)] + public class MaterialMessageBox : IMaterialControl + { + [Browsable(false)] + public int Depth { get; set; } + + [Browsable(false)] + public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; + + [Browsable(false)] + public MouseState MouseState { get; set; } + + [Browsable(false)] public Point MouseLocation { get; set; } - public static DialogResult Show(string text) - { - return FlexibleMaterialForm.Show(null, text, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1); - } - - public static DialogResult Show(IWin32Window owner, string text) - { - return FlexibleMaterialForm.Show(owner, text, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1); - } - - public static DialogResult Show(string text, string caption) - { - return FlexibleMaterialForm.Show(null, text, caption, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1); - } - - public static DialogResult Show(IWin32Window owner, string text, string caption) - { - return FlexibleMaterialForm.Show(owner, text, caption, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1); - } - - public static DialogResult Show(string text, string caption, MessageBoxButtons buttons) - { - return FlexibleMaterialForm.Show(null, text, caption, buttons, MessageBoxIcon.None, MessageBoxDefaultButton.Button1); - } - - public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons) - { - return FlexibleMaterialForm.Show(owner, text, caption, buttons, MessageBoxIcon.None, MessageBoxDefaultButton.Button1); - } - - public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon) - { - return FlexibleMaterialForm.Show(null, text, caption, buttons, icon, MessageBoxDefaultButton.Button1); - } - - public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon) - { - return FlexibleMaterialForm.Show(owner, text, caption, buttons, icon, MessageBoxDefaultButton.Button1); - } - - public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton) - { - return FlexibleMaterialForm.Show(null, text, caption, buttons, icon, defaultButton); - } - - public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton) - { - return FlexibleMaterialForm.Show(owner, text, caption, buttons, icon, defaultButton); + public static DialogResult Show(string text, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right, RightToLeft RightToLeft = RightToLeft.No) + { + return FlexibleMaterialForm.Show(null, text, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, UseRichTextBox, buttonsPosition, RightToLeft); + } + + public static DialogResult Show(IWin32Window owner, string text, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right, RightToLeft RightToLeft = RightToLeft.No) + { + return FlexibleMaterialForm.Show(owner, text, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, UseRichTextBox, buttonsPosition, RightToLeft); + } + + public static DialogResult Show(string text, string caption, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right, RightToLeft RightToLeft = RightToLeft.No) + { + return FlexibleMaterialForm.Show(null, text, caption, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, UseRichTextBox, buttonsPosition, RightToLeft); + } + + public static DialogResult Show(IWin32Window owner, string text, string caption, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right, RightToLeft RightToLeft = RightToLeft.No) + { + return FlexibleMaterialForm.Show(owner, text, caption, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, UseRichTextBox, buttonsPosition, RightToLeft); + } + + public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right, RightToLeft RightToLeft = RightToLeft.No) + { + return FlexibleMaterialForm.Show(null, text, caption, buttons, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, UseRichTextBox, buttonsPosition, RightToLeft); + } + + public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right, RightToLeft RightToLeft = RightToLeft.No) + { + return FlexibleMaterialForm.Show(owner, text, caption, buttons, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, UseRichTextBox, buttonsPosition, RightToLeft); + } + + public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right, RightToLeft RightToLeft = RightToLeft.No) + { + return FlexibleMaterialForm.Show(null, text, caption, buttons, icon, MessageBoxDefaultButton.Button1, UseRichTextBox, buttonsPosition, RightToLeft); + } + + public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right, RightToLeft RightToLeft = RightToLeft.No) + { + return FlexibleMaterialForm.Show(owner, text, caption, buttons, icon, MessageBoxDefaultButton.Button1, UseRichTextBox, buttonsPosition, RightToLeft); + } + + public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right, RightToLeft RightToLeft = RightToLeft.No) + { + return FlexibleMaterialForm.Show(null, text, caption, buttons, icon, defaultButton, UseRichTextBox, buttonsPosition, RightToLeft); + } + + public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right, RightToLeft RightToLeft = RightToLeft.No) + { + return FlexibleMaterialForm.Show(owner, text, caption, buttons, icon, defaultButton, UseRichTextBox, buttonsPosition, RightToLeft); } - } -} \ No newline at end of file + + public static DialogResult Show(string text, string caption, MessageBoxButtons messageBoxButtons, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right, RightToLeft RightToLeft = RightToLeft.No) + { + return FlexibleMaterialForm.Show(null, text, caption, messageBoxButtons, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, true, buttonsPosition, RightToLeft); + } + + } +} diff --git a/MaterialSkin/Controls/MaterialMultiLineTextBox.cs b/MaterialSkin/Controls/MaterialMultiLineTextBox.cs index 6957b132..53f153b3 100644 --- a/MaterialSkin/Controls/MaterialMultiLineTextBox.cs +++ b/MaterialSkin/Controls/MaterialMultiLineTextBox.cs @@ -1,73 +1,105 @@ -namespace MaterialSkin.Controls -{ - using System; - using System.ComponentModel; - using System.Runtime.InteropServices; - using System.Windows.Forms; - - public class MaterialMultiLineTextBox : RichTextBox, IMaterialControl - { - //Properties for managing the material design properties - [Browsable(false)] - public int Depth { get; set; } - - [Browsable(false)] - public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; - - [Browsable(false)] - public MouseState MouseState { get; set; } - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - private static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, string lParam); - - private const int EM_SETCUEBANNER = 0x1501; - - private const char EmptyChar = (char)0; - - private const char VisualStylePasswordChar = '\u25CF'; - - private const char NonVisualStylePasswordChar = '\u002A'; - - private string hint = string.Empty; - - public string Hint - { - get { return hint; } - set - { - hint = value; - SendMessage(Handle, EM_SETCUEBANNER, (int)IntPtr.Zero, Hint); - } - } - - public new void SelectAll() - { - BeginInvoke((MethodInvoker)delegate () - { - base.Focus(); - base.SelectAll(); - }); - } - - public new void Focus() - { - BeginInvoke((MethodInvoker)delegate () - { - base.Focus(); - }); +namespace MaterialSkin.Controls +{ + using System; + using System.ComponentModel; + using System.Runtime.InteropServices; + using System.Windows.Forms; + + public class MaterialMultiLineTextBox : RichTextBox, IMaterialControl + { + //Properties for managing the material design properties + [Browsable(false)] + public int Depth { get; set; } + + [Browsable(false)] + public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; + + [Browsable(false)] + public MouseState MouseState { get; set; } + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + private static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, string lParam); + + private const int EM_SETCUEBANNER = 0x1501; + + private const char EmptyChar = (char)0; + + private const char VisualStylePasswordChar = '\u25CF'; + + private const char NonVisualStylePasswordChar = '\u002A'; + + private string hint = string.Empty; + + [Category("Material Skin"), DefaultValue(""), Localizable(true)] + public string Hint + { + get { return hint; } + set + { + hint = value; + SendMessage(Handle, EM_SETCUEBANNER, (int)IntPtr.Zero, Hint); + } } - public MaterialMultiLineTextBox() - { - base.OnCreateControl(); - this.Multiline = true; - - BorderStyle = BorderStyle.None; - Font = SkinManager.getFontByType(MaterialSkinManager.fontType.Body1); - BackColor = SkinManager.BackgroundColor; - ForeColor = SkinManager.TextHighEmphasisColor; - BackColorChanged += (sender, args) => BackColor = SkinManager.BackgroundColor; - ForeColorChanged += (sender, args) => ForeColor = SkinManager.TextHighEmphasisColor; - } - } -} \ No newline at end of file + private bool _leaveOnEnterKey; + + [Category("Material Skin"), DefaultValue(false), Description("Select next control which have TabStop property set to True when enter key is pressed. To add enter in text, the user must press CTRL+Enter")] + public bool LeaveOnEnterKey + { + get => _leaveOnEnterKey; + set + { + _leaveOnEnterKey = value; + if (value) + { + KeyDown += new KeyEventHandler(LeaveOnEnterKey_KeyDown); + } + else + { + KeyDown -= LeaveOnEnterKey_KeyDown; + } + Invalidate(); + } + } + + public new void SelectAll() + { + BeginInvoke((MethodInvoker)delegate () + { + base.Focus(); + base.SelectAll(); + }); + } + + public new void Focus() + { + BeginInvoke((MethodInvoker)delegate () + { + base.Focus(); + }); + } + + private void LeaveOnEnterKey_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyData == Keys.Enter && e.Control == false) + { + e.Handled = true; + e.SuppressKeyPress = true; + SendKeys.Send("{TAB}"); + } + } + + public MaterialMultiLineTextBox() + { + base.OnCreateControl(); + this.Multiline = true; + + BorderStyle = BorderStyle.None; + Font = SkinManager.getFontByType(MaterialSkinManager.fontType.Body1, RightToLeft); + BackColor = SkinManager.BackgroundColor; + ForeColor = SkinManager.TextHighEmphasisColor; + BackColorChanged += (sender, args) => BackColor = SkinManager.BackgroundColor; + ForeColorChanged += (sender, args) => ForeColor = SkinManager.TextHighEmphasisColor; + } + } +} diff --git a/MaterialSkin/Controls/MaterialMultiLineTextBox2.cs b/MaterialSkin/Controls/MaterialMultiLineTextBox2.cs new file mode 100644 index 00000000..8c709407 --- /dev/null +++ b/MaterialSkin/Controls/MaterialMultiLineTextBox2.cs @@ -0,0 +1,1397 @@ + +namespace MaterialSkin.Controls +{ + using System; + using System.ComponentModel; + using System.Drawing; + using System.Runtime.InteropServices; + using System.Windows.Forms; + using MaterialSkin.Animations; + + public class MaterialMultiLineTextBox2 : Control, IMaterialControl + { + + MaterialContextMenuStrip cms = new BaseTextBoxContextMenuStrip(); + ContextMenuStrip _lastContextMenuStrip = new ContextMenuStrip(); + + //Properties for managing the material design properties + + [Browsable(false)] + public int Depth { get; set; } + + [Browsable(false)] + public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; + + [Browsable(false)] + public MouseState MouseState { get; set; } + + //Unused properties + + [Browsable(false)] + public override System.Drawing.Image BackgroundImage { get; set; } + + [Browsable(false)] + public override System.Windows.Forms.ImageLayout BackgroundImageLayout { get; set; } + + [Browsable(false)] + public string SelectedText { get { return baseTextBox.SelectedText; } set { baseTextBox.SelectedText = value; } } + + [Browsable(false)] + public int SelectionStart { get { return baseTextBox.SelectionStart; } set { baseTextBox.SelectionStart = value; } } + [Browsable(false)] + public int SelectionLength { get { return baseTextBox.SelectionLength; } set { baseTextBox.SelectionLength = value; } } + [Browsable(false)] + public int TextLength { get { return baseTextBox.TextLength; } } + + [Browsable(false)] + public override System.Drawing.Color ForeColor { get; set; } + + //Material Skin properties + + + [Category("Material Skin"), DefaultValue(""), Localizable(true)] + public string Hint + { + get { return baseTextBox.Hint; } + set + { + baseTextBox.Hint = value; + hasHint = !String.IsNullOrEmpty(baseTextBox.Hint); + Invalidate(); + } + } + + [Category("Material Skin"), DefaultValue(true)] + public bool UseAccent { get; set; } + + + + [Browsable(true)] + [Category("Material Skin"), DefaultValue(true), Description("Defines whether MaterialMultiLineTextBox allows scrolling of text. This property is independent of the ScrollBars property")] + public bool AllowScroll { get; set; } + + + + //TextBox properties + + public override ContextMenuStrip ContextMenuStrip + { + get { return baseTextBox.ContextMenuStrip; } + set + { + if (value != null) + { + baseTextBox.ContextMenuStrip = value; + base.ContextMenuStrip = value; + } + else + { + baseTextBox.ContextMenuStrip = cms; + base.ContextMenuStrip = cms; + } + _lastContextMenuStrip = base.ContextMenuStrip; + } + } + + [Browsable(false)] + public override Color BackColor { get { return Parent == null ? SkinManager.BackgroundColor : Parent.BackColor; } } + + public override string Text { get { return baseTextBox.Text; } set { baseTextBox.Text = value; } } + + [Category("Appearance")] + public HorizontalAlignment TextAlign { get { return baseTextBox.TextAlign; } set { baseTextBox.TextAlign = value; } } + + [Category("Appearance")] + public ScrollBars ScrollBars { get { return baseTextBox.ScrollBars; } set { baseTextBox.ScrollBars = value; } } + + [Category("Behavior")] + public CharacterCasing CharacterCasing { get { return baseTextBox.CharacterCasing; } set { baseTextBox.CharacterCasing = value; } } + + [Category("Behavior")] + public bool HideSelection { get { return baseTextBox.HideSelection; } set { baseTextBox.HideSelection = value; } } + + [Category("Behavior")] + public int MaxLength { get { return baseTextBox.MaxLength; } set { baseTextBox.MaxLength = value; } } + + [Category("Behavior")] + public char PasswordChar { get { return baseTextBox.PasswordChar; } set { baseTextBox.PasswordChar = value; } } + + [Category("Behavior")] + public bool ShortcutsEnabled + { + get + { return baseTextBox.ShortcutsEnabled; } + set + { + baseTextBox.ShortcutsEnabled = value; + if (value == false) + { + baseTextBox.ContextMenuStrip = null; + base.ContextMenuStrip = null; + } + else + { + baseTextBox.ContextMenuStrip = _lastContextMenuStrip; + base.ContextMenuStrip = _lastContextMenuStrip; + } + } + } + + [Category("Behavior")] + public bool UseSystemPasswordChar { get { return baseTextBox.UseSystemPasswordChar; } set { baseTextBox.UseSystemPasswordChar = value; } } + + public new object Tag { get { return baseTextBox.Tag; } set { baseTextBox.Tag = value; } } + + private bool _readonly; + [Category("Behavior")] + public bool ReadOnly + { + get { return _readonly; } + set + { + _readonly = value; + if (Enabled == true) + { + baseTextBox.ReadOnly = _readonly; + } + this.Invalidate(); + } + } + + private bool _animateReadOnly; + + [Category("Material Skin")] + [Browsable(true)] + public bool AnimateReadOnly + { + get => _animateReadOnly; + set + { + _animateReadOnly = value; + Invalidate(); + } + } + + private bool _leaveOnEnterKey; + + [Category("Material Skin"), DefaultValue(false), Description("Select next control which have TabStop property set to True when enter key is pressed. To add enter in text, the user must press CTRL+Enter")] + public bool LeaveOnEnterKey + { + get => _leaveOnEnterKey; + set + { + _leaveOnEnterKey = value; + if (value) + { + baseTextBox.KeyDown += new KeyEventHandler(LeaveOnEnterKey_KeyDown); + } + else + { + baseTextBox.KeyDown -= LeaveOnEnterKey_KeyDown; + } + Invalidate(); + } + } + + public void SelectAll() { baseTextBox.SelectAll(); } + + public void Clear() { baseTextBox.Clear(); } + + public void Copy() { baseTextBox.Copy(); } + + public void Cut() { baseTextBox.Cut(); } + + public void Undo() { baseTextBox.Undo(); } + + public void Paste() { baseTextBox.Paste(); } + + + #region Forwarding events to baseTextBox + + public event EventHandler AcceptsTabChanged + { + add + { + baseTextBox.AcceptsTabChanged += value; + } + remove + { + baseTextBox.AcceptsTabChanged -= value; + } + } + + public new event EventHandler AutoSizeChanged + { + add + { + baseTextBox.AutoSizeChanged += value; + } + remove + { + baseTextBox.AutoSizeChanged -= value; + } + } + + public new event EventHandler BackgroundImageChanged + { + add + { + baseTextBox.BackgroundImageChanged += value; + } + remove + { + baseTextBox.BackgroundImageChanged -= value; + } + } + + public new event EventHandler BackgroundImageLayoutChanged + { + add + { + baseTextBox.BackgroundImageLayoutChanged += value; + } + remove + { + baseTextBox.BackgroundImageLayoutChanged -= value; + } + } + + public new event EventHandler BindingContextChanged + { + add + { + baseTextBox.BindingContextChanged += value; + } + remove + { + baseTextBox.BindingContextChanged -= value; + } + } + + public event EventHandler BorderStyleChanged + { + add + { + baseTextBox.BorderStyleChanged += value; + } + remove + { + baseTextBox.BorderStyleChanged -= value; + } + } + + public new event EventHandler CausesValidationChanged + { + add + { + baseTextBox.CausesValidationChanged += value; + } + remove + { + baseTextBox.CausesValidationChanged -= value; + } + } + + public new event UICuesEventHandler ChangeUICues + { + add + { + baseTextBox.ChangeUICues += value; + } + remove + { + baseTextBox.ChangeUICues -= value; + } + } + + public new event EventHandler Click + { + add + { + baseTextBox.Click += value; + } + remove + { + baseTextBox.Click -= value; + } + } + + public new event EventHandler ClientSizeChanged + { + add + { + baseTextBox.ClientSizeChanged += value; + } + remove + { + baseTextBox.ClientSizeChanged -= value; + } + } + +#if NETFRAMEWORK + public new event EventHandler ContextMenuChanged + { + add + { + baseTextBox.ContextMenuChanged += value; + } + remove + { + baseTextBox.ContextMenuChanged -= value; + } + } +#endif + + public new event EventHandler ContextMenuStripChanged + { + add + { + baseTextBox.ContextMenuStripChanged += value; + } + remove + { + baseTextBox.ContextMenuStripChanged -= value; + } + } + + public new event ControlEventHandler ControlAdded + { + add + { + baseTextBox.ControlAdded += value; + } + remove + { + baseTextBox.ControlAdded -= value; + } + } + + public new event ControlEventHandler ControlRemoved + { + add + { + baseTextBox.ControlRemoved += value; + } + remove + { + baseTextBox.ControlRemoved -= value; + } + } + + public new event EventHandler CursorChanged + { + add + { + baseTextBox.CursorChanged += value; + } + remove + { + baseTextBox.CursorChanged -= value; + } + } + + public new event EventHandler Disposed + { + add + { + baseTextBox.Disposed += value; + } + remove + { + baseTextBox.Disposed -= value; + } + } + + public new event EventHandler DockChanged + { + add + { + baseTextBox.DockChanged += value; + } + remove + { + baseTextBox.DockChanged -= value; + } + } + + public new event EventHandler DoubleClick + { + add + { + baseTextBox.DoubleClick += value; + } + remove + { + baseTextBox.DoubleClick -= value; + } + } + + public new event DragEventHandler DragDrop + { + add + { + baseTextBox.DragDrop += value; + } + remove + { + baseTextBox.DragDrop -= value; + } + } + + public new event DragEventHandler DragEnter + { + add + { + baseTextBox.DragEnter += value; + } + remove + { + baseTextBox.DragEnter -= value; + } + } + + public new event EventHandler DragLeave + { + add + { + baseTextBox.DragLeave += value; + } + remove + { + baseTextBox.DragLeave -= value; + } + } + + public new event DragEventHandler DragOver + { + add + { + baseTextBox.DragOver += value; + } + remove + { + baseTextBox.DragOver -= value; + } + } + + public new event EventHandler EnabledChanged + { + add + { + baseTextBox.EnabledChanged += value; + } + remove + { + baseTextBox.EnabledChanged -= value; + } + } + + public new event EventHandler Enter + { + add + { + baseTextBox.Enter += value; + } + remove + { + baseTextBox.Enter -= value; + } + } + + public new event EventHandler FontChanged + { + add + { + baseTextBox.FontChanged += value; + } + remove + { + baseTextBox.FontChanged -= value; + } + } + + public new event EventHandler ForeColorChanged + { + add + { + baseTextBox.ForeColorChanged += value; + } + remove + { + baseTextBox.ForeColorChanged -= value; + } + } + + public new event GiveFeedbackEventHandler GiveFeedback + { + add + { + baseTextBox.GiveFeedback += value; + } + remove + { + baseTextBox.GiveFeedback -= value; + } + } + + public new event EventHandler GotFocus + { + add + { + baseTextBox.GotFocus += value; + } + remove + { + baseTextBox.GotFocus -= value; + } + } + + public new event EventHandler HandleCreated + { + add + { + baseTextBox.HandleCreated += value; + } + remove + { + baseTextBox.HandleCreated -= value; + } + } + + public new event EventHandler HandleDestroyed + { + add + { + baseTextBox.HandleDestroyed += value; + } + remove + { + baseTextBox.HandleDestroyed -= value; + } + } + + public new event HelpEventHandler HelpRequested + { + add + { + baseTextBox.HelpRequested += value; + } + remove + { + baseTextBox.HelpRequested -= value; + } + } + + public event EventHandler HideSelectionChanged + { + add + { + baseTextBox.HideSelectionChanged += value; + } + remove + { + baseTextBox.HideSelectionChanged -= value; + } + } + + public new event EventHandler ImeModeChanged + { + add + { + baseTextBox.ImeModeChanged += value; + } + remove + { + baseTextBox.ImeModeChanged -= value; + } + } + + public new event InvalidateEventHandler Invalidated + { + add + { + baseTextBox.Invalidated += value; + } + remove + { + baseTextBox.Invalidated -= value; + } + } + + public new event KeyEventHandler KeyDown + { + add + { + baseTextBox.KeyDown += value; + } + remove + { + baseTextBox.KeyDown -= value; + } + } + + public new event KeyPressEventHandler KeyPress + { + add + { + baseTextBox.KeyPress += value; + } + remove + { + baseTextBox.KeyPress -= value; + } + } + + public new event KeyEventHandler KeyUp + { + add + { + baseTextBox.KeyUp += value; + } + remove + { + baseTextBox.KeyUp -= value; + } + } + + public new event LayoutEventHandler Layout + { + add + { + baseTextBox.Layout += value; + } + remove + { + baseTextBox.Layout -= value; + } + } + + public new event EventHandler Leave + { + add + { + baseTextBox.Leave += value; + } + remove + { + baseTextBox.Leave -= value; + } + } + + public new event EventHandler LocationChanged + { + add + { + baseTextBox.LocationChanged += value; + } + remove + { + baseTextBox.LocationChanged -= value; + } + } + + public new event EventHandler LostFocus + { + add + { + baseTextBox.LostFocus += value; + } + remove + { + baseTextBox.LostFocus -= value; + } + } + + public new event EventHandler MarginChanged + { + add + { + baseTextBox.MarginChanged += value; + } + remove + { + baseTextBox.MarginChanged -= value; + } + } + + public event EventHandler ModifiedChanged + { + add + { + baseTextBox.ModifiedChanged += value; + } + remove + { + baseTextBox.ModifiedChanged -= value; + } + } + + public new event EventHandler MouseCaptureChanged + { + add + { + baseTextBox.MouseCaptureChanged += value; + } + remove + { + baseTextBox.MouseCaptureChanged -= value; + } + } + + public new event MouseEventHandler MouseClick + { + add + { + baseTextBox.MouseClick += value; + } + remove + { + baseTextBox.MouseClick -= value; + } + } + + public new event MouseEventHandler MouseDoubleClick + { + add + { + baseTextBox.MouseDoubleClick += value; + } + remove + { + baseTextBox.MouseDoubleClick -= value; + } + } + + public new event MouseEventHandler MouseDown + { + add + { + baseTextBox.MouseDown += value; + } + remove + { + baseTextBox.MouseDown -= value; + } + } + + public new event EventHandler MouseEnter + { + add + { + baseTextBox.MouseEnter += value; + } + remove + { + baseTextBox.MouseEnter -= value; + } + } + + public new event EventHandler MouseHover + { + add + { + baseTextBox.MouseHover += value; + } + remove + { + baseTextBox.MouseHover -= value; + } + } + + public new event EventHandler MouseLeave + { + add + { + baseTextBox.MouseLeave += value; + } + remove + { + baseTextBox.MouseLeave -= value; + } + } + + public new event MouseEventHandler MouseMove + { + add + { + baseTextBox.MouseMove += value; + } + remove + { + baseTextBox.MouseMove -= value; + } + } + + public new event MouseEventHandler MouseUp + { + add + { + baseTextBox.MouseUp += value; + } + remove + { + baseTextBox.MouseUp -= value; + } + } + + public new event MouseEventHandler MouseWheel + { + add + { + baseTextBox.MouseWheel += value; + } + remove + { + baseTextBox.MouseWheel -= value; + } + } + + public new event EventHandler Move + { + add + { + baseTextBox.Move += value; + } + remove + { + baseTextBox.Move -= value; + } + } + + public event EventHandler MultilineChanged + { + add + { + baseTextBox.MultilineChanged += value; + } + remove + { + baseTextBox.MultilineChanged -= value; + } + } + + public new event EventHandler PaddingChanged + { + add + { + baseTextBox.PaddingChanged += value; + } + remove + { + baseTextBox.PaddingChanged -= value; + } + } + + public new event PaintEventHandler Paint + { + add + { + baseTextBox.Paint += value; + } + remove + { + baseTextBox.Paint -= value; + } + } + + public new event EventHandler ParentChanged + { + add + { + baseTextBox.ParentChanged += value; + } + remove + { + baseTextBox.ParentChanged -= value; + } + } + + public new event PreviewKeyDownEventHandler PreviewKeyDown + { + add + { + baseTextBox.PreviewKeyDown += value; + } + remove + { + baseTextBox.PreviewKeyDown -= value; + } + } + + public new event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp + { + add + { + baseTextBox.QueryAccessibilityHelp += value; + } + remove + { + baseTextBox.QueryAccessibilityHelp -= value; + } + } + + public new event QueryContinueDragEventHandler QueryContinueDrag + { + add + { + baseTextBox.QueryContinueDrag += value; + } + remove + { + baseTextBox.QueryContinueDrag -= value; + } + } + + public event EventHandler ReadOnlyChanged + { + add + { + baseTextBox.ReadOnlyChanged += value; + } + remove + { + baseTextBox.ReadOnlyChanged -= value; + } + } + + public new event EventHandler RegionChanged + { + add + { + baseTextBox.RegionChanged += value; + } + remove + { + baseTextBox.RegionChanged -= value; + } + } + + public new event EventHandler Resize + { + add + { + baseTextBox.Resize += value; + } + remove + { + baseTextBox.Resize -= value; + } + } + + public new event EventHandler RightToLeftChanged + { + add + { + baseTextBox.RightToLeftChanged += value; + } + remove + { + baseTextBox.RightToLeftChanged -= value; + } + } + + public new event EventHandler SizeChanged + { + add + { + baseTextBox.SizeChanged += value; + } + remove + { + baseTextBox.SizeChanged -= value; + } + } + + public new event EventHandler StyleChanged + { + add + { + baseTextBox.StyleChanged += value; + } + remove + { + baseTextBox.StyleChanged -= value; + } + } + + public new event EventHandler SystemColorsChanged + { + add + { + baseTextBox.SystemColorsChanged += value; + } + remove + { + baseTextBox.SystemColorsChanged -= value; + } + } + + public new event EventHandler TabIndexChanged + { + add + { + baseTextBox.TabIndexChanged += value; + } + remove + { + baseTextBox.TabIndexChanged -= value; + } + } + + public new event EventHandler TabStopChanged + { + add + { + baseTextBox.TabStopChanged += value; + } + remove + { + baseTextBox.TabStopChanged -= value; + } + } + + public event EventHandler TextAlignChanged + { + add + { + baseTextBox.TextAlignChanged += value; + } + remove + { + baseTextBox.TextAlignChanged -= value; + } + } + + public new event EventHandler TextChanged + { + add + { + baseTextBox.TextChanged += value; + } + remove + { + baseTextBox.TextChanged -= value; + } + } + + public new event EventHandler Validated + { + add + { + baseTextBox.Validated += value; + } + remove + { + baseTextBox.Validated -= value; + } + } + + public new event CancelEventHandler Validating + { + add + { + baseTextBox.Validating += value; + } + remove + { + baseTextBox.Validating -= value; + } + } + + public new event EventHandler VisibleChanged + { + add + { + baseTextBox.VisibleChanged += value; + } + remove + { + baseTextBox.VisibleChanged -= value; + } + } + # endregion + + //private readonly AnimationManager animationManager; + private readonly AnimationManager _animationManager; + + public bool isFocused = false; + private const int HINT_TEXT_SMALL_SIZE = 18; + private const int HINT_TEXT_SMALL_Y = 4; + private const int LINE_BOTTOM_PADDING = 3; + private const int TOP_PADDING = 10; + private const int BOTTOM_PADDING = 10; + private const int LEFT_PADDING = 16; + private const int RIGHT_PADDING = 12; + private int LINE_Y; + private bool hasHint; + private readonly int SB_LINEUP = 0; + private readonly int SB_LINEDOWN = 1; + private readonly uint WM_VSCROLL = 277; + private readonly IntPtr ptrLparam = new IntPtr(0); + + protected readonly BaseTextBox baseTextBox; + public MaterialMultiLineTextBox2():this(RightToLeft.No) + { + + } + public MaterialMultiLineTextBox2(RightToLeft RightToLeft) + { + AllowScroll = true; + // Material Properties + UseAccent = true; + MouseState = MouseState.OUT; + + SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.DoubleBuffer, true); + + // Animations + _animationManager = new AnimationManager + { + Increment = 0.06, + AnimationType = AnimationType.EaseInOut, + InterruptAnimation = false + }; + _animationManager.OnAnimationProgress += sender => Invalidate(); + + baseTextBox = new BaseTextBox + { + BorderStyle = BorderStyle.None, + Font = SkinManager.getFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft), + ForeColor = SkinManager.TextHighEmphasisColor, + Multiline = true + }; + + Cursor = Cursors.IBeam; + Enabled = true; + ReadOnly = false; + ScrollBars = ScrollBars.None; + Size = new Size(250, 100); + + if (!Controls.Contains(baseTextBox) && !DesignMode) + { + Controls.Add(baseTextBox); + } + + baseTextBox.GotFocus += (sender, args) => + { + if (Enabled) + { + isFocused = true; + _animationManager.StartNewAnimation(AnimationDirection.In); + } + else + base.Focus(); + }; + baseTextBox.LostFocus += (sender, args) => + { + isFocused = false; + _animationManager.StartNewAnimation(AnimationDirection.Out); + }; + + baseTextBox.TextChanged += new EventHandler(Redraw); + baseTextBox.BackColorChanged += new EventHandler(Redraw); + + baseTextBox.TabStop = true; + this.TabStop = false; + + cms.Opening += ContextMenuStripOnOpening; + cms.OnItemClickStart += ContextMenuStripOnItemClickStart; + ContextMenuStrip = cms; + this.MouseWheel += OnMouseWheel; + } + + private void Redraw(object sencer, EventArgs e) + { + SuspendLayout(); + Invalidate(); + ResumeLayout(false); + } + + protected override void OnPaint(PaintEventArgs pevent) + { + var g = pevent.Graphics; + g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; + g.Clear(Parent.BackColor); + SolidBrush backBrush = new SolidBrush(DrawHelper.BlendColor(Parent.BackColor, SkinManager.BackgroundAlternativeColor, SkinManager.BackgroundAlternativeColor.A)); + + //backColor + g.FillRectangle( + !Enabled ? SkinManager.BackgroundDisabledBrush : // Disabled + isFocused ? SkinManager.BackgroundFocusBrush : // Focused + MouseState == MouseState.HOVER && (!ReadOnly || (ReadOnly && !AnimateReadOnly)) ? SkinManager.BackgroundHoverBrush : // Hover + backBrush, // Normal + ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, LINE_Y); + + baseTextBox.BackColor = !Enabled ? ColorHelper.RemoveAlpha(SkinManager.BackgroundDisabledColor, BackColor) : //Disabled + isFocused ? DrawHelper.BlendColor(BackColor, SkinManager.BackgroundFocusColor, SkinManager.BackgroundFocusColor.A) : //Focused + MouseState == MouseState.HOVER && (!ReadOnly || (ReadOnly && !AnimateReadOnly)) ? DrawHelper.BlendColor(BackColor, SkinManager.BackgroundHoverColor, SkinManager.BackgroundHoverColor.A) : // Hover + DrawHelper.BlendColor(BackColor, SkinManager.BackgroundAlternativeColor, SkinManager.BackgroundAlternativeColor.A); // Normal + + // bottom line base + g.FillRectangle(SkinManager.DividersAlternativeBrush, 0, LINE_Y, Width, 1); + + if (ReadOnly == false || (ReadOnly && AnimateReadOnly)) + { + if (!_animationManager.IsAnimating()) + { + // bottom line + if (isFocused) + { + //No animation + g.FillRectangle(isFocused ? UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush : SkinManager.DividersBrush, 0, LINE_Y, Width, isFocused ? 2 : 1); + } + } + else + { + // Animate - Focus got/lost + double animationProgress = _animationManager.GetProgress(); + + // Line Animation + int LineAnimationWidth = (int)(Width * animationProgress); + int LineAnimationX = (Width / 2) - (LineAnimationWidth / 2); + g.FillRectangle(UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush, LineAnimationX, LINE_Y, LineAnimationWidth, 2); + } + } + } + + + [DllImport("User32.dll", CharSet = CharSet.Auto, EntryPoint = "SendMessage")] + protected static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); + + protected void OnMouseWheel(object sender, MouseEventArgs e) + { + if (AllowScroll) + { + if (DesignMode) + return; + //Calculate number of notches mouse wheel moved + int v = e.Delta / 120; + //Down Movement + if (v < 0) + { + var ptrWparam = new IntPtr(SB_LINEDOWN); + SendMessage(baseTextBox.Handle, WM_VSCROLL, ptrWparam, ptrLparam); + } + //Up Movement + else if (v > 0) + { + var ptrWparam = new IntPtr(SB_LINEUP); + SendMessage(baseTextBox.Handle, WM_VSCROLL, ptrWparam, ptrLparam); + } + + baseTextBox?.Focus(); + base.OnMouseDown(e); + } + } + + protected override void OnMouseMove(MouseEventArgs e) + { + if (DesignMode) + return; + + base.OnMouseMove(e); + } + + protected override void OnMouseDown(MouseEventArgs e) + { + if (DesignMode) + return; + + baseTextBox?.Focus(); + base.OnMouseDown(e); + } + + protected override void OnMouseEnter(EventArgs e) + { + if (DesignMode) + return; + + base.OnMouseEnter(e); + MouseState = MouseState.HOVER; + Invalidate(); + } + + protected override void OnMouseLeave(EventArgs e) + { + if (DesignMode) + return; + + if (this.ClientRectangle.Contains(this.PointToClient(Control.MousePosition))) + return; + else + { + base.OnMouseLeave(e); + MouseState = MouseState.OUT; + Invalidate(); + } + } + + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + + baseTextBox.Location = new Point(LEFT_PADDING, TOP_PADDING); + baseTextBox.Width = Width - (LEFT_PADDING + RIGHT_PADDING); + baseTextBox.Height = Height - (TOP_PADDING + BOTTOM_PADDING); + + LINE_Y = Height - LINE_BOTTOM_PADDING; + + } + + protected override void OnCreateControl() + { + base.OnCreateControl(); + + // events + MouseState = MouseState.OUT; + } + + private void ContextMenuStripOnItemClickStart(object sender, ToolStripItemClickedEventArgs toolStripItemClickedEventArgs) + { + switch (toolStripItemClickedEventArgs.ClickedItem.Text) + { + case "Undo": + Undo(); + break; + case "Cut": + Cut(); + break; + case "Copy": + Copy(); + break; + case "Paste": + Paste(); + break; + case "Delete": + SelectedText = string.Empty; + break; + case "Select All": + SelectAll(); + break; + } + } + + private void ContextMenuStripOnOpening(object sender, CancelEventArgs cancelEventArgs) + { + var strip = sender as BaseTextBoxContextMenuStrip; + if (strip != null) + { + strip.undo.Enabled = baseTextBox.CanUndo && !ReadOnly; + strip.cut.Enabled = !string.IsNullOrEmpty(SelectedText) && !ReadOnly; + strip.copy.Enabled = !string.IsNullOrEmpty(SelectedText); + strip.paste.Enabled = Clipboard.ContainsText() && !ReadOnly; + strip.delete.Enabled = !string.IsNullOrEmpty(SelectedText) && !ReadOnly; + strip.selectAll.Enabled = !string.IsNullOrEmpty(Text); + } + } + + private void LeaveOnEnterKey_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyData == Keys.Enter && e.Control == false) + { + e.Handled = true; + e.SuppressKeyPress = true; + SendKeys.Send("{TAB}"); + } + } + } +} diff --git a/MaterialSkin/Controls/MaterialProgressBar.cs b/MaterialSkin/Controls/MaterialProgressBar.cs index 7b11e588..aeb913bc 100644 --- a/MaterialSkin/Controls/MaterialProgressBar.cs +++ b/MaterialSkin/Controls/MaterialProgressBar.cs @@ -1,6 +1,7 @@ namespace MaterialSkin.Controls { using System.ComponentModel; + using System.Drawing; using System.Windows.Forms; public class MaterialProgressBar : ProgressBar, IMaterialControl @@ -28,8 +29,11 @@ protected override void SetBoundsCore(int x, int y, int width, int height, Bound protected override void OnPaint(PaintEventArgs e) { var doneProgress = (int)(Width * ((double)Value / Maximum)); - e.Graphics.FillRectangle(SkinManager.ColorScheme.PrimaryBrush, 0, 0, doneProgress, Height); + e.Graphics.FillRectangle(Enabled ? + SkinManager.ColorScheme.PrimaryBrush : + new SolidBrush(DrawHelper.BlendColor(SkinManager.ColorScheme.PrimaryColor, SkinManager.SwitchOffDisabledThumbColor, 197)), + 0, 0, doneProgress, Height); e.Graphics.FillRectangle(SkinManager.BackgroundFocusBrush, doneProgress, 0, Width - doneProgress, Height); } } -} \ No newline at end of file +} diff --git a/MaterialSkin/Controls/MaterialRadioButton.cs b/MaterialSkin/Controls/MaterialRadioButton.cs index 661796cd..218e9c0b 100644 --- a/MaterialSkin/Controls/MaterialRadioButton.cs +++ b/MaterialSkin/Controls/MaterialRadioButton.cs @@ -1,308 +1,313 @@ -namespace MaterialSkin.Controls -{ - using MaterialSkin.Animations; - using System; - using System.ComponentModel; - using System.Drawing; - using System.Drawing.Drawing2D; - using System.Drawing.Text; - using System.Windows.Forms; - - public class MaterialRadioButton : RadioButton, IMaterialControl - { - [Browsable(false)] - public int Depth { get; set; } - - [Browsable(false)] - public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; - - [Browsable(false)] - public MouseState MouseState { get; set; } - - [Browsable(false)] - public Point MouseLocation { get; set; } - - private bool ripple; - - [Category("Behavior")] - public bool Ripple - { - get { return ripple; } - set - { - ripple = value; - AutoSize = AutoSize; //Make AutoSize directly set the bounds. - - if (value) - { - Margin = new Padding(0); - } - - Invalidate(); - } - } - - // animation managers - private readonly AnimationManager _checkAM; - - private readonly AnimationManager _rippleAM; - private readonly AnimationManager _hoverAM; - - // size related variables which should be recalculated onsizechanged - private Rectangle _radioButtonBounds; - - private int _boxOffset; - - // size constants - private const int HEIGHT_RIPPLE = 37; - - private const int HEIGHT_NO_RIPPLE = 20; - private const int RADIOBUTTON_SIZE = 18; - private const int RADIOBUTTON_SIZE_HALF = RADIOBUTTON_SIZE / 2; - private const int RADIOBUTTON_OUTER_CIRCLE_WIDTH = 2; - private const int RADIOBUTTON_INNER_CIRCLE_SIZE = RADIOBUTTON_SIZE - (2 * RADIOBUTTON_OUTER_CIRCLE_WIDTH); - private const int TEXT_OFFSET = 26; - - public MaterialRadioButton() - { - SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer, true); - - _checkAM = new AnimationManager - { - AnimationType = AnimationType.EaseInOut, - Increment = 0.06 - }; - _hoverAM = new AnimationManager(true) - { - AnimationType = AnimationType.Linear, - Increment = 0.10 - }; - _rippleAM = new AnimationManager(false) - { - AnimationType = AnimationType.Linear, - Increment = 0.10, - SecondaryIncrement = 0.08 - }; - - _checkAM.OnAnimationProgress += sender => Invalidate(); - _hoverAM.OnAnimationProgress += sender => Invalidate(); - _rippleAM.OnAnimationProgress += sender => Invalidate(); - - TabStopChanged += (sender, e) => TabStop = true; - - CheckedChanged += (sender, args) => - { - if (Ripple) - _checkAM.StartNewAnimation(Checked ? AnimationDirection.In : AnimationDirection.Out); - }; - - SizeChanged += OnSizeChanged; - - Ripple = true; - MouseLocation = new Point(-1, -1); - } - - private void OnSizeChanged(object sender, EventArgs eventArgs) - { - _boxOffset = Height / 2 - (int)(RADIOBUTTON_SIZE / 2); - _radioButtonBounds = new Rectangle(_boxOffset, _boxOffset, RADIOBUTTON_SIZE, RADIOBUTTON_SIZE); - } - - public override Size GetPreferredSize(Size proposedSize) - { - Size strSize; - - using (NativeTextRenderer NativeText = new NativeTextRenderer(CreateGraphics())) - { - strSize = NativeText.MeasureLogString(Text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1)); - } - - int w = _boxOffset + TEXT_OFFSET + strSize.Width; - return Ripple ? new Size(w, HEIGHT_RIPPLE) : new Size(w, HEIGHT_NO_RIPPLE); - } - - protected override void OnPaint(PaintEventArgs pevent) - { - Graphics g = pevent.Graphics; - g.SmoothingMode = SmoothingMode.AntiAlias; - g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; - - // clear the control - g.Clear(Parent.BackColor); - - int RADIOBUTTON_CENTER = _boxOffset + RADIOBUTTON_SIZE_HALF; - Point animationSource = new Point(RADIOBUTTON_CENTER, RADIOBUTTON_CENTER); - - double animationProgress = _checkAM.GetProgress(); - - int colorAlpha = Enabled ? (int)(animationProgress * 255.0) : SkinManager.CheckBoxOffDisabledColor.A; - int backgroundAlpha = Enabled ? (int)(SkinManager.CheckboxOffColor.A * (1.0 - animationProgress)) : SkinManager.CheckBoxOffDisabledColor.A; - float animationSize = (float)(animationProgress * 9f); - float animationSizeHalf = animationSize / 2; - int rippleHeight = (HEIGHT_RIPPLE % 2 == 0) ? HEIGHT_RIPPLE - 3 : HEIGHT_RIPPLE - 2; - - Color RadioColor = Color.FromArgb(colorAlpha, Enabled ? SkinManager.ColorScheme.AccentColor : SkinManager.CheckBoxOffDisabledColor); - - // draw hover animation - if (Ripple) - { - double animationValue = _hoverAM.GetProgress(); - int rippleSize = (int)(rippleHeight * (0.7 + (0.3 * animationValue))); - - using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)(40 * animationValue), - !Checked ? (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? Color.Black : Color.White) : RadioColor))) - { - g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize - 1, rippleSize - 1)); - } - } - - // draw ripple animation - if (Ripple && _rippleAM.IsAnimating()) - { - for (int i = 0; i < _rippleAM.GetAnimationCount(); i++) - { - double animationValue = _rippleAM.GetProgress(i); - int rippleSize = (_rippleAM.GetDirection(i) == AnimationDirection.InOutIn) ? (int)(rippleHeight * (0.7 + (0.3 * animationValue))) : rippleHeight; - - using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)((animationValue * 40)), !Checked ? (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? Color.Black : Color.White) : RadioColor))) - { - g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize - 1, rippleSize - 1)); - } - } - } - - // draw radiobutton circle - using (Pen pen = new Pen(DrawHelper.BlendColor(Parent.BackColor, Enabled ? SkinManager.CheckboxOffColor : SkinManager.CheckBoxOffDisabledColor, backgroundAlpha), 2)) - { - g.DrawEllipse(pen, new Rectangle(_boxOffset, _boxOffset, RADIOBUTTON_SIZE, RADIOBUTTON_SIZE)); - } - - if (Enabled) - { - using (Pen pen = new Pen(RadioColor, 2)) - { - g.DrawEllipse(pen, new Rectangle(_boxOffset, _boxOffset, RADIOBUTTON_SIZE, RADIOBUTTON_SIZE)); - } - } - - if (Checked) - { - using (SolidBrush brush = new SolidBrush(RadioColor)) - { - g.FillEllipse(brush, new RectangleF(RADIOBUTTON_CENTER - animationSizeHalf, RADIOBUTTON_CENTER - animationSizeHalf, animationSize, animationSize)); - } - } - - // Text - using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) - { - Rectangle textLocation = new Rectangle(_boxOffset + TEXT_OFFSET, 0, Width, Height); - NativeText.DrawTransparentText(Text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1), - Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor, - textLocation.Location, - textLocation.Size, - NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); - } - } - - private bool IsMouseInCheckArea() - { - return ClientRectangle.Contains(MouseLocation); - } - - private bool hovered = false; - - protected override void OnCreateControl() - { - base.OnCreateControl(); - - if (DesignMode) return; - - MouseState = MouseState.OUT; - - GotFocus += (sender, AddingNewEventArgs) => - { - if (Ripple && !hovered) - { - _hoverAM.StartNewAnimation(AnimationDirection.In, new object[] { Checked }); - hovered = true; - } - }; - - LostFocus += (sender, args) => - { - if (Ripple && hovered) - { - _hoverAM.StartNewAnimation(AnimationDirection.Out, new object[] { Checked }); - hovered = false; - } - }; - - MouseEnter += (sender, args) => - { - MouseState = MouseState.HOVER; - //if (Ripple && !hovered) - //{ - // _hoverAM.StartNewAnimation(AnimationDirection.In, new object[] { Checked }); - // hovered = true; - //} - }; - - MouseLeave += (sender, args) => - { - MouseLocation = new Point(-1, -1); - MouseState = MouseState.OUT; - //if (Ripple && hovered) - //{ - // _hoverAM.StartNewAnimation(AnimationDirection.Out, new object[] { Checked }); - // hovered = false; - //} - }; - - MouseDown += (sender, args) => - { - MouseState = MouseState.DOWN; - if (Ripple) - { - _rippleAM.SecondaryIncrement = 0; - _rippleAM.StartNewAnimation(AnimationDirection.InOutIn, new object[] { Checked }); - } - }; - - KeyDown += (sender, args) => - { - if (Ripple && (args.KeyCode == Keys.Space) && _rippleAM.GetAnimationCount() == 0) - { - _rippleAM.SecondaryIncrement = 0; - _rippleAM.StartNewAnimation(AnimationDirection.InOutIn, new object[] { Checked }); - } - }; - - MouseUp += (sender, args) => - { - if (Ripple) - { - MouseState = MouseState.HOVER; - _rippleAM.SecondaryIncrement = 0.08; - _hoverAM.StartNewAnimation(AnimationDirection.Out, new object[] { Checked }); - hovered = false; - } - }; - - KeyUp += (sender, args) => - { - if (Ripple && (args.KeyCode == Keys.Space)) - { - MouseState = MouseState.HOVER; - _rippleAM.SecondaryIncrement = 0.08; - } - }; - - MouseMove += (sender, args) => - { - MouseLocation = args.Location; - Cursor = IsMouseInCheckArea() ? Cursors.Hand : Cursors.Default; - }; - } - } +namespace MaterialSkin.Controls +{ + using MaterialSkin.Animations; + using System; + using System.ComponentModel; + using System.Drawing; + using System.Drawing.Drawing2D; + using System.Drawing.Text; + using System.Windows.Forms; + + public class MaterialRadioButton : RadioButton, IMaterialControl + { + [Browsable(false)] + public int Depth { get; set; } + + [Browsable(false)] + public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; + + [Browsable(false)] + public MouseState MouseState { get; set; } + + [Browsable(false)] + public Point MouseLocation { get; set; } + + private bool ripple; + + [Category("Behavior")] + public bool Ripple + { + get { return ripple; } + set + { + ripple = value; + AutoSize = AutoSize; //Make AutoSize directly set the bounds. + + if (value) + { + Margin = new Padding(0); + } + + Invalidate(); + } + } + + // animation managers + private readonly AnimationManager _checkAM; + + private readonly AnimationManager _rippleAM; + private readonly AnimationManager _hoverAM; + + // size related variables which should be recalculated onsizechanged + private Rectangle _radioButtonBounds; + + private int _boxOffset; + + // size constants + private const int HEIGHT_RIPPLE = 37; + + private const int HEIGHT_NO_RIPPLE = 20; + private const int RADIOBUTTON_SIZE = 18; + private const int RADIOBUTTON_SIZE_HALF = RADIOBUTTON_SIZE / 2; + private const int RADIOBUTTON_OUTER_CIRCLE_WIDTH = 2; + private const int RADIOBUTTON_INNER_CIRCLE_SIZE = RADIOBUTTON_SIZE - (2 * RADIOBUTTON_OUTER_CIRCLE_WIDTH); + private const int TEXT_OFFSET = 26; + + public MaterialRadioButton() + { + SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer, true); + + _checkAM = new AnimationManager + { + AnimationType = AnimationType.EaseInOut, + Increment = 0.06 + }; + _hoverAM = new AnimationManager(true) + { + AnimationType = AnimationType.Linear, + Increment = 0.10 + }; + _rippleAM = new AnimationManager(false) + { + AnimationType = AnimationType.Linear, + Increment = 0.10, + SecondaryIncrement = 0.08 + }; + + _checkAM.OnAnimationProgress += sender => Invalidate(); + _hoverAM.OnAnimationProgress += sender => Invalidate(); + _rippleAM.OnAnimationProgress += sender => Invalidate(); + + TabStopChanged += (sender, e) => TabStop = true; + + CheckedChanged += (sender, args) => + { + if (Ripple) + _checkAM.StartNewAnimation(Checked ? AnimationDirection.In : AnimationDirection.Out); + }; + + SizeChanged += OnSizeChanged; + + Ripple = true; + MouseLocation = new Point(-1, -1); + } + + private void OnSizeChanged(object sender, EventArgs eventArgs) + { + _boxOffset = Height / 2 - (int)(RADIOBUTTON_SIZE / 2); + _radioButtonBounds = new Rectangle(_boxOffset, _boxOffset, RADIOBUTTON_SIZE, RADIOBUTTON_SIZE); + } + + public override Size GetPreferredSize(Size proposedSize) + { + Size strSize; + + using (NativeTextRenderer NativeText = new NativeTextRenderer(CreateGraphics())) + { + strSize = NativeText.MeasureLogString(Text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1, RightToLeft)); + } + + int w = _boxOffset + TEXT_OFFSET + strSize.Width; + return Ripple ? new Size(w, HEIGHT_RIPPLE) : new Size(w, HEIGHT_NO_RIPPLE); + } + + protected override void OnPaint(PaintEventArgs pevent) + { + Graphics g = pevent.Graphics; + g.SmoothingMode = SmoothingMode.AntiAlias; + g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; + + // clear the control + g.Clear(Parent.BackColor); + + int RADIOBUTTON_CENTER_X = RightToLeft == RightToLeft.Yes ? Width - (_boxOffset + RADIOBUTTON_SIZE_HALF) : _boxOffset + RADIOBUTTON_SIZE_HALF; + int RADIOBUTTON_CENTER_Y = _boxOffset + RADIOBUTTON_SIZE_HALF; + Point animationSource = new Point(RADIOBUTTON_CENTER_X, RADIOBUTTON_CENTER_Y); + + double animationProgress = _checkAM.GetProgress(); + + int colorAlpha = Enabled ? (int)(animationProgress * 255.0) : SkinManager.CheckBoxOffDisabledColor.A; + int backgroundAlpha = Enabled ? (int)(SkinManager.CheckboxOffColor.A * (1.0 - animationProgress)) : SkinManager.CheckBoxOffDisabledColor.A; + float animationSize = (float)(animationProgress * 9f); + float animationSizeHalf = animationSize / 2; + int rippleHeight = (HEIGHT_RIPPLE % 2 == 0) ? HEIGHT_RIPPLE - 3 : HEIGHT_RIPPLE - 2; + + Color RadioColor = Color.FromArgb(colorAlpha, Enabled ? SkinManager.ColorScheme.AccentColor : SkinManager.CheckBoxOffDisabledColor); + + // draw hover animation + if (Ripple) + { + double animationValue = _hoverAM.GetProgress(); + int rippleSize = (int)(rippleHeight * (0.7 + (0.3 * animationValue))); + + using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)(40 * animationValue), + !Checked ? (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? Color.Black : Color.White) : RadioColor))) + { + g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize - 1, rippleSize - 1)); + } + } + + // draw ripple animation + if (Ripple && _rippleAM.IsAnimating()) + { + for (int i = 0; i < _rippleAM.GetAnimationCount(); i++) + { + double animationValue = _rippleAM.GetProgress(i); + int rippleSize = (_rippleAM.GetDirection(i) == AnimationDirection.InOutIn) ? (int)(rippleHeight * (0.7 + (0.3 * animationValue))) : rippleHeight; + + using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)((animationValue * 40)), !Checked ? (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? Color.Black : Color.White) : RadioColor))) + { + g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize - 1, rippleSize - 1)); + } + } + } + + // draw radiobutton circle + using (Pen pen = new Pen(DrawHelper.BlendColor(Parent.BackColor, Enabled ? SkinManager.CheckboxOffColor : SkinManager.CheckBoxOffDisabledColor, backgroundAlpha), 2)) + { + var x = RightToLeft == RightToLeft.Yes ? Width - RADIOBUTTON_SIZE - _boxOffset : _boxOffset; + g.DrawEllipse(pen, new Rectangle(x, _boxOffset, RADIOBUTTON_SIZE, RADIOBUTTON_SIZE)); + } + + if (Enabled) + { + using (Pen pen = new Pen(RadioColor, 2)) + { + var x = RightToLeft == RightToLeft.Yes ? Width - RADIOBUTTON_SIZE - _boxOffset : _boxOffset; + g.DrawEllipse(pen, new Rectangle(x, _boxOffset, RADIOBUTTON_SIZE, RADIOBUTTON_SIZE)); + } + } + + if (Checked) + { + using (SolidBrush brush = new SolidBrush(RadioColor)) + { + g.FillEllipse(brush, new RectangleF(RADIOBUTTON_CENTER_X - animationSizeHalf, RADIOBUTTON_CENTER_Y - animationSizeHalf, animationSize, animationSize)); + } + } + + // Text + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + var x = RightToLeft == RightToLeft.Yes ? 0 : _boxOffset + TEXT_OFFSET; + var w = RightToLeft == RightToLeft.Yes ? Width - (_boxOffset + TEXT_OFFSET) : Width; + Rectangle textLocation = new Rectangle(x, 0, Width, Height); + NativeText.DrawTransparentText(Text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1, RightToLeft), + Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor, + textLocation.Location, + textLocation.Size, + NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); + } + } + + private bool IsMouseInCheckArea() + { + return ClientRectangle.Contains(MouseLocation); + } + + private bool hovered = false; + + protected override void OnCreateControl() + { + base.OnCreateControl(); + + if (DesignMode) return; + + MouseState = MouseState.OUT; + + GotFocus += (sender, AddingNewEventArgs) => + { + if (Ripple && !hovered) + { + _hoverAM.StartNewAnimation(AnimationDirection.In, new object[] { Checked }); + hovered = true; + } + }; + + LostFocus += (sender, args) => + { + if (Ripple && hovered) + { + _hoverAM.StartNewAnimation(AnimationDirection.Out, new object[] { Checked }); + hovered = false; + } + }; + + MouseEnter += (sender, args) => + { + MouseState = MouseState.HOVER; + //if (Ripple && !hovered) + //{ + // _hoverAM.StartNewAnimation(AnimationDirection.In, new object[] { Checked }); + // hovered = true; + //} + }; + + MouseLeave += (sender, args) => + { + MouseLocation = new Point(-1, -1); + MouseState = MouseState.OUT; + //if (Ripple && hovered) + //{ + // _hoverAM.StartNewAnimation(AnimationDirection.Out, new object[] { Checked }); + // hovered = false; + //} + }; + + MouseDown += (sender, args) => + { + MouseState = MouseState.DOWN; + if (Ripple) + { + _rippleAM.SecondaryIncrement = 0; + _rippleAM.StartNewAnimation(AnimationDirection.InOutIn, new object[] { Checked }); + } + }; + + KeyDown += (sender, args) => + { + if (Ripple && (args.KeyCode == Keys.Space) && _rippleAM.GetAnimationCount() == 0) + { + _rippleAM.SecondaryIncrement = 0; + _rippleAM.StartNewAnimation(AnimationDirection.InOutIn, new object[] { Checked }); + } + }; + + MouseUp += (sender, args) => + { + if (Ripple) + { + MouseState = MouseState.HOVER; + _rippleAM.SecondaryIncrement = 0.08; + _hoverAM.StartNewAnimation(AnimationDirection.Out, new object[] { Checked }); + hovered = false; + } + }; + + KeyUp += (sender, args) => + { + if (Ripple && (args.KeyCode == Keys.Space)) + { + MouseState = MouseState.HOVER; + _rippleAM.SecondaryIncrement = 0.08; + } + }; + + MouseMove += (sender, args) => + { + MouseLocation = args.Location; + Cursor = IsMouseInCheckArea() ? Cursors.Hand : Cursors.Default; + }; + } + } } \ No newline at end of file diff --git a/MaterialSkin/Controls/MaterialScrollBar.cs b/MaterialSkin/Controls/MaterialScrollBar.cs new file mode 100644 index 00000000..cc30a82b --- /dev/null +++ b/MaterialSkin/Controls/MaterialScrollBar.cs @@ -0,0 +1,1025 @@ + +namespace MaterialSkin.Controls +{ + + using System; + using System.ComponentModel; + using System.Diagnostics; + using System.Drawing; + using System.Security; + using System.Windows.Forms; + using System.Runtime.InteropServices; + + public enum MaterialScrollOrientation + { + Horizontal, + Vertical + } + + [DefaultEvent("Scroll")] + [DefaultProperty("Value")] + public class MaterialScrollBar : Control, IMaterialControl + { + + [Browsable(false)] + public int Depth { get; set; } + [Browsable(false)] + public MaterialSkinManager SkinManager { get { return MaterialSkinManager.Instance; } } + [Browsable(false)] + public MouseState MouseState { get; set; } + + private bool useAccentColor; + + [Category("Material Skin"), DefaultValue(false), DisplayName("Use Accent Color")] + public bool UseAccentColor + { + get { return useAccentColor; } + set { useAccentColor = value; Invalidate(); } + } + + [DllImport("user32.dll")] + public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); + + internal const int SCROLLBAR_DEFAULT_SIZE = 10; + + #region Events + + public event ScrollEventHandler Scroll; + + private void OnScroll(ScrollEventType type, int oldValue, int newValue, ScrollOrientation orientation) + { + if (oldValue != newValue) + { + if (ValueChanged != null) + { + ValueChanged(this, curValue); + } + } + + if (Scroll == null) + { + return; + } + + if (orientation == ScrollOrientation.HorizontalScroll) + { + if (type != ScrollEventType.EndScroll && isFirstScrollEventHorizontal) + { + type = ScrollEventType.First; + } + else if (!isFirstScrollEventHorizontal && type == ScrollEventType.EndScroll) + { + isFirstScrollEventHorizontal = true; + } + } + else + { + if (type != ScrollEventType.EndScroll && isFirstScrollEventVertical) + { + type = ScrollEventType.First; + } + else if (!isFirstScrollEventHorizontal && type == ScrollEventType.EndScroll) + { + isFirstScrollEventVertical = true; + } + } + + Scroll(this, new ScrollEventArgs(type, oldValue, newValue, orientation)); + } + + #endregion + + #region Properties + + private bool isFirstScrollEventVertical = true; + private bool isFirstScrollEventHorizontal = true; + + private bool inUpdate; + + private Rectangle clickedBarRectangle; + private Rectangle thumbRectangle; + + private bool topBarClicked; + private bool bottomBarClicked; + private bool thumbClicked; + + private int thumbWidth = 6; + private int thumbHeight; + + private int thumbBottomLimitBottom; + private int thumbBottomLimitTop; + private int thumbTopLimit; + private int thumbPosition; + + public const int WM_SETREDRAW = 0xb; + + private int trackPosition; + + private readonly Timer progressTimer = new Timer(); + + private int mouseWheelBarPartitions = 10; + [DefaultValue(10)] + public int MouseWheelBarPartitions + { + get { return mouseWheelBarPartitions; } + set + { + if (value > 0) + { + mouseWheelBarPartitions = value; + } + else + { + throw new ArgumentOutOfRangeException("value", "MouseWheelBarPartitions has to be greather than zero"); + } + } + } + + private bool isHovered; + //private bool isPressed; + + private bool useBarColor = false; + [DefaultValue(false)] + public bool UseBarColor + { + get { return useBarColor; } + set { useBarColor = value; } + } + + [DefaultValue(SCROLLBAR_DEFAULT_SIZE)] + public int ScrollbarSize + { + get { return Orientation == MaterialScrollOrientation.Vertical ? Width : Height; } + set + { + if (Orientation == MaterialScrollOrientation.Vertical) + Width = value; + else + Height = value; + } + } + + private bool highlightOnWheel = false; + [DefaultValue(false)] + public bool HighlightOnWheel + { + get { return highlightOnWheel; } + set { highlightOnWheel = value; } + } + + private MaterialScrollOrientation MaterialOrientation = MaterialScrollOrientation.Vertical; + private ScrollOrientation scrollOrientation = ScrollOrientation.VerticalScroll; + + public MaterialScrollOrientation Orientation + { + get { return MaterialOrientation; } + set + { + if (value == MaterialOrientation) return; + MaterialOrientation = value; + scrollOrientation = value == MaterialScrollOrientation.Vertical ? ScrollOrientation.VerticalScroll : ScrollOrientation.HorizontalScroll; + Size = new Size(Height, Width); + SetupScrollBar(); + } + } + + private int minimum = 0; + [DefaultValue(0)] + public int Minimum + { + get { return minimum; } + set + { + if (minimum == value || value < 0 || value >= maximum) + { + return; + } + + minimum = value; + if (curValue < value) + { + curValue = value; + } + + if (largeChange > (maximum - minimum)) + { + largeChange = maximum - minimum; + } + + SetupScrollBar(); + + if (curValue < value) + { + dontUpdateColor = true; + Value = value; + } + else + { + ChangeThumbPosition(GetThumbPosition()); + Refresh(); + } + } + } + + private int maximum = 100; + [DefaultValue(100)] + public int Maximum + { + get { return maximum; } + set + { + if (value == maximum || value < 1 || value <= minimum) + { + return; + } + + maximum = value; + if (largeChange > (maximum - minimum)) + { + largeChange = maximum - minimum; + } + + SetupScrollBar(); + + if (curValue > value) + { + dontUpdateColor = true; + Value = maximum; + } + else + { + ChangeThumbPosition(GetThumbPosition()); + Refresh(); + } + } + } + + private int smallChange = 1; + [DefaultValue(1)] + public int SmallChange + { + get { return smallChange; } + set + { + if (value == smallChange || value < 1 || value >= largeChange) + { + return; + } + + smallChange = value; + SetupScrollBar(); + } + } + + private int largeChange = 10; + [DefaultValue(10)] + public int LargeChange + { + get { return largeChange; } + set + { + if (value == largeChange || value < smallChange || value < 2) + { + return; + } + + if (value > (maximum - minimum)) + { + largeChange = maximum - minimum; + } + else + { + largeChange = value; + } + + SetupScrollBar(); + } + } + + #region ValueChangeEvent + // Declare a delegate + public delegate void ScrollValueChangedDelegate(object sender, int newValue); + + public event ScrollValueChangedDelegate ValueChanged; + #endregion + + private bool dontUpdateColor = false; + + private int curValue = 0; + [DefaultValue(0)] + [Browsable(false)] + public int Value + { + get { return curValue; } + + set + { + if (curValue == value || value < minimum || value > maximum) + { + return; + } + + curValue = value; + + ChangeThumbPosition(GetThumbPosition()); + + OnScroll(ScrollEventType.ThumbPosition, -1, value, scrollOrientation); + + if (!dontUpdateColor && highlightOnWheel) + { + if (!isHovered) + isHovered = true; + + if (autoHoverTimer == null) + { + autoHoverTimer = new Timer(); + autoHoverTimer.Interval = 1000; + autoHoverTimer.Tick += new EventHandler(autoHoverTimer_Tick); + autoHoverTimer.Start(); + } + else + { + autoHoverTimer.Stop(); + autoHoverTimer.Start(); + } + } + else + { + dontUpdateColor = false; + } + + Refresh(); + } + } + + private void autoHoverTimer_Tick(object sender, EventArgs e) + { + isHovered = false; + Invalidate(); + autoHoverTimer.Stop(); + } + + private Timer autoHoverTimer = null; + + #endregion + + public MaterialScrollBar() + { + SetStyle(ControlStyles.OptimizedDoubleBuffer | + ControlStyles.OptimizedDoubleBuffer | + ControlStyles.ResizeRedraw | + ControlStyles.Selectable | +// ControlStyles.AllPaintingInWmPaint | + ControlStyles.SupportsTransparentBackColor | + ControlStyles.UserPaint, true); + + Width = SCROLLBAR_DEFAULT_SIZE; + Height = 200; + + UseAccentColor = false; + + SetupScrollBar(); + + progressTimer.Interval = 20; + progressTimer.Tick += ProgressTimerTick; + } + + public MaterialScrollBar(MaterialScrollOrientation orientation) + : this() + { + Orientation = orientation; + } + + public MaterialScrollBar(MaterialScrollOrientation orientation, int width) + : this(orientation) + { + Width = width; + } + + public bool HitTest(Point point) + { + return thumbRectangle.Contains(point); + } + + #region Update Methods + + [SecuritySafeCritical] + public void BeginUpdate() + { + SendMessage(Handle, WM_SETREDRAW, 0, 0); + inUpdate = true; + } + + [SecuritySafeCritical] + public void EndUpdate() + { + SendMessage(Handle, WM_SETREDRAW, 1, 0); + inUpdate = false; + SetupScrollBar(); + Refresh(); + } + + #endregion + + #region Paint Methods + + + protected override void OnPaintBackground(PaintEventArgs e) + { + try + { + e.Graphics.Clear(Parent.BackColor); + } + catch (Exception ex) + { + Trace.WriteLine(ex); + Invalidate(); + } + } + + protected override void OnPaint(PaintEventArgs e) + { + DrawScrollBar(e.Graphics, MaterialSkinManager.Instance.CardsColor, SkinManager.SwitchOffTrackColor, useAccentColor ? MaterialSkinManager.Instance.ColorScheme.AccentColor : MaterialSkinManager.Instance.ColorScheme.PrimaryColor); + } + + private void DrawScrollBar(Graphics g, Color backColor, Color thumbColor, Color barColor) + { + if (useBarColor) + { + using (SolidBrush b = new SolidBrush(barColor)) + { + g.FillRectangle(b, ClientRectangle); + } + } + + using (SolidBrush b = new SolidBrush(backColor)) + { + Rectangle thumbRect = new Rectangle(thumbRectangle.X - 1, thumbRectangle.Y - 1, thumbRectangle.Width + 2, thumbRectangle.Height + 2); + g.FillRectangle(b, thumbRect); + } + + using (SolidBrush b = new SolidBrush(isHovered ? barColor : thumbColor)) + { + g.FillRectangle(b, thumbRectangle); + } + } + + #endregion + + #region Focus Methods + + protected override void OnGotFocus(EventArgs e) + { + Invalidate(); + + base.OnGotFocus(e); + } + + protected override void OnLostFocus(EventArgs e) + { + isHovered = false; + //isPressed = false; + Invalidate(); + + base.OnLostFocus(e); + } + + protected override void OnEnter(EventArgs e) + { + Invalidate(); + + base.OnEnter(e); + } + + protected override void OnLeave(EventArgs e) + { + isHovered = false; + //isPressed = false; + Invalidate(); + + base.OnLeave(e); + } + + #endregion + + #region Mouse Methods + + protected override void OnMouseWheel(MouseEventArgs e) + { + base.OnMouseWheel(e); + + int v = e.Delta / 120 * (maximum - minimum) / mouseWheelBarPartitions; + + if (Orientation == MaterialScrollOrientation.Vertical) + { + Value -= v; + } + else + { + Value += v; + } + } + + protected override void OnMouseDown(MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + //isPressed = true; + Invalidate(); + } + + base.OnMouseDown(e); + + Focus(); + + if (e.Button == MouseButtons.Left) + { + + Point mouseLocation = e.Location; + + if (thumbRectangle.Contains(mouseLocation)) + { + thumbClicked = true; + thumbPosition = MaterialOrientation == MaterialScrollOrientation.Vertical ? mouseLocation.Y - thumbRectangle.Y : mouseLocation.X - thumbRectangle.X; + + Invalidate(thumbRectangle); + } + else + { + trackPosition = MaterialOrientation == MaterialScrollOrientation.Vertical ? mouseLocation.Y : mouseLocation.X; + + if (trackPosition < (MaterialOrientation == MaterialScrollOrientation.Vertical ? thumbRectangle.Y : thumbRectangle.X)) + { + topBarClicked = true; + } + else + { + bottomBarClicked = true; + } + + ProgressThumb(true); + } + } + else if (e.Button == MouseButtons.Right) + { + trackPosition = MaterialOrientation == MaterialScrollOrientation.Vertical ? e.Y : e.X; + } + } + + protected override void OnMouseUp(MouseEventArgs e) + { + //isPressed = false; + + base.OnMouseUp(e); + + if (e.Button == MouseButtons.Left) + { + if (thumbClicked) + { + thumbClicked = false; + OnScroll(ScrollEventType.EndScroll, -1, curValue, scrollOrientation); + } + else if (topBarClicked) + { + topBarClicked = false; + StopTimer(); + } + else if (bottomBarClicked) + { + bottomBarClicked = false; + StopTimer(); + } + + Invalidate(); + } + } + + protected override void OnMouseEnter(EventArgs e) + { + isHovered = true; + Invalidate(); + + base.OnMouseEnter(e); + } + + protected override void OnMouseLeave(EventArgs e) + { + isHovered = false; + Invalidate(); + + base.OnMouseLeave(e); + + ResetScrollStatus(); + } + + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + + if (e.Button == MouseButtons.Left) + { + if (thumbClicked) + { + int oldScrollValue = curValue; + + int pos = MaterialOrientation == MaterialScrollOrientation.Vertical ? e.Location.Y : e.Location.X; + int thumbSize = MaterialOrientation == MaterialScrollOrientation.Vertical ? (pos / Height) / thumbHeight : (pos / Width) / thumbWidth; + + if (pos <= (thumbTopLimit + thumbPosition)) + { + ChangeThumbPosition(thumbTopLimit); + curValue = minimum; + Invalidate(); + } + else if (pos >= (thumbBottomLimitTop + thumbPosition)) + { + ChangeThumbPosition(thumbBottomLimitTop); + curValue = maximum; + Invalidate(); + } + else + { + ChangeThumbPosition(pos - thumbPosition); + + int pixelRange, thumbPos; + + if (Orientation == MaterialScrollOrientation.Vertical) + { + pixelRange = Height - thumbSize; + thumbPos = thumbRectangle.Y; + } + else + { + pixelRange = Width - thumbSize; + thumbPos = thumbRectangle.X; + } + + float perc = 0f; + + if (pixelRange != 0) + { + perc = (thumbPos) / (float)pixelRange; + } + + curValue = Convert.ToInt32((perc * (maximum - minimum)) + minimum); + } + + if (oldScrollValue != curValue) + { + OnScroll(ScrollEventType.ThumbTrack, oldScrollValue, curValue, scrollOrientation); + Refresh(); + } + } + } + else if (!ClientRectangle.Contains(e.Location)) + { + ResetScrollStatus(); + } + else if (e.Button == MouseButtons.None) + { + if (thumbRectangle.Contains(e.Location)) + { + Invalidate(thumbRectangle); + } + else if (ClientRectangle.Contains(e.Location)) + { + Invalidate(); + } + } + } + + #endregion + + #region Keyboard Methods + + protected override void OnKeyDown(KeyEventArgs e) + { + isHovered = true; + //isPressed = true; + Invalidate(); + + base.OnKeyDown(e); + } + + protected override void OnKeyUp(KeyEventArgs e) + { + isHovered = false; + //isPressed = false; + Invalidate(); + + base.OnKeyUp(e); + } + + #endregion + + #region Management Methods + + protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) + { + base.SetBoundsCore(x, y, width, height, specified); + + if (DesignMode) + { + SetupScrollBar(); + } + } + + protected override void OnSizeChanged(EventArgs e) + { + base.OnSizeChanged(e); + SetupScrollBar(); + } + + protected override bool ProcessDialogKey(Keys keyData) + { + Keys keyUp = Keys.Up; + Keys keyDown = Keys.Down; + + if (Orientation == MaterialScrollOrientation.Horizontal) + { + keyUp = Keys.Left; + keyDown = Keys.Right; + } + + if (keyData == keyUp) + { + Value -= smallChange; + + return true; + } + + if (keyData == keyDown) + { + Value += smallChange; + + return true; + } + + if (keyData == Keys.PageUp) + { + Value = GetValue(false, true); + + return true; + } + + if (keyData == Keys.PageDown) + { + if (curValue + largeChange > maximum) + { + Value = maximum; + } + else + { + Value += largeChange; + } + + return true; + } + + if (keyData == Keys.Home) + { + Value = minimum; + + return true; + } + + if (keyData == Keys.End) + { + Value = maximum; + + return true; + } + + return base.ProcessDialogKey(keyData); + } + + protected override void OnEnabledChanged(EventArgs e) + { + base.OnEnabledChanged(e); + Invalidate(); + } + + private void SetupScrollBar() + { + if (inUpdate) return; + + if (Orientation == MaterialScrollOrientation.Vertical) + { + thumbWidth = Width > 0 ? Width : 10; + thumbHeight = GetThumbSize(); + + clickedBarRectangle = ClientRectangle; + clickedBarRectangle.Inflate(-1, -1); + + thumbRectangle = new Rectangle(ClientRectangle.X, ClientRectangle.Y, thumbWidth, thumbHeight); + + thumbPosition = thumbRectangle.Height / 2; + thumbBottomLimitBottom = ClientRectangle.Bottom; + thumbBottomLimitTop = thumbBottomLimitBottom - thumbRectangle.Height; + thumbTopLimit = ClientRectangle.Y; + } + else + { + thumbHeight = Height > 0 ? Height : 10; + thumbWidth = GetThumbSize(); + + clickedBarRectangle = ClientRectangle; + clickedBarRectangle.Inflate(-1, -1); + + thumbRectangle = new Rectangle(ClientRectangle.X, ClientRectangle.Y, thumbWidth, thumbHeight); + + thumbPosition = thumbRectangle.Width / 2; + thumbBottomLimitBottom = ClientRectangle.Right; + thumbBottomLimitTop = thumbBottomLimitBottom - thumbRectangle.Width; + thumbTopLimit = ClientRectangle.X; + } + + ChangeThumbPosition(GetThumbPosition()); + + Refresh(); + } + + private void ResetScrollStatus() + { + bottomBarClicked = topBarClicked = false; + + StopTimer(); + Refresh(); + } + + private void ProgressTimerTick(object sender, EventArgs e) + { + ProgressThumb(true); + } + + private int GetValue(bool smallIncrement, bool up) + { + int newValue; + + if (up) + { + newValue = curValue - (smallIncrement ? smallChange : largeChange); + + if (newValue < minimum) + { + newValue = minimum; + } + } + else + { + newValue = curValue + (smallIncrement ? smallChange : largeChange); + + if (newValue > maximum) + { + newValue = maximum; + } + } + + return newValue; + } + + private int GetThumbPosition() + { + int pixelRange; + + if (thumbHeight == 0 || thumbWidth == 0) + { + return 0; + } + + int thumbSize = MaterialOrientation == MaterialScrollOrientation.Vertical ? (thumbPosition / Height) / thumbHeight : (thumbPosition / Width) / thumbWidth; + + if (Orientation == MaterialScrollOrientation.Vertical) + { + pixelRange = Height - thumbSize; + } + else + { + pixelRange = Width - thumbSize; + } + + int realRange = maximum - minimum; + float perc = 0f; + + if (realRange != 0) + { + perc = (curValue - (float)minimum) / realRange; + } + + return Math.Max(thumbTopLimit, Math.Min(thumbBottomLimitTop, Convert.ToInt32((perc * pixelRange)))); + } + + private int GetThumbSize() + { + int trackSize = + MaterialOrientation == MaterialScrollOrientation.Vertical ? + Height : Width; + + if (maximum == 0 || largeChange == 0) + { + return trackSize; + } + + float newThumbSize = (largeChange * (float)trackSize) / maximum; + + return Convert.ToInt32(Math.Min(trackSize, Math.Max(newThumbSize, 10f))); + } + + private void EnableTimer() + { + if (!progressTimer.Enabled) + { + progressTimer.Interval = 600; + progressTimer.Start(); + } + else + { + progressTimer.Interval = 10; + } + } + + private void StopTimer() + { + progressTimer.Stop(); + } + + private void ChangeThumbPosition(int position) + { + if (Orientation == MaterialScrollOrientation.Vertical) + { + thumbRectangle.Y = position; + } + else + { + thumbRectangle.X = position; + } + } + + private void ProgressThumb(bool enableTimer) + { + int scrollOldValue = curValue; + ScrollEventType type = ScrollEventType.First; + int thumbSize, thumbPos; + + if (Orientation == MaterialScrollOrientation.Vertical) + { + thumbPos = thumbRectangle.Y; + thumbSize = thumbRectangle.Height; + } + else + { + thumbPos = thumbRectangle.X; + thumbSize = thumbRectangle.Width; + } + + if ((bottomBarClicked && (thumbPos + thumbSize) < trackPosition)) + { + type = ScrollEventType.LargeIncrement; + + curValue = GetValue(false, false); + + if (curValue == maximum) + { + ChangeThumbPosition(thumbBottomLimitTop); + + type = ScrollEventType.Last; + } + else + { + ChangeThumbPosition(Math.Min(thumbBottomLimitTop, GetThumbPosition())); + } + } + else if ((topBarClicked && thumbPos > trackPosition)) + { + type = ScrollEventType.LargeDecrement; + + curValue = GetValue(false, true); + + if (curValue == minimum) + { + ChangeThumbPosition(thumbTopLimit); + + type = ScrollEventType.First; + } + else + { + ChangeThumbPosition(Math.Max(thumbTopLimit, GetThumbPosition())); + } + } + + if (scrollOldValue != curValue) + { + OnScroll(type, scrollOldValue, curValue, scrollOrientation); + + Invalidate(); + + if (enableTimer) + { + EnableTimer(); + } + } + } + + #endregion + } +} diff --git a/MaterialSkin/Controls/MaterialSlider.cs b/MaterialSkin/Controls/MaterialSlider.cs new file mode 100644 index 00000000..a9ca2c52 --- /dev/null +++ b/MaterialSkin/Controls/MaterialSlider.cs @@ -0,0 +1,476 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Windows.Forms; + +namespace MaterialSkin.Controls +{ + public class MaterialSlider : Control, IMaterialControl + { + #region "Private members" + private bool _mousePressed; + private int _mouseX; + //private int _indicatorSize; + private bool _hovered = false; + private Rectangle _indicatorRectangle; + private Rectangle _indicatorRectangleNormal; + private Rectangle _indicatorRectanglePressed; + private Rectangle _textRectangle; + private Rectangle _valueRectangle; + private Rectangle _sliderRectangle; + + private const int _activeTrack = 6; + private const int _inactiveTrack = 4; + private const int _thumbRadius = 20; + private const int _thumbRadiusHoverPressed = 40; + + + #endregion + + #region "Public Properties" + [Browsable(false)] + public int Depth { get; set; } + [Browsable(false)] + public MaterialSkinManager SkinManager { get { return MaterialSkinManager.Instance; } } + [Browsable(false)] + public MouseState MouseState { get; set; } + + private int _value; + [DefaultValue(50)] + [Category("Material Skin")] + [Description("Define control value")] + public int Value + { + get { return _value; } + set + { + if (value < _rangeMin) + _value = _rangeMin; + else if (value > _rangeMax) + _value = _rangeMax; + else + _value = value; + //_mouseX = _sliderRectangle.X + ((int)((double)_value / (double)(RangeMax - RangeMin) * (double)(_sliderRectangle.Width) - _thumbRadius / 2)); + _mouseX = _sliderRectangle.X + ((int)((double)_value / (double)(RangeMax - RangeMin) * (double)(_sliderRectangle.Width - _thumbRadius))); + RecalcutlateIndicator(); + } + } + + private int _valueMax; + [DefaultValue(0)] + [Category("Material Skin")] + [Description("Define position indicator maximum value. Ignored when set to 0.")] + public int ValueMax + { + get { return _valueMax; } + set + { + if (value > _rangeMax) + _valueMax = _rangeMax; + else if (value < _rangeMin) + _valueMax = _rangeMin; + else + _valueMax = value; + } + } + + private int _rangeMax; + [DefaultValue(100)] + [Category("Material Skin")] + [Description("Define control range maximum value")] + public int RangeMax + { + get { return _rangeMax; } + set + { + _rangeMax = value; + //_mouseX = _sliderRectangle.X + ((int)((double)_value / (double)(RangeMax - RangeMin) * (double)(_sliderRectangle.Width) - _thumbRadius / 2)); + _mouseX = _sliderRectangle.X + ((int)((double)_value / (double)(RangeMax - RangeMin) * (double)(_sliderRectangle.Width - _thumbRadius))); + RecalcutlateIndicator(); + } + } + + private int _rangeMin; + [DefaultValue(0)] + [Category("Material Skin")] + [Description("Define control range minimum value")] + public int RangeMin + { + get { return _rangeMin; } + set + { + _rangeMin = value; + //_mouseX = _sliderRectangle.X + ((int)((double)_value / (double)(RangeMax - RangeMin) * (double)(_sliderRectangle.Width) - _thumbRadius / 2)); + _mouseX = _sliderRectangle.X + ((int)((double)_value / (double)(RangeMax - RangeMin) * (double)(_sliderRectangle.Width - _thumbRadius))); + RecalcutlateIndicator(); + } + } + + private string _text; + [DefaultValue("MyData")] + [Category("Material Skin")] + [Description("Set control text")] + public override string Text + { + get { return _text; } + set + { + _text = value; + UpdateRects(); + Invalidate(); + } + } + + private string _valueSuffix; + [DefaultValue("")] + [Category("Material Skin")] + [Description("Set control value suffix text")] + public string ValueSuffix + { + get { return _valueSuffix; } + set + { + _valueSuffix = value; + UpdateRects(); + } + } + + private Boolean _showText; + [DefaultValue(true)] + [Category("Material Skin"), DisplayName("Show text")] + [Description("Show text")] + public bool ShowText + { + get { return _showText; } + set { _showText = value; UpdateRects(); Invalidate(); } + } + + private Boolean _showValue; + [DefaultValue(true)] + [Category("Material Skin"), DisplayName("Show value")] + [Description("Show value")] + public bool ShowValue + { + get { return _showValue; } + set { _showValue = value; UpdateRects(); Invalidate(); } + } + + private bool _useAccentColor; + [Category("Material Skin"), DefaultValue(false), DisplayName("Use Accent Color")] + public bool UseAccentColor + { + get { return _useAccentColor; } + set { _useAccentColor = value; Invalidate(); } + } + + private MaterialSkinManager.fontType _fontType = MaterialSkinManager.fontType.Body1; + + [Category("Material Skin"), + DefaultValue(typeof(MaterialSkinManager.fontType), "Body1")] + public MaterialSkinManager.fontType FontType + { + get + { + return _fontType; + } + set + { + _fontType = value; + Font = SkinManager.getFontByType(_fontType, RightToLeft); + Refresh(); + } + } + + + #endregion + + #region "Events" + + [Category("Behavior")] + [Description("Occurs when value change.")] + public delegate void ValueChanged(object sender, int newValue); + public event ValueChanged onValueChanged; + + #endregion + + public MaterialSlider() + { + SetStyle(ControlStyles.Selectable, true); + ForeColor = SkinManager.TextHighEmphasisColor; // Color.Black; + RangeMax = 100; + RangeMin = 0; + Size = new Size(250, _thumbRadiusHoverPressed); + Text = "My Data"; + Value = 50; + ValueSuffix = ""; + ShowText = true; + ShowValue = true; + UseAccentColor = false; + + UpdateRects(); + + //EnabledChanged += MaterialSlider_EnabledChanged; + + DoubleBuffered = true; + + } + + //protected override void OnCreateControl() + //{ + // base.OnCreateControl(); + //} + + protected override void OnSizeChanged(EventArgs e) + { + base.OnSizeChanged(e); + Height = _thumbRadiusHoverPressed; + UpdateRects(); + } + + protected override void OnGotFocus(EventArgs e) + { + base.OnGotFocus(e); + _hovered = true; + Invalidate(); + } + + protected override void OnLostFocus(EventArgs e) + { + base.OnLostFocus(e); + _hovered = false; + Invalidate(); + } + + protected override void OnMouseDown(MouseEventArgs e) + { + base.OnMouseDown(e); + if (e.Button == System.Windows.Forms.MouseButtons.Left && e.Y > _indicatorRectanglePressed.Top && e.Y < _indicatorRectanglePressed.Bottom) + { + _mousePressed = true; + UpdateValue(e); + } + } + + protected override void OnMouseWheel(MouseEventArgs e) + { + base.OnMouseWheel(e); + if (_valueMax != 0 && (Value + e.Delta / -40) > _valueMax) + Value = _valueMax; + else + Value += e.Delta/-40; + onValueChanged?.Invoke(this, _value); + } + + protected override void OnMouseEnter(EventArgs e) + { + base.OnMouseEnter(e); + _hovered = true; + if (!this.Focused) this.Focus(); + Invalidate(); + } + + protected override void OnMouseLeave(EventArgs e) + { + base.OnMouseLeave(e); + _hovered = false; + if (this.Focused) this.Parent.Focus(); + Invalidate(); + } + + protected override void OnMouseUp(MouseEventArgs e) + { + base.OnMouseUp(e); + _mousePressed = false; + Invalidate(); + } + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + if (_mousePressed) + { + UpdateValue(e); + } + } + + private void UpdateValue(MouseEventArgs e) + { + int v = 0; + if (e.X >= _sliderRectangle.X + (_thumbRadius / 2) && e.X <= _sliderRectangle.Right - _thumbRadius / 2) + { + _mouseX = e.X - _thumbRadius / 2; + double ValuePerPx = ((double)(RangeMax - RangeMin)) / (_sliderRectangle.Width - _thumbRadius); + v = (int)(ValuePerPx * (_mouseX - _sliderRectangle.X)); + //if (_valueMax!=0 && v > _valueMax) v = _valueMax; + } + else if (e.X < _sliderRectangle.X)// + (_thumbRadius / 2)) + { + _mouseX = _sliderRectangle.X ; + v = _rangeMin; + } + else if (e.X > _sliderRectangle.Right - _thumbRadius)// / 2) + { + _mouseX = _sliderRectangle.Right - _thumbRadius; + v = _rangeMax; + } + + if (_valueMax != 0 && v > _valueMax) + { + Value = _valueMax; + } + else + { + if (v != _value) + { + _value = v; + onValueChanged?.Invoke(this, _value); + } + RecalcutlateIndicator(); + } + } + + private void UpdateRects() + { + Size textSize; + Size valueSize; + using (NativeTextRenderer NativeText = new NativeTextRenderer(CreateGraphics())) + { + textSize = NativeText.MeasureLogString(_showText ? Text : "", SkinManager.getLogFontByType(_fontType, RightToLeft)); + valueSize = NativeText.MeasureLogString(_showValue ? RangeMax.ToString() + _valueSuffix : "" , SkinManager.getLogFontByType(_fontType, RightToLeft)); + } + _valueRectangle = new Rectangle(Width - valueSize.Width - _thumbRadiusHoverPressed / 4, 0, valueSize.Width + _thumbRadiusHoverPressed / 4, Height); + _textRectangle = new Rectangle(0, 0, textSize.Width + _thumbRadiusHoverPressed/4, Height); + _sliderRectangle = new Rectangle(_textRectangle.Right , 0, _valueRectangle.Left - _textRectangle.Right , _thumbRadius); + _mouseX = _sliderRectangle.X + ((int)((double)_value / (double)(_rangeMax - _rangeMin) * (double)(_sliderRectangle.Width) - _thumbRadius / 2)); + RecalcutlateIndicator(); + } + + private void RecalcutlateIndicator() + { + _indicatorRectangle = new Rectangle(_mouseX, (Height - _thumbRadius) /2, _thumbRadius, _thumbRadius); + _indicatorRectangleNormal = new Rectangle(_indicatorRectangle.X, Height/2 - _thumbRadius/2, _thumbRadius, _thumbRadius); + _indicatorRectanglePressed = new Rectangle(_indicatorRectangle.X + _thumbRadius/2 - _thumbRadiusHoverPressed/2, Height / 2 - _thumbRadiusHoverPressed/2, _thumbRadiusHoverPressed, _thumbRadiusHoverPressed); + Invalidate(); + } + + protected override void OnPaint(PaintEventArgs e) + { + var g = e.Graphics; + g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; + g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; + g.Clear(Parent.BackColor); + + Color _inactiveTrackColor; + Color _accentColor; + Brush _accentBrush; + Brush _disabledBrush; + Color _disabledColor; + Color _thumbHoverColor; + Color _thumbPressedColor; + + if (_useAccentColor) + _accentColor = SkinManager.ColorScheme.AccentColor; + else + _accentColor = SkinManager.ColorScheme.PrimaryColor; + + _accentBrush = new SolidBrush(_accentColor); + _disabledBrush = new SolidBrush(Color.FromArgb(255, 158, 158, 158)); + + if (SkinManager.Theme == MaterialSkinManager.Themes.DARK) + { + _disabledColor = Color.FromArgb((int)(2.55 * 30), 255, 255, 255); + _inactiveTrackColor = _accentColor.Darken(0.25f); + } + else + { + _disabledColor = Color.FromArgb((int)(2.55 * (_hovered ? 38 : 26)), 0, 0, 0); + _inactiveTrackColor = _accentColor.Lighten(0.6f); + } + + //_disabledBrush = new SolidBrush(_disabledColor); + //_thumbHoverColor = Color.FromArgb((int)(2.55 * 15), (Value == 0 ? Color.Gray : _accentColor)); + //_thumbPressedColor = Color.FromArgb((int)(2.55 * 30), (Value == 0 ? Color.Gray : _accentColor)); _thumbHoverColor = Color.FromArgb((int)(2.55 * 15), (Value == 0 ? Color.Gray : _accentColor)); + _thumbHoverColor = Color.FromArgb((int)(2.55 * 15), _accentColor); + _thumbPressedColor = Color.FromArgb((int)(2.55 * 30), _accentColor); + //Pen LinePen = new Pen(_disabledColor, _inactiveTrack); + + //Draw track + //g.DrawLine(LinePen, _indicatorSize / 2, Height / 2 + (Height - _indicatorSize) / 2, Width - _indicatorSize / 2, Height / 2 + (Height - _indicatorSize) / 2); + //g.DrawLine(LinePen, _sliderRectangle.X + (_indicatorSize / 2), Height / 2 , _sliderRectangle.Right - (_indicatorSize / 2), Height / 2 ); + + GraphicsPath _inactiveTrackPath = DrawHelper.CreateRoundRect(_sliderRectangle.X + (_thumbRadius / 2), _sliderRectangle.Y + Height / 2 - _inactiveTrack/2, _sliderRectangle.Width - _thumbRadius, _inactiveTrack, 2); + //g.FillPath(_disabledBrush, _inactiveTrackPath); + GraphicsPath _activeTrackPath = DrawHelper.CreateRoundRect(_sliderRectangle.X + (_thumbRadius / 2), _sliderRectangle.Y + Height / 2 - _activeTrack / 2, _indicatorRectangleNormal.X - _sliderRectangle.X, _activeTrack, 2); + + if (Enabled) + { + //Draw inactive track + g.FillPath(new SolidBrush(_inactiveTrackColor), _inactiveTrackPath); + + //Draw active track + //g.DrawLine(SkinManager.ColorScheme.AccentPen, _indicatorSize / 2, Height / 2 + (Height - _indicatorSize) / 2, _indicatorRectangleNormal.X, Height / 2 + (Height - _indicatorSize) / 2); + //g.DrawLine(AccentPen, _sliderRectangle.X + (_indicatorSize / 2), Height / 2 , _indicatorRectangleNormal.X + (_indicatorSize / 2), Height / 2 ) ; + + g.FillPath(_accentBrush, _activeTrackPath); + + if (_mousePressed) + { + //g.FillEllipse(_accentBrush, _indicatorRectanglePressed); + g.FillEllipse(_accentBrush, _indicatorRectangleNormal); + g.FillEllipse(new SolidBrush(_thumbPressedColor), _indicatorRectanglePressed); + + } + else + { + g.FillEllipse(_accentBrush, _indicatorRectangleNormal); + + if (_hovered) + { + g.FillEllipse(new SolidBrush(_thumbHoverColor), _indicatorRectanglePressed); + } + } + } + else + { + //Draw inactive track + g.FillPath(new SolidBrush(_disabledColor.Lighten(0.25f)), _inactiveTrackPath); + + //Draw active track + g.FillPath(_disabledBrush, _activeTrackPath); + g.FillEllipse(_disabledBrush, _indicatorRectangleNormal); + } + + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + // Draw text + if (_showText == true) + { + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + NativeText.DrawTransparentText( + Text, + SkinManager.getLogFontByType(_fontType, RightToLeft), + Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor, + _textRectangle.Location, + _textRectangle.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + + + // Draw value + if (_showValue == true) + { + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Left : NativeTextRenderer.TextAlignFlags.Right; + NativeText.DrawTransparentText( + Value.ToString() + ValueSuffix, + SkinManager.getLogFontByType(_fontType, RightToLeft), + Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor, + _valueRectangle.Location, + _valueRectangle.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + } + + } + } + +} diff --git a/MaterialSkin/Controls/MaterialSnackBar.cs b/MaterialSkin/Controls/MaterialSnackBar.cs new file mode 100644 index 00000000..92938490 --- /dev/null +++ b/MaterialSkin/Controls/MaterialSnackBar.cs @@ -0,0 +1,370 @@ +namespace MaterialSkin.Controls +{ + using MaterialSkin.Animations; + using System; + using System.ComponentModel; + using System.Drawing; + using System.Drawing.Drawing2D; + using System.Windows.Forms; + using System.Runtime.InteropServices; + + public class MaterialSnackBar : MaterialForm + { + + private const int TOP_PADDING_SINGLE_LINE = 6; + private const int LEFT_RIGHT_PADDING = 16; + private const int BUTTON_PADDING = 8; + private const int BUTTON_HEIGHT = 36; + + private MaterialButton _actionButton = new MaterialButton(); + private Timer _duration = new Timer(); // Timer that checks when the drop down is fully visible + + private AnimationManager _AnimationManager; + private bool _closingAnimationDone = false; + private bool _useAccentColor; + private bool CloseAnimation = false; + + #region "Events" + + [Category("Action")] + [Description("Fires when Action button is clicked")] + public event EventHandler ActionButtonClick; + + #endregion + + + [Category("Material Skin"), DefaultValue(false), DisplayName("Use Accent Color")] + public bool UseAccentColor + { + get { return _useAccentColor; } + set { _useAccentColor = value; Invalidate(); } + } + + + /// + /// Get or Set SnackBar show duration in milliseconds + /// + [Category("Material Skin"), DefaultValue(2000)] + public int Duration + { + get + { + return _duration.Interval; + } + set + { + _duration.Interval = value; + } + } + + private String _text; + /// + /// The Text which gets displayed as the Content + /// + [Category("Material Skin"), DefaultValue("SnackBar text")] + public new String Text + { + get + { + return _text; + } + set + { + _text = value; + UpdateRects(); + Invalidate(); + } + } + + private bool _showActionButton; + [Category("Material Skin"), DefaultValue(false), DisplayName("Show Action Button")] + public bool ShowActionButton + { + get { return _showActionButton; } + set { _showActionButton = value; UpdateRects(); Invalidate(); } + } + + private String _actionButtonText; + /// + /// The Text which gets displayed as the Content + /// + [Category("Material Skin"), DefaultValue("OK")] + public String ActionButtonText + { + get + { + return _actionButtonText; + } + set + { + _actionButtonText = value; + Invalidate(); + } + } + + /// + /// The Collection for the Buttons + /// + //public ObservableCollection Buttons { get; set; } + + [DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")] + private static extern IntPtr CreateRoundRectRgn + ( + int nLeftRect, // x-coordinate of upper-left corner + int nTopRect, // y-coordinate of upper-left corner + int nRightRect, // x-coordinate of lower-right corner + int nBottomRect, // y-coordinate of lower-right corner + int nWidthEllipse, // width of ellipse + int nHeightEllipse // height of ellipse + ); + + /// + /// Constructer Setting up the Layout + /// + public MaterialSnackBar(string Text, int Duration, bool ShowActionButton, string ActionButtonText, bool UseAccentColor, RightToLeft rightToLeft = RightToLeft.No) : base(rightToLeft) + { + this.Text = Text; + this.Duration = Duration; + TopMost = true; + ShowInTaskbar = false; + Sizable = false; + + BackColor = SkinManager.SnackBarBackgroundColor; + FormStyle = FormStyles.StatusAndActionBar_None; + + this.ActionButtonText = ActionButtonText; + this.UseAccentColor = UseAccentColor; + Height = 48; + MinimumSize = new System.Drawing.Size(344, 48); + MaximumSize = new System.Drawing.Size(568, 48); + + this.ShowActionButton = ShowActionButton; + + Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 6, 6)); + + _AnimationManager = new AnimationManager(); + _AnimationManager.AnimationType = AnimationType.EaseOut; + _AnimationManager.Increment = 0.03; + _AnimationManager.OnAnimationProgress += _AnimationManager_OnAnimationProgress; + + _duration.Tick += new EventHandler(duration_Tick); + + _actionButton = new MaterialButton + { + AutoSize = false, + NoAccentTextColor = SkinManager.SnackBarTextButtonNoAccentTextColor, + DrawShadows = false, + Type = MaterialButton.MaterialButtonType.Text, + UseAccentColor = _useAccentColor, + Visible = _showActionButton, + Text = _actionButtonText + }; + _actionButton.Click += (sender, e) => + { + ActionButtonClick?.Invoke(this, new EventArgs()); + _closingAnimationDone = false; + Close(); + }; + + if (!Controls.Contains(_actionButton)) + { + Controls.Add(_actionButton); + } + + UpdateRects(); + + } + + public MaterialSnackBar(RightToLeft rightToLeft=RightToLeft.No) : this("SnackBar Text", 3000, false, "OK", false, rightToLeft) + { + } + + public MaterialSnackBar(string Text, RightToLeft rightToLeft = RightToLeft.No) : this(Text, 3000, false, "OK", false, rightToLeft) + { + } + + public MaterialSnackBar(string Text, int Duration, RightToLeft rightToLeft = RightToLeft.No) : this(Text, Duration, false, "OK", false, rightToLeft) + { + } + + public MaterialSnackBar(string Text, string ActionButtonText, RightToLeft rightToLeft = RightToLeft.No) : this(Text, 3000, true, ActionButtonText, false, rightToLeft) + { + } + + public MaterialSnackBar(string Text, string ActionButtonText, bool UseAccentColor, RightToLeft rightToLeft = RightToLeft.No) : this(Text, 3000, true, ActionButtonText, UseAccentColor, rightToLeft) + { + } + + public MaterialSnackBar(string Text, int Duration, string ActionButtonText, RightToLeft rightToLeft = RightToLeft.No) : this(Text, Duration, true, ActionButtonText, false, rightToLeft) + { + } + + public MaterialSnackBar(string Text, int Duration, string ActionButtonText, bool UseAccentColor, RightToLeft rightToLeft) : this(Text, Duration, true, ActionButtonText, UseAccentColor, rightToLeft) + { + } + + private void UpdateRects() + { + if (_showActionButton == true) + { + int _buttonWidth = ((TextRenderer.MeasureText(ActionButtonText, SkinManager.getFontByType(MaterialSkinManager.fontType.Button, RightToLeft))).Width + 32); + Rectangle _actionbuttonBounds = new Rectangle((Width) - BUTTON_PADDING - _buttonWidth, TOP_PADDING_SINGLE_LINE, _buttonWidth, BUTTON_HEIGHT); + _actionButton.Width = _actionbuttonBounds.Width; + _actionButton.Height = _actionbuttonBounds.Height; + _actionButton.Text = _actionButtonText; + _actionButton.Top = _actionbuttonBounds.Top; + _actionButton.UseAccentColor = _useAccentColor; + } + else + { + _actionButton.Width = 0; + } + _actionButton.Left = Width - BUTTON_PADDING - _actionButton.Width; //Button minimum width management + _actionButton.Visible = _showActionButton; + + Width = TextRenderer.MeasureText(_text, SkinManager.getFontByType(MaterialSkinManager.fontType.Body2, RightToLeft)).Width + (2 * LEFT_RIGHT_PADDING) + _actionButton.Width + 48; + Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 6, 6)); + + } + + private void duration_Tick(object sender, EventArgs e) + { + _duration.Stop(); + _closingAnimationDone = false; + Close(); + } + + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + UpdateRects(); + + } + + /// + /// Sets up the Starting Location and starts the Animation + /// + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + Location = new Point(Convert.ToInt32(Owner.Location.X + (Owner.Width / 2) - (Width / 2)), Convert.ToInt32(Owner.Location.Y + Owner.Height - 60)); + _AnimationManager.StartNewAnimation(AnimationDirection.In); + _duration.Start(); + } + + /// + /// Animates the Form slides + /// + void _AnimationManager_OnAnimationProgress(object sender) + { + if (CloseAnimation) + { + Opacity = _AnimationManager.GetProgress(); + } + } + + /// + /// Ovverides the Paint to create the solid colored backcolor + /// + protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) + { + + Graphics g = e.Graphics; + g.SmoothingMode = SmoothingMode.AntiAlias; + + e.Graphics.Clear(BackColor); + + + // Calc text Rect + Rectangle textRect = new Rectangle( + LEFT_RIGHT_PADDING, + 0, + Width - (2 * LEFT_RIGHT_PADDING) - _actionButton.Width, + Height); + + //Draw Text + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + // Draw header text + NativeText.DrawTransparentText( + _text, + SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body2, RightToLeft), + SkinManager.SnackBarTextHighEmphasisColor, + textRect.Location, + textRect.Size, + NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); + } + + } + + /// + /// Overrides the Closing Event to Animate the Slide Out + /// + protected override void OnClosing(System.ComponentModel.CancelEventArgs e) + { + e.Cancel = !_closingAnimationDone; + if (!_closingAnimationDone) + { + CloseAnimation = true; + _AnimationManager.Increment = 0.06; + _AnimationManager.OnAnimationFinished += _AnimationManager_OnAnimationFinished; + _AnimationManager.StartNewAnimation(AnimationDirection.Out); + } + base.OnClosing(e); + } + + /// + /// Closes the Form after the pull out animation + /// + void _AnimationManager_OnAnimationFinished(object sender) + { + _closingAnimationDone = true; + Close(); + } + + protected override void OnClick(EventArgs e) + { + base.OnClick(e); + _closingAnimationDone = false; + Close(); + } + + private void InitializeComponent() + { + this.SuspendLayout(); + this.ClientSize = new System.Drawing.Size(344, 48); + this.Name = "SnackBar"; + this.ResumeLayout(false); + + } + + /// + /// Prevents the Form from beeing dragged + /// + protected override void WndProc(ref Message message) + { + const int WM_SYSCOMMAND = 0x0112; + const int SC_MOVE = 0xF010; + + switch (message.Msg) + { + case WM_SYSCOMMAND: + int command = message.WParam.ToInt32() & 0xfff0; + if (command == SC_MOVE) + return; + break; + } + + base.WndProc(ref message); + } + + public new void Show() + { + if (Owner == null) + { + throw new Exception("Owner is null. Set Owner first."); + } + } + + } +} diff --git a/MaterialSkin/Controls/MaterialSwitch.cs b/MaterialSkin/Controls/MaterialSwitch.cs index 28d78bdc..b7450fb5 100644 --- a/MaterialSkin/Controls/MaterialSwitch.cs +++ b/MaterialSkin/Controls/MaterialSwitch.cs @@ -1,352 +1,362 @@ -namespace MaterialSkin.Controls -{ - using MaterialSkin.Animations; - using System; - using System.ComponentModel; - using System.Drawing; - using System.Drawing.Drawing2D; - using System.Drawing.Text; - using System.Windows.Forms; - - public class MaterialSwitch : CheckBox, IMaterialControl - { - [Browsable(false)] - public int Depth { get; set; } - - [Browsable(false)] - public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; - - [Browsable(false)] - public MouseState MouseState { get; set; } - - [Browsable(false)] - public Point MouseLocation { get; set; } - - private bool _ripple; - - [Category("Appearance")] - public bool Ripple - { - get { return _ripple; } - set - { - _ripple = value; - AutoSize = AutoSize; //Make AutoSize directly set the bounds. - - if (value) - { - Margin = new Padding(0); - } - - Invalidate(); - } - } - - private readonly AnimationManager _checkAM; - private readonly AnimationManager _hoverAM; - private readonly AnimationManager _rippleAM; - - private const int THUMB_SIZE = 22; - - private const int THUMB_SIZE_HALF = THUMB_SIZE / 2; - - private const int TRACK_SIZE_HEIGHT = (int)(14); - private const int TRACK_SIZE_WIDTH = (int)(36); - private const int TRACK_RADIUS = (int)(TRACK_SIZE_HEIGHT / 2); - - private int TRACK_CENTER_Y; - private int TRACK_CENTER_X_BEGIN; - private int TRACK_CENTER_X_END; - private int TRACK_CENTER_X_DELTA; - - private const int RIPPLE_DIAMETER = 37; - - private int _trackOffsetY; - - public MaterialSwitch() - { - _checkAM = new AnimationManager - { - AnimationType = AnimationType.EaseInOut, - Increment = 0.05 - }; - _hoverAM = new AnimationManager(true) - { - AnimationType = AnimationType.Linear, - Increment = 0.10 - }; - _rippleAM = new AnimationManager(false) - { - AnimationType = AnimationType.Linear, - Increment = 0.10, - SecondaryIncrement = 0.08 - }; - _checkAM.OnAnimationProgress += sender => Invalidate(); - _rippleAM.OnAnimationProgress += sender => Invalidate(); - _hoverAM.OnAnimationProgress += sender => Invalidate(); - - CheckedChanged += (sender, args) => - { - if (Ripple) - _checkAM.StartNewAnimation(Checked ? AnimationDirection.In : AnimationDirection.Out); - }; - - Ripple = true; - MouseLocation = new Point(-1, -1); - } - - protected override void OnSizeChanged(EventArgs e) - { - base.OnSizeChanged(e); - - _trackOffsetY = Height / 2 - THUMB_SIZE_HALF; - - TRACK_CENTER_Y = _trackOffsetY + THUMB_SIZE_HALF - 1; - TRACK_CENTER_X_BEGIN = TRACK_CENTER_Y; - TRACK_CENTER_X_END = TRACK_CENTER_X_BEGIN + TRACK_SIZE_WIDTH - (TRACK_RADIUS * 2); - TRACK_CENTER_X_DELTA = TRACK_CENTER_X_END - TRACK_CENTER_X_BEGIN; - } - - public override Size GetPreferredSize(Size proposedSize) - { - Size strSize; - using (NativeTextRenderer NativeText = new NativeTextRenderer(CreateGraphics())) - { - strSize = NativeText.MeasureLogString(Text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1)); - } - var w = TRACK_SIZE_WIDTH + THUMB_SIZE + strSize.Width; - return Ripple ? new Size(w, RIPPLE_DIAMETER) : new Size(w, THUMB_SIZE); - } - - private static readonly Point[] CheckmarkLine = { new Point(3, 8), new Point(7, 12), new Point(14, 5) }; - - private const int TEXT_OFFSET = THUMB_SIZE; - - protected override void OnPaint(PaintEventArgs pevent) - { - var g = pevent.Graphics; - g.SmoothingMode = SmoothingMode.AntiAlias; - g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; - - g.Clear(Parent.BackColor); - - var animationProgress = _checkAM.GetProgress(); - - // Draw Track - Color thumbColor = DrawHelper.BlendColor( - (Enabled ? SkinManager.SwitchOffThumbColor : SkinManager.SwitchOffDisabledThumbColor), // Off color - (Enabled ? SkinManager.ColorScheme.AccentColor : DrawHelper.BlendColor(SkinManager.ColorScheme.AccentColor, SkinManager.SwitchOffDisabledThumbColor, 197)), // On color - animationProgress * 255); // Blend amount - - using (var path = DrawHelper.CreateRoundRect(new Rectangle(TRACK_CENTER_X_BEGIN - TRACK_RADIUS, TRACK_CENTER_Y - TRACK_SIZE_HEIGHT / 2, TRACK_SIZE_WIDTH, TRACK_SIZE_HEIGHT), TRACK_RADIUS)) - { - using (SolidBrush trackBrush = new SolidBrush( - Color.FromArgb(Enabled ? SkinManager.SwitchOffTrackColor.A : SkinManager.BackgroundDisabledColor.A, // Track alpha - DrawHelper.BlendColor( // animate color - (Enabled ? SkinManager.SwitchOffTrackColor : SkinManager.BackgroundDisabledColor), // Off color - SkinManager.ColorScheme.AccentColor, // On color - animationProgress * 255) // Blend amount - .RemoveAlpha()))) - { - g.FillPath(trackBrush, path); - } - } - - // Calculate animation movement X position - int OffsetX = (int)(TRACK_CENTER_X_DELTA * animationProgress); - - // Ripple - int rippleSize = (Height % 2 == 0) ? Height - 2 : Height - 3; - - Color rippleColor = Color.FromArgb(40, // color alpha - Checked ? SkinManager.ColorScheme.AccentColor : // On color - (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? Color.Black : Color.White)); // Off color - - if (Ripple && _rippleAM.IsAnimating()) - { - for (int i = 0; i < _rippleAM.GetAnimationCount(); i++) - { - double rippleAnimProgress = _rippleAM.GetProgress(i); - int rippleAnimatedDiameter = (_rippleAM.GetDirection(i) == AnimationDirection.InOutIn) ? (int)(rippleSize * (0.7 + (0.3 * rippleAnimProgress))) : rippleSize; - - using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)(40 * rippleAnimProgress), rippleColor.RemoveAlpha()))) - { - g.FillEllipse(rippleBrush, new Rectangle(TRACK_CENTER_X_BEGIN + OffsetX - rippleAnimatedDiameter / 2, TRACK_CENTER_Y - rippleAnimatedDiameter / 2, rippleAnimatedDiameter, rippleAnimatedDiameter)); - } - } - } - - // Hover - if (Ripple) - { - double rippleAnimProgress = _hoverAM.GetProgress(); - int rippleAnimatedDiameter = (int)(rippleSize * (0.7 + (0.3 * rippleAnimProgress))); - - using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)(40 * rippleAnimProgress), rippleColor.RemoveAlpha()))) - { - g.FillEllipse(rippleBrush, new Rectangle(TRACK_CENTER_X_BEGIN + OffsetX - rippleAnimatedDiameter / 2, TRACK_CENTER_Y - rippleAnimatedDiameter / 2, rippleAnimatedDiameter, rippleAnimatedDiameter)); - } - } - - // draw Thumb Shadow - RectangleF thumbBounds = new RectangleF(TRACK_CENTER_X_BEGIN + OffsetX - THUMB_SIZE_HALF, TRACK_CENTER_Y - THUMB_SIZE_HALF, THUMB_SIZE, THUMB_SIZE); - using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(12, 0, 0, 0))) - { - g.FillEllipse(shadowBrush, new RectangleF(thumbBounds.X - 2, thumbBounds.Y - 1, thumbBounds.Width + 4, thumbBounds.Height + 6)); - g.FillEllipse(shadowBrush, new RectangleF(thumbBounds.X - 1, thumbBounds.Y - 1, thumbBounds.Width + 2, thumbBounds.Height + 4)); - g.FillEllipse(shadowBrush, new RectangleF(thumbBounds.X - 0, thumbBounds.Y - 0, thumbBounds.Width + 0, thumbBounds.Height + 2)); - g.FillEllipse(shadowBrush, new RectangleF(thumbBounds.X - 0, thumbBounds.Y + 2, thumbBounds.Width + 0, thumbBounds.Height + 0)); - g.FillEllipse(shadowBrush, new RectangleF(thumbBounds.X - 0, thumbBounds.Y + 1, thumbBounds.Width + 0, thumbBounds.Height + 0)); - } - - // draw Thumb - using (SolidBrush thumbBrush = new SolidBrush(thumbColor)) - { - g.FillEllipse(thumbBrush, thumbBounds); - } - - // draw text - using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) - { - Rectangle textLocation = new Rectangle(TEXT_OFFSET + TRACK_SIZE_WIDTH, 0, Width - (TEXT_OFFSET + TRACK_SIZE_WIDTH), Height); - NativeText.DrawTransparentText( - Text, - SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1), - Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor, - textLocation.Location, - textLocation.Size, - NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); - } - } - - private Bitmap DrawCheckMarkBitmap() - { - var checkMark = new Bitmap(THUMB_SIZE, THUMB_SIZE); - var g = Graphics.FromImage(checkMark); - - // clear everything, transparent - g.Clear(Color.Transparent); - - // draw the checkmark lines - using (var pen = new Pen(Parent.BackColor, 2)) - { - g.DrawLines(pen, CheckmarkLine); - } - - return checkMark; - } - - public override bool AutoSize - { - get { return base.AutoSize; } - set - { - base.AutoSize = value; - if (value) - { - Size = new Size(10, 10); - } - } +namespace MaterialSkin.Controls +{ + using MaterialSkin.Animations; + using System; + using System.ComponentModel; + using System.Drawing; + using System.Drawing.Drawing2D; + using System.Drawing.Text; + using System.Windows.Forms; + + public class MaterialSwitch : CheckBox, IMaterialControl + { + [Browsable(false)] + public int Depth { get; set; } + + [Browsable(false)] + public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; + + [Browsable(false)] + public MouseState MouseState { get; set; } + + [Browsable(false)] + public Point MouseLocation { get; set; } + + private bool _ripple; + + [Category("Appearance")] + public bool Ripple + { + get { return _ripple; } + set + { + _ripple = value; + AutoSize = AutoSize; //Make AutoSize directly set the bounds. + + if (value) + { + Margin = new Padding(0); + } + + Invalidate(); + } } - - private bool IsMouseInCheckArea() - { - return ClientRectangle.Contains(MouseLocation); - } - - private bool hovered = false; - - protected override void OnCreateControl() - { - base.OnCreateControl(); - - if (DesignMode) return; - - MouseState = MouseState.OUT; - - GotFocus += (sender, AddingNewEventArgs) => - { - if (Ripple && !hovered) - { - _hoverAM.StartNewAnimation(AnimationDirection.In, new object[] { Checked }); - hovered = true; - } - }; - - LostFocus += (sender, args) => - { - if (Ripple && hovered) - { - _hoverAM.StartNewAnimation(AnimationDirection.Out, new object[] { Checked }); - hovered = false; - } - }; - - MouseEnter += (sender, args) => - { - MouseState = MouseState.HOVER; - //if (Ripple && !hovered) - //{ - // _hoverAM.StartNewAnimation(AnimationDirection.In, new object[] { Checked }); - // hovered = true; - //} - }; - - MouseLeave += (sender, args) => - { - MouseLocation = new Point(-1, -1); - MouseState = MouseState.OUT; - //if (Ripple && hovered) - //{ - // _hoverAM.StartNewAnimation(AnimationDirection.Out, new object[] { Checked }); - // hovered = false; - //} - }; - - MouseDown += (sender, args) => - { - MouseState = MouseState.DOWN; - if (Ripple) - { - _rippleAM.SecondaryIncrement = 0; - _rippleAM.StartNewAnimation(AnimationDirection.InOutIn, new object[] { Checked }); - } - }; - - KeyDown += (sender, args) => - { - if (Ripple && (args.KeyCode == Keys.Space) && _rippleAM.GetAnimationCount() == 0) - { - _rippleAM.SecondaryIncrement = 0; - _rippleAM.StartNewAnimation(AnimationDirection.InOutIn, new object[] { Checked }); - } - }; - - MouseUp += (sender, args) => - { - if (Ripple) - { - MouseState = MouseState.HOVER; - _rippleAM.SecondaryIncrement = 0.08; - _hoverAM.StartNewAnimation(AnimationDirection.Out, new object[] { Checked }); - hovered = false; - } - }; - - KeyUp += (sender, args) => - { - if (Ripple && (args.KeyCode == Keys.Space)) - { - MouseState = MouseState.HOVER; - _rippleAM.SecondaryIncrement = 0.08; - } - }; - - MouseMove += (sender, args) => - { - MouseLocation = args.Location; - Cursor = IsMouseInCheckArea() ? Cursors.Hand : Cursors.Default; - }; - } - } -} \ No newline at end of file + + [Category("Appearance")] + [Browsable(true), DefaultValue(false), EditorBrowsable(EditorBrowsableState.Always)] + public bool ReadOnly { get; set; } + + private readonly AnimationManager _checkAM; + private readonly AnimationManager _hoverAM; + private readonly AnimationManager _rippleAM; + + private const int THUMB_SIZE = 22; + + private const int THUMB_SIZE_HALF = THUMB_SIZE / 2; + + private const int TRACK_SIZE_HEIGHT = (int)(14); + private const int TRACK_SIZE_WIDTH = (int)(36); + private const int TRACK_RADIUS = (int)(TRACK_SIZE_HEIGHT / 2); + + private int TRACK_CENTER_Y; + private int TRACK_CENTER_X_BEGIN; + private int TRACK_CENTER_X_END; + private int TRACK_CENTER_X_DELTA; + + private const int RIPPLE_DIAMETER = 37; + + private int _trackOffsetY; + + public MaterialSwitch() + { + _checkAM = new AnimationManager + { + AnimationType = AnimationType.EaseInOut, + Increment = 0.05 + }; + _hoverAM = new AnimationManager(true) + { + AnimationType = AnimationType.Linear, + Increment = 0.10 + }; + _rippleAM = new AnimationManager(false) + { + AnimationType = AnimationType.Linear, + Increment = 0.10, + SecondaryIncrement = 0.08 + }; + _checkAM.OnAnimationProgress += sender => Invalidate(); + _rippleAM.OnAnimationProgress += sender => Invalidate(); + _hoverAM.OnAnimationProgress += sender => Invalidate(); + + CheckedChanged += (sender, args) => + { + if (Ripple) + _checkAM.StartNewAnimation(Checked ? AnimationDirection.In : AnimationDirection.Out); + }; + + Ripple = true; + MouseLocation = new Point(-1, -1); + ReadOnly = false; + } + + protected override void OnClick(EventArgs e) + { + if (!ReadOnly) base.OnClick(e); + } + + protected override void OnSizeChanged(EventArgs e) + { + base.OnSizeChanged(e); + + _trackOffsetY = Height / 2 - THUMB_SIZE_HALF; + + TRACK_CENTER_Y = _trackOffsetY + THUMB_SIZE_HALF - 1; + TRACK_CENTER_X_BEGIN = (RightToLeft == RightToLeft.Yes) ? this.Width - TRACK_SIZE_WIDTH - (TRACK_RADIUS / 2) : TRACK_CENTER_Y; + TRACK_CENTER_X_END = TRACK_CENTER_X_BEGIN + TRACK_SIZE_WIDTH - (TRACK_RADIUS * 2); + TRACK_CENTER_X_DELTA = TRACK_CENTER_X_END - TRACK_CENTER_X_BEGIN; + } + + public override Size GetPreferredSize(Size proposedSize) + { + Size strSize; + using (NativeTextRenderer NativeText = new NativeTextRenderer(CreateGraphics())) + { + strSize = NativeText.MeasureLogString(Text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1, RightToLeft)); + } + var w = TRACK_SIZE_WIDTH + THUMB_SIZE + strSize.Width; + return Ripple ? new Size(w, RIPPLE_DIAMETER) : new Size(w, THUMB_SIZE); + } + + private static readonly Point[] CheckmarkLine = { new Point(3, 8), new Point(7, 12), new Point(14, 5) }; + + private const int TEXT_OFFSET = THUMB_SIZE; + + protected override void OnPaint(PaintEventArgs pevent) + { + var g = pevent.Graphics; + g.SmoothingMode = SmoothingMode.AntiAlias; + g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; + + g.Clear(Parent.BackColor); + + var animationProgress = _checkAM.GetProgress(); + + // Draw Track + Color thumbColor = DrawHelper.BlendColor( + (Enabled ? SkinManager.SwitchOffThumbColor : SkinManager.SwitchOffDisabledThumbColor), // Off color + (Enabled ? SkinManager.ColorScheme.AccentColor : DrawHelper.BlendColor(SkinManager.ColorScheme.AccentColor, SkinManager.SwitchOffDisabledThumbColor, 197)), // On color + animationProgress * 255); // Blend amount + + using (var path = DrawHelper.CreateRoundRect(new Rectangle(TRACK_CENTER_X_BEGIN - TRACK_RADIUS, TRACK_CENTER_Y - TRACK_SIZE_HEIGHT / 2, TRACK_SIZE_WIDTH, TRACK_SIZE_HEIGHT), TRACK_RADIUS)) + { + using (SolidBrush trackBrush = new SolidBrush( + Color.FromArgb(Enabled ? SkinManager.SwitchOffTrackColor.A : SkinManager.BackgroundDisabledColor.A, // Track alpha + DrawHelper.BlendColor( // animate color + (Enabled ? SkinManager.SwitchOffTrackColor : SkinManager.BackgroundDisabledColor), // Off color + SkinManager.ColorScheme.AccentColor, // On color + animationProgress * 255) // Blend amount + .RemoveAlpha()))) + { + g.FillPath(trackBrush, path); + } + } + + // Calculate animation movement X position + int OffsetX = (int)(TRACK_CENTER_X_DELTA * animationProgress); + + // Ripple + int rippleSize = (Height % 2 == 0) ? Height - 2 : Height - 3; + + Color rippleColor = Color.FromArgb(40, // color alpha + Checked ? SkinManager.ColorScheme.AccentColor : // On color + (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ? Color.Black : Color.White)); // Off color + + if (Ripple && _rippleAM.IsAnimating()) + { + for (int i = 0; i < _rippleAM.GetAnimationCount(); i++) + { + double rippleAnimProgress = _rippleAM.GetProgress(i); + int rippleAnimatedDiameter = (_rippleAM.GetDirection(i) == AnimationDirection.InOutIn) ? (int)(rippleSize * (0.7 + (0.3 * rippleAnimProgress))) : rippleSize; + + using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)(40 * rippleAnimProgress), rippleColor.RemoveAlpha()))) + { + g.FillEllipse(rippleBrush, new Rectangle(TRACK_CENTER_X_BEGIN + OffsetX - rippleAnimatedDiameter / 2, TRACK_CENTER_Y - rippleAnimatedDiameter / 2, rippleAnimatedDiameter, rippleAnimatedDiameter)); + } + } + } + + // Hover + if (Ripple) + { + double rippleAnimProgress = _hoverAM.GetProgress(); + int rippleAnimatedDiameter = (int)(rippleSize * (0.7 + (0.3 * rippleAnimProgress))); + + using (SolidBrush rippleBrush = new SolidBrush(Color.FromArgb((int)(40 * rippleAnimProgress), rippleColor.RemoveAlpha()))) + { + g.FillEllipse(rippleBrush, new Rectangle(TRACK_CENTER_X_BEGIN + OffsetX - rippleAnimatedDiameter / 2, TRACK_CENTER_Y - rippleAnimatedDiameter / 2, rippleAnimatedDiameter, rippleAnimatedDiameter)); + } + } + + // draw Thumb Shadow + RectangleF thumbBounds = new RectangleF(TRACK_CENTER_X_BEGIN + OffsetX - THUMB_SIZE_HALF, TRACK_CENTER_Y - THUMB_SIZE_HALF, THUMB_SIZE, THUMB_SIZE); + using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(12, 0, 0, 0))) + { + g.FillEllipse(shadowBrush, new RectangleF(thumbBounds.X - 2, thumbBounds.Y - 1, thumbBounds.Width + 4, thumbBounds.Height + 6)); + g.FillEllipse(shadowBrush, new RectangleF(thumbBounds.X - 1, thumbBounds.Y - 1, thumbBounds.Width + 2, thumbBounds.Height + 4)); + g.FillEllipse(shadowBrush, new RectangleF(thumbBounds.X - 0, thumbBounds.Y - 0, thumbBounds.Width + 0, thumbBounds.Height + 2)); + g.FillEllipse(shadowBrush, new RectangleF(thumbBounds.X - 0, thumbBounds.Y + 2, thumbBounds.Width + 0, thumbBounds.Height + 0)); + g.FillEllipse(shadowBrush, new RectangleF(thumbBounds.X - 0, thumbBounds.Y + 1, thumbBounds.Width + 0, thumbBounds.Height + 0)); + } + + // draw Thumb + using (SolidBrush thumbBrush = new SolidBrush(thumbColor)) + { + g.FillEllipse(thumbBrush, thumbBounds); + } + + // draw text + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + Rectangle textLocation = (RightToLeft == RightToLeft.Yes) ? new Rectangle(0, 0, Width - (TEXT_OFFSET + TRACK_SIZE_WIDTH), Height) : new Rectangle(TEXT_OFFSET + TRACK_SIZE_WIDTH, 0, Width - (TEXT_OFFSET + TRACK_SIZE_WIDTH), Height); + NativeText.DrawTransparentText( + Text, + SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body1, RightToLeft), + Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor, + textLocation.Location, + textLocation.Size, + NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); + } + } + + private Bitmap DrawCheckMarkBitmap() + { + var checkMark = new Bitmap(THUMB_SIZE, THUMB_SIZE); + var g = Graphics.FromImage(checkMark); + + // clear everything, transparent + g.Clear(Color.Transparent); + + // draw the checkmark lines + using (var pen = new Pen(Parent.BackColor, 2)) + { + g.DrawLines(pen, CheckmarkLine); + } + + return checkMark; + } + + public override bool AutoSize + { + get { return base.AutoSize; } + set + { + base.AutoSize = value; + if (value) + { + Size = new Size(10, 10); + } + } + } + + private bool IsMouseInCheckArea() + { + return ClientRectangle.Contains(MouseLocation); + } + + private bool hovered = false; + + protected override void OnCreateControl() + { + base.OnCreateControl(); + + if (DesignMode) return; + + MouseState = MouseState.OUT; + + GotFocus += (sender, AddingNewEventArgs) => + { + if (Ripple && !hovered) + { + _hoverAM.StartNewAnimation(AnimationDirection.In, new object[] { Checked }); + hovered = true; + } + }; + + LostFocus += (sender, args) => + { + if (Ripple && hovered) + { + _hoverAM.StartNewAnimation(AnimationDirection.Out, new object[] { Checked }); + hovered = false; + } + }; + + MouseEnter += (sender, args) => + { + MouseState = MouseState.HOVER; + //if (Ripple && !hovered) + //{ + // _hoverAM.StartNewAnimation(AnimationDirection.In, new object[] { Checked }); + // hovered = true; + //} + }; + + MouseLeave += (sender, args) => + { + MouseLocation = new Point(-1, -1); + MouseState = MouseState.OUT; + //if (Ripple && hovered) + //{ + // _hoverAM.StartNewAnimation(AnimationDirection.Out, new object[] { Checked }); + // hovered = false; + //} + }; + + MouseDown += (sender, args) => + { + MouseState = MouseState.DOWN; + if (Ripple) + { + _rippleAM.SecondaryIncrement = 0; + _rippleAM.StartNewAnimation(AnimationDirection.InOutIn, new object[] { Checked }); + } + }; + + KeyDown += (sender, args) => + { + if (Ripple && (args.KeyCode == Keys.Space) && _rippleAM.GetAnimationCount() == 0) + { + _rippleAM.SecondaryIncrement = 0; + _rippleAM.StartNewAnimation(AnimationDirection.InOutIn, new object[] { Checked }); + } + }; + + MouseUp += (sender, args) => + { + if (Ripple) + { + MouseState = MouseState.HOVER; + _rippleAM.SecondaryIncrement = 0.08; + _hoverAM.StartNewAnimation(AnimationDirection.Out, new object[] { Checked }); + hovered = false; + } + }; + + KeyUp += (sender, args) => + { + if (Ripple && (args.KeyCode == Keys.Space)) + { + MouseState = MouseState.HOVER; + _rippleAM.SecondaryIncrement = 0.08; + } + }; + + MouseMove += (sender, args) => + { + MouseLocation = args.Location; + Cursor = IsMouseInCheckArea() ? Cursors.Hand : Cursors.Default; + }; + } + } +} diff --git a/MaterialSkin/Controls/MaterialTabControl.cs b/MaterialSkin/Controls/MaterialTabControl.cs index 9c01ad00..fc5acacc 100644 --- a/MaterialSkin/Controls/MaterialTabControl.cs +++ b/MaterialSkin/Controls/MaterialTabControl.cs @@ -6,6 +6,11 @@ public class MaterialTabControl : TabControl, IMaterialControl { + public MaterialTabControl() + { + Multiline = true; + } + [Browsable(false)] public int Depth { get; set; } @@ -20,5 +25,12 @@ protected override void WndProc(ref Message m) if (m.Msg == 0x1328 && !DesignMode) m.Result = (IntPtr)1; else base.WndProc(ref m); } + + protected override void OnControlAdded(ControlEventArgs e) + { + base.OnControlAdded(e); + + e.Control.BackColor = System.Drawing.Color.White; + } } -} \ No newline at end of file +} diff --git a/MaterialSkin/Controls/MaterialTabSelector.cs b/MaterialSkin/Controls/MaterialTabSelector.cs index 671b246a..0ca04051 100644 --- a/MaterialSkin/Controls/MaterialTabSelector.cs +++ b/MaterialSkin/Controls/MaterialTabSelector.cs @@ -1,10 +1,12 @@ namespace MaterialSkin.Controls { using MaterialSkin.Animations; + using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Drawing.Text; + using System.Globalization; using System.Windows.Forms; public class MaterialTabSelector : Control, IMaterialControl @@ -18,8 +20,24 @@ public class MaterialTabSelector : Control, IMaterialControl [Browsable(false)] public MouseState MouseState { get; set; } + //[Browsable(false)] + public enum CustomCharacterCasing + { + [Description("Text will be used as user inserted, no alteration")] + Normal, + [Description("Text will be converted to UPPER case")] + Upper, + [Description("Text will be converted to lower case")] + Lower, + [Description("Text will be converted to Proper case (aka Title case)")] + Proper + } + + TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; + private MaterialTabControl _baseTabControl; + [Category("Material Skin"), Browsable(true)] public MaterialTabControl BaseTabControl { get { return _baseTabControl; } @@ -27,6 +45,9 @@ public MaterialTabControl BaseTabControl { _baseTabControl = value; if (_baseTabControl == null) return; + + UpdateTabRects(); + _previousSelectedTabIndex = _baseTabControl.SelectedIndex; _baseTabControl.Deselected += (sender, args) => { @@ -56,14 +77,77 @@ public MaterialTabControl BaseTabControl private List _tabRects; + private const int ICON_SIZE = 24; + private const int FIRST_TAB_PADDING = 50; private const int TAB_HEADER_PADDING = 24; + private const int TAB_WIDTH_MIN = 160; + private const int TAB_WIDTH_MAX = 264; + + private int _tab_over_index = -1; + + private CustomCharacterCasing _characterCasing; + + [Category("Appearance")] + public CustomCharacterCasing CharacterCasing + { + get => _characterCasing; + set + { + _characterCasing = value; + _baseTabControl.Invalidate(); + Invalidate(); + } + } + private int _tab_indicator_height; + + [Category("Material Skin"), Browsable(true), DisplayName("Tab Indicator Height"), DefaultValue(2)] + public int TabIndicatorHeight + { + get { return _tab_indicator_height; } + set + { + if (value < 1) + throw new ArgumentOutOfRangeException("Tab Indicator Height", value, "Value should be > 0"); + else + { + _tab_indicator_height = value; + Refresh(); + } + } + } + + public enum TabLabelStyle + { + Text, + Icon, + IconAndText, + } + + private TabLabelStyle _tabLabel; + [Category("Material Skin"), Browsable(true), DisplayName("Tab Label"), DefaultValue(TabLabelStyle.Text)] + public TabLabelStyle TabLabel + { + get { return _tabLabel; } + set + { + _tabLabel = value; + if (_tabLabel == TabLabelStyle.IconAndText) + Height = 72; + else + Height = 48; + UpdateTabRects(); + Invalidate(); + } + } - private const int TAB_INDICATOR_HEIGHT = 2; public MaterialTabSelector() { SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer, true); - Height = 48; + TabIndicatorHeight = 2; + TabLabel = TabLabelStyle.Text; + + Size = new Size(480, 48); _animationManager = new AnimationManager { @@ -76,7 +160,7 @@ public MaterialTabSelector() protected override void OnCreateControl() { base.OnCreateControl(); - Font = SkinManager.getFontByType(MaterialSkinManager.fontType.Body1); + Font = SkinManager.getFontByType(MaterialSkinManager.fontType.Body1, RightToLeft); } protected override void OnPaint(PaintEventArgs e) @@ -106,33 +190,90 @@ protected override void OnPaint(PaintEventArgs e) } //Draw tab headers + if (_tab_over_index >= 0) + { + //Change mouse over tab background color + g.FillRectangle(SkinManager.BackgroundHoverBrush , _tabRects[_tab_over_index].X, _tabRects[_tab_over_index].Y , _tabRects[_tab_over_index].Width, _tabRects[_tab_over_index].Height - _tab_indicator_height); + } + foreach (TabPage tabPage in _baseTabControl.TabPages) { var currentTabIndex = _baseTabControl.TabPages.IndexOf(tabPage); - using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + if (_tabLabel != TabLabelStyle.Icon) { - Rectangle textLocation = _tabRects[currentTabIndex]; - NativeText.DrawTransparentText( - tabPage.Text.ToUpper(), - SkinManager.getLogFontByType(MaterialSkinManager.fontType.Button), - Color.FromArgb(CalculateTextAlpha(currentTabIndex, animationProgress), SkinManager.ColorScheme.TextColor), - textLocation.Location, - textLocation.Size, - NativeTextRenderer.TextAlignFlags.Center | NativeTextRenderer.TextAlignFlags.Middle); + // Text + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + Size textSize = TextRenderer.MeasureText(_baseTabControl.TabPages[currentTabIndex].Text, Font); + Rectangle textLocation = new Rectangle(_tabRects[currentTabIndex].X+ (TAB_HEADER_PADDING/2), _tabRects[currentTabIndex].Y, _tabRects[currentTabIndex].Width - (TAB_HEADER_PADDING), _tabRects[currentTabIndex].Height); + + if (_tabLabel == TabLabelStyle.IconAndText) + { + textLocation.Y = 46; + textLocation.Height = 10; + } + + if (((TAB_HEADER_PADDING*2) + textSize.Width < TAB_WIDTH_MAX)) + { + NativeText.DrawTransparentText( + CharacterCasing == CustomCharacterCasing.Upper ? tabPage.Text.ToUpper() : + CharacterCasing == CustomCharacterCasing.Lower ? tabPage.Text.ToLower() : + CharacterCasing == CustomCharacterCasing.Proper ? textInfo.ToTitleCase(tabPage.Text.ToLower()) : tabPage.Text, + Font, + Color.FromArgb(CalculateTextAlpha(currentTabIndex, animationProgress), SkinManager.ColorScheme.TextColor), + textLocation.Location, + textLocation.Size, + NativeTextRenderer.TextAlignFlags.Center | NativeTextRenderer.TextAlignFlags.Middle); + } + else + { + if (_tabLabel == TabLabelStyle.IconAndText) + { + textLocation.Y = 40; + textLocation.Height = 26; + } + NativeText.DrawMultilineTransparentText( + CharacterCasing == CustomCharacterCasing.Upper ? tabPage.Text.ToUpper() : + CharacterCasing == CustomCharacterCasing.Lower ? tabPage.Text.ToLower() : + CharacterCasing == CustomCharacterCasing.Proper ? textInfo.ToTitleCase(tabPage.Text.ToLower()) : tabPage.Text, + SkinManager.getFontByType(MaterialSkinManager.fontType.Body2, RightToLeft), + Color.FromArgb(CalculateTextAlpha(currentTabIndex, animationProgress), SkinManager.ColorScheme.TextColor), + textLocation.Location, + textLocation.Size, + NativeTextRenderer.TextAlignFlags.Center | NativeTextRenderer.TextAlignFlags.Middle); + } + } } - } + + if (_tabLabel != TabLabelStyle.Text) + { + // Icons + if (_baseTabControl.ImageList != null && (!String.IsNullOrEmpty(tabPage.ImageKey) | tabPage.ImageIndex > -1)) + { + Rectangle iconRect = new Rectangle( + _tabRects[currentTabIndex].X + (_tabRects[currentTabIndex].Width / 2) - (ICON_SIZE / 2), + _tabRects[currentTabIndex].Y + (_tabRects[currentTabIndex].Height / 2) - (ICON_SIZE / 2), + ICON_SIZE, ICON_SIZE); + if (_tabLabel == TabLabelStyle.IconAndText) + { + iconRect.Y = 12; + } + g.DrawImage(!String.IsNullOrEmpty(tabPage.ImageKey) ? _baseTabControl.ImageList.Images[tabPage.ImageKey]: _baseTabControl.ImageList.Images[tabPage.ImageIndex], iconRect); + } + } + } //Animate tab indicator var previousSelectedTabIndexIfHasOne = _previousSelectedTabIndex == -1 ? _baseTabControl.SelectedIndex : _previousSelectedTabIndex; var previousActiveTabRect = _tabRects[previousSelectedTabIndexIfHasOne]; var activeTabPageRect = _tabRects[_baseTabControl.SelectedIndex]; - var y = activeTabPageRect.Bottom - 2; + var y = activeTabPageRect.Bottom - _tab_indicator_height; var x = previousActiveTabRect.X + (int)((activeTabPageRect.X - previousActiveTabRect.X) * animationProgress); var width = previousActiveTabRect.Width + (int)((activeTabPageRect.Width - previousActiveTabRect.Width) * animationProgress); - g.FillRectangle(SkinManager.ColorScheme.AccentBrush, x, y, width, TAB_INDICATOR_HEIGHT); + g.FillRectangle(SkinManager.ColorScheme.AccentBrush, x, y, width, _tab_indicator_height); } private int CalculateTextAlpha(int tabIndex, double animationProgress) @@ -171,6 +312,47 @@ protected override void OnMouseUp(MouseEventArgs e) _animationSource = e.Location; } + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + + if (DesignMode) + return; + + if (_tabRects == null) + UpdateTabRects(); + + int old_tab_over_index = _tab_over_index; + _tab_over_index = -1; + for (var i = 0; i < _tabRects.Count; i++) + { + if (_tabRects[i].Contains(e.Location)) + { + Cursor = Cursors.Hand; + _tab_over_index = i; + break; + } + } + if (_tab_over_index == -1) + Cursor = Cursors.Arrow; + if (old_tab_over_index != _tab_over_index) + Invalidate(); + } + + protected override void OnMouseLeave(EventArgs e) + { + base.OnMouseLeave(e); + if (DesignMode) + return; + + if (_tabRects == null) + UpdateTabRects(); + + Cursor = Cursors.Arrow; + _tab_over_index = -1; + Invalidate(); + } + private void UpdateTabRects() { _tabRects = new List(); @@ -184,13 +366,33 @@ private void UpdateTabRects() { using (var g = Graphics.FromImage(b)) { - _tabRects.Add(new Rectangle(SkinManager.FORM_PADDING, 0, TAB_HEADER_PADDING * 2 + (int)g.MeasureString(_baseTabControl.TabPages[0].Text, Font).Width, Height)); - for (int i = 1; i < _baseTabControl.TabPages.Count; i++) + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) { - _tabRects.Add(new Rectangle(_tabRects[i - 1].Right, 0, TAB_HEADER_PADDING * 2 + (int)g.MeasureString(_baseTabControl.TabPages[i].Text, Font).Width, Height)); + for (int i = 0; i < _baseTabControl.TabPages.Count; i++) + { + Size textSize = TextRenderer.MeasureText(_baseTabControl.TabPages[i].Text, Font); + if (_tabLabel == TabLabelStyle.Icon) textSize.Width = ICON_SIZE; + + int TabWidth = (TAB_HEADER_PADDING * 2) + textSize.Width; + if (TabWidth > TAB_WIDTH_MAX) + TabWidth = TAB_WIDTH_MAX; + else if (TabWidth < TAB_WIDTH_MIN) + TabWidth = TAB_WIDTH_MIN; + + if (i == 0) + { + var RectangleX = (RightToLeft == RightToLeft.Yes) ? Width - TabWidth - FIRST_TAB_PADDING + (TAB_HEADER_PADDING) : FIRST_TAB_PADDING - (TAB_HEADER_PADDING); + _tabRects.Add(new Rectangle(RectangleX, 0, TabWidth, Height)); + } + else + { + var RectangleX = (RightToLeft == RightToLeft.Yes) ? _tabRects[i - 1].Left - TabWidth : _tabRects[i - 1].Right; + _tabRects.Add(new Rectangle(RectangleX, 0, TabWidth, Height)); + } + } } } } } } -} \ No newline at end of file +} diff --git a/MaterialSkin/Controls/MaterialTextBox.cs b/MaterialSkin/Controls/MaterialTextBox.cs index 1ca6acb2..e27f9e07 100644 --- a/MaterialSkin/Controls/MaterialTextBox.cs +++ b/MaterialSkin/Controls/MaterialTextBox.cs @@ -1,438 +1,898 @@ -namespace MaterialSkin.Controls -{ - using MaterialSkin.Animations; - using System; - using System.ComponentModel; - using System.Drawing; - using System.Runtime.InteropServices; - using System.Windows.Forms; - - public class MaterialTextBox : RichTextBox, IMaterialControl - { - //Properties for managing the material design properties - [Browsable(false)] +namespace MaterialSkin.Controls +{ + using MaterialSkin.Animations; + using System; + using System.Collections.Generic; + using System.ComponentModel; + using System.Drawing; + using System.Drawing.Imaging; + using System.Runtime.InteropServices; + using System.Windows.Forms; + + [ToolboxItem(false), Description("This control has been replaced by MaterialTextBox2"), Obsolete("Use MaterialTextBox2 instead", false)] + public class MaterialTextBox : RichTextBox, IMaterialControl + { + + MaterialContextMenuStrip cms = new TextBoxContextMenuStrip(); + ContextMenuStrip _lastContextMenuStrip = new ContextMenuStrip(); + + //Properties for managing the material design properties + [Browsable(false)] public int Depth { get; set; } - - [Browsable(false)] + + [Browsable(false)] public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; - - [Browsable(false)] - public MouseState MouseState { get; set; } - - [Category("Material Skin"), DefaultValue(false)] - public bool Password { get; set; } - + + [Browsable(false)] + public MouseState MouseState { get; set; } + + [Category("Material Skin"), DefaultValue(false)] + public bool Password { get; set; } + private bool _UseTallSize; - - [Category("Material Skin"), DefaultValue(true), Description("Using a larger size enables the hint to always be visible")] - public bool UseTallSize - { - get { return _UseTallSize; } - set - { - _UseTallSize = value; - HEIGHT = UseTallSize ? 50 : 36; - Size = new Size(Size.Width, HEIGHT); - Invalidate(); - } - } - - [Category("Material Skin"), DefaultValue(true)] - public bool UseAccent { get; set; } - + + [Category("Material Skin"), DefaultValue(true), Description("Using a larger size enables the hint to always be visible")] + public bool UseTallSize + { + get { return _UseTallSize; } + set + { + _UseTallSize = value; + HEIGHT = UseTallSize ? 50 : 36; + Size = new Size(Size.Width, HEIGHT); + UpdateRects(false); + Invalidate(); + } + } + + [Category("Material Skin"), DefaultValue(true)] + public bool UseAccent { get; set; } + private string _hint = string.Empty; - - [Category("Material Skin"), DefaultValue("")] - public string Hint - { - get { return _hint; } - set - { - _hint = value; - hasHint = !String.IsNullOrEmpty(Hint); - Invalidate(); - } - } - - private const int HINT_TEXT_SMALL_SIZE = 18; - private const int HINT_TEXT_SMALL_Y = 4; - private const int BOTTOM_PADDING = 3; - private int HEIGHT = 50; - private int LINE_Y; - - private bool hasHint; - - private readonly AnimationManager _animationManager; - - public MaterialTextBox() - { - // Material Properties - Hint = ""; - Password = false; - UseAccent = true; - UseTallSize = true; - - // Properties - TabStop = true; - Multiline = false; - BorderStyle = BorderStyle.None; - - // Animations - _animationManager = new AnimationManager - { - Increment = 0.08, - AnimationType = AnimationType.EaseInOut - }; - _animationManager.OnAnimationProgress += sender => Invalidate(); - - MaterialContextMenuStrip cms = new TextBoxContextMenuStrip(); - cms.Opening += ContextMenuStripOnOpening; - cms.OnItemClickStart += ContextMenuStripOnItemClickStart; - - ContextMenuStrip = cms; - - MaxLength = 50; - } - + + [Category("Material Skin"), DefaultValue(""), Localizable(true)] + public string Hint + { + get { return _hint; } + set + { + _hint = value; + hasHint = !String.IsNullOrEmpty(Hint); + Invalidate(); + } + } + + private Image _leadingIcon; + + [Category("Material Skin"), Browsable(true), Localizable(false)] + /// + /// Gets or sets the leading Icon + /// + public Image LeadingIcon + { + get { return _leadingIcon; } + set + { + _leadingIcon = value; + UpdateRects(false); + preProcessIcons(); + if (AutoSize) + { + Refresh(); + } + else + { + Invalidate(); + } + } + } + + private Image _trailingIcon; + + [Category("Material Skin"), Browsable(true), Localizable(false)] + /// + /// Gets or sets the trailing Icon + /// + public Image TrailingIcon + { + get { return _trailingIcon; } + set + { + _trailingIcon = value; + UpdateRects(false); + preProcessIcons(); + if (AutoSize) + { + Refresh(); + } + else + { + Invalidate(); + } + } + } + + + public override ContextMenuStrip ContextMenuStrip + { + get { return base.ContextMenuStrip; } + set + { + if (value != null) + { + base.ContextMenuStrip = value; + } + else + { + base.ContextMenuStrip = cms; + } + _lastContextMenuStrip = base.ContextMenuStrip; + } + } + + + public override bool ShortcutsEnabled + { + get + { + return base.ShortcutsEnabled; + } + set + { + base.ShortcutsEnabled = value; + if (value == false) + { + base.ContextMenuStrip = null; + } + else + { + base.ContextMenuStrip = _lastContextMenuStrip; + } + } + } + + private const int ICON_SIZE = 24; + private const int HINT_TEXT_SMALL_SIZE = 18; + private const int HINT_TEXT_SMALL_Y = 4; + private const int BOTTOM_PADDING = 3; + private int HEIGHT = 50; + private int LINE_Y; + + private bool hasHint; + private bool _errorState = false; + private int _left_padding ; + private int _right_padding ; + private Rectangle _leadingIconBounds; + private Rectangle _trailingIconBounds; + private Rectangle _textfieldBounds; + + private readonly AnimationManager _animationManager; + private Dictionary iconsBrushes; + private Dictionary iconsErrorBrushes; + + private bool _animateReadOnly; + + [Category("Material Skin")] + [Browsable(true)] + public bool AnimateReadOnly + { + get => _animateReadOnly; + set + { + _animateReadOnly = value; + Invalidate(); + } + } + + private bool _leaveOnEnterKey; + + [Category("Material Skin"), DefaultValue(false), Description("Select next control which have TabStop property set to True when enter key is pressed.")] + public bool LeaveOnEnterKey + { + get => _leaveOnEnterKey; + set + { + _leaveOnEnterKey = value; + if (value) + { + KeyDown += new KeyEventHandler(LeaveOnEnterKey_KeyDown); + } + else + { + KeyDown -= LeaveOnEnterKey_KeyDown; + } + Invalidate(); + } + } + + #region "Events" + + [Category("Action")] + [Description("Fires when Leading Icon is clicked")] + public event EventHandler LeadingIconClick; + + [Category("Action")] + [Description("Fires when Trailing Icon is clicked")] + public event EventHandler TrailingIconClick; + + #endregion + + public MaterialTextBox() + { + // Material Properties + Hint = ""; + Password = false; + UseAccent = true; + UseTallSize = true; + + // Properties + TabStop = true; + Multiline = false; + BorderStyle = BorderStyle.None; + + // Animations + _animationManager = new AnimationManager + { + Increment = 0.08, + AnimationType = AnimationType.EaseInOut + }; + _animationManager.OnAnimationProgress += sender => Invalidate(); + + SkinManager.ColorSchemeChanged += sender => + { + preProcessIcons(); + }; + + SkinManager.ThemeChanged += sender => + { + preProcessIcons(); + }; + + cms.Opening += ContextMenuStripOnOpening; + cms.OnItemClickStart += ContextMenuStripOnItemClickStart; + ContextMenuStrip = cms; + + MaxLength = 50; + } + private const int EM_SETPASSWORDCHAR = 0x00cc; - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); - - protected override void OnCreateControl() - { - base.OnCreateControl(); - base.Font = new Font(SkinManager.getFontByType(MaterialSkinManager.fontType.Subtitle1).FontFamily, 12f, FontStyle.Regular); - base.AutoSize = false; - - SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); - - if (Password) SendMessage(Handle, EM_SETPASSWORDCHAR, 'T', 0); - - // Size and padding - HEIGHT = UseTallSize ? 50 : 36; - Size = new Size(Size.Width, HEIGHT); - LINE_Y = HEIGHT - BOTTOM_PADDING; - - // Position the "real" text field - var rect = new Rectangle(SkinManager.FORM_PADDING, UseTallSize ? hasHint ? - (HINT_TEXT_SMALL_Y + HINT_TEXT_SMALL_SIZE) : // Has hint and it's tall - (int)(LINE_Y / 3.5) : // No hint and tall - Height / 5, // not tall - ClientSize.Width - (SkinManager.FORM_PADDING * 2), LINE_Y); - RECT rc = new RECT(rect); - SendMessageRefRect(Handle, EM_SETRECT, 0, ref rc); - - // events - MouseState = MouseState.OUT; - LostFocus += (sender, args) => _animationManager.StartNewAnimation(AnimationDirection.Out); - GotFocus += (sender, args) => - { - _animationManager.StartNewAnimation(AnimationDirection.In); - }; - MouseEnter += (sender, args) => - { - MouseState = MouseState.HOVER; - Invalidate(); - }; - MouseLeave += (sender, args) => - { - MouseState = MouseState.OUT; - Invalidate(); - }; - HScroll += (sender, args) => - { - SendMessage(this.Handle, EM_GETSCROLLPOS, 0, ref scrollPos); - Invalidate(); - }; - KeyDown += (sender, args) => - { - SendMessage(this.Handle, EM_GETSCROLLPOS, 0, ref scrollPos); - }; - } - - private Point scrollPos = Point.Empty; - private const int EM_GETSCROLLPOS = WM_USER + 221; + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); + + protected override void OnCreateControl() + { + base.OnCreateControl(); + base.Font = SkinManager.getFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft); + base.AutoSize = false; + + SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); + + if (Password) SendMessage(Handle, EM_SETPASSWORDCHAR, 'T', 0); + + // Size and padding + HEIGHT = UseTallSize ? 50 : 36; + Size = new Size(Size.Width, HEIGHT); + LINE_Y = HEIGHT - BOTTOM_PADDING; + UpdateRects(); + + // events + MouseState = MouseState.OUT; + LostFocus += (sender, args) => _animationManager.StartNewAnimation(AnimationDirection.Out); + GotFocus += (sender, args) => + { + _animationManager.StartNewAnimation(AnimationDirection.In); + }; + MouseEnter += (sender, args) => + { + MouseState = MouseState.HOVER; + Invalidate(); + }; + MouseLeave += (sender, args) => + { + MouseState = MouseState.OUT; + Invalidate(); + }; + HScroll += (sender, args) => + { + SendMessage(this.Handle, EM_GETSCROLLPOS, 0, ref scrollPos); + Invalidate(); + }; + KeyDown += (sender, args) => + { + SendMessage(this.Handle, EM_GETSCROLLPOS, 0, ref scrollPos); + }; + } + + private Point scrollPos = Point.Empty; + private const int EM_GETSCROLLPOS = WM_USER + 221; private const int WM_USER = 0x400; - - [DllImport("user32.dll")] - private static extern IntPtr SendMessage(IntPtr hWnd, Int32 wMsg, Int32 wParam, ref Point lParam); - - public override Size GetPreferredSize(Size proposedSize) - { - return new Size(proposedSize.Width, HEIGHT); - } - - protected override void OnPaint(PaintEventArgs pevent) - { - base.OnPaint(pevent); - - var g = pevent.Graphics; - - g.Clear(Parent.BackColor); - - SolidBrush backBrush = new SolidBrush(DrawHelper.BlendColor(Parent.BackColor, SkinManager.BackgroundAlternativeColor, SkinManager.BackgroundAlternativeColor.A)); - - g.FillRectangle( - !Enabled ? SkinManager.BackgroundDisabledBrush : // Disabled - Focused ? SkinManager.BackgroundFocusBrush : // Focused - MouseState == MouseState.HOVER ? SkinManager.BackgroundHoverBrush : // Hover - backBrush, // Normal - ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, LINE_Y); - - // HintText - bool userTextPresent = !String.IsNullOrEmpty(Text); - Color textColor = Enabled ? Focused ? - UseAccent ? SkinManager.ColorScheme.AccentColor : SkinManager.ColorScheme.PrimaryColor : // Focused - SkinManager.TextHighEmphasisColor : // Inactive - SkinManager.TextDisabledOrHintColor; // Disabled - Rectangle hintRect = new Rectangle(SkinManager.FORM_PADDING, ClientRectangle.Y, Width, LINE_Y); - int hintTextSize = 16; - - // bottom line base - g.FillRectangle(SkinManager.DividersAlternativeBrush, 0, LINE_Y, Width, 1); - - if (!_animationManager.IsAnimating()) - { - // No animation - if (hasHint && UseTallSize && (Focused || userTextPresent)) - { - // hint text - hintRect = new Rectangle(SkinManager.FORM_PADDING, HINT_TEXT_SMALL_Y, Width, HINT_TEXT_SMALL_SIZE); - hintTextSize = 12; - } - - // bottom line - if (Focused) - { - g.FillRectangle(UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush, 0, LINE_Y, Width, 2); - } - } - else - { - // Animate - Focus got/lost - double animationProgress = _animationManager.GetProgress(); - - // hint Animation - if (hasHint && UseTallSize) - { - hintRect = new Rectangle( - SkinManager.FORM_PADDING, - userTextPresent ? (HINT_TEXT_SMALL_Y) : ClientRectangle.Y + (int)((HINT_TEXT_SMALL_Y - ClientRectangle.Y) * animationProgress), - Width, - userTextPresent ? (HINT_TEXT_SMALL_SIZE) : (int)(LINE_Y + (HINT_TEXT_SMALL_SIZE - LINE_Y) * animationProgress)); - hintTextSize = userTextPresent ? 12 : (int)(16 + (12 - 16) * animationProgress); - } - - // Line Animation - int LineAnimationWidth = (int)(Width * animationProgress); - int LineAnimationX = (Width / 2) - (LineAnimationWidth / 2); - g.FillRectangle(UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush, LineAnimationX, LINE_Y, LineAnimationWidth, 2); - } - - // Text stuff: - string textToDisplay = Password ? Text.ToSecureString() : Text; - string textSelected; - Rectangle textSelectRect; - - // Calc text Rect - Rectangle textRect = new Rectangle( - SkinManager.FORM_PADDING, - hasHint && UseTallSize ? (hintRect.Y + hintRect.Height) - 2 : ClientRectangle.Y, - ClientRectangle.Width - SkinManager.FORM_PADDING * 2 + scrollPos.X, - hasHint && UseTallSize ? LINE_Y - (hintRect.Y + hintRect.Height) : LINE_Y); - - g.Clip = new Region(textRect); - textRect.X -= scrollPos.X; - - using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) - { - // Selection rects calc - string textBeforeSelection = textToDisplay.Substring(0, SelectionStart); - textSelected = textToDisplay.Substring(SelectionStart, SelectionLength); - - int selectX = NativeText.MeasureLogString(textBeforeSelection, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1)).Width; - int selectWidth = NativeText.MeasureLogString(textSelected, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1)).Width; - - textSelectRect = new Rectangle( - textRect.X + selectX, UseTallSize ? hasHint ? - textRect.Y + BOTTOM_PADDING : // tall and hint - LINE_Y / 3 - BOTTOM_PADDING : // tall and no hint - BOTTOM_PADDING, // not tall - selectWidth, - UseTallSize ? hasHint ? - textRect.Height - BOTTOM_PADDING * 2 : // tall and hint - (int)(LINE_Y / 2) : // tall and no hint - LINE_Y - BOTTOM_PADDING * 2); // not tall - - // Draw user text - NativeText.DrawTransparentText( - textToDisplay, - SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1), - Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor, - textRect.Location, - textRect.Size, - NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); - } - - if (Focused) - { - // Draw Selection Rectangle - g.FillRectangle(UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.DarkPrimaryBrush, textSelectRect); - - // Draw Selected Text - using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) - { - NativeText.DrawTransparentText( - textSelected, - SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1), - SkinManager.ColorScheme.TextColor, - textSelectRect.Location, - textSelectRect.Size, - NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); - } - } - - g.Clip = new Region(ClientRectangle); - - // Draw hint text - if (hasHint && (UseTallSize || String.IsNullOrEmpty(Text))) - { - using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) - { - NativeText.DrawTransparentText( - Hint, - SkinManager.getTextBoxFontBySize(hintTextSize), - Enabled ? Focused ? UseAccent ? - SkinManager.ColorScheme.AccentColor : // Focus Accent - SkinManager.ColorScheme.PrimaryColor : // Focus Primary - SkinManager.TextMediumEmphasisColor : // not focused - SkinManager.TextDisabledOrHintColor, // Disabled - hintRect.Location, - hintRect.Size, - NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); - } - } - } - - protected override void OnTextChanged(EventArgs e) - { - base.OnTextChanged(e); - Invalidate(); - } - - protected override void OnSelectionChanged(EventArgs e) - { - base.OnSelectionChanged(e); - Invalidate(); - } - - protected override void OnResize(EventArgs e) - { - base.OnResize(e); - Size = new Size(Width, HEIGHT); - LINE_Y = HEIGHT - BOTTOM_PADDING; - } - - private void ContextMenuStripOnItemClickStart(object sender, ToolStripItemClickedEventArgs toolStripItemClickedEventArgs) - { - switch (toolStripItemClickedEventArgs.ClickedItem.Text) - { - case "Cut": - Cut(); - break; - - case "Copy": - Copy(); - break; - - case "Paste": - Paste(); - break; - - case "Delete": - SelectedText = string.Empty; - break; - - case "Select All": - SelectAll(); - break; - } - } - - private void ContextMenuStripOnOpening(object sender, CancelEventArgs cancelEventArgs) - { - var strip = sender as TextBoxContextMenuStrip; - if (strip != null) - { - strip.Cut.Enabled = !string.IsNullOrEmpty(SelectedText); - strip.Copy.Enabled = !string.IsNullOrEmpty(SelectedText); - strip.Paste.Enabled = Clipboard.ContainsText(); - strip.Delete.Enabled = !string.IsNullOrEmpty(SelectedText); - strip.SelectAll.Enabled = !string.IsNullOrEmpty(Text); - } - } - - // Cursor flickering fix - private const int WM_SETCURSOR = 0x0020; - - protected override void WndProc(ref Message m) - { - if (m.Msg == WM_SETCURSOR) - Cursor.Current = this.Cursor; - else - base.WndProc(ref m); - } - - // Padding - private const int EM_SETRECT = 0xB3; - - [DllImport(@"User32.dll", EntryPoint = @"SendMessage", CharSet = CharSet.Auto)] - private static extern int SendMessageRefRect(IntPtr hWnd, uint msg, int wParam, ref RECT rect); - - [StructLayout(LayoutKind.Sequential)] - private struct RECT - { - public readonly int Left; - public readonly int Top; - public readonly int Right; - public readonly int Bottom; - - private RECT(int left, int top, int right, int bottom) - { - Left = left; - Top = top; - Right = right; - Bottom = bottom; - } - + + [DllImport("user32.dll")] + private static extern IntPtr SendMessage(IntPtr hWnd, Int32 wMsg, Int32 wParam, ref Point lParam); + + public override Size GetPreferredSize(Size proposedSize) + { + return new Size(proposedSize.Width, HEIGHT); + } + + private static Size ResizeIcon(Image Icon) + { + int newWidth, newHeight; + //Resize icon if greater than ICON_SIZE + if (Icon.Width > ICON_SIZE || Icon.Height > ICON_SIZE) + { + //calculate aspect ratio + float aspect = Icon.Width / (float)Icon.Height; + + //calculate new dimensions based on aspect ratio + newWidth = (int)(ICON_SIZE * aspect); + newHeight = (int)(newWidth / aspect); + + //if one of the two dimensions exceed the box dimensions + if (newWidth > ICON_SIZE || newHeight > ICON_SIZE) + { + //depending on which of the two exceeds the box dimensions set it as the box dimension and calculate the other one based on the aspect ratio + if (newWidth > newHeight) + { + newWidth = ICON_SIZE; + newHeight = (int)(newWidth / aspect); + } + else + { + newHeight = ICON_SIZE; + newWidth = (int)(newHeight * aspect); + } + } + } + else + { + newWidth = Icon.Width; + newHeight = Icon.Height; + } + + return new Size() + { + Height = newHeight, + Width = newWidth + }; + } + + private void preProcessIcons() + { + if (_trailingIcon == null && _leadingIcon == null) return; + + // Calculate lightness and color + float l = (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT ) ? 0f : 1f; + + // Create matrices + float[][] matrixGray = { + new float[] { 0, 0, 0, 0, 0}, // Red scale factor + new float[] { 0, 0, 0, 0, 0}, // Green scale factor + new float[] { 0, 0, 0, 0, 0}, // Blue scale factor + new float[] { 0, 0, 0, Enabled ? .7f : .3f, 0}, // alpha scale factor + new float[] { l, l, l, 0, 1}};// offset + + float[][] matrixRed = { + new float[] { 0, 0, 0, 0, 0}, // Red scale factor + new float[] { 0, 0, 0, 0, 0}, // Green scale factor + new float[] { 0, 0, 0, 0, 0}, // Blue scale factor + new float[] { 0, 0, 0, 1, 0}, // alpha scale factor + new float[] { 1, 0, 0, 0, 1}};// offset + + ColorMatrix colorMatrixGray = new ColorMatrix(matrixGray); + ColorMatrix colorMatrixRed = new ColorMatrix(matrixRed); + + ImageAttributes grayImageAttributes = new ImageAttributes(); + ImageAttributes redImageAttributes = new ImageAttributes(); + + // Set color matrices + grayImageAttributes.SetColorMatrix(colorMatrixGray, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); + redImageAttributes.SetColorMatrix(colorMatrixRed, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); + + // Create brushes + iconsBrushes = new Dictionary(2); + iconsErrorBrushes = new Dictionary(2); + + // Image Rect + Rectangle destRect = new Rectangle(0, 0, ICON_SIZE, ICON_SIZE); + + if (_leadingIcon != null) + { + // ******************** + // *** _leadingIcon *** + // ******************** + + //Resize icon if greater than ICON_SIZE + Size newSize_leadingIcon = ResizeIcon(_leadingIcon); + Bitmap _leadingIconIconResized = new Bitmap(_leadingIcon, newSize_leadingIcon.Width, newSize_leadingIcon.Height); + + // Create a pre-processed copy of the image (GRAY) + Bitmap bgray = new Bitmap(destRect.Width, destRect.Height); + using (Graphics gGray = Graphics.FromImage(bgray)) + { + gGray.DrawImage(_leadingIconIconResized, + new Point[] { + new Point(0, 0), + new Point(destRect.Width, 0), + new Point(0, destRect.Height), + }, + destRect, GraphicsUnit.Pixel, grayImageAttributes); + } + + // added processed image to brush for drawing + TextureBrush textureBrushGray = new TextureBrush(bgray); + + textureBrushGray.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; + + var iconRect = _leadingIconBounds; + + textureBrushGray.TranslateTransform(iconRect.X + iconRect.Width / 2 - _leadingIconIconResized.Width / 2, + iconRect.Y + iconRect.Height / 2 - _leadingIconIconResized.Height / 2); + + // add to dictionary + iconsBrushes.Add("_leadingIcon", textureBrushGray); + } + + if (_trailingIcon != null) + { + // ********************* + // *** _trailingIcon *** + // ********************* + + //Resize icon if greater than ICON_SIZE + Size newSize_trailingIcon = ResizeIcon(_trailingIcon); + Bitmap _trailingIconResized = new Bitmap(_trailingIcon, newSize_trailingIcon.Width, newSize_trailingIcon.Height); + + // Create a pre-processed copy of the image (GRAY) + Bitmap bgray = new Bitmap(destRect.Width, destRect.Height); + using (Graphics gGray = Graphics.FromImage(bgray)) + { + gGray.DrawImage(_trailingIconResized, + new Point[] { + new Point(0, 0), + new Point(destRect.Width, 0), + new Point(0, destRect.Height), + }, + destRect, GraphicsUnit.Pixel, grayImageAttributes); + } + + //Create a pre - processed copy of the image(RED) + Bitmap bred = new Bitmap(destRect.Width, destRect.Height); + using (Graphics gred = Graphics.FromImage(bred)) + { + gred.DrawImage(_trailingIconResized, + new Point[] { + new Point(0, 0), + new Point(destRect.Width, 0), + new Point(0, destRect.Height), + }, + destRect, GraphicsUnit.Pixel, redImageAttributes); + } + + + // added processed image to brush for drawing + TextureBrush textureBrushGray = new TextureBrush(bgray); + TextureBrush textureBrushRed = new TextureBrush(bred); + + textureBrushGray.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; + textureBrushRed.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; + + var iconRect = _trailingIconBounds; + + textureBrushGray.TranslateTransform(iconRect.X + iconRect.Width / 2 - _trailingIconResized.Width / 2, + iconRect.Y + iconRect.Height / 2 - _trailingIconResized.Height / 2); + textureBrushRed.TranslateTransform(iconRect.X + iconRect.Width / 2 - _trailingIconResized.Width / 2, + iconRect.Y + iconRect.Height / 2 - _trailingIconResized.Height / 2); + + // add to dictionary + iconsBrushes.Add("_trailingIcon", textureBrushGray); + //iconsSelectedBrushes.Add(0, textureBrushColor); + iconsErrorBrushes.Add("_trailingIcon", textureBrushRed); + } + } + + private void UpdateRects(bool RedefineTextField = true) + { + if (LeadingIcon != null) + _left_padding = SkinManager.FORM_PADDING + ICON_SIZE; + else + _left_padding = SkinManager.FORM_PADDING; + + if (_trailingIcon != null) + _right_padding = SkinManager.FORM_PADDING + ICON_SIZE; + else + _right_padding = SkinManager.FORM_PADDING; + + _leadingIconBounds = new Rectangle(8, (HEIGHT / 2) - (ICON_SIZE / 2), ICON_SIZE, ICON_SIZE); + _trailingIconBounds = new Rectangle(Width - (ICON_SIZE + 8), (HEIGHT / 2) - (ICON_SIZE / 2), ICON_SIZE, ICON_SIZE); + _textfieldBounds = new Rectangle(_left_padding, ClientRectangle.Y, Width - _left_padding - _right_padding, LINE_Y); + + if (RedefineTextField) + { + var rect = new Rectangle(_left_padding, UseTallSize ? hasHint ? + (HINT_TEXT_SMALL_Y + HINT_TEXT_SMALL_SIZE) : // Has hint and it's tall + (int)(LINE_Y / 3.5) : // No hint and tall + Height / 5, // not tall + ClientSize.Width - _left_padding - _right_padding, LINE_Y); + RECT rc = new RECT(rect); + SendMessageRefRect(Handle, EM_SETRECT, 0, ref rc); + } + + } + + public void SetErrorState(bool ErrorState) + { + _errorState = ErrorState; + Invalidate(); + } + + public bool GetErrorState() + { + return _errorState; + } + + protected override void OnPaint(PaintEventArgs pevent) + { + base.OnPaint(pevent); + + var g = pevent.Graphics; + + g.Clear(Parent.BackColor); + + SolidBrush backBrush = new SolidBrush(DrawHelper.BlendColor(Parent.BackColor, SkinManager.BackgroundAlternativeColor, SkinManager.BackgroundAlternativeColor.A)); + + g.FillRectangle( + !Enabled ? SkinManager.BackgroundDisabledBrush : // Disabled + Focused ? SkinManager.BackgroundFocusBrush : // Focused + MouseState == MouseState.HOVER && (!ReadOnly || (ReadOnly && !AnimateReadOnly)) ? SkinManager.BackgroundHoverBrush : // Hover + backBrush, // Normal + ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, LINE_Y); + + //Leading Icon + if (LeadingIcon != null) + { + g.FillRectangle(iconsBrushes["_leadingIcon"], _leadingIconBounds); + } + + //Trailing Icon + if (TrailingIcon != null) + { + if(_errorState) + g.FillRectangle(iconsErrorBrushes["_trailingIcon"], _trailingIconBounds); + else + g.FillRectangle(iconsBrushes["_trailingIcon"], _trailingIconBounds); + } + + // HintText + bool userTextPresent = !String.IsNullOrEmpty(Text); + Color textColor = Enabled ? Focused ? + UseAccent ? SkinManager.ColorScheme.AccentColor : SkinManager.ColorScheme.PrimaryColor : // Focused + SkinManager.TextHighEmphasisColor : // Inactive + SkinManager.TextDisabledOrHintColor; // Disabled + Rectangle hintRect = new Rectangle(_left_padding, ClientRectangle.Y, Width - _left_padding - _right_padding, LINE_Y); + int hintTextSize = 16; + + // bottom line base + g.FillRectangle(SkinManager.DividersAlternativeBrush, 0, LINE_Y, Width, 1); + + if (ReadOnly == false || (ReadOnly && AnimateReadOnly)) + { + if (!_animationManager.IsAnimating()) + { + // No animation + if (hasHint && UseTallSize && (Focused || userTextPresent)) + { + // hint text + hintRect = new Rectangle(_left_padding, HINT_TEXT_SMALL_Y, Width - _left_padding - _right_padding, HINT_TEXT_SMALL_SIZE); + hintTextSize = 12; + } + + // bottom line + if (Focused) + { + g.FillRectangle(_errorState ? SkinManager.BackgroundHoverRedBrush : UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush, 0, LINE_Y, Width, 2); + } + } + else + { + // Animate - Focus got/lost + double animationProgress = _animationManager.GetProgress(); + + // hint Animation + if (hasHint && UseTallSize) + { + hintRect = new Rectangle( + _left_padding, + userTextPresent ? (HINT_TEXT_SMALL_Y) : ClientRectangle.Y + (int)((HINT_TEXT_SMALL_Y - ClientRectangle.Y) * animationProgress), + Width - _left_padding - _right_padding, + userTextPresent ? (HINT_TEXT_SMALL_SIZE) : (int)(LINE_Y + (HINT_TEXT_SMALL_SIZE - LINE_Y) * animationProgress)); + hintTextSize = userTextPresent ? 12 : (int)(16 + (12 - 16) * animationProgress); + } + + // Line Animation + int LineAnimationWidth = (int)(Width * animationProgress); + int LineAnimationX = (Width / 2) - (LineAnimationWidth / 2); + g.FillRectangle(UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush, LineAnimationX, LINE_Y, LineAnimationWidth, 2); + } + } + + // Text stuff: + string textToDisplay = Password ? Text.ToSecureString() : Text; + string textSelected; + Rectangle textSelectRect; + + // Calc text Rect + Rectangle textRect = new Rectangle( + hintRect.X, + hasHint && UseTallSize ? (hintRect.Y + hintRect.Height) - 2 : ClientRectangle.Y, + ClientRectangle.Width - _left_padding - _right_padding + scrollPos.X, + hasHint && UseTallSize ? LINE_Y - (hintRect.Y + hintRect.Height) : LINE_Y); + + g.Clip = new Region(textRect); + textRect.X -= scrollPos.X; + + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + // Selection rects calc + string textBeforeSelection = textToDisplay.Substring(0, SelectionStart); + textSelected = textToDisplay.Substring(SelectionStart, SelectionLength); + + int selectX = NativeText.MeasureLogString(textBeforeSelection, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft)).Width; + int selectWidth = NativeText.MeasureLogString(textSelected, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft)).Width; + + textSelectRect = new Rectangle( + textRect.X + selectX, UseTallSize ? hasHint ? + textRect.Y + BOTTOM_PADDING : // tall and hint + LINE_Y / 3 - BOTTOM_PADDING : // tall and no hint + BOTTOM_PADDING, // not tall + selectWidth, + UseTallSize ? hasHint ? + textRect.Height - BOTTOM_PADDING * 2 : // tall and hint + (int)(LINE_Y / 2) : // tall and no hint + LINE_Y - BOTTOM_PADDING * 2); // not tall + + // Draw user text + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + NativeText.DrawTransparentText( + textToDisplay, + SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft), + Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor, + textRect.Location, + textRect.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + + if (Focused) + { + // Draw Selection Rectangle + g.FillRectangle(UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.DarkPrimaryBrush, textSelectRect); + + // Draw Selected Text + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + NativeText.DrawTransparentText( + textSelected, + SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft), + SkinManager.ColorScheme.TextColor, + textSelectRect.Location, + textSelectRect.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + } + + g.Clip = new Region(ClientRectangle); + + // Draw hint text + if (hasHint && (UseTallSize || String.IsNullOrEmpty(Text))) + { + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + NativeText.DrawTransparentText( + Hint, + SkinManager.getTextBoxFontBySize(hintTextSize, RightToLeft), + Enabled ? !_errorState || (!userTextPresent && !Focused) ? Focused ? UseAccent ? + SkinManager.ColorScheme.AccentColor : // Focus Accent + SkinManager.ColorScheme.PrimaryColor : // Focus Primary + SkinManager.TextMediumEmphasisColor : // not focused + SkinManager.BackgroundHoverRedColor : // error state + SkinManager.TextDisabledOrHintColor, // Disabled + hintRect.Location, + hintRect.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + } + } + + protected override void OnTextChanged(EventArgs e) + { + base.OnTextChanged(e); + Invalidate(); + } + + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + + if (DesignMode) + return; + + if (_textfieldBounds.Contains(e.Location)) + { + Cursor = Cursors.IBeam; + } + else if (LeadingIcon != null && _leadingIconBounds.Contains(e.Location) && LeadingIconClick != null) + { + Cursor = Cursors.Hand; + } + else if (TrailingIcon != null && _trailingIconBounds.Contains(e.Location) && TrailingIconClick != null) + { + Cursor = Cursors.Hand; + } + else + { + Cursor = Cursors.Default; + } + + } + + protected override void OnMouseDown(MouseEventArgs e) + { + if (LeadingIcon != null && _leadingIconBounds.Contains(e.Location)) + { + LeadingIconClick?.Invoke(this, new EventArgs()); + } + else if (TrailingIcon != null && _trailingIconBounds.Contains(e.Location)) + { + TrailingIconClick?.Invoke(this, new EventArgs()); + } + else + { + if (DesignMode) + return; + } + base.OnMouseDown(e); + } + + protected override void OnSelectionChanged(EventArgs e) + { + base.OnSelectionChanged(e); + Invalidate(); + } + + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + Size = new Size(Width, HEIGHT); + LINE_Y = HEIGHT - BOTTOM_PADDING; + UpdateRects(false); + preProcessIcons(); + + if (DesignMode) + { + //Below code helps to redraw images in design mode only + Image _tmpimage; + _tmpimage = LeadingIcon; + LeadingIcon = null; + LeadingIcon = _tmpimage; + _tmpimage = TrailingIcon; + TrailingIcon = null; + TrailingIcon = _tmpimage; + } + } + + private void ContextMenuStripOnItemClickStart(object sender, ToolStripItemClickedEventArgs toolStripItemClickedEventArgs) + { + switch (toolStripItemClickedEventArgs.ClickedItem.Text) + { + case "Cut": + Cut(); + break; + + case "Copy": + Copy(); + break; + + case "Paste": + Paste(); + break; + + case "Delete": + SelectedText = string.Empty; + break; + + case "Select All": + SelectAll(); + break; + } + } + + private void ContextMenuStripOnOpening(object sender, CancelEventArgs cancelEventArgs) + { + var strip = sender as TextBoxContextMenuStrip; + if (strip != null) + { + strip.Cut.Enabled = !string.IsNullOrEmpty(SelectedText) && !ReadOnly; + strip.Copy.Enabled = !string.IsNullOrEmpty(SelectedText); + strip.Paste.Enabled = Clipboard.ContainsText() && !ReadOnly; + strip.Delete.Enabled = !string.IsNullOrEmpty(SelectedText) && !ReadOnly; + strip.SelectAll.Enabled = !string.IsNullOrEmpty(Text); + } + } + + private void LeaveOnEnterKey_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + e.Handled = true; + e.SuppressKeyPress = true; + SendKeys.Send("{TAB}"); + } + } + + // Cursor flickering fix + private const int WM_SETCURSOR = 0x0020; + + protected override void WndProc(ref Message m) + { + if (m.Msg == WM_SETCURSOR) + Cursor.Current = this.Cursor; + else + base.WndProc(ref m); + } + + // Padding + private const int EM_SETRECT = 0xB3; + + [DllImport(@"User32.dll", EntryPoint = @"SendMessage", CharSet = CharSet.Auto)] + private static extern int SendMessageRefRect(IntPtr hWnd, uint msg, int wParam, ref RECT rect); + + [StructLayout(LayoutKind.Sequential)] + private struct RECT + { + public readonly int Left; + public readonly int Top; + public readonly int Right; + public readonly int Bottom; + + private RECT(int left, int top, int right, int bottom) + { + Left = left; + Top = top; + Right = right; + Bottom = bottom; + } + public RECT(Rectangle r) : this(r.Left, r.Top, r.Right, r.Bottom) { - } - } - } - - public class TextBoxContextMenuStrip : MaterialContextMenuStrip - { - public readonly ToolStripItem SelectAll = new MaterialToolStripMenuItem { Text = "Select All" }; - public readonly ToolStripItem Separator2 = new ToolStripSeparator(); - public readonly ToolStripItem Paste = new MaterialToolStripMenuItem { Text = "Paste" }; - public readonly ToolStripItem Copy = new MaterialToolStripMenuItem { Text = "Copy" }; - public readonly ToolStripItem Cut = new MaterialToolStripMenuItem { Text = "Cut" }; - public readonly ToolStripItem Delete = new MaterialToolStripMenuItem { Text = "Delete" }; - - public TextBoxContextMenuStrip() - { - Items.AddRange(new[] - { - Cut, - Copy, - Paste, - Delete, - Separator2, - SelectAll - } - ); - } - } -} \ No newline at end of file + } + } + } + + [ToolboxItem(false)] + public class TextBoxContextMenuStrip : MaterialContextMenuStrip + { + public readonly ToolStripItem SelectAll = new MaterialToolStripMenuItem { Text = "Select All" }; + public readonly ToolStripItem Separator2 = new ToolStripSeparator(); + public readonly ToolStripItem Paste = new MaterialToolStripMenuItem { Text = "Paste" }; + public readonly ToolStripItem Copy = new MaterialToolStripMenuItem { Text = "Copy" }; + public readonly ToolStripItem Cut = new MaterialToolStripMenuItem { Text = "Cut" }; + public readonly ToolStripItem Delete = new MaterialToolStripMenuItem { Text = "Delete" }; + + public TextBoxContextMenuStrip() + { + Items.AddRange(new[] + { + Cut, + Copy, + Paste, + Delete, + Separator2, + SelectAll + } + ); + } + } +} diff --git a/MaterialSkin/Controls/MaterialTextBox2.cs b/MaterialSkin/Controls/MaterialTextBox2.cs new file mode 100644 index 00000000..89a7aa28 --- /dev/null +++ b/MaterialSkin/Controls/MaterialTextBox2.cs @@ -0,0 +1,1986 @@ +namespace MaterialSkin.Controls +{ + using System; + using System.Collections.Generic; + using System.ComponentModel; + using System.Drawing; + using System.Drawing.Imaging; + using System.Windows.Forms; + using MaterialSkin.Animations; + + public class MaterialTextBox2 : Control, IMaterialControl + { + + MaterialContextMenuStrip cms = new BaseTextBoxContextMenuStrip(); + ContextMenuStrip _lastContextMenuStrip = new ContextMenuStrip(); + + //Properties for managing the material design properties + [Browsable(false)] + public int Depth { get; set; } + + [Browsable(false)] + public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; + + [Browsable(false)] + public MouseState MouseState { get; set; } + + //Unused properties + [Browsable(false)] + public override System.Drawing.Image BackgroundImage { get; set; } + + [Browsable(false)] + public override System.Windows.Forms.ImageLayout BackgroundImageLayout { get; set; } + + [Browsable(false)] + public string SelectedText { get { return baseTextBox.SelectedText; } set { baseTextBox.SelectedText = value; } } + + [Browsable(false)] + public int SelectionStart { get { return baseTextBox.SelectionStart; } set { baseTextBox.SelectionStart = value; } } + + [Browsable(false)] + public int SelectionLength { get { return baseTextBox.SelectionLength; } set { baseTextBox.SelectionLength = value; } } + + [Browsable(false)] + public int TextLength { get { return baseTextBox.TextLength; } } + + [Browsable(false)] + public override System.Drawing.Color ForeColor { get; set; } + + + //Material Skin properties + + private bool _UseTallSize; + + [Category("Material Skin"), DefaultValue(true), Description("Using a larger size enables the hint to always be visible")] + public bool UseTallSize + { + get { return _UseTallSize; } + set + { + _UseTallSize = value; + UpdateHeight(); + UpdateRects(); + Invalidate(); + } + } + + private bool _showAssistiveText; + [Category("Material Skin"), DefaultValue(false), Description("Assistive elements provide additional detail about text entered into text fields. Could be Helper text or Error message.")] + public bool ShowAssistiveText + { + get { return _showAssistiveText; } + set + { + _showAssistiveText = value; + if (_showAssistiveText) + _helperTextHeight = HELPER_TEXT_HEIGHT; + else + _helperTextHeight = 0; + UpdateHeight(); + //UpdateRects(); + Invalidate(); + } + } + + private string _helperText; + + [Category("Material Skin"), DefaultValue(""), Localizable(true), Description("Helper text conveys additional guidance about the input field, such as how it will be used.")] + public string HelperText + { + get { return _helperText; } + set + { + _helperText = value; + Invalidate(); + } + } + + private string _errorMessage; + + [Category("Material Skin"), DefaultValue(""), Localizable(true), Description("When text input isn't accepted, an error message can display instructions on how to fix it. Error messages are displayed below the input line, replacing helper text until fixed.")] + public string ErrorMessage + { + get { return _errorMessage; } + set + { + _errorMessage = value; + Invalidate(); + } + } + + [Category("Material Skin"), DefaultValue(""), Localizable(true)] + public string Hint + { + get { return baseTextBox.Hint; } + set + { + baseTextBox.Hint = value; + hasHint = !String.IsNullOrEmpty(baseTextBox.Hint); + UpdateRects(); + Invalidate(); + } + } + + [Category("Material Skin"), DefaultValue(true)] + public bool UseAccent { get; set; } + + private Image _leadingIcon; + + [Category("Material Skin"), Browsable(true), Localizable(false)] + /// + /// Gets or sets the leading Icon + /// + public Image LeadingIcon + { + get { return _leadingIcon; } + set + { + _leadingIcon = value; + UpdateRects(); + preProcessIcons(); + Invalidate(); + } + } + + private Image _trailingIcon; + + [Category("Material Skin"), Browsable(true), Localizable(false)] + /// + /// Gets or sets the trailing Icon + /// + public Image TrailingIcon + { + get { return _trailingIcon; } + set + { + _trailingIcon = value; + UpdateRects(); + preProcessIcons(); + Invalidate(); + } + } + + public enum PrefixSuffixTypes + { + None, + Prefix, + Suffix, + } + + private PrefixSuffixTypes _prefixsuffix; + [Category("Material Skin"), DefaultValue(PrefixSuffixTypes.None), Description("Set Prefix/Suffix/None")] + public PrefixSuffixTypes PrefixSuffix + { + get { return _prefixsuffix; } + set + { + _prefixsuffix = value; + UpdateRects(); //Génére une nullref exception + if (_prefixsuffix == PrefixSuffixTypes.Suffix) + RightToLeft = RightToLeft.Yes; + else + RightToLeft = RightToLeft.No; + Invalidate(); + } + } + + private string _prefixsuffixText; + [Category("Material Skin"), DefaultValue(""), Localizable(true), Description("Set Prefix or Suffix text")] + public string PrefixSuffixText + { + get { return _prefixsuffixText; } + set + { + //if (_prefixsuffixText != value) + //{ + _prefixsuffixText = value; + UpdateRects(); + Invalidate(); + //} + } + } + + //TextBox properties + + public override ContextMenuStrip ContextMenuStrip + { + get { return baseTextBox.ContextMenuStrip; } + set + { + if (value != null) + { + //ContextMenuStrip = value; + baseTextBox.ContextMenuStrip = value; + base.ContextMenuStrip = value; + } + else + { + //ContextMenuStrip = cms; + baseTextBox.ContextMenuStrip = cms; + base.ContextMenuStrip = cms; + } + _lastContextMenuStrip = base.ContextMenuStrip; + } + } + + [Browsable(false)] + public override Color BackColor { get { return Parent == null ? SkinManager.BackgroundColor : Parent.BackColor; } } + + public override string Text { get { return baseTextBox.Text; } set { baseTextBox.Text = value; UpdateRects(); } } + + [Category("Appearance")] + public HorizontalAlignment TextAlign { get { return baseTextBox.TextAlign; } set { baseTextBox.TextAlign = value; } } + + [Category("Behavior")] + public CharacterCasing CharacterCasing { get { return baseTextBox.CharacterCasing; } set { baseTextBox.CharacterCasing = value; } } + + [Category("Behavior")] + public bool HideSelection { get { return baseTextBox.HideSelection; } set { baseTextBox.HideSelection = value; } } + + [Category("Behavior")] + public int MaxLength { get { return baseTextBox.MaxLength; } set { baseTextBox.MaxLength = value; } } + + [Category("Behavior")] + public char PasswordChar { get { return baseTextBox.PasswordChar; } set { baseTextBox.PasswordChar = value; } } + + [Category("Behavior")] + public bool ShortcutsEnabled + { + get + { return baseTextBox.ShortcutsEnabled; } + set + { + baseTextBox.ShortcutsEnabled = value; + if (value == false) + { + baseTextBox.ContextMenuStrip = null; + base.ContextMenuStrip = null; + } + else + { + baseTextBox.ContextMenuStrip = _lastContextMenuStrip; + base.ContextMenuStrip = _lastContextMenuStrip; + } + } + } + + [Category("Behavior")] + public bool UseSystemPasswordChar { get { return baseTextBox.UseSystemPasswordChar; } set { baseTextBox.UseSystemPasswordChar = value; } } + + public new object Tag { get { return baseTextBox.Tag; } set { baseTextBox.Tag = value; } } + + private bool _readonly; + [Category("Behavior")] + public bool ReadOnly + { + get { return _readonly; } + set + { + _readonly = value; + if (Enabled == true) + { + baseTextBox.ReadOnly = _readonly; + } + this.Invalidate(); + } + } + + private bool _animateReadOnly; + + [Category("Material Skin")] + [Browsable(true)] + public bool AnimateReadOnly + { + get => _animateReadOnly; + set + { + _animateReadOnly = value; + Invalidate(); + } + } + + private bool _leaveOnEnterKey; + + [Category("Material Skin"), DefaultValue(false), Description("Select next control which have TabStop property set to True when enter key is pressed.")] + public bool LeaveOnEnterKey + { + get => _leaveOnEnterKey; + set + { + _leaveOnEnterKey = value; + if (value) + { + baseTextBox.KeyDown += new KeyEventHandler(LeaveOnEnterKey_KeyDown); + } + else + { + baseTextBox.KeyDown -= LeaveOnEnterKey_KeyDown; + } + Invalidate(); + } + } + + public AutoCompleteStringCollection AutoCompleteCustomSource { get { return baseTextBox.AutoCompleteCustomSource; } set { baseTextBox.AutoCompleteCustomSource = value; } } + + public AutoCompleteSource AutoCompleteSource { get { return baseTextBox.AutoCompleteSource; } set { baseTextBox.AutoCompleteSource = value; } } + + public AutoCompleteMode AutoCompleteMode { get { return baseTextBox.AutoCompleteMode; } set { baseTextBox.AutoCompleteMode = value; } } + + public void SelectAll() { baseTextBox.SelectAll(); } + + public void Clear() { baseTextBox.Clear(); } + + public void Copy() { baseTextBox.Copy(); } + + public void Cut() { baseTextBox.Cut(); } + + public void Undo() { baseTextBox.Undo(); } + + public void Paste() { baseTextBox.Paste(); } + + #region "Events" + + [Category("Action")] + [Description("Fires when Leading Icon is clicked")] + public event EventHandler LeadingIconClick; + + [Category("Action")] + [Description("Fires when Trailing Icon is clicked")] + public event EventHandler TrailingIconClick; + + #endregion + + # region Forwarding events to baseTextBox + + public event EventHandler AcceptsTabChanged + { + add + { + baseTextBox.AcceptsTabChanged += value; + } + remove + { + baseTextBox.AcceptsTabChanged -= value; + } + } + + public new event EventHandler AutoSizeChanged + { + add + { + baseTextBox.AutoSizeChanged += value; + } + remove + { + baseTextBox.AutoSizeChanged -= value; + } + } + + public new event EventHandler BackgroundImageChanged + { + add + { + baseTextBox.BackgroundImageChanged += value; + } + remove + { + baseTextBox.BackgroundImageChanged -= value; + } + } + + public new event EventHandler BackgroundImageLayoutChanged + { + add + { + baseTextBox.BackgroundImageLayoutChanged += value; + } + remove + { + baseTextBox.BackgroundImageLayoutChanged -= value; + } + } + + public new event EventHandler BindingContextChanged + { + add + { + baseTextBox.BindingContextChanged += value; + } + remove + { + baseTextBox.BindingContextChanged -= value; + } + } + + public event EventHandler BorderStyleChanged + { + add + { + baseTextBox.BorderStyleChanged += value; + } + remove + { + baseTextBox.BorderStyleChanged -= value; + } + } + + public new event EventHandler CausesValidationChanged + { + add + { + baseTextBox.CausesValidationChanged += value; + } + remove + { + baseTextBox.CausesValidationChanged -= value; + } + } + + public new event UICuesEventHandler ChangeUICues + { + add + { + baseTextBox.ChangeUICues += value; + } + remove + { + baseTextBox.ChangeUICues -= value; + } + } + + public new event EventHandler Click + { + add + { + baseTextBox.Click += value; + } + remove + { + baseTextBox.Click -= value; + } + } + + public new event EventHandler ClientSizeChanged + { + add + { + baseTextBox.ClientSizeChanged += value; + } + remove + { + baseTextBox.ClientSizeChanged -= value; + } + } + + #if NETFRAMEWORK + public new event EventHandler ContextMenuChanged + { + add + { + baseTextBox.ContextMenuChanged += value; + } + remove + { + baseTextBox.ContextMenuChanged -= value; + } + } + #endif + + public new event EventHandler ContextMenuStripChanged + { + add + { + baseTextBox.ContextMenuStripChanged += value; + } + remove + { + baseTextBox.ContextMenuStripChanged -= value; + } + } + + public new event ControlEventHandler ControlAdded + { + add + { + baseTextBox.ControlAdded += value; + } + remove + { + baseTextBox.ControlAdded -= value; + } + } + + public new event ControlEventHandler ControlRemoved + { + add + { + baseTextBox.ControlRemoved += value; + } + remove + { + baseTextBox.ControlRemoved -= value; + } + } + + public new event EventHandler CursorChanged + { + add + { + baseTextBox.CursorChanged += value; + } + remove + { + baseTextBox.CursorChanged -= value; + } + } + + public new event EventHandler Disposed + { + add + { + baseTextBox.Disposed += value; + } + remove + { + baseTextBox.Disposed -= value; + } + } + + public new event EventHandler DockChanged + { + add + { + baseTextBox.DockChanged += value; + } + remove + { + baseTextBox.DockChanged -= value; + } + } + + public new event EventHandler DoubleClick + { + add + { + baseTextBox.DoubleClick += value; + } + remove + { + baseTextBox.DoubleClick -= value; + } + } + + public new event DragEventHandler DragDrop + { + add + { + baseTextBox.DragDrop += value; + } + remove + { + baseTextBox.DragDrop -= value; + } + } + + public new event DragEventHandler DragEnter + { + add + { + baseTextBox.DragEnter += value; + } + remove + { + baseTextBox.DragEnter -= value; + } + } + + public new event EventHandler DragLeave + { + add + { + baseTextBox.DragLeave += value; + } + remove + { + baseTextBox.DragLeave -= value; + } + } + + public new event DragEventHandler DragOver + { + add + { + baseTextBox.DragOver += value; + } + remove + { + baseTextBox.DragOver -= value; + } + } + + public new event EventHandler EnabledChanged + { + add + { + baseTextBox.EnabledChanged += value; + } + remove + { + baseTextBox.EnabledChanged -= value; + } + } + + public new event EventHandler Enter + { + add + { + baseTextBox.Enter += value; + } + remove + { + baseTextBox.Enter -= value; + } + } + + public new event EventHandler FontChanged + { + add + { + baseTextBox.FontChanged += value; + } + remove + { + baseTextBox.FontChanged -= value; + } + } + + public new event EventHandler ForeColorChanged + { + add + { + baseTextBox.ForeColorChanged += value; + } + remove + { + baseTextBox.ForeColorChanged -= value; + } + } + + public new event GiveFeedbackEventHandler GiveFeedback + { + add + { + baseTextBox.GiveFeedback += value; + } + remove + { + baseTextBox.GiveFeedback -= value; + } + } + + public new event EventHandler GotFocus + { + add + { + baseTextBox.GotFocus += value; + } + remove + { + baseTextBox.GotFocus -= value; + } + } + + public new event EventHandler HandleCreated + { + add + { + baseTextBox.HandleCreated += value; + } + remove + { + baseTextBox.HandleCreated -= value; + } + } + + public new event EventHandler HandleDestroyed + { + add + { + baseTextBox.HandleDestroyed += value; + } + remove + { + baseTextBox.HandleDestroyed -= value; + } + } + + public new event HelpEventHandler HelpRequested + { + add + { + baseTextBox.HelpRequested += value; + } + remove + { + baseTextBox.HelpRequested -= value; + } + } + + public event EventHandler HideSelectionChanged + { + add + { + baseTextBox.HideSelectionChanged += value; + } + remove + { + baseTextBox.HideSelectionChanged -= value; + } + } + + public new event EventHandler ImeModeChanged + { + add + { + baseTextBox.ImeModeChanged += value; + } + remove + { + baseTextBox.ImeModeChanged -= value; + } + } + + public new event InvalidateEventHandler Invalidated + { + add + { + baseTextBox.Invalidated += value; + } + remove + { + baseTextBox.Invalidated -= value; + } + } + + public new event KeyEventHandler KeyDown + { + add + { + baseTextBox.KeyDown += value; + } + remove + { + baseTextBox.KeyDown -= value; + } + } + + public new event KeyPressEventHandler KeyPress + { + add + { + baseTextBox.KeyPress += value; + } + remove + { + baseTextBox.KeyPress -= value; + } + } + + public new event KeyEventHandler KeyUp + { + add + { + baseTextBox.KeyUp += value; + } + remove + { + baseTextBox.KeyUp -= value; + } + } + + public new event LayoutEventHandler Layout + { + add + { + baseTextBox.Layout += value; + } + remove + { + baseTextBox.Layout -= value; + } + } + + public new event EventHandler Leave + { + add + { + baseTextBox.Leave += value; + } + remove + { + baseTextBox.Leave -= value; + } + } + + public new event EventHandler LocationChanged + { + add + { + baseTextBox.LocationChanged += value; + } + remove + { + baseTextBox.LocationChanged -= value; + } + } + + public new event EventHandler LostFocus + { + add + { + baseTextBox.LostFocus += value; + } + remove + { + baseTextBox.LostFocus -= value; + } + } + + public new event EventHandler MarginChanged + { + add + { + baseTextBox.MarginChanged += value; + } + remove + { + baseTextBox.MarginChanged -= value; + } + } + + public event EventHandler ModifiedChanged + { + add + { + baseTextBox.ModifiedChanged += value; + } + remove + { + baseTextBox.ModifiedChanged -= value; + } + } + + public new event EventHandler MouseCaptureChanged + { + add + { + baseTextBox.MouseCaptureChanged += value; + } + remove + { + baseTextBox.MouseCaptureChanged -= value; + } + } + + public new event MouseEventHandler MouseClick + { + add + { + baseTextBox.MouseClick += value; + } + remove + { + baseTextBox.MouseClick -= value; + } + } + + public new event MouseEventHandler MouseDoubleClick + { + add + { + baseTextBox.MouseDoubleClick += value; + } + remove + { + baseTextBox.MouseDoubleClick -= value; + } + } + + public new event MouseEventHandler MouseDown + { + add + { + baseTextBox.MouseDown += value; + } + remove + { + baseTextBox.MouseDown -= value; + } + } + + public new event EventHandler MouseEnter + { + add + { + baseTextBox.MouseEnter += value; + } + remove + { + baseTextBox.MouseEnter -= value; + } + } + + public new event EventHandler MouseHover + { + add + { + baseTextBox.MouseHover += value; + } + remove + { + baseTextBox.MouseHover -= value; + } + } + + public new event EventHandler MouseLeave + { + add + { + baseTextBox.MouseLeave += value; + } + remove + { + baseTextBox.MouseLeave -= value; + } + } + + public new event MouseEventHandler MouseMove + { + add + { + baseTextBox.MouseMove += value; + } + remove + { + baseTextBox.MouseMove -= value; + } + } + + public new event MouseEventHandler MouseUp + { + add + { + baseTextBox.MouseUp += value; + } + remove + { + baseTextBox.MouseUp -= value; + } + } + + public new event MouseEventHandler MouseWheel + { + add + { + baseTextBox.MouseWheel += value; + } + remove + { + baseTextBox.MouseWheel -= value; + } + } + + public new event EventHandler Move + { + add + { + baseTextBox.Move += value; + } + remove + { + baseTextBox.Move -= value; + } + } + + public event EventHandler MultilineChanged + { + add + { + baseTextBox.MultilineChanged += value; + } + remove + { + baseTextBox.MultilineChanged -= value; + } + } + + public new event EventHandler PaddingChanged + { + add + { + baseTextBox.PaddingChanged += value; + } + remove + { + baseTextBox.PaddingChanged -= value; + } + } + + public new event PaintEventHandler Paint + { + add + { + baseTextBox.Paint += value; + } + remove + { + baseTextBox.Paint -= value; + } + } + + public new event EventHandler ParentChanged + { + add + { + baseTextBox.ParentChanged += value; + } + remove + { + baseTextBox.ParentChanged -= value; + } + } + + public new event PreviewKeyDownEventHandler PreviewKeyDown + { + add + { + baseTextBox.PreviewKeyDown += value; + } + remove + { + baseTextBox.PreviewKeyDown -= value; + } + } + + public new event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp + { + add + { + baseTextBox.QueryAccessibilityHelp += value; + } + remove + { + baseTextBox.QueryAccessibilityHelp -= value; + } + } + + public new event QueryContinueDragEventHandler QueryContinueDrag + { + add + { + baseTextBox.QueryContinueDrag += value; + } + remove + { + baseTextBox.QueryContinueDrag -= value; + } + } + + public event EventHandler ReadOnlyChanged + { + add + { + baseTextBox.ReadOnlyChanged += value; + } + remove + { + baseTextBox.ReadOnlyChanged -= value; + } + } + + public new event EventHandler RegionChanged + { + add + { + baseTextBox.RegionChanged += value; + } + remove + { + baseTextBox.RegionChanged -= value; + } + } + + public new event EventHandler Resize + { + add + { + baseTextBox.Resize += value; + } + remove + { + baseTextBox.Resize -= value; + } + } + + public new event EventHandler RightToLeftChanged + { + add + { + baseTextBox.RightToLeftChanged += value; + } + remove + { + baseTextBox.RightToLeftChanged -= value; + } + } + + public new event EventHandler SizeChanged + { + add + { + baseTextBox.SizeChanged += value; + } + remove + { + baseTextBox.SizeChanged -= value; + } + } + + public new event EventHandler StyleChanged + { + add + { + baseTextBox.StyleChanged += value; + } + remove + { + baseTextBox.StyleChanged -= value; + } + } + + public new event EventHandler SystemColorsChanged + { + add + { + baseTextBox.SystemColorsChanged += value; + } + remove + { + baseTextBox.SystemColorsChanged -= value; + } + } + + public new event EventHandler TabIndexChanged + { + add + { + baseTextBox.TabIndexChanged += value; + } + remove + { + baseTextBox.TabIndexChanged -= value; + } + } + + public new event EventHandler TabStopChanged + { + add + { + baseTextBox.TabStopChanged += value; + } + remove + { + baseTextBox.TabStopChanged -= value; + } + } + + public event EventHandler TextAlignChanged + { + add + { + baseTextBox.TextAlignChanged += value; + } + remove + { + baseTextBox.TextAlignChanged -= value; + } + } + + public new event EventHandler TextChanged + { + add + { + baseTextBox.TextChanged += value; + } + remove + { + baseTextBox.TextChanged -= value; + } + } + + public new event EventHandler Validated + { + add + { + baseTextBox.Validated += value; + } + remove + { + baseTextBox.Validated -= value; + } + } + + public new event CancelEventHandler Validating + { + add + { + baseTextBox.Validating += value; + } + remove + { + baseTextBox.Validating -= value; + } + } + + public new event EventHandler VisibleChanged + { + add + { + baseTextBox.VisibleChanged += value; + } + remove + { + baseTextBox.VisibleChanged -= value; + } + } + # endregion + + private readonly AnimationManager _animationManager; + + public bool isFocused = false; + private const int PREFIX_SUFFIX_PADDING = 4; + private const int ICON_SIZE = 24; + private const int HINT_TEXT_SMALL_SIZE = 18; + private const int HINT_TEXT_SMALL_Y = 4; + private const int ACTIVATION_INDICATOR_HEIGHT = 2; + private const int HELPER_TEXT_HEIGHT = 16; + private const int FONT_HEIGHT = 20; + + private int LEFT_PADDING = 16; + private int RIGHT_PADDING = 12; + + private int HEIGHT = 48; + + private int LINE_Y; + private bool hasHint; + private bool _errorState = false; + private int _left_padding; + private int _right_padding; + private int _prefix_padding; + private int _suffix_padding; + private int _helperTextHeight; + private Rectangle _leadingIconBounds; + private Rectangle _trailingIconBounds; + + private Dictionary iconsBrushes; + private Dictionary iconsErrorBrushes; + + protected readonly BaseTextBox baseTextBox; + + public MaterialTextBox2():this(RightToLeft.No) + { + + } + public MaterialTextBox2(RightToLeft RightToLeft) + { + // Material Properties + if (RightToLeft == RightToLeft.Yes) + { + var temp = LEFT_PADDING; + LEFT_PADDING = RIGHT_PADDING; + RIGHT_PADDING = temp; + } + + UseAccent = true; + MouseState = MouseState.OUT; + + SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.DoubleBuffer, true); + + // Animations + _animationManager = new AnimationManager + { + Increment = 0.06, + AnimationType = AnimationType.EaseInOut, + InterruptAnimation = false + }; + _animationManager.OnAnimationProgress += sender => Invalidate(); + + SkinManager.ColorSchemeChanged += sender => + { + preProcessIcons(); + }; + + SkinManager.ThemeChanged += sender => + { + preProcessIcons(); + }; + + Font = SkinManager.getFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft); + + baseTextBox = new BaseTextBox + { + BorderStyle = BorderStyle.None, + Font = base.Font, + ForeColor = SkinManager.TextHighEmphasisColor, + Multiline = false, + Location = new Point(LEFT_PADDING, HEIGHT/2- FONT_HEIGHT/2), + Width = Width - (LEFT_PADDING + RIGHT_PADDING), + Height = FONT_HEIGHT, + RightToLeft=RightToLeft, + TextAlign= (RightToLeft == RightToLeft.Yes)? HorizontalAlignment.Right: HorizontalAlignment.Left + }; + + Enabled = true; + ReadOnly = false; + Size = new Size(250, HEIGHT); + + UseTallSize = true; + PrefixSuffix = PrefixSuffixTypes.None; + ShowAssistiveText = false; + HelperText = string.Empty; + ErrorMessage = string.Empty; + + if (!Controls.Contains(baseTextBox) && !DesignMode) + { + Controls.Add(baseTextBox); + } + + baseTextBox.GotFocus += (sender, args) => + { + if (Enabled) + { + isFocused = true; + if (RightToLeft==RightToLeft.Yes) SendKeys.Send("^+"); + _animationManager.StartNewAnimation(AnimationDirection.In); + } + else + base.Focus(); + UpdateRects(); + }; + baseTextBox.LostFocus += (sender, args) => + { + isFocused = false; + _animationManager.StartNewAnimation(AnimationDirection.Out); + UpdateRects(); + }; + + baseTextBox.TextChanged += new EventHandler(Redraw); + baseTextBox.BackColorChanged += new EventHandler(Redraw); + + baseTextBox.TabStop = true; + this.TabStop = false; + + cms.Opening += ContextMenuStripOnOpening; + cms.OnItemClickStart += ContextMenuStripOnItemClickStart; + ContextMenuStrip = cms; + } + + private void Redraw(object sencer, EventArgs e) + { + SuspendLayout(); + Invalidate(); + ResumeLayout(false); + } + + protected override void OnPaint(PaintEventArgs pevent) + { + var g = pevent.Graphics; + g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; + g.Clear(Parent.BackColor); + SolidBrush backBrush = new SolidBrush(DrawHelper.BlendColor(Parent.BackColor, SkinManager.BackgroundAlternativeColor, SkinManager.BackgroundAlternativeColor.A)); + + //backColor + g.FillRectangle( + !Enabled ? SkinManager.BackgroundDisabledBrush : // Disabled + isFocused ? SkinManager.BackgroundFocusBrush : // Focused + MouseState == MouseState.HOVER && (!ReadOnly || (ReadOnly && !AnimateReadOnly)) ? SkinManager.BackgroundHoverBrush : // Hover + backBrush, // Normal + ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, LINE_Y); + + baseTextBox.BackColor = !Enabled ? ColorHelper.RemoveAlpha(SkinManager.BackgroundDisabledColor, BackColor) : //Disabled + isFocused ? DrawHelper.BlendColor(BackColor, SkinManager.BackgroundFocusColor, SkinManager.BackgroundFocusColor.A) : //Focused + MouseState == MouseState.HOVER && (!ReadOnly || (ReadOnly && !AnimateReadOnly)) ? DrawHelper.BlendColor(BackColor, SkinManager.BackgroundHoverColor, SkinManager.BackgroundHoverColor.A) : // Hover + DrawHelper.BlendColor(BackColor, SkinManager.BackgroundAlternativeColor, SkinManager.BackgroundAlternativeColor.A); // Normal + + //Leading Icon + if (LeadingIcon != null) + { + if (_errorState) + g.FillRectangle(iconsErrorBrushes["_leadingIcon"], _leadingIconBounds); + else + g.FillRectangle(iconsBrushes["_leadingIcon"], _leadingIconBounds); + } + + //Trailing Icon + if (TrailingIcon != null) + { + if (_errorState) + g.FillRectangle(iconsErrorBrushes["_trailingIcon"], _trailingIconBounds); + else + g.FillRectangle(iconsBrushes["_trailingIcon"], _trailingIconBounds); + } + + // HintText + bool userTextPresent = !String.IsNullOrEmpty(Text); + Rectangle helperTextRect = new Rectangle(LEFT_PADDING - _prefix_padding, LINE_Y + ACTIVATION_INDICATOR_HEIGHT, Width - (LEFT_PADDING - _prefix_padding) - _right_padding, HELPER_TEXT_HEIGHT); + Rectangle hintRect = new Rectangle(_left_padding - _prefix_padding, HINT_TEXT_SMALL_Y, Width - (_left_padding - _prefix_padding) - _right_padding, HINT_TEXT_SMALL_SIZE); + int hintTextSize = 12; + + // bottom line base + g.FillRectangle(SkinManager.DividersAlternativeBrush, 0, LINE_Y, Width, 1); + + if (ReadOnly == false || (ReadOnly && AnimateReadOnly)) + { + if (!_animationManager.IsAnimating()) + { + // No animation + + // bottom line + if (isFocused) + { + g.FillRectangle(_errorState ? SkinManager.BackgroundHoverRedBrush : isFocused ? UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush : SkinManager.DividersBrush, 0, LINE_Y, Width, isFocused ? 2 : 1); + } + } + else + { + // Animate - Focus got/lost + double animationProgress = _animationManager.GetProgress(); + + // Line Animation + int LineAnimationWidth = (int)(Width * animationProgress); + int LineAnimationX = (Width / 2) - (LineAnimationWidth / 2); + g.FillRectangle(UseAccent ? SkinManager.ColorScheme.AccentBrush : SkinManager.ColorScheme.PrimaryBrush, LineAnimationX, LINE_Y, LineAnimationWidth, 2); + } + } + + // Prefix: + if (_prefixsuffix == PrefixSuffixTypes.Prefix && _prefixsuffixText != null && _prefixsuffixText.Length > 0 && (isFocused || userTextPresent || !hasHint)) + { + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + Rectangle prefixRect = new Rectangle( + _left_padding - _prefix_padding, + hasHint && UseTallSize ? (hintRect.Y + hintRect.Height) - 2 : ClientRectangle.Y, +// NativeText.MeasureLogString(_prefixsuffixText, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1)).Width, + _prefix_padding, + hasHint && UseTallSize ? LINE_Y - (hintRect.Y + hintRect.Height) : LINE_Y); + + // Draw Prefix text + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + NativeText.DrawTransparentText( + _prefixsuffixText, + SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft), + Enabled ? SkinManager.TextMediumEmphasisColor : SkinManager.TextDisabledOrHintColor, + prefixRect.Location, + prefixRect.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + } + + // Suffix: + if (_prefixsuffix == PrefixSuffixTypes.Suffix && _prefixsuffixText != null && _prefixsuffixText.Length > 0 && (isFocused || userTextPresent || !hasHint)) + { + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + Rectangle suffixRect = new Rectangle( + Width - _right_padding , + hasHint && UseTallSize ? (hintRect.Y + hintRect.Height) - 2 : ClientRectangle.Y, + //NativeText.MeasureLogString(_prefixsuffixText, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1)).Width + PREFIX_SUFFIX_PADDING, + _suffix_padding, + hasHint && UseTallSize ? LINE_Y - (hintRect.Y + hintRect.Height) : LINE_Y); + + // Draw Suffix text + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Left : NativeTextRenderer.TextAlignFlags.Right; + NativeText.DrawTransparentText( + _prefixsuffixText, + SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft), + Enabled ? SkinManager.TextMediumEmphasisColor : SkinManager.TextDisabledOrHintColor, + suffixRect.Location, + suffixRect.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + } + + // Draw hint text + if(hasHint && UseTallSize && (isFocused || userTextPresent)) + { + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + NativeText.DrawTransparentText( + Hint, + SkinManager.getTextBoxFontBySize(hintTextSize, RightToLeft), + Enabled ? !_errorState || (!userTextPresent && !isFocused) ? isFocused ? UseAccent ? + SkinManager.ColorScheme.AccentColor : // Focus Accent + SkinManager.ColorScheme.PrimaryColor : // Focus Primary + SkinManager.TextMediumEmphasisColor : // not focused + SkinManager.BackgroundHoverRedColor : // error state + SkinManager.TextDisabledOrHintColor, // Disabled + hintRect.Location, + hintRect.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + } + + // Draw helper text + if (_showAssistiveText && isFocused && !_errorState) + { + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + NativeText.DrawTransparentText( + HelperText, + SkinManager.getTextBoxFontBySize(hintTextSize, RightToLeft), + Enabled ? !_errorState || (!userTextPresent && !isFocused) ? isFocused ? UseAccent ? + SkinManager.ColorScheme.AccentColor : // Focus Accent + SkinManager.ColorScheme.PrimaryColor : // Focus Primary + SkinManager.TextMediumEmphasisColor : // not focused + SkinManager.BackgroundHoverRedColor : // error state + SkinManager.TextDisabledOrHintColor, // Disabled + helperTextRect.Location, + helperTextRect.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + } + + // Draw error message + if (_showAssistiveText && _errorState && ErrorMessage!=null) + { + using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) + { + var textAlignFlag = RightToLeft == RightToLeft.Yes ? NativeTextRenderer.TextAlignFlags.Right : NativeTextRenderer.TextAlignFlags.Left; + NativeText.DrawTransparentText( + ErrorMessage, + SkinManager.getTextBoxFontBySize(hintTextSize, RightToLeft), + Enabled ? + SkinManager.BackgroundHoverRedColor : // error state + SkinManager.TextDisabledOrHintColor, // Disabled + helperTextRect.Location, + helperTextRect.Size, + textAlignFlag | NativeTextRenderer.TextAlignFlags.Middle); + } + } + + } + + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + + if (DesignMode) + return; + + if (LeadingIcon != null && _leadingIconBounds.Contains(e.Location) && LeadingIconClick != null) + { + Cursor = Cursors.Hand; + } + else if (TrailingIcon != null && _trailingIconBounds.Contains(e.Location) && TrailingIconClick != null) + { + Cursor = Cursors.Hand; + } + else + { + Cursor = Cursors.IBeam; + } + + } + + protected override void OnMouseDown(MouseEventArgs e) + { + if (DesignMode) + return; + + if (LeadingIcon != null && _leadingIconBounds.Contains(e.Location)) + { + LeadingIconClick?.Invoke(this, new EventArgs()); + } + else if (TrailingIcon != null && _trailingIconBounds.Contains(e.Location)) + { + TrailingIconClick?.Invoke(this, new EventArgs()); + } + else + { + baseTextBox?.Focus(); + } + base.OnMouseDown(e); + + } + protected override void OnMouseEnter(EventArgs e) + { + if (DesignMode) + return; + + base.OnMouseEnter(e); + MouseState = MouseState.HOVER; + Invalidate(); + } + + protected override void OnMouseLeave(EventArgs e) + { + if (DesignMode) + return; + + if (this.ClientRectangle.Contains(this.PointToClient(Control.MousePosition))) + return; + else + { + base.OnMouseLeave(e); + MouseState = MouseState.OUT; + Invalidate(); + } + } + + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + + UpdateRects(); + preProcessIcons(); + + Size = new Size(Width, HEIGHT); + LINE_Y = HEIGHT - ACTIVATION_INDICATOR_HEIGHT - _helperTextHeight; + + } + + protected override void OnCreateControl() + { + base.OnCreateControl(); + + // events + MouseState = MouseState.OUT; + + } + + #region Icon + + private static Size ResizeIcon(Image Icon) + { + int newWidth, newHeight; + //Resize icon if greater than ICON_SIZE + if (Icon.Width > ICON_SIZE || Icon.Height > ICON_SIZE) + { + //calculate aspect ratio + float aspect = Icon.Width / (float)Icon.Height; + + //calculate new dimensions based on aspect ratio + newWidth = (int)(ICON_SIZE * aspect); + newHeight = (int)(newWidth / aspect); + + //if one of the two dimensions exceed the box dimensions + if (newWidth > ICON_SIZE || newHeight > ICON_SIZE) + { + //depending on which of the two exceeds the box dimensions set it as the box dimension and calculate the other one based on the aspect ratio + if (newWidth > newHeight) + { + newWidth = ICON_SIZE; + newHeight = (int)(newWidth / aspect); + } + else + { + newHeight = ICON_SIZE; + newWidth = (int)(newHeight * aspect); + } + } + } + else + { + newWidth = Icon.Width; + newHeight = Icon.Height; + } + + return new Size() + { + Height = newHeight, + Width = newWidth + }; + } + + private void preProcessIcons() + { + if (_trailingIcon == null && _leadingIcon == null) return; + + // Calculate lightness and color + float l = (SkinManager.Theme == MaterialSkinManager.Themes.LIGHT) ? 0f : 1f; + + // Create matrices + float[][] matrixGray = { + new float[] { 0, 0, 0, 0, 0}, // Red scale factor + new float[] { 0, 0, 0, 0, 0}, // Green scale factor + new float[] { 0, 0, 0, 0, 0}, // Blue scale factor + new float[] { 0, 0, 0, Enabled ? .7f : .3f, 0}, // alpha scale factor + new float[] { l, l, l, 0, 1}};// offset + + float[][] matrixRed = { + new float[] { 0, 0, 0, 0, 0}, // Red scale factor + new float[] { 0, 0, 0, 0, 0}, // Green scale factor + new float[] { 0, 0, 0, 0, 0}, // Blue scale factor + new float[] { 0, 0, 0, 1, 0}, // alpha scale factor + new float[] { 1, 0, 0, 0, 1}};// offset + + ColorMatrix colorMatrixGray = new ColorMatrix(matrixGray); + ColorMatrix colorMatrixRed = new ColorMatrix(matrixRed); + + ImageAttributes grayImageAttributes = new ImageAttributes(); + ImageAttributes redImageAttributes = new ImageAttributes(); + + // Set color matrices + grayImageAttributes.SetColorMatrix(colorMatrixGray, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); + redImageAttributes.SetColorMatrix(colorMatrixRed, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); + + // Create brushes + iconsBrushes = new Dictionary(2); + iconsErrorBrushes = new Dictionary(2); + + // Image Rect + Rectangle destRect = new Rectangle(0, 0, ICON_SIZE, ICON_SIZE); + + if (_leadingIcon != null) + { + // ******************** + // *** _leadingIcon *** + // ******************** + + //Resize icon if greater than ICON_SIZE + Size newSize_leadingIcon = ResizeIcon(_leadingIcon); + Bitmap _leadingIconIconResized = new Bitmap(_leadingIcon, newSize_leadingIcon.Width, newSize_leadingIcon.Height); + + // Create a pre-processed copy of the image (GRAY) + Bitmap bgray = new Bitmap(destRect.Width, destRect.Height); + using (Graphics gGray = Graphics.FromImage(bgray)) + { + gGray.DrawImage(_leadingIconIconResized, + new Point[] { + new Point(0, 0), + new Point(destRect.Width, 0), + new Point(0, destRect.Height), + }, + destRect, GraphicsUnit.Pixel, grayImageAttributes); + } + + //Create a pre - processed copy of the image(RED) + Bitmap bred = new Bitmap(destRect.Width, destRect.Height); + using (Graphics gred = Graphics.FromImage(bred)) + { + gred.DrawImage(_leadingIconIconResized, + new Point[] { + new Point(0, 0), + new Point(destRect.Width, 0), + new Point(0, destRect.Height), + }, + destRect, GraphicsUnit.Pixel, redImageAttributes); + } + + // added processed image to brush for drawing + TextureBrush textureBrushGray = new TextureBrush(bgray); + TextureBrush textureBrushRed = new TextureBrush(bred); + + textureBrushGray.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; + textureBrushRed.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; + + var iconRect = _leadingIconBounds; + + textureBrushGray.TranslateTransform(iconRect.X + iconRect.Width / 2 - _leadingIconIconResized.Width / 2, + iconRect.Y + iconRect.Height / 2 - _leadingIconIconResized.Height / 2); + textureBrushRed.TranslateTransform(iconRect.X + iconRect.Width / 2 - _leadingIconIconResized.Width / 2, + iconRect.Y + iconRect.Height / 2 - _leadingIconIconResized.Height / 2); + + // add to dictionary + iconsBrushes.Add("_leadingIcon", textureBrushGray); + + iconsErrorBrushes.Add("_leadingIcon", textureBrushRed); + + } + + if (_trailingIcon != null) + { + // ********************* + // *** _trailingIcon *** + // ********************* + + //Resize icon if greater than ICON_SIZE + Size newSize_trailingIcon = ResizeIcon(_trailingIcon); + Bitmap _trailingIconResized = new Bitmap(_trailingIcon, newSize_trailingIcon.Width, newSize_trailingIcon.Height); + + // Create a pre-processed copy of the image (GRAY) + Bitmap bgray = new Bitmap(destRect.Width, destRect.Height); + using (Graphics gGray = Graphics.FromImage(bgray)) + { + gGray.DrawImage(_trailingIconResized, + new Point[] { + new Point(0, 0), + new Point(destRect.Width, 0), + new Point(0, destRect.Height), + }, + destRect, GraphicsUnit.Pixel, grayImageAttributes); + } + + //Create a pre - processed copy of the image(RED) + Bitmap bred = new Bitmap(destRect.Width, destRect.Height); + using (Graphics gred = Graphics.FromImage(bred)) + { + gred.DrawImage(_trailingIconResized, + new Point[] { + new Point(0, 0), + new Point(destRect.Width, 0), + new Point(0, destRect.Height), + }, + destRect, GraphicsUnit.Pixel, redImageAttributes); + } + + + // added processed image to brush for drawing + TextureBrush textureBrushGray = new TextureBrush(bgray); + TextureBrush textureBrushRed = new TextureBrush(bred); + + textureBrushGray.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; + textureBrushRed.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp; + + var iconRect = _trailingIconBounds; + + textureBrushGray.TranslateTransform(iconRect.X + iconRect.Width / 2 - _trailingIconResized.Width / 2, + iconRect.Y + iconRect.Height / 2 - _trailingIconResized.Height / 2); + textureBrushRed.TranslateTransform(iconRect.X + iconRect.Width / 2 - _trailingIconResized.Width / 2, + iconRect.Y + iconRect.Height / 2 - _trailingIconResized.Height / 2); + + // add to dictionary + iconsBrushes.Add("_trailingIcon", textureBrushGray); + //iconsSelectedBrushes.Add(0, textureBrushColor); + iconsErrorBrushes.Add("_trailingIcon", textureBrushRed); + } + } + + #endregion + + private void UpdateHeight() + { + HEIGHT = _UseTallSize ? 48 : 36; + HEIGHT += _helperTextHeight; + Size = new Size(Size.Width, HEIGHT); + } + + private void UpdateRects() + { + if (LeadingIcon != null) + _left_padding = LEFT_PADDING + ICON_SIZE; + else + _left_padding = LEFT_PADDING; + + if (_trailingIcon != null) + _right_padding = RIGHT_PADDING + ICON_SIZE; + else + _right_padding = RIGHT_PADDING; + + if (_prefixsuffix == PrefixSuffixTypes.Prefix && !string.IsNullOrEmpty(_prefixsuffixText)) + { + using (NativeTextRenderer NativeText = new NativeTextRenderer(CreateGraphics())) + { + _prefix_padding = NativeText.MeasureLogString(_prefixsuffixText, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft)).Width + PREFIX_SUFFIX_PADDING; + _left_padding += _prefix_padding; + } + } + else + _prefix_padding = 0; + + if (_prefixsuffix == PrefixSuffixTypes.Suffix && !string.IsNullOrEmpty(_prefixsuffixText)) + { + using (NativeTextRenderer NativeText = new NativeTextRenderer(CreateGraphics())) + { + _suffix_padding = NativeText.MeasureLogString(_prefixsuffixText, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle1, RightToLeft)).Width + PREFIX_SUFFIX_PADDING; + _right_padding += _suffix_padding; + } + } + else + _suffix_padding = 0; + + if (hasHint && UseTallSize && (isFocused || !string.IsNullOrEmpty(Text))) + { + baseTextBox.Location = new Point(_left_padding, 22); + baseTextBox.Width = Width - (_left_padding + _right_padding); + baseTextBox.Height = FONT_HEIGHT; + } + else + { + baseTextBox.Location = new Point(_left_padding, (LINE_Y + ACTIVATION_INDICATOR_HEIGHT) / 2 - FONT_HEIGHT / 2); + baseTextBox.Width = Width - (_left_padding + _right_padding); + baseTextBox.Height = FONT_HEIGHT; + } + + _leadingIconBounds = new Rectangle(8, ((LINE_Y + ACTIVATION_INDICATOR_HEIGHT) / 2) - (ICON_SIZE / 2), ICON_SIZE, ICON_SIZE); + _trailingIconBounds = new Rectangle(Width - (ICON_SIZE + 8), ((LINE_Y + ACTIVATION_INDICATOR_HEIGHT) / 2) - (ICON_SIZE / 2), ICON_SIZE, ICON_SIZE); + } + + public void SetErrorState(bool ErrorState) + { + _errorState = ErrorState; + if (_errorState) + baseTextBox.ForeColor = SkinManager.BackgroundHoverRedColor; + else + baseTextBox.ForeColor = SkinManager.TextHighEmphasisColor; + baseTextBox.Invalidate(); + Invalidate(); + } + + public bool GetErrorState() + { + return _errorState; + } + + private void ContextMenuStripOnItemClickStart(object sender, ToolStripItemClickedEventArgs toolStripItemClickedEventArgs) + { + switch (toolStripItemClickedEventArgs.ClickedItem.Text) + { + case "Undo": + Undo(); + break; + case "Cut": + Cut(); + break; + case "Copy": + Copy(); + break; + case "Paste": + Paste(); + break; + case "Delete": + SelectedText = string.Empty; + break; + case "Select All": + SelectAll(); + break; + } + } + + private void ContextMenuStripOnOpening(object sender, CancelEventArgs cancelEventArgs) + { + if (sender is BaseTextBoxContextMenuStrip strip) + { + strip.undo.Enabled = baseTextBox.CanUndo && !ReadOnly; + strip.cut.Enabled = !string.IsNullOrEmpty(SelectedText) && !ReadOnly; + strip.copy.Enabled = !string.IsNullOrEmpty(SelectedText); + strip.paste.Enabled = Clipboard.ContainsText() && !ReadOnly; + strip.delete.Enabled = !string.IsNullOrEmpty(SelectedText) && !ReadOnly; + strip.selectAll.Enabled = !string.IsNullOrEmpty(Text); + } + } + + private void LeaveOnEnterKey_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + e.Handled = true; + e.SuppressKeyPress = true; + SendKeys.Send("{TAB}"); + } + } + } +} diff --git a/MaterialSkin/DrawHelper.cs b/MaterialSkin/DrawHelper.cs index a58eb4ec..92f64f08 100644 --- a/MaterialSkin/DrawHelper.cs +++ b/MaterialSkin/DrawHelper.cs @@ -1,112 +1,112 @@ -namespace MaterialSkin -{ - using System.Drawing; - using System.Drawing.Drawing2D; - - /// - /// Defines the - /// - internal static class DrawHelper - { - /// - /// The CreateRoundRect - /// - /// The x - /// The y - /// The width - /// The height - /// The radius - /// The - public static GraphicsPath CreateRoundRect(float x, float y, float width, float height, float radius) - { - var gp = new GraphicsPath(); - gp.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90); - gp.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90); - gp.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90); - gp.AddArc(x, y, radius * 2, radius * 2, 180, 90); - gp.CloseFigure(); - return gp; - } - - /// - /// The CreateRoundRect - /// - /// The rect - /// The radius - /// The - public static GraphicsPath CreateRoundRect(Rectangle rect, float radius) - { - return CreateRoundRect(rect.X, rect.Y, rect.Width, rect.Height, radius); - } - - /// - /// The CreateRoundRect - /// - /// The rect - /// The radius - /// The - public static GraphicsPath CreateRoundRect(RectangleF rect, float radius) - { - return CreateRoundRect(rect.X, rect.Y, rect.Width, rect.Height, radius); - } - - /// - /// The BlendColor - /// - /// The backgroundColor - /// The frontColor - /// The blend - /// The - public static Color BlendColor(Color backgroundColor, Color frontColor, double blend) - { - var ratio = blend / 255d; - var invRatio = 1d - ratio; - var r = (int)((backgroundColor.R * invRatio) + (frontColor.R * ratio)); - var g = (int)((backgroundColor.G * invRatio) + (frontColor.G * ratio)); - var b = (int)((backgroundColor.B * invRatio) + (frontColor.B * ratio)); - return Color.FromArgb(r, g, b); - } - - /// - /// The BlendColor - /// - /// The backgroundColor - /// The frontColor - /// The - public static Color BlendColor(Color backgroundColor, Color frontColor) - { - return BlendColor(backgroundColor, frontColor, frontColor.A); +namespace MaterialSkin +{ + using System.Drawing; + using System.Drawing.Drawing2D; + + /// + /// Defines the + /// + internal static class DrawHelper + { + /// + /// The CreateRoundRect + /// + /// The x + /// The y + /// The width + /// The height + /// The radius + /// The + public static GraphicsPath CreateRoundRect(float x, float y, float width, float height, float radius) + { + var gp = new GraphicsPath(); + gp.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90); + gp.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90); + gp.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90); + gp.AddArc(x, y, radius * 2, radius * 2, 180, 90); + gp.CloseFigure(); + return gp; } - - public static void DrawSquareShadow(Graphics g, Rectangle bounds) - { - using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(12, 0, 0, 0))) - { - GraphicsPath path; - path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 3.5f, bounds.Y - 1.5f, bounds.Width + 6, bounds.Height + 6), 8); - g.FillPath(shadowBrush, path); - path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 2.5f, bounds.Y - 1.5f, bounds.Width + 4, bounds.Height + 4), 6); - g.FillPath(shadowBrush, path); - path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 1.5f, bounds.Y - 0.5f, bounds.Width + 2, bounds.Height + 2), 4); - g.FillPath(shadowBrush, path); - path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 0.5f, bounds.Y + 1.5f, bounds.Width + 0, bounds.Height + 0), 4); - g.FillPath(shadowBrush, path); - path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 0.5f, bounds.Y + 2.5f, bounds.Width + 0, bounds.Height + 0), 4); - g.FillPath(shadowBrush, path); - path.Dispose(); - } - } - - public static void DrawRoundShadow(Graphics g, Rectangle bounds) - { - using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(12, 0, 0, 0))) - { - g.FillEllipse(shadowBrush, new Rectangle(bounds.X - 2, bounds.Y - 1, bounds.Width + 4, bounds.Height + 6)); - g.FillEllipse(shadowBrush, new Rectangle(bounds.X - 1, bounds.Y - 1, bounds.Width + 2, bounds.Height + 4)); - g.FillEllipse(shadowBrush, new Rectangle(bounds.X - 0, bounds.Y - 0, bounds.Width + 0, bounds.Height + 2)); - g.FillEllipse(shadowBrush, new Rectangle(bounds.X - 0, bounds.Y + 2, bounds.Width + 0, bounds.Height + 0)); - g.FillEllipse(shadowBrush, new Rectangle(bounds.X - 0, bounds.Y + 1, bounds.Width + 0, bounds.Height + 0)); - } - } - } + + /// + /// The CreateRoundRect + /// + /// The rect + /// The radius + /// The + public static GraphicsPath CreateRoundRect(Rectangle rect, float radius) + { + return CreateRoundRect(rect.X, rect.Y, rect.Width, rect.Height, radius); + } + + /// + /// The CreateRoundRect + /// + /// The rect + /// The radius + /// The + public static GraphicsPath CreateRoundRect(RectangleF rect, float radius) + { + return CreateRoundRect(rect.X, rect.Y, rect.Width, rect.Height, radius); + } + + /// + /// The BlendColor + /// + /// The backgroundColor + /// The frontColor + /// The blend + /// The + public static Color BlendColor(Color backgroundColor, Color frontColor, double blend) + { + var ratio = blend / 255d; + var invRatio = 1d - ratio; + var r = (int)((backgroundColor.R * invRatio) + (frontColor.R * ratio)); + var g = (int)((backgroundColor.G * invRatio) + (frontColor.G * ratio)); + var b = (int)((backgroundColor.B * invRatio) + (frontColor.B * ratio)); + return Color.FromArgb(r, g, b); + } + + /// + /// The BlendColor + /// + /// The backgroundColor + /// The frontColor + /// The + public static Color BlendColor(Color backgroundColor, Color frontColor) + { + return BlendColor(backgroundColor, frontColor, frontColor.A); + } + + public static void DrawSquareShadow(Graphics g, Rectangle bounds) + { + using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(12, 0, 0, 0))) + { + GraphicsPath path; + path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 3.5f, bounds.Y - 1.5f, bounds.Width + 6, bounds.Height + 6), 8); + g.FillPath(shadowBrush, path); + path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 2.5f, bounds.Y - 1.5f, bounds.Width + 4, bounds.Height + 4), 6); + g.FillPath(shadowBrush, path); + path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 1.5f, bounds.Y - 0.5f, bounds.Width + 2, bounds.Height + 2), 4); + g.FillPath(shadowBrush, path); + path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 0.5f, bounds.Y + 1.5f, bounds.Width + 0, bounds.Height + 0), 4); + g.FillPath(shadowBrush, path); + path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 0.5f, bounds.Y + 2.5f, bounds.Width + 0, bounds.Height + 0), 4); + g.FillPath(shadowBrush, path); + path.Dispose(); + } + } + + public static void DrawRoundShadow(Graphics g, Rectangle bounds) + { + using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(12, 0, 0, 0))) + { + g.FillEllipse(shadowBrush, new Rectangle(bounds.X - 2, bounds.Y - 1, bounds.Width + 4, bounds.Height + 6)); + g.FillEllipse(shadowBrush, new Rectangle(bounds.X - 1, bounds.Y - 1, bounds.Width + 2, bounds.Height + 4)); + g.FillEllipse(shadowBrush, new Rectangle(bounds.X - 0, bounds.Y - 0, bounds.Width + 0, bounds.Height + 2)); + g.FillEllipse(shadowBrush, new Rectangle(bounds.X - 0, bounds.Y + 2, bounds.Width + 0, bounds.Height + 0)); + g.FillEllipse(shadowBrush, new Rectangle(bounds.X - 0, bounds.Y + 1, bounds.Width + 0, bounds.Height + 0)); + } + } + } } \ No newline at end of file diff --git a/MaterialSkin/MaterialItemCollection.cs b/MaterialSkin/MaterialItemCollection.cs new file mode 100644 index 00000000..9c6263af --- /dev/null +++ b/MaterialSkin/MaterialItemCollection.cs @@ -0,0 +1,122 @@ +#region Imports + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Drawing.Design; +using System.Windows.Forms; + +#endregion + +namespace MaterialSkin +{ + #region MaterialItemCollectionChild + + [Editor(typeof(MaterialItemCollectionEditor), typeof(UITypeEditor))] + public class MaterialItemCollection : Collection + { + public event EventHandler ItemUpdated; + + public delegate void EventHandler(object sender, EventArgs e); + + public void AddRange(IEnumerable items) + { + foreach (object item in items) + { + Add(item); + } + } + + public void AddRange(string[] items) + { + foreach (object item in items) + { + Add(item); + } + } + + protected new void Add(object item) + { + base.Add(item); + ItemUpdated?.Invoke(this, null); + } + + protected override void InsertItem(int index, object item) + { + base.InsertItem(index, item); + ItemUpdated?.Invoke(this, null); + } + + protected override void RemoveItem(int value) + { + base.RemoveItem(value); + ItemUpdated?.Invoke(this, null); + } + + protected new void Clear() + { + base.Clear(); + ItemUpdated?.Invoke(this, null); + } + + protected override void ClearItems() + { + base.ClearItems(); + ItemUpdated?.Invoke(this, null); + } + } + + #endregion + + #region MaterialListBoxItemChild + + public class MaterialListBoxItem + { + #region Property Region + + public string Text { get; set; } + public string SecondaryText { get; set; } + public object Tag { get; set; } + + //public Bitmap Icon { get; set; } + + #endregion + + #region Constructor Region + + public MaterialListBoxItem() + { + Text = "ListBoxItem"; + SecondaryText = ""; + } + + public MaterialListBoxItem(string text) + { + Text = text; + } + + public MaterialListBoxItem(string text, string secondarytext) + { + Text = text; + SecondaryText = secondarytext; + } + + public MaterialListBoxItem(string text, string secondarytext, object tag) + { + Text = text; + SecondaryText = secondarytext; + Tag = tag; + } + + //public MaterialListBoxItem(string text, Bitmap icon) : this(text) + //{ + // Icon = icon; + //} + + #endregion + } + + #endregion + +} diff --git a/MaterialSkin/MaterialItemCollectionEditor.cs b/MaterialSkin/MaterialItemCollectionEditor.cs new file mode 100644 index 00000000..dc51651e --- /dev/null +++ b/MaterialSkin/MaterialItemCollectionEditor.cs @@ -0,0 +1,87 @@ +#region Imports + +using System; +using System.Collections.Generic; +using System.Text; +using System.Drawing; +using System.Drawing.Design; +using System.ComponentModel; +using System.ComponentModel.Design; +using MaterialSkin; +//using MaterialSkin.Controls; + +using System.Drawing.Text; +using System.Windows.Forms; +using System.Collections; +using System.Collections.ObjectModel; +using System.Runtime.InteropServices; + + +#endregion + +namespace System.Windows.Forms +{ + public class MaterialItemCollectionEditor : CollectionEditor + { + public MaterialItemCollectionEditor() : base(typeof(MaterialItemCollection)) + { + + } + + protected override Type CreateCollectionItemType() + { + return typeof(MaterialListBoxItem); + } + + protected override Type[] CreateNewItemTypes() + { + return new Type[] { + typeof(MaterialListBoxItem) + }; + } + } + + //public class MaterialItemCollectionEditor : CollectionEditor + //{ + // // Define a static event to expose the inner PropertyGrid's + // // PropertyValueChanged event args... + // public delegate void MyPropertyValueChangedEventHandler(object sender, + // PropertyValueChangedEventArgs e); + // public static event MyPropertyValueChangedEventHandler MyPropertyValueChanged; + + // // Inherit the default constructor from the standard + // // Collection Editor... + // public MyCollectionEditor(Type type) : base(type) { } + + // // Override this method in order to access the containing user controls + // // from the default Collection Editor form or to add new ones... + // protected override CollectionForm CreateCollectionForm() + // { + // // Getting the default layout of the Collection Editor... + // CollectionForm collectionForm = base.CreateCollectionForm(); + // Form frmCollectionEditorForm = collectionForm as Form; + // TableLayoutPanel tlpLayout = frmCollectionEditorForm.Controls[0] as TableLayoutPanel; + + // if (tlpLayout != null) + // { + // // Get a reference to the inner PropertyGrid and hook + // // an event handler to it. + // if (tlpLayout.Controls[5] is PropertyGrid) + // { + // PropertyGrid propertyGrid = tlpLayout.Controls[5] as PropertyGrid; + // propertyGrid.PropertyValueChanged += new PropertyValueChangedEventHandler(propertyGrid_PropertyValueChanged); + // } + // } + // return collectionForm; + // } + + // void propertyGrid_PropertyValueChanged(object sender, PropertyValueChangedEventArgs e) + // { + // // Fire our customized collection event... + // if (MyCollectionEditor.MyPropertyValueChanged != null) + // { + // MyCollectionEditor.MyPropertyValueChanged(this, e); + // } + // } + //} +} diff --git a/MaterialSkin/MaterialSkin.csproj b/MaterialSkin/MaterialSkin.csproj index 9ac8960a..308ff881 100644 --- a/MaterialSkin/MaterialSkin.csproj +++ b/MaterialSkin/MaterialSkin.csproj @@ -33,6 +33,8 @@ + + @@ -42,10 +44,16 @@ + + Component + Form - + + Component + + Component @@ -60,10 +68,16 @@ Component + + Form + Component - + + Component + + Component @@ -75,38 +89,59 @@ Component + + Component + Component + + Component + + + Component + + + Component + + + Component + Component - + Component - + Component - + + Form + + Component Component - + Component - + Component - + Component + + + @@ -151,6 +186,12 @@ SettingsSingleFileGenerator Settings.Designer.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + در اینجا فهرستی از هر گونه‌ای که یک دکمه Material می‌تواند باشد، آمده است. سایه های دکمه موجود فقط در زمان اجرا کشیده می شوند. +روی آنها کلیک کنید و آن انیمیشن های شیرین را بررسی کنید. اوه بله، دکمه‌ها از تم و رنگ‌ها پیروی می‌کنند، آن‌ها را نیز تغییر دهید. +به طور معمول دکمه ها باید AutoSize = true باشند، اما به خاطر OCD من، در اینجا روی false تنظیم شده است. +اگر هر یک از دکمه ها هنگام طراحی عجیب به نظر می رسد، رنگ پس زمینه برگه را از شفاف به سفید تغییر دهید. + + + 219, 17 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABs + NgAAAk1TRnQBSQFMAgEBEgEAAbgBBwG4AQcBGAEAARgBAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFg + AwABeAMAAQEBAAEgBgABtP8A/wD/ADEAAwwBEAM9AWcDWAG7A1wB5wMAAf8DAAH/A10B4wNUAa8DOQFf + AwYBCCgAAy8BSQNdAeMDAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wNdAeMDLgFI5AADPgFrA2AB6wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/ + A1wB3wM1AVckAANdAeIDAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8DAAH/A10B4twAAwkBDANSAaMDAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/ + AwAB/wMAAf8DAAH/AwAB/wMAAf8DSgGLAwMBBB8AAf8DAAH/AycBOzAAAycBOwMAAf8DAAH/3AADUgGj + AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DRwGD + HwAB/wMAAf87AAH/AwAB/9gAAz4BawMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DMAFLGwAB/wMAAf8cAANZAcQDAAH/AwAB/wMAAf8DWQHE + CwAB/wMAAf/UAAMMARADYAHrAwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wsAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8DXQHXAwMBBBQAAwYB/gMAAf8fAAH/AwAB/wMAAf8DAAH/AwAB/wsAAf8DAAH/ + 1AADPQFnAwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8LAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMuAUcUAAMGAf4DAAH/HwAB/wMAAf8DAAH/AwAB/wMAAf8LAAH/AwAB/9QAA1gBuwMA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wNPAZsUAAMGAf4DAAH/HwAB/wMAAf8DAAH/AwAB/wMAAf8LAAH/AwAB/9QAA1wB5wMA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wNZAccUAAMGAf4DAAH/HAADWQHEAwAB/wMAAf8DAAH/A1kBxAsAAf8DAAH/1wAB/wMA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/A0ABbwNAAW8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wNdAeMUAAMGAf4DAAH/OwAB/wMAAf/XAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/ + AwAB/wMAAf8LAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wNcAd8UAANAAf0DAAH/OwAB/wMA + Af/UAANdAeMDAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wsAAf8DAAH/AwAB/wMAAf8DAAH/ + AwAB/wMAAf8DAAH/A1kBwxQAA0AB/QMAAf87AAH/AwAB/9QAA1QBrwMAAf8DAAH/AwAB/wMAAf8DAAH/ + AwAB/wMAAf8DAAH/CwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DSwGPFAADQAH9AwAB/zsA + Af8DAAH/1AADOQFfAwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8LAAH/AwAB/wMAAf8DAAH/ + AwAB/wMAAf8DAAH/AwAB/wMqAUAUAANAAf0DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/9QAAwYBCANcAd8DAAH/AwAB/wMAAf8DAAH/ + AwAB/wMAAf8DAAH/A0sBjwNLAY8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/A1kBxxgAA0AB/QMA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/2AADNQFXAwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/ + AwAB/wMAAf8DAAH/AyEB+wMoATwYAAMrAfwDAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/9wAA0oBiwMAAf8DAAH/AwAB/wMAAf8DAAH/ + AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/Az4BaxwAA18B4AMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DXQHi3AADAwEE + A0cBgwMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AyEB+wM+AWsgAAMu + AUgDXQHjAwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DXQHjAy4BSOQAAzABSwNdAdcDAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wNZAccDKAE8 + MwAB/wMAAf8jAAH/AwAB//QAAwMBBAMuAUcDTwGbA1kBxwNcAd8DXAHfA1kBwwNLAY8DKgFAOAADWQHE + A1kBxCAAA1kBxANZAcT/AP8A/wD/AP8A/wD/AEsAAy4BSANdAeMDAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/A10B4wMuAUgkAAMrAUIDTAGT + A1wB1ANcAeoDAAH/AwAB/wMAAf8DAAH/A1kBxDgAAwQBBQM1AVYDUAGkA18B2wNPAfMDTwHzA18B2wNQ + AaQDNQFWAwQBBYgAA10B4gMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/ + AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wNdAeIcAAMnAToDWgHKAwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8DWQHENAADMwFSA1wB3AMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/ + A1wB3AMzAVIoAANZAcQDAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wNZAcQfAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/xgAA0IBdgMhAfsDAAH/A1oB5ANGAX4DJgE4 + Aw0BEUAAAwEBAgNKAYsDAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DSgGLAwEBAiMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8fAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/A1YBswMqAUADCQEMAwkBDAMq + AUADVgGzAwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/xQAA0MBeAMAAf8DKwH8A0cBggMEAQZMAANK + AYsDAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wNK + AYsgAANcAd8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/ + AwAB/wNcAd8fAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DRAF6GAADRAF6AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/EAADLAFDAwYB/gMrAfwDMgFRUAADMwFSAwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMzAVIcAAMyAVEDKQH6AwAB/wMAAf8DAAH/ + AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AykB+gMyAVEfAAH/AwAB/wMAAf8DAAH/ + AwAB/wNVAbIEAAMEAQYDSQGHA2EB5gNhAeYDSQGHAwQBBgQAA1UBsgMAAf8DAAH/AwAB/wMAAf8DAAH/ + DAADAwEEA18B2wMAAf8DQgF0DAADMQFNA1kBvgNSAfADWQHyA1gBwQMwAUwEAAM5AV8DXAHRAykB+gNc + Ac4DNQFWFAADBAEGA1wB3AMAAf8DAAH/AwAB/wNbAd4DRwGDA1wB6gMAAf8DAAH/AwAB/wMAAf8DWgHp + A0cBgwNcAd8DAAH/AwAB/wMAAf8DXAHcAwQBBhwAAyQBNgNYAcEDAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8DAAH/A1gBwQMkATYjAAH/AwAB/wMAAf8DAAH/AwAB/wMqAUAEAANJAYgDAAH/ + AwAB/wMAAf8DAAH/A0kBiAQAAyoBQAMAAf8DAAH/AwAB/wMAAf8DAAH/DAADMQFOAwAB/wNbAdYDAgED + CAADSAGFAwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/A1gBwQMAAf8DAAH/AwAB/wMAAf8DBgH+AzMBUhAA + AzUBVQMAAf8DAAH/AwAB/wMAAf8DRwGDBAADHwEsA1oB6QMAAf8DAAH/A1oB6QMeASsEAANIAYUDAAH/ + AwAB/wMAAf8DAAH/AzUBVSQAAxkBIwM/AWwDVQGyA1sB2ANZAfIDAAH/A2AB4QNVAbIDPwFsAxkBIysA + Af8DAAH/AwAB/wMAAf8DAAH/AwoBDQQAA14B5QMAAf8DAAH/AwAB/wMAAf8DXgHlBAADCgENAwAB/wMA + Af8DAAH/AwAB/wMAAf8MAANSAaYDAAH/A0ABcAgAAzABSwMAAf8DQQH5A0MBdwMSARgDEgEYA0MBdwNB + AfkDAAH/AwAB/wNIAYYDCwEPA0gBhgMAAf8DXAHMEAADUQGlAwAB/wMAAf8DAAH/AwAB/wNcAeoDHwEs + BAADHwEsA1oB6QNaAekDHgErBAADHwEtA2AB6wMAAf8DAAH/AwAB/wMAAf8DUQGldwAB/wMAAf8DAAH/ + AwAB/wMAAf8DCgENBAADXgHlAwAB/wMAAf8DAAH/AwAB/wNeAeUEAAMKAQ0DAAH/AwAB/wMAAf8DAAH/ + AwAB/wwAA14B1QMAAf8DIgEyCAADVgG5AwAB/wNCAXYQAANCAXYDAAH/AwAB/wMGAQgEAAMGAQgDAAH/ + Az4B+BAAA1sB2AMAAf8DAAH/AwAB/wMAAf8DAAH/A1oB6QMfASwEAAMfASwDHwEsBAADHwEtA1wB6gMA + Af8DAAH/AwAB/wMAAf8DAAH/A1sB2HcAAf8DAAH/AwAB/wMAAf8DAAH/AyoBQAQAA0kBiAMAAf8DAAH/ + AwAB/wMAAf8DSQGIBAADKgFAAwAB/wMAAf8DAAH/AwAB/wMAAf8MAANPAfMDAAH/Aw8BFAgAA1YB8QMA + Af8DEgEZEAADEgEZAwAB/wMGAf4LAAEBAwAB/wMGAf4QAANZAfIDAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DWgHpAx8BLAgAAx8BLANcAeoDAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DWQHyLAADFAEcA1IBpgNh + AeYDYQHmA1IBpgMUARwzAAH/AwAB/wMAAf8DAAH/AwAB/wNVAbIEAAMEAQYDSQGHA2EB5gNhAeYDSQGH + AwQBBgQAA1UBsgMAAf8DAAH/AwAB/wMAAf8DAAH/DAADYAHrAwAB/wMKAQ4IAANWAfEDAAH/AxIBGRAA + AxIBGQMAAf8DXwHgCAADDQERAwAB/wNgAesQAANZAfIDAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DXAHq + Ax8BLAgAAx8BLANaAekDAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DWQHyKAADFAEcA10B7QMAAf8DAAH/ + AwAB/wMAAf8DXQHtAxQBHC8AAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wNEAXoYAANEAXoDAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8MAANeAdoDAAH/AyQBNggAA1YBvAMAAf8DQgF2EAADQgF2AwAB/wNVAa0IAAMm + ATgDAAH/A1sB0BAAA1sB2AMAAf8DAAH/AwAB/wMAAf8DAAH/A1wB6gMfAS0EAAMfASwDHwEsBAADHwEs + A1oB6QMAAf8DAAH/AwAB/wMAAf8DAAH/A1sB2CgAA1IBpgMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wNS + AaYsAAMZASMDFAEcA1cBtwMAAf8DAAH/AwAB/wMAAf8DVgGzAyoBQAMJAQwDCQEMAyoBQANWAbMDAAH/ + AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/DAADUAGeAwAB/wNCAXUIAAMvAUoDAAH/A0EB+QNDAXcDEgEY + AxIBGANDAXcDQQH5A0AB/QMiATIIAANGAX8DAAH/A0wBkhAAA1EBpQMAAf8DAAH/AwAB/wMAAf8DYAHr + Ax8BLQQAAx4BKwNaAekDWgHpAx8BLAQAAx8BLANcAeoDAAH/AwAB/wMAAf8DAAH/A1EBpSgAA14B5QMA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wNeAeUsAANZAcQDWQHEAxUBHQMAAf8DAAH/AwAB/wMAAf8DAAH/ + AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/DAADNQFWAwAB/wNf + AeADAwEECAADRwGCAwAB/wMAAf8DAAH/AwAB/wMAAf8DQAH9A0ABbwgAAwUBBwNdAeMDAAH/AysBQhAA + AzUBVQMAAf8DAAH/AwAB/wMAAf8DSAGFBAADHgErA1oB6QMAAf8DAAH/A1oB6QMfASwEAANHAYMDAAH/ + AwAB/wMAAf8DAAH/AzUBVSgAA14B5QMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wNeAeUvAAH/AwAB/wcA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DXQHiDAADAgEDA1sB2QMAAf8DRgF+DAADLwFJA1gBuwNPAfMDUQH3A1QBrAMrAUIMAANHAYIDAAH/ + A1wByRQAAwQBBgNcAdwDAAH/AwAB/wMAAf8DXAHfA0cBgwNaAekDAAH/AwAB/wMAAf8DAAH/A1wB6gNH + AYMDWwHeAwAB/wMAAf8DAAH/A1wB3AMEAQYoAANSAaYDAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DUgGm + LwAB/wMAAf8IAAMUARwDVwG3AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/A10B4wMuAUgQAAMyAVADBgH+A0AB/QMyAVEoAAMzAVMDKwH8AyEB+wMnAToYAAMzAVIDAAH/ + AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/ + AzMBUiwAAxQBHANdAe0DAAH/AwAB/wMAAf8DAAH/A10B7QMUARwgAANZAcQDAAH/AwAB/wMAAf8DAAH/ + AwAB/wMAAf8DWQHEAxUBHQMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DBgH+AzkBXygAA0kBhwMA + Af8DQAH9A0YBfgMDAQQYAAMDAQQDQgF2AysB/AMAAf8DQgF1IAADSgGLAwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DSgGLNAADFAEcA1IBpgNhAeYDYQHm + A1IBpgMUARwkAANZAcQDAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DWQHEAxkBIwMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wNcAeoDOwFjLAADAQECA0kBhwMAAf8DAAH/A2AB4QNCAXUDJAE1AwsBDwMRARcDJAE1 + A0EBcwNdAdcDAAH/AwAB/wNDAXckAAMBAQIDSgGLAwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8DAAH/A0oBiwMBAQJ/AAH/AwAB/2QAAzIBUANbAdkDAAH/AwAB/wMAAf8DAAH/ + AwAB/wMAAf8DAAH/AwAB/wNfAdsDKwFCMAADMwFSA1wB3AMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/A1wB3AMzAVKHAAH/AwAB/2gAAwIBAwM1AVYDUAGeA1sB2ANdAeMDKwH8A1oB0wNSAaYDMQFO + AwMBBDgAAwQBBQM1AVYDUAGkA18B2wNPAfMDTwHzA18B2wNQAaQDNQFWAwQBBYgAA1kBxANZAcT/AP8A + /wD/AP8A/wB+AANLAY8DSwGPxAADSgGKA0oBilgAAwoBDQM5AV8DTgGVA1kBvwNfAegDXwHbAywBRDQA + AxcBIAMAAf8DXAHfwAADSAGECP8DSAGETAADJwE7A1QBqwNRAfcDAAH/AwAB/wMAAf8DAAH/AwAB/wNe + Ad00AAMXASADAAH/A1wB3zQAAy4BSANdAeMDAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/A10B4wMuAUg4AANAAW8Q/wNAAW9AAAMWAR4DUgGm + AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DKwH8NAADFwEgAwAB/wNcAd80AANdAeIDAAH/ + AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/ + AwAB/wMAAf8DXQHiNAADHgErGP8DIAEuOAADMQRPAfMDAAH/A1kB8gNcAdwDAAH/AwAB/wMAAf8DAAH/ + AwAB/wMAAf8DIQH7NAADFwEgAwAB/wNcAd83AAH/AwAB/wMnATs4AAMnATsDAAH/AwAB/0AACP9AAAND + AXgDQAH9AwAB/wNUAasDFAEbAxABFQNaAdMDAAH/AwAB/wMAAf8DAAH/AwAB/wNbAcs0AAMXASADAAH/ + A1wB3zcAAf8DAAH/QwAB/wMAAf9AAAj/PAADQwF3AwAB/wMrAfwDQAFxDAADEAEVA1gBuwMAAf8DWAHv + A10B0gNRAaUDGQEjNAADFwEgAwAB/wNcAd80AAMGAf4DAAH/QwAB/wMAAf9AAAj/OAADMgFQA0AB/QMr + AfwDNQFVYAADFwEgAwAB/wNcAd80AAMGAf4DAAH/QwAB/wMAAf8oAANdAdIDXQHSEAAI/zQAAxYBHwNP + AfMDAAH/A0ABcVAAA0sBjwMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/ + AwAB/wNLAY8cAAMGAf4DAAH/QwAB/wMAAf8oAAj/EAAI/zQAA1IBpwMAAf8DVAGrVAADVgGzAwAB/wMA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/A04BlxwAAwYB/gMAAf8YAAMV + AR0DRgGAA0YBgAMVAR0bAAH/AwAB/ygACP8QAAj/MAADJwE7AwYB/gNZAfIDFAEbVAADBgEIA0oBiwMh + AfsDAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wNRAfcDQQFzAwMBBBwAAwYB/gMAAf8QAAMC + AQMDQAFwA1kB8gMAAf8DAAH/A1kB8gNAAXADAgEDEwAB/wMAAf8oAAj/EAADYAHUA14B1TAAA1QBqwMA + Af8DXwHbAxABFVwAA0sBjwMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/A0ABbyQAA0AB/QMA + Af8MAAMjATMDXAHMAwAB/wNdAeIDMQFPAzEBTwNdAeIDAAH/A1wBzAMjATMPAAH/AwAB/ygACP9EAAMK + AQ4DUQH3AwAB/wMAAf8DWgHTAxABFVgAAyYBOAMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/ + AxQBHCQAA0AB/QMAAf8EAAMKAQ0DSwGPAysB/AMrAfwDSwGPAwoBDQgAAwoBDQNLAY8DKwH8AysB/ANL + AY8DCgENBwAB/wMAAf8oAAj/RAADOQFfAwAB/wMAAf8DAAH/AwAB/wNWAbxfAAH/AwAB/wMAAf8DAAH/ + AwAB/wMAAf8DAAH/AwAB/ygAA0AB/QMAAf8DMQFPA10B4gMAAf8DXAHMAyMBMxgAAyMBMwNcAcwDAAH/ + A10B4gMxAU8DAAH/AwAB/ygACP9EAANOAZcDAAH/AwAB/wMAAf8DAAH/A0AB/QMCAQNbAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/ygAA0AB/QMAAf8DAAH/A1kB8gNAAW8DAgEDIAADAgEDA0ABbwNZ + AfIDAAH/AwAB/wMAAf8cAAMfASwU/wN/Af4DHwEsOAADWQG/AwAB/wMAAf8DAAH/AwAB/wNZAfJfAAH/ + AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/ygAA0AB/QMAAf8DVAGvAxUBHTAAAxUBHQNUAa8DAAH/ + AwAB/yAAA0ABbxD/Az0BaDwAA2EB5gMAAf8DAAH/AwAB/wMAAf8DXAHUXwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8oAANcAd8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/ + AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DXQHiJAADSAGECP8DRwGBQAADXAHcAwAB/wMA + Af8DAAH/AwAB/wNSAahfAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/ygAAy4BRwNdAeMDAAH/ + AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/ + A10B4wMuAUgoAANKAYoDSgGKRAADLAFDA1sB3gMAAf8DAAH/A1wByQMZASNUAANLAY8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wMAAf8DAAH/A0sBj/8AUQADQAFvAwAB/wMAAf8DAAH/AwAB/wMA + Af8DAAH/AwAB/wMAAf8DAAH/AwAB/wNAAW//AP8A/wD/AP8ARQADAwEEAyEBMAMHAQo4AANdAdIDXQHS + /wAxAAMtAUUDYQHmBP8DWQH1AzoBYTQACP//AC0AAysBQgNqAfkM/wOoAf0DEAEVJAADJQE3A1YBtgNd + Ae0I/wNdAe0DWAG7AzsBZAMGAQiAAAMUARwDXAHfSP8DXgHdAxMBGkAAAysBQgNcAfgU/wMfASwcAAMU + ARsDVAGsIP8DXwHjAy0BRXwAAxYBHgMrAfxI/wNNAfoDFAEcPAADKwFCA1wB+BT/A2EB4gMDAQQYAAMf + ASwDZAHnBP8DZAHsA0QBeQMsAUQDEQEXAxABFgMtAUUDRAF5A10B7QT/AysB/AM1AVV8AANMAZJI/wNK + AYs8AAMrAUIDXAH4FP8DXwHzAyYBORgAAxsBJgNdAe0E/wNUAa8DDgETGAADDgETA1UBsgT/A1wB+AMd + ASl4AAMNAREDYQHuHP8IABz/A1wB6gMKAQ04AAMrAUIDXAH4FP8DXwHzAyQBNRwAA1wBzAT/A1MBpSgA + A1MBpQT/A1wBzXwAAz0BaRz/CAAc/wM7AWM4AAMrAUIDXAH4FP8DZAHxAyQBNRwAAy4BSAT/A2QB5wMG + AQgIAAMSARkDVQG1A10B7QNdAe0DVQGyAxIBGQgAAwYBCANfAegE/wMuAUd7AAEBA14B1Tj/A1wBzwMA + AQE0AAMoATwDXAH4FP8DYQHuAyEBMCAAA1ABngT/A0QBewgAAxABFgNhAeYQ/wNhAeYDEAEVCAADRAF6 + BP8DUAGeEAADXgHQAzUBVQQAAzUBVQNeAdAIAAM1AVUDXgHQEAADXgHQAzUBVQgAA14B0AM1AVUgAAMp + AT44/wMlATcgAAMmATkDSgGNA1wByQNdAfADYQHhA04BmANZAfUU/wNhAe4DHgErJAADXQHXBP8DIAEu + CAADUQGgGP8DUgGhCAADHwEtBP8DYAHWEAAE/wNHAYAEAANHAYAE/wgAA0cBgAT/EAAE/wNHAYAIAAT/ + A0cBgCQAA1QBrBT/AyABLwMgAS8U/wNUAaYfAAEBA0YBfiz/A2AB6wMeASsgAANdAdIM/wMKAQ0IAANl + AeUY/wNlAeUIAAMKAQ0M/wNdAdIIAAT/A1oBwANHAYADWgHABP8IAANHAYAE/xAABP8DRwGACAAQ/wNJ + AYcYAAMWAR4DXAH4EP8IABD/A1wB+AMSARkcAANHAYIs/wNfAegDHAEnJAADYAHUDP8DCQEMCAADYAHr + GP8DYAHrCAADCQEMDP8DXgHVCAAU/wgAA0cBgAT/EAAE/wNHAYAIAAT/A1oBwANHAYADWgHAA2oB+RwA + A0gBgxD/CAAQ/wNGAX4cAAMpAT4s/wNfAegDGAEiMAADXgHYBP8DHwEsCAADUQGgGP8DUgGhCAADHgEr + BP8DXQHXEAAE/wNHAYAEAANHAYAE/wQAAzUBVgNaAcAE/wNFAX0DEgEZAxIBGQNFAX0E/wNaAcADNQFW + BAAE/wNaAcADRwGAA1oBwANfAfscAAMHAQoDYQHmDP8DIAEvAyABLgz/A2EB4QMFAQccAANQAZ0s/wNS + Aak0AANQAZ4E/wNEAXoIAAMQARUDYQHmEP8DZAHnAw0BEQgAA0QBeQT/A1ABnhAAA14B0AM1AVcEAAM1 + AVcDXgHQBAADXgHQCP8DKwH8AzMBUwMzAVMDKwH8CP8DXgHQBAADYAHUDP8DSQGHIAADNwFaIP8DNQFV + IAADXwHjDP8DVQGyA1YBthj/A2EB5jQAAy0BRgT/A2QB5wMGAQgIAAMSARgDVgGzA2QB7ANkAewDVgGz + AxIBGAgAAwcBCQNkAecE/wMtAUWMAANcAckY/wNYAcEkAANhAe4I/wNGAX8IAANIAYMU/wNiAe83AAEB + A1wBzQT/A1MBpSgAA1MBpQT/A1wBzQMAAQGMAAMhATADfwH+EP8DfwH+Ax0BKiQAA18B2wT/A0ABcBAA + A1MBpRD/A1wB3zgAAx0BKQNiAfYE/wNUAa8DDQESGAADDQESA1QBrwT/A10B7QMbASaUAANRAZwQ/wNO + AZgoAANMAZIDPQFpFAADVAGmEP8DTgGZPAADNAFUAysB/AT/A2QB7ANDAXgDLAFEAw8BFAMPARQDLAFE + A0MBeANkAewE/wNkAecDHgErmAADEAEVA2cB8gj/A2cB8gMNAREoAAMHAQoUAANHAYAQ/wOoAf0DIgEy + QAADLAFEA18B4yD/A1QBrAMTARqgAANCAXMI/wNAAXBAAANMAY8U/wNEAXlIAAMGAQgDPAFmA1gBuwNk + AewI/wNkAewDVwG3AyYBOKgAAwQBBQNgAdQDXQHTAwIBAzwAA04BlhD/A00B+gNAAXBcAAj//AADDQES + A0QBeQNWAbYDWgHAA1cBuANGAX4DHQEqYAADYAHUA14B1f8A/wD/AP8A/wD/AF4AAzEBTQMyAVGYAAMx + AU8DXQHXOP8DXQHXAzEBT5gAA1kB9QT/Az8BbDwAA10BygM4AVwDBAEFIAADBAEFAzcBWwNcAc8gAANh + AeJA/wNhAeIUAAMFAQcDPgFrA14B3Tz/A1gBvAMyAVE0AAz/A0IBdDgACP8DXwHoA0cBgAMQARYQAAMR + ARcDRgF/A2IB6Qj/IABI/xAAAxQBGwNeAdVM/wNIAYQYAAMUARsDPgFqAwsBDwwACP8DagH5BP8DQgF0 + NAAQ/wNNAfoDUgGkAyMBNAMkATYDUgGjA00B+hD/IABI/wwAAwEBAgNZAcdU/wMwAUsUAANDAXcE/wNc + AdEDDgETCAAI/wMvAUoDKwH8BP8DRQF8MAA4/yAAEP8DIAEvAyABLwj/AyABLwMgAS8I/wMgAS8DIAEv + EP8MAAM6AWIk/xAAJP8DWQHCFAADBwEKA1sByAT/A2EB2gMQARYEAAj/BAADPgFrCP8DHwEtLAA4/yAA + EP8IAAj/CAAI/wgAEP8MAANbAcgk/xAAJP8DZQH0GAADCQEMA14BzgT/A2AB3gMTARoI/wMQARYDXQHX + BP8DXAHfAwoBDSwAOP8gABD/CAAI/wgACP8IABD/DAADZQH0JP8QACT/A2IB6RwAAwsBDwNeAc4E/wNc + Ad8I/wNeAd0E/wNeAd0DFAEbMAA4/yAAEP8IAAj/CAAI/wMgAS8DIAEuEP8MAANNAfok/xAAJP8DVAGv + IAADCwEPA10B0hD/A14B2AMRARc0ADj/IAAQ/wgACP8IACD/DAADXAHPGP8DQwF4IAADRQF9GP8DJgE4 + JAADDQESA10B1wj/A2AB1AMPARQ4ADj/IAAQ/wgACP8IACD/DAADQgF2HP8DQAFwGAADQAFwGP8DSgGJ + KAADDQESA10B1wj/A14B2AMPARQ4ADj/IAAQ/wMgAS8DIAEuCP8IACD/DAADCAELA10B1xz/Az0BaRAA + Az0BaRD/A2QB8QNUAa8DLQFGKAADCwEPA10B0hD/A14B2AMRARc0ADj/IAAg/wgAIP8QAAMQARYDXgHQ + HP8DPQFpCAADPQFpFP8DJAE2LAADCwEPA14BzgT/A1wB3wj/A18B4wT/A14B3QMUARswADj/IAAg/wgA + IP8UAAMBAQIDOAFeA10BygMrAfwU/wNBAXIDQQFyFP8DXgHdLAADCQEMA14BzgT/A2AB3gMTARoI/wMS + ARkDXQHXBP8DXAHfAwoBDSwAOP8gACD/AyABLwMgAS4g/yAAAywBRAN/Af4s/wM7AWQoAAMHAQoDWwHI + BP8DXgHVAxABFgQACP8EAAM+AWsI/wMfASwsADj/IABI/yQAA0IBdSj/A1IBoSwAA0QBeQT/A1wB0QMM + ARAIAAj/AzABTAMrAfwE/wNCAXQwADj/IABI/ygAA0ABcBz/A00B+gNCAXQwAAMTARoDPgFqAwsBDwwA + CP8DXAH4BP8DQgF0NAA4/yAAA2EB5ED/A18B4ywAAx0BKgNOAZgDXQHSA2UB9AT/A2AB6wNJAYgDFQEd + TAAM/wNCAXQ4AANhAeQw/wNfAeMgAAMxAU8DYAHWOP8DYAHWAzEBT5gAA20B9wT/Az8BbDwAAzEBTwNg + AdYo/wNgAdYDMQFP/wABAAMxAU0DMwFS/wD/AP8AjwABQgFNAT4HAAE+AwABKAMAAWADAAF4AwABAQEA + AQEFAAGgAQUWAAP/AQAG/wYABv8GAAH+AQABfwHgAQABBwYAAfwBAAE/AeABAAEHBgAB8AEAAQ8B4wH/ + AccGAAHwAQABDwHnAf8B5wYAAeABAAEHAecB8AFnBgABwAEYAQMB5wHwAWcGAAHAARgBAwHnAfABZwYA + AcABAAEDAecB8AFnBgABwAEAAQMB5wHwAWcGAAHAAQABAwHnAf8B5wYAAcABGAEDAecB/wHnBgABwAEY + AQMB5wH/AecGAAHAARgBAwHnAf8B5wYAAcABGAEDAeABAAEHBgABwAEAAQcB4AEAAQcGAAHgAQABBwHg + AQABBwYAAfABAAEPAeABAAEHBgAB8AEAAR8B4AEAAQcGAAH8AQABPwH8Af8BPwYAAf4BAAH/AfwB/wE/ + BgAG/wYABv8GABv/AeABAAEBAf8BAAF/Af4BAAF/A/8B4AEAAQEB/AEAAX8B/AEAAT8B8AEAAQ8B4AEA + AQEB+AEPAf8B8AEAAQ8B8AEAAQ8B4AEAAQEB8AF/Af8B8AEAAQ8B8AEAAQ8B4AE/AQEB4QL/AeABAAEH + AfABAAEPAeABQAGBAcMBgQEHAcABAAEDAfgBAAEfAeABQAGBAcMBAAEDAcABgQEDAf4BAAF/AeABQAGB + AcYBAAEDAcABQgEDA/8B4AFAAYEBxgE8ASMBwAEkAQMD/wHgAUABgQHGATwBYwHAARgBAwH/AYEB/wHg + AUABgQHGATwBYwHAARgBAwH/AQAB/wHgAT8BAQHGATwBYwHAASQBAwH/AQAB/wHgAQABAQHGAQABYwHA + AUIBAwH/AQAB/wHgAQABAQHDAQABwwHAAYEBAwH/AQAB/wHkAQABAQHDAYEBxwHAAQABAwH/AQAB/wHm + AQABAQHhAf8BhwHgAQABBwH/AQAB/wIAAT8B8AF+AQ8B8AEAAQ8B/wGBAf8CAAF/AfABAAEfAfABAAEP + A/8B5wL/AfwBAAE/AfwBAAE/A/8B5wL/Af4BAAF/Af4BAAF/A/8B5zP/AecF/wH8Av8B/AEHAf8BxwX/ + AfgBfwH/AfABBwH/AccB/wHAAQABAwH/AfABPwH/AcABBwH/AccB/wHAAQABAwH/AeABHwH/AYABBwH/ + AccB/wHHAf8B4wH/AfwC/wEAAQcB/wHHAf8BzwH/AfMB/wH8Af8B/gEcAQcB/wHHAf8BzwH/AfMB/wH8 + Af8B/AE/Av8BxwH/Ac8B/wHzAf8BPAH/AfgBfwH/AfgBAAEfAc8B/wHzAf8BPAH/AfgC/wH4AQABHwHP + AcMB8wH/ATwB/wHwAv8B+AEAAR8BzwEAAfMB/wE8Af8B8AL/Af4BAAF/Ac4BAAFzAf8BPwH/AeABfwH/ + Af4BAAF/AcgBGAETAf8BPwH/AeABfwL/AQAB/wHAAX4BAwH/AT8B/wHgAT8C/wEAAf8BwAH/AQMB+AEH + Af8B4AF/Av8BAAH/AcMB/wHDAfwBDwH/AeABfwL/AQAB/wHAAQABAwH+AR8B/wHgAX8C/wEAAf8BwAEA + AQMB/wE/Af8B4AF/Af8B/AEAAT8J/wH8AQABPyn/AccB/wHnCf8BgwH/AecJ/wEBAf8BAAF/A/8BgAEA + AQEB/wH+AQEB/AEAAT8D/wGAAQABAQH/AfwBAQH4AQABHwP/AcABAAEDAf8B+AEDAfABfgEPA/8BwAEY + AQMB/wHwAQcB8QH/AY8D/wHgARgBBwH/AeABDwHhAYEBhwP/AeABAAEHAf8BwAEfAeMBAAHHAZMBPAHP + AfABAAEPAfABAAE/AeMBAAHHAZMBPAHPAfgBAAEfAcABAAF/AYMBAAHBAYMBPAHBAfgBGAEfAcABAAH/ + AYMBAAHBAYMBPAHBAfwBGAE/AYABAQH/AeMBAAHHAZIBAAFBAfwBAAE/AYABAwH/AeMBAAHHAZIBAAFB + Af4BAAF/AYABAwH/AeEBgQGHBP8BAAH/AYYBAwH/AeEB/wGHBP8BAAH/AY8BAwH/AfABfgEPBP8BgQH/ + AZ8BAwH/AfgBAAEfBP8BgQH/Ab4BAwH/AfwBAAE/BP8BwwH/AfwBBwH/Af4BAAX/AcMB/wH4AQ8C/wHn + B/8B8AEfAv8B5zL/AecE/wHgAQABBwT/AeMB/wH4Af8BHwHgAQABBwHAAQABAwH/AeEB/wH4ATwBHwHg + AQABBwGAAQABAQH4AeAB/wH4AQABHwHgAQABBwMAAfgBYAF/AfgBAAEfAeABAAEHAQABPAEAAfgBJAE/ + AfgBAAEfAeEBmQGHAQABPAEAAfwBAAE/AfgBAAEfAeEBmQGHAQABPAEAAf4BAAF/AfgBAAEfAeEBmAEH + AQABPAEAAf8BAAH/AfgBAAEfAeEBmAEHAQAB/wEAAf8BgQH/AfgBAAEfAeEBmAEHAQABfgEBAf8BgQH/ + AfgBAAEfAeABGAEHAQABPAEDAf8BAAH/AfgBAAEfAeABGAEHAYABGAEPAf4BAAF/AfgBAAEfAeABGAEH + AcABAAEfAfwBAAE/AfgBAAEfAeABAAEHAfgBAAEfAfgBJAE/AfgBAAEfAeABAAEHAfwBAAE/AfgBYAF/ + AfgBAAEfAeABAAEHAf4BAAF/AfgB4AH/AfgBAAEfAeABAAEHAf8BAAL/AeEB/wH4AQABHwHgAQABBwT/ + AeMB/wH4AQABHwf/Aecc/ws= + + + + 17, 17 + + + 50 + + \ No newline at end of file diff --git a/MaterialSkinExample.RTL/MaterialSkinExample.RTL.csproj b/MaterialSkinExample.RTL/MaterialSkinExample.RTL.csproj new file mode 100644 index 00000000..80656090 --- /dev/null +++ b/MaterialSkinExample.RTL/MaterialSkinExample.RTL.csproj @@ -0,0 +1,148 @@ + + + + + Debug + AnyCPU + {8E08A8CF-A5DB-41DF-B486-E0E5DE552697} + WinExe + Properties + MaterialSkinExample.RTL + MaterialSkinExample.RTL + v4.6.1 + 512 + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + Form + + + MainForm.cs + + + + + MainForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + {8eb7611b-68cd-4b8b-987a-11717e2b250c} + MaterialSkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MaterialSkinExample.RTL/Program.cs b/MaterialSkinExample.RTL/Program.cs new file mode 100644 index 00000000..45164be5 --- /dev/null +++ b/MaterialSkinExample.RTL/Program.cs @@ -0,0 +1,16 @@ +using System; +using System.Windows.Forms; + +namespace MaterialSkinExample +{ + internal static class Program + { + [STAThread] + private static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(true); + Application.Run(new MainForm()); + } + } +} \ No newline at end of file diff --git a/MaterialSkinExample.RTL/Properties/AssemblyInfo.cs b/MaterialSkinExample.RTL/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..798dfc80 --- /dev/null +++ b/MaterialSkinExample.RTL/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("MaterialSkinExample")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("MaterialSkinExample")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b3fe1c46-7ac9-4dc9-bfe7-f66f3136e410")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/MaterialSkinExample.RTL/Properties/Resources.Designer.cs b/MaterialSkinExample.RTL/Properties/Resources.Designer.cs new file mode 100644 index 00000000..863ea05c --- /dev/null +++ b/MaterialSkinExample.RTL/Properties/Resources.Designer.cs @@ -0,0 +1,243 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace MaterialSkinExample.RTL.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MaterialSkinExample.RTL.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap baseline_bluetooth_black_24dp { + get { + object obj = ResourceManager.GetObject("baseline_bluetooth_black_24dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap baseline_build_black_24dp { + get { + object obj = ResourceManager.GetObject("baseline_build_black_24dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap baseline_favorite_border_black_24dp { + get { + object obj = ResourceManager.GetObject("baseline_favorite_border_black_24dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap baseline_fingerprint_black_24dp { + get { + object obj = ResourceManager.GetObject("baseline_fingerprint_black_24dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap baseline_thumb_up_black_24dp { + get { + object obj = ResourceManager.GetObject("baseline_thumb_up_black_24dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap minus { + get { + object obj = ResourceManager.GetObject("minus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap plus { + get { + object obj = ResourceManager.GetObject("plus", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap round_add_black_24dp { + get { + object obj = ResourceManager.GetObject("round_add_black_24dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap round_assessment_white_24dp { + get { + object obj = ResourceManager.GetObject("round_assessment_white_24dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap round_backup_white_24dp { + get { + object obj = ResourceManager.GetObject("round_backup_white_24dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap round_bluetooth_white_24dp { + get { + object obj = ResourceManager.GetObject("round_bluetooth_white_24dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap round_bookmark_white_24dp { + get { + object obj = ResourceManager.GetObject("round_bookmark_white_24dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap round_build_white_24dp { + get { + object obj = ResourceManager.GetObject("round_build_white_24dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap round_gps_fixed_white_24dp { + get { + object obj = ResourceManager.GetObject("round_gps_fixed_white_24dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap round_http_white_24dp { + get { + object obj = ResourceManager.GetObject("round_http_white_24dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap round_phone_black_24dp { + get { + object obj = ResourceManager.GetObject("round_phone_black_24dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap round_report_problem_white_24dp { + get { + object obj = ResourceManager.GetObject("round_report_problem_white_24dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap round_swap_vert_white_24dp { + get { + object obj = ResourceManager.GetObject("round_swap_vert_white_24dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/MaterialSkinExample.RTL/Properties/Resources.resx b/MaterialSkinExample.RTL/Properties/Resources.resx new file mode 100644 index 00000000..f49864df --- /dev/null +++ b/MaterialSkinExample.RTL/Properties/Resources.resx @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + ..\Resources\round_report_problem_white_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\round_build_white_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\round_swap_vert_white_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\baseline_thumb_up_black_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\round_gps_fixed_white_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\round_bookmark_white_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\round_assessment_white_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\minus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\round_backup_white_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\plus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\baseline_build_black_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\baseline_fingerprint_black_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\round_http_white_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\round_bluetooth_white_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\baseline_bluetooth_black_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\baseline_favorite_border_black_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\round_add_black_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\round_phone_black_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + diff --git a/MaterialSkinExample.RTL/Properties/Settings.Designer.cs b/MaterialSkinExample.RTL/Properties/Settings.Designer.cs new file mode 100644 index 00000000..5f02ea1d --- /dev/null +++ b/MaterialSkinExample.RTL/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace MaterialSkinExample.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.2.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/MaterialSkinExample.RTL/Properties/Settings.settings b/MaterialSkinExample.RTL/Properties/Settings.settings new file mode 100644 index 00000000..39645652 --- /dev/null +++ b/MaterialSkinExample.RTL/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/MaterialSkinExample.RTL/Resources/MaterialSkinExample.RTL.gif b/MaterialSkinExample.RTL/Resources/MaterialSkinExample.RTL.gif new file mode 100644 index 00000000..9501b8ad Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/MaterialSkinExample.RTL.gif differ diff --git a/MaterialSkinExample.RTL/Resources/baseline_bluetooth_black_24dp.png b/MaterialSkinExample.RTL/Resources/baseline_bluetooth_black_24dp.png new file mode 100644 index 00000000..c505e9ab Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/baseline_bluetooth_black_24dp.png differ diff --git a/MaterialSkinExample.RTL/Resources/baseline_build_black_24dp.png b/MaterialSkinExample.RTL/Resources/baseline_build_black_24dp.png new file mode 100644 index 00000000..f9b6fa12 Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/baseline_build_black_24dp.png differ diff --git a/MaterialSkinExample.RTL/Resources/baseline_favorite_border_black_24dp.png b/MaterialSkinExample.RTL/Resources/baseline_favorite_border_black_24dp.png new file mode 100644 index 00000000..b5758382 Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/baseline_favorite_border_black_24dp.png differ diff --git a/MaterialSkinExample.RTL/Resources/baseline_fingerprint_black_24dp.png b/MaterialSkinExample.RTL/Resources/baseline_fingerprint_black_24dp.png new file mode 100644 index 00000000..ff5afe36 Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/baseline_fingerprint_black_24dp.png differ diff --git a/MaterialSkinExample.RTL/Resources/baseline_thumb_up_black_24dp.png b/MaterialSkinExample.RTL/Resources/baseline_thumb_up_black_24dp.png new file mode 100644 index 00000000..d207c07b Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/baseline_thumb_up_black_24dp.png differ diff --git a/MaterialSkinExample.RTL/Resources/demo-1.png b/MaterialSkinExample.RTL/Resources/demo-1.png new file mode 100644 index 00000000..2664ebbe Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/demo-1.png differ diff --git a/MaterialSkinExample.RTL/Resources/demo-10.png b/MaterialSkinExample.RTL/Resources/demo-10.png new file mode 100644 index 00000000..345527c5 Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/demo-10.png differ diff --git a/MaterialSkinExample.RTL/Resources/demo-11.png b/MaterialSkinExample.RTL/Resources/demo-11.png new file mode 100644 index 00000000..1ecce1fa Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/demo-11.png differ diff --git a/MaterialSkinExample.RTL/Resources/demo-2.png b/MaterialSkinExample.RTL/Resources/demo-2.png new file mode 100644 index 00000000..74501aae Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/demo-2.png differ diff --git a/MaterialSkinExample.RTL/Resources/demo-3.png b/MaterialSkinExample.RTL/Resources/demo-3.png new file mode 100644 index 00000000..a55d819d Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/demo-3.png differ diff --git a/MaterialSkinExample.RTL/Resources/demo-4.png b/MaterialSkinExample.RTL/Resources/demo-4.png new file mode 100644 index 00000000..046bf4f9 Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/demo-4.png differ diff --git a/MaterialSkinExample.RTL/Resources/demo-5.png b/MaterialSkinExample.RTL/Resources/demo-5.png new file mode 100644 index 00000000..d81f50e9 Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/demo-5.png differ diff --git a/MaterialSkinExample.RTL/Resources/demo-6.png b/MaterialSkinExample.RTL/Resources/demo-6.png new file mode 100644 index 00000000..e768467e Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/demo-6.png differ diff --git a/MaterialSkinExample.RTL/Resources/demo-7.png b/MaterialSkinExample.RTL/Resources/demo-7.png new file mode 100644 index 00000000..021616d0 Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/demo-7.png differ diff --git a/MaterialSkinExample.RTL/Resources/demo-8.png b/MaterialSkinExample.RTL/Resources/demo-8.png new file mode 100644 index 00000000..35f960c7 Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/demo-8.png differ diff --git a/MaterialSkinExample.RTL/Resources/demo-9.png b/MaterialSkinExample.RTL/Resources/demo-9.png new file mode 100644 index 00000000..06df2338 Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/demo-9.png differ diff --git a/MaterialSkinExample.RTL/Resources/minus.png b/MaterialSkinExample.RTL/Resources/minus.png new file mode 100644 index 00000000..484bd06f Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/minus.png differ diff --git a/MaterialSkinExample.RTL/Resources/plus.png b/MaterialSkinExample.RTL/Resources/plus.png new file mode 100644 index 00000000..265017dc Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/plus.png differ diff --git a/MaterialSkinExample.RTL/Resources/round_add_black_24dp.png b/MaterialSkinExample.RTL/Resources/round_add_black_24dp.png new file mode 100644 index 00000000..a77cfcd9 Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/round_add_black_24dp.png differ diff --git a/MaterialSkinExample.RTL/Resources/round_assessment_white_24dp.png b/MaterialSkinExample.RTL/Resources/round_assessment_white_24dp.png new file mode 100644 index 00000000..35b55658 Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/round_assessment_white_24dp.png differ diff --git a/MaterialSkinExample.RTL/Resources/round_backup_white_24dp.png b/MaterialSkinExample.RTL/Resources/round_backup_white_24dp.png new file mode 100644 index 00000000..4a1da43d Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/round_backup_white_24dp.png differ diff --git a/MaterialSkinExample.RTL/Resources/round_bluetooth_white_24dp.png b/MaterialSkinExample.RTL/Resources/round_bluetooth_white_24dp.png new file mode 100644 index 00000000..c437dc29 Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/round_bluetooth_white_24dp.png differ diff --git a/MaterialSkinExample.RTL/Resources/round_bookmark_white_24dp.png b/MaterialSkinExample.RTL/Resources/round_bookmark_white_24dp.png new file mode 100644 index 00000000..aa277414 Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/round_bookmark_white_24dp.png differ diff --git a/MaterialSkinExample.RTL/Resources/round_build_white_24dp.png b/MaterialSkinExample.RTL/Resources/round_build_white_24dp.png new file mode 100644 index 00000000..38a0e8c7 Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/round_build_white_24dp.png differ diff --git a/MaterialSkinExample.RTL/Resources/round_gps_fixed_white_24dp.png b/MaterialSkinExample.RTL/Resources/round_gps_fixed_white_24dp.png new file mode 100644 index 00000000..ae93dd7e Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/round_gps_fixed_white_24dp.png differ diff --git a/MaterialSkinExample.RTL/Resources/round_http_white_24dp.png b/MaterialSkinExample.RTL/Resources/round_http_white_24dp.png new file mode 100644 index 00000000..66952687 Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/round_http_white_24dp.png differ diff --git a/MaterialSkinExample.RTL/Resources/round_phone_black_24dp.png b/MaterialSkinExample.RTL/Resources/round_phone_black_24dp.png new file mode 100644 index 00000000..7abe7e62 Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/round_phone_black_24dp.png differ diff --git a/MaterialSkinExample.RTL/Resources/round_report_problem_white_24dp.png b/MaterialSkinExample.RTL/Resources/round_report_problem_white_24dp.png new file mode 100644 index 00000000..44ee7827 Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/round_report_problem_white_24dp.png differ diff --git a/MaterialSkinExample.RTL/Resources/round_swap_vert_white_24dp.png b/MaterialSkinExample.RTL/Resources/round_swap_vert_white_24dp.png new file mode 100644 index 00000000..b9e965d7 Binary files /dev/null and b/MaterialSkinExample.RTL/Resources/round_swap_vert_white_24dp.png differ diff --git a/MaterialSkinExample/MainForm.Designer.cs b/MaterialSkinExample/MainForm.Designer.cs index cde17ce8..7da9791c 100644 --- a/MaterialSkinExample/MainForm.Designer.cs +++ b/MaterialSkinExample/MainForm.Designer.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using System.Windows.Forms; using MaterialSkin; using MaterialSkin.Controls; @@ -35,10 +35,34 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); + MaterialSkin.MaterialListBoxItem materialListBoxItem1 = new MaterialSkin.MaterialListBoxItem(); + MaterialSkin.MaterialListBoxItem materialListBoxItem2 = new MaterialSkin.MaterialListBoxItem(); + MaterialSkin.MaterialListBoxItem materialListBoxItem3 = new MaterialSkin.MaterialListBoxItem(); + MaterialSkin.MaterialListBoxItem materialListBoxItem4 = new MaterialSkin.MaterialListBoxItem(); + MaterialSkin.MaterialListBoxItem materialListBoxItem5 = new MaterialSkin.MaterialListBoxItem(); + MaterialSkin.MaterialListBoxItem materialListBoxItem6 = new MaterialSkin.MaterialListBoxItem(); + MaterialSkin.MaterialListBoxItem materialListBoxItem7 = new MaterialSkin.MaterialListBoxItem(); + MaterialSkin.MaterialListBoxItem materialListBoxItem8 = new MaterialSkin.MaterialListBoxItem(); + MaterialSkin.MaterialListBoxItem materialListBoxItem9 = new MaterialSkin.MaterialListBoxItem(); + MaterialSkin.MaterialListBoxItem materialListBoxItem10 = new MaterialSkin.MaterialListBoxItem(); + MaterialSkin.MaterialListBoxItem materialListBoxItem11 = new MaterialSkin.MaterialListBoxItem(); + MaterialSkin.MaterialListBoxItem materialListBoxItem12 = new MaterialSkin.MaterialListBoxItem(); + MaterialSkin.MaterialListBoxItem materialListBoxItem13 = new MaterialSkin.MaterialListBoxItem(); + MaterialSkin.MaterialListBoxItem materialListBoxItem14 = new MaterialSkin.MaterialListBoxItem(); + MaterialSkin.MaterialListBoxItem materialListBoxItem15 = new MaterialSkin.MaterialListBoxItem(); + MaterialSkin.MaterialListBoxItem materialListBoxItem16 = new MaterialSkin.MaterialListBoxItem(); + MaterialSkin.MaterialListBoxItem materialListBoxItem17 = new MaterialSkin.MaterialListBoxItem(); + MaterialSkin.MaterialListBoxItem materialListBoxItem18 = new MaterialSkin.MaterialListBoxItem(); this.materialCheckbox3 = new MaterialSkin.Controls.MaterialCheckbox(); this.materialCheckbox1 = new MaterialSkin.Controls.MaterialCheckbox(); this.materialTabControl1 = new MaterialSkin.Controls.MaterialTabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); + this.materialButton25 = new MaterialSkin.Controls.MaterialButton(); + this.materialButton6 = new MaterialSkin.Controls.MaterialButton(); + this.materialLabel57 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel53 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel52 = new MaterialSkin.Controls.MaterialLabel(); + this.materialListBoxFormStyle = new MaterialSkin.Controls.MaterialListBox(); this.MaterialButton3 = new MaterialSkin.Controls.MaterialButton(); this.materialSwitch8 = new MaterialSkin.Controls.MaterialSwitch(); this.materialLabel24 = new MaterialSkin.Controls.MaterialLabel(); @@ -47,6 +71,7 @@ private void InitializeComponent() this.materialLabel9 = new MaterialSkin.Controls.MaterialLabel(); this.materialSwitch5 = new MaterialSkin.Controls.MaterialSwitch(); this.materialButton7 = new MaterialSkin.Controls.MaterialButton(); + this.materialSwitch9 = new MaterialSkin.Controls.MaterialSwitch(); this.materialSwitch4 = new MaterialSkin.Controls.MaterialSwitch(); this.MaterialButton4 = new MaterialSkin.Controls.MaterialButton(); this.tabPage7 = new System.Windows.Forms.TabPage(); @@ -76,6 +101,7 @@ private void InitializeComponent() this.materialButton11 = new MaterialSkin.Controls.MaterialButton(); this.materialButton10 = new MaterialSkin.Controls.MaterialButton(); this.tabPage2 = new System.Windows.Forms.TabPage(); + this.msReadOnly = new MaterialSkin.Controls.MaterialSwitch(); this.materialComboBox6 = new MaterialSkin.Controls.MaterialComboBox(); this.materialComboBox2 = new MaterialSkin.Controls.MaterialComboBox(); this.materialComboBox5 = new MaterialSkin.Controls.MaterialComboBox(); @@ -100,31 +126,26 @@ private void InitializeComponent() this.materialCheckBox6 = new MaterialSkin.Controls.MaterialCheckbox(); this.materialCheckBox5 = new MaterialSkin.Controls.MaterialCheckbox(); this.tabPage3 = new System.Windows.Forms.TabPage(); - this.materialTextBox5 = new MaterialSkin.Controls.MaterialTextBox(); - this.materialTextBox4 = new MaterialSkin.Controls.MaterialTextBox(); - this.materialTextBox3 = new MaterialSkin.Controls.MaterialTextBox(); - this.materialLabel43 = new MaterialSkin.Controls.MaterialLabel(); - this.materialLabel42 = new MaterialSkin.Controls.MaterialLabel(); - this.materialLabel41 = new MaterialSkin.Controls.MaterialLabel(); - this.materialLabel40 = new MaterialSkin.Controls.MaterialLabel(); + this.materialMaskedTextBox1 = new MaterialSkin.Controls.MaterialMaskedTextBox(); + this.materialSwitch15 = new MaterialSkin.Controls.MaterialSwitch(); + this.materialSwitch14 = new MaterialSkin.Controls.MaterialSwitch(); + this.materialSwitch16 = new MaterialSkin.Controls.MaterialSwitch(); + this.materialSwitch13 = new MaterialSkin.Controls.MaterialSwitch(); + this.materialComboBox7 = new MaterialSkin.Controls.MaterialComboBox(); + this.materialSwitch12 = new MaterialSkin.Controls.MaterialSwitch(); + this.materialSwitch11 = new MaterialSkin.Controls.MaterialSwitch(); + this.materialSwitch10 = new MaterialSkin.Controls.MaterialSwitch(); + this.materialTextBox21 = new MaterialSkin.Controls.MaterialTextBox2(); + this.materialMultiLineTextBox21 = new MaterialSkin.Controls.MaterialMultiLineTextBox2(); + this.materialTextBox5 = new MaterialSkin.Controls.MaterialTextBox2(); + this.materialTextBox4 = new MaterialSkin.Controls.MaterialTextBox2(); + this.materialTextBox3 = new MaterialSkin.Controls.MaterialTextBox2(); this.materialLabel27 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel56 = new MaterialSkin.Controls.MaterialLabel(); this.materialLabel23 = new MaterialSkin.Controls.MaterialLabel(); - this.materialTextBox2 = new MaterialSkin.Controls.MaterialTextBox(); - this.materialTextBox1 = new MaterialSkin.Controls.MaterialTextBox(); - this.materialSingleLineTextField2 = new MaterialSkin.Controls.MaterialTextBox(); - this.materialLabel22 = new MaterialSkin.Controls.MaterialLabel(); - this.materialLabel21 = new MaterialSkin.Controls.MaterialLabel(); - this.materialLabel20 = new MaterialSkin.Controls.MaterialLabel(); - this.materialLabel19 = new MaterialSkin.Controls.MaterialLabel(); - this.materialLabel18 = new MaterialSkin.Controls.MaterialLabel(); - this.materialLabel17 = new MaterialSkin.Controls.MaterialLabel(); - this.materialLabel1 = new MaterialSkin.Controls.MaterialLabel(); - this.materialLabel16 = new MaterialSkin.Controls.MaterialLabel(); - this.materialLabel15 = new MaterialSkin.Controls.MaterialLabel(); - this.materialLabel14 = new MaterialSkin.Controls.MaterialLabel(); - this.materialLabel13 = new MaterialSkin.Controls.MaterialLabel(); - this.materialLabel12 = new MaterialSkin.Controls.MaterialLabel(); - this.materialLabel11 = new MaterialSkin.Controls.MaterialLabel(); + this.materialTextBox2 = new MaterialSkin.Controls.MaterialTextBox2(); + this.materialTextBox1 = new MaterialSkin.Controls.MaterialTextBox2(); + this.materialSingleLineTextField2 = new MaterialSkin.Controls.MaterialTextBox2(); this.tabPage4 = new System.Windows.Forms.TabPage(); this.materialLabel39 = new MaterialSkin.Controls.MaterialLabel(); this.materialLabel28 = new MaterialSkin.Controls.MaterialLabel(); @@ -134,7 +155,10 @@ private void InitializeComponent() this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.tabPage5 = new System.Windows.Forms.TabPage(); + this.materialSlider1 = new MaterialSkin.Controls.MaterialSlider(); + this.materialLabel49 = new MaterialSkin.Controls.MaterialLabel(); this.materialFlatButton2 = new MaterialSkin.Controls.MaterialButton(); + this.materialLabel50 = new MaterialSkin.Controls.MaterialLabel(); this.materialLabel2 = new MaterialSkin.Controls.MaterialLabel(); this.MaterialButton2 = new MaterialSkin.Controls.MaterialButton(); this.materialProgressBar1 = new MaterialSkin.Controls.MaterialProgressBar(); @@ -156,6 +180,39 @@ private void InitializeComponent() this.materialLabel10 = new MaterialSkin.Controls.MaterialLabel(); this.materialTabSelector1 = new MaterialSkin.Controls.MaterialTabSelector(); this.materialLabel30 = new MaterialSkin.Controls.MaterialLabel(); + this.tabPage10 = new System.Windows.Forms.TabPage(); + this.materialLabel55 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel48 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel47 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel46 = new MaterialSkin.Controls.MaterialLabel(); + this.materialListBox3 = new MaterialSkin.Controls.MaterialListBox(); + this.materialListBox2 = new MaterialSkin.Controls.MaterialListBox(); + this.materialListBox1 = new MaterialSkin.Controls.MaterialListBox(); + this.tabPage11 = new System.Windows.Forms.TabPage(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.materialExpansionPanel1 = new MaterialSkin.Controls.MaterialExpansionPanel(); + this.materialLabel51 = new MaterialSkin.Controls.MaterialLabel(); + this.materialExpansionPanel2 = new MaterialSkin.Controls.MaterialExpansionPanel(); + this.tabPage12 = new System.Windows.Forms.TabPage(); + this.materialLabel58 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel43 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel42 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel41 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel40 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel22 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel21 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel20 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel19 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel18 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel17 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel1 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel16 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel15 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel14 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel13 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel12 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel11 = new MaterialSkin.Controls.MaterialLabel(); + this.materialLabel54 = new MaterialSkin.Controls.MaterialLabel(); this.menuIconList = new System.Windows.Forms.ImageList(this.components); this.materialContextMenuStrip1 = new MaterialSkin.Controls.MaterialContextMenuStrip(); this.item1ToolStripMenuItem = new MaterialSkin.Controls.MaterialToolStripMenuItem(); @@ -177,6 +234,11 @@ private void InitializeComponent() this.materialTabControl2.SuspendLayout(); this.tabPage8.SuspendLayout(); this.tabPage9.SuspendLayout(); + this.tabPage10.SuspendLayout(); + this.tabPage11.SuspendLayout(); + this.flowLayoutPanel1.SuspendLayout(); + this.materialExpansionPanel1.SuspendLayout(); + this.tabPage12.SuspendLayout(); this.materialContextMenuStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -191,6 +253,7 @@ private void InitializeComponent() this.materialCheckbox3.MouseLocation = new System.Drawing.Point(-1, -1); this.materialCheckbox3.MouseState = MaterialSkin.MouseState.HOVER; this.materialCheckbox3.Name = "materialCheckbox3"; + this.materialCheckbox3.ReadOnly = false; this.materialCheckbox3.Ripple = true; this.materialCheckbox3.Size = new System.Drawing.Size(171, 37); this.materialCheckbox3.TabIndex = 2; @@ -210,6 +273,7 @@ private void InitializeComponent() this.materialCheckbox1.MouseLocation = new System.Drawing.Point(-1, -1); this.materialCheckbox1.MouseState = MaterialSkin.MouseState.HOVER; this.materialCheckbox1.Name = "materialCheckbox1"; + this.materialCheckbox1.ReadOnly = false; this.materialCheckbox1.Ripple = true; this.materialCheckbox1.Size = new System.Drawing.Size(171, 37); this.materialCheckbox1.TabIndex = 1; @@ -225,11 +289,15 @@ private void InitializeComponent() this.materialTabControl1.Controls.Add(this.tabPage4); this.materialTabControl1.Controls.Add(this.tabPage5); this.materialTabControl1.Controls.Add(this.tabPage6); + this.materialTabControl1.Controls.Add(this.tabPage10); + this.materialTabControl1.Controls.Add(this.tabPage11); + this.materialTabControl1.Controls.Add(this.tabPage12); this.materialTabControl1.Depth = 0; this.materialTabControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.materialTabControl1.ImageList = this.menuIconList; this.materialTabControl1.Location = new System.Drawing.Point(3, 64); this.materialTabControl1.MouseState = MaterialSkin.MouseState.HOVER; + this.materialTabControl1.Multiline = true; this.materialTabControl1.Name = "materialTabControl1"; this.materialTabControl1.SelectedIndex = 0; this.materialTabControl1.Size = new System.Drawing.Size(1023, 555); @@ -238,6 +306,12 @@ private void InitializeComponent() // tabPage1 // this.tabPage1.BackColor = System.Drawing.Color.White; + this.tabPage1.Controls.Add(this.materialButton25); + this.tabPage1.Controls.Add(this.materialButton6); + this.tabPage1.Controls.Add(this.materialLabel57); + this.tabPage1.Controls.Add(this.materialLabel53); + this.tabPage1.Controls.Add(this.materialLabel52); + this.tabPage1.Controls.Add(this.materialListBoxFormStyle); this.tabPage1.Controls.Add(this.MaterialButton3); this.tabPage1.Controls.Add(this.materialSwitch8); this.tabPage1.Controls.Add(this.materialLabel24); @@ -246,6 +320,7 @@ private void InitializeComponent() this.tabPage1.Controls.Add(this.materialLabel9); this.tabPage1.Controls.Add(this.materialSwitch5); this.tabPage1.Controls.Add(this.materialButton7); + this.tabPage1.Controls.Add(this.materialSwitch9); this.tabPage1.Controls.Add(this.materialSwitch4); this.tabPage1.Controls.Add(this.MaterialButton4); this.tabPage1.ImageKey = "round_assessment_white_24dp.png"; @@ -255,18 +330,114 @@ private void InitializeComponent() this.tabPage1.TabIndex = 0; this.tabPage1.Text = "Home"; // + // materialButton25 + // + this.materialButton25.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton25.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; + this.materialButton25.Depth = 0; + this.materialButton25.HighEmphasis = true; + this.materialButton25.Icon = null; + this.materialButton25.Location = new System.Drawing.Point(450, 459); + this.materialButton25.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); + this.materialButton25.MouseState = MaterialSkin.MouseState.HOVER; + this.materialButton25.Name = "materialButton25"; + this.materialButton25.NoAccentTextColor = System.Drawing.Color.Empty; + this.materialButton25.Size = new System.Drawing.Size(118, 36); + this.materialButton25.TabIndex = 41; + this.materialButton25.Text = "Show Dialog"; + this.materialButton25.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; + this.materialButton25.UseAccentColor = false; + this.materialButton25.UseVisualStyleBackColor = true; + this.materialButton25.Click += new System.EventHandler(this.materialButton25_Click); + // + // materialButton6 + // + this.materialButton6.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton6.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; + this.materialButton6.Depth = 0; + this.materialButton6.HighEmphasis = true; + this.materialButton6.Icon = null; + this.materialButton6.Location = new System.Drawing.Point(249, 459); + this.materialButton6.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); + this.materialButton6.MouseState = MaterialSkin.MouseState.HOVER; + this.materialButton6.Name = "materialButton6"; + this.materialButton6.NoAccentTextColor = System.Drawing.Color.Empty; + this.materialButton6.Size = new System.Drawing.Size(142, 36); + this.materialButton6.TabIndex = 41; + this.materialButton6.Text = "Show SnackBar"; + this.materialButton6.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; + this.materialButton6.UseAccentColor = false; + this.materialButton6.UseVisualStyleBackColor = true; + this.materialButton6.Click += new System.EventHandler(this.materialButton6_Click); + // + // materialLabel57 + // + this.materialLabel57.AutoSize = true; + this.materialLabel57.Depth = 0; + this.materialLabel57.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel57.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel57.Location = new System.Drawing.Point(447, 423); + this.materialLabel57.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.materialLabel57.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel57.Name = "materialLabel57"; + this.materialLabel57.Size = new System.Drawing.Size(47, 19); + this.materialLabel57.TabIndex = 40; + this.materialLabel57.Text = "Dialog"; + // + // materialLabel53 + // + this.materialLabel53.AutoSize = true; + this.materialLabel53.Depth = 0; + this.materialLabel53.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel53.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel53.Location = new System.Drawing.Point(246, 423); + this.materialLabel53.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.materialLabel53.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel53.Name = "materialLabel53"; + this.materialLabel53.Size = new System.Drawing.Size(69, 19); + this.materialLabel53.TabIndex = 40; + this.materialLabel53.Text = "SnackBar"; + // + // materialLabel52 + // + this.materialLabel52.AutoSize = true; + this.materialLabel52.Depth = 0; + this.materialLabel52.Font = new System.Drawing.Font("Roboto", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel52.FontType = MaterialSkin.MaterialSkinManager.fontType.H5; + this.materialLabel52.Location = new System.Drawing.Point(642, 69); + this.materialLabel52.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel52.Name = "materialLabel52"; + this.materialLabel52.Size = new System.Drawing.Size(113, 29); + this.materialLabel52.TabIndex = 39; + this.materialLabel52.Text = "Form style"; + // + // materialListBoxFormStyle + // + this.materialListBoxFormStyle.BackColor = System.Drawing.Color.White; + this.materialListBoxFormStyle.BorderColor = System.Drawing.Color.LightGray; + this.materialListBoxFormStyle.Depth = 0; + this.materialListBoxFormStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialListBoxFormStyle.Location = new System.Drawing.Point(635, 102); + this.materialListBoxFormStyle.MouseState = MaterialSkin.MouseState.HOVER; + this.materialListBoxFormStyle.Name = "materialListBoxFormStyle"; + this.materialListBoxFormStyle.SelectedIndex = -1; + this.materialListBoxFormStyle.SelectedItem = null; + this.materialListBoxFormStyle.Size = new System.Drawing.Size(225, 258); + this.materialListBoxFormStyle.TabIndex = 38; + // // MaterialButton3 // this.MaterialButton3.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.MaterialButton3.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.MaterialButton3.Depth = 0; - this.MaterialButton3.DrawShadows = true; this.MaterialButton3.HighEmphasis = true; this.MaterialButton3.Icon = null; - this.MaterialButton3.Location = new System.Drawing.Point(22, 425); + this.MaterialButton3.Location = new System.Drawing.Point(22, 460); this.MaterialButton3.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.MaterialButton3.MouseState = MaterialSkin.MouseState.HOVER; this.MaterialButton3.Name = "MaterialButton3"; - this.MaterialButton3.Size = new System.Drawing.Size(163, 36); + this.MaterialButton3.NoAccentTextColor = System.Drawing.Color.Empty; + this.MaterialButton3.Size = new System.Drawing.Size(160, 36); this.MaterialButton3.TabIndex = 36; this.MaterialButton3.Text = "Open Message box"; this.MaterialButton3.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; @@ -329,7 +500,7 @@ private void InitializeComponent() this.materialLabel6.Depth = 0; this.materialLabel6.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this.materialLabel6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel6.Location = new System.Drawing.Point(19, 389); + this.materialLabel6.Location = new System.Drawing.Point(19, 424); this.materialLabel6.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.materialLabel6.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel6.Name = "materialLabel6"; @@ -372,15 +543,16 @@ private void InitializeComponent() // materialButton7 // this.materialButton7.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton7.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton7.Depth = 0; - this.materialButton7.DrawShadows = true; this.materialButton7.HighEmphasis = true; this.materialButton7.Icon = null; this.materialButton7.Location = new System.Drawing.Point(180, 156); this.materialButton7.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton7.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton7.Name = "materialButton7"; - this.materialButton7.Size = new System.Drawing.Size(133, 36); + this.materialButton7.NoAccentTextColor = System.Drawing.Color.Empty; + this.materialButton7.Size = new System.Drawing.Size(132, 36); this.materialButton7.TabIndex = 0; this.materialButton7.Text = "Change Theme"; this.materialButton7.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Outlined; @@ -388,6 +560,23 @@ private void InitializeComponent() this.materialButton7.UseVisualStyleBackColor = true; this.materialButton7.Click += new System.EventHandler(this.materialButton1_Click); // + // materialSwitch9 + // + this.materialSwitch9.AutoSize = true; + this.materialSwitch9.Depth = 0; + this.materialSwitch9.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialSwitch9.Location = new System.Drawing.Point(22, 360); + this.materialSwitch9.Margin = new System.Windows.Forms.Padding(0); + this.materialSwitch9.MouseLocation = new System.Drawing.Point(-1, -1); + this.materialSwitch9.MouseState = MaterialSkin.MouseState.HOVER; + this.materialSwitch9.Name = "materialSwitch9"; + this.materialSwitch9.Ripple = true; + this.materialSwitch9.Size = new System.Drawing.Size(195, 37); + this.materialSwitch9.TabIndex = 29; + this.materialSwitch9.Text = "Drawer - Auto show"; + this.materialSwitch9.UseVisualStyleBackColor = true; + this.materialSwitch9.CheckedChanged += new System.EventHandler(this.materialSwitch9_CheckedChanged); + // // materialSwitch4 // this.materialSwitch4.AutoSize = true; @@ -408,15 +597,16 @@ private void InitializeComponent() // MaterialButton4 // this.MaterialButton4.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.MaterialButton4.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.MaterialButton4.Depth = 0; - this.MaterialButton4.DrawShadows = true; this.MaterialButton4.HighEmphasis = true; this.MaterialButton4.Icon = null; this.MaterialButton4.Location = new System.Drawing.Point(22, 156); this.MaterialButton4.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.MaterialButton4.MouseState = MaterialSkin.MouseState.HOVER; this.MaterialButton4.Name = "MaterialButton4"; - this.MaterialButton4.Size = new System.Drawing.Size(140, 36); + this.MaterialButton4.NoAccentTextColor = System.Drawing.Color.Empty; + this.MaterialButton4.Size = new System.Drawing.Size(138, 36); this.MaterialButton4.TabIndex = 22; this.MaterialButton4.Text = "Change Colors"; this.MaterialButton4.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; @@ -464,14 +654,15 @@ private void InitializeComponent() // this.materialButton23.AutoSize = false; this.materialButton23.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton23.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton23.Depth = 0; - this.materialButton23.DrawShadows = true; this.materialButton23.HighEmphasis = false; this.materialButton23.Icon = global::MaterialSkinExample.Properties.Resources.baseline_fingerprint_black_24dp; this.materialButton23.Location = new System.Drawing.Point(280, 221); this.materialButton23.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton23.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton23.Name = "materialButton23"; + this.materialButton23.NoAccentTextColor = System.Drawing.Color.Empty; this.materialButton23.Size = new System.Drawing.Size(168, 36); this.materialButton23.TabIndex = 7; this.materialButton23.Text = "CONT - ICON"; @@ -525,11 +716,9 @@ private void InitializeComponent() // this.materialFloatingActionButton1.AnimateShowHideButton = true; this.materialFloatingActionButton1.Depth = 0; - this.materialFloatingActionButton1.DrawShadows = true; this.materialFloatingActionButton1.Icon = global::MaterialSkinExample.Properties.Resources.plus; this.materialFloatingActionButton1.Location = new System.Drawing.Point(761, 221); this.materialFloatingActionButton1.Margin = new System.Windows.Forms.Padding(2); - this.materialFloatingActionButton1.Mini = false; this.materialFloatingActionButton1.MouseState = MaterialSkin.MouseState.HOVER; this.materialFloatingActionButton1.Name = "materialFloatingActionButton1"; this.materialFloatingActionButton1.Size = new System.Drawing.Size(56, 56); @@ -568,14 +757,15 @@ private void InitializeComponent() // this.materialButton24.AutoSize = false; this.materialButton24.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton24.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton24.Depth = 0; - this.materialButton24.DrawShadows = true; this.materialButton24.HighEmphasis = false; this.materialButton24.Icon = global::MaterialSkinExample.Properties.Resources.baseline_bluetooth_black_24dp; this.materialButton24.Location = new System.Drawing.Point(522, 221); this.materialButton24.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton24.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton24.Name = "materialButton24"; + this.materialButton24.NoAccentTextColor = System.Drawing.Color.Empty; this.materialButton24.Size = new System.Drawing.Size(189, 36); this.materialButton24.TabIndex = 13; this.materialButton24.Text = "OUTLINE - ICON"; @@ -587,14 +777,15 @@ private void InitializeComponent() // this.materialButton22.AutoSize = false; this.materialButton22.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton22.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton22.Depth = 0; - this.materialButton22.DrawShadows = true; this.materialButton22.HighEmphasis = false; this.materialButton22.Icon = global::MaterialSkinExample.Properties.Resources.baseline_favorite_border_black_24dp; this.materialButton22.Location = new System.Drawing.Point(32, 221); this.materialButton22.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton22.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton22.Name = "materialButton22"; + this.materialButton22.NoAccentTextColor = System.Drawing.Color.Empty; this.materialButton22.Size = new System.Drawing.Size(174, 36); this.materialButton22.TabIndex = 1; this.materialButton22.Text = "TEXT - ICON"; @@ -618,14 +809,15 @@ private void InitializeComponent() // this.materialButton19.AutoSize = false; this.materialButton19.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton19.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton19.Depth = 0; - this.materialButton19.DrawShadows = true; this.materialButton19.HighEmphasis = false; this.materialButton19.Icon = null; this.materialButton19.Location = new System.Drawing.Point(522, 365); this.materialButton19.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton19.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton19.Name = "materialButton19"; + this.materialButton19.NoAccentTextColor = System.Drawing.Color.Empty; this.materialButton19.Size = new System.Drawing.Size(189, 36); this.materialButton19.TabIndex = 16; this.materialButton19.Text = "OUTLINE - LOW - NORMAL"; @@ -637,14 +829,15 @@ private void InitializeComponent() // this.materialButton20.AutoSize = false; this.materialButton20.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton20.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton20.Depth = 0; - this.materialButton20.DrawShadows = true; this.materialButton20.HighEmphasis = false; this.materialButton20.Icon = null; this.materialButton20.Location = new System.Drawing.Point(32, 365); this.materialButton20.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton20.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton20.Name = "materialButton20"; + this.materialButton20.NoAccentTextColor = System.Drawing.Color.Empty; this.materialButton20.Size = new System.Drawing.Size(174, 36); this.materialButton20.TabIndex = 4; this.materialButton20.Text = "TEXT - LOW - NORMAL"; @@ -656,14 +849,15 @@ private void InitializeComponent() // this.materialButton21.AutoSize = false; this.materialButton21.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton21.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton21.Depth = 0; - this.materialButton21.DrawShadows = true; this.materialButton21.HighEmphasis = false; this.materialButton21.Icon = null; this.materialButton21.Location = new System.Drawing.Point(280, 365); this.materialButton21.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton21.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton21.Name = "materialButton21"; + this.materialButton21.NoAccentTextColor = System.Drawing.Color.Empty; this.materialButton21.Size = new System.Drawing.Size(168, 36); this.materialButton21.TabIndex = 10; this.materialButton21.Text = "CONT - LOW - NORMAL"; @@ -675,14 +869,15 @@ private void InitializeComponent() // this.materialButton5.AutoSize = false; this.materialButton5.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton5.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton5.Depth = 0; - this.materialButton5.DrawShadows = true; this.materialButton5.HighEmphasis = true; this.materialButton5.Icon = null; this.materialButton5.Location = new System.Drawing.Point(522, 269); this.materialButton5.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton5.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton5.Name = "materialButton5"; + this.materialButton5.NoAccentTextColor = System.Drawing.Color.Empty; this.materialButton5.Size = new System.Drawing.Size(189, 36); this.materialButton5.TabIndex = 14; this.materialButton5.Text = "OUTLINE - HIGH - NORMAL"; @@ -694,14 +889,15 @@ private void InitializeComponent() // this.materialButton8.AutoSize = false; this.materialButton8.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton8.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton8.Depth = 0; - this.materialButton8.DrawShadows = true; this.materialButton8.HighEmphasis = true; this.materialButton8.Icon = null; this.materialButton8.Location = new System.Drawing.Point(32, 269); this.materialButton8.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton8.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton8.Name = "materialButton8"; + this.materialButton8.NoAccentTextColor = System.Drawing.Color.Empty; this.materialButton8.Size = new System.Drawing.Size(174, 36); this.materialButton8.TabIndex = 2; this.materialButton8.Text = "TEXT - HIGH - NORMAL"; @@ -713,14 +909,15 @@ private void InitializeComponent() // this.materialButton9.AutoSize = false; this.materialButton9.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton9.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton9.Depth = 0; - this.materialButton9.DrawShadows = true; this.materialButton9.HighEmphasis = true; this.materialButton9.Icon = null; this.materialButton9.Location = new System.Drawing.Point(280, 269); this.materialButton9.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton9.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton9.Name = "materialButton9"; + this.materialButton9.NoAccentTextColor = System.Drawing.Color.Empty; this.materialButton9.Size = new System.Drawing.Size(168, 36); this.materialButton9.TabIndex = 8; this.materialButton9.Text = "CONT - HIGH - NORMAL"; @@ -732,8 +929,8 @@ private void InitializeComponent() // this.materialButton18.AutoSize = false; this.materialButton18.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton18.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton18.Depth = 0; - this.materialButton18.DrawShadows = true; this.materialButton18.Enabled = false; this.materialButton18.HighEmphasis = false; this.materialButton18.Icon = null; @@ -741,6 +938,7 @@ private void InitializeComponent() this.materialButton18.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton18.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton18.Name = "materialButton18"; + this.materialButton18.NoAccentTextColor = System.Drawing.Color.Empty; this.materialButton18.Size = new System.Drawing.Size(189, 36); this.materialButton18.TabIndex = 18; this.materialButton18.Text = "OUTLINE - DISABLED"; @@ -752,14 +950,15 @@ private void InitializeComponent() // this.materialButton17.AutoSize = false; this.materialButton17.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton17.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton17.Depth = 0; - this.materialButton17.DrawShadows = true; this.materialButton17.HighEmphasis = false; this.materialButton17.Icon = null; this.materialButton17.Location = new System.Drawing.Point(522, 413); this.materialButton17.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton17.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton17.Name = "materialButton17"; + this.materialButton17.NoAccentTextColor = System.Drawing.Color.Empty; this.materialButton17.Size = new System.Drawing.Size(189, 36); this.materialButton17.TabIndex = 17; this.materialButton17.Text = "OUTLINE - LOW - ACCENT"; @@ -771,14 +970,15 @@ private void InitializeComponent() // this.materialButton16.AutoSize = false; this.materialButton16.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton16.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton16.Depth = 0; - this.materialButton16.DrawShadows = true; this.materialButton16.HighEmphasis = true; this.materialButton16.Icon = null; this.materialButton16.Location = new System.Drawing.Point(522, 317); this.materialButton16.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton16.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton16.Name = "materialButton16"; + this.materialButton16.NoAccentTextColor = System.Drawing.Color.Empty; this.materialButton16.Size = new System.Drawing.Size(189, 36); this.materialButton16.TabIndex = 15; this.materialButton16.Text = "OUTLINE - HIGH - ACCENT"; @@ -790,14 +990,15 @@ private void InitializeComponent() // this.materialButton15.AutoSize = false; this.materialButton15.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton15.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton15.Depth = 0; - this.materialButton15.DrawShadows = true; this.materialButton15.HighEmphasis = false; this.materialButton15.Icon = null; this.materialButton15.Location = new System.Drawing.Point(32, 413); this.materialButton15.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton15.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton15.Name = "materialButton15"; + this.materialButton15.NoAccentTextColor = System.Drawing.Color.Empty; this.materialButton15.Size = new System.Drawing.Size(174, 36); this.materialButton15.TabIndex = 5; this.materialButton15.Text = "TEXT - LOW - ACCENT"; @@ -809,14 +1010,15 @@ private void InitializeComponent() // this.materialButton14.AutoSize = false; this.materialButton14.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton14.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton14.Depth = 0; - this.materialButton14.DrawShadows = true; this.materialButton14.HighEmphasis = true; this.materialButton14.Icon = null; this.materialButton14.Location = new System.Drawing.Point(32, 317); this.materialButton14.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton14.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton14.Name = "materialButton14"; + this.materialButton14.NoAccentTextColor = System.Drawing.Color.Empty; this.materialButton14.Size = new System.Drawing.Size(174, 36); this.materialButton14.TabIndex = 3; this.materialButton14.Text = "TEXT - HIGH - ACCENT"; @@ -828,8 +1030,8 @@ private void InitializeComponent() // this.materialButton13.AutoSize = false; this.materialButton13.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton13.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton13.Depth = 0; - this.materialButton13.DrawShadows = true; this.materialButton13.Enabled = false; this.materialButton13.HighEmphasis = false; this.materialButton13.Icon = null; @@ -837,6 +1039,7 @@ private void InitializeComponent() this.materialButton13.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton13.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton13.Name = "materialButton13"; + this.materialButton13.NoAccentTextColor = System.Drawing.Color.Empty; this.materialButton13.Size = new System.Drawing.Size(168, 36); this.materialButton13.TabIndex = 12; this.materialButton13.Text = "CONT - DISABLED"; @@ -848,8 +1051,8 @@ private void InitializeComponent() // this.materialButton12.AutoSize = false; this.materialButton12.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton12.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton12.Depth = 0; - this.materialButton12.DrawShadows = true; this.materialButton12.Enabled = false; this.materialButton12.HighEmphasis = false; this.materialButton12.Icon = null; @@ -857,6 +1060,7 @@ private void InitializeComponent() this.materialButton12.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton12.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton12.Name = "materialButton12"; + this.materialButton12.NoAccentTextColor = System.Drawing.Color.Empty; this.materialButton12.Size = new System.Drawing.Size(174, 36); this.materialButton12.TabIndex = 6; this.materialButton12.Text = "TEXT - DISABLED"; @@ -868,14 +1072,15 @@ private void InitializeComponent() // this.materialButton11.AutoSize = false; this.materialButton11.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton11.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton11.Depth = 0; - this.materialButton11.DrawShadows = true; this.materialButton11.HighEmphasis = false; this.materialButton11.Icon = null; this.materialButton11.Location = new System.Drawing.Point(280, 413); this.materialButton11.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton11.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton11.Name = "materialButton11"; + this.materialButton11.NoAccentTextColor = System.Drawing.Color.Empty; this.materialButton11.Size = new System.Drawing.Size(168, 36); this.materialButton11.TabIndex = 11; this.materialButton11.Text = "CONT - LOW - ACCENT"; @@ -887,14 +1092,15 @@ private void InitializeComponent() // this.materialButton10.AutoSize = false; this.materialButton10.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton10.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton10.Depth = 0; - this.materialButton10.DrawShadows = true; this.materialButton10.HighEmphasis = true; this.materialButton10.Icon = null; this.materialButton10.Location = new System.Drawing.Point(280, 317); this.materialButton10.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton10.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton10.Name = "materialButton10"; + this.materialButton10.NoAccentTextColor = System.Drawing.Color.Empty; this.materialButton10.Size = new System.Drawing.Size(168, 36); this.materialButton10.TabIndex = 9; this.materialButton10.Text = "CONT - HIGH - ACCENT"; @@ -905,6 +1111,7 @@ private void InitializeComponent() // tabPage2 // this.tabPage2.BackColor = System.Drawing.Color.White; + this.tabPage2.Controls.Add(this.msReadOnly); this.tabPage2.Controls.Add(this.materialComboBox6); this.tabPage2.Controls.Add(this.materialComboBox2); this.tabPage2.Controls.Add(this.materialComboBox5); @@ -938,6 +1145,23 @@ private void InitializeComponent() this.tabPage2.TabIndex = 1; this.tabPage2.Text = "Selection Controls"; // + // msReadOnly + // + this.msReadOnly.AutoSize = true; + this.msReadOnly.Depth = 0; + this.msReadOnly.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.msReadOnly.Location = new System.Drawing.Point(237, 125); + this.msReadOnly.Margin = new System.Windows.Forms.Padding(0); + this.msReadOnly.MouseLocation = new System.Drawing.Point(-1, -1); + this.msReadOnly.MouseState = MaterialSkin.MouseState.HOVER; + this.msReadOnly.Name = "msReadOnly"; + this.msReadOnly.Ripple = true; + this.msReadOnly.Size = new System.Drawing.Size(130, 37); + this.msReadOnly.TabIndex = 75; + this.msReadOnly.Text = "Read Only"; + this.msReadOnly.UseVisualStyleBackColor = true; + this.msReadOnly.CheckedChanged += new System.EventHandler(this.MsReadOnly_CheckedChanged); + // // materialComboBox6 // this.materialComboBox6.AutoResize = false; @@ -962,6 +1186,7 @@ private void InitializeComponent() this.materialComboBox6.MouseState = MaterialSkin.MouseState.OUT; this.materialComboBox6.Name = "materialComboBox6"; this.materialComboBox6.Size = new System.Drawing.Size(190, 49); + this.materialComboBox6.StartIndex = 0; this.materialComboBox6.TabIndex = 74; // // materialComboBox2 @@ -987,6 +1212,7 @@ private void InitializeComponent() this.materialComboBox2.MouseState = MaterialSkin.MouseState.OUT; this.materialComboBox2.Name = "materialComboBox2"; this.materialComboBox2.Size = new System.Drawing.Size(435, 49); + this.materialComboBox2.StartIndex = 0; this.materialComboBox2.TabIndex = 73; // // materialComboBox5 @@ -1080,6 +1306,7 @@ private void InitializeComponent() this.materialComboBox5.MouseState = MaterialSkin.MouseState.OUT; this.materialComboBox5.Name = "materialComboBox5"; this.materialComboBox5.Size = new System.Drawing.Size(190, 49); + this.materialComboBox5.StartIndex = 0; this.materialComboBox5.TabIndex = 72; // // materialComboBox4 @@ -1174,6 +1401,7 @@ private void InitializeComponent() this.materialComboBox4.MouseState = MaterialSkin.MouseState.OUT; this.materialComboBox4.Name = "materialComboBox4"; this.materialComboBox4.Size = new System.Drawing.Size(190, 49); + this.materialComboBox4.StartIndex = 0; this.materialComboBox4.TabIndex = 71; this.materialComboBox4.UseAccent = false; // @@ -1205,6 +1433,7 @@ private void InitializeComponent() this.materialComboBox3.MouseState = MaterialSkin.MouseState.HOVER; this.materialComboBox3.Name = "materialComboBox3"; this.materialComboBox3.Size = new System.Drawing.Size(190, 35); + this.materialComboBox3.StartIndex = 0; this.materialComboBox3.TabIndex = 70; this.materialComboBox3.UseTallSize = false; // @@ -1264,6 +1493,7 @@ private void InitializeComponent() this.materialComboBox1.MouseState = MaterialSkin.MouseState.OUT; this.materialComboBox1.Name = "materialComboBox1"; this.materialComboBox1.Size = new System.Drawing.Size(190, 49); + this.materialComboBox1.StartIndex = 0; this.materialComboBox1.TabIndex = 17; // // materialLabel34 @@ -1286,7 +1516,7 @@ private void InitializeComponent() this.materialLabel33.Depth = 0; this.materialLabel33.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this.materialLabel33.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel33.Location = new System.Drawing.Point(502, 90); + this.materialLabel33.Location = new System.Drawing.Point(675, 90); this.materialLabel33.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.materialLabel33.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel33.Name = "materialLabel33"; @@ -1300,7 +1530,7 @@ private void InitializeComponent() this.materialLabel32.Depth = 0; this.materialLabel32.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this.materialLabel32.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel32.Location = new System.Drawing.Point(255, 90); + this.materialLabel32.Location = new System.Drawing.Point(428, 90); this.materialLabel32.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.materialLabel32.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel32.Name = "materialLabel32"; @@ -1327,7 +1557,7 @@ private void InitializeComponent() this.materialSwitch7.AutoSize = true; this.materialSwitch7.Depth = 0; this.materialSwitch7.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this.materialSwitch7.Location = new System.Drawing.Point(505, 168); + this.materialSwitch7.Location = new System.Drawing.Point(678, 168); this.materialSwitch7.Margin = new System.Windows.Forms.Padding(0); this.materialSwitch7.MouseLocation = new System.Drawing.Point(-1, -1); this.materialSwitch7.MouseState = MaterialSkin.MouseState.HOVER; @@ -1344,7 +1574,7 @@ private void InitializeComponent() this.materialRadioButton5.Cursor = System.Windows.Forms.Cursors.Default; this.materialRadioButton5.Depth = 0; this.materialRadioButton5.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this.materialRadioButton5.Location = new System.Drawing.Point(258, 251); + this.materialRadioButton5.Location = new System.Drawing.Point(431, 251); this.materialRadioButton5.Margin = new System.Windows.Forms.Padding(0); this.materialRadioButton5.MouseLocation = new System.Drawing.Point(-1, -1); this.materialRadioButton5.MouseState = MaterialSkin.MouseState.HOVER; @@ -1377,7 +1607,7 @@ private void InitializeComponent() this.materialRadioButton4.Depth = 0; this.materialRadioButton4.Enabled = false; this.materialRadioButton4.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this.materialRadioButton4.Location = new System.Drawing.Point(258, 209); + this.materialRadioButton4.Location = new System.Drawing.Point(431, 209); this.materialRadioButton4.Margin = new System.Windows.Forms.Padding(0); this.materialRadioButton4.MouseLocation = new System.Drawing.Point(-1, -1); this.materialRadioButton4.MouseState = MaterialSkin.MouseState.HOVER; @@ -1395,7 +1625,7 @@ private void InitializeComponent() this.materialRadioButton1.Cursor = System.Windows.Forms.Cursors.Default; this.materialRadioButton1.Depth = 0; this.materialRadioButton1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this.materialRadioButton1.Location = new System.Drawing.Point(258, 125); + this.materialRadioButton1.Location = new System.Drawing.Point(431, 125); this.materialRadioButton1.Margin = new System.Windows.Forms.Padding(0); this.materialRadioButton1.MouseLocation = new System.Drawing.Point(-1, -1); this.materialRadioButton1.MouseState = MaterialSkin.MouseState.HOVER; @@ -1413,7 +1643,7 @@ private void InitializeComponent() this.materialRadioButton2.Cursor = System.Windows.Forms.Cursors.Default; this.materialRadioButton2.Depth = 0; this.materialRadioButton2.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this.materialRadioButton2.Location = new System.Drawing.Point(258, 167); + this.materialRadioButton2.Location = new System.Drawing.Point(431, 167); this.materialRadioButton2.Margin = new System.Windows.Forms.Padding(0); this.materialRadioButton2.MouseLocation = new System.Drawing.Point(-1, -1); this.materialRadioButton2.MouseState = MaterialSkin.MouseState.HOVER; @@ -1433,7 +1663,7 @@ private void InitializeComponent() this.materialSwitch3.Depth = 0; this.materialSwitch3.Enabled = false; this.materialSwitch3.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this.materialSwitch3.Location = new System.Drawing.Point(505, 252); + this.materialSwitch3.Location = new System.Drawing.Point(678, 252); this.materialSwitch3.Margin = new System.Windows.Forms.Padding(0); this.materialSwitch3.MouseLocation = new System.Drawing.Point(-1, -1); this.materialSwitch3.MouseState = MaterialSkin.MouseState.HOVER; @@ -1450,7 +1680,7 @@ private void InitializeComponent() this.materialSwitch2.Depth = 0; this.materialSwitch2.Enabled = false; this.materialSwitch2.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this.materialSwitch2.Location = new System.Drawing.Point(505, 210); + this.materialSwitch2.Location = new System.Drawing.Point(678, 210); this.materialSwitch2.Margin = new System.Windows.Forms.Padding(0); this.materialSwitch2.MouseLocation = new System.Drawing.Point(-1, -1); this.materialSwitch2.MouseState = MaterialSkin.MouseState.HOVER; @@ -1466,7 +1696,7 @@ private void InitializeComponent() this.materialSwitch1.AutoSize = true; this.materialSwitch1.Depth = 0; this.materialSwitch1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this.materialSwitch1.Location = new System.Drawing.Point(505, 126); + this.materialSwitch1.Location = new System.Drawing.Point(678, 126); this.materialSwitch1.Margin = new System.Windows.Forms.Padding(0); this.materialSwitch1.MouseLocation = new System.Drawing.Point(-1, -1); this.materialSwitch1.MouseState = MaterialSkin.MouseState.HOVER; @@ -1489,6 +1719,7 @@ private void InitializeComponent() this.materialCheckBox6.MouseLocation = new System.Drawing.Point(-1, -1); this.materialCheckBox6.MouseState = MaterialSkin.MouseState.HOVER; this.materialCheckBox6.Name = "materialCheckBox6"; + this.materialCheckBox6.ReadOnly = false; this.materialCheckBox6.Ripple = true; this.materialCheckBox6.Size = new System.Drawing.Size(172, 37); this.materialCheckBox6.TabIndex = 5; @@ -1509,6 +1740,7 @@ private void InitializeComponent() this.materialCheckBox5.MouseLocation = new System.Drawing.Point(-1, -1); this.materialCheckBox5.MouseState = MaterialSkin.MouseState.HOVER; this.materialCheckBox5.Name = "materialCheckBox5"; + this.materialCheckBox5.ReadOnly = false; this.materialCheckBox5.Ripple = true; this.materialCheckBox5.Size = new System.Drawing.Size(172, 37); this.materialCheckBox5.TabIndex = 4; @@ -1518,153 +1750,340 @@ private void InitializeComponent() // tabPage3 // this.tabPage3.BackColor = System.Drawing.Color.White; + this.tabPage3.Controls.Add(this.materialMaskedTextBox1); + this.tabPage3.Controls.Add(this.materialSwitch15); + this.tabPage3.Controls.Add(this.materialSwitch14); + this.tabPage3.Controls.Add(this.materialSwitch16); + this.tabPage3.Controls.Add(this.materialSwitch13); + this.tabPage3.Controls.Add(this.materialComboBox7); + this.tabPage3.Controls.Add(this.materialSwitch12); + this.tabPage3.Controls.Add(this.materialSwitch11); + this.tabPage3.Controls.Add(this.materialSwitch10); + this.tabPage3.Controls.Add(this.materialTextBox21); + this.tabPage3.Controls.Add(this.materialMultiLineTextBox21); this.tabPage3.Controls.Add(this.materialTextBox5); this.tabPage3.Controls.Add(this.materialTextBox4); this.tabPage3.Controls.Add(this.materialTextBox3); - this.tabPage3.Controls.Add(this.materialLabel43); - this.tabPage3.Controls.Add(this.materialLabel42); - this.tabPage3.Controls.Add(this.materialLabel41); - this.tabPage3.Controls.Add(this.materialLabel40); this.tabPage3.Controls.Add(this.materialLabel27); + this.tabPage3.Controls.Add(this.materialLabel56); this.tabPage3.Controls.Add(this.materialLabel23); this.tabPage3.Controls.Add(this.materialTextBox2); this.tabPage3.Controls.Add(this.materialTextBox1); this.tabPage3.Controls.Add(this.materialSingleLineTextField2); - this.tabPage3.Controls.Add(this.materialLabel22); - this.tabPage3.Controls.Add(this.materialLabel21); - this.tabPage3.Controls.Add(this.materialLabel20); - this.tabPage3.Controls.Add(this.materialLabel19); - this.tabPage3.Controls.Add(this.materialLabel18); - this.tabPage3.Controls.Add(this.materialLabel17); - this.tabPage3.Controls.Add(this.materialLabel1); - this.tabPage3.Controls.Add(this.materialLabel16); - this.tabPage3.Controls.Add(this.materialLabel15); - this.tabPage3.Controls.Add(this.materialLabel14); - this.tabPage3.Controls.Add(this.materialLabel13); - this.tabPage3.Controls.Add(this.materialLabel12); - this.tabPage3.Controls.Add(this.materialLabel11); this.tabPage3.ImageKey = "round_build_white_24dp.png"; this.tabPage3.Location = new System.Drawing.Point(4, 31); this.tabPage3.Name = "tabPage3"; this.tabPage3.Padding = new System.Windows.Forms.Padding(3); this.tabPage3.Size = new System.Drawing.Size(1015, 520); this.tabPage3.TabIndex = 2; - this.tabPage3.Text = "Textbox & Label"; + this.tabPage3.Text = "Textbox"; + // + // materialMaskedTextBox1 + // + this.materialMaskedTextBox1.AllowPromptAsInput = true; + this.materialMaskedTextBox1.AnimateReadOnly = false; + this.materialMaskedTextBox1.AsciiOnly = false; + this.materialMaskedTextBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; + this.materialMaskedTextBox1.BeepOnError = false; + this.materialMaskedTextBox1.CutCopyMaskFormat = System.Windows.Forms.MaskFormat.IncludeLiterals; + this.materialMaskedTextBox1.Depth = 0; + this.materialMaskedTextBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialMaskedTextBox1.HidePromptOnLeave = true; + this.materialMaskedTextBox1.HideSelection = false; + this.materialMaskedTextBox1.Hint = "Phone number mask"; + this.materialMaskedTextBox1.InsertKeyMode = System.Windows.Forms.InsertKeyMode.Default; + this.materialMaskedTextBox1.LeadingIcon = global::MaterialSkinExample.Properties.Resources.round_phone_black_24dp; + this.materialMaskedTextBox1.Location = new System.Drawing.Point(528, 437); + this.materialMaskedTextBox1.Mask = "+00-0-00-00-00-00"; + this.materialMaskedTextBox1.MaxLength = 32767; + this.materialMaskedTextBox1.MouseState = MaterialSkin.MouseState.OUT; + this.materialMaskedTextBox1.Name = "materialMaskedTextBox1"; + this.materialMaskedTextBox1.PasswordChar = '\0'; + this.materialMaskedTextBox1.PrefixSuffixText = null; + this.materialMaskedTextBox1.PromptChar = '_'; + this.materialMaskedTextBox1.ReadOnly = false; + this.materialMaskedTextBox1.RejectInputOnFirstFailure = true; + this.materialMaskedTextBox1.ResetOnPrompt = true; + this.materialMaskedTextBox1.ResetOnSpace = true; + this.materialMaskedTextBox1.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.materialMaskedTextBox1.SelectedText = ""; + this.materialMaskedTextBox1.SelectionLength = 0; + this.materialMaskedTextBox1.SelectionStart = 15; + this.materialMaskedTextBox1.ShortcutsEnabled = true; + this.materialMaskedTextBox1.Size = new System.Drawing.Size(384, 48); + this.materialMaskedTextBox1.SkipLiterals = true; + this.materialMaskedTextBox1.TabIndex = 81; + this.materialMaskedTextBox1.TabStop = false; + this.materialMaskedTextBox1.Text = "+ - - - - -"; + this.materialMaskedTextBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Left; + this.materialMaskedTextBox1.TextMaskFormat = System.Windows.Forms.MaskFormat.IncludeLiterals; + this.materialMaskedTextBox1.TrailingIcon = null; + this.materialMaskedTextBox1.UseSystemPasswordChar = false; + this.materialMaskedTextBox1.ValidatingType = null; + // + // materialSwitch15 + // + this.materialSwitch15.AutoSize = true; + this.materialSwitch15.Depth = 0; + this.materialSwitch15.Location = new System.Drawing.Point(528, 368); + this.materialSwitch15.Margin = new System.Windows.Forms.Padding(0); + this.materialSwitch15.MouseLocation = new System.Drawing.Point(-1, -1); + this.materialSwitch15.MouseState = MaterialSkin.MouseState.HOVER; + this.materialSwitch15.Name = "materialSwitch15"; + this.materialSwitch15.Ripple = true; + this.materialSwitch15.Size = new System.Drawing.Size(146, 37); + this.materialSwitch15.TabIndex = 78; + this.materialSwitch15.Text = "Trailing Icon"; + this.materialSwitch15.UseVisualStyleBackColor = true; + this.materialSwitch15.CheckedChanged += new System.EventHandler(this.materialSwitch15_CheckedChanged); + // + // materialSwitch14 + // + this.materialSwitch14.AutoSize = true; + this.materialSwitch14.Depth = 0; + this.materialSwitch14.Location = new System.Drawing.Point(528, 331); + this.materialSwitch14.Margin = new System.Windows.Forms.Padding(0); + this.materialSwitch14.MouseLocation = new System.Drawing.Point(-1, -1); + this.materialSwitch14.MouseState = MaterialSkin.MouseState.HOVER; + this.materialSwitch14.Name = "materialSwitch14"; + this.materialSwitch14.Ripple = true; + this.materialSwitch14.Size = new System.Drawing.Size(149, 37); + this.materialSwitch14.TabIndex = 77; + this.materialSwitch14.Text = "Leading Icon"; + this.materialSwitch14.UseVisualStyleBackColor = true; + this.materialSwitch14.CheckedChanged += new System.EventHandler(this.materialSwitch14_CheckedChanged); + // + // materialSwitch16 + // + this.materialSwitch16.AutoSize = true; + this.materialSwitch16.Checked = true; + this.materialSwitch16.CheckState = System.Windows.Forms.CheckState.Checked; + this.materialSwitch16.Depth = 0; + this.materialSwitch16.Location = new System.Drawing.Point(729, 295); + this.materialSwitch16.Margin = new System.Windows.Forms.Padding(0); + this.materialSwitch16.MouseLocation = new System.Drawing.Point(-1, -1); + this.materialSwitch16.MouseState = MaterialSkin.MouseState.HOVER; + this.materialSwitch16.Name = "materialSwitch16"; + this.materialSwitch16.Ripple = true; + this.materialSwitch16.Size = new System.Drawing.Size(200, 37); + this.materialSwitch16.TabIndex = 76; + this.materialSwitch16.Text = "Show Assistive Text"; + this.materialSwitch16.UseVisualStyleBackColor = true; + this.materialSwitch16.CheckedChanged += new System.EventHandler(this.materialSwitch16_CheckedChanged); + // + // materialSwitch13 + // + this.materialSwitch13.AutoSize = true; + this.materialSwitch13.Depth = 0; + this.materialSwitch13.Location = new System.Drawing.Point(528, 293); + this.materialSwitch13.Margin = new System.Windows.Forms.Padding(0); + this.materialSwitch13.MouseLocation = new System.Drawing.Point(-1, -1); + this.materialSwitch13.MouseState = MaterialSkin.MouseState.HOVER; + this.materialSwitch13.Name = "materialSwitch13"; + this.materialSwitch13.Ripple = true; + this.materialSwitch13.Size = new System.Drawing.Size(128, 37); + this.materialSwitch13.TabIndex = 76; + this.materialSwitch13.Text = "Password"; + this.materialSwitch13.UseVisualStyleBackColor = true; + this.materialSwitch13.CheckedChanged += new System.EventHandler(this.materialSwitch13_CheckedChanged); + // + // materialComboBox7 + // + this.materialComboBox7.AutoResize = false; + this.materialComboBox7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + this.materialComboBox7.Depth = 0; + this.materialComboBox7.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable; + this.materialComboBox7.DropDownHeight = 174; + this.materialComboBox7.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.materialComboBox7.DropDownWidth = 121; + this.materialComboBox7.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); + this.materialComboBox7.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialComboBox7.FormattingEnabled = true; + this.materialComboBox7.Hint = "Set prefix or Suffix"; + this.materialComboBox7.IntegralHeight = false; + this.materialComboBox7.ItemHeight = 43; + this.materialComboBox7.Items.AddRange(new object[] { + "None", + "Prefix", + "Suffix"}); + this.materialComboBox7.Location = new System.Drawing.Point(729, 182); + this.materialComboBox7.MaxDropDownItems = 4; + this.materialComboBox7.MouseState = MaterialSkin.MouseState.OUT; + this.materialComboBox7.Name = "materialComboBox7"; + this.materialComboBox7.Size = new System.Drawing.Size(183, 49); + this.materialComboBox7.StartIndex = 0; + this.materialComboBox7.TabIndex = 75; + this.materialComboBox7.SelectionChangeCommitted += new System.EventHandler(this.materialComboBox7_SelectionChangeCommitted); + // + // materialSwitch12 + // + this.materialSwitch12.AutoSize = true; + this.materialSwitch12.Depth = 0; + this.materialSwitch12.Location = new System.Drawing.Point(528, 256); + this.materialSwitch12.Margin = new System.Windows.Forms.Padding(0); + this.materialSwitch12.MouseLocation = new System.Drawing.Point(-1, -1); + this.materialSwitch12.MouseState = MaterialSkin.MouseState.HOVER; + this.materialSwitch12.Name = "materialSwitch12"; + this.materialSwitch12.Ripple = true; + this.materialSwitch12.Size = new System.Drawing.Size(117, 37); + this.materialSwitch12.TabIndex = 74; + this.materialSwitch12.Text = "Hint text"; + this.materialSwitch12.UseVisualStyleBackColor = true; + this.materialSwitch12.CheckedChanged += new System.EventHandler(this.materialSwitch12_CheckedChanged); + // + // materialSwitch11 + // + this.materialSwitch11.AutoSize = true; + this.materialSwitch11.Checked = true; + this.materialSwitch11.CheckState = System.Windows.Forms.CheckState.Checked; + this.materialSwitch11.Depth = 0; + this.materialSwitch11.Location = new System.Drawing.Point(528, 219); + this.materialSwitch11.Margin = new System.Windows.Forms.Padding(0); + this.materialSwitch11.MouseLocation = new System.Drawing.Point(-1, -1); + this.materialSwitch11.MouseState = MaterialSkin.MouseState.HOVER; + this.materialSwitch11.Name = "materialSwitch11"; + this.materialSwitch11.Ripple = true; + this.materialSwitch11.Size = new System.Drawing.Size(149, 37); + this.materialSwitch11.TabIndex = 73; + this.materialSwitch11.Text = "Use Tall Size"; + this.materialSwitch11.UseVisualStyleBackColor = true; + this.materialSwitch11.CheckedChanged += new System.EventHandler(this.materialSwitch11_CheckedChanged); + // + // materialSwitch10 + // + this.materialSwitch10.AutoSize = true; + this.materialSwitch10.Checked = true; + this.materialSwitch10.CheckState = System.Windows.Forms.CheckState.Checked; + this.materialSwitch10.Depth = 0; + this.materialSwitch10.Location = new System.Drawing.Point(528, 182); + this.materialSwitch10.Margin = new System.Windows.Forms.Padding(0); + this.materialSwitch10.MouseLocation = new System.Drawing.Point(-1, -1); + this.materialSwitch10.MouseState = MaterialSkin.MouseState.HOVER; + this.materialSwitch10.Name = "materialSwitch10"; + this.materialSwitch10.Ripple = true; + this.materialSwitch10.Size = new System.Drawing.Size(136, 37); + this.materialSwitch10.TabIndex = 72; + this.materialSwitch10.Text = "Use Accent"; + this.materialSwitch10.UseVisualStyleBackColor = true; + this.materialSwitch10.CheckedChanged += new System.EventHandler(this.materialSwitch10_CheckedChanged); + // + // materialTextBox21 + // + this.materialTextBox21.AnimateReadOnly = false; + this.materialTextBox21.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; + this.materialTextBox21.CharacterCasing = System.Windows.Forms.CharacterCasing.Normal; + this.materialTextBox21.Depth = 0; + this.materialTextBox21.ErrorMessage = "Invalid entry"; + this.materialTextBox21.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialTextBox21.HelperText = "Helper Text"; + this.materialTextBox21.HideSelection = true; + this.materialTextBox21.LeadingIcon = null; + this.materialTextBox21.Location = new System.Drawing.Point(528, 114); + this.materialTextBox21.MaxLength = 32767; + this.materialTextBox21.MouseState = MaterialSkin.MouseState.OUT; + this.materialTextBox21.Name = "materialTextBox21"; + this.materialTextBox21.PasswordChar = '\0'; + this.materialTextBox21.PrefixSuffixText = "$"; + this.materialTextBox21.ReadOnly = false; + this.materialTextBox21.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.materialTextBox21.SelectedText = ""; + this.materialTextBox21.SelectionLength = 0; + this.materialTextBox21.SelectionStart = 0; + this.materialTextBox21.ShortcutsEnabled = true; + this.materialTextBox21.ShowAssistiveText = true; + this.materialTextBox21.Size = new System.Drawing.Size(384, 64); + this.materialTextBox21.TabIndex = 71; + this.materialTextBox21.TabStop = false; + this.materialTextBox21.Text = "MaterialTextBox2"; + this.materialTextBox21.TextAlign = System.Windows.Forms.HorizontalAlignment.Left; + this.materialTextBox21.TrailingIcon = null; + this.materialTextBox21.UseSystemPasswordChar = false; + this.materialTextBox21.LeadingIconClick += new System.EventHandler(this.materialTextBox21_LeadingIconClick); + this.materialTextBox21.TrailingIconClick += new System.EventHandler(this.materialTextBox21_TrailingIconClick); + // + // materialMultiLineTextBox21 + // + this.materialMultiLineTextBox21.AnimateReadOnly = false; + this.materialMultiLineTextBox21.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; + this.materialMultiLineTextBox21.CharacterCasing = System.Windows.Forms.CharacterCasing.Normal; + this.materialMultiLineTextBox21.Cursor = System.Windows.Forms.Cursors.IBeam; + this.materialMultiLineTextBox21.Depth = 0; + this.materialMultiLineTextBox21.HideSelection = true; + this.materialMultiLineTextBox21.Hint = "MaterialMultiLineTextBox2"; + this.materialMultiLineTextBox21.Location = new System.Drawing.Point(25, 385); + this.materialMultiLineTextBox21.MaxLength = 2147483647; + this.materialMultiLineTextBox21.MouseState = MaterialSkin.MouseState.OUT; + this.materialMultiLineTextBox21.Name = "materialMultiLineTextBox21"; + this.materialMultiLineTextBox21.PasswordChar = '\0'; + this.materialMultiLineTextBox21.ReadOnly = false; + this.materialMultiLineTextBox21.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.materialMultiLineTextBox21.SelectedText = ""; + this.materialMultiLineTextBox21.SelectionLength = 0; + this.materialMultiLineTextBox21.SelectionStart = 0; + this.materialMultiLineTextBox21.ShortcutsEnabled = true; + this.materialMultiLineTextBox21.Size = new System.Drawing.Size(406, 100); + this.materialMultiLineTextBox21.TabIndex = 70; + this.materialMultiLineTextBox21.TabStop = false; + this.materialMultiLineTextBox21.TextAlign = System.Windows.Forms.HorizontalAlignment.Left; + this.materialMultiLineTextBox21.UseSystemPasswordChar = false; // // materialTextBox5 // - this.materialTextBox5.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.materialTextBox5.AnimateReadOnly = false; this.materialTextBox5.Cursor = System.Windows.Forms.Cursors.IBeam; this.materialTextBox5.Depth = 0; this.materialTextBox5.Enabled = false; - this.materialTextBox5.Font = new System.Drawing.Font("Roboto", 12F); + this.materialTextBox5.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F); this.materialTextBox5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialTextBox5.Hint = "This is Disabled"; + this.materialTextBox5.LeadingIcon = null; this.materialTextBox5.Location = new System.Drawing.Point(222, 170); this.materialTextBox5.MaxLength = 50; this.materialTextBox5.MouseState = MaterialSkin.MouseState.OUT; - this.materialTextBox5.Multiline = false; this.materialTextBox5.Name = "materialTextBox5"; this.materialTextBox5.Size = new System.Drawing.Size(209, 50); this.materialTextBox5.TabIndex = 69; this.materialTextBox5.Text = "But with value"; + this.materialTextBox5.TrailingIcon = null; // // materialTextBox4 // - this.materialTextBox4.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.materialTextBox4.AnimateReadOnly = false; this.materialTextBox4.Cursor = System.Windows.Forms.Cursors.IBeam; this.materialTextBox4.Depth = 0; this.materialTextBox4.Enabled = false; - this.materialTextBox4.Font = new System.Drawing.Font("Roboto", 12F); + this.materialTextBox4.Font = new System.Drawing.Font("Roboto", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this.materialTextBox4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialTextBox4.Hint = "This is Disabled"; + this.materialTextBox4.LeadingIcon = null; this.materialTextBox4.Location = new System.Drawing.Point(25, 170); this.materialTextBox4.MaxLength = 50; this.materialTextBox4.MouseState = MaterialSkin.MouseState.OUT; - this.materialTextBox4.Multiline = false; this.materialTextBox4.Name = "materialTextBox4"; this.materialTextBox4.Size = new System.Drawing.Size(191, 50); this.materialTextBox4.TabIndex = 68; this.materialTextBox4.Text = ""; + this.materialTextBox4.TrailingIcon = null; // // materialTextBox3 // - this.materialTextBox3.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.materialTextBox3.AnimateReadOnly = false; this.materialTextBox3.Cursor = System.Windows.Forms.Cursors.IBeam; this.materialTextBox3.Depth = 0; - this.materialTextBox3.Font = new System.Drawing.Font("Roboto", 12F); + this.materialTextBox3.Font = new System.Drawing.Font("Roboto", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this.materialTextBox3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialTextBox3.Hint = "This field has UseTallSize = false"; + this.materialTextBox3.LeadingIcon = null; this.materialTextBox3.Location = new System.Drawing.Point(25, 338); this.materialTextBox3.MaxLength = 50; this.materialTextBox3.MouseState = MaterialSkin.MouseState.OUT; - this.materialTextBox3.Multiline = false; this.materialTextBox3.Name = "materialTextBox3"; this.materialTextBox3.Size = new System.Drawing.Size(406, 36); this.materialTextBox3.TabIndex = 67; this.materialTextBox3.Text = ""; + this.materialTextBox3.TrailingIcon = null; this.materialTextBox3.UseTallSize = false; // - // materialLabel43 - // - this.materialLabel43.Depth = 0; - this.materialLabel43.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this.materialLabel43.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel43.Location = new System.Drawing.Point(686, 283); - this.materialLabel43.MouseState = MaterialSkin.MouseState.HOVER; - this.materialLabel43.Name = "materialLabel43"; - this.materialLabel43.Size = new System.Drawing.Size(245, 103); - this.materialLabel43.TabIndex = 66; - this.materialLabel43.Text = "Want to make a multiline label?\r\nNo problem! just disable the AutoSize Property\r\n" + - "TextAlign should work too"; - this.materialLabel43.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // materialLabel42 - // - this.materialLabel42.AutoSize = true; - this.materialLabel42.Depth = 0; - this.materialLabel42.Enabled = false; - this.materialLabel42.Font = new System.Drawing.Font("Roboto Medium", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); - this.materialLabel42.FontType = MaterialSkin.MaterialSkinManager.fontType.Subtitle2; - this.materialLabel42.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel42.Location = new System.Drawing.Point(629, 468); - this.materialLabel42.MouseState = MaterialSkin.MouseState.HOVER; - this.materialLabel42.Name = "materialLabel42"; - this.materialLabel42.Size = new System.Drawing.Size(269, 17); - this.materialLabel42.TabIndex = 65; - this.materialLabel42.Text = "This is a label is disabled (use it for hints!)"; - // - // materialLabel41 - // - this.materialLabel41.AutoSize = true; - this.materialLabel41.Depth = 0; - this.materialLabel41.Font = new System.Drawing.Font("Roboto Medium", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); - this.materialLabel41.FontType = MaterialSkin.MaterialSkinManager.fontType.Subtitle2; - this.materialLabel41.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel41.HighEmphasis = true; - this.materialLabel41.Location = new System.Drawing.Point(629, 441); - this.materialLabel41.MouseState = MaterialSkin.MouseState.HOVER; - this.materialLabel41.Name = "materialLabel41"; - this.materialLabel41.Size = new System.Drawing.Size(302, 17); - this.materialLabel41.TabIndex = 64; - this.materialLabel41.Text = "This is a label with High Emphasis + Use Accent"; - this.materialLabel41.UseAccent = true; - // - // materialLabel40 - // - this.materialLabel40.AutoSize = true; - this.materialLabel40.Depth = 0; - this.materialLabel40.Font = new System.Drawing.Font("Roboto Medium", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); - this.materialLabel40.FontType = MaterialSkin.MaterialSkinManager.fontType.Subtitle2; - this.materialLabel40.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel40.HighEmphasis = true; - this.materialLabel40.Location = new System.Drawing.Point(629, 415); - this.materialLabel40.MouseState = MaterialSkin.MouseState.HOVER; - this.materialLabel40.Name = "materialLabel40"; - this.materialLabel40.Size = new System.Drawing.Size(217, 17); - this.materialLabel40.TabIndex = 63; - this.materialLabel40.Text = "This is a label with High Emphasis"; - // // materialLabel27 // this.materialLabel27.AutoSize = true; @@ -1674,9 +2093,22 @@ private void InitializeComponent() this.materialLabel27.Location = new System.Drawing.Point(28, 18); this.materialLabel27.MouseState = MaterialSkin.MouseState.HOVER; this.materialLabel27.Name = "materialLabel27"; - this.materialLabel27.Size = new System.Drawing.Size(373, 58); + this.materialLabel27.Size = new System.Drawing.Size(173, 58); this.materialLabel27.TabIndex = 62; - this.materialLabel27.Text = "Textbox && Label"; + this.materialLabel27.Text = "Textbox"; + // + // materialLabel56 + // + this.materialLabel56.Depth = 0; + this.materialLabel56.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel56.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel56.Location = new System.Drawing.Point(525, 51); + this.materialLabel56.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel56.Name = "materialLabel56"; + this.materialLabel56.Size = new System.Drawing.Size(413, 51); + this.materialLabel56.TabIndex = 61; + this.materialLabel56.Text = "Material TextBox2 is a new variant of Material TextBox but with new code approach" + + " and with new functionality."; // // materialLabel23 // @@ -1693,235 +2125,58 @@ private void InitializeComponent() // // materialTextBox2 // - this.materialTextBox2.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.materialTextBox2.AnimateReadOnly = false; this.materialTextBox2.Cursor = System.Windows.Forms.Cursors.IBeam; this.materialTextBox2.Depth = 0; - this.materialTextBox2.Font = new System.Drawing.Font("Roboto", 12F); + this.materialTextBox2.Font = new System.Drawing.Font("Roboto", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this.materialTextBox2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialTextBox2.Hint = "Password"; + this.materialTextBox2.LeadingIcon = global::MaterialSkinExample.Properties.Resources.baseline_fingerprint_black_24dp; this.materialTextBox2.Location = new System.Drawing.Point(25, 282); this.materialTextBox2.MaxLength = 50; this.materialTextBox2.MouseState = MaterialSkin.MouseState.OUT; - this.materialTextBox2.Multiline = false; this.materialTextBox2.Name = "materialTextBox2"; - this.materialTextBox2.Password = true; + this.materialTextBox2.UseSystemPasswordChar = true; this.materialTextBox2.Size = new System.Drawing.Size(406, 50); this.materialTextBox2.TabIndex = 3; this.materialTextBox2.Text = ""; + this.materialTextBox2.TrailingIcon = null; + this.materialTextBox2.LeadingIconClick += new System.EventHandler(this.materialTextBox2_LeadingIconClick); // // materialTextBox1 // - this.materialTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.materialTextBox1.AnimateReadOnly = false; this.materialTextBox1.Cursor = System.Windows.Forms.Cursors.IBeam; this.materialTextBox1.Depth = 0; - this.materialTextBox1.Font = new System.Drawing.Font("Roboto", 12F); + this.materialTextBox1.Font = new System.Drawing.Font("Roboto", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this.materialTextBox1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialTextBox1.LeadingIcon = null; this.materialTextBox1.Location = new System.Drawing.Point(25, 114); this.materialTextBox1.MaxLength = 50; this.materialTextBox1.MouseState = MaterialSkin.MouseState.OUT; - this.materialTextBox1.Multiline = false; this.materialTextBox1.Name = "materialTextBox1"; this.materialTextBox1.Size = new System.Drawing.Size(406, 50); this.materialTextBox1.TabIndex = 1; this.materialTextBox1.Text = ""; + this.materialTextBox1.TrailingIcon = global::MaterialSkinExample.Properties.Resources.baseline_favorite_border_black_24dp; // // materialSingleLineTextField2 // - this.materialSingleLineTextField2.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.materialSingleLineTextField2.AnimateReadOnly = false; this.materialSingleLineTextField2.Cursor = System.Windows.Forms.Cursors.IBeam; this.materialSingleLineTextField2.Depth = 0; - this.materialSingleLineTextField2.Font = new System.Drawing.Font("Roboto", 12F); + this.materialSingleLineTextField2.Font = new System.Drawing.Font("Roboto", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this.materialSingleLineTextField2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); this.materialSingleLineTextField2.Hint = "Type here"; + this.materialSingleLineTextField2.LeadingIcon = null; this.materialSingleLineTextField2.Location = new System.Drawing.Point(25, 226); this.materialSingleLineTextField2.MaxLength = 50; this.materialSingleLineTextField2.MouseState = MaterialSkin.MouseState.OUT; - this.materialSingleLineTextField2.Multiline = false; this.materialSingleLineTextField2.Name = "materialSingleLineTextField2"; this.materialSingleLineTextField2.Size = new System.Drawing.Size(406, 50); this.materialSingleLineTextField2.TabIndex = 2; this.materialSingleLineTextField2.Text = ""; - // - // materialLabel22 - // - this.materialLabel22.AutoSize = true; - this.materialLabel22.Depth = 0; - this.materialLabel22.Font = new System.Drawing.Font("Roboto", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this.materialLabel22.FontType = MaterialSkin.MaterialSkinManager.fontType.Overline; - this.materialLabel22.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel22.Location = new System.Drawing.Point(478, 468); - this.materialLabel22.MouseState = MaterialSkin.MouseState.HOVER; - this.materialLabel22.Name = "materialLabel22"; - this.materialLabel22.Size = new System.Drawing.Size(47, 13); - this.materialLabel22.TabIndex = 57; - this.materialLabel22.Text = "OVERLINE"; - // - // materialLabel21 - // - this.materialLabel21.AutoSize = true; - this.materialLabel21.Depth = 0; - this.materialLabel21.Font = new System.Drawing.Font("Roboto", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this.materialLabel21.FontType = MaterialSkin.MaterialSkinManager.fontType.Caption; - this.materialLabel21.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel21.Location = new System.Drawing.Point(478, 448); - this.materialLabel21.MouseState = MaterialSkin.MouseState.HOVER; - this.materialLabel21.Name = "materialLabel21"; - this.materialLabel21.Size = new System.Drawing.Size(44, 14); - this.materialLabel21.TabIndex = 56; - this.materialLabel21.Text = "Caption"; - // - // materialLabel20 - // - this.materialLabel20.AutoSize = true; - this.materialLabel20.Depth = 0; - this.materialLabel20.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); - this.materialLabel20.FontType = MaterialSkin.MaterialSkinManager.fontType.Button; - this.materialLabel20.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel20.Location = new System.Drawing.Point(478, 428); - this.materialLabel20.MouseState = MaterialSkin.MouseState.HOVER; - this.materialLabel20.Name = "materialLabel20"; - this.materialLabel20.Size = new System.Drawing.Size(57, 17); - this.materialLabel20.TabIndex = 55; - this.materialLabel20.Text = "BUTTON"; - // - // materialLabel19 - // - this.materialLabel19.AutoSize = true; - this.materialLabel19.Depth = 0; - this.materialLabel19.Font = new System.Drawing.Font("Roboto", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this.materialLabel19.FontType = MaterialSkin.MaterialSkinManager.fontType.Body2; - this.materialLabel19.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel19.Location = new System.Drawing.Point(478, 407); - this.materialLabel19.MouseState = MaterialSkin.MouseState.HOVER; - this.materialLabel19.Name = "materialLabel19"; - this.materialLabel19.Size = new System.Drawing.Size(44, 17); - this.materialLabel19.TabIndex = 54; - this.materialLabel19.Text = "Body 2"; - // - // materialLabel18 - // - this.materialLabel18.AutoSize = true; - this.materialLabel18.Depth = 0; - this.materialLabel18.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this.materialLabel18.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel18.Location = new System.Drawing.Point(478, 384); - this.materialLabel18.MouseState = MaterialSkin.MouseState.HOVER; - this.materialLabel18.Name = "materialLabel18"; - this.materialLabel18.Size = new System.Drawing.Size(50, 19); - this.materialLabel18.TabIndex = 53; - this.materialLabel18.Text = "Body 1"; - // - // materialLabel17 - // - this.materialLabel17.AutoSize = true; - this.materialLabel17.Depth = 0; - this.materialLabel17.Font = new System.Drawing.Font("Roboto Medium", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); - this.materialLabel17.FontType = MaterialSkin.MaterialSkinManager.fontType.Subtitle2; - this.materialLabel17.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel17.Location = new System.Drawing.Point(478, 365); - this.materialLabel17.MouseState = MaterialSkin.MouseState.HOVER; - this.materialLabel17.Name = "materialLabel17"; - this.materialLabel17.Size = new System.Drawing.Size(62, 17); - this.materialLabel17.TabIndex = 52; - this.materialLabel17.Text = "Subtitle 2"; - // - // materialLabel1 - // - this.materialLabel1.AutoSize = true; - this.materialLabel1.Depth = 0; - this.materialLabel1.Font = new System.Drawing.Font("Roboto", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this.materialLabel1.FontType = MaterialSkin.MaterialSkinManager.fontType.Subtitle1; - this.materialLabel1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel1.Location = new System.Drawing.Point(477, 342); - this.materialLabel1.MouseState = MaterialSkin.MouseState.HOVER; - this.materialLabel1.Name = "materialLabel1"; - this.materialLabel1.Size = new System.Drawing.Size(68, 19); - this.materialLabel1.TabIndex = 51; - this.materialLabel1.Text = "Subtitle 1"; - // - // materialLabel16 - // - this.materialLabel16.AutoSize = true; - this.materialLabel16.Depth = 0; - this.materialLabel16.Font = new System.Drawing.Font("Roboto Medium", 20F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); - this.materialLabel16.FontType = MaterialSkin.MaterialSkinManager.fontType.H6; - this.materialLabel16.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel16.Location = new System.Drawing.Point(477, 314); - this.materialLabel16.MouseState = MaterialSkin.MouseState.HOVER; - this.materialLabel16.Name = "materialLabel16"; - this.materialLabel16.Size = new System.Drawing.Size(91, 24); - this.materialLabel16.TabIndex = 50; - this.materialLabel16.Text = "Heading 6"; - // - // materialLabel15 - // - this.materialLabel15.AutoSize = true; - this.materialLabel15.Depth = 0; - this.materialLabel15.Font = new System.Drawing.Font("Roboto", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); - this.materialLabel15.FontType = MaterialSkin.MaterialSkinManager.fontType.H5; - this.materialLabel15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel15.Location = new System.Drawing.Point(476, 283); - this.materialLabel15.MouseState = MaterialSkin.MouseState.HOVER; - this.materialLabel15.Name = "materialLabel15"; - this.materialLabel15.Size = new System.Drawing.Size(109, 29); - this.materialLabel15.TabIndex = 49; - this.materialLabel15.Text = "Heading 5"; - // - // materialLabel14 - // - this.materialLabel14.AutoSize = true; - this.materialLabel14.Depth = 0; - this.materialLabel14.Font = new System.Drawing.Font("Roboto", 34F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); - this.materialLabel14.FontType = MaterialSkin.MaterialSkinManager.fontType.H4; - this.materialLabel14.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel14.Location = new System.Drawing.Point(474, 242); - this.materialLabel14.MouseState = MaterialSkin.MouseState.HOVER; - this.materialLabel14.Name = "materialLabel14"; - this.materialLabel14.Size = new System.Drawing.Size(154, 41); - this.materialLabel14.TabIndex = 48; - this.materialLabel14.Text = "Heading 4"; - // - // materialLabel13 - // - this.materialLabel13.AutoSize = true; - this.materialLabel13.Depth = 0; - this.materialLabel13.Font = new System.Drawing.Font("Roboto", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); - this.materialLabel13.FontType = MaterialSkin.MaterialSkinManager.fontType.H3; - this.materialLabel13.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel13.Location = new System.Drawing.Point(471, 185); - this.materialLabel13.MouseState = MaterialSkin.MouseState.HOVER; - this.materialLabel13.Name = "materialLabel13"; - this.materialLabel13.Size = new System.Drawing.Size(217, 58); - this.materialLabel13.TabIndex = 47; - this.materialLabel13.Text = "Heading 3"; - // - // materialLabel12 - // - this.materialLabel12.AutoSize = true; - this.materialLabel12.Depth = 0; - this.materialLabel12.Font = new System.Drawing.Font("Roboto Light", 60F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this.materialLabel12.FontType = MaterialSkin.MaterialSkinManager.fontType.H2; - this.materialLabel12.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel12.Location = new System.Drawing.Point(468, 114); - this.materialLabel12.MouseState = MaterialSkin.MouseState.HOVER; - this.materialLabel12.Name = "materialLabel12"; - this.materialLabel12.Size = new System.Drawing.Size(266, 72); - this.materialLabel12.TabIndex = 46; - this.materialLabel12.Text = "Heading 2"; - // - // materialLabel11 - // - this.materialLabel11.AutoSize = true; - this.materialLabel11.Depth = 0; - this.materialLabel11.Font = new System.Drawing.Font("Roboto Light", 96F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); - this.materialLabel11.FontType = MaterialSkin.MaterialSkinManager.fontType.H1; - this.materialLabel11.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.materialLabel11.Location = new System.Drawing.Point(461, 18); - this.materialLabel11.MouseState = MaterialSkin.MouseState.HOVER; - this.materialLabel11.Name = "materialLabel11"; - this.materialLabel11.Size = new System.Drawing.Size(427, 115); - this.materialLabel11.TabIndex = 45; - this.materialLabel11.Text = "Heading 1"; + this.materialSingleLineTextField2.TrailingIcon = null; // // tabPage4 // @@ -1975,7 +2230,7 @@ private void InitializeComponent() this.columnHeader3, this.columnHeader4}); this.materialListView1.Depth = 0; - this.materialListView1.Font = new System.Drawing.Font("Roboto", 34F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); + this.materialListView1.Font = new System.Drawing.Font("Microsoft Sans Serif", 34F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); this.materialListView1.FullRowSelect = true; this.materialListView1.HideSelection = false; this.materialListView1.Location = new System.Drawing.Point(25, 149); @@ -2013,7 +2268,10 @@ private void InitializeComponent() // tabPage5 // this.tabPage5.BackColor = System.Drawing.Color.White; + this.tabPage5.Controls.Add(this.materialSlider1); + this.tabPage5.Controls.Add(this.materialLabel49); this.tabPage5.Controls.Add(this.materialFlatButton2); + this.tabPage5.Controls.Add(this.materialLabel50); this.tabPage5.Controls.Add(this.materialLabel2); this.tabPage5.Controls.Add(this.MaterialButton2); this.tabPage5.Controls.Add(this.materialProgressBar1); @@ -2026,18 +2284,44 @@ private void InitializeComponent() this.tabPage5.TabIndex = 4; this.tabPage5.Text = "Progress Bar"; // + // materialSlider1 + // + this.materialSlider1.Depth = 0; + this.materialSlider1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialSlider1.Location = new System.Drawing.Point(32, 327); + this.materialSlider1.MouseState = MaterialSkin.MouseState.HOVER; + this.materialSlider1.Name = "materialSlider1"; + this.materialSlider1.Size = new System.Drawing.Size(300, 40); + this.materialSlider1.TabIndex = 66; + this.materialSlider1.Text = "materialSlider1"; + this.materialSlider1.ValueSuffix = "%"; + // + // materialLabel49 + // + this.materialLabel49.AutoSize = true; + this.materialLabel49.Depth = 0; + this.materialLabel49.Font = new System.Drawing.Font("Roboto", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel49.FontType = MaterialSkin.MaterialSkinManager.fontType.H3; + this.materialLabel49.Location = new System.Drawing.Point(32, 234); + this.materialLabel49.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel49.Name = "materialLabel49"; + this.materialLabel49.Size = new System.Drawing.Size(121, 58); + this.materialLabel49.TabIndex = 65; + this.materialLabel49.Text = "Slider"; + // // materialFlatButton2 // this.materialFlatButton2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialFlatButton2.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialFlatButton2.Depth = 0; - this.materialFlatButton2.DrawShadows = true; this.materialFlatButton2.HighEmphasis = false; this.materialFlatButton2.Icon = global::MaterialSkinExample.Properties.Resources.minus; this.materialFlatButton2.Location = new System.Drawing.Point(29, 156); this.materialFlatButton2.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialFlatButton2.MouseState = MaterialSkin.MouseState.HOVER; this.materialFlatButton2.Name = "materialFlatButton2"; - this.materialFlatButton2.Size = new System.Drawing.Size(108, 36); + this.materialFlatButton2.NoAccentTextColor = System.Drawing.Color.Empty; + this.materialFlatButton2.Size = new System.Drawing.Size(107, 36); this.materialFlatButton2.TabIndex = 1; this.materialFlatButton2.Text = "Remove"; this.materialFlatButton2.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Outlined; @@ -2045,6 +2329,20 @@ private void InitializeComponent() this.materialFlatButton2.UseVisualStyleBackColor = true; this.materialFlatButton2.Click += new System.EventHandler(this.materialFlatButton4_Click); // + // materialLabel50 + // + this.materialLabel50.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.materialLabel50.Depth = 0; + this.materialLabel50.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel50.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel50.Location = new System.Drawing.Point(29, 292); + this.materialLabel50.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel50.Name = "materialLabel50"; + this.materialLabel50.Size = new System.Drawing.Size(821, 32); + this.materialLabel50.TabIndex = 3; + this.materialLabel50.Text = "Sliders allow users to make selections from a range of values"; + // // materialLabel2 // this.materialLabel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -2064,14 +2362,15 @@ private void InitializeComponent() // this.MaterialButton2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.MaterialButton2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.MaterialButton2.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.MaterialButton2.Depth = 0; - this.MaterialButton2.DrawShadows = true; this.MaterialButton2.HighEmphasis = true; - this.MaterialButton2.Icon = global::MaterialSkinExample.Properties.Resources.plus; + this.MaterialButton2.Icon = global::MaterialSkinExample.Properties.Resources.round_add_black_24dp; this.MaterialButton2.Location = new System.Drawing.Point(755, 156); this.MaterialButton2.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.MaterialButton2.MouseState = MaterialSkin.MouseState.HOVER; this.MaterialButton2.Name = "MaterialButton2"; + this.MaterialButton2.NoAccentTextColor = System.Drawing.Color.Empty; this.MaterialButton2.Size = new System.Drawing.Size(78, 36); this.MaterialButton2.TabIndex = 2; this.MaterialButton2.Text = "Add"; @@ -2190,15 +2489,16 @@ private void InitializeComponent() // this.materialButton1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.materialButton1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.materialButton1.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; this.materialButton1.Depth = 0; - this.materialButton1.DrawShadows = true; this.materialButton1.HighEmphasis = true; this.materialButton1.Icon = null; - this.materialButton1.Location = new System.Drawing.Point(226, 131); + this.materialButton1.Location = new System.Drawing.Point(220, 131); this.materialButton1.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton1.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton1.Name = "materialButton1"; - this.materialButton1.Size = new System.Drawing.Size(58, 36); + this.materialButton1.NoAccentTextColor = System.Drawing.Color.Empty; + this.materialButton1.Size = new System.Drawing.Size(64, 36); this.materialButton1.TabIndex = 1; this.materialButton1.Text = "Nice!"; this.materialButton1.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Text; @@ -2241,6 +2541,7 @@ private void InitializeComponent() this.materialTabControl2.Location = new System.Drawing.Point(40, 128); this.materialTabControl2.Margin = new System.Windows.Forms.Padding(0); this.materialTabControl2.MouseState = MaterialSkin.MouseState.HOVER; + this.materialTabControl2.Multiline = true; this.materialTabControl2.Name = "materialTabControl2"; this.materialTabControl2.SelectedIndex = 0; this.materialTabControl2.Size = new System.Drawing.Size(491, 278); @@ -2256,7 +2557,7 @@ private void InitializeComponent() this.tabPage8.Padding = new System.Windows.Forms.Padding(3); this.tabPage8.Size = new System.Drawing.Size(483, 252); this.tabPage8.TabIndex = 0; - this.tabPage8.Text = "FIRST"; + this.tabPage8.Text = "FirSt"; // // materialLabel45 // @@ -2296,7 +2597,7 @@ private void InitializeComponent() this.tabPage9.Padding = new System.Windows.Forms.Padding(3); this.tabPage9.Size = new System.Drawing.Size(483, 252); this.tabPage9.TabIndex = 1; - this.tabPage9.Text = "Second"; + this.tabPage9.Text = "seConD"; // // materialLabel10 // @@ -2317,6 +2618,7 @@ private void InitializeComponent() // materialTabSelector1 // this.materialTabSelector1.BaseTabControl = this.materialTabControl2; + this.materialTabSelector1.CharacterCasing = MaterialSkin.Controls.MaterialTabSelector.CustomCharacterCasing.Proper; this.materialTabSelector1.Depth = 0; this.materialTabSelector1.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this.materialTabSelector1.Location = new System.Drawing.Point(40, 90); @@ -2340,6 +2642,557 @@ private void InitializeComponent() this.materialLabel30.TabIndex = 65; this.materialLabel30.Text = "Cards"; // + // tabPage10 + // + this.tabPage10.BackColor = System.Drawing.Color.White; + this.tabPage10.Controls.Add(this.materialLabel55); + this.tabPage10.Controls.Add(this.materialLabel48); + this.tabPage10.Controls.Add(this.materialLabel47); + this.tabPage10.Controls.Add(this.materialLabel46); + this.tabPage10.Controls.Add(this.materialListBox3); + this.tabPage10.Controls.Add(this.materialListBox2); + this.tabPage10.Controls.Add(this.materialListBox1); + this.tabPage10.ImageKey = "round_bookmark_white_24dp.png"; + this.tabPage10.Location = new System.Drawing.Point(4, 31); + this.tabPage10.Name = "tabPage10"; + this.tabPage10.Size = new System.Drawing.Size(1015, 520); + this.tabPage10.TabIndex = 7; + this.tabPage10.Text = "ListBox"; + // + // materialLabel55 + // + this.materialLabel55.AutoSize = true; + this.materialLabel55.Depth = 0; + this.materialLabel55.Font = new System.Drawing.Font("Roboto", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel55.FontType = MaterialSkin.MaterialSkinManager.fontType.H3; + this.materialLabel55.Location = new System.Drawing.Point(28, 18); + this.materialLabel55.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel55.Name = "materialLabel55"; + this.materialLabel55.Size = new System.Drawing.Size(158, 58); + this.materialLabel55.TabIndex = 63; + this.materialLabel55.Text = "Listbox"; + // + // materialLabel48 + // + this.materialLabel48.AutoSize = true; + this.materialLabel48.Depth = 0; + this.materialLabel48.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel48.Location = new System.Drawing.Point(587, 98); + this.materialLabel48.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel48.Name = "materialLabel48"; + this.materialLabel48.Size = new System.Drawing.Size(130, 19); + this.materialLabel48.TabIndex = 3; + this.materialLabel48.Text = "ListBox three lines"; + // + // materialLabel47 + // + this.materialLabel47.AutoSize = true; + this.materialLabel47.Depth = 0; + this.materialLabel47.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel47.Location = new System.Drawing.Point(314, 98); + this.materialLabel47.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel47.Name = "materialLabel47"; + this.materialLabel47.Size = new System.Drawing.Size(121, 19); + this.materialLabel47.TabIndex = 3; + this.materialLabel47.Text = "ListBox two lines"; + // + // materialLabel46 + // + this.materialLabel46.AutoSize = true; + this.materialLabel46.Depth = 0; + this.materialLabel46.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel46.Location = new System.Drawing.Point(49, 98); + this.materialLabel46.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel46.Name = "materialLabel46"; + this.materialLabel46.Size = new System.Drawing.Size(129, 19); + this.materialLabel46.TabIndex = 3; + this.materialLabel46.Text = "ListBox single line"; + // + // materialListBox3 + // + this.materialListBox3.BackColor = System.Drawing.Color.White; + this.materialListBox3.BorderColor = System.Drawing.Color.LightGray; + this.materialListBox3.Depth = 0; + this.materialListBox3.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + materialListBoxItem1.SecondaryText = "A very very long secondary text to display 1 "; + materialListBoxItem1.Tag = null; + materialListBoxItem1.Text = "ListBoxItem1"; + materialListBoxItem2.SecondaryText = "A very very long secondary text to display 2"; + materialListBoxItem2.Tag = null; + materialListBoxItem2.Text = "ListBoxItem2"; + materialListBoxItem3.SecondaryText = "A very very long secondary text to display 3"; + materialListBoxItem3.Tag = null; + materialListBoxItem3.Text = "ListBoxItem3"; + materialListBoxItem4.SecondaryText = "A very very long secondary text to display 4"; + materialListBoxItem4.Tag = null; + materialListBoxItem4.Text = "ListBoxItem4"; + materialListBoxItem5.SecondaryText = "A very very long secondary text to display 5"; + materialListBoxItem5.Tag = null; + materialListBoxItem5.Text = "ListBoxItem5"; + materialListBoxItem6.SecondaryText = "A very very long secondary text to display 6"; + materialListBoxItem6.Tag = null; + materialListBoxItem6.Text = "ListBoxItem6"; + this.materialListBox3.Items.Add(materialListBoxItem1); + this.materialListBox3.Items.Add(materialListBoxItem2); + this.materialListBox3.Items.Add(materialListBoxItem3); + this.materialListBox3.Items.Add(materialListBoxItem4); + this.materialListBox3.Items.Add(materialListBoxItem5); + this.materialListBox3.Items.Add(materialListBoxItem6); + this.materialListBox3.Location = new System.Drawing.Point(579, 132); + this.materialListBox3.MouseState = MaterialSkin.MouseState.HOVER; + this.materialListBox3.Name = "materialListBox3"; + this.materialListBox3.SelectedIndex = -1; + this.materialListBox3.SelectedItem = null; + this.materialListBox3.Size = new System.Drawing.Size(200, 160); + this.materialListBox3.Style = MaterialSkin.Controls.MaterialListBox.ListBoxStyle.ThreeLine; + this.materialListBox3.TabIndex = 2; + // + // materialListBox2 + // + this.materialListBox2.BackColor = System.Drawing.Color.White; + this.materialListBox2.BorderColor = System.Drawing.Color.LightGray; + this.materialListBox2.Depth = 0; + this.materialListBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + materialListBoxItem7.SecondaryText = "Secondary text1"; + materialListBoxItem7.Tag = null; + materialListBoxItem7.Text = "ListBoxItem1"; + materialListBoxItem8.SecondaryText = "Secondary text2"; + materialListBoxItem8.Tag = null; + materialListBoxItem8.Text = "ListBoxItem2"; + materialListBoxItem9.SecondaryText = "Secondary text3"; + materialListBoxItem9.Tag = null; + materialListBoxItem9.Text = "ListBoxItem3"; + materialListBoxItem10.SecondaryText = "Secondary text4"; + materialListBoxItem10.Tag = null; + materialListBoxItem10.Text = "ListBoxItem4"; + materialListBoxItem11.SecondaryText = "Secondary text5"; + materialListBoxItem11.Tag = null; + materialListBoxItem11.Text = "ListBoxItem5"; + materialListBoxItem12.SecondaryText = "Secondary text6"; + materialListBoxItem12.Tag = null; + materialListBoxItem12.Text = "ListBoxItem6"; + this.materialListBox2.Items.Add(materialListBoxItem7); + this.materialListBox2.Items.Add(materialListBoxItem8); + this.materialListBox2.Items.Add(materialListBoxItem9); + this.materialListBox2.Items.Add(materialListBoxItem10); + this.materialListBox2.Items.Add(materialListBoxItem11); + this.materialListBox2.Items.Add(materialListBoxItem12); + this.materialListBox2.Location = new System.Drawing.Point(306, 132); + this.materialListBox2.MouseState = MaterialSkin.MouseState.HOVER; + this.materialListBox2.Name = "materialListBox2"; + this.materialListBox2.SelectedIndex = -1; + this.materialListBox2.SelectedItem = null; + this.materialListBox2.Size = new System.Drawing.Size(200, 160); + this.materialListBox2.Style = MaterialSkin.Controls.MaterialListBox.ListBoxStyle.TwoLine; + this.materialListBox2.TabIndex = 1; + this.materialListBox2.UseAccentColor = true; + // + // materialListBox1 + // + this.materialListBox1.BackColor = System.Drawing.Color.White; + this.materialListBox1.BorderColor = System.Drawing.Color.LightGray; + this.materialListBox1.Depth = 0; + this.materialListBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + materialListBoxItem13.SecondaryText = ""; + materialListBoxItem13.Tag = null; + materialListBoxItem13.Text = "ListBoxItem1"; + materialListBoxItem14.SecondaryText = ""; + materialListBoxItem14.Tag = null; + materialListBoxItem14.Text = "ListBoxItem2"; + materialListBoxItem15.SecondaryText = ""; + materialListBoxItem15.Tag = null; + materialListBoxItem15.Text = "ListBoxItem3"; + materialListBoxItem16.SecondaryText = ""; + materialListBoxItem16.Tag = null; + materialListBoxItem16.Text = "ListBoxItem4"; + materialListBoxItem17.SecondaryText = ""; + materialListBoxItem17.Tag = null; + materialListBoxItem17.Text = "ListBoxItem5"; + materialListBoxItem18.SecondaryText = ""; + materialListBoxItem18.Tag = null; + materialListBoxItem18.Text = "ListBoxItem6"; + this.materialListBox1.Items.Add(materialListBoxItem13); + this.materialListBox1.Items.Add(materialListBoxItem14); + this.materialListBox1.Items.Add(materialListBoxItem15); + this.materialListBox1.Items.Add(materialListBoxItem16); + this.materialListBox1.Items.Add(materialListBoxItem17); + this.materialListBox1.Items.Add(materialListBoxItem18); + this.materialListBox1.Location = new System.Drawing.Point(38, 132); + this.materialListBox1.MouseState = MaterialSkin.MouseState.HOVER; + this.materialListBox1.Name = "materialListBox1"; + this.materialListBox1.SelectedIndex = -1; + this.materialListBox1.SelectedItem = null; + this.materialListBox1.Size = new System.Drawing.Size(200, 160); + this.materialListBox1.TabIndex = 0; + // + // tabPage11 + // + this.tabPage11.BackColor = System.Drawing.Color.White; + this.tabPage11.Controls.Add(this.flowLayoutPanel1); + this.tabPage11.ImageKey = "round_http_white_24dp.png"; + this.tabPage11.Location = new System.Drawing.Point(4, 31); + this.tabPage11.Name = "tabPage11"; + this.tabPage11.Size = new System.Drawing.Size(1015, 520); + this.tabPage11.TabIndex = 8; + this.tabPage11.Text = "Expansion panel"; + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.flowLayoutPanel1.AutoScroll = true; + this.flowLayoutPanel1.Controls.Add(this.materialExpansionPanel1); + this.flowLayoutPanel1.Controls.Add(this.materialExpansionPanel2); + this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 3); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(561, 514); + this.flowLayoutPanel1.TabIndex = 0; + this.flowLayoutPanel1.WrapContents = false; + // + // materialExpansionPanel1 + // + this.materialExpansionPanel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + this.materialExpansionPanel1.Controls.Add(this.materialLabel51); + this.materialExpansionPanel1.Depth = 0; + this.materialExpansionPanel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialExpansionPanel1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialExpansionPanel1.Location = new System.Drawing.Point(16, 16); + this.materialExpansionPanel1.Margin = new System.Windows.Forms.Padding(16); + this.materialExpansionPanel1.MouseState = MaterialSkin.MouseState.HOVER; + this.materialExpansionPanel1.Name = "materialExpansionPanel1"; + this.materialExpansionPanel1.Padding = new System.Windows.Forms.Padding(24, 64, 24, 16); + this.materialExpansionPanel1.Size = new System.Drawing.Size(523, 240); + this.materialExpansionPanel1.TabIndex = 0; + this.materialExpansionPanel1.Title = "Expansion panel"; + // + // materialLabel51 + // + this.materialLabel51.Depth = 0; + this.materialLabel51.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel51.Location = new System.Drawing.Point(28, 68); + this.materialLabel51.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel51.Name = "materialLabel51"; + this.materialLabel51.Size = new System.Drawing.Size(468, 64); + this.materialLabel51.TabIndex = 2; + this.materialLabel51.Text = "An expansion panel is a lightweight container that may either stand alone or be c" + + "onnected to a larger surface, such as a card."; + // + // materialExpansionPanel2 + // + this.materialExpansionPanel2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + this.materialExpansionPanel2.Collapse = true; + this.materialExpansionPanel2.Depth = 0; + this.materialExpansionPanel2.Description = "With accent color"; + this.materialExpansionPanel2.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialExpansionPanel2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialExpansionPanel2.Location = new System.Drawing.Point(16, 273); + this.materialExpansionPanel2.Margin = new System.Windows.Forms.Padding(16, 1, 16, 0); + this.materialExpansionPanel2.MouseState = MaterialSkin.MouseState.HOVER; + this.materialExpansionPanel2.Name = "materialExpansionPanel2"; + this.materialExpansionPanel2.Padding = new System.Windows.Forms.Padding(24, 64, 24, 16); + this.materialExpansionPanel2.Size = new System.Drawing.Size(523, 48); + this.materialExpansionPanel2.TabIndex = 2; + this.materialExpansionPanel2.Title = "Expansion panel"; + this.materialExpansionPanel2.UseAccentColor = true; + // + // tabPage12 + // + this.tabPage12.BackColor = System.Drawing.Color.White; + this.tabPage12.Controls.Add(this.materialLabel58); + this.tabPage12.Controls.Add(this.materialLabel43); + this.tabPage12.Controls.Add(this.materialLabel42); + this.tabPage12.Controls.Add(this.materialLabel41); + this.tabPage12.Controls.Add(this.materialLabel40); + this.tabPage12.Controls.Add(this.materialLabel22); + this.tabPage12.Controls.Add(this.materialLabel21); + this.tabPage12.Controls.Add(this.materialLabel20); + this.tabPage12.Controls.Add(this.materialLabel19); + this.tabPage12.Controls.Add(this.materialLabel18); + this.tabPage12.Controls.Add(this.materialLabel17); + this.tabPage12.Controls.Add(this.materialLabel1); + this.tabPage12.Controls.Add(this.materialLabel16); + this.tabPage12.Controls.Add(this.materialLabel15); + this.tabPage12.Controls.Add(this.materialLabel14); + this.tabPage12.Controls.Add(this.materialLabel13); + this.tabPage12.Controls.Add(this.materialLabel12); + this.tabPage12.Controls.Add(this.materialLabel11); + this.tabPage12.Controls.Add(this.materialLabel54); + this.tabPage12.ImageKey = "round_phone_black_24dp.png"; + this.tabPage12.Location = new System.Drawing.Point(4, 31); + this.tabPage12.Name = "tabPage12"; + this.tabPage12.Size = new System.Drawing.Size(1015, 520); + this.tabPage12.TabIndex = 9; + this.tabPage12.Text = "Label"; + // + // materialLabel58 + // + this.materialLabel58.AutoSize = true; + this.materialLabel58.Depth = 0; + this.materialLabel58.Font = new System.Drawing.Font("Roboto", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel58.FontType = MaterialSkin.MaterialSkinManager.fontType.SubtleEmphasis; + this.materialLabel58.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel58.Location = new System.Drawing.Point(492, 483); + this.materialLabel58.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel58.Name = "materialLabel58"; + this.materialLabel58.Size = new System.Drawing.Size(89, 14); + this.materialLabel58.TabIndex = 84; + this.materialLabel58.Text = "SubtleEmphasis"; + // + // materialLabel43 + // + this.materialLabel43.Depth = 0; + this.materialLabel43.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel43.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel43.Location = new System.Drawing.Point(675, 283); + this.materialLabel43.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel43.Name = "materialLabel43"; + this.materialLabel43.Size = new System.Drawing.Size(245, 103); + this.materialLabel43.TabIndex = 83; + this.materialLabel43.Text = "Want to make a multiline label?\r\nNo problem! just disable the AutoSize Property\r\n" + + "TextAlign should work too"; + this.materialLabel43.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // materialLabel42 + // + this.materialLabel42.AutoSize = true; + this.materialLabel42.Depth = 0; + this.materialLabel42.Enabled = false; + this.materialLabel42.Font = new System.Drawing.Font("Roboto Medium", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel42.FontType = MaterialSkin.MaterialSkinManager.fontType.Subtitle2; + this.materialLabel42.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel42.Location = new System.Drawing.Point(643, 468); + this.materialLabel42.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel42.Name = "materialLabel42"; + this.materialLabel42.Size = new System.Drawing.Size(269, 17); + this.materialLabel42.TabIndex = 82; + this.materialLabel42.Text = "This is a label is disabled (use it for hints!)"; + // + // materialLabel41 + // + this.materialLabel41.AutoSize = true; + this.materialLabel41.Depth = 0; + this.materialLabel41.Font = new System.Drawing.Font("Roboto Medium", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel41.FontType = MaterialSkin.MaterialSkinManager.fontType.Subtitle2; + this.materialLabel41.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel41.HighEmphasis = true; + this.materialLabel41.Location = new System.Drawing.Point(643, 441); + this.materialLabel41.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel41.Name = "materialLabel41"; + this.materialLabel41.Size = new System.Drawing.Size(302, 17); + this.materialLabel41.TabIndex = 81; + this.materialLabel41.Text = "This is a label with High Emphasis + Use Accent"; + this.materialLabel41.UseAccent = true; + // + // materialLabel40 + // + this.materialLabel40.AutoSize = true; + this.materialLabel40.Depth = 0; + this.materialLabel40.Font = new System.Drawing.Font("Roboto Medium", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel40.FontType = MaterialSkin.MaterialSkinManager.fontType.Subtitle2; + this.materialLabel40.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel40.HighEmphasis = true; + this.materialLabel40.Location = new System.Drawing.Point(643, 415); + this.materialLabel40.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel40.Name = "materialLabel40"; + this.materialLabel40.Size = new System.Drawing.Size(217, 17); + this.materialLabel40.TabIndex = 80; + this.materialLabel40.Text = "This is a label with High Emphasis"; + // + // materialLabel22 + // + this.materialLabel22.AutoSize = true; + this.materialLabel22.Depth = 0; + this.materialLabel22.Font = new System.Drawing.Font("Roboto", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel22.FontType = MaterialSkin.MaterialSkinManager.fontType.Overline; + this.materialLabel22.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel22.Location = new System.Drawing.Point(492, 468); + this.materialLabel22.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel22.Name = "materialLabel22"; + this.materialLabel22.Size = new System.Drawing.Size(47, 13); + this.materialLabel22.TabIndex = 79; + this.materialLabel22.Text = "OVERLINE"; + // + // materialLabel21 + // + this.materialLabel21.AutoSize = true; + this.materialLabel21.Depth = 0; + this.materialLabel21.Font = new System.Drawing.Font("Roboto", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel21.FontType = MaterialSkin.MaterialSkinManager.fontType.Caption; + this.materialLabel21.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel21.Location = new System.Drawing.Point(492, 448); + this.materialLabel21.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel21.Name = "materialLabel21"; + this.materialLabel21.Size = new System.Drawing.Size(44, 14); + this.materialLabel21.TabIndex = 78; + this.materialLabel21.Text = "Caption"; + // + // materialLabel20 + // + this.materialLabel20.AutoSize = true; + this.materialLabel20.Depth = 0; + this.materialLabel20.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel20.FontType = MaterialSkin.MaterialSkinManager.fontType.Button; + this.materialLabel20.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel20.Location = new System.Drawing.Point(492, 428); + this.materialLabel20.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel20.Name = "materialLabel20"; + this.materialLabel20.Size = new System.Drawing.Size(57, 17); + this.materialLabel20.TabIndex = 77; + this.materialLabel20.Text = "BUTTON"; + // + // materialLabel19 + // + this.materialLabel19.AutoSize = true; + this.materialLabel19.Depth = 0; + this.materialLabel19.Font = new System.Drawing.Font("Roboto", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel19.FontType = MaterialSkin.MaterialSkinManager.fontType.Body2; + this.materialLabel19.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel19.Location = new System.Drawing.Point(492, 407); + this.materialLabel19.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel19.Name = "materialLabel19"; + this.materialLabel19.Size = new System.Drawing.Size(44, 17); + this.materialLabel19.TabIndex = 76; + this.materialLabel19.Text = "Body 2"; + // + // materialLabel18 + // + this.materialLabel18.AutoSize = true; + this.materialLabel18.Depth = 0; + this.materialLabel18.Font = new System.Drawing.Font("Roboto", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel18.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel18.Location = new System.Drawing.Point(492, 384); + this.materialLabel18.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel18.Name = "materialLabel18"; + this.materialLabel18.Size = new System.Drawing.Size(50, 19); + this.materialLabel18.TabIndex = 75; + this.materialLabel18.Text = "Body 1"; + // + // materialLabel17 + // + this.materialLabel17.AutoSize = true; + this.materialLabel17.Depth = 0; + this.materialLabel17.Font = new System.Drawing.Font("Roboto Medium", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel17.FontType = MaterialSkin.MaterialSkinManager.fontType.Subtitle2; + this.materialLabel17.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel17.Location = new System.Drawing.Point(492, 365); + this.materialLabel17.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel17.Name = "materialLabel17"; + this.materialLabel17.Size = new System.Drawing.Size(62, 17); + this.materialLabel17.TabIndex = 74; + this.materialLabel17.Text = "Subtitle 2"; + // + // materialLabel1 + // + this.materialLabel1.AutoSize = true; + this.materialLabel1.Depth = 0; + this.materialLabel1.Font = new System.Drawing.Font("Roboto", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel1.FontType = MaterialSkin.MaterialSkinManager.fontType.Subtitle1; + this.materialLabel1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel1.Location = new System.Drawing.Point(491, 342); + this.materialLabel1.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel1.Name = "materialLabel1"; + this.materialLabel1.Size = new System.Drawing.Size(68, 19); + this.materialLabel1.TabIndex = 73; + this.materialLabel1.Text = "Subtitle 1"; + // + // materialLabel16 + // + this.materialLabel16.AutoSize = true; + this.materialLabel16.Depth = 0; + this.materialLabel16.Font = new System.Drawing.Font("Roboto Medium", 20F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel16.FontType = MaterialSkin.MaterialSkinManager.fontType.H6; + this.materialLabel16.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel16.Location = new System.Drawing.Point(491, 314); + this.materialLabel16.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel16.Name = "materialLabel16"; + this.materialLabel16.Size = new System.Drawing.Size(91, 24); + this.materialLabel16.TabIndex = 72; + this.materialLabel16.Text = "Heading 6"; + // + // materialLabel15 + // + this.materialLabel15.AutoSize = true; + this.materialLabel15.Depth = 0; + this.materialLabel15.Font = new System.Drawing.Font("Roboto", 24F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel15.FontType = MaterialSkin.MaterialSkinManager.fontType.H5; + this.materialLabel15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel15.Location = new System.Drawing.Point(490, 283); + this.materialLabel15.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel15.Name = "materialLabel15"; + this.materialLabel15.Size = new System.Drawing.Size(109, 29); + this.materialLabel15.TabIndex = 71; + this.materialLabel15.Text = "Heading 5"; + // + // materialLabel14 + // + this.materialLabel14.AutoSize = true; + this.materialLabel14.Depth = 0; + this.materialLabel14.Font = new System.Drawing.Font("Roboto", 34F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel14.FontType = MaterialSkin.MaterialSkinManager.fontType.H4; + this.materialLabel14.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel14.Location = new System.Drawing.Point(488, 242); + this.materialLabel14.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel14.Name = "materialLabel14"; + this.materialLabel14.Size = new System.Drawing.Size(154, 41); + this.materialLabel14.TabIndex = 70; + this.materialLabel14.Text = "Heading 4"; + // + // materialLabel13 + // + this.materialLabel13.AutoSize = true; + this.materialLabel13.Depth = 0; + this.materialLabel13.Font = new System.Drawing.Font("Roboto", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel13.FontType = MaterialSkin.MaterialSkinManager.fontType.H3; + this.materialLabel13.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel13.Location = new System.Drawing.Point(485, 185); + this.materialLabel13.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel13.Name = "materialLabel13"; + this.materialLabel13.Size = new System.Drawing.Size(217, 58); + this.materialLabel13.TabIndex = 69; + this.materialLabel13.Text = "Heading 3"; + // + // materialLabel12 + // + this.materialLabel12.AutoSize = true; + this.materialLabel12.Depth = 0; + this.materialLabel12.Font = new System.Drawing.Font("Roboto Light", 60F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel12.FontType = MaterialSkin.MaterialSkinManager.fontType.H2; + this.materialLabel12.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel12.Location = new System.Drawing.Point(482, 114); + this.materialLabel12.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel12.Name = "materialLabel12"; + this.materialLabel12.Size = new System.Drawing.Size(266, 72); + this.materialLabel12.TabIndex = 68; + this.materialLabel12.Text = "Heading 2"; + // + // materialLabel11 + // + this.materialLabel11.AutoSize = true; + this.materialLabel11.Depth = 0; + this.materialLabel11.Font = new System.Drawing.Font("Roboto Light", 96F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel11.FontType = MaterialSkin.MaterialSkinManager.fontType.H1; + this.materialLabel11.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(180)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.materialLabel11.Location = new System.Drawing.Point(475, 18); + this.materialLabel11.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel11.Name = "materialLabel11"; + this.materialLabel11.Size = new System.Drawing.Size(427, 115); + this.materialLabel11.TabIndex = 67; + this.materialLabel11.Text = "Heading 1"; + // + // materialLabel54 + // + this.materialLabel54.AutoSize = true; + this.materialLabel54.Depth = 0; + this.materialLabel54.Font = new System.Drawing.Font("Roboto", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); + this.materialLabel54.FontType = MaterialSkin.MaterialSkinManager.fontType.H3; + this.materialLabel54.Location = new System.Drawing.Point(28, 18); + this.materialLabel54.MouseState = MaterialSkin.MouseState.HOVER; + this.materialLabel54.Name = "materialLabel54"; + this.materialLabel54.Size = new System.Drawing.Size(117, 58); + this.materialLabel54.TabIndex = 63; + this.materialLabel54.Text = "Label"; + // // menuIconList // this.menuIconList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("menuIconList.ImageStream"))); @@ -2353,6 +3206,15 @@ private void InitializeComponent() this.menuIconList.Images.SetKeyName(6, "round_http_white_24dp.png"); this.menuIconList.Images.SetKeyName(7, "round_report_problem_white_24dp.png"); this.menuIconList.Images.SetKeyName(8, "round_swap_vert_white_24dp.png"); + this.menuIconList.Images.SetKeyName(9, "round_phone_black_24dp.png"); + this.menuIconList.Images.SetKeyName(10, "round_push_pin_black_24dp.png"); + this.menuIconList.Images.SetKeyName(11, "round_mail_outline_black_24dp.png"); + this.menuIconList.Images.SetKeyName(12, "round_person_black_24dp.png"); + this.menuIconList.Images.SetKeyName(13, "round_add_a_photo_black_24dp.png"); + this.menuIconList.Images.SetKeyName(14, "round_alternate_email_black_24dp.png"); + this.menuIconList.Images.SetKeyName(15, "round_cancel_black_24dp.png"); + this.menuIconList.Images.SetKeyName(16, "round_error_black_24dp.png"); + this.menuIconList.Images.SetKeyName(17, "round_event_black_24dp.png"); // // materialContextMenuStrip1 // @@ -2435,7 +3297,7 @@ private void InitializeComponent() this.DrawerTabControl = this.materialTabControl1; this.MinimumSize = new System.Drawing.Size(300, 200); this.Name = "MainForm"; - this.Padding = new System.Windows.Forms.Padding(3, 64, 3, 3); + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "MaterialSkin Demo"; this.materialTabControl1.ResumeLayout(false); this.tabPage1.ResumeLayout(false); @@ -2459,6 +3321,14 @@ private void InitializeComponent() this.tabPage8.PerformLayout(); this.tabPage9.ResumeLayout(false); this.tabPage9.PerformLayout(); + this.tabPage10.ResumeLayout(false); + this.tabPage10.PerformLayout(); + this.tabPage11.ResumeLayout(false); + this.flowLayoutPanel1.ResumeLayout(false); + this.materialExpansionPanel1.ResumeLayout(false); + this.materialExpansionPanel1.PerformLayout(); + this.tabPage12.ResumeLayout(false); + this.tabPage12.PerformLayout(); this.materialContextMenuStrip1.ResumeLayout(false); this.ResumeLayout(false); @@ -2530,23 +3400,10 @@ private void InitializeComponent() private MaterialRadioButton materialRadioButton4; private MaterialRadioButton materialRadioButton1; private MaterialRadioButton materialRadioButton2; - private MaterialLabel materialLabel22; - private MaterialLabel materialLabel21; - private MaterialLabel materialLabel20; - private MaterialLabel materialLabel19; - private MaterialLabel materialLabel18; - private MaterialLabel materialLabel17; - private MaterialLabel materialLabel1; - private MaterialLabel materialLabel16; - private MaterialLabel materialLabel15; - private MaterialLabel materialLabel14; - private MaterialLabel materialLabel13; - private MaterialLabel materialLabel12; - private MaterialLabel materialLabel11; private MaterialLabel materialLabel23; - private MaterialTextBox materialTextBox2; - private MaterialTextBox materialTextBox1; - private MaterialTextBox materialSingleLineTextField2; + private MaterialTextBox2 materialTextBox2; + private MaterialTextBox2 materialTextBox1; + private MaterialTextBox2 materialSingleLineTextField2; private MaterialLabel materialLabel24; private MaterialLabel materialLabel25; private MaterialLabel materialLabel26; @@ -2571,19 +3428,15 @@ private void InitializeComponent() private MaterialButton MaterialButton3; private MaterialLabel materialLabel6; private MaterialLabel materialLabel39; - private MaterialLabel materialLabel42; - private MaterialLabel materialLabel41; - private MaterialLabel materialLabel40; - private MaterialLabel materialLabel43; private MaterialButton materialButton23; - private MaterialTextBox materialTextBox3; + private MaterialTextBox2 materialTextBox3; private MaterialComboBox materialComboBox5; private MaterialComboBox materialComboBox4; private MaterialComboBox materialComboBox3; private MaterialComboBox materialComboBox2; private MaterialComboBox materialComboBox6; - private MaterialTextBox materialTextBox5; - private MaterialTextBox materialTextBox4; + private MaterialTextBox2 materialTextBox5; + private MaterialTextBox2 materialTextBox4; private MaterialSwitch materialSwitch8; private MaterialLabel materialLabel7; private MaterialLabel materialLabel45; @@ -2595,5 +3448,61 @@ private void InitializeComponent() private MaterialLabel materialLabel38; private MaterialDivider materialDivider3; private MaterialDivider materialDivider2; + private TabPage tabPage10; + private MaterialLabel materialLabel47; + private MaterialLabel materialLabel46; + private MaterialListBox materialListBox3; + private MaterialListBox materialListBox2; + private MaterialListBox materialListBox1; + private MaterialLabel materialLabel48; + private MaterialSlider materialSlider1; + private MaterialLabel materialLabel49; + private MaterialLabel materialLabel50; + private TabPage tabPage11; + private FlowLayoutPanel flowLayoutPanel1; + private MaterialExpansionPanel materialExpansionPanel1; + private MaterialExpansionPanel materialExpansionPanel2; + private MaterialLabel materialLabel51; + private MaterialSwitch materialSwitch9; + private MaterialListBox materialListBoxFormStyle; + private MaterialLabel materialLabel52; + private MaterialButton materialButton6; + private MaterialLabel materialLabel53; + private MaterialMultiLineTextBox2 materialMultiLineTextBox21; + private TabPage tabPage12; + private MaterialLabel materialLabel55; + private MaterialLabel materialLabel43; + private MaterialLabel materialLabel42; + private MaterialLabel materialLabel41; + private MaterialLabel materialLabel40; + private MaterialLabel materialLabel22; + private MaterialLabel materialLabel21; + private MaterialLabel materialLabel20; + private MaterialLabel materialLabel19; + private MaterialLabel materialLabel18; + private MaterialLabel materialLabel17; + private MaterialLabel materialLabel1; + private MaterialLabel materialLabel16; + private MaterialLabel materialLabel15; + private MaterialLabel materialLabel14; + private MaterialLabel materialLabel13; + private MaterialLabel materialLabel12; + private MaterialLabel materialLabel11; + private MaterialLabel materialLabel54; + private MaterialTextBox2 materialTextBox21; + private MaterialLabel materialLabel56; + private MaterialComboBox materialComboBox7; + private MaterialSwitch materialSwitch12; + private MaterialSwitch materialSwitch11; + private MaterialSwitch materialSwitch10; + private MaterialSwitch materialSwitch13; + private MaterialSwitch materialSwitch15; + private MaterialSwitch materialSwitch14; + private MaterialSwitch msReadOnly; + private MaterialMaskedTextBox materialMaskedTextBox1; + private MaterialButton materialButton25; + private MaterialLabel materialLabel57; + private MaterialSwitch materialSwitch16; + private MaterialLabel materialLabel58; } -} \ No newline at end of file +} diff --git a/MaterialSkinExample/MainForm.cs b/MaterialSkinExample/MainForm.cs index f47d18f6..f401528e 100644 --- a/MaterialSkinExample/MainForm.cs +++ b/MaterialSkinExample/MainForm.cs @@ -1,168 +1,294 @@ -using MaterialSkin; -using MaterialSkin.Controls; -using System; -using System.Text; -using System.Windows.Forms; - -namespace MaterialSkinExample -{ - public partial class MainForm : MaterialForm - { +using MaterialSkin; +using MaterialSkin.Controls; +using System; +using System.Text; +using System.Windows.Forms; + +namespace MaterialSkinExample +{ + public partial class MainForm : MaterialForm + { private readonly MaterialSkinManager materialSkinManager; - - public MainForm() - { - InitializeComponent(); - - // Initialize MaterialSkinManager - materialSkinManager = MaterialSkinManager.Instance; - - // Set this to false to disable backcolor enforcing on non-materialSkin components - // This HAS to be set before the AddFormToManage() - materialSkinManager.EnforceBackcolorOnAllComponents = true; - - // MaterialSkinManager properties - materialSkinManager.AddFormToManage(this); - materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT; - materialSkinManager.ColorScheme = new ColorScheme(Primary.Indigo500, Primary.Indigo700, Primary.Indigo100, Accent.Pink200, TextShade.WHITE); - - // Add dummy data to the listview - seedListView(); - materialCheckedListBox1.Items.Add("Item1", false); - materialCheckedListBox1.Items.Add("Item2", true); - materialCheckedListBox1.Items.Add("Item3", true); - materialCheckedListBox1.Items.Add("Item4", false); - materialCheckedListBox1.Items.Add("Item5", true); - materialCheckedListBox1.Items.Add("Item6", false); - materialCheckedListBox1.Items.Add("Item7", false); - - materialComboBox6.SelectedIndex = 0; - } - - private void seedListView() - { - //Define - var data = new[] - { - new []{"Lollipop", "392", "0.2", "0"}, - new []{"KitKat", "518", "26.0", "7"}, - new []{"Ice cream sandwich", "237", "9.0", "4.3"}, - new []{"Jelly Bean", "375", "0.0", "0.0"}, - new []{"Honeycomb", "408", "3.2", "6.5"} - }; - - //Add - foreach (string[] version in data) - { - var item = new ListViewItem(version); - materialListView1.Items.Add(item); - } - } - - private void materialButton1_Click(object sender, EventArgs e) - { - materialSkinManager.Theme = materialSkinManager.Theme == MaterialSkinManager.Themes.DARK ? MaterialSkinManager.Themes.LIGHT : MaterialSkinManager.Themes.DARK; - updateColor(); - } - + + public MainForm() + { + InitializeComponent(); + + // Initialize MaterialSkinManager + materialSkinManager = MaterialSkinManager.Instance; + + // Set this to false to disable backcolor enforcing on non-materialSkin components + // This HAS to be set before the AddFormToManage() + materialSkinManager.EnforceBackcolorOnAllComponents = true; + + // MaterialSkinManager properties + materialSkinManager.AddFormToManage(this); + materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT; + materialSkinManager.ColorScheme = new ColorScheme(Primary.Indigo500, Primary.Indigo700, Primary.Indigo100, Accent.Pink200, TextShade.WHITE); + + // Add dummy data to the listview + seedListView(); + materialCheckedListBox1.Items.Add("Item1", false); + materialCheckedListBox1.Items.Add("Item2", true); + materialCheckedListBox1.Items.Add("Item3", true); + materialCheckedListBox1.Items.Add("Item4", false); + materialCheckedListBox1.Items.Add("Item5", true); + materialCheckedListBox1.Items.Add("Item6", false); + materialCheckedListBox1.Items.Add("Item7", false); + + materialComboBox6.SelectedIndex = 0; + + materialListBoxFormStyle.Clear(); + foreach (var FormStyleItem in Enum.GetNames(typeof(MaterialForm.FormStyles))) + { + materialListBoxFormStyle.AddItem(FormStyleItem); + if (FormStyleItem == this.FormStyle.ToString()) materialListBoxFormStyle.SelectedIndex = materialListBoxFormStyle.Items.Count-1; + } + + materialListBoxFormStyle.SelectedIndexChanged += (sender, args) => + { + MaterialForm.FormStyles SelectedStyle = (MaterialForm.FormStyles)Enum.Parse(typeof(MaterialForm.FormStyles), args.Text); + if (this.FormStyle!= SelectedStyle) this.FormStyle = SelectedStyle; + }; + + materialMaskedTextBox1.ValidatingType = typeof(System.Int16); + + } + + private void seedListView() + { + //Define + var data = new[] + { + new []{"Lollipop", "392", "0.2", "0"}, + new []{"KitKat", "518", "26.0", "7"}, + new []{"Ice cream sandwich", "237", "9.0", "4.3"}, + new []{"Jelly Bean", "375", "0.0", "0.0"}, + new []{"Honeycomb", "408", "3.2", "6.5"} + }; + + //Add + foreach (string[] version in data) + { + var item = new ListViewItem(version); + materialListView1.Items.Add(item); + } + } + + private void materialButton1_Click(object sender, EventArgs e) + { + materialSkinManager.Theme = materialSkinManager.Theme == MaterialSkinManager.Themes.DARK ? MaterialSkinManager.Themes.LIGHT : MaterialSkinManager.Themes.DARK; + updateColor(); + } + private int colorSchemeIndex; - - private void MaterialButton1_Click(object sender, EventArgs e) - { - colorSchemeIndex++; - if (colorSchemeIndex > 2) - colorSchemeIndex = 0; - updateColor(); - } - - private void updateColor() - { - //These are just example color schemes - switch (colorSchemeIndex) - { - case 0: - materialSkinManager.ColorScheme = new ColorScheme( - materialSkinManager.Theme == MaterialSkinManager.Themes.DARK ? Primary.Teal500 : Primary.Indigo500, - materialSkinManager.Theme == MaterialSkinManager.Themes.DARK ? Primary.Teal700 : Primary.Indigo700, - materialSkinManager.Theme == MaterialSkinManager.Themes.DARK ? Primary.Teal200 : Primary.Indigo100, - Accent.Pink200, - TextShade.WHITE); - break; - - case 1: - materialSkinManager.ColorScheme = new ColorScheme( - Primary.Green600, + + private void MaterialButton1_Click(object sender, EventArgs e) + { + colorSchemeIndex++; + if (colorSchemeIndex > 2) + colorSchemeIndex = 0; + updateColor(); + } + + private void updateColor() + { + //These are just example color schemes + switch (colorSchemeIndex) + { + case 0: + materialSkinManager.ColorScheme = new ColorScheme( + materialSkinManager.Theme == MaterialSkinManager.Themes.DARK ? Primary.Teal500 : Primary.Indigo500, + materialSkinManager.Theme == MaterialSkinManager.Themes.DARK ? Primary.Teal700 : Primary.Indigo700, + materialSkinManager.Theme == MaterialSkinManager.Themes.DARK ? Primary.Teal200 : Primary.Indigo100, + Accent.Pink200, + TextShade.WHITE); + break; + + case 1: + materialSkinManager.ColorScheme = new ColorScheme( + Primary.Green600, Primary.Green700, Primary.Green200, Accent.Red100, - TextShade.WHITE); - break; - - case 2: - materialSkinManager.ColorScheme = new ColorScheme( + TextShade.WHITE); + break; + + case 2: + materialSkinManager.ColorScheme = new ColorScheme( Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, - TextShade.WHITE); - break; - } - Invalidate(); - } - - private void MaterialButton2_Click(object sender, EventArgs e) - { - materialProgressBar1.Value = Math.Min(materialProgressBar1.Value + 10, 100); - } - - private void materialFlatButton4_Click(object sender, EventArgs e) - { - materialProgressBar1.Value = Math.Max(materialProgressBar1.Value - 10, 0); - } - - private void materialSwitch4_CheckedChanged(object sender, EventArgs e) - { - DrawerUseColors = materialSwitch4.Checked; - } - - private void MaterialSwitch5_CheckedChanged(object sender, EventArgs e) - { - DrawerHighlightWithAccent = materialSwitch5.Checked; - } - - private void MaterialSwitch6_CheckedChanged(object sender, EventArgs e) - { - DrawerBackgroundWithAccent = materialSwitch6.Checked; - } - - private void materialSwitch8_CheckedChanged(object sender, EventArgs e) - { - DrawerShowIconsWhenHidden = materialSwitch8.Checked; - } - - private void MaterialButton3_Click(object sender, EventArgs e) - { - var builder = new StringBuilder("Batch operation report:\n\n"); - var random = new Random(); - var result = 0; - - for (int i = 0; i < 200; i++) - { - result = random.Next(1000); - - if (result < 950) - { - builder.AppendFormat(" - Task {0}: Operation completed sucessfully.\n", i); - } - else - { - builder.AppendFormat(" - Task {0}: Operation failed! A very very very very very very very very very very very very serious error has occured during this sub-operation. The errorcode is: {1}).\n", i, result); - } - } - - var batchOperationResults = builder.ToString(); - var mresult = MaterialMessageBox.Show(batchOperationResults, "Batch Operation"); - materialComboBox1.Items.Add("this is a very long string"); - } - } -} \ No newline at end of file + TextShade.WHITE); + break; + } + Invalidate(); + } + + private void MaterialButton2_Click(object sender, EventArgs e) + { + materialProgressBar1.Value = Math.Min(materialProgressBar1.Value + 10, 100); + } + + private void materialFlatButton4_Click(object sender, EventArgs e) + { + materialProgressBar1.Value = Math.Max(materialProgressBar1.Value - 10, 0); + } + + private void materialSwitch4_CheckedChanged(object sender, EventArgs e) + { + DrawerUseColors = materialSwitch4.Checked; + } + + private void MaterialSwitch5_CheckedChanged(object sender, EventArgs e) + { + DrawerHighlightWithAccent = materialSwitch5.Checked; + } + + private void MaterialSwitch6_CheckedChanged(object sender, EventArgs e) + { + DrawerBackgroundWithAccent = materialSwitch6.Checked; + } + + private void materialSwitch8_CheckedChanged(object sender, EventArgs e) + { + DrawerShowIconsWhenHidden = materialSwitch8.Checked; + } + + private void MaterialButton3_Click(object sender, EventArgs e) + { + var builder = new StringBuilder("Batch operation report:\n\n"); + var random = new Random(); + var result = 0; + + for (int i = 0; i < 200; i++) + { + result = random.Next(1000); + + if (result < 950) + { + builder.AppendFormat(" - Task {0}: Operation completed sucessfully.\n", i); + } + else + { + builder.AppendFormat(" - Task {0}: Operation failed! A very very very very very very very very very very very very serious error has occured during this sub-operation. The errorcode is: {1}).\n", i, result); + } + } + + var batchOperationResults = builder.ToString(); + batchOperationResults = "Simple text"; + var mresult = MaterialMessageBox.Show(batchOperationResults, "Batch Operation", MessageBoxButtons.YesNoCancel, FlexibleMaterialForm.ButtonsPosition.Center); + materialComboBox1.Items.Add("this is a very long string"); + } + + private void materialSwitch9_CheckedChanged(object sender, EventArgs e) + { + DrawerAutoShow = materialSwitch9.Checked; + } + + private void materialTextBox2_LeadingIconClick(object sender, EventArgs e) + { + MaterialSnackBar SnackBarMessage = new MaterialSnackBar("Leading Icon Click"); + SnackBarMessage.Show(this); + + } + + private void materialButton6_Click(object sender, EventArgs e) + { + MaterialSnackBar SnackBarMessage = new MaterialSnackBar("SnackBar started succesfully", "OK", true); + SnackBarMessage.Show(this); + } + + private void materialSwitch10_CheckedChanged(object sender, EventArgs e) + { + materialTextBox21.UseAccent = materialSwitch10.Checked; + } + + private void materialSwitch11_CheckedChanged(object sender, EventArgs e) + { + materialTextBox21.UseTallSize = materialSwitch11.Checked; + } + + private void materialSwitch12_CheckedChanged(object sender, EventArgs e) + { + if (materialSwitch12.Checked) + materialTextBox21.Hint = "Hint text"; + else + materialTextBox21.Hint = ""; + } + + private void materialComboBox7_SelectionChangeCommitted(object sender, EventArgs e) + { + if (materialComboBox7.SelectedIndex == 1) + { + materialTextBox21.PrefixSuffix = MaterialTextBox2.PrefixSuffixTypes.Prefix; + } + else if (materialComboBox7.SelectedIndex == 2) + { + materialTextBox21.PrefixSuffix = MaterialTextBox2.PrefixSuffixTypes.Suffix; + } + else + { + materialTextBox21.PrefixSuffix = MaterialTextBox2.PrefixSuffixTypes.None; + } + } + + private void materialSwitch13_CheckedChanged(object sender, EventArgs e) + { + materialTextBox21.UseSystemPasswordChar = materialSwitch13.Checked; + + } + + private void materialSwitch14_CheckedChanged(object sender, EventArgs e) + { + if (materialSwitch14.Checked) + materialTextBox21.LeadingIcon = global::MaterialSkinExample.Properties.Resources.baseline_fingerprint_black_24dp; + else + materialTextBox21.LeadingIcon = null; + } + + private void materialSwitch15_CheckedChanged(object sender, EventArgs e) + { + if (materialSwitch15.Checked) + materialTextBox21.TrailingIcon = global::MaterialSkinExample.Properties.Resources.baseline_build_black_24dp; + else + materialTextBox21.TrailingIcon = null; + } + + private void materialTextBox21_LeadingIconClick(object sender, EventArgs e) + { + MaterialSnackBar SnackBarMessage = new MaterialSnackBar("Leading Icon Click"); + SnackBarMessage.Show(this); + } + + private void materialTextBox21_TrailingIconClick(object sender, EventArgs e) + { + MaterialSnackBar SnackBarMessage = new MaterialSnackBar("Trailing Icon Click"); + SnackBarMessage.Show(this); + } + + private void MsReadOnly_CheckedChanged(object sender, EventArgs e) + { + materialCheckbox1.ReadOnly = msReadOnly.Checked; + } + + private void materialButton25_Click(object sender, EventArgs e) + { + MaterialDialog materialDialog = new MaterialDialog(this,"Dialog Title", "Dialogs inform users about a task and can contain critical information, require decisions, or involve multiple tasks.", "OK", true, "Cancel"); + DialogResult result = materialDialog.ShowDialog(this); + + MaterialSnackBar SnackBarMessage = new MaterialSnackBar(result.ToString(),750); + SnackBarMessage.Show(this); + + } + + private void materialSwitch16_CheckedChanged(object sender, EventArgs e) + { + materialTextBox21.ShowAssistiveText = materialSwitch16.Checked; + } + + + + } +} diff --git a/MaterialSkinExample/MainForm.resx b/MaterialSkinExample/MainForm.resx index b4beb2eb..e788af04 100644 --- a/MaterialSkinExample/MainForm.resx +++ b/MaterialSkinExample/MainForm.resx @@ -1,4 +1,4 @@ - + - \ No newline at end of file + diff --git a/MaterialSkinExample/Properties/Resources.Designer.cs b/MaterialSkinExample/Properties/Resources.Designer.cs index 35c199d0..eccbad9e 100644 --- a/MaterialSkinExample/Properties/Resources.Designer.cs +++ b/MaterialSkinExample/Properties/Resources.Designer.cs @@ -130,6 +130,16 @@ internal static System.Drawing.Bitmap plus { } } + /// + /// Recherche une ressource localisée de type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap round_add_black_24dp { + get { + object obj = ResourceManager.GetObject("round_add_black_24dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -200,6 +210,16 @@ internal static System.Drawing.Bitmap round_http_white_24dp { } } + /// + /// Recherche une ressource localisée de type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap round_phone_black_24dp { + get { + object obj = ResourceManager.GetObject("round_phone_black_24dp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/MaterialSkinExample/Properties/Resources.resx b/MaterialSkinExample/Properties/Resources.resx index fe7a503a..f49864df 100644 --- a/MaterialSkinExample/Properties/Resources.resx +++ b/MaterialSkinExample/Properties/Resources.resx @@ -166,4 +166,10 @@ ..\Resources\baseline_favorite_border_black_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - \ No newline at end of file + + ..\Resources\round_add_black_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\round_phone_black_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + diff --git a/MaterialSkinExample/Resources/round_add_black_24dp.png b/MaterialSkinExample/Resources/round_add_black_24dp.png new file mode 100644 index 00000000..a77cfcd9 Binary files /dev/null and b/MaterialSkinExample/Resources/round_add_black_24dp.png differ diff --git a/MaterialSkinExample/Resources/round_phone_black_24dp.png b/MaterialSkinExample/Resources/round_phone_black_24dp.png new file mode 100644 index 00000000..7abe7e62 Binary files /dev/null and b/MaterialSkinExample/Resources/round_phone_black_24dp.png differ diff --git a/MaterialSkinExample/obj/Debug/MaterialSkinExample.csprojAssemblyReference.cache b/MaterialSkinExample/obj/Debug/MaterialSkinExample.csprojAssemblyReference.cache deleted file mode 100644 index 32472c00..00000000 Binary files a/MaterialSkinExample/obj/Debug/MaterialSkinExample.csprojAssemblyReference.cache and /dev/null differ diff --git a/README.md b/README.md index 319452c4..416287aa 100644 --- a/README.md +++ b/README.md @@ -1,79 +1,82 @@ -# MaterialSkin for .NET WinForms +# MaterialSkin 2 for .NET WinForms with RTL support Theming .NET WinForms, C# or VB.Net, to Google's Material Design Principles. -This project is **temporarily paused** _(While I don't updated it very often, I still plan to in the future; that said, I still read every issue and check every PR)_ - -![home](https://user-images.githubusercontent.com/8310271/66237904-9dff9380-e6cc-11e9-9f08-3c5ba182e144.png) - -## [Join us on Slack!](https://join.slack.com/t/cmaterialskin/shared_invite/enQtNzk1NjM5NTEyNTE0LTI0ZDY0ODlkNGRmMGRmMTc4NTdjNmMwZjY2YTU5NTg4ODNiZmY5ZTUxNTE0YTZmOTlhMGFlYmZiNzQ3ZmViOWQ) -Have a quick question? want to discuss some improvement or question some code? [come here](https://join.slack.com/t/cmaterialskin/shared_invite/enQtNzk1NjM5NTEyNTE0LTI0ZDY0ODlkNGRmMGRmMTc4NTdjNmMwZjY2YTU5NTg4ODNiZmY5ZTUxNTE0YTZmOTlhMGFlYmZiNzQ3ZmViOWQ), let's talk about it +> This project is ACTIVE (With some long pauses in between, but I still read every issue and check every PR) +> +![home](https://raw.githubusercontent.com/baqeryan/MaterialSkin/master/MaterialSkinExample.RTL/Resources/MaterialSkinExample.RTL.gif) ## Nuget Package -A nuget package version is available [here](https://www.nuget.org/packages/MaterialSkin.2/) +A nuget package version is available [here](https://www.nuget.org/packages/MaterialSkin.2.RTL/) -Or simply search for MaterialSkin.2 on the **Nuget Package Manager** inside Visual Studio +Or simply search for MaterialSkin.2.RTL on the **Nuget Package Manager** inside Visual Studio ## WIKI Available! But there's not much in there for now, please contribute if you can. :smile: -You can access it [here](https://github.com/leocb/MaterialSkin/wiki) +You can access it [here](https://github.com/baqeryan/MaterialSkin/wiki) ## Current state of the MaterialSkin components -| Component | Supported | Disabled mode | Animated | -| ---------------------------- | :-------: | :-----------: | :------: | -| Buttons | Yes | Yes | Yes | -| Backdrop | **No** | - | - | -| Cards | Yes | N/A | N/A | -| Check Box | Yes | Yes | Yes | -| Check Box List | Yes | Yes | Yes | -| Combobox | Yes | Yes | Yes | -| Context Menu | Yes | Yes | Yes | -| Dialog | **No** | - | - | -| Divider | Yes | N/A | N/A | -| Drawer | Yes | N/A | Yes | -| Flexible Dialog (big) | Yes | Yes | N/A | -| FAB - Floating Action Button | Yes | **No** | Yes | -| Label | Yes | Yes | N/A | -| ListView | Yes | **No** | N/A | -| Progress Bar | _Partial_ | **No** | **No** | -| Radio Button | Yes | Yes | Yes | -| Text field | Yes | **No** | Yes | -| Sliders | **No** | - | - | -| Switch | Yes | Yes | Yes | -| Tabs | Yes | N/A | Yes | +| Component | Supported | Disabled mode | Animated | RTL supported | +| ---------------------------- | :-------: | :-----------: | :------: | :-----------: | +| Backdrop | **No** | - | - | - | +| Banner | **No** | - | - | - | +| Buttons | Yes | Yes | Yes | Yes | +| Cards | Yes | N/A | N/A | Yes | +| Check Box | Yes | Yes | Yes | Yes | +| Check Box List | Yes | Yes | Yes | Yes | +| Chips | **No** | - | - | - | +| Combobox | Yes | Yes | Yes | Yes | +| Context Menu | Yes | Yes | Yes | Yes | +| Date Picker | **No** | - | - | - | +| Dialog | Yes | N/A | **No** | Yes | +| Divider | Yes | N/A | N/A | N/A | +| Drawer | Yes | N/A | Yes | Yes | +| Expansion Panel | Yes | Yes | **No** | Yes | +| Flexible Dialog (big) | Yes | Yes | N/A | Yes | +| FAB - Floating Action Button | Yes | Yes | Yes | Yes | +| Label | Yes | Yes | N/A | Yes | +| ListBox | Yes | Yes | N/A | Yes | +| ListView | Yes | **No** | N/A | N/A | +| Progress Bar | _Partial_ | **No** | **No** | N/A | +| Radio Button | Yes | Yes | Yes | Yes | +| Text field | Yes | Yes | Yes | Yes | +| Sliders | Yes | Yes | **No** | N/A | +| SnackBar | Yes | N/A | Yes | Yes | +| Switch | Yes | Yes | Yes | Yes | +| Tabs | Yes | N/A | Yes | Yes | +| Time Picker | **No** | - | - | - | +| Tooltips | **No** | - | - | - | All supported components have a dark theme -## TODO List -- Progress bar - Animation and variants, maybe round loading thingy -- Sliders -- Dialog (!= message box) -- Backdrop (maybe) -- Better FAB -- Better Listview -- Disabled textfield -- Some Color code improvements and refactoring +## Contributing ---- - -## Contributting +Thanks for taking the time to contribute! :+1: If you have any issues please open an issue; have an improvement? open a pull request. ->This project was heavily updated by @leocb [leocb/MaterialSkin](https://github.com/leocb/MaterialSkin) -> ->forked from [donaldsteele/MaterialSkin](https://github.com/donaldsteele/MaterialSkin) -> ->and he forked it from the original [IgnaceMaes/MaterialSkin](https://github.com/IgnaceMaes/MaterialSkin) +> - This project was heavily updated by [@leocb](https://github.com/leocb/MaterialSkin) +> - Currently it's kept alive by [@orapps44](https://github.com/orapps44/MaterialSkin) +> - forked from [@donaldsteele](https://github.com/donaldsteele/MaterialSkin) +> - and he forked it from the original [@IgnaceMaes](https://github.com/IgnaceMaes/MaterialSkin) + +## Contributors + +Thank you to all the people who have already contributed to MaterialSkin 2 ! + + + + + --- -## Implementing MaterialSkin in your application +## Implementing MaterialSkin 2 in your application ### 1. Add the library to your project @@ -119,7 +122,7 @@ Set your preferred colors & theme. Also add the form to the manager so it keeps #### C# (Form1.cs) ```cs -public Form1() +public Form1(RightToLeft RightToLeft = RightToLeft.Yes) : base(RightToLeft) { InitializeComponent(); @@ -157,31 +160,40 @@ If you love .NET and Material Design, you should definitely check out [Material ## Images *A simple demo interface with MaterialSkin components.* -![home](https://user-images.githubusercontent.com/8310271/66237904-9dff9380-e6cc-11e9-9f08-3c5ba182e144.png) +![home](https://raw.githubusercontent.com/baqeryan/MaterialSkin/master/MaterialSkinExample.RTL/Resources/demo-1.png) *The MaterialSkin Drawer (menu).* -![drawer](https://user-images.githubusercontent.com/8310271/66237910-a0fa8400-e6cc-11e9-8f1d-0bc424f404c3.png) +![drawer](https://raw.githubusercontent.com/baqeryan/MaterialSkin/master/MaterialSkinExample.RTL/Resources/demo-2.png) *Every MaterialSkin button variant - this is 1 control, 3 properties* -![buttons](https://user-images.githubusercontent.com/8310271/66237911-a0fa8400-e6cc-11e9-8781-3e4c8cb0362b.png) +![buttons](https://raw.githubusercontent.com/baqeryan/MaterialSkin/master/MaterialSkinExample.RTL/Resources/demo-3.png) *The MaterialSkin checkboxes, radio and Switch.* -![selection](https://user-images.githubusercontent.com/8310271/66237912-a0fa8400-e6cc-11e9-9fb8-2cb247d2eff1.png) +![selection](https://raw.githubusercontent.com/baqeryan/MaterialSkin/master/MaterialSkinExample.RTL/Resources/demo-4.png) -*Material skin textfield and labels* -![text](https://user-images.githubusercontent.com/8310271/66237914-a0fa8400-e6cc-11e9-8afa-b9f6da2382fe.png) +*Material skin textfield* +![text](https://raw.githubusercontent.com/baqeryan/MaterialSkin/master/MaterialSkinExample.RTL/Resources/demo-5.png) *Table control* -![table](https://user-images.githubusercontent.com/8310271/66237915-a1931a80-e6cc-11e9-8e68-bc919f533366.png) +![table](https://raw.githubusercontent.com/baqeryan/MaterialSkin/master/MaterialSkinExample.RTL/Resources/demo-6.png) *Progress bar* -![progress bar](https://user-images.githubusercontent.com/8310271/66237916-a1931a80-e6cc-11e9-836b-157596b4ed33.png) +![progress bar](https://raw.githubusercontent.com/baqeryan/MaterialSkin/master/MaterialSkinExample.RTL/Resources/demo-7.png) *Cards* -![cards](https://user-images.githubusercontent.com/8310271/66237917-a1931a80-e6cc-11e9-9b32-47374554bc07.png) +![cards](https://raw.githubusercontent.com/baqeryan/MaterialSkin/master/MaterialSkinExample.RTL/Resources/demo-8.png) + +*List Box* +![listbox](https://raw.githubusercontent.com/baqeryan/MaterialSkin/master/MaterialSkinExample.RTL/Resources/demo-9.png) + +*Expansion Panel* +![expansion](https://raw.githubusercontent.com/baqeryan/MaterialSkin/master/MaterialSkinExample.RTL/Resources/demo-10.png) + +*Label* +![label](https://raw.githubusercontent.com/baqeryan/MaterialSkin/master/MaterialSkinExample.RTL/Resources/demo-11.png) *MaterialSkin using a custom color scheme.* -![custom](https://user-images.githubusercontent.com/8310271/66237918-a1931a80-e6cc-11e9-820e-8c811629d937.png) +![custom](https://user-images.githubusercontent.com/77468294/119881411-8e7e2f80-bf2d-11eb-9fa3-883eceabfadc.png) *FlexibleMaterial Messagebox* ![messagebox](https://user-images.githubusercontent.com/8310271/66238105-25e59d80-e6cd-11e9-88c9-5a21ceae1a5a.png)