/// <summary> /// Constructor /// </summary> public MRadioButton() { InitializeComponent(); // Scaling DIP.GetGraphics(this); // Default variables _controlTimer = new Timer(); _controlTimer.Enabled = true; _controlTimer.Interval = 1; _controlTimer.Tick += new EventHandler(Update); _controlTimer.Start(); _state = false; _tintAlpha = 0; _radius = 0; _hoverAlpha = 0; _hover = false; _usedTheme = null; DoubleBuffered = true; AutoSize = false; Height = DIP.Set(20); Font = new Font("Segoe UI", 7); Size = new Size(130, 36); // Pass graphics to DIP class DIP.GetGraphics(this); // Redraw Invalidate(); }
/// <summary> /// Constructor /// </summary> public MCheckBox() { InitializeComponent(); // Default variables _controlTimer = new Timer(); _controlTimer.Enabled = true; _controlTimer.Interval = 1; _controlTimer.Tick += new EventHandler(Update); _controlTimer.Start(); _state = false; _a = 0; _frame = 0; _hover = false; _hoverAlpha = 0; DoubleBuffered = true; AutoSize = false; DIP.GetGraphics(this); Height = DIP.Set(15); Font = new Font("Segoe UI", 7); Size = new Size(130, 36); // Redraw Invalidate(); }
/// <summary> /// Draw item /// </summary> public override void DrawItem(MListBox owner, Graphics g, Rectangle itemBounds) { // DIP DIP.GetGraphics(g); // Basic varibles Height = DIP.Set(70); Bounds = itemBounds; Graphics = g; // Handles control's source theme // Check if control has set own theme if (owner.UsedTheme != null) { // Set custom theme as source theme _sourceTheme = owner.UsedTheme; } else { // Control dont have its own theme // Try cast control's parent form to MForm try { MForm form = (MForm)owner.FindForm(); _sourceTheme = form.UsedTheme; } catch { // Control's parent form is not MForm type // Set application wide theme _sourceTheme = Minimal.UsedTheme; } } // Background g.FillRectangle(new SolidBrush(_sourceTheme.CONTROL_BACKGROUND.Normal.ToColor()), Bounds); // Item have focus || mouse hover if (Bounds.Contains(owner.MousePosition)) { // Partially transparent tint layer g.FillRectangle(new SolidBrush(Color.FromArgb(25, owner.Tint)), Bounds); } // Draw primary text StringFormat sfPrimary = new StringFormat(); sfPrimary.LineAlignment = StringAlignment.Center; g.DrawString(PrimaryText, new Font("Segoe UI", 9), new SolidBrush((Bounds.Contains(owner.MousePosition) ? owner.Tint : _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor())), new Rectangle(Bounds.X + 10, Bounds.Y + 5, Bounds.Width, Bounds.Height / 2 + 1), sfPrimary); // Draw secondary text StringFormat sfSecondary = new StringFormat(); sfSecondary.LineAlignment = StringAlignment.Center; Color textColor = (_sourceTheme.DARK_BASED) ? MColor.AddRGB(-120, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()) : MColor.AddRGB(100, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()); g.DrawString(SecondaryText, new Font("Segoe UI", 8), new SolidBrush(textColor), new Rectangle(Bounds.X + 10, Bounds.Y + Bounds.Height / 2 - 9, Bounds.Width, Bounds.Height / 2 + 5), sfSecondary); }
/// <summary> /// Draw /// </summary> public override void DrawItem(MListBox owner, Graphics g, Rectangle itemBounds) { // DIP DIP.GetGraphics(g); // Basic varibles Height = DIP.Set(50); Bounds = itemBounds; Graphics = g; // Handles control's source theme // Check if control has set own theme if (owner.UsedTheme != null) { // Set custom theme as source theme _sourceTheme = owner.UsedTheme; } else { // Control dont have its own theme // Try cast control's parent form to MForm try { MForm form = (MForm)owner.FindForm(); _sourceTheme = form.UsedTheme; } catch { // Control's parent form is not MForm type // Set application wide theme _sourceTheme = Minimal.UsedTheme; } } // Background g.FillRectangle(new SolidBrush(_sourceTheme.CONTROL_BACKGROUND.Normal.ToColor()), Bounds); // Item have focus || mouse hover if (Bounds.Contains(owner.MousePosition)) { // Partially transparent tint layer g.FillRectangle(new SolidBrush(Color.FromArgb(25, owner.Tint)), Bounds); } // Avatar g.FillRectangle(new SolidBrush(owner.Tint), new Rectangle(new Point(Bounds.X + 10, Bounds.Y + (Bounds.Height / 2) - 16), new Size(32, 32))); StringFormat sfAvatar = new StringFormat(); sfAvatar.LineAlignment = StringAlignment.Center; sfAvatar.Alignment = StringAlignment.Center; g.DrawString(PrimaryText[0].ToString(), new Font("Segoe UI Light", 12), new SolidBrush(Color.White), new Rectangle(new Point(Bounds.X + 10, Bounds.Y + (Bounds.Height / 2) - 16), new Size(32, 32)), sfAvatar); // Draw primary text StringFormat sfPrimary = new StringFormat(); sfPrimary.LineAlignment = StringAlignment.Center; g.DrawString(PrimaryText, new Font("Segoe UI", 9), new SolidBrush(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()), new Rectangle(Bounds.X + 48, Bounds.Y + 1, Bounds.Width + 50, Bounds.Height), sfPrimary); }
public override void DrawItem(MListBox owner, Graphics g, Rectangle itemBounds) { // DIP DIP.GetGraphics(g); // Basic varibles Height = DIP.Set(30); Bounds = itemBounds; Graphics = g; // Handles control's source theme // Check if control has set own theme if (owner.UsedTheme != null) { // Set custom theme as source theme _sourceTheme = owner.UsedTheme; } else { // Control dont have its own theme // Try cast control's parent form to MForm try { MForm form = (MForm)owner.FindForm(); _sourceTheme = form.UsedTheme; } catch { // Control's parent form is not MForm type // Set application wide theme _sourceTheme = Minimal.UsedTheme; } } // Background g.FillRectangle(new SolidBrush((_sourceTheme.DARK_BASED) ? MColor.AddRGB(5, _sourceTheme.CONTROL_BACKGROUND.Normal.ToColor()) : MColor.AddRGB(-5, _sourceTheme.CONTROL_BACKGROUND.Normal.ToColor())), Bounds); // Draw primary text Color color = _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor(); StringFormat sfPrimary = new StringFormat(); sfPrimary.LineAlignment = StringAlignment.Center; g.DrawString(PrimaryText, new Font("Segoe UI Semibold", 8), new SolidBrush(color), new Rectangle(Bounds.X + 10, Bounds.Y + 5, Bounds.Width, Bounds.Height / 2 + 5), sfPrimary); // Draw divider lines Color lineColor = (_sourceTheme.DARK_BASED) ? MColor.AddRGB(-150, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()) : MColor.AddRGB(150, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()); g.DrawLine(new Pen(lineColor), new Point(Bounds.X, Bounds.Y), new Point(Bounds.X + Bounds.Width, Bounds.Y)); g.DrawLine(new Pen(lineColor), new Point(Bounds.X, Bounds.Y + Bounds.Height - 1), new Point(Bounds.X + Bounds.Width, Bounds.Y + Bounds.Height - 1)); }
/// <summary> /// Construcotor /// </summary> public MLabeledTextBox() { InitializeComponent(); DIP.GetGraphics(this); // Default variables _controlTimer = new Timer(); _controlTimer.Enabled = true; _controlTimer.Interval = 1; _controlTimer.Tick += new EventHandler(Update); _controlTimer.Start(); _usedTheme = null; _tintAlpha = 0; DoubleBuffered = true; _textBox.TextChanged += new PropertyChangedEventHandler(OnTextChanged); PrefixChanged += OnPrefixChange; PostfixChanged += OnPostfixChanged; _textBox.Font = new Font("Segoe UI", 9); Controls.Add(_textBox); Height = _textBox.Height; Prefix = ""; Postfix = ""; UpdateLayout(); }
/// <summary> /// Paint /// </summary> protected override void OnPaint(PaintEventArgs e) { // Base painting base.OnPaint(e); // Handles control's source theme // Check if control has set own theme if (_usedTheme != null) { // Set custom theme as source theme _sourceTheme = _usedTheme; } else { // Control dont have its own theme // Try cast control's parent form to MForm try { MForm form = (MForm)FindForm(); _sourceTheme = form.UsedTheme; } catch { // Control's parent form is not MForm type // Set application wide theme _sourceTheme = Minimal.UsedTheme; } } // Graphics Graphics g = e.Graphics; // Clear control g.Clear(Parent.BackColor); // Scaling DIP.GetGraphics(this); // Fill color, text and border Color fill = new Color(); Color border = new Color(); Color foreground = new Color(); if (Enabled) { // Enabled fill = MColor.Mix(Color.FromArgb(_hoverAlpha, _sourceTheme.CONTROL_BACKGROUND.Hover.ToColor()), _sourceTheme.CONTROL_BACKGROUND.Normal.ToColor()); border = _sourceTheme.CONTROL_BORDER.Normal.ToColor(); foreground = _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor(); } else { // Disabled fill = _sourceTheme.CONTROL_BACKGROUND.Disabled.ToColor(); border = _sourceTheme.CONTROL_BORDER.Disabled.ToColor(); foreground = _sourceTheme.CONTROL_FOREGROUND.Disabled.ToColor(); } // Draw unchecked checkbox int height = 19; g.FillRectangle(new SolidBrush(fill), new Rectangle(0, Height / 2 - height / 2, height, height)); g.DrawRectangle(new Pen(border), new Rectangle(0, Height / 2 - height / 2, height, height)); // Draws cover GraphicsPath square = Draw.GetSquarePath(new Point(10, Height / 2 - height / 2 + 10), _a); g.FillPath(new SolidBrush(Enabled ? _tint : _sourceTheme.CONTROL_FILL.Disabled.ToColor()), square); int b = Height / 2 - height / 2; _checkmark = new Point[] { new Point(4, b + 9), new Point(5, b + 10), new Point(6, b + 11), new Point(7, b + 12), new Point(8, b + 13), new Point(9, b + 12), new Point(10, b + 11), new Point(11, b + 10), new Point(12, b + 9), new Point(13, b + 8), new Point(14, b + 7), new Point(15, b + 6), }; // Draws checkmark if (_a == 10 && _state == true) { DrawCheckmarkIn(e); } if (_a == 10 && _state == false) { DrawCheckmarkOut(e); } // Draw text g.DrawString(this.Text, this.Font, new SolidBrush(foreground), new Point(25, b)); }
/// <summary> /// Draw /// </summary> protected override void OnPaint(PaintEventArgs e) { // Base painting base.OnPaint(e); // Scaling DIP.GetGraphics(this); // Handles control's source theme // Check if control has set own theme if (_usedTheme != null) { // Set custom theme as source theme _sourceTheme = _usedTheme; } else { // Control don't have its own theme // Try cast control's parent form to MForm try { MForm form = (MForm)FindForm(); _sourceTheme = form.UsedTheme; } catch { // Control's parent form is not MForm type // Set application wide theme _sourceTheme = Minimal.UsedTheme; } } // Graphics Graphics g = e.Graphics; // Clear control g.Clear(Parent.BackColor); // Fill color, text and border Color fill = new Color(); Color border = new Color(); Color hover = new Color(); Color foreground = new Color(); if (Enabled) { // Enabled fill = _sourceTheme.CONTROL_BACKGROUND.Normal.ToColor(); border = _sourceTheme.CONTROL_BORDER.Normal.ToColor(); foreground = _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor(); hover = _sourceTheme.CONTROL_FILL.Hover.ToColor(); } else { // Disabled fill = _sourceTheme.CONTROL_BACKGROUND.Disabled.ToColor(); border = _sourceTheme.CONTROL_BORDER.Disabled.ToColor(); foreground = _sourceTheme.CONTROL_FOREGROUND.Disabled.ToColor(); hover = _sourceTheme.CONTROL_FILL.Disabled.ToColor(); } // Draw background g.FillPath(new SolidBrush(fill), Draw.GetEllipsePath(new Point(DIP.Set(10), DIP.Set(10)), DIP.Set((10)))); // Antialiasing g.SmoothingMode = SmoothingMode.AntiAlias; // Draw border if (!_state) { g.DrawPath(new Pen(!Checked ? _sourceTheme.CONTROL_BORDER.Normal.ToColor() : _tint, 1), Draw.GetEllipsePath(new Point(DIP.Set(10), DIP.Set(10)), DIP.Set(10))); } // Mouse hover g.FillPath(new SolidBrush(Color.FromArgb(_hoverAlpha, hover)), Draw.GetEllipsePath(new Point(DIP.Set(10), DIP.Set(10)), DIP.Set(3))); // Animation - inner circle g.FillPath(new SolidBrush(Enabled ? _tint : _sourceTheme.CONTROL_FILL.Disabled.ToColor()), Draw.GetEllipsePath(new Point(DIP.Set(10), DIP.Set(10)), Convert.ToInt32(_radius))); // Animation - border tint g.DrawEllipse(new Pen(MColor.Mix(Color.FromArgb(_tintAlpha, Enabled ? _tint : _sourceTheme.CONTROL_BORDER.Disabled.ToColor()), border)), new Rectangle(0, 0, DIP.Set(20), DIP.Set(20))); // Antialiasing g.SmoothingMode = SmoothingMode.Default; // Draw text g.DrawString(this.Text, this.Font, new SolidBrush(foreground), new Point(25 + DIP.Set(8), 2)); }
/// <summary> /// Draw method /// </summary> /// <param name="e"></param> protected override void OnPaint(PaintEventArgs e) { // Base painting base.OnPaint(e); Graphics g = e.Graphics; DIP.GetGraphics(g); // Handles control's source theme // Check if control has set own theme if (Owner.UsedTheme != null) { // Set custom theme as source theme _sourceTheme = Owner.UsedTheme; } else { // Control dont have its own theme // Try cast control's parent form to MForm try { MForm form = (MForm)FindForm(); _sourceTheme = form.UsedTheme; } catch { // Control's parent form is not MForm type // Set application wide theme _sourceTheme = Minimal.UsedTheme; } } // Draw item background Color fill = (Owner.MenuItem == this) ? _sourceTheme.WINDOW_CAPTIONBAR.Normal.ToColor() : MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(230, _tint, _sourceTheme.WINDOW_CAPTIONBAR.Normal.ToColor())), _sourceTheme.WINDOW_CAPTIONBAR.Normal.ToColor()); g.FillRectangle(new SolidBrush(fill), new Rectangle(0, 0, Width, Height)); if (FullColored) { g.FillRectangle(new SolidBrush(MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.AddRGB((_sourceTheme.DARK_BASED) ? +(_hoverAlpha / 15) : -(_hoverAlpha / 15), _tint)), _tint)), new Rectangle(0, 0, Owner.MenuItem.Height, Owner.MenuItem.Height)); } // Click effect DrawClick(e); // Icon mode if (_icon != null && !_fullColored) { if (_sourceTheme.DARK_BASED) { _icon.DarkBased = true; } else { _icon.DarkBased = false; } } // Draw Icon if (_icon != null) { g.InterpolationMode = InterpolationMode.NearestNeighbor; if (Owner.SelectedItem == this) { Image img = MColor.SetImageColor(_icon.Icon, _tint); g.DrawImage(MColor.SetImageOpacity(img, 1f), 16, 16, 32, 32); } else { g.DrawImage(MColor.SetImageOpacity(_icon.Icon, 1f), 16, 16, 32, 32); } } else { // Icon rect g.DrawRectangle(new Pen(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()), new Rectangle(20, 20, 20, 20)); } // Draw text SolidBrush brush = (Owner.SelectedItem == this) ? new SolidBrush(_tint) : (_fullColored) ? new SolidBrush(ForeColor) : new SolidBrush(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()); g.DrawString(Text, Font, brush, new Rectangle(65, (Height / 2) - (Font.Height / 2), Width, Height)); }
/// <summary> /// Draw /// </summary> public override void DrawItem(MListBox owner, Graphics g, Rectangle itemBounds) { // DIP DIP.GetGraphics(g); // Basic variables Height = DIP.Set(70); Bounds = itemBounds; Graphics = g; // Handles control's source theme // Check if control has set own theme if (owner.UsedTheme != null) { // Set custom theme as source theme _sourceTheme = owner.UsedTheme; } else { // Control don't have its own theme // Try cast control's parent form to MForm try { MForm form = (MForm)owner.FindForm(); _sourceTheme = form.UsedTheme; } catch { // Control's parent form is not MForm type // Set application wide theme _sourceTheme = Minimal.UsedTheme; } } // Background g.FillRectangle(new SolidBrush(_sourceTheme.CONTROL_BACKGROUND.Normal.ToColor()), Bounds); // Item have focus || mouse hover if (Bounds.Contains(owner.MousePosition)) { // Partially transparent tint layer g.FillRectangle(new SolidBrush(Color.FromArgb(25, owner.Tint)), Bounds); } // Draw primary text StringFormat sfPrimary = new StringFormat(); sfPrimary.LineAlignment = StringAlignment.Center; g.DrawString(PrimaryText, new Font("Segoe UI", 9), new SolidBrush(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()), new Rectangle(Bounds.X + 21, Bounds.Y + 6, Bounds.Width, Bounds.Height / 2 + 1), sfPrimary); // Draw secondary text StringFormat sfSecondary = new StringFormat(); sfSecondary.LineAlignment = StringAlignment.Center; Color textColor = (_sourceTheme.DARK_BASED) ? MColor.AddRGB(-120, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()) : MColor.AddRGB(100, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()); g.DrawString(SecondaryText, new Font("Segoe UI", 8), new SolidBrush(textColor), new Rectangle(Bounds.X + 21, Bounds.Y + Bounds.Height / 2 - 6, Bounds.Width, Bounds.Height / 2 + 5), sfSecondary); Color bad = new Hex("#F56C6C").ToColor(); Color medium = new Hex("#E6A23C").ToColor(); Color good = new Hex("#67C23A").ToColor(); string strength = ""; Color infoColor = Color.Beige; if (_passwordHash.Length >= 10) { infoColor = good; strength = "Strong"; } else if (_passwordHash.Length >= 6) { infoColor = medium; strength = "Good"; } else { infoColor = bad; strength = "Weak"; } // Draw password hash StringFormat sfPassword = new StringFormat(); sfPassword.LineAlignment = StringAlignment.Center; sfPassword.Alignment = StringAlignment.Far; Font passwordFont = new Font("Segoe UI", 9); SizeF size = g.MeasureString(strength, passwordFont); Color passwordColor = (_sourceTheme.DARK_BASED) ? MColor.AddRGB(-120, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()) : MColor.AddRGB(100, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()); g.DrawString(strength, passwordFont, new SolidBrush(infoColor), new Rectangle(Bounds.X, Bounds.Y, Convert.ToInt32(Bounds.Width - 20), Bounds.Height), sfPassword); // new Rectangle(Bounds.X + Bounds.Width - Convert.ToInt32(size.Width) - 21, Bounds.Y + Bounds.Height / 2 - Convert.ToInt32(size.Height/2), Bounds.Width, Bounds.Height / 2 - Convert.ToInt32(size.Height / 2)) }