Minimal library
MButton is replacement for the standard WinForms Button. It can be clicked with the mouse, enter-key, or spacebar if the button has focus. In addition to all standard functions was also added support for the themes, click effects, button types and many more.
Like other controls, MButton can be simply droped from toolbox on the form. If you are not using IDE with integrated form designer (like Visual Studio), you can always create button programmatically:
// Initialize button first MButton btn = new MButton(); // Add size and location btn.Size = new Size(150, 45); btn.Location = new Point(50, 50); // Add text (optional) btn.Text = "Click me!"; // Don't forget to add our newly created // button to form's control collection. targetForm.Controls.Add(btn);
using System; using System.Windows.Forms; using Minimal.Components; namespace Demo { public partial class MyForm : Form { // Initialize button first MButton btn = new MButton(); // Form constructor public MyForm() { InitializeComponent(); // Add size and location btn.Size = new Size(150, 45); btn.Location = new Point(50, 50); // Add text (optional) btn.Text = "Click me!"; // Don't forget to add our newly created // button to form's control collection. Controls.Add(btn); } } }
Code example asumes, that targetForm variable is form where you want to have your button placed. If you are working inside a class derived from System.Windows.Forms.Form, you can of course replace targetForm variable with this keyword or in latest version of C# omit form reference completely. See second example.
The biggest difference is a new refreshed look and feel. MButton have smooth animations on the focus, mouse hover, click and on the lot of other different places. You can switch between multiple render modes like raised, flat and outline on the fly using Type property. Click effects can be also changed by modyfing ClickEffect. Windows 10 (fluent design) reveal effect was also added. Like other M-components, theme support was added.
MButton and other M-components support themes. Button is by default using theme which is set on parent MForm. If button is placed on classic form derived from System.Windows.Forms.Form, then M.ApplicationWideTheme is used for component rendering. This behavior can be overridden by changing component’s CustomTheme property.
// Setting button's custom theme btn.CustomTheme = M.Dark;
// Setting button's custom fill and text color: // First we need to enable custom color property. This will tell button to ignore // currently set theme and use Accent and ForeColor properties instead. btn.CustomColor = true; // Now we can set actual fill and text color btn.Accent = Hex.Blue; btn.ForeColor = Hex.White;
You can use default build-in themes or create your own. CustomTheme property is not visible in Visual Studio properties window at a design time by default so you need to make those changes programmatically. See Themes section for more informations.
Most of M-components, including MButton, supports multiple predefined click effects that you can choose from. As the name suggest, those effects occurs on component’s click event. Ripple effect inspired by the Google’s material design is set by default. Those effects can be turned off completely if necessary.
// Setting buttons click effect btn.ClickEffect = ClickEffect.SquareRotate; // Removing click effect completely btn.ClickEffect = ClickEffect.None;
Using button’s Type property and ButtonType enum you can switch between flat, outline and raised button style on the fly.
// Setting button's type to outlined btn.Type = ButtonType.Outline;
Raised buttons are often used for important actions.
Outlined buttons are used for secondary actions to raised buttons due to the stroke.
Flat buttons are typically used for less important actions.
This list doesn’t include content derived from the parent class. See Microsoft’s official Button class documentation for a complete list of items.
Caught a mistake or want to contribute to the documentation? Edit this page on GitHub!