/// <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 Rectangle avatar = new Rectangle(new Point(Bounds.X + 10, Bounds.Y + (Bounds.Height / 2) - 8), new Size(15, 15)); LinearGradientBrush lgb = new LinearGradientBrush(avatar, Color, MColor.AddRGB(55, Color), LinearGradientMode.ForwardDiagonal); g.FillRectangle(lgb, avatar); g.DrawRectangle(new Pen(_sourceTheme.CONTROL_FOREGROUND.Normal.ToColor(), 1), avatar); // 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 + 32, 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> /// Draw label /// </summary> /// <param name="e"></param> protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics g = e.Graphics; // 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 it's 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; } } // Normal and alternate color Color standardTextColor = _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor(); Color alternateTextColor = (_sourceTheme.DARK_BASED) ? MColor.AddRGB(-120, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()) : MColor.AddRGB(100, _sourceTheme.CONTROL_FOREGROUND.Normal.ToColor()); Color tintTextColor = _tint; // Set foreground color switch (_type) { case LabelType.Standard: ForeColor = standardTextColor; break; case LabelType.Alternate: ForeColor = alternateTextColor; break; case LabelType.Tint: ForeColor = tintTextColor; break; } }
/// <summary> /// Draw click effect /// </summary> /// <param name="e"></param> private void DrawClick(PaintEventArgs e) { // Control's graphics object Graphics g = e.Graphics; // 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; } } // ClickEffect if (_clickEffect != ClickEffect.None) { // Color of ClickEffect Color color; Color fill = (_fullColored) ? _tint : _sourceTheme.CONTROL_FILL.Normal.ToColor(); if (_sourceTheme.DARK_BASED == true) { // Dark based themes color = Color.FromArgb(_alpha, MColor.AddRGB(150, fill)); } else { // Light based themes color = Color.FromArgb(_alpha, MColor.AddRGB(-150, fill)); } // Draws ClickEffect // Set up antialiasing g.SmoothingMode = SmoothingMode.AntiAlias; // Ink if (_clickEffect == ClickEffect.Ink) { // Ink's brush and grapics path SolidBrush brush = new SolidBrush(color); GraphicsPath ink = Draw.GetEllipsePath(_mouse, (int)_radius); // Draws ink ClickEffect g.FillPath(brush, ink); } // Square if (_clickEffect == ClickEffect.Square || _clickEffect == ClickEffect.SquareRotate) { // Square's brush and grapics path SolidBrush brush = new SolidBrush(color); GraphicsPath square = Draw.GetSquarePath(_mouse, (int)_radius); // Rotates square if (_clickEffect == ClickEffect.SquareRotate) { Matrix matrix = new Matrix(); matrix.RotateAt(_rotation, _mouse); square.Transform(matrix); } // Draws square ClickEffect g.FillPath(brush, square); } // Remove antialiasing g.SmoothingMode = SmoothingMode.Default; } }
/// <summary> /// Draw method /// </summary> /// <param name="e"></param> 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 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); // Draw raised button if (_buttonType == ButtonType.Raised) { // Fill color Color fill = new Color(); // Button is filled with his Tint color if (_fullColored) { if (Enabled) { fill = MColor.AddRGB((_sourceTheme.DARK_BASED) ? +(_hoverAlpha / 15) : -(_hoverAlpha / 15), _tint); } else { fill = _sourceTheme.CONTROL_FILL.Disabled.ToColor(); } g.FillRectangle(new SolidBrush(fill), ClientRectangle); } else { // Regular raised button fill = MColor.Mix(Color.FromArgb(_hoverAlpha, _sourceTheme.CONTROL_FILL.Hover.ToColor()), _sourceTheme.CONTROL_FILL.Normal.ToColor()); // Disabled if (!Enabled) { fill = _sourceTheme.CONTROL_FILL.Disabled.ToColor(); } g.FillRectangle(new SolidBrush(fill), ClientRectangle); } // Click effect DrawClick(e); // Focus rectangle if (Focused || _tintAlpha > 0) { Rectangle rc = new Rectangle(Location.X, Location.Y, Width, Height); Color frameColor = MColor.Mix(Color.FromArgb(_tintAlpha, Enabled ? _tint : fill), fill); Pen framePen = new Pen(frameColor); Rectangle frameRectangle = new Rectangle(0, 0, rc.Width - 1, rc.Height - 1); g.DrawRectangle(framePen, frameRectangle); } // Text DrawText(e); } if (_buttonType == ButtonType.Outline) { // Fill color Color fill = new Color(); Color border = new Color(); // Button is filled with his Tint color if (_fullColored) { // Fullcolored outlined button fill = MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(220, _tint, Parent.BackColor)), Parent.BackColor); border = (Enabled) ? _tint : _sourceTheme.CONTROL_FILL.Disabled.ToColor(); // Disabled if (!Enabled) { fill = Parent.BackColor; } Rectangle r = ClientRectangle; g.FillRectangle(new SolidBrush(fill), r); g.DrawRectangle(new Pen(border), new Rectangle(r.X, r.Y, r.Width - 1, r.Height - 1)); } else { // Fullcolored outlined button fill = MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(220, _sourceTheme.CONTROL_BORDER.Normal.ToColor(), Parent.BackColor)), Parent.BackColor); border = (Enabled) ? _sourceTheme.CONTROL_FILL.Normal.ToColor() : _sourceTheme.CONTROL_FILL.Disabled.ToColor(); // Disabled if (!Enabled) { fill = Parent.BackColor; } Rectangle r = ClientRectangle; g.FillRectangle(new SolidBrush(fill), r); g.DrawRectangle(new Pen(border), new Rectangle(r.X, r.Y, r.Width - 1, r.Height - 1)); } // Click effect DrawClick(e); // Text DrawText(e); } if (_buttonType == ButtonType.Flat) { // Fill color Color fill = new Color(); // Button is filled with his Tint color if (_fullColored) { // Fullcolored outlined button fill = MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(220, _tint, Parent.BackColor)), Parent.BackColor); // Disabled if (!Enabled) { fill = Parent.BackColor; } Rectangle r = ClientRectangle; g.FillRectangle(new SolidBrush(fill), r); } else { // Fullcolored outlined button fill = MColor.Mix(Color.FromArgb(_hoverAlpha, MColor.Lighten(160, _sourceTheme.CONTROL_BORDER.Normal.ToColor(), Parent.BackColor)), Parent.BackColor); // Disabled if (!Enabled) { fill = Parent.BackColor; } Rectangle r = ClientRectangle; g.FillRectangle(new SolidBrush(fill), r); } // Click effect DrawClick(e); // Text DrawText(e); } }
/// <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)) }