protected override void OnPaint(PaintEventArgs pevent) { base.OnPaint(pevent); Graphics graphics = pevent.Graphics; graphics.SmoothingMode = SmoothingMode.HighQuality; if (Parent is MaterialCard card) { graphics.Clear(card.CardColor); } else { graphics.Clear(Parent.BackColor); } GraphicsPath mainSketch = GraphicHelper.GetPillShape(0, 0, Width - 1, Height - 1, Height); switch (style) { case ChipStyle.Filled: graphics.FillPath(new SolidBrush(Enabled ? Checked ? Color.FromArgb(100, primaryColor) : Color.WhiteSmoke : Checked ? Color.FromArgb(220, Color.Gainsboro) : Color.WhiteSmoke), mainSketch); break; case ChipStyle.Outlined: graphics.DrawPath(new Pen(new SolidBrush(Enabled ? Checked ? primaryColor : Color.DimGray : Color.Silver)), mainSketch); if (Checked) { graphics.FillPath(new SolidBrush(Color.FromArgb(100, Enabled ? primaryColor : Color.Gainsboro)), mainSketch); } break; default: break; } if (MouseState == MouseState.HOVER) { graphics.FillPath(new SolidBrush(Color.FromArgb((Checked) ? 25 : 100, Color.Gray)), mainSketch); } if (Focused) { graphics.FillPath(new SolidBrush(Color.FromArgb(25, Color.Gray)), mainSketch); } graphics.DrawString(Text, Font, new SolidBrush((Enabled) ? Color.Black : Color.Gray), new RectangleF(0, 0, Width, Height), textAlignment); if (Checked && Enabled) { graphics.DrawString(Text, Font, new SolidBrush(Color.FromArgb(140, primaryColor)), new RectangleF(0, 0, Width, Height), textAlignment); } }
protected override void OnPaint(PaintEventArgs pevent) { base.OnPaint(pevent); Graphics graphics = pevent.Graphics; graphics.SmoothingMode = SmoothingMode.HighQuality; Region region = new Region(); if (Parent is MaterialCard) { graphics.Clear(((MaterialCard)Parent).CardColor); } else { graphics.Clear(Parent.BackColor); } GraphicsPath mainSketch; if (this.Enabled) { mainSketch = GraphicHelper.GetRoundedRectangle(1, 1, Width - 2, Height - 2, radius); region = new Region(mainSketch); graphics.DrawPath(new Pen(borderColor), mainSketch); graphics.SetClip(region, CombineMode.Replace); graphics.SmoothingMode = SmoothingMode.HighSpeed; graphics.FillEllipse(new SolidBrush(Color.FromArgb(aniOpacity, primaryColor)), mouseX - (animationSize / 2), mouseY - (animationSize / 2), animationSize, animationSize); graphics.SmoothingMode = SmoothingMode.AntiAlias; if (MouseState == MouseState.HOVER || Focused && Enabled) { graphics.FillPath(new SolidBrush(Color.FromArgb(Convert.ToInt32(Math.Round(defaultAniOpacity * 0.3, 0)), primaryColor)), mainSketch); } } else { mainSketch = GraphicHelper.GetRoundedRectangle(1, 1, Width - 2, Height - 2, radius); graphics.DrawPath(new Pen(Color.FromArgb(165, Color.Gray)), mainSketch); } graphics.SmoothingMode = SmoothingMode.HighQuality; if (icon != null) { graphics.DrawImage(icon, iconArea); } if (this.Enabled) { graphics.DrawString(Text, this.Font, new SolidBrush(this.ForeColor), drawArea, textAlignment); } else { graphics.DrawString(Text, this.Font, new SolidBrush(Color.FromArgb(125, Color.Gray)), drawArea, textAlignment); } mainSketch.Dispose(); region.Dispose(); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics graphics = e.Graphics; graphics.SmoothingMode = SmoothingMode.HighQuality; GraphicsPath mainSketch = new GraphicsPath(); switch (cardStyle) { case CardStyle.Elevated: mainSketch = GraphicHelper.GetRoundedRectangle(5, 5, Width - 10, Height - 10, radius); graphics.Clear(Parent.BackColor); /* -- Draw shadow -- */ if ((MouseState == MouseState.HOVER || Focused) && mouseInteract) { for (int i = 0; i < shadowDepth + 1; i++) { var shadowSketch = GraphicHelper.GetRoundedRectangle(5 - i, 5 - i + 2, Width - 10 + i * 2, Height - 10 + i * 2, radius); graphics.FillPath(new SolidBrush(Color.FromArgb(shadowOpacity + 10 - (5 * i), Color.Black)), shadowSketch); } } else { for (int i = 0; i < shadowDepth; i++) { var shadowSketch = GraphicHelper.GetRoundedRectangle(5 - i, 5 - i + 1, Width - 10 + i * 2, Height - 10 + i * 2, radius); graphics.FillPath(new SolidBrush(Color.FromArgb(shadowOpacity - (5 * i), Color.Black)), shadowSketch); } } /* ----------------- */ graphics.FillPath(new SolidBrush(cardColor), mainSketch); break; case CardStyle.Outlined: mainSketch = GraphicHelper.GetRoundedRectangle(4, 4, Width - 8, Height - 8, radius + 1); graphics.DrawPath(new Pen(Color.Gray, 1.4f), mainSketch); if ((MouseState == MouseState.HOVER || Focused) && mouseInteract) { for (int i = 0; i < 4; i++) { var shadowSketch = GraphicHelper.GetRoundedRectangle(5 - i, 5 - i + 2, Width - 10 + i * 2, Height - 10 + i * 2, radius); graphics.FillPath(new SolidBrush(Color.FromArgb(shadowOpacity - 20 - (5 * i), Color.Black)), shadowSketch); } } graphics.FillPath(new SolidBrush(cardColor), mainSketch); break; default: break; } mainSketch.Dispose(); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics graphics = e.Graphics; graphics.SmoothingMode = SmoothingMode.HighQuality; if (Parent is MaterialCard) graphics.Clear(((MaterialCard)Parent).CardColor); else graphics.Clear(mainParent.BackColor); GraphicsPath mainSketch = GraphicHelper.GetRoundedRectangle(0, 0, Width, Height, 5); graphics.FillPath(new SolidBrush(BackColor), mainSketch); graphics.DrawString(strMessage, MessageFont, (darkTheme) ? Brushes.DimGray : Brushes.WhiteSmoke, messageArea, textAlignment); }
protected override void OnPaint(PaintEventArgs pevent) { base.OnPaint(pevent); Graphics graphics = pevent.Graphics; graphics.SmoothingMode = SmoothingMode.HighQuality; if (Parent is IMaterialControl) { graphics.Clear(((MaterialCard)Parent).CardColor); } else { graphics.Clear(Parent.BackColor); } GraphicsPath sketch = GraphicHelper.GetRoundedRectangle(5, 5, Height - 10, Height - 10, 1); graphics.FillEllipse(new SolidBrush(Color.FromArgb(aniAlpha2, Color.Gray)), 0, 0, Height, Height); Region region = new Region(sketch); if (Enabled) { if (Focused || MouseState == MouseState.HOVER) { if (!Checked) { graphics.FillEllipse(new SolidBrush(Color.FromArgb(90, Color.Gray)), 0, 0, Height, Height); } else { graphics.FillEllipse(new SolidBrush(Color.FromArgb(90, primaryColor)), 0, 0, Height, Height); } } if (!Checked && !animationDirector1.Enabled) { graphics.DrawPath(new Pen(new SolidBrush(borderColor), 2), sketch); } else { graphics.DrawPath(new Pen(new SolidBrush(primaryColor), 2), sketch); } graphics.SetClip(region, CombineMode.Replace); graphics.FillRectangle(new SolidBrush(primaryColor), aniLocation, aniLocation, aniSize, aniSize); graphics.ResetClip(); if (Checked) { switch (CheckState) { case CheckState.Checked: GraphicHelper.DrawSymbolMark(graphics, new Pen(Color.FromArgb(aniAlpha, markColor), 2), 0, 0, Height, Height, 8); break; case CheckState.Indeterminate: graphics.DrawLine(new Pen(Color.FromArgb(aniAlpha, markColor), 2), 5 + (int)Height / 12, (int)(Height / 2), Height - 7, (int)(Height / 2)); break; default: break; } } graphics.DrawString(Text, Font, new SolidBrush(this.ForeColor), textArea, textAglignment); } else { graphics.DrawPath(new Pen(new SolidBrush(Color.Silver), 2), sketch); graphics.SetClip(region, CombineMode.Replace); graphics.FillRectangle(new SolidBrush(Color.Silver), aniLocation, aniLocation, aniSize, aniSize); graphics.ResetClip(); if (Checked) { switch (CheckState) { case CheckState.Checked: GraphicHelper.DrawSymbolMark(graphics, new Pen(Color.White, 2), 0, 0, Height, Height, 7); break; case CheckState.Indeterminate: graphics.DrawLine(new Pen(Color.White, 2), 5 + (int)Height / 12, (int)(Height / 2), Height - 7, (int)(Height / 2)); break; default: break; } } graphics.DrawString(Text, Font, new SolidBrush(Color.Silver), textArea, textAglignment); } sketch.Dispose(); region.Dispose(); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics graphics = e.Graphics; graphics.SmoothingMode = SmoothingMode.HighQuality; Pen pen = new Pen(new SolidBrush(Color.FromArgb(180, Color.Gray)), 1.5f); GraphicsPath mainSketch = new GraphicsPath(); Color ParentColor; float[] dashValues = { 4, 2 }; pen.DashPattern = dashValues; if (Parent is IMaterialControl) { ParentColor = ((MaterialCard)Parent).CardColor; } else { ParentColor = Parent.BackColor; } graphics.Clear(ParentColor); if (Enabled) { switch (comboBoxType) { case BoxType.Normal: graphics.DrawLine(new Pen(new SolidBrush((MouseState == MouseState.OUT) ? Color.Gray : primaryColor), (MouseState == MouseState.OUT) ? 1.3f : 1.6f), 0, Height - 4, Width, Height - 4); break; case BoxType.Outlined: mainSketch = GraphicHelper.GetRoundedRectangle(2, topPadding / 2, Width - 4, Height - topPadding / 2 - 2, 4); if (Focused) { graphics.DrawPath(new Pen(primaryColor, 2.2f), mainSketch); } else { graphics.DrawPath(new Pen((MouseState == MouseState.OUT) ? Color.DimGray : primaryColor, (MouseState == MouseState.OUT) ? 1.3f : 1.6f), mainSketch); } break; case BoxType.Filled: mainSketch = GraphicHelper.GetRoundedRectangle(0, 0, Width, Height - 2, 4); graphics.FillPath(new SolidBrush(Color.FromArgb(Focused ? 255 : 200, Color.WhiteSmoke)), mainSketch); graphics.DrawLine(new Pen(new SolidBrush((MouseState == MouseState.OUT) ? Color.Gray : primaryColor), (MouseState == MouseState.OUT) ? 1.3f : 1.6f), 0, Height - 4, Width, Height - 4); break; default: break; } } else { switch (comboBoxType) { case BoxType.Normal: graphics.DrawLine(pen, 0, Height - 4, Width, Height - 4); break; case BoxType.Outlined: mainSketch = GraphicHelper.GetRoundedRectangle(2, topPadding / 2, Width - 4, Height - topPadding / 2 - 2, 4); graphics.DrawPath(pen, mainSketch); break; case BoxType.Filled: mainSketch = GraphicHelper.GetRoundedRectangle(0, 0, Width, Height - 2, 4); graphics.FillPath(new SolidBrush(Color.WhiteSmoke), mainSketch); graphics.DrawLine(pen, 0, Height - 4, Width, Height - 4); break; default: break; } } if (comboBoxType == BoxType.Outlined) { SizeF hintRec = this.CreateGraphics().MeasureString(hintText, hintFont); graphics.FillRectangle(new SolidBrush(ParentColor), 7, hintLocation / 2, hintRec.Width, hintRec.Height); } graphics.DrawString(hintText, hintFont, new SolidBrush(Focused ? primaryColor : (SelectedItem != null) ? Color.Gray : Color.Silver), 8, hintLocation, textAglignment); if (SelectedItem != null) { graphics.DrawString(SelectedItem.ToString(), this.Font, new SolidBrush(ForeColor), 8, Height / 2 + topPadding / 2 - 2, textAglignment); } GraphicsPath triangle = new GraphicsPath(); triangle.AddLine(trianglePoints[0], trianglePoints[1]); triangle.AddLine(trianglePoints[1], trianglePoints[2]); triangle.AddLine(trianglePoints[0], trianglePoints[2]); triangle.CloseFigure(); graphics.FillPath(new SolidBrush((Focused || MouseState == MouseState.HOVER) ? primaryColor : Color.Gray), triangle); if (comboBoxType != BoxType.Outlined) { graphics.DrawLine(new Pen(new SolidBrush(primaryColor), 2.6f), firstDot, Height - 4, middleDot, Height - 4); graphics.DrawLine(new Pen(new SolidBrush(primaryColor), 2.6f), middleDot, Height - 4, lastDot, Height - 4); } mainSketch.Dispose(); pen.Dispose(); }
protected override void OnPaint(PaintEventArgs pevent) { base.OnPaint(pevent); Graphics graphics = pevent.Graphics; graphics.SmoothingMode = SmoothingMode.HighQuality; Region region = new Region(); if (Parent is MaterialCard) { graphics.Clear(((MaterialCard)Parent).CardColor); } else { graphics.Clear(Parent.BackColor); } GraphicsPath mainSketch; if (this.Enabled) { mainSketch = GraphicHelper.GetRoundedRectangle(6, 6, Width - 12, Height - 12, radius); region = new Region(mainSketch); /* -- Draw shadow -- */ if (MouseState == MouseState.HOVER || Focused) { if (MouseState == MouseState.HOVER || MouseState == MouseState.OUT) { for (int i = 0; i < shadowDepth; i++) { var shadowSketch = GraphicHelper.GetRoundedRectangle(6 - i, 6 - i + 2, Width - 12 + i * 2, Height - 12 + i * 2, radius + 2); graphics.FillPath(new SolidBrush(Color.FromArgb(shadowOpacity + 10 - (5 * i), Color.Black)), shadowSketch); } } else { for (int i = 0; i < shadowDepth + 1; i++) { var shadowSketch = GraphicHelper.GetRoundedRectangle(6 - i, 6 - i + 2, Width - 12 + i * 2, Height - 12 + i * 2, radius + 2); graphics.FillPath(new SolidBrush(Color.FromArgb(shadowOpacity + 10 - (5 * i), Color.Black)), shadowSketch); } } } else { for (int i = 0; i < shadowDepth; i++) { var shadowSketch = GraphicHelper.GetRoundedRectangle(6 - i, 6 - i + 1, Width - 12 + i * 2, Height - 12 + i * 2, radius + 1); graphics.FillPath(new SolidBrush(Color.FromArgb(shadowOpacity - (5 * i), Color.Black)), shadowSketch); } } /* ----------------- */ graphics.FillPath(new SolidBrush(primaryColor), mainSketch); graphics.SetClip(region, CombineMode.Replace); graphics.SmoothingMode = SmoothingMode.HighSpeed; graphics.FillEllipse(new SolidBrush(Color.FromArgb(aniOpacity, effectColor)), mouseX - (animationSize / 2), mouseY - (animationSize / 2), animationSize, animationSize); graphics.SmoothingMode = SmoothingMode.AntiAlias; if (MouseState == MouseState.HOVER || Focused && Enabled) { graphics.FillPath(new SolidBrush(Color.FromArgb(Convert.ToInt32(Math.Round(defaultAniOpacity * 0.3, 0)), effectColor)), mainSketch); } } else { mainSketch = GraphicHelper.GetRoundedRectangle(6, 6, Width - 12, Height - 12, radius); graphics.FillPath(new SolidBrush(Color.FromArgb(95, Color.Gray)), mainSketch); } graphics.SmoothingMode = SmoothingMode.HighQuality; if (icon != null) { graphics.DrawImage(icon, iconArea); } if (this.Enabled) { graphics.DrawString(Text, this.Font, new SolidBrush(this.ForeColor), drawArea, textAlignment); } else { graphics.DrawString(Text, this.Font, new SolidBrush(Color.FromArgb(125, Color.Gray)), drawArea, textAlignment); } mainSketch.Dispose(); region.Dispose(); }