├── nugetIcon.png ├── .github └── FUNDING.yml ├── MaterialSkin ├── Resources │ ├── Roboto-Black.ttf │ ├── Roboto-Bold.ttf │ ├── Roboto-Light.ttf │ ├── Roboto-Medium.ttf │ ├── Roboto-Thin.ttf │ └── Roboto-Regular.ttf ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── Controls │ ├── MaterialDivider.cs │ ├── MaterialTabControl.cs │ ├── MaterialProgressBar.cs │ ├── MaterialCheckedListBox.cs │ ├── MaterialMultiLineTextBox.cs │ ├── MaterialCard.cs │ ├── MaterialMessageBox.cs │ ├── MaterialMenuStrip.cs │ ├── MaterialForm.resx │ ├── FlexibleMaterialDialog.resx │ ├── MaterialLabel.cs │ ├── MaterialListView.cs │ ├── MaterialContextMenuStrip.cs │ ├── BaseTextBox.cs │ └── MaterialFloatingActionButton.cs ├── IMaterialControl.cs ├── Animations │ ├── AnimationDirection.cs │ └── Animations.cs ├── MouseWheelRedirector.cs ├── MaterialItemCollectionEditor.cs ├── MaterialItemCollection.cs ├── Extensions.cs ├── MaterialSkinCore.csproj ├── DrawHelper.cs ├── ColorHelper.cs └── MaterialSkin.csproj ├── MaterialSkinExample ├── Resources │ ├── minus.png │ ├── plus.png │ ├── round_add_black_24dp.png │ ├── round_http_white_24dp.png │ ├── round_backup_white_24dp.png │ ├── round_build_white_24dp.png │ ├── round_phone_black_24dp.png │ ├── baseline_build_black_24dp.png │ ├── round_bluetooth_white_24dp.png │ ├── round_bookmark_white_24dp.png │ ├── round_gps_fixed_white_24dp.png │ ├── round_swap_vert_white_24dp.png │ ├── baseline_thumb_up_black_24dp.png │ ├── round_assessment_white_24dp.png │ ├── baseline_bluetooth_black_24dp.png │ ├── baseline_fingerprint_black_24dp.png │ ├── round_report_problem_white_24dp.png │ └── baseline_favorite_border_black_24dp.png ├── Icons │ ├── ic_settings_black_24dp_1x.png │ └── ic_settings_white_24dp_1x.png ├── App.config ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── Program.cs ├── MaterialSkinExample.csproj └── MainForm.cs ├── LICENSE ├── .nuspec ├── MaterialSkin.sln ├── .gitattributes ├── .gitignore └── README.md /nugetIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/nugetIcon.png -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [leocb] 4 | -------------------------------------------------------------------------------- /MaterialSkin/Resources/Roboto-Black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkin/Resources/Roboto-Black.ttf -------------------------------------------------------------------------------- /MaterialSkin/Resources/Roboto-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkin/Resources/Roboto-Bold.ttf -------------------------------------------------------------------------------- /MaterialSkin/Resources/Roboto-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkin/Resources/Roboto-Light.ttf -------------------------------------------------------------------------------- /MaterialSkin/Resources/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkin/Resources/Roboto-Medium.ttf -------------------------------------------------------------------------------- /MaterialSkin/Resources/Roboto-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkin/Resources/Roboto-Thin.ttf -------------------------------------------------------------------------------- /MaterialSkinExample/Resources/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Resources/minus.png -------------------------------------------------------------------------------- /MaterialSkinExample/Resources/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Resources/plus.png -------------------------------------------------------------------------------- /MaterialSkin/Resources/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkin/Resources/Roboto-Regular.ttf -------------------------------------------------------------------------------- /MaterialSkinExample/Icons/ic_settings_black_24dp_1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Icons/ic_settings_black_24dp_1x.png -------------------------------------------------------------------------------- /MaterialSkinExample/Icons/ic_settings_white_24dp_1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Icons/ic_settings_white_24dp_1x.png -------------------------------------------------------------------------------- /MaterialSkinExample/Resources/round_add_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Resources/round_add_black_24dp.png -------------------------------------------------------------------------------- /MaterialSkinExample/Resources/round_http_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Resources/round_http_white_24dp.png -------------------------------------------------------------------------------- /MaterialSkinExample/Resources/round_backup_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Resources/round_backup_white_24dp.png -------------------------------------------------------------------------------- /MaterialSkinExample/Resources/round_build_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Resources/round_build_white_24dp.png -------------------------------------------------------------------------------- /MaterialSkinExample/Resources/round_phone_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Resources/round_phone_black_24dp.png -------------------------------------------------------------------------------- /MaterialSkinExample/Resources/baseline_build_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Resources/baseline_build_black_24dp.png -------------------------------------------------------------------------------- /MaterialSkinExample/Resources/round_bluetooth_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Resources/round_bluetooth_white_24dp.png -------------------------------------------------------------------------------- /MaterialSkinExample/Resources/round_bookmark_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Resources/round_bookmark_white_24dp.png -------------------------------------------------------------------------------- /MaterialSkinExample/Resources/round_gps_fixed_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Resources/round_gps_fixed_white_24dp.png -------------------------------------------------------------------------------- /MaterialSkinExample/Resources/round_swap_vert_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Resources/round_swap_vert_white_24dp.png -------------------------------------------------------------------------------- /MaterialSkinExample/Resources/baseline_thumb_up_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Resources/baseline_thumb_up_black_24dp.png -------------------------------------------------------------------------------- /MaterialSkinExample/Resources/round_assessment_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Resources/round_assessment_white_24dp.png -------------------------------------------------------------------------------- /MaterialSkinExample/Resources/baseline_bluetooth_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Resources/baseline_bluetooth_black_24dp.png -------------------------------------------------------------------------------- /MaterialSkinExample/Resources/baseline_fingerprint_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Resources/baseline_fingerprint_black_24dp.png -------------------------------------------------------------------------------- /MaterialSkinExample/Resources/round_report_problem_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Resources/round_report_problem_white_24dp.png -------------------------------------------------------------------------------- /MaterialSkinExample/Resources/baseline_favorite_border_black_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/MaterialSkin/master/MaterialSkinExample/Resources/baseline_favorite_border_black_24dp.png -------------------------------------------------------------------------------- /MaterialSkinExample/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /MaterialSkin/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MaterialSkinExample/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MaterialSkinExample/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace MaterialSkinExample 5 | { 6 | internal static class Program 7 | { 8 | [STAThread] 9 | private static void Main() 10 | { 11 | Application.EnableVisualStyles(); 12 | Application.SetCompatibleTextRenderingDefault(true); 13 | Application.Run(new MainForm()); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /MaterialSkin/Controls/MaterialDivider.cs: -------------------------------------------------------------------------------- 1 | namespace MaterialSkin.Controls 2 | { 3 | using System.ComponentModel; 4 | using System.Windows.Forms; 5 | 6 | public sealed class MaterialDivider : Control, IMaterialControl 7 | { 8 | [Browsable(false)] 9 | public int Depth { get; set; } 10 | 11 | [Browsable(false)] 12 | public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; 13 | 14 | [Browsable(false)] 15 | public MouseState MouseState { get; set; } 16 | 17 | public MaterialDivider() 18 | { 19 | SetStyle(ControlStyles.SupportsTransparentBackColor, true); 20 | Height = 1; 21 | BackColor = SkinManager.DividersColor; 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /MaterialSkin/Controls/MaterialTabControl.cs: -------------------------------------------------------------------------------- 1 | namespace MaterialSkin.Controls 2 | { 3 | using System; 4 | using System.ComponentModel; 5 | using System.Windows.Forms; 6 | 7 | public class MaterialTabControl : TabControl, IMaterialControl 8 | { 9 | public MaterialTabControl() 10 | { 11 | Multiline = true; 12 | } 13 | 14 | [Browsable(false)] 15 | public int Depth { get; set; } 16 | 17 | [Browsable(false)] 18 | public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; 19 | 20 | [Browsable(false)] 21 | public MouseState MouseState { get; set; } 22 | 23 | protected override void WndProc(ref Message m) 24 | { 25 | if (m.Msg == 0x1328 && !DesignMode) m.Result = (IntPtr)1; 26 | else base.WndProc(ref m); 27 | } 28 | 29 | protected override void OnControlAdded(ControlEventArgs e) 30 | { 31 | base.OnControlAdded(e); 32 | 33 | e.Control.BackColor = System.Drawing.Color.White; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /MaterialSkin/IMaterialControl.cs: -------------------------------------------------------------------------------- 1 | namespace MaterialSkin 2 | { 3 | /// 4 | /// Defines the 5 | /// 6 | public interface IMaterialControl 7 | { 8 | /// 9 | /// Gets or sets the Depth 10 | /// 11 | int Depth { get; set; } 12 | 13 | /// 14 | /// Gets the SkinManager 15 | /// 16 | MaterialSkinManager SkinManager { get; } 17 | 18 | /// 19 | /// Gets or sets the MouseState 20 | /// 21 | MouseState MouseState { get; set; } 22 | } 23 | 24 | /// 25 | /// Defines the MouseState 26 | /// 27 | public enum MouseState 28 | { 29 | /// 30 | /// Defines the HOVER 31 | /// 32 | HOVER, 33 | 34 | /// 35 | /// Defines the DOWN 36 | /// 37 | DOWN, 38 | 39 | /// 40 | /// Defines the OUT 41 | /// 42 | OUT 43 | } 44 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Ignace Maes 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MaterialSkin/Animations/AnimationDirection.cs: -------------------------------------------------------------------------------- 1 | namespace MaterialSkin.Animations 2 | { 3 | /// 4 | /// Defines the AnimationDirection 5 | /// 6 | internal enum AnimationDirection 7 | { 8 | /// 9 | /// Defines the In 10 | /// 11 | In, //In. Stops if finished. 12 | 13 | /// 14 | /// Defines the Out 15 | /// 16 | Out, //Out. Stops if finished. 17 | 18 | /// 19 | /// Defines the InOutIn 20 | /// 21 | InOutIn, //Same as In, but changes to InOutOut if finished. 22 | 23 | /// 24 | /// Defines the InOutOut 25 | /// 26 | InOutOut, //Same as Out. 27 | 28 | /// 29 | /// Defines the InOutRepeatingIn 30 | /// 31 | InOutRepeatingIn, // Same as In, but changes to InOutRepeatingOut if finished. 32 | 33 | /// 34 | /// Defines the InOutRepeatingOut 35 | /// 36 | InOutRepeatingOut// Same as Out, but changes to InOutRepeatingIn if finished. 37 | } 38 | } -------------------------------------------------------------------------------- /MaterialSkin/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace MaterialSkin.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.2.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /MaterialSkinExample/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace MaterialSkinExample.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.2.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | MaterialSkin.2 5 | 2.3.1 6 | MaterialSkin 2 7 | leocb, IgnaceMaes, orapps44 8 | leocb 9 | MIT 10 | https://github.com/leocb/MaterialSkin 11 | images\nugetIcon.png 12 | false 13 | Google's Material Design for your windows forms. 14 | see github page for release notes 15 | Copyright Leonardo C Bottaro © 2021 16 | material design materialdesign google forms theme skin 17 | 18 | 19 | 20 | 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. 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /MaterialSkinExample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("MaterialSkinExample")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("MaterialSkinExample")] 12 | [assembly: AssemblyCopyright("Copyright © 2014")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("b3fe1c46-7ac9-4dc9-bfe7-f66f3136e410")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /MaterialSkin/Controls/MaterialProgressBar.cs: -------------------------------------------------------------------------------- 1 | namespace MaterialSkin.Controls 2 | { 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Windows.Forms; 6 | 7 | public class MaterialProgressBar : ProgressBar, IMaterialControl 8 | { 9 | public MaterialProgressBar() 10 | { 11 | SetStyle(ControlStyles.UserPaint, true); 12 | SetStyle(ControlStyles.OptimizedDoubleBuffer, true); 13 | } 14 | 15 | [Browsable(false)] 16 | public int Depth { get; set; } 17 | 18 | [Browsable(false)] 19 | public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; 20 | 21 | [Browsable(false)] 22 | public MouseState MouseState { get; set; } 23 | 24 | protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) 25 | { 26 | base.SetBoundsCore(x, y, width, 5, specified); 27 | } 28 | 29 | protected override void OnPaint(PaintEventArgs e) 30 | { 31 | var doneProgress = (int)(Width * ((double)Value / Maximum)); 32 | e.Graphics.FillRectangle(Enabled ? 33 | SkinManager.ColorScheme.PrimaryBrush : 34 | new SolidBrush(DrawHelper.BlendColor(SkinManager.ColorScheme.PrimaryColor, SkinManager.SwitchOffDisabledThumbColor, 197)), 35 | 0, 0, doneProgress, Height); 36 | e.Graphics.FillRectangle(SkinManager.BackgroundFocusBrush, doneProgress, 0, Width - doneProgress, Height); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /MaterialSkin/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("MaterialSkin")] 9 | [assembly: AssemblyDescription("Google's Material Design on your windows forms")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("MaterialSkin")] 13 | [assembly: AssemblyCopyright("Copyright Leonardo C Bottaro © 2021")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("52781de3-a323-49ee-9a4f-c67280f8d328")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("2.3.1.0")] 36 | [assembly: AssemblyFileVersion("2.3.1.0")] 37 | [assembly: NeutralResourcesLanguage("en-US")] 38 | -------------------------------------------------------------------------------- /MaterialSkin.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.136 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MaterialSkinExample", "MaterialSkinExample\MaterialSkinExample.csproj", "{47409AA5-62AE-4189-8E83-C471502DF5E9}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MaterialSkin", "MaterialSkin\MaterialSkin.csproj", "{8EB7611B-68CD-4B8B-987A-11717E2B250C}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{17028688-3699-4BC7-849F-A6B0F6E766BC}" 11 | ProjectSection(SolutionItems) = preProject 12 | README.md = README.md 13 | EndProjectSection 14 | EndProject 15 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MaterialSkinCore", "MaterialSkin\MaterialSkinCore.csproj", "{031DCCA6-79CD-41F0-AA5A-09FDE1C1D308}" 16 | EndProject 17 | Global 18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 19 | Debug|Any CPU = Debug|Any CPU 20 | Release|Any CPU = Release|Any CPU 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {47409AA5-62AE-4189-8E83-C471502DF5E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {47409AA5-62AE-4189-8E83-C471502DF5E9}.Debug|Any CPU.Build.0 = Debug|Any CPU 25 | {47409AA5-62AE-4189-8E83-C471502DF5E9}.Release|Any CPU.ActiveCfg = Release|Any CPU 26 | {47409AA5-62AE-4189-8E83-C471502DF5E9}.Release|Any CPU.Build.0 = Release|Any CPU 27 | {8EB7611B-68CD-4B8B-987A-11717E2B250C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {8EB7611B-68CD-4B8B-987A-11717E2B250C}.Debug|Any CPU.Build.0 = Debug|Any CPU 29 | {8EB7611B-68CD-4B8B-987A-11717E2B250C}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {8EB7611B-68CD-4B8B-987A-11717E2B250C}.Release|Any CPU.Build.0 = Release|Any CPU 31 | {031DCCA6-79CD-41F0-AA5A-09FDE1C1D308}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {031DCCA6-79CD-41F0-AA5A-09FDE1C1D308}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {031DCCA6-79CD-41F0-AA5A-09FDE1C1D308}.Release|Any CPU.ActiveCfg = Release|Any CPU 34 | {031DCCA6-79CD-41F0-AA5A-09FDE1C1D308}.Release|Any CPU.Build.0 = Release|Any CPU 35 | EndGlobalSection 36 | GlobalSection(SolutionProperties) = preSolution 37 | HideSolutionNode = FALSE 38 | EndGlobalSection 39 | GlobalSection(ExtensibilityGlobals) = postSolution 40 | SolutionGuid = {0DF2ED56-BB31-432A-BE76-7C00E7541216} 41 | EndGlobalSection 42 | EndGlobal 43 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /MaterialSkin/Controls/MaterialCheckedListBox.cs: -------------------------------------------------------------------------------- 1 | namespace MaterialSkin.Controls 2 | { 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Drawing; 6 | using System.Windows.Forms; 7 | 8 | public class MaterialCheckedListBox : Panel, IMaterialControl 9 | { 10 | [Browsable(false)] 11 | public int Depth { get; set; } 12 | 13 | [Browsable(false)] 14 | public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; 15 | 16 | [Browsable(false)] 17 | public MouseState MouseState { get; set; } 18 | 19 | public bool Striped { get; set; } 20 | 21 | public Color StripeDarkColor { get; set; } 22 | 23 | public ItemsList Items { get; set; } 24 | 25 | public MaterialCheckedListBox() : base() 26 | { 27 | this.DoubleBuffered = true; 28 | this.Items = new ItemsList(this); 29 | this.AutoScroll = true; 30 | } 31 | 32 | protected override void OnCreateControl() 33 | { 34 | base.OnCreateControl(); 35 | if (DesignMode) 36 | { 37 | BackColorChanged += (sender, args) => BackColor = Parent.BackColor; 38 | BackColor = Parent.BackColor; 39 | } 40 | else 41 | { 42 | BackColorChanged += (sender, args) => BackColor = DrawHelper.BlendColor(Parent.BackColor, SkinManager.BackgroundAlternativeColor, SkinManager.BackgroundAlternativeColor.A); 43 | BackColor = DrawHelper.BlendColor(Parent.BackColor, SkinManager.BackgroundAlternativeColor, SkinManager.BackgroundAlternativeColor.A); 44 | } 45 | } 46 | 47 | public CheckState GetItemCheckState(int Index) 48 | { 49 | return Items[Index].CheckState; 50 | } 51 | 52 | public class ItemsList : List 53 | { 54 | private Panel _parent; 55 | 56 | public ItemsList(Panel parent) 57 | { 58 | _parent = parent; 59 | } 60 | 61 | public delegate void SelectedIndexChangedEventHandler(int Index); 62 | 63 | public void Add(string text) 64 | { 65 | Add(text, false); 66 | } 67 | 68 | public void Add(string text, bool defaultValue) 69 | { 70 | MaterialSkin.Controls.MaterialCheckbox cb = new MaterialSkin.Controls.MaterialCheckbox(); 71 | Add(cb); 72 | cb.Checked = defaultValue; 73 | cb.Text = text; 74 | } 75 | 76 | public new void Add(MaterialSkin.Controls.MaterialCheckbox value) 77 | { 78 | base.Add(value); 79 | _parent.Controls.Add(value); 80 | value.Dock = DockStyle.Top; 81 | } 82 | 83 | public new void Remove(MaterialSkin.Controls.MaterialCheckbox value) 84 | { 85 | base.Remove(value); 86 | _parent.Controls.Remove(value); 87 | } 88 | } 89 | } 90 | } -------------------------------------------------------------------------------- /MaterialSkin/MouseWheelRedirector.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Globalization; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Reflection; 8 | using System.Runtime.CompilerServices; 9 | using System.Security; 10 | using System.Text; 11 | using System.Threading.Tasks; 12 | using Microsoft.VisualBasic; 13 | using System.Windows.Forms; 14 | using System.Runtime.InteropServices; 15 | 16 | public class MouseWheelRedirector : IMessageFilter 17 | { 18 | private static MouseWheelRedirector instance = null; 19 | private static bool _active = false; 20 | 21 | public static bool Active 22 | { 23 | set 24 | { 25 | if (_active != value) 26 | { 27 | _active = value; 28 | if (_active) 29 | { 30 | if (instance == null) 31 | instance = new MouseWheelRedirector(); 32 | Application.AddMessageFilter(instance); 33 | } 34 | else if (instance != null) 35 | Application.RemoveMessageFilter(instance); 36 | } 37 | } 38 | get 39 | { 40 | return _active; 41 | } 42 | } 43 | 44 | public static void Attach(Control control) 45 | { 46 | if (!_active) 47 | Active = true; 48 | control.MouseEnter += instance.ControlMouseEnter; 49 | control.MouseLeave += instance.ControlMouseLeaveOrDisposed; 50 | control.Disposed += instance.ControlMouseLeaveOrDisposed; 51 | } 52 | 53 | public static void Detach(Control control) 54 | { 55 | if (instance == null) 56 | return; 57 | control.MouseEnter -= instance.ControlMouseEnter; 58 | control.MouseLeave -= instance.ControlMouseLeaveOrDisposed; 59 | control.Disposed -= instance.ControlMouseLeaveOrDisposed; 60 | if (instance.currentControl == control) 61 | instance.currentControl = null; 62 | } 63 | 64 | public MouseWheelRedirector() 65 | { 66 | } 67 | 68 | private Control currentControl; 69 | 70 | private void ControlMouseEnter(object sender, System.EventArgs e) 71 | { 72 | var control = (Control)sender; 73 | if (!control.Focused) 74 | currentControl = control; 75 | else 76 | currentControl = null; 77 | } 78 | 79 | private void ControlMouseLeaveOrDisposed(object sender, System.EventArgs e) 80 | { 81 | if (currentControl == sender) 82 | currentControl = null; 83 | } 84 | 85 | private const int WM_MOUSEWHEEL = 0x20A; 86 | public bool PreFilterMessage(ref System.Windows.Forms.Message m) 87 | { 88 | if (currentControl != null && m.Msg == WM_MOUSEWHEEL) 89 | { 90 | SendMessage(currentControl.Handle, m.Msg, m.WParam, m.LParam); 91 | return true; 92 | } 93 | else 94 | return false; 95 | } 96 | 97 | [DllImport("user32.dll", SetLastError = false)] 98 | private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); 99 | } 100 | -------------------------------------------------------------------------------- /MaterialSkin/MaterialItemCollectionEditor.cs: -------------------------------------------------------------------------------- 1 | #region Imports 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | using System.Drawing; 7 | using System.Drawing.Design; 8 | using System.ComponentModel; 9 | using System.ComponentModel.Design; 10 | using MaterialSkin; 11 | //using MaterialSkin.Controls; 12 | 13 | using System.Drawing.Text; 14 | using System.Windows.Forms; 15 | using System.Collections; 16 | using System.Collections.ObjectModel; 17 | using System.Runtime.InteropServices; 18 | 19 | 20 | #endregion 21 | 22 | namespace System.Windows.Forms 23 | { 24 | public class MaterialItemCollectionEditor : CollectionEditor 25 | { 26 | public MaterialItemCollectionEditor() : base(typeof(MaterialItemCollection)) 27 | { 28 | 29 | } 30 | 31 | protected override Type CreateCollectionItemType() 32 | { 33 | return typeof(MaterialListBoxItem); 34 | } 35 | 36 | protected override Type[] CreateNewItemTypes() 37 | { 38 | return new Type[] { 39 | typeof(MaterialListBoxItem) 40 | }; 41 | } 42 | } 43 | 44 | //public class MaterialItemCollectionEditor : CollectionEditor 45 | //{ 46 | // // Define a static event to expose the inner PropertyGrid's 47 | // // PropertyValueChanged event args... 48 | // public delegate void MyPropertyValueChangedEventHandler(object sender, 49 | // PropertyValueChangedEventArgs e); 50 | // public static event MyPropertyValueChangedEventHandler MyPropertyValueChanged; 51 | 52 | // // Inherit the default constructor from the standard 53 | // // Collection Editor... 54 | // public MyCollectionEditor(Type type) : base(type) { } 55 | 56 | // // Override this method in order to access the containing user controls 57 | // // from the default Collection Editor form or to add new ones... 58 | // protected override CollectionForm CreateCollectionForm() 59 | // { 60 | // // Getting the default layout of the Collection Editor... 61 | // CollectionForm collectionForm = base.CreateCollectionForm(); 62 | // Form frmCollectionEditorForm = collectionForm as Form; 63 | // TableLayoutPanel tlpLayout = frmCollectionEditorForm.Controls[0] as TableLayoutPanel; 64 | 65 | // if (tlpLayout != null) 66 | // { 67 | // // Get a reference to the inner PropertyGrid and hook 68 | // // an event handler to it. 69 | // if (tlpLayout.Controls[5] is PropertyGrid) 70 | // { 71 | // PropertyGrid propertyGrid = tlpLayout.Controls[5] as PropertyGrid; 72 | // propertyGrid.PropertyValueChanged += new PropertyValueChangedEventHandler(propertyGrid_PropertyValueChanged); 73 | // } 74 | // } 75 | // return collectionForm; 76 | // } 77 | 78 | // void propertyGrid_PropertyValueChanged(object sender, PropertyValueChangedEventArgs e) 79 | // { 80 | // // Fire our customized collection event... 81 | // if (MyCollectionEditor.MyPropertyValueChanged != null) 82 | // { 83 | // MyCollectionEditor.MyPropertyValueChanged(this, e); 84 | // } 85 | // } 86 | //} 87 | } 88 | -------------------------------------------------------------------------------- /MaterialSkin/MaterialItemCollection.cs: -------------------------------------------------------------------------------- 1 | #region Imports 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Collections.ObjectModel; 6 | using System.ComponentModel; 7 | using System.Drawing.Design; 8 | using System.Windows.Forms; 9 | 10 | #endregion 11 | 12 | namespace MaterialSkin 13 | { 14 | #region MaterialItemCollectionChild 15 | 16 | [Editor(typeof(MaterialItemCollectionEditor), typeof(UITypeEditor))] 17 | public class MaterialItemCollection : Collection 18 | { 19 | public event EventHandler ItemUpdated; 20 | 21 | public delegate void EventHandler(object sender, EventArgs e); 22 | 23 | public void AddRange(IEnumerable items) 24 | { 25 | foreach (object item in items) 26 | { 27 | Add(item); 28 | } 29 | } 30 | 31 | public void AddRange(string[] items) 32 | { 33 | foreach (object item in items) 34 | { 35 | Add(item); 36 | } 37 | } 38 | 39 | protected new void Add(object item) 40 | { 41 | base.Add(item); 42 | ItemUpdated?.Invoke(this, null); 43 | } 44 | 45 | protected override void InsertItem(int index, object item) 46 | { 47 | base.InsertItem(index, item); 48 | ItemUpdated?.Invoke(this, null); 49 | } 50 | 51 | protected override void RemoveItem(int value) 52 | { 53 | base.RemoveItem(value); 54 | ItemUpdated?.Invoke(this, null); 55 | } 56 | 57 | protected new void Clear() 58 | { 59 | base.Clear(); 60 | ItemUpdated?.Invoke(this, null); 61 | } 62 | 63 | protected override void ClearItems() 64 | { 65 | base.ClearItems(); 66 | ItemUpdated?.Invoke(this, null); 67 | } 68 | } 69 | 70 | #endregion 71 | 72 | #region MaterialListBoxItemChild 73 | 74 | public class MaterialListBoxItem 75 | { 76 | #region Property Region 77 | 78 | public string Text { get; set; } 79 | public string SecondaryText { get; set; } 80 | public object Tag { get; set; } 81 | 82 | //public Bitmap Icon { get; set; } 83 | 84 | #endregion 85 | 86 | #region Constructor Region 87 | 88 | public MaterialListBoxItem() 89 | { 90 | Text = "ListBoxItem"; 91 | SecondaryText = ""; 92 | } 93 | 94 | public MaterialListBoxItem(string text) 95 | { 96 | Text = text; 97 | } 98 | 99 | public MaterialListBoxItem(string text, string secondarytext) 100 | { 101 | Text = text; 102 | SecondaryText = secondarytext; 103 | } 104 | 105 | public MaterialListBoxItem(string text, string secondarytext, object tag) 106 | { 107 | Text = text; 108 | SecondaryText = secondarytext; 109 | Tag = tag; 110 | } 111 | 112 | //public MaterialListBoxItem(string text, Bitmap icon) : this(text) 113 | //{ 114 | // Icon = icon; 115 | //} 116 | 117 | #endregion 118 | } 119 | 120 | #endregion 121 | 122 | } 123 | -------------------------------------------------------------------------------- /MaterialSkin/Extensions.cs: -------------------------------------------------------------------------------- 1 | namespace MaterialSkin 2 | { 3 | using System; 4 | using System.Drawing; 5 | using System.Reflection; 6 | 7 | /// 8 | /// Defines the 9 | /// These add functions on default C# types and classes 10 | /// 11 | internal static class Extensions 12 | { 13 | /// 14 | /// The HasProperty 15 | /// 16 | /// The objectToCheck 17 | /// The propertyName 18 | /// The 19 | public static bool HasProperty(this object objectToCheck, string propertyName) 20 | { 21 | try 22 | { 23 | var type = objectToCheck.GetType(); 24 | 25 | return type.GetProperty(propertyName) != null; 26 | } 27 | catch (AmbiguousMatchException) 28 | { 29 | // ambiguous means there is more than one result, 30 | // which means: a method with that name does exist 31 | return true; 32 | } 33 | } 34 | 35 | /// 36 | /// The IsMaterialControl 37 | /// 38 | /// The obj 39 | /// The 40 | public static bool IsMaterialControl(this Object obj) 41 | { 42 | if (obj is IMaterialControl) 43 | { 44 | return true; 45 | } 46 | else 47 | { 48 | return false; 49 | } 50 | } 51 | 52 | /// 53 | /// Transforms every char on a string to this dot: ● 54 | /// 55 | /// 56 | /// 57 | public static string ToSecureString(this string plainString) 58 | { 59 | if (plainString == null) 60 | return null; 61 | 62 | string secureString = ""; 63 | for (uint i = 0; i < plainString.Length; i++) 64 | { 65 | secureString += '\u25CF'; 66 | } 67 | return secureString; 68 | } 69 | 70 | // Color extensions 71 | public static Color ToColor(this int argb) 72 | { 73 | return Color.FromArgb( 74 | (argb & 0xFF0000) >> 16, 75 | (argb & 0x00FF00) >> 8, 76 | argb & 0x0000FF); 77 | } 78 | 79 | public static Color RemoveAlpha(this Color color) 80 | { 81 | return Color.FromArgb(color.R, color.G, color.B); 82 | } 83 | 84 | public static int PercentageToColorComponent(this int percentage) 85 | { 86 | return (int)((percentage / 100d) * 255d); 87 | } 88 | 89 | // Simulate Clamp function from .NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8 90 | // https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/Math.cs,538 91 | internal static int Clamp(this int value, int min, int max) 92 | { 93 | if (min > max) 94 | { 95 | throw new ArgumentException(string.Format("'{0}' cannot be greater than {1}.", min, max)); 96 | } 97 | 98 | if (value < min) 99 | { 100 | return min; 101 | } 102 | else if (value > max) 103 | { 104 | return max; 105 | } 106 | 107 | return value; 108 | } 109 | } 110 | } -------------------------------------------------------------------------------- /MaterialSkin/Animations/Animations.cs: -------------------------------------------------------------------------------- 1 | namespace MaterialSkin.Animations 2 | { 3 | using System; 4 | 5 | /// 6 | /// Defines the AnimationType 7 | /// 8 | internal enum AnimationType 9 | { 10 | /// 11 | /// Defines the Linear 12 | /// 13 | Linear, 14 | 15 | /// 16 | /// Defines the EaseInOut 17 | /// 18 | EaseInOut, 19 | 20 | /// 21 | /// Defines the EaseOut 22 | /// 23 | EaseOut, 24 | 25 | /// 26 | /// Defines the CustomQuadratic 27 | /// 28 | CustomQuadratic 29 | } 30 | 31 | /// 32 | /// Defines the 33 | /// 34 | internal static class AnimationLinear 35 | { 36 | /// 37 | /// The CalculateProgress 38 | /// 39 | /// The progress 40 | /// The 41 | public static double CalculateProgress(double progress) 42 | { 43 | return progress; 44 | } 45 | } 46 | 47 | /// 48 | /// Defines the 49 | /// 50 | internal static class AnimationEaseInOut 51 | { 52 | /// 53 | /// Defines the PI 54 | /// 55 | public static double PI = Math.PI; 56 | 57 | /// 58 | /// Defines the PI_HALF 59 | /// 60 | public static double PI_HALF = Math.PI / 2; 61 | 62 | /// 63 | /// The CalculateProgress 64 | /// 65 | /// The progress 66 | /// The 67 | public static double CalculateProgress(double progress) 68 | { 69 | return EaseInOut(progress); 70 | } 71 | 72 | /// 73 | /// The EaseInOut 74 | /// 75 | /// The s 76 | /// The 77 | private static double EaseInOut(double s) 78 | { 79 | return s - Math.Sin(s * 2 * PI) / (2 * PI); 80 | } 81 | } 82 | 83 | /// 84 | /// Defines the 85 | /// 86 | public static class AnimationEaseOut 87 | { 88 | /// 89 | /// The CalculateProgress 90 | /// 91 | /// The progress 92 | /// The 93 | public static double CalculateProgress(double progress) 94 | { 95 | return -1 * progress * (progress - 2); 96 | } 97 | } 98 | 99 | /// 100 | /// Defines the 101 | /// 102 | public static class AnimationCustomQuadratic 103 | { 104 | /// 105 | /// The CalculateProgress 106 | /// 107 | /// The progress 108 | /// The 109 | public static double CalculateProgress(double progress) 110 | { 111 | var kickoff = 0.6; 112 | return 1 - Math.Cos((Math.Max(progress, kickoff) - kickoff) * Math.PI / (2 - (2 * kickoff))); 113 | } 114 | } 115 | } -------------------------------------------------------------------------------- /MaterialSkin/Controls/MaterialMultiLineTextBox.cs: -------------------------------------------------------------------------------- 1 | namespace MaterialSkin.Controls 2 | { 3 | using System; 4 | using System.ComponentModel; 5 | using System.Runtime.InteropServices; 6 | using System.Windows.Forms; 7 | 8 | public class MaterialMultiLineTextBox : RichTextBox, IMaterialControl 9 | { 10 | //Properties for managing the material design properties 11 | [Browsable(false)] 12 | public int Depth { get; set; } 13 | 14 | [Browsable(false)] 15 | public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; 16 | 17 | [Browsable(false)] 18 | public MouseState MouseState { get; set; } 19 | 20 | [DllImport("user32.dll", CharSet = CharSet.Auto)] 21 | private static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, string lParam); 22 | 23 | private const int EM_SETCUEBANNER = 0x1501; 24 | 25 | private const char EmptyChar = (char)0; 26 | 27 | private const char VisualStylePasswordChar = '\u25CF'; 28 | 29 | private const char NonVisualStylePasswordChar = '\u002A'; 30 | 31 | private string hint = string.Empty; 32 | 33 | [Category("Material Skin"), DefaultValue(""), Localizable(true)] 34 | public string Hint 35 | { 36 | get { return hint; } 37 | set 38 | { 39 | hint = value; 40 | SendMessage(Handle, EM_SETCUEBANNER, (int)IntPtr.Zero, Hint); 41 | } 42 | } 43 | 44 | private bool _leaveOnEnterKey; 45 | 46 | [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")] 47 | public bool LeaveOnEnterKey 48 | { 49 | get => _leaveOnEnterKey; 50 | set 51 | { 52 | _leaveOnEnterKey = value; 53 | if (value) 54 | { 55 | KeyDown += new KeyEventHandler(LeaveOnEnterKey_KeyDown); 56 | } 57 | else 58 | { 59 | KeyDown -= LeaveOnEnterKey_KeyDown; 60 | } 61 | Invalidate(); 62 | } 63 | } 64 | 65 | public new void SelectAll() 66 | { 67 | BeginInvoke((MethodInvoker)delegate () 68 | { 69 | base.Focus(); 70 | base.SelectAll(); 71 | }); 72 | } 73 | 74 | public new void Focus() 75 | { 76 | BeginInvoke((MethodInvoker)delegate () 77 | { 78 | base.Focus(); 79 | }); 80 | } 81 | 82 | private void LeaveOnEnterKey_KeyDown(object sender, KeyEventArgs e) 83 | { 84 | if (e.KeyData == Keys.Enter && e.Control == false) 85 | { 86 | e.Handled = true; 87 | e.SuppressKeyPress = true; 88 | SendKeys.Send("{TAB}"); 89 | } 90 | } 91 | 92 | public MaterialMultiLineTextBox() 93 | { 94 | base.OnCreateControl(); 95 | this.Multiline = true; 96 | 97 | BorderStyle = BorderStyle.None; 98 | Font = SkinManager.getFontByType(MaterialSkinManager.fontType.Body1); 99 | BackColor = SkinManager.BackgroundColor; 100 | ForeColor = SkinManager.TextHighEmphasisColor; 101 | BackColorChanged += (sender, args) => BackColor = SkinManager.BackgroundColor; 102 | ForeColorChanged += (sender, args) => ForeColor = SkinManager.TextHighEmphasisColor; 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /MaterialSkin/Controls/MaterialCard.cs: -------------------------------------------------------------------------------- 1 | namespace MaterialSkin.Controls 2 | { 3 | using System; 4 | using System.ComponentModel; 5 | using System.Drawing; 6 | using System.Drawing.Drawing2D; 7 | using System.Windows.Forms; 8 | 9 | public class MaterialCard : Panel, IMaterialControl 10 | { 11 | [Browsable(false)] 12 | public int Depth { get; set; } 13 | 14 | [Browsable(false)] 15 | public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; 16 | 17 | [Browsable(false)] 18 | public MouseState MouseState { get; set; } 19 | 20 | public MaterialCard() 21 | { 22 | SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); 23 | Paint += new PaintEventHandler(paintControl); 24 | BackColor = SkinManager.BackgroundColor; 25 | ForeColor = SkinManager.TextHighEmphasisColor; 26 | Margin = new Padding(SkinManager.FORM_PADDING); 27 | Padding = new Padding(SkinManager.FORM_PADDING); 28 | } 29 | 30 | private void drawShadowOnParent(object sender, PaintEventArgs e) 31 | { 32 | if (Parent == null) 33 | { 34 | RemoveShadowPaintEvent((Control)sender, drawShadowOnParent); 35 | return; 36 | } 37 | 38 | // paint shadow on parent 39 | Graphics gp = e.Graphics; 40 | Rectangle rect = new Rectangle(Location, ClientRectangle.Size); 41 | gp.SmoothingMode = SmoothingMode.AntiAlias; 42 | DrawHelper.DrawSquareShadow(gp, rect); 43 | } 44 | 45 | protected override void InitLayout() 46 | { 47 | LocationChanged += (sender, e) => { Parent?.Invalidate(); }; 48 | ForeColor = SkinManager.TextHighEmphasisColor; 49 | } 50 | 51 | protected override void OnParentChanged(EventArgs e) 52 | { 53 | base.OnParentChanged(e); 54 | if (Parent != null) AddShadowPaintEvent(Parent, drawShadowOnParent); 55 | if (_oldParent != null) RemoveShadowPaintEvent(_oldParent, drawShadowOnParent); 56 | _oldParent = Parent; 57 | } 58 | 59 | private Control _oldParent; 60 | 61 | protected override void OnVisibleChanged(EventArgs e) 62 | { 63 | base.OnVisibleChanged(e); 64 | if (Parent == null) return; 65 | if (Visible) 66 | AddShadowPaintEvent(Parent, drawShadowOnParent); 67 | else 68 | RemoveShadowPaintEvent(Parent, drawShadowOnParent); 69 | } 70 | 71 | private bool _shadowDrawEventSubscribed = false; 72 | 73 | private void AddShadowPaintEvent(Control control, PaintEventHandler shadowPaintEvent) 74 | { 75 | if (_shadowDrawEventSubscribed) return; 76 | control.Paint += shadowPaintEvent; 77 | control.Invalidate(); 78 | _shadowDrawEventSubscribed = true; 79 | } 80 | 81 | private void RemoveShadowPaintEvent(Control control, PaintEventHandler shadowPaintEvent) 82 | { 83 | if (!_shadowDrawEventSubscribed) return; 84 | control.Paint -= shadowPaintEvent; 85 | control.Invalidate(); 86 | _shadowDrawEventSubscribed = false; 87 | } 88 | 89 | protected override void OnBackColorChanged(EventArgs e) 90 | { 91 | base.OnBackColorChanged(e); 92 | BackColor = SkinManager.BackgroundColor; 93 | } 94 | 95 | private void paintControl(Object sender, PaintEventArgs e) 96 | { 97 | Graphics g = e.Graphics; 98 | g.SmoothingMode = SmoothingMode.AntiAlias; 99 | 100 | g.Clear(Parent.BackColor); 101 | 102 | // card rectangle path 103 | RectangleF cardRectF = new RectangleF(ClientRectangle.Location, ClientRectangle.Size); 104 | cardRectF.X -= 0.5f; 105 | cardRectF.Y -= 0.5f; 106 | GraphicsPath cardPath = DrawHelper.CreateRoundRect(cardRectF, 4); 107 | 108 | // button shadow (blend with form shadow) 109 | DrawHelper.DrawSquareShadow(g, ClientRectangle); 110 | 111 | // Draw card 112 | using (SolidBrush normalBrush = new SolidBrush(BackColor)) 113 | { 114 | g.FillPath(normalBrush, cardPath); 115 | } 116 | } 117 | } 118 | } -------------------------------------------------------------------------------- /MaterialSkin/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace MaterialSkin.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | public class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | public static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MaterialSkin.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | public static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Byte[]. 65 | /// 66 | public static byte[] Roboto_Black { 67 | get { 68 | object obj = ResourceManager.GetObject("Roboto_Black", resourceCulture); 69 | return ((byte[])(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// Looks up a localized resource of type System.Byte[]. 75 | /// 76 | public static byte[] Roboto_Bold { 77 | get { 78 | object obj = ResourceManager.GetObject("Roboto_Bold", resourceCulture); 79 | return ((byte[])(obj)); 80 | } 81 | } 82 | 83 | /// 84 | /// Looks up a localized resource of type System.Byte[]. 85 | /// 86 | public static byte[] Roboto_Light { 87 | get { 88 | object obj = ResourceManager.GetObject("Roboto_Light", resourceCulture); 89 | return ((byte[])(obj)); 90 | } 91 | } 92 | 93 | /// 94 | /// Looks up a localized resource of type System.Byte[]. 95 | /// 96 | public static byte[] Roboto_Medium { 97 | get { 98 | object obj = ResourceManager.GetObject("Roboto_Medium", resourceCulture); 99 | return ((byte[])(obj)); 100 | } 101 | } 102 | 103 | /// 104 | /// Looks up a localized resource of type System.Byte[]. 105 | /// 106 | public static byte[] Roboto_Regular { 107 | get { 108 | object obj = ResourceManager.GetObject("Roboto_Regular", resourceCulture); 109 | return ((byte[])(obj)); 110 | } 111 | } 112 | 113 | /// 114 | /// Looks up a localized resource of type System.Byte[]. 115 | /// 116 | public static byte[] Roboto_Thin { 117 | get { 118 | object obj = ResourceManager.GetObject("Roboto_Thin", resourceCulture); 119 | return ((byte[])(obj)); 120 | } 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /MaterialSkin/Controls/MaterialMessageBox.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Drawing; 3 | using System.Windows.Forms; 4 | 5 | namespace MaterialSkin.Controls 6 | { 7 | ///TODO: Break this out into a MaterialDialog then extend into the MaterialMsgBox 8 | 9 | ///Adapted from http://www.codeproject.com/Articles/601900/FlexibleMessageBox 10 | public class MaterialMessageBox : IMaterialControl 11 | { 12 | [Browsable(false)] 13 | public int Depth { get; set; } 14 | 15 | [Browsable(false)] 16 | public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; 17 | 18 | [Browsable(false)] 19 | public MouseState MouseState { get; set; } 20 | 21 | [Browsable(false)] 22 | public Point MouseLocation { get; set; } 23 | 24 | public static DialogResult Show(string text, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right) 25 | { 26 | return FlexibleMaterialForm.Show(null, text, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, UseRichTextBox, buttonsPosition); 27 | } 28 | 29 | public static DialogResult Show(IWin32Window owner, string text, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right) 30 | { 31 | return FlexibleMaterialForm.Show(owner, text, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, UseRichTextBox, buttonsPosition); 32 | } 33 | 34 | public static DialogResult Show(string text, string caption, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right) 35 | { 36 | return FlexibleMaterialForm.Show(null, text, caption, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, UseRichTextBox, buttonsPosition); 37 | } 38 | 39 | public static DialogResult Show(IWin32Window owner, string text, string caption, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right) 40 | { 41 | return FlexibleMaterialForm.Show(owner, text, caption, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, UseRichTextBox, buttonsPosition); 42 | } 43 | 44 | public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right) 45 | { 46 | return FlexibleMaterialForm.Show(null, text, caption, buttons, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, UseRichTextBox, buttonsPosition); 47 | } 48 | 49 | public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right) 50 | { 51 | return FlexibleMaterialForm.Show(owner, text, caption, buttons, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, UseRichTextBox, buttonsPosition); 52 | } 53 | 54 | public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right) 55 | { 56 | return FlexibleMaterialForm.Show(null, text, caption, buttons, icon, MessageBoxDefaultButton.Button1, UseRichTextBox, buttonsPosition); 57 | } 58 | 59 | public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right) 60 | { 61 | return FlexibleMaterialForm.Show(owner, text, caption, buttons, icon, MessageBoxDefaultButton.Button1, UseRichTextBox, buttonsPosition); 62 | } 63 | 64 | public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, bool UseRichTextBox = true, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right) 65 | { 66 | return FlexibleMaterialForm.Show(null, text, caption, buttons, icon, defaultButton, UseRichTextBox, buttonsPosition); 67 | } 68 | 69 | 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) 70 | { 71 | return FlexibleMaterialForm.Show(owner, text, caption, buttons, icon, defaultButton, UseRichTextBox, buttonsPosition); 72 | } 73 | 74 | public static DialogResult Show(string text, string caption, MessageBoxButtons messageBoxButtons, FlexibleMaterialForm.ButtonsPosition buttonsPosition = FlexibleMaterialForm.ButtonsPosition.Right) 75 | { 76 | return FlexibleMaterialForm.Show(null, text, caption, messageBoxButtons, MessageBoxIcon.None, MessageBoxDefaultButton.Button1, true, buttonsPosition); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /MaterialSkin/Controls/MaterialMenuStrip.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Drawing.Drawing2D; 5 | using System.Drawing.Text; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace MaterialSkin.Controls 12 | { 13 | public class MaterialMenuStrip : MenuStrip, IMaterialControl 14 | { 15 | public int Depth { get; set; } 16 | public MaterialSkinManager SkinManager { get { return MaterialSkinManager.Instance; } } 17 | public MouseState MouseState { get; set; } 18 | 19 | public MaterialMenuStrip() 20 | { 21 | Renderer = new MaterialMenuStripRender(); 22 | 23 | if (DesignMode) 24 | { 25 | Dock = DockStyle.None; 26 | Anchor |= AnchorStyles.Right; 27 | AutoSize = false; 28 | Location = new Point(0, 28); 29 | } 30 | } 31 | 32 | protected override void OnCreateControl() 33 | { 34 | base.OnCreateControl(); 35 | Font = SkinManager.ROBOTO_MEDIUM_10; 36 | BackColor = SkinManager.PrimaryColor; 37 | } 38 | } 39 | 40 | internal class MaterialMenuStripRender : ToolStripProfessionalRenderer, IMaterialControl 41 | { 42 | //Properties for managing the material design properties 43 | public int Depth { get; set; } 44 | public MaterialSkinManager SkinManager { get { return MaterialSkinManager.Instance; } } 45 | public MouseState MouseState { get; set; } 46 | 47 | protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) 48 | { 49 | var g = e.Graphics; 50 | g.TextRenderingHint = TextRenderingHint.AntiAlias; 51 | 52 | if (e.Item.IsOnDropDown) 53 | { 54 | var itemRect = GetItemRect(e.Item); 55 | var textRect = new Rectangle(24, itemRect.Y, itemRect.Width - (24 + 16), itemRect.Height); 56 | g.DrawString(e.Text, SkinManager.ROBOTO_MEDIUM_10, e.Item.Enabled ? SkinManager.GetMainTextBrush() : SkinManager.GetDisabledOrHintBrush(), textRect, new StringFormat() { LineAlignment = StringAlignment.Center }); 57 | } 58 | else 59 | { 60 | g.DrawString(e.Text, SkinManager.ROBOTO_MEDIUM_10, Brushes.White, e.TextRectangle, new StringFormat() { LineAlignment = StringAlignment.Center }); 61 | } 62 | } 63 | 64 | protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) 65 | { 66 | var g = e.Graphics; 67 | g.Clear(SkinManager.PrimaryColor); 68 | 69 | //Draw background 70 | var itemRect = GetItemRect(e.Item); 71 | if (e.Item.IsOnDropDown) 72 | { 73 | g.FillRectangle(e.Item.Selected && e.Item.Enabled ? SkinManager.GetCmsSelectedItemBrush() : new SolidBrush(SkinManager.GetApplicationBackgroundColor()), itemRect); 74 | } 75 | else 76 | { 77 | g.FillRectangle(e.Item.Selected ? SkinManager.GetFlatButtonPressedBackgroundBrush() : SkinManager.PrimaryColorBrush, itemRect); 78 | } 79 | 80 | //Ripple animation 81 | var toolStrip = e.ToolStrip as MaterialContextMenuStrip; 82 | if (toolStrip != null) 83 | { 84 | var animationManager = toolStrip.animationManager; 85 | var animationSource = toolStrip.animationSource; 86 | if (toolStrip.animationManager.IsAnimating() && e.Item.Bounds.Contains(animationSource)) 87 | { 88 | for (int i = 0; i < animationManager.GetAnimationCount(); i++) 89 | { 90 | var animationValue = animationManager.GetProgress(i); 91 | var rippleBrush = new SolidBrush(Color.FromArgb((int)(51 - (animationValue * 50)), Color.Black)); 92 | var rippleSize = (int)(animationValue * itemRect.Width * 2.5); 93 | g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, itemRect.Y - itemRect.Height, rippleSize, itemRect.Height * 3)); 94 | } 95 | } 96 | } 97 | } 98 | 99 | protected override void OnRenderImageMargin(ToolStripRenderEventArgs e) 100 | { 101 | //base.OnRenderImageMargin(e); 102 | } 103 | 104 | protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e) 105 | { 106 | var g = e.Graphics; 107 | 108 | g.FillRectangle(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), e.Item.Bounds); 109 | g.DrawLine(new Pen(SkinManager.GetDividersColor()), new Point(e.Item.Bounds.Left, e.Item.Bounds.Height / 2), new Point(e.Item.Bounds.Right, e.Item.Bounds.Height / 2)); 110 | } 111 | 112 | protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) 113 | { 114 | //var g = e.Graphics; 115 | 116 | //g.DrawRectangle(new Pen(SkinManager.GetDividersColor()), new Rectangle(e.AffectedBounds.X, e.AffectedBounds.Y, e.AffectedBounds.Width - 1, e.AffectedBounds.Height - 1)); 117 | } 118 | 119 | protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) 120 | { 121 | var g = e.Graphics; 122 | const int ARROW_SIZE = 4; 123 | 124 | var arrowMiddle = new Point(e.ArrowRectangle.X + e.ArrowRectangle.Width / 2, e.ArrowRectangle.Y + e.ArrowRectangle.Height / 2); 125 | var arrowBrush = e.Item.Enabled ? SkinManager.GetMainTextBrush() : SkinManager.GetDisabledOrHintBrush(); 126 | using (var arrowPath = new GraphicsPath()) 127 | { 128 | arrowPath.AddLines(new[] { new Point(arrowMiddle.X - ARROW_SIZE, arrowMiddle.Y - ARROW_SIZE), new Point(arrowMiddle.X, arrowMiddle.Y), new Point(arrowMiddle.X - ARROW_SIZE, arrowMiddle.Y + ARROW_SIZE) }); 129 | arrowPath.CloseFigure(); 130 | 131 | g.FillPath(arrowBrush, arrowPath); 132 | } 133 | } 134 | 135 | private Rectangle GetItemRect(ToolStripItem item) 136 | { 137 | return new Rectangle(0, item.ContentRectangle.Y, item.ContentRectangle.Width + 4, item.ContentRectangle.Height); 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /MaterialSkin/MaterialSkinCore.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net5.0-windows;net48;net461 4 | win 5 | Library 6 | false 7 | true 8 | true 9 | MaterialSkin 10 | $(AssemblyName) 11 | MaterialSkin.2 12 | 2.3.1 13 | MaterialSkin 2 14 | leocb, IgnaceMaes, orapps44 15 | MIT 16 | https://github.com/leocb/MaterialSkin 17 | nugetIcon.png 18 | False 19 | Google's Material Design for your windows forms. 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 supersedes the MaterialSkin package By IgnaceMaes. Example app and documentation is available on the project site. 20 | See GitHub page for release notes. 21 | Copyright Leonardo C Bottaro © 2021 22 | material design materialdesign google forms theme skin 23 | README.md 24 | 25 | 26 | 27 | 28 | 29 | 30 | Component 31 | 32 | 33 | Component 34 | 35 | 36 | Component 37 | 38 | 39 | Component 40 | 41 | 42 | Component 43 | 44 | 45 | Component 46 | 47 | 48 | Component 49 | 50 | 51 | Component 52 | 53 | 54 | Component 55 | 56 | 57 | Component 58 | 59 | 60 | Component 61 | 62 | 63 | Component 64 | 65 | 66 | Component 67 | 68 | 69 | Component 70 | 71 | 72 | Component 73 | 74 | 75 | Component 76 | 77 | 78 | Component 79 | 80 | 81 | Component 82 | 83 | 84 | Component 85 | 86 | 87 | Component 88 | 89 | 90 | Component 91 | 92 | 93 | Component 94 | 95 | 96 | Component 97 | 98 | 99 | Component 100 | 101 | 102 | Component 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | True 119 | 120 | 121 | 122 | True 123 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /MaterialSkin/DrawHelper.cs: -------------------------------------------------------------------------------- 1 | namespace MaterialSkin 2 | { 3 | using System.Drawing; 4 | using System.Drawing.Drawing2D; 5 | 6 | /// 7 | /// Defines the 8 | /// 9 | internal static class DrawHelper 10 | { 11 | /// 12 | /// The CreateRoundRect 13 | /// 14 | /// The x 15 | /// The y 16 | /// The width 17 | /// The height 18 | /// The radius 19 | /// The 20 | public static GraphicsPath CreateRoundRect(float x, float y, float width, float height, float radius) 21 | { 22 | var gp = new GraphicsPath(); 23 | gp.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90); 24 | gp.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90); 25 | gp.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90); 26 | gp.AddArc(x, y, radius * 2, radius * 2, 180, 90); 27 | gp.CloseFigure(); 28 | return gp; 29 | } 30 | 31 | /// 32 | /// The CreateRoundRect 33 | /// 34 | /// The rect 35 | /// The radius 36 | /// The 37 | public static GraphicsPath CreateRoundRect(Rectangle rect, float radius) 38 | { 39 | return CreateRoundRect(rect.X, rect.Y, rect.Width, rect.Height, radius); 40 | } 41 | 42 | /// 43 | /// The CreateRoundRect 44 | /// 45 | /// The rect 46 | /// The radius 47 | /// The 48 | public static GraphicsPath CreateRoundRect(RectangleF rect, float radius) 49 | { 50 | return CreateRoundRect(rect.X, rect.Y, rect.Width, rect.Height, radius); 51 | } 52 | 53 | /// 54 | /// The BlendColor 55 | /// 56 | /// The backgroundColor 57 | /// The frontColor 58 | /// The blend 59 | /// The 60 | public static Color BlendColor(Color backgroundColor, Color frontColor, double blend) 61 | { 62 | var ratio = blend / 255d; 63 | var invRatio = 1d - ratio; 64 | var r = (int)((backgroundColor.R * invRatio) + (frontColor.R * ratio)); 65 | var g = (int)((backgroundColor.G * invRatio) + (frontColor.G * ratio)); 66 | var b = (int)((backgroundColor.B * invRatio) + (frontColor.B * ratio)); 67 | return Color.FromArgb(r, g, b); 68 | } 69 | 70 | /// 71 | /// The BlendColor 72 | /// 73 | /// The backgroundColor 74 | /// The frontColor 75 | /// The 76 | public static Color BlendColor(Color backgroundColor, Color frontColor) 77 | { 78 | return BlendColor(backgroundColor, frontColor, frontColor.A); 79 | } 80 | 81 | public static void DrawSquareShadow(Graphics g, Rectangle bounds) 82 | { 83 | using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(12, 0, 0, 0))) 84 | { 85 | GraphicsPath path; 86 | path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 3.5f, bounds.Y - 1.5f, bounds.Width + 6, bounds.Height + 6), 8); 87 | g.FillPath(shadowBrush, path); 88 | path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 2.5f, bounds.Y - 1.5f, bounds.Width + 4, bounds.Height + 4), 6); 89 | g.FillPath(shadowBrush, path); 90 | path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 1.5f, bounds.Y - 0.5f, bounds.Width + 2, bounds.Height + 2), 4); 91 | g.FillPath(shadowBrush, path); 92 | path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 0.5f, bounds.Y + 1.5f, bounds.Width + 0, bounds.Height + 0), 4); 93 | g.FillPath(shadowBrush, path); 94 | path = DrawHelper.CreateRoundRect(new RectangleF(bounds.X - 0.5f, bounds.Y + 2.5f, bounds.Width + 0, bounds.Height + 0), 4); 95 | g.FillPath(shadowBrush, path); 96 | path.Dispose(); 97 | } 98 | } 99 | 100 | public static void DrawRoundShadow(Graphics g, Rectangle bounds) 101 | { 102 | using (SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(12, 0, 0, 0))) 103 | { 104 | g.FillEllipse(shadowBrush, new Rectangle(bounds.X - 2, bounds.Y - 1, bounds.Width + 4, bounds.Height + 6)); 105 | g.FillEllipse(shadowBrush, new Rectangle(bounds.X - 1, bounds.Y - 1, bounds.Width + 2, bounds.Height + 4)); 106 | g.FillEllipse(shadowBrush, new Rectangle(bounds.X - 0, bounds.Y - 0, bounds.Width + 0, bounds.Height + 2)); 107 | g.FillEllipse(shadowBrush, new Rectangle(bounds.X - 0, bounds.Y + 2, bounds.Width + 0, bounds.Height + 0)); 108 | g.FillEllipse(shadowBrush, new Rectangle(bounds.X - 0, bounds.Y + 1, bounds.Width + 0, bounds.Height + 0)); 109 | } 110 | } 111 | } 112 | } -------------------------------------------------------------------------------- /MaterialSkinExample/MaterialSkinExample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {47409AA5-62AE-4189-8E83-C471502DF5E9} 8 | WinExe 9 | Properties 10 | MaterialSkinExample 11 | MaterialSkinExample 12 | v4.6.1 13 | 512 14 | 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | Form 44 | 45 | 46 | MainForm.cs 47 | 48 | 49 | 50 | 51 | MainForm.cs 52 | 53 | 54 | ResXFileCodeGenerator 55 | Resources.Designer.cs 56 | Designer 57 | 58 | 59 | True 60 | Resources.resx 61 | True 62 | 63 | 64 | SettingsSingleFileGenerator 65 | Settings.Designer.cs 66 | 67 | 68 | True 69 | Settings.settings 70 | True 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | {8eb7611b-68cd-4b8b-987a-11717e2b250c} 80 | MaterialSkin 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 145 | 146 | -------------------------------------------------------------------------------- /MaterialSkin/ColorHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | 4 | namespace MaterialSkin 5 | { 6 | public static class ColorHelper 7 | { 8 | /// 9 | /// Tints the color by the given percent. 10 | /// 11 | /// The color being tinted. 12 | /// The percent to tint. Ex: 0.1 will make the color 10% lighter. 13 | /// The new tinted color. 14 | public static Color Lighten(this Color color, float percent) 15 | { 16 | var lighting = color.GetBrightness(); 17 | lighting = lighting + lighting * percent; 18 | if (lighting > 1.0) 19 | { 20 | lighting = 1; 21 | } 22 | else if (lighting <= 0) 23 | { 24 | lighting = 0.1f; 25 | } 26 | var tintedColor = ColorHelper.FromHsl(color.A, color.GetHue(), color.GetSaturation(), lighting); 27 | 28 | return tintedColor; 29 | } 30 | 31 | /// 32 | /// Tints the color by the given percent. 33 | /// 34 | /// The color being tinted. 35 | /// The percent to tint. Ex: 0.1 will make the color 10% darker. 36 | /// The new tinted color. 37 | public static Color Darken(this Color color, float percent) 38 | { 39 | var lighting = color.GetBrightness(); 40 | lighting = lighting - lighting * percent; 41 | if (lighting > 1.0) 42 | { 43 | lighting = 1; 44 | } 45 | else if (lighting <= 0) 46 | { 47 | lighting = 0; 48 | } 49 | var tintedColor = ColorHelper.FromHsl(color.A, color.GetHue(), color.GetSaturation(), lighting); 50 | 51 | return tintedColor; 52 | } 53 | 54 | /// 55 | /// Converts the HSL values to a Color. 56 | /// 57 | /// The alpha. 58 | /// The hue. 59 | /// The saturation. 60 | /// The lighting. 61 | /// 62 | public static Color FromHsl(int alpha, float hue, float saturation, float lighting) 63 | { 64 | if (0 > alpha || 255 < alpha) 65 | { 66 | throw new ArgumentOutOfRangeException("alpha"); 67 | } 68 | if (0f > hue || 360f < hue) 69 | { 70 | throw new ArgumentOutOfRangeException("hue"); 71 | } 72 | if (0f > saturation || 1f < saturation) 73 | { 74 | throw new ArgumentOutOfRangeException("saturation"); 75 | } 76 | if (0f > lighting || 1f < lighting) 77 | { 78 | throw new ArgumentOutOfRangeException("lighting"); 79 | } 80 | 81 | if (0 == saturation) 82 | { 83 | return Color.FromArgb(alpha, Convert.ToInt32(lighting * 255), Convert.ToInt32(lighting * 255), Convert.ToInt32(lighting * 255)); 84 | } 85 | 86 | float fMax, fMid, fMin; 87 | int iSextant, iMax, iMid, iMin; 88 | 89 | if (0.5 < lighting) 90 | { 91 | fMax = lighting - (lighting * saturation) + saturation; 92 | fMin = lighting + (lighting * saturation) - saturation; 93 | } 94 | else 95 | { 96 | fMax = lighting + (lighting * saturation); 97 | fMin = lighting - (lighting * saturation); 98 | } 99 | 100 | iSextant = (int)Math.Floor(hue / 60f); 101 | if (300f <= hue) 102 | { 103 | hue -= 360f; 104 | } 105 | hue /= 60f; 106 | hue -= 2f * (float)Math.Floor(((iSextant + 1f) % 6f) / 2f); 107 | if (0 == iSextant % 2) 108 | { 109 | fMid = hue * (fMax - fMin) + fMin; 110 | } 111 | else 112 | { 113 | fMid = fMin - hue * (fMax - fMin); 114 | } 115 | 116 | iMax = Convert.ToInt32(fMax * 255); 117 | iMid = Convert.ToInt32(fMid * 255); 118 | iMin = Convert.ToInt32(fMin * 255); 119 | 120 | switch (iSextant) 121 | { 122 | case 1: 123 | return Color.FromArgb(alpha, iMid, iMax, iMin); 124 | 125 | case 2: 126 | return Color.FromArgb(alpha, iMin, iMax, iMid); 127 | 128 | case 3: 129 | return Color.FromArgb(alpha, iMin, iMid, iMax); 130 | 131 | case 4: 132 | return Color.FromArgb(alpha, iMid, iMin, iMax); 133 | 134 | case 5: 135 | return Color.FromArgb(alpha, iMax, iMin, iMid); 136 | 137 | default: 138 | return Color.FromArgb(alpha, iMax, iMid, iMin); 139 | } 140 | } 141 | 142 | /// 143 | /// Removes alpha value without changing Color. 144 | /// 145 | /// The foreground color. 146 | /// The background color. 147 | /// 148 | public static Color RemoveAlpha(Color foreground, Color background) 149 | { 150 | if (foreground.A == 255) 151 | return foreground; 152 | 153 | var alpha = foreground.A / 255.0; 154 | var diff = 1.0 - alpha; 155 | return Color.FromArgb(255, 156 | (byte)(foreground.R * alpha + background.R * diff), 157 | (byte)(foreground.G * alpha + background.G * diff), 158 | (byte)(foreground.B * alpha + background.B * diff)); 159 | } 160 | 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /MaterialSkin/Controls/MaterialForm.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /MaterialSkin/Controls/FlexibleMaterialDialog.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /MaterialSkin/Controls/MaterialLabel.cs: -------------------------------------------------------------------------------- 1 | namespace MaterialSkin.Controls 2 | { 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Windows.Forms; 6 | 7 | public class MaterialLabel : Label, IMaterialControl 8 | { 9 | [Browsable(false)] 10 | public int Depth { get; set; } 11 | 12 | [Browsable(false)] 13 | public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; 14 | 15 | [Browsable(false)] 16 | public MouseState MouseState { get; set; } 17 | 18 | private ContentAlignment _TextAlign = ContentAlignment.TopLeft; 19 | 20 | [DefaultValue(typeof(ContentAlignment), "TopLeft")] 21 | public override ContentAlignment TextAlign 22 | { 23 | get 24 | { 25 | return _TextAlign; 26 | } 27 | set 28 | { 29 | _TextAlign = value; 30 | updateAligment(); 31 | Invalidate(); 32 | } 33 | } 34 | 35 | [Category("Material Skin"), 36 | DefaultValue(false)] 37 | public bool HighEmphasis { get; set; } 38 | 39 | [Category("Material Skin"), 40 | DefaultValue(false)] 41 | public bool UseAccent { get; set; } 42 | 43 | private MaterialSkinManager.fontType _fontType = MaterialSkinManager.fontType.Body1; 44 | 45 | [Category("Material Skin"), 46 | DefaultValue(typeof(MaterialSkinManager.fontType), "Body1")] 47 | public MaterialSkinManager.fontType FontType 48 | { 49 | get 50 | { 51 | return _fontType; 52 | } 53 | set 54 | { 55 | _fontType = value; 56 | Font = SkinManager.getFontByType(_fontType); 57 | Refresh(); 58 | } 59 | } 60 | 61 | public MaterialLabel() 62 | { 63 | FontType = MaterialSkinManager.fontType.Body1; 64 | TextAlign = ContentAlignment.TopLeft; 65 | } 66 | 67 | public override Size GetPreferredSize(Size proposedSize) 68 | { 69 | if (AutoSize) 70 | { 71 | Size strSize; 72 | using (NativeTextRenderer NativeText = new NativeTextRenderer(CreateGraphics())) 73 | { 74 | strSize = NativeText.MeasureLogString(Text, SkinManager.getLogFontByType(_fontType)); 75 | strSize.Width += 1; // necessary to avoid a bug when autosize = true 76 | } 77 | return strSize; 78 | } 79 | else 80 | { 81 | return proposedSize; 82 | } 83 | } 84 | 85 | private NativeTextRenderer.TextAlignFlags Alignment; 86 | 87 | private void updateAligment() 88 | { 89 | switch (_TextAlign) 90 | { 91 | case ContentAlignment.TopLeft: 92 | Alignment = NativeTextRenderer.TextAlignFlags.Top | NativeTextRenderer.TextAlignFlags.Left; 93 | break; 94 | 95 | case ContentAlignment.TopCenter: 96 | Alignment = NativeTextRenderer.TextAlignFlags.Top | NativeTextRenderer.TextAlignFlags.Center; 97 | break; 98 | 99 | case ContentAlignment.TopRight: 100 | Alignment = NativeTextRenderer.TextAlignFlags.Top | NativeTextRenderer.TextAlignFlags.Right; 101 | break; 102 | 103 | case ContentAlignment.MiddleLeft: 104 | Alignment = NativeTextRenderer.TextAlignFlags.Middle | NativeTextRenderer.TextAlignFlags.Left; 105 | break; 106 | 107 | case ContentAlignment.MiddleCenter: 108 | Alignment = NativeTextRenderer.TextAlignFlags.Middle | NativeTextRenderer.TextAlignFlags.Center; 109 | break; 110 | 111 | case ContentAlignment.MiddleRight: 112 | Alignment = NativeTextRenderer.TextAlignFlags.Middle | NativeTextRenderer.TextAlignFlags.Right; 113 | break; 114 | 115 | case ContentAlignment.BottomLeft: 116 | Alignment = NativeTextRenderer.TextAlignFlags.Bottom | NativeTextRenderer.TextAlignFlags.Left; 117 | break; 118 | 119 | case ContentAlignment.BottomCenter: 120 | Alignment = NativeTextRenderer.TextAlignFlags.Bottom | NativeTextRenderer.TextAlignFlags.Center; 121 | break; 122 | 123 | case ContentAlignment.BottomRight: 124 | Alignment = NativeTextRenderer.TextAlignFlags.Bottom | NativeTextRenderer.TextAlignFlags.Right; 125 | break; 126 | 127 | default: 128 | Alignment = NativeTextRenderer.TextAlignFlags.Top | NativeTextRenderer.TextAlignFlags.Left; 129 | break; 130 | } 131 | } 132 | 133 | protected override void OnPaint(PaintEventArgs e) 134 | { 135 | Graphics g = e.Graphics; 136 | g.Clear(Parent.BackColor); 137 | 138 | // Draw Text 139 | using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) 140 | { 141 | NativeText.DrawMultilineTransparentText( 142 | Text, 143 | SkinManager.getLogFontByType(_fontType), 144 | Enabled ? HighEmphasis ? UseAccent ? 145 | SkinManager.ColorScheme.AccentColor : // High emphasis, accent 146 | (SkinManager.Theme == MaterialSkin.MaterialSkinManager.Themes.LIGHT) ? 147 | SkinManager.ColorScheme.PrimaryColor : // High emphasis, primary Light theme 148 | SkinManager.ColorScheme.PrimaryColor.Lighten(0.25f) : // High emphasis, primary Dark theme 149 | SkinManager.TextHighEmphasisColor : // Normal 150 | SkinManager.TextDisabledOrHintColor, // Disabled 151 | ClientRectangle.Location, 152 | ClientRectangle.Size, 153 | Alignment); 154 | } 155 | } 156 | 157 | protected override void InitLayout() 158 | { 159 | Font = SkinManager.getFontByType(_fontType); 160 | } 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /MaterialSkin/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\Resources\Roboto-Black.ttf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 123 | 124 | 125 | ..\Resources\Roboto-Bold.ttf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 126 | 127 | 128 | ..\Resources\Roboto-Light.ttf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 129 | 130 | 131 | ..\Resources\Roboto-Medium.ttf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 132 | 133 | 134 | ..\Resources\Roboto-Regular.ttf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 135 | 136 | 137 | ..\Resources\Roboto-Thin.ttf;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 138 | 139 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.cache 72 | *.ilk 73 | *.meta 74 | *.obj 75 | *.iobj 76 | *.pch 77 | *.pdb 78 | *.ipdb 79 | *.pgc 80 | *.pgd 81 | *.rsp 82 | *.sbr 83 | *.tlb 84 | *.tli 85 | *.tlh 86 | *.tmp 87 | *.tmp_proj 88 | *_wpftmp.csproj 89 | *.log 90 | *.vspscc 91 | *.vssscc 92 | .builds 93 | *.pidb 94 | *.svclog 95 | *.scc 96 | 97 | # Chutzpah Test files 98 | _Chutzpah* 99 | 100 | # Visual C++ cache files 101 | ipch/ 102 | *.aps 103 | *.ncb 104 | *.opendb 105 | *.opensdf 106 | *.sdf 107 | *.cachefile 108 | *.VC.db 109 | *.VC.VC.opendb 110 | 111 | # Visual Studio profiler 112 | *.psess 113 | *.vsp 114 | *.vspx 115 | *.sap 116 | 117 | # Visual Studio Trace Files 118 | *.e2e 119 | 120 | # TFS 2012 Local Workspace 121 | $tf/ 122 | 123 | # Guidance Automation Toolkit 124 | *.gpState 125 | 126 | # ReSharper is a .NET coding add-in 127 | _ReSharper*/ 128 | *.[Rr]e[Ss]harper 129 | *.DotSettings.user 130 | 131 | # JustCode is a .NET coding add-in 132 | .JustCode 133 | 134 | # TeamCity is a build add-in 135 | _TeamCity* 136 | 137 | # DotCover is a Code Coverage Tool 138 | *.dotCover 139 | 140 | # AxoCover is a Code Coverage Tool 141 | .axoCover/* 142 | !.axoCover/settings.json 143 | 144 | # Visual Studio code coverage results 145 | *.coverage 146 | *.coveragexml 147 | 148 | # NCrunch 149 | _NCrunch_* 150 | .*crunch*.local.xml 151 | nCrunchTemp_* 152 | 153 | # MightyMoose 154 | *.mm.* 155 | AutoTest.Net/ 156 | 157 | # Web workbench (sass) 158 | .sass-cache/ 159 | 160 | # Installshield output folder 161 | [Ee]xpress/ 162 | 163 | # DocProject is a documentation generator add-in 164 | DocProject/buildhelp/ 165 | DocProject/Help/*.HxT 166 | DocProject/Help/*.HxC 167 | DocProject/Help/*.hhc 168 | DocProject/Help/*.hhk 169 | DocProject/Help/*.hhp 170 | DocProject/Help/Html2 171 | DocProject/Help/html 172 | 173 | # Click-Once directory 174 | publish/ 175 | 176 | # Publish Web Output 177 | *.[Pp]ublish.xml 178 | *.azurePubxml 179 | # Note: Comment the next line if you want to checkin your web deploy settings, 180 | # but database connection strings (with potential passwords) will be unencrypted 181 | *.pubxml 182 | *.publishproj 183 | 184 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 185 | # checkin your Azure Web App publish settings, but sensitive information contained 186 | # in these scripts will be unencrypted 187 | PublishScripts/ 188 | 189 | # NuGet Packages 190 | *.nupkg 191 | # NuGet Symbol Packages 192 | *.snupkg 193 | # The packages folder can be ignored because of Package Restore 194 | **/[Pp]ackages/* 195 | # except build/, which is used as an MSBuild target. 196 | !**/[Pp]ackages/build/ 197 | # Uncomment if necessary however generally it will be regenerated when needed 198 | #!**/[Pp]ackages/repositories.config 199 | # NuGet v3's project.json files produces more ignorable files 200 | *.nuget.props 201 | *.nuget.targets 202 | 203 | # Microsoft Azure Build Output 204 | csx/ 205 | *.build.csdef 206 | 207 | # Microsoft Azure Emulator 208 | ecf/ 209 | rcf/ 210 | 211 | # Windows Store app package directories and files 212 | AppPackages/ 213 | BundleArtifacts/ 214 | Package.StoreAssociation.xml 215 | _pkginfo.txt 216 | *.appx 217 | *.appxbundle 218 | *.appxupload 219 | 220 | # Visual Studio cache files 221 | # files ending in .cache can be ignored 222 | *.[Cc]ache 223 | # but keep track of directories ending in .cache 224 | !?*.[Cc]ache/ 225 | 226 | # Others 227 | ClientBin/ 228 | ~$* 229 | *~ 230 | *.dbmdl 231 | *.dbproj.schemaview 232 | *.jfm 233 | *.pfx 234 | *.publishsettings 235 | orleans.codegen.cs 236 | 237 | # Including strong name files can present a security risk 238 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 239 | #*.snk 240 | 241 | # Since there are multiple workflows, uncomment next line to ignore bower_components 242 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 243 | #bower_components/ 244 | 245 | # RIA/Silverlight projects 246 | Generated_Code/ 247 | 248 | # Backup & report files from converting an old project file 249 | # to a newer Visual Studio version. Backup files are not needed, 250 | # because we have git ;-) 251 | _UpgradeReport_Files/ 252 | Backup*/ 253 | UpgradeLog*.XML 254 | UpgradeLog*.htm 255 | ServiceFabricBackup/ 256 | *.rptproj.bak 257 | 258 | # SQL Server files 259 | *.mdf 260 | *.ldf 261 | *.ndf 262 | 263 | # Business Intelligence projects 264 | *.rdl.data 265 | *.bim.layout 266 | *.bim_*.settings 267 | *.rptproj.rsuser 268 | *- [Bb]ackup.rdl 269 | *- [Bb]ackup ([0-9]).rdl 270 | *- [Bb]ackup ([0-9][0-9]).rdl 271 | 272 | # Microsoft Fakes 273 | FakesAssemblies/ 274 | 275 | # GhostDoc plugin setting file 276 | *.GhostDoc.xml 277 | 278 | # Node.js Tools for Visual Studio 279 | .ntvs_analysis.dat 280 | node_modules/ 281 | 282 | # Visual Studio 6 build log 283 | *.plg 284 | 285 | # Visual Studio 6 workspace options file 286 | *.opt 287 | 288 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 289 | *.vbw 290 | 291 | # Visual Studio LightSwitch build output 292 | **/*.HTMLClient/GeneratedArtifacts 293 | **/*.DesktopClient/GeneratedArtifacts 294 | **/*.DesktopClient/ModelManifest.xml 295 | **/*.Server/GeneratedArtifacts 296 | **/*.Server/ModelManifest.xml 297 | _Pvt_Extensions 298 | 299 | # Paket dependency manager 300 | .paket/paket.exe 301 | paket-files/ 302 | 303 | # FAKE - F# Make 304 | .fake/ 305 | 306 | # CodeRush personal settings 307 | .cr/personal 308 | 309 | # Python Tools for Visual Studio (PTVS) 310 | __pycache__/ 311 | *.pyc 312 | 313 | # Cake - Uncomment if you are using it 314 | # tools/** 315 | # !tools/packages.config 316 | 317 | # Tabs Studio 318 | *.tss 319 | 320 | # Telerik's JustMock configuration file 321 | *.jmconfig 322 | 323 | # BizTalk build output 324 | *.btp.cs 325 | *.btm.cs 326 | *.odx.cs 327 | *.xsd.cs 328 | 329 | # OpenCover UI analysis results 330 | OpenCover/ 331 | 332 | # Azure Stream Analytics local run output 333 | ASALocalRun/ 334 | 335 | # MSBuild Binary and Structured Log 336 | *.binlog 337 | 338 | # NVidia Nsight GPU debugger configuration file 339 | *.nvuser 340 | 341 | # MFractors (Xamarin productivity tool) working folder 342 | .mfractor/ 343 | 344 | # Local History for Visual Studio 345 | .localhistory/ 346 | 347 | # BeatPulse healthcheck temp database 348 | healthchecksdb 349 | 350 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 351 | MigrationBackup/ 352 | 353 | # Ionide (cross platform F# VS Code tools) working folder 354 | .ionide/ -------------------------------------------------------------------------------- /MaterialSkin/Controls/MaterialListView.cs: -------------------------------------------------------------------------------- 1 | namespace MaterialSkin.Controls 2 | { 3 | using System; 4 | using System.ComponentModel; 5 | using System.Drawing; 6 | using System.Windows.Forms; 7 | 8 | public class MaterialListView : ListView, IMaterialControl 9 | { 10 | [Browsable(false)] 11 | public int Depth { get; set; } 12 | 13 | [Browsable(false)] 14 | public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; 15 | 16 | [Browsable(false)] 17 | public MouseState MouseState { get; set; } 18 | 19 | [Browsable(false)] 20 | public Point MouseLocation { get; set; } 21 | 22 | private bool _autoSizeTable; 23 | 24 | [Category("Appearance"), Browsable(true)] 25 | public bool AutoSizeTable 26 | { 27 | get 28 | { 29 | return _autoSizeTable; 30 | } 31 | set 32 | { 33 | _autoSizeTable = value; 34 | Scrollable = !value; 35 | } 36 | } 37 | 38 | [Browsable(false)] 39 | private ListViewItem HoveredItem { get; set; } 40 | 41 | private const int PAD = 16; 42 | private const int ITEMS_HEIGHT = 52; 43 | 44 | public MaterialListView() 45 | { 46 | GridLines = false; 47 | FullRowSelect = true; 48 | View = View.Details; 49 | OwnerDraw = true; 50 | ResizeRedraw = true; 51 | BorderStyle = BorderStyle.None; 52 | MinimumSize = new Size(200, 100); 53 | 54 | SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer, true); 55 | BackColor = SkinManager.BackgroundColor; 56 | 57 | // Fix for hovers, by default it doesn't redraw 58 | MouseLocation = new Point(-1, -1); 59 | MouseState = MouseState.OUT; 60 | MouseEnter += delegate 61 | { 62 | MouseState = MouseState.HOVER; 63 | }; 64 | MouseLeave += delegate 65 | { 66 | MouseState = MouseState.OUT; 67 | MouseLocation = new Point(-1, -1); 68 | HoveredItem = null; 69 | Invalidate(); 70 | }; 71 | MouseDown += delegate 72 | { 73 | MouseState = MouseState.DOWN; 74 | }; 75 | MouseUp += delegate 76 | { 77 | MouseState = MouseState.HOVER; 78 | }; 79 | MouseMove += delegate (object sender, MouseEventArgs args) 80 | { 81 | MouseLocation = args.Location; 82 | var currentHoveredItem = GetItemAt(MouseLocation.X, MouseLocation.Y); 83 | if (HoveredItem != currentHoveredItem) 84 | { 85 | HoveredItem = currentHoveredItem; 86 | Invalidate(); 87 | } 88 | }; 89 | } 90 | 91 | protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e) 92 | { 93 | Graphics g = e.Graphics; 94 | 95 | g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; 96 | 97 | g.FillRectangle(new SolidBrush(BackColor), e.Bounds); 98 | // Draw Text 99 | using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) 100 | { 101 | NativeText.DrawTransparentText( 102 | e.Header.Text, 103 | SkinManager.getLogFontByType(MaterialSkinManager.fontType.Subtitle2), 104 | Enabled ? SkinManager.TextHighEmphasisNoAlphaColor : SkinManager.TextDisabledOrHintColor, 105 | new Point(e.Bounds.Location.X + PAD, e.Bounds.Location.Y), 106 | new Size(e.Bounds.Size.Width - PAD * 2, e.Bounds.Size.Height), 107 | NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); 108 | } 109 | } 110 | 111 | protected override void OnDrawItem(DrawListViewItemEventArgs e) 112 | { 113 | Graphics g = e.Graphics; 114 | 115 | g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; 116 | 117 | // Always draw default background 118 | g.FillRectangle(SkinManager.BackgroundBrush, e.Bounds); 119 | 120 | if (e.Item.Selected) 121 | { 122 | // Selected background 123 | g.FillRectangle(SkinManager.BackgroundFocusBrush, e.Bounds); 124 | } 125 | else if (e.Bounds.Contains(MouseLocation) && MouseState == MouseState.HOVER) 126 | { 127 | // Hover background 128 | g.FillRectangle(SkinManager.BackgroundHoverBrush, e.Bounds); 129 | } 130 | 131 | // Draw separator line 132 | g.DrawLine(new Pen(SkinManager.DividersColor), e.Bounds.Left, e.Bounds.Y, e.Bounds.Right, e.Bounds.Y); 133 | 134 | foreach (ListViewItem.ListViewSubItem subItem in e.Item.SubItems) 135 | { 136 | // Draw Text 137 | using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) 138 | { 139 | NativeText.DrawTransparentText( 140 | subItem.Text, 141 | SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body2), 142 | Enabled ? SkinManager.TextHighEmphasisNoAlphaColor : SkinManager.TextDisabledOrHintColor, 143 | new Point(subItem.Bounds.X + PAD, subItem.Bounds.Y), 144 | new Size(subItem.Bounds.Width - PAD * 2, subItem.Bounds.Height), 145 | NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); 146 | } 147 | } 148 | } 149 | 150 | // Resize 151 | protected override void OnColumnWidthChanging(ColumnWidthChangingEventArgs e) 152 | { 153 | base.OnColumnWidthChanging(e); 154 | AutoResize(); 155 | } 156 | 157 | protected override void OnColumnWidthChanged(ColumnWidthChangedEventArgs e) 158 | { 159 | base.OnColumnWidthChanged(e); 160 | AutoResize(); 161 | } 162 | 163 | protected override void OnResize(EventArgs e) 164 | { 165 | base.OnResize(e); 166 | AutoResize(); 167 | } 168 | 169 | private void AutoResize() 170 | { 171 | if (!AutoSizeTable) return; 172 | 173 | // Width 174 | int w = 0; 175 | foreach (ColumnHeader col in Columns) 176 | { 177 | w += col.Width; 178 | } 179 | 180 | // Height 181 | int h = 50; //Header size 182 | if (Items.Count > 0) h = TopItem.Bounds.Top; 183 | foreach (ListViewItem item in Items) 184 | { 185 | h += item.Bounds.Height; 186 | } 187 | 188 | Size = new Size(w, h); 189 | } 190 | 191 | protected override void InitLayout() 192 | { 193 | base.InitLayout(); 194 | 195 | // enforce settings 196 | GridLines = false; 197 | FullRowSelect = true; 198 | View = View.Details; 199 | OwnerDraw = true; 200 | ResizeRedraw = true; 201 | BorderStyle = BorderStyle.None; 202 | } 203 | 204 | protected override void OnCreateControl() 205 | { 206 | base.OnCreateControl(); 207 | } 208 | 209 | protected override void OnBackColorChanged(EventArgs e) 210 | { 211 | base.OnBackColorChanged(e); 212 | BackColor = SkinManager.BackgroundColor; 213 | } 214 | } 215 | } 216 | -------------------------------------------------------------------------------- /MaterialSkin/MaterialSkin.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {8EB7611B-68CD-4B8B-987A-11717E2B250C} 8 | Library 9 | Properties 10 | MaterialSkin 11 | MaterialSkin 12 | v4.6.1 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | Component 49 | 50 | 51 | Form 52 | 53 | 54 | Component 55 | 56 | 57 | Component 58 | 59 | 60 | Component 61 | 62 | 63 | Component 64 | 65 | 66 | Form 67 | 68 | 69 | Form 70 | 71 | 72 | Component 73 | 74 | 75 | Component 76 | 77 | 78 | Component 79 | 80 | 81 | Component 82 | 83 | 84 | Component 85 | 86 | 87 | Component 88 | 89 | 90 | Component 91 | 92 | 93 | Component 94 | 95 | 96 | Component 97 | 98 | 99 | Form 100 | 101 | 102 | Component 103 | 104 | 105 | Component 106 | 107 | 108 | 109 | Component 110 | 111 | 112 | Component 113 | 114 | 115 | Component 116 | 117 | 118 | Component 119 | 120 | 121 | Component 122 | 123 | 124 | Component 125 | 126 | 127 | Component 128 | 129 | 130 | Component 131 | 132 | 133 | Component 134 | 135 | 136 | Component 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | True 149 | True 150 | Resources.resx 151 | 152 | 153 | Settings.settings 154 | True 155 | True 156 | 157 | 158 | 159 | 160 | FlexibleMaterialDialog.cs 161 | 162 | 163 | MaterialForm.cs 164 | 165 | 166 | PublicResXFileCodeGenerator 167 | Resources.Designer.cs 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | SettingsSingleFileGenerator 187 | Settings.Designer.cs 188 | 189 | 190 | 191 | 198 | -------------------------------------------------------------------------------- /MaterialSkin/Controls/MaterialContextMenuStrip.cs: -------------------------------------------------------------------------------- 1 | namespace MaterialSkin.Controls 2 | { 3 | using MaterialSkin.Animations; 4 | using System.ComponentModel; 5 | using System.Drawing; 6 | using System.Drawing.Drawing2D; 7 | using System.Drawing.Text; 8 | using System.Windows.Forms; 9 | 10 | [ToolboxItem(false)] 11 | public class MaterialContextMenuStrip : ContextMenuStrip, IMaterialControl 12 | { 13 | //Properties for managing the material design properties 14 | [Browsable(false)] 15 | public int Depth { get; set; } 16 | 17 | [Browsable(false)] 18 | public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; 19 | 20 | [Browsable(false)] 21 | public MouseState MouseState { get; set; } 22 | 23 | internal AnimationManager AnimationManager; 24 | 25 | internal Point AnimationSource; 26 | 27 | public delegate void ItemClickStart(object sender, ToolStripItemClickedEventArgs e); 28 | 29 | public event ItemClickStart OnItemClickStart; 30 | 31 | public MaterialContextMenuStrip() 32 | { 33 | Renderer = new MaterialToolStripRender(); 34 | 35 | AnimationManager = new AnimationManager(false) 36 | { 37 | Increment = 0.07, 38 | AnimationType = AnimationType.Linear 39 | }; 40 | AnimationManager.OnAnimationProgress += sender => Invalidate(); 41 | AnimationManager.OnAnimationFinished += sender => OnItemClicked(_delayesArgs); 42 | 43 | BackColor = SkinManager.BackdropColor; 44 | } 45 | 46 | protected override void OnMouseUp(MouseEventArgs mea) 47 | { 48 | base.OnMouseUp(mea); 49 | 50 | AnimationSource = mea.Location; 51 | } 52 | 53 | private ToolStripItemClickedEventArgs _delayesArgs; 54 | 55 | protected override void OnItemClicked(ToolStripItemClickedEventArgs e) 56 | { 57 | if (e.ClickedItem != null && !(e.ClickedItem is ToolStripSeparator)) 58 | { 59 | if (e == _delayesArgs) 60 | { 61 | //The event has been fired manualy because the args are the ones we saved for delay 62 | base.OnItemClicked(e); 63 | } 64 | else 65 | { 66 | //Interrupt the default on click, saving the args for the delay which is needed to display the animaton 67 | _delayesArgs = e; 68 | 69 | //Fire custom event to trigger actions directly but keep cms open 70 | OnItemClickStart?.Invoke(this, e); 71 | 72 | //Start animation 73 | AnimationManager.StartNewAnimation(AnimationDirection.In); 74 | } 75 | } 76 | } 77 | } 78 | 79 | public class MaterialToolStripMenuItem : ToolStripMenuItem 80 | { 81 | public MaterialToolStripMenuItem() 82 | { 83 | AutoSize = false; 84 | Size = new Size(128, 32); 85 | } 86 | 87 | protected override ToolStripDropDown CreateDefaultDropDown() 88 | { 89 | var baseDropDown = base.CreateDefaultDropDown(); 90 | if (DesignMode) return baseDropDown; 91 | 92 | var defaultDropDown = new MaterialContextMenuStrip(); 93 | defaultDropDown.Items.AddRange(baseDropDown.Items); 94 | 95 | return defaultDropDown; 96 | } 97 | } 98 | 99 | internal class MaterialToolStripRender : ToolStripProfessionalRenderer, IMaterialControl 100 | { 101 | private const int LEFT_PADDING = 16; 102 | private const int RIGHT_PADDING = 8; 103 | 104 | //Properties for managing the material design properties 105 | public int Depth { get; set; } 106 | 107 | public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; 108 | 109 | public MouseState MouseState { get; set; } 110 | 111 | protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) 112 | { 113 | var g = e.Graphics; 114 | g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; 115 | 116 | var itemRect = GetItemRect(e.Item); 117 | var textRect = new Rectangle(LEFT_PADDING, itemRect.Y, itemRect.Width - (LEFT_PADDING + RIGHT_PADDING), itemRect.Height); 118 | 119 | using (NativeTextRenderer NativeText = new NativeTextRenderer(g)) 120 | { 121 | NativeText.DrawTransparentText(e.Text, SkinManager.getLogFontByType(MaterialSkinManager.fontType.Body2), 122 | e.Item.Enabled ? SkinManager.TextHighEmphasisColor : SkinManager.TextDisabledOrHintColor, 123 | textRect.Location, 124 | textRect.Size, 125 | NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Middle); 126 | } 127 | } 128 | 129 | protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) 130 | { 131 | var g = e.Graphics; 132 | g.Clear(SkinManager.BackgroundColor); 133 | 134 | //Draw background 135 | var itemRect = GetItemRect(e.Item); 136 | g.FillRectangle(e.Item.Selected && e.Item.Enabled ? SkinManager.BackgroundFocusBrush : SkinManager.BackgroundBrush, itemRect); 137 | 138 | //Ripple animation 139 | var toolStrip = e.ToolStrip as MaterialContextMenuStrip; 140 | if (toolStrip != null) 141 | { 142 | var animationManager = toolStrip.AnimationManager; 143 | var animationSource = toolStrip.AnimationSource; 144 | if (toolStrip.AnimationManager.IsAnimating() && e.Item.Bounds.Contains(animationSource)) 145 | { 146 | for (int i = 0; i < animationManager.GetAnimationCount(); i++) 147 | { 148 | var animationValue = animationManager.GetProgress(i); 149 | var rippleBrush = new SolidBrush(Color.FromArgb((int)(51 - (animationValue * 50)), Color.Black)); 150 | var rippleSize = (int)(animationValue * itemRect.Width * 2.5); 151 | g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, itemRect.Y - itemRect.Height, rippleSize, itemRect.Height * 3)); 152 | } 153 | } 154 | } 155 | } 156 | 157 | protected override void OnRenderImageMargin(ToolStripRenderEventArgs e) 158 | { 159 | } 160 | 161 | protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e) 162 | { 163 | var g = e.Graphics; 164 | 165 | g.FillRectangle(SkinManager.BackgroundBrush, e.Item.Bounds); 166 | g.DrawLine( 167 | new Pen(SkinManager.DividersColor), 168 | new Point(e.Item.Bounds.Left, e.Item.Bounds.Height / 2), 169 | new Point(e.Item.Bounds.Right, e.Item.Bounds.Height / 2)); 170 | } 171 | 172 | protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) 173 | { 174 | e.ToolStrip.BackColor = SkinManager.BackgroundColor; 175 | } 176 | 177 | protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) 178 | { 179 | var g = e.Graphics; 180 | const int ARROW_SIZE = 4; 181 | 182 | var arrowMiddle = new Point(e.ArrowRectangle.X + e.ArrowRectangle.Width / 2, e.ArrowRectangle.Y + e.ArrowRectangle.Height / 2); 183 | var arrowBrush = e.Item.Enabled ? SkinManager.TextHighEmphasisBrush : SkinManager.TextDisabledOrHintBrush; 184 | using (var arrowPath = new GraphicsPath()) 185 | { 186 | arrowPath.AddLines( 187 | new[] { 188 | new Point(arrowMiddle.X - ARROW_SIZE, arrowMiddle.Y - ARROW_SIZE), 189 | new Point(arrowMiddle.X, arrowMiddle.Y), 190 | new Point(arrowMiddle.X - ARROW_SIZE, arrowMiddle.Y + ARROW_SIZE) }); 191 | arrowPath.CloseFigure(); 192 | 193 | g.FillPath(arrowBrush, arrowPath); 194 | } 195 | } 196 | 197 | private Rectangle GetItemRect(ToolStripItem item) 198 | { 199 | return new Rectangle(0, item.ContentRectangle.Y, item.ContentRectangle.Width , item.ContentRectangle.Height); 200 | } 201 | } 202 | } 203 | -------------------------------------------------------------------------------- /MaterialSkin/Controls/BaseTextBox.cs: -------------------------------------------------------------------------------- 1 | namespace MaterialSkin.Controls 2 | { 3 | using System; 4 | using System.ComponentModel; 5 | using System.Drawing; 6 | using System.Windows.Forms; 7 | 8 | [ToolboxItem(false)] 9 | public class BaseTextBox : TextBox, IMaterialControl 10 | { 11 | #region "Public Properties" 12 | 13 | //Properties for managing the material design properties 14 | [Browsable(false)] 15 | public int Depth { get; set; } 16 | 17 | [Browsable(false)] 18 | public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; 19 | 20 | [Browsable(false)] 21 | public MouseState MouseState { get; set; } 22 | 23 | private string hint = string.Empty; 24 | public string Hint 25 | { 26 | get { return hint; } 27 | set 28 | { 29 | hint = value; 30 | Invalidate(); 31 | } 32 | } 33 | 34 | public new void SelectAll() 35 | { 36 | BeginInvoke((MethodInvoker)delegate () 37 | { 38 | base.Focus(); 39 | base.SelectAll(); 40 | }); 41 | } 42 | 43 | #endregion 44 | 45 | public BaseTextBox() 46 | { 47 | } 48 | 49 | 50 | protected override void OnGotFocus(EventArgs e) 51 | { 52 | base.OnGotFocus(e); 53 | Invalidate(); 54 | } 55 | 56 | protected override void OnLostFocus(EventArgs e) 57 | { 58 | base.OnLostFocus(e); 59 | Invalidate(); 60 | } 61 | 62 | private const int WM_ENABLE = 0x0A; 63 | private const int WM_PAINT = 0xF; 64 | private const UInt32 WM_USER = 0x0400; 65 | private const UInt32 EM_SETBKGNDCOLOR = (WM_USER + 67); 66 | private const UInt32 WM_KILLFOCUS = 0x0008; 67 | protected override void WndProc(ref Message m) 68 | { 69 | base.WndProc(ref m); 70 | 71 | 72 | if (m.Msg == WM_PAINT) 73 | { 74 | if (m.Msg == WM_ENABLE) 75 | { 76 | Graphics g = Graphics.FromHwnd(Handle); 77 | Rectangle bounds = new Rectangle(0, 0, Width, Height); 78 | g.FillRectangle(SkinManager.BackgroundDisabledBrush, bounds); 79 | } 80 | } 81 | 82 | if (m.Msg == WM_PAINT && String.IsNullOrEmpty(Text) && !Focused) 83 | { 84 | using (NativeTextRenderer NativeText = new NativeTextRenderer(Graphics.FromHwnd(m.HWnd))) 85 | { 86 | NativeText.DrawTransparentText( 87 | Hint, 88 | SkinManager.getFontByType(MaterialSkinManager.fontType.Subtitle1), 89 | Enabled ? 90 | ColorHelper.RemoveAlpha(SkinManager.TextMediumEmphasisColor, BackColor) : // not focused 91 | ColorHelper.RemoveAlpha(SkinManager.TextDisabledOrHintColor, BackColor), // Disabled 92 | ClientRectangle.Location, 93 | ClientRectangle.Size, 94 | NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Top); 95 | } 96 | } 97 | 98 | if (m.Msg == EM_SETBKGNDCOLOR) 99 | { 100 | Invalidate(); 101 | } 102 | 103 | if (m.Msg == WM_KILLFOCUS) //set border back to normal on lost focus 104 | { 105 | Invalidate(); 106 | } 107 | 108 | } 109 | 110 | } 111 | 112 | [ToolboxItem(false)] 113 | public class BaseMaskedTextBox : MaskedTextBox, IMaterialControl 114 | { 115 | //Properties for managing the material design properties 116 | [Browsable(false)] 117 | public int Depth { get; set; } 118 | 119 | [Browsable(false)] 120 | public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; 121 | 122 | [Browsable(false)] 123 | public MouseState MouseState { get; set; } 124 | 125 | private string hint = string.Empty; 126 | public string Hint 127 | { 128 | get { return hint; } 129 | set 130 | { 131 | hint = value; 132 | Invalidate(); 133 | } 134 | } 135 | 136 | public new void SelectAll() 137 | { 138 | BeginInvoke((MethodInvoker)delegate () 139 | { 140 | base.Focus(); 141 | base.SelectAll(); 142 | }); 143 | } 144 | 145 | 146 | public BaseMaskedTextBox() 147 | { 148 | } 149 | 150 | protected override void OnGotFocus(EventArgs e) 151 | { 152 | base.OnGotFocus(e); 153 | Invalidate(); 154 | } 155 | 156 | protected override void OnLostFocus(EventArgs e) 157 | { 158 | base.OnLostFocus(e); 159 | Invalidate(); 160 | } 161 | 162 | private const int WM_ENABLE = 0x0A; 163 | private const int WM_PAINT = 0xF; 164 | private const UInt32 WM_USER = 0x0400; 165 | private const UInt32 EM_SETBKGNDCOLOR = (WM_USER + 67); 166 | private const UInt32 WM_KILLFOCUS = 0x0008; 167 | protected override void WndProc(ref Message m) 168 | { 169 | base.WndProc(ref m); 170 | 171 | 172 | if (m.Msg == WM_PAINT) 173 | { 174 | if (m.Msg == WM_ENABLE) 175 | { 176 | Graphics g = Graphics.FromHwnd(Handle); 177 | Rectangle bounds = new Rectangle(0, 0, Width, Height); 178 | g.FillRectangle(SkinManager.BackgroundDisabledBrush, bounds); 179 | } 180 | } 181 | 182 | if (m.Msg == WM_PAINT && String.IsNullOrEmpty(Text) && !Focused) 183 | { 184 | using (NativeTextRenderer NativeText = new NativeTextRenderer(Graphics.FromHwnd(m.HWnd))) 185 | { 186 | NativeText.DrawTransparentText( 187 | Hint, 188 | SkinManager.getFontByType(MaterialSkinManager.fontType.Subtitle1), 189 | Enabled ? 190 | ColorHelper.RemoveAlpha(SkinManager.TextMediumEmphasisColor, BackColor) : // not focused 191 | ColorHelper.RemoveAlpha(SkinManager.TextDisabledOrHintColor, BackColor), // Disabled 192 | ClientRectangle.Location, 193 | ClientRectangle.Size, 194 | NativeTextRenderer.TextAlignFlags.Left | NativeTextRenderer.TextAlignFlags.Top); 195 | } 196 | } 197 | 198 | if (m.Msg == EM_SETBKGNDCOLOR) 199 | { 200 | Invalidate(); 201 | } 202 | 203 | if (m.Msg == WM_KILLFOCUS) //set border back to normal on lost focus 204 | { 205 | Invalidate(); 206 | } 207 | 208 | } 209 | } 210 | 211 | [ToolboxItem(false)] 212 | public class BaseTextBoxContextMenuStrip : MaterialContextMenuStrip 213 | { 214 | public readonly ToolStripItem undo = new MaterialToolStripMenuItem { Text = "Undo" }; 215 | public readonly ToolStripItem seperator1 = new ToolStripSeparator(); 216 | public readonly ToolStripItem cut = new MaterialToolStripMenuItem { Text = "Cut" }; 217 | public readonly ToolStripItem copy = new MaterialToolStripMenuItem { Text = "Copy" }; 218 | public readonly ToolStripItem paste = new MaterialToolStripMenuItem { Text = "Paste" }; 219 | public readonly ToolStripItem delete = new MaterialToolStripMenuItem { Text = "Delete" }; 220 | public readonly ToolStripItem seperator2 = new ToolStripSeparator(); 221 | public readonly ToolStripItem selectAll = new MaterialToolStripMenuItem { Text = "Select All" }; 222 | 223 | public BaseTextBoxContextMenuStrip() 224 | { 225 | Items.AddRange(new[] 226 | { 227 | undo, 228 | seperator1, 229 | cut, 230 | copy, 231 | paste, 232 | delete, 233 | seperator2, 234 | selectAll 235 | }); 236 | } 237 | } 238 | 239 | } 240 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MaterialSkin 2 for .NET WinForms 2 | 3 | Theming .NET WinForms, C# or VB.Net, to Google's Material Design Principles. 4 | 5 | > ⚠️ **It's NOT recommended to use this lib for new projects** ⚠️ 6 | > 7 | > ❓For new projects I recommend [WPF with this Material Design Xaml Toolkit](https://github.com/ButchersBoy/MaterialDesignInXamlToolkit) since it's a lot newer and performant and feature complete 8 | > 9 | > ℹ️ The current state of this project state is: **not active** 10 | 11 | ## Contributing 12 | 13 | - Feel free to open a PR with new features or bug fixes. Since this project is not currently active, big changes will not be considered. 14 | - Support this and more projects by donating: 15 | 16 | [![Paypal](https://user-images.githubusercontent.com/8310271/225498353-9d0a672d-ed45-4fed-9838-11d71ee49c28.png)](https://www.paypal.com/donate/?hosted_button_id=683D7S6KLX7EA) 17 | 18 | ## A quick look 19 | 20 | ![home](https://user-images.githubusercontent.com/77468294/134770847-0f20f37f-e3e7-4e15-b838-cf53b0b32c4e.png) 21 | 22 | ## Nuget Package 23 | 24 | A nuget package version is available [here](https://www.nuget.org/packages/MaterialSkin.2/) 25 | 26 | Or simply search for MaterialSkin.2 on the **Nuget Package Manager** inside Visual Studio 27 | 28 | ## WIKI Available! 29 | 30 | But there's not much in there for now, please contribute if you can. :smile: 31 | 32 | You can access it [here](https://github.com/leocb/MaterialSkin/wiki) 33 | 34 | ## Current state of the MaterialSkin components 35 | 36 | | Component | Supported | Disabled mode | Animated | 37 | | ---------------------------- | :-------: | :-----------: | :------: | 38 | | Backdrop | **No** | - | - | 39 | | Banner | **No** | - | - | 40 | | Buttons | Yes | Yes | Yes | 41 | | Cards | Yes | N/A | N/A | 42 | | Check Box | Yes | Yes | Yes | 43 | | Check Box List | Yes | Yes | Yes | 44 | | Chips | **No** | - | - | 45 | | Combobox | Yes | Yes | Yes | 46 | | Context Menu | Yes | Yes | Yes | 47 | | Date Picker | **No** | - | - | 48 | | Dialog | Yes | N/A | **No** | 49 | | Divider | Yes | N/A | N/A | 50 | | Drawer | Yes | N/A | Yes | 51 | | Expansion Panel | Yes | Yes | **No** | 52 | | Flexible Dialog (big) | Yes | Yes | N/A | 53 | | FAB - Floating Action Button | Yes | Yes | Yes | 54 | | Label | Yes | Yes | N/A | 55 | | ListBox | Yes | Yes | N/A | 56 | | ListView | Yes | **No** | N/A | 57 | | Progress Bar | _Partial_ | **No** | **No** | 58 | | Radio Button | Yes | Yes | Yes | 59 | | Text field | Yes | Yes | Yes | 60 | | Sliders | Yes | Yes | **No** | 61 | | SnackBar | Yes | N/A | Yes | 62 | | Switch | Yes | Yes | Yes | 63 | | Tabs | Yes | N/A | Yes | 64 | | Time Picker | **No** | - | - | 65 | | Tooltips | **No** | - | - | 66 | 67 | All supported components have a dark theme 68 | 69 | ## TODO List 70 | 71 | - [ ] Progress bar - Animation and variants, maybe round loading thingy 72 | - [ ] Backdrop (maybe) 73 | - [ ] Some Color code improvements and refactoring 74 | - [ ] DatePicker 75 | - [ ] Drawer - Header, Divider, subtitle & submenu 76 | - [ ] Textfield ContextualMenu translation 77 | - [ ] Controls code cleanup 78 | - [ ] Add Noto font support 79 | 80 | --- 81 | 82 | ## Contributing 83 | 84 | Thanks for taking the time to contribute! :+1: 85 | 86 | If you have any issues please open an issue; have an improvement? open a pull request. 87 | 88 | > - This project was heavily updated by [@leocb](https://github.com/leocb/MaterialSkin) 89 | > - Currently it's kept alive by [@orapps44](https://github.com/orapps44/MaterialSkin) 90 | > - forked from [@donaldsteele](https://github.com/donaldsteele/MaterialSkin) 91 | > - and he forked it from the original [@IgnaceMaes](https://github.com/IgnaceMaes/MaterialSkin) 92 | 93 | ## Contributors 94 | 95 | Thank you to all the people who have already contributed to MaterialSkin 2 ! 96 | 97 | 98 | 99 | 100 | 101 | 102 | --- 103 | 104 | ## Implementing MaterialSkin 2 in your application 105 | 106 | ### 1. Add the library to your project 107 | 108 | There are a few methods to add this lib: 109 | 110 | #### The Easy way 111 | 112 | Search for MaterialSkin.2 on the Nuget Package manager inside VisualStudio and add it to your project. 113 | 114 | #### Manual way 115 | 116 | Download the precompiled DLL available on the releases section and add it as a external reference on your project. 117 | 118 | #### Compile from the latest master 119 | 120 | Clone the project from GitHub, then add the MaterialSkin.csproj to your own solution, then add it as a project reference on your project. 121 | 122 | ### 2. Add the MaterialSkin components to your ToolBox 123 | 124 | Simply drag the MaterialSkin.dll file into your IDE's ToolBox and all the controls should be added there. 125 | 126 | ### 3. Inherit from MaterialForm 127 | 128 | Open the code behind your Form you wish to skin. Make it inherit from MaterialForm rather than Form. Don't forget to put the library in your imports, so it can find the MaterialForm class! 129 | 130 | #### C# (Form1.cs) 131 | 132 | ```cs 133 | public partial class Form1 : MaterialForm 134 | ``` 135 | 136 | #### VB.NET (Form1.Designer.vb) 137 | 138 | ```vb 139 | Partial Class Form1 140 | Inherits MaterialSkin.Controls.MaterialForm 141 | ``` 142 | 143 | ### 4. Initialize your colorscheme 144 | 145 | Set your preferred colors & theme. Also add the form to the manager so it keeps updated if the color scheme or theme changes later on. 146 | 147 | #### C# (Form1.cs) 148 | 149 | ```cs 150 | public Form1() 151 | { 152 | InitializeComponent(); 153 | 154 | var materialSkinManager = MaterialSkinManager.Instance; 155 | materialSkinManager.AddFormToManage(this); 156 | materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT; 157 | materialSkinManager.ColorScheme = new ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE); 158 | } 159 | ``` 160 | 161 | #### VB.NET (Form1.vb) 162 | 163 | ```vb 164 | Imports MaterialSkin 165 | 166 | Public Class Form1 167 | 168 | Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 169 | Dim SkinManager As MaterialSkinManager = MaterialSkinManager.Instance 170 | SkinManager.AddFormToManage(Me) 171 | SkinManager.Theme = MaterialSkinManager.Themes.LIGHT 172 | SkinManager.ColorScheme = New ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE) 173 | End Sub 174 | End Class 175 | ``` 176 | 177 | --- 178 | 179 | ## Material Design in WPF 180 | 181 | If you love .NET and Material Design, you should definitely check out [Material Design Xaml Toolkit](https://github.com/ButchersBoy/MaterialDesignInXamlToolkit) by ButchersBoy. It's a similar project but for WPF instead of WinForms. 182 | 183 | --- 184 | 185 | ## Preview! 186 | 187 | *A simple demo interface with MaterialSkin components.* 188 | ![home](https://user-images.githubusercontent.com/77468294/134770847-0f20f37f-e3e7-4e15-b838-cf53b0b32c4e.png) 189 | 190 | *The MaterialSkin Drawer (menu).* 191 | ![drawer](https://user-images.githubusercontent.com/77468294/119880600-b4570480-bf2c-11eb-9a83-e2d59b88bf22.png) 192 | 193 | *Every MaterialSkin button variant - this is 1 control, 3 properties* 194 | ![buttons](https://user-images.githubusercontent.com/77468294/119880777-e1a3b280-bf2c-11eb-8042-45b767459b41.png) 195 | 196 | *The MaterialSkin checkboxes, radio and Switch.* 197 | ![selection](https://user-images.githubusercontent.com/77468294/134740844-795cd759-e4dc-4592-b2c1-86896e61f66f.png) 198 | 199 | *Material skin textfield* 200 | ![text](https://user-images.githubusercontent.com/77468294/134825517-23f517e7-0793-4c4c-bcb2-6c2c2fb36b4a.png) 201 | 202 | *Table control* 203 | ![table](https://user-images.githubusercontent.com/8310271/66237915-a1931a80-e6cc-11e9-8e68-bc919f533366.png) 204 | 205 | *Progress bar* 206 | ![progress bar](https://user-images.githubusercontent.com/77468294/119880969-131c7e00-bf2d-11eb-9ec6-b00e928e59ed.png) 207 | 208 | *Cards* 209 | ![cards](https://user-images.githubusercontent.com/77468294/119881312-6f7f9d80-bf2d-11eb-93b8-e4dc58dc3a4e.png) 210 | 211 | *List Box* 212 | ![listbox](https://user-images.githubusercontent.com/77468294/119881063-2891a800-bf2d-11eb-93d8-d0395dc1f19e.png) 213 | 214 | *Expansion Panel* 215 | ![expansion](https://user-images.githubusercontent.com/77468294/119881153-419a5900-bf2d-11eb-95a2-ab29089acdd3.png) 216 | 217 | *Label* 218 | ![label](https://user-images.githubusercontent.com/77468294/132769098-440841c8-07d2-4b9b-bff7-e525402525dd.png) 219 | 220 | *MaterialSkin using a custom color scheme.* 221 | ![custom](https://user-images.githubusercontent.com/77468294/119881411-8e7e2f80-bf2d-11eb-9fa3-883eceabfadc.png) 222 | 223 | *FlexibleMaterial Messagebox* 224 | ![messagebox](https://user-images.githubusercontent.com/8310271/66238105-25e59d80-e6cd-11e9-88c9-5a21ceae1a5a.png) 225 | -------------------------------------------------------------------------------- /MaterialSkinExample/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace MaterialSkinExample.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MaterialSkinExample.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Bitmap. 65 | /// 66 | internal static System.Drawing.Bitmap baseline_bluetooth_black_24dp { 67 | get { 68 | object obj = ResourceManager.GetObject("baseline_bluetooth_black_24dp", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// Looks up a localized resource of type System.Drawing.Bitmap. 75 | /// 76 | internal static System.Drawing.Bitmap baseline_build_black_24dp { 77 | get { 78 | object obj = ResourceManager.GetObject("baseline_build_black_24dp", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | 83 | /// 84 | /// Looks up a localized resource of type System.Drawing.Bitmap. 85 | /// 86 | internal static System.Drawing.Bitmap baseline_favorite_border_black_24dp { 87 | get { 88 | object obj = ResourceManager.GetObject("baseline_favorite_border_black_24dp", resourceCulture); 89 | return ((System.Drawing.Bitmap)(obj)); 90 | } 91 | } 92 | 93 | /// 94 | /// Looks up a localized resource of type System.Drawing.Bitmap. 95 | /// 96 | internal static System.Drawing.Bitmap baseline_fingerprint_black_24dp { 97 | get { 98 | object obj = ResourceManager.GetObject("baseline_fingerprint_black_24dp", resourceCulture); 99 | return ((System.Drawing.Bitmap)(obj)); 100 | } 101 | } 102 | 103 | /// 104 | /// Looks up a localized resource of type System.Drawing.Bitmap. 105 | /// 106 | internal static System.Drawing.Bitmap baseline_thumb_up_black_24dp { 107 | get { 108 | object obj = ResourceManager.GetObject("baseline_thumb_up_black_24dp", resourceCulture); 109 | return ((System.Drawing.Bitmap)(obj)); 110 | } 111 | } 112 | 113 | /// 114 | /// Looks up a localized resource of type System.Drawing.Bitmap. 115 | /// 116 | internal static System.Drawing.Bitmap minus { 117 | get { 118 | object obj = ResourceManager.GetObject("minus", resourceCulture); 119 | return ((System.Drawing.Bitmap)(obj)); 120 | } 121 | } 122 | 123 | /// 124 | /// Looks up a localized resource of type System.Drawing.Bitmap. 125 | /// 126 | internal static System.Drawing.Bitmap plus { 127 | get { 128 | object obj = ResourceManager.GetObject("plus", resourceCulture); 129 | return ((System.Drawing.Bitmap)(obj)); 130 | } 131 | } 132 | 133 | /// 134 | /// Recherche une ressource localisée de type System.Drawing.Bitmap. 135 | /// 136 | internal static System.Drawing.Bitmap round_add_black_24dp { 137 | get { 138 | object obj = ResourceManager.GetObject("round_add_black_24dp", resourceCulture); 139 | return ((System.Drawing.Bitmap)(obj)); 140 | } 141 | } 142 | 143 | /// 144 | /// Looks up a localized resource of type System.Drawing.Bitmap. 145 | /// 146 | internal static System.Drawing.Bitmap round_assessment_white_24dp { 147 | get { 148 | object obj = ResourceManager.GetObject("round_assessment_white_24dp", resourceCulture); 149 | return ((System.Drawing.Bitmap)(obj)); 150 | } 151 | } 152 | 153 | /// 154 | /// Looks up a localized resource of type System.Drawing.Bitmap. 155 | /// 156 | internal static System.Drawing.Bitmap round_backup_white_24dp { 157 | get { 158 | object obj = ResourceManager.GetObject("round_backup_white_24dp", resourceCulture); 159 | return ((System.Drawing.Bitmap)(obj)); 160 | } 161 | } 162 | 163 | /// 164 | /// Looks up a localized resource of type System.Drawing.Bitmap. 165 | /// 166 | internal static System.Drawing.Bitmap round_bluetooth_white_24dp { 167 | get { 168 | object obj = ResourceManager.GetObject("round_bluetooth_white_24dp", resourceCulture); 169 | return ((System.Drawing.Bitmap)(obj)); 170 | } 171 | } 172 | 173 | /// 174 | /// Looks up a localized resource of type System.Drawing.Bitmap. 175 | /// 176 | internal static System.Drawing.Bitmap round_bookmark_white_24dp { 177 | get { 178 | object obj = ResourceManager.GetObject("round_bookmark_white_24dp", resourceCulture); 179 | return ((System.Drawing.Bitmap)(obj)); 180 | } 181 | } 182 | 183 | /// 184 | /// Looks up a localized resource of type System.Drawing.Bitmap. 185 | /// 186 | internal static System.Drawing.Bitmap round_build_white_24dp { 187 | get { 188 | object obj = ResourceManager.GetObject("round_build_white_24dp", resourceCulture); 189 | return ((System.Drawing.Bitmap)(obj)); 190 | } 191 | } 192 | 193 | /// 194 | /// Looks up a localized resource of type System.Drawing.Bitmap. 195 | /// 196 | internal static System.Drawing.Bitmap round_gps_fixed_white_24dp { 197 | get { 198 | object obj = ResourceManager.GetObject("round_gps_fixed_white_24dp", resourceCulture); 199 | return ((System.Drawing.Bitmap)(obj)); 200 | } 201 | } 202 | 203 | /// 204 | /// Looks up a localized resource of type System.Drawing.Bitmap. 205 | /// 206 | internal static System.Drawing.Bitmap round_http_white_24dp { 207 | get { 208 | object obj = ResourceManager.GetObject("round_http_white_24dp", resourceCulture); 209 | return ((System.Drawing.Bitmap)(obj)); 210 | } 211 | } 212 | 213 | /// 214 | /// Recherche une ressource localisée de type System.Drawing.Bitmap. 215 | /// 216 | internal static System.Drawing.Bitmap round_phone_black_24dp { 217 | get { 218 | object obj = ResourceManager.GetObject("round_phone_black_24dp", resourceCulture); 219 | return ((System.Drawing.Bitmap)(obj)); 220 | } 221 | } 222 | 223 | /// 224 | /// Looks up a localized resource of type System.Drawing.Bitmap. 225 | /// 226 | internal static System.Drawing.Bitmap round_report_problem_white_24dp { 227 | get { 228 | object obj = ResourceManager.GetObject("round_report_problem_white_24dp", resourceCulture); 229 | return ((System.Drawing.Bitmap)(obj)); 230 | } 231 | } 232 | 233 | /// 234 | /// Looks up a localized resource of type System.Drawing.Bitmap. 235 | /// 236 | internal static System.Drawing.Bitmap round_swap_vert_white_24dp { 237 | get { 238 | object obj = ResourceManager.GetObject("round_swap_vert_white_24dp", resourceCulture); 239 | return ((System.Drawing.Bitmap)(obj)); 240 | } 241 | } 242 | } 243 | } 244 | -------------------------------------------------------------------------------- /MaterialSkinExample/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\Resources\round_report_problem_white_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | 125 | ..\Resources\round_build_white_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 126 | 127 | 128 | ..\Resources\round_swap_vert_white_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 129 | 130 | 131 | ..\Resources\baseline_thumb_up_black_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 132 | 133 | 134 | ..\Resources\round_gps_fixed_white_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 135 | 136 | 137 | ..\Resources\round_bookmark_white_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 138 | 139 | 140 | ..\Resources\round_assessment_white_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 141 | 142 | 143 | ..\Resources\minus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 144 | 145 | 146 | ..\Resources\round_backup_white_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 147 | 148 | 149 | ..\Resources\plus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 150 | 151 | 152 | ..\Resources\baseline_build_black_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 153 | 154 | 155 | ..\Resources\baseline_fingerprint_black_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 156 | 157 | 158 | ..\Resources\round_http_white_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 159 | 160 | 161 | ..\Resources\round_bluetooth_white_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 162 | 163 | 164 | ..\Resources\baseline_bluetooth_black_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 165 | 166 | 167 | ..\Resources\baseline_favorite_border_black_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 168 | 169 | 170 | ..\Resources\round_add_black_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 171 | 172 | 173 | ..\Resources\round_phone_black_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 174 | 175 | 176 | -------------------------------------------------------------------------------- /MaterialSkin/Controls/MaterialFloatingActionButton.cs: -------------------------------------------------------------------------------- 1 | namespace MaterialSkin.Controls 2 | { 3 | using MaterialSkin.Animations; 4 | using System; 5 | using System.ComponentModel; 6 | using System.Drawing; 7 | using System.Drawing.Drawing2D; 8 | using System.Windows.Forms; 9 | 10 | public class MaterialFloatingActionButton : Button, IMaterialControl 11 | { 12 | [Browsable(false)] 13 | public int Depth { get; set; } 14 | 15 | [Browsable(false)] 16 | public MaterialSkinManager SkinManager => MaterialSkinManager.Instance; 17 | 18 | [Browsable(false)] 19 | public MouseState MouseState { get; set; } 20 | 21 | private const int FAB_SIZE = 56; 22 | private const int FAB_MINI_SIZE = 40; 23 | private const int FAB_ICON_MARGIN = 16; 24 | private const int FAB_MINI_ICON_MARGIN = 8; 25 | private const int FAB_ICON_SIZE = 24; 26 | 27 | private Boolean _mouseHover = false; 28 | 29 | [DefaultValue(true)] 30 | [Category("Material Skin"), DisplayName("Draw Shadows")] 31 | [Description("Draw Shadows around control")] 32 | public bool DrawShadows { get; set; } 33 | 34 | [DefaultValue(false)] 35 | [Category("Material Skin"), DisplayName("Size Mini")] 36 | [Description("Set control size to default or mini")] 37 | public bool Mini 38 | { 39 | get { return _mini; } 40 | set 41 | { 42 | if (Parent != null) 43 | Parent.Invalidate(); 44 | setSize(value); 45 | } 46 | } 47 | 48 | private bool _mini ; 49 | 50 | [DefaultValue(false)] 51 | [Category("Material Skin"), DisplayName("Animate Show HideButton")] 52 | public bool AnimateShowHideButton 53 | { 54 | get { return _animateShowButton; } 55 | set { _animateShowButton = value; Refresh(); } 56 | } 57 | 58 | private bool _animateShowButton; 59 | 60 | [DefaultValue(false)] 61 | [Category("Material Skin")] 62 | [Description("Define icon to display")] 63 | public Image Icon 64 | { 65 | get { return _icon; } 66 | set { _icon = value; Refresh(); } 67 | } 68 | 69 | private Image _icon; 70 | 71 | private bool _isHiding = false; 72 | 73 | private readonly AnimationManager _animationManager; 74 | 75 | private readonly AnimationManager _showAnimationManager; 76 | 77 | public MaterialFloatingActionButton() 78 | { 79 | AnimateShowHideButton = false; 80 | Mini = false; 81 | DrawShadows = true; 82 | SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); 83 | 84 | Size = new Size(FAB_SIZE, FAB_SIZE); 85 | _animationManager = new AnimationManager(false) 86 | { 87 | Increment = 0.03, 88 | AnimationType = AnimationType.EaseOut 89 | }; 90 | _animationManager.OnAnimationProgress += sender => Invalidate(); 91 | 92 | _showAnimationManager = new AnimationManager(true) 93 | { 94 | Increment = 0.1, 95 | AnimationType = AnimationType.EaseOut 96 | }; 97 | _showAnimationManager.OnAnimationProgress += sender => Invalidate(); 98 | _showAnimationManager.OnAnimationFinished += _showAnimationManager_OnAnimationFinished; 99 | } 100 | 101 | protected override void InitLayout() 102 | { 103 | LocationChanged += (sender, e) => { if (DrawShadows) Parent?.Invalidate(); }; 104 | } 105 | 106 | protected override void OnParentChanged(EventArgs e) 107 | { 108 | base.OnParentChanged(e); 109 | if (DrawShadows && Parent != null) AddShadowPaintEvent(Parent, drawShadowOnParent); 110 | if (_oldParent != null) RemoveShadowPaintEvent(_oldParent, drawShadowOnParent); 111 | _oldParent = Parent; 112 | } 113 | 114 | private Control _oldParent; 115 | 116 | protected override void OnVisibleChanged(EventArgs e) 117 | { 118 | base.OnVisibleChanged(e); 119 | if (Parent == null) return; 120 | if (Visible) 121 | AddShadowPaintEvent(Parent, drawShadowOnParent); 122 | else 123 | RemoveShadowPaintEvent(Parent, drawShadowOnParent); 124 | } 125 | 126 | private bool _shadowDrawEventSubscribed = false; 127 | 128 | private void AddShadowPaintEvent(Control control, PaintEventHandler shadowPaintEvent) 129 | { 130 | if (_shadowDrawEventSubscribed) return; 131 | control.Paint += shadowPaintEvent; 132 | control.Invalidate(); 133 | _shadowDrawEventSubscribed = true; 134 | } 135 | 136 | private void RemoveShadowPaintEvent(Control control, PaintEventHandler shadowPaintEvent) 137 | { 138 | if (!_shadowDrawEventSubscribed) return; 139 | control.Paint -= shadowPaintEvent; 140 | control.Invalidate(); 141 | _shadowDrawEventSubscribed = false; 142 | } 143 | 144 | private void setSize(bool mini) 145 | { 146 | _mini = mini; 147 | Size = _mini ? new Size(FAB_MINI_SIZE, FAB_MINI_SIZE) : new Size(FAB_SIZE, FAB_SIZE); 148 | fabBounds = _mini ? new Rectangle(0, 0, FAB_MINI_SIZE, FAB_MINI_SIZE) : new Rectangle(0, 0, FAB_SIZE, FAB_SIZE); 149 | fabBounds.Width -= 1; 150 | fabBounds.Height -= 1; 151 | } 152 | 153 | private void _showAnimationManager_OnAnimationFinished(object sender) 154 | { 155 | if (_isHiding) 156 | { 157 | Visible = false; 158 | _isHiding = false; 159 | } 160 | } 161 | 162 | private void drawShadowOnParent(object sender, PaintEventArgs e) 163 | { 164 | if (Parent == null) 165 | { 166 | RemoveShadowPaintEvent((Control)sender, drawShadowOnParent); 167 | return; 168 | } 169 | 170 | // paint shadow on parent 171 | Graphics gp = e.Graphics; 172 | Rectangle rect = new Rectangle(Location, fabBounds.Size); 173 | gp.SmoothingMode = SmoothingMode.AntiAlias; 174 | DrawHelper.DrawRoundShadow(gp, rect); 175 | } 176 | 177 | private Rectangle fabBounds; 178 | 179 | protected override void OnPaint(PaintEventArgs pevent) 180 | { 181 | var g = pevent.Graphics; 182 | 183 | g.Clear(Parent.BackColor); 184 | g.SmoothingMode = SmoothingMode.AntiAlias; 185 | 186 | // Paint shadow on element to blend with the parent shadow 187 | DrawHelper.DrawRoundShadow(g, fabBounds); 188 | 189 | // draw fab 190 | g.FillEllipse(Enabled ? _mouseHover ? 191 | new SolidBrush(SkinManager.ColorScheme.AccentColor.Lighten(0.25f)) : 192 | SkinManager.ColorScheme.AccentBrush : 193 | new SolidBrush(DrawHelper.BlendColor(SkinManager.ColorScheme.AccentColor, SkinManager.SwitchOffDisabledThumbColor, 197)), 194 | fabBounds); 195 | 196 | if (_animationManager.IsAnimating()) 197 | { 198 | GraphicsPath regionPath = new GraphicsPath(); 199 | regionPath.AddEllipse(new Rectangle(fabBounds.X - 1, fabBounds.Y - 1, fabBounds.Width + 3, fabBounds.Height + 2)); 200 | Region fabRegion = new Region(regionPath); 201 | 202 | GraphicsContainer gcont = g.BeginContainer(); 203 | g.SetClip(fabRegion, CombineMode.Replace); 204 | 205 | for (int i = 0; i < _animationManager.GetAnimationCount(); i++) 206 | { 207 | var animationValue = _animationManager.GetProgress(i); 208 | var animationSource = _animationManager.GetSource(i); 209 | var rippleBrush = new SolidBrush(Color.FromArgb((int)(51 - (animationValue * 50)), Color.White)); 210 | var rippleSize = (int)(animationValue * Width * 2); 211 | g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize)); 212 | } 213 | 214 | g.EndContainer(gcont); 215 | } 216 | 217 | if (Icon != null) 218 | { 219 | g.DrawImage(Icon, new Rectangle(fabBounds.Width / 2 - 11, fabBounds.Height / 2 - 11, 24, 24)); 220 | } 221 | 222 | if (_showAnimationManager.IsAnimating()) 223 | { 224 | int target = Convert.ToInt32((_mini ? FAB_MINI_SIZE : FAB_SIZE) * _showAnimationManager.GetProgress()); 225 | fabBounds.Width = target == 0 ? 1 : target; 226 | fabBounds.Height = target == 0 ? 1 : target; 227 | fabBounds.X = Convert.ToInt32(((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) - (((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) * _showAnimationManager.GetProgress())); 228 | fabBounds.Y = Convert.ToInt32(((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) - (((_mini ? FAB_MINI_SIZE : FAB_SIZE) / 2) * _showAnimationManager.GetProgress())); 229 | } 230 | 231 | // Clip to a round shape with a 1px padding 232 | GraphicsPath clipPath = new GraphicsPath(); 233 | clipPath.AddEllipse(new Rectangle(fabBounds.X - 1, fabBounds.Y - 1, fabBounds.Width + 3, fabBounds.Height + 3)); 234 | Region = new Region(clipPath); 235 | } 236 | 237 | protected override void OnMouseClick(MouseEventArgs mevent) 238 | { 239 | base.OnMouseClick(mevent); 240 | _animationManager.StartNewAnimation(AnimationDirection.In, mevent.Location); 241 | } 242 | 243 | protected override void OnMouseMove(MouseEventArgs e) 244 | { 245 | base.OnMouseMove(e); 246 | 247 | if (DesignMode) 248 | return; 249 | 250 | _mouseHover = ClientRectangle.Contains(e.Location); 251 | Invalidate(); 252 | } 253 | 254 | protected override void OnMouseLeave(EventArgs e) 255 | { 256 | base.OnMouseLeave(e); 257 | if (DesignMode) 258 | return; 259 | 260 | _mouseHover = false; 261 | Invalidate(); 262 | } 263 | 264 | protected override void OnResize(EventArgs e) 265 | { 266 | base.OnResize(e); 267 | 268 | if (DrawShadows && Parent != null) 269 | { 270 | RemoveShadowPaintEvent(Parent, drawShadowOnParent); 271 | AddShadowPaintEvent(Parent, drawShadowOnParent); 272 | } 273 | } 274 | 275 | 276 | private Point origin; 277 | 278 | public new void Hide() 279 | { 280 | if (Visible) 281 | { 282 | _isHiding = true; 283 | _showAnimationManager.StartNewAnimation(AnimationDirection.Out); 284 | } 285 | } 286 | 287 | public new void Show() 288 | { 289 | if (!Visible) 290 | { 291 | origin = Location; 292 | _showAnimationManager.StartNewAnimation(AnimationDirection.In); 293 | Visible = true; 294 | } 295 | } 296 | } 297 | } 298 | -------------------------------------------------------------------------------- /MaterialSkinExample/MainForm.cs: -------------------------------------------------------------------------------- 1 | using MaterialSkin; 2 | using MaterialSkin.Controls; 3 | using System; 4 | using System.Text; 5 | using System.Windows.Forms; 6 | 7 | namespace MaterialSkinExample 8 | { 9 | public partial class MainForm : MaterialForm 10 | { 11 | private readonly MaterialSkinManager materialSkinManager; 12 | 13 | public MainForm() 14 | { 15 | InitializeComponent(); 16 | 17 | // Initialize MaterialSkinManager 18 | materialSkinManager = MaterialSkinManager.Instance; 19 | 20 | // Set this to false to disable backcolor enforcing on non-materialSkin components 21 | // This HAS to be set before the AddFormToManage() 22 | materialSkinManager.EnforceBackcolorOnAllComponents = true; 23 | 24 | // MaterialSkinManager properties 25 | materialSkinManager.AddFormToManage(this); 26 | materialSkinManager.Theme = MaterialSkinManager.Themes.LIGHT; 27 | materialSkinManager.ColorScheme = new ColorScheme(Primary.Indigo500, Primary.Indigo700, Primary.Indigo100, Accent.Pink200, TextShade.WHITE); 28 | 29 | // Add dummy data to the listview 30 | seedListView(); 31 | materialCheckedListBox1.Items.Add("Item1", false); 32 | materialCheckedListBox1.Items.Add("Item2", true); 33 | materialCheckedListBox1.Items.Add("Item3", true); 34 | materialCheckedListBox1.Items.Add("Item4", false); 35 | materialCheckedListBox1.Items.Add("Item5", true); 36 | materialCheckedListBox1.Items.Add("Item6", false); 37 | materialCheckedListBox1.Items.Add("Item7", false); 38 | 39 | materialComboBox6.SelectedIndex = 0; 40 | 41 | materialListBoxFormStyle.Clear(); 42 | foreach (var FormStyleItem in Enum.GetNames(typeof(MaterialForm.FormStyles))) 43 | { 44 | materialListBoxFormStyle.AddItem(FormStyleItem); 45 | if (FormStyleItem == this.FormStyle.ToString()) materialListBoxFormStyle.SelectedIndex = materialListBoxFormStyle.Items.Count-1; 46 | } 47 | 48 | materialListBoxFormStyle.SelectedIndexChanged += (sender, args) => 49 | { 50 | MaterialForm.FormStyles SelectedStyle = (MaterialForm.FormStyles)Enum.Parse(typeof(MaterialForm.FormStyles), args.Text); 51 | if (this.FormStyle!= SelectedStyle) this.FormStyle = SelectedStyle; 52 | }; 53 | 54 | materialMaskedTextBox1.ValidatingType = typeof(System.Int16); 55 | 56 | } 57 | 58 | private void seedListView() 59 | { 60 | //Define 61 | var data = new[] 62 | { 63 | new []{"Lollipop", "392", "0.2", "0"}, 64 | new []{"KitKat", "518", "26.0", "7"}, 65 | new []{"Ice cream sandwich", "237", "9.0", "4.3"}, 66 | new []{"Jelly Bean", "375", "0.0", "0.0"}, 67 | new []{"Honeycomb", "408", "3.2", "6.5"} 68 | }; 69 | 70 | //Add 71 | foreach (string[] version in data) 72 | { 73 | var item = new ListViewItem(version); 74 | materialListView1.Items.Add(item); 75 | } 76 | } 77 | 78 | private void materialButton1_Click(object sender, EventArgs e) 79 | { 80 | materialSkinManager.Theme = materialSkinManager.Theme == MaterialSkinManager.Themes.DARK ? MaterialSkinManager.Themes.LIGHT : MaterialSkinManager.Themes.DARK; 81 | updateColor(); 82 | } 83 | 84 | private int colorSchemeIndex; 85 | 86 | private void MaterialButton1_Click(object sender, EventArgs e) 87 | { 88 | colorSchemeIndex++; 89 | if (colorSchemeIndex > 2) 90 | colorSchemeIndex = 0; 91 | updateColor(); 92 | } 93 | 94 | private void updateColor() 95 | { 96 | //These are just example color schemes 97 | switch (colorSchemeIndex) 98 | { 99 | case 0: 100 | materialSkinManager.ColorScheme = new ColorScheme( 101 | materialSkinManager.Theme == MaterialSkinManager.Themes.DARK ? Primary.Teal500 : Primary.Indigo500, 102 | materialSkinManager.Theme == MaterialSkinManager.Themes.DARK ? Primary.Teal700 : Primary.Indigo700, 103 | materialSkinManager.Theme == MaterialSkinManager.Themes.DARK ? Primary.Teal200 : Primary.Indigo100, 104 | Accent.Pink200, 105 | TextShade.WHITE); 106 | break; 107 | 108 | case 1: 109 | materialSkinManager.ColorScheme = new ColorScheme( 110 | Primary.Green600, 111 | Primary.Green700, 112 | Primary.Green200, 113 | Accent.Red100, 114 | TextShade.WHITE); 115 | break; 116 | 117 | case 2: 118 | materialSkinManager.ColorScheme = new ColorScheme( 119 | Primary.BlueGrey800, 120 | Primary.BlueGrey900, 121 | Primary.BlueGrey500, 122 | Accent.LightBlue200, 123 | TextShade.WHITE); 124 | break; 125 | } 126 | Invalidate(); 127 | } 128 | 129 | private void MaterialButton2_Click(object sender, EventArgs e) 130 | { 131 | materialProgressBar1.Value = Math.Min(materialProgressBar1.Value + 10, 100); 132 | } 133 | 134 | private void materialFlatButton4_Click(object sender, EventArgs e) 135 | { 136 | materialProgressBar1.Value = Math.Max(materialProgressBar1.Value - 10, 0); 137 | } 138 | 139 | private void materialSwitch4_CheckedChanged(object sender, EventArgs e) 140 | { 141 | DrawerUseColors = materialSwitch4.Checked; 142 | } 143 | 144 | private void MaterialSwitch5_CheckedChanged(object sender, EventArgs e) 145 | { 146 | DrawerHighlightWithAccent = materialSwitch5.Checked; 147 | } 148 | 149 | private void MaterialSwitch6_CheckedChanged(object sender, EventArgs e) 150 | { 151 | DrawerBackgroundWithAccent = materialSwitch6.Checked; 152 | } 153 | 154 | private void materialSwitch8_CheckedChanged(object sender, EventArgs e) 155 | { 156 | DrawerShowIconsWhenHidden = materialSwitch8.Checked; 157 | } 158 | 159 | private void MaterialButton3_Click(object sender, EventArgs e) 160 | { 161 | var builder = new StringBuilder("Batch operation report:\n\n"); 162 | var random = new Random(); 163 | var result = 0; 164 | 165 | for (int i = 0; i < 200; i++) 166 | { 167 | result = random.Next(1000); 168 | 169 | if (result < 950) 170 | { 171 | builder.AppendFormat(" - Task {0}: Operation completed sucessfully.\n", i); 172 | } 173 | else 174 | { 175 | 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); 176 | } 177 | } 178 | 179 | var batchOperationResults = builder.ToString(); 180 | batchOperationResults = "Simple text"; 181 | var mresult = MaterialMessageBox.Show(batchOperationResults, "Batch Operation", MessageBoxButtons.YesNoCancel, FlexibleMaterialForm.ButtonsPosition.Center); 182 | materialComboBox1.Items.Add("this is a very long string"); 183 | } 184 | 185 | private void materialSwitch9_CheckedChanged(object sender, EventArgs e) 186 | { 187 | DrawerAutoShow = materialSwitch9.Checked; 188 | } 189 | 190 | private void materialTextBox2_LeadingIconClick(object sender, EventArgs e) 191 | { 192 | MaterialSnackBar SnackBarMessage = new MaterialSnackBar("Leading Icon Click"); 193 | SnackBarMessage.Show(this); 194 | 195 | } 196 | 197 | private void materialButton6_Click(object sender, EventArgs e) 198 | { 199 | MaterialSnackBar SnackBarMessage = new MaterialSnackBar("SnackBar started succesfully", "OK", true); 200 | SnackBarMessage.Show(this); 201 | } 202 | 203 | private void materialSwitch10_CheckedChanged(object sender, EventArgs e) 204 | { 205 | materialTextBox21.UseAccent = materialSwitch10.Checked; 206 | } 207 | 208 | private void materialSwitch11_CheckedChanged(object sender, EventArgs e) 209 | { 210 | materialTextBox21.UseTallSize = materialSwitch11.Checked; 211 | } 212 | 213 | private void materialSwitch12_CheckedChanged(object sender, EventArgs e) 214 | { 215 | if (materialSwitch12.Checked) 216 | materialTextBox21.Hint = "Hint text"; 217 | else 218 | materialTextBox21.Hint = ""; 219 | } 220 | 221 | private void materialComboBox7_SelectionChangeCommitted(object sender, EventArgs e) 222 | { 223 | if (materialComboBox7.SelectedIndex == 1) 224 | { 225 | materialTextBox21.PrefixSuffix = MaterialTextBox2.PrefixSuffixTypes.Prefix; 226 | } 227 | else if (materialComboBox7.SelectedIndex == 2) 228 | { 229 | materialTextBox21.PrefixSuffix = MaterialTextBox2.PrefixSuffixTypes.Suffix; 230 | } 231 | else 232 | { 233 | materialTextBox21.PrefixSuffix = MaterialTextBox2.PrefixSuffixTypes.None; 234 | } 235 | } 236 | 237 | private void materialSwitch13_CheckedChanged(object sender, EventArgs e) 238 | { 239 | materialTextBox21.UseSystemPasswordChar = materialSwitch13.Checked; 240 | 241 | } 242 | 243 | private void materialSwitch14_CheckedChanged(object sender, EventArgs e) 244 | { 245 | if (materialSwitch14.Checked) 246 | materialTextBox21.LeadingIcon = global::MaterialSkinExample.Properties.Resources.baseline_fingerprint_black_24dp; 247 | else 248 | materialTextBox21.LeadingIcon = null; 249 | } 250 | 251 | private void materialSwitch15_CheckedChanged(object sender, EventArgs e) 252 | { 253 | if (materialSwitch15.Checked) 254 | materialTextBox21.TrailingIcon = global::MaterialSkinExample.Properties.Resources.baseline_build_black_24dp; 255 | else 256 | materialTextBox21.TrailingIcon = null; 257 | } 258 | 259 | private void materialTextBox21_LeadingIconClick(object sender, EventArgs e) 260 | { 261 | MaterialSnackBar SnackBarMessage = new MaterialSnackBar("Leading Icon Click"); 262 | SnackBarMessage.Show(this); 263 | } 264 | 265 | private void materialTextBox21_TrailingIconClick(object sender, EventArgs e) 266 | { 267 | MaterialSnackBar SnackBarMessage = new MaterialSnackBar("Trailing Icon Click"); 268 | SnackBarMessage.Show(this); 269 | } 270 | 271 | private void MsReadOnly_CheckedChanged(object sender, EventArgs e) 272 | { 273 | materialCheckbox1.ReadOnly = msReadOnly.Checked; 274 | } 275 | 276 | private void materialButton25_Click(object sender, EventArgs e) 277 | { 278 | 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"); 279 | DialogResult result = materialDialog.ShowDialog(this); 280 | 281 | MaterialSnackBar SnackBarMessage = new MaterialSnackBar(result.ToString(),750); 282 | SnackBarMessage.Show(this); 283 | 284 | } 285 | 286 | private void materialSwitch16_CheckedChanged(object sender, EventArgs e) 287 | { 288 | materialTextBox21.ShowAssistiveText = materialSwitch16.Checked; 289 | } 290 | 291 | 292 | 293 | } 294 | } 295 | --------------------------------------------------------------------------------