public FormMaterial() { BackColor = Color.White; ControlBox = false; this.SetMaterialFontNormal(); this.SetMaterialStyle(); Size = new Size(720, 360); Text = ("Material UI - " + ((MaterialThemes)(MaterialUISettings.Theme)).ToString()).ToUpper(); uwfHeaderFont = Font; innerBorderPen.Color = Color.Transparent; for (int i = 0; i < 4; i++) { MaterialFlatButton flatButton = new MaterialFlatButton(); flatButton.Location = new Point(16 + i * 128, 32); flatButton.SetMaterialStyle((MaterialFlatButonStyles)i); flatButton.Text = ((MaterialFlatButonStyles)i).ToString().ToUpper(); flatButton.Size = new Size(12 * flatButton.Text.Length, MaterialFlatButton.DefaultHeight); Controls.Add(flatButton); } MaterialFlatButton flatButtonWImage = new MaterialFlatButton(); flatButtonWImage.Location = new Point(16, 32 + 40); flatButtonWImage.SetMaterialStyle(MaterialFlatButonStyles.Primary); flatButtonWImage.Text = "WITH IMAGE"; flatButtonWImage.Size = new Size(128, flatButtonWImage.Height); flatButtonWImage.Image = ResourceManager.Images.SafeGet(ImageNames.imageMaterial_Android); flatButtonWImage.ImageColor = flatButtonWImage.ForeColor; flatButtonWImage.ImageRect = new Rectangle(8, 8, flatButtonWImage.Height - 16, flatButtonWImage.Height - 16); flatButtonWImage.Padding = new Padding(flatButtonWImage.ImageRect.X + flatButtonWImage.ImageRect.Width, 0, flatButtonWImage.ImageRect.X, 0); Controls.Add(flatButtonWImage); MaterialFlatButton flatButtonNoRipple = new MaterialFlatButton(); flatButtonNoRipple.Location = new Point(flatButtonWImage.Location.X + flatButtonWImage.Width + 16, flatButtonWImage.Location.Y); flatButtonNoRipple.Ripple = false; flatButtonNoRipple.SetMaterialStyle(MaterialFlatButonStyles.Secondary); flatButtonNoRipple.Size = new Size(128, flatButtonNoRipple.Height); flatButtonNoRipple.Text = "NO RIPPLE"; Controls.Add(flatButtonNoRipple); for (int i = 0; i < 4; i++) { MaterialRaisedButton raisedButton = new MaterialRaisedButton(); raisedButton.Location = new Point(16 + i * 128, 32 + 80); raisedButton.SetMaterialStyle((MaterialFlatButonStyles)i); raisedButton.Text = ((MaterialFlatButonStyles)i).ToString().ToUpper(); raisedButton.Size = new Size(12 * raisedButton.Text.Length, MaterialFlatButton.DefaultHeight); Controls.Add(raisedButton); } MaterialTextField textField1 = new MaterialTextField(); textField1.Location = new Point(16, 32 + 124); Controls.Add(textField1); MaterialTextField textField2 = new MaterialTextField(); textField2.Location = new Point(textField1.Location.X + textField1.Width + 16, 32 + 124); textField2.Password = true; textField2.PlaceHolder = "Password hint"; Controls.Add(textField2); MaterialTextField textField3 = new MaterialTextField(); textField3.FloatingText = "Floating text"; textField3.Location = new Point(textField2.Location.X + textField2.Width + 16, 32 + 124); textField3.PlaceHolder = "Hint here"; Controls.Add(textField3); MaterialTextField textField4 = new MaterialTextField(); textField4.BottomText = "Error here"; textField4.LineAlwaysFilled = true; textField4.LineFillColor = textField4.BottomTextColor; textField4.Location = new Point(textField3.Location.X + textField3.Width + 16, 32 + 124); textField4.PlaceHolder = ""; Controls.Add(textField4); MaterialCheckbox checkBox = new MaterialCheckbox(); checkBox.Image = ResourceManager.Images.SafeGet(ImageNames.imageMaterial_Checkbox); checkBox.ImageOutline = ResourceManager.Images.SafeGet(ImageNames.imageMaterial_CheckboxOutline); checkBox.Location = new Point(16, 212); checkBox.Text = "CheckBox"; Controls.Add(checkBox); }
public static void SetMaterialStyle(this MaterialFlatButton button, MaterialFlatButonStyles style, MaterialThemes theme = MaterialThemes.None) { if (theme == MaterialThemes.None) { theme = MaterialUISettings.Theme; } #region flat style. if (button.ButtonType == MaterialButtonTypes.Flat) { switch (theme) { case MaterialThemes.Light: button.HoverColor = Color.FromArgb(221, 221, 221); button.PressedColor = Color.FromArgb(204, 204, 204); break; case MaterialThemes.Dark: button.HoverColor = Color.FromArgb(74, 74, 74); button.PressedColor = Color.FromArgb(89, 89, 89); break; } switch (style) { case MaterialFlatButonStyles.Default: if (theme != MaterialThemes.Dark) { button.ForeColor = Color.FromArgb(42, 42, 42); } else { button.ForeColor = Color.White; } break; case MaterialFlatButonStyles.Primary: button.ForeColor = Color.FromArgb(255, 64, 129); break; case MaterialFlatButonStyles.Secondary: button.ForeColor = Color.FromArgb(0, 188, 216); break; case MaterialFlatButonStyles.Disabled: button.ForeColor = Color.FromArgb(160, 160, 160); button.HoverColor = Color.Transparent; button.PressedColor = Color.Transparent; button.Ripple = false; break; } button.BackColor = Color.FromArgb(0, button.HoverColor); } #endregion else { switch (theme) { case MaterialThemes.Light: button.ForeColor = Color.White; button.HoverColor = Color.FromArgb(221, 221, 221); button.PressedColor = Color.FromArgb(204, 204, 204); break; case MaterialThemes.Dark: button.ForeColor = Color.FromArgb(42, 42, 42); button.HoverColor = Color.FromArgb(74, 74, 74); button.PressedColor = Color.FromArgb(89, 89, 89); break; } button.uwfShadowBox = true; switch (style) { case MaterialFlatButonStyles.Default: button.BackColor = Color.White; button.ForeColor = Color.FromArgb(42, 42, 42); //button.HoverColor = button.BackColor - Color.FromArgb(0, 48, 48, 48); //button.PressedColor = button.BackColor - Color.FromArgb(0, 72, 72, 72); break; case MaterialFlatButonStyles.Primary: button.BackColor = Color.FromArgb(255, 64, 129); //button.HoverColor = button.BackColor - Color.FromArgb(0, 48, 48, 48); //button.PressedColor = button.BackColor - Color.FromArgb(0, 72, 72, 72); break; case MaterialFlatButonStyles.Secondary: button.BackColor = Color.FromArgb(0, 188, 216); //button.HoverColor = button.BackColor - Color.FromArgb(0, 48, 48, 48); //button.PressedColor = button.BackColor - Color.FromArgb(0, 72, 72, 72); break; case MaterialFlatButonStyles.Disabled: if (theme == MaterialThemes.Light) { button.BackColor = Color.FromArgb(229, 229, 229); } else { button.BackColor = Color.FromArgb(64, 64, 64); } button.ForeColor = Color.FromArgb(160, 160, 160); button.HoverColor = button.BackColor; button.PressedColor = button.BackColor; button.Ripple = false; button.uwfShadowBox = false; break; } button.ForceUpdateColor(); } }