private void DrawBackGround(Graphics g) { GDIHelper.InitializeGraphics(g); Rectangle rect = new Rectangle(1, 1, base.Width - 3, base.Height - 3); RoundRectangle roundRect = new RoundRectangle(rect, new CornerRadius(_CornerRadius)); switch (_ControlState) { case EnumControlState.Default: if (base.FlatStyle != 0) { GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.DefaultControlColor); GDIHelper.DrawPathBorder(g, roundRect); } break; case EnumControlState.HeightLight: GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.HeightLightControlColor); GDIHelper.DrawPathBorder(g, roundRect); break; case EnumControlState.Focused: GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.FocusedControlColor); GDIHelper.DrawPathBorder(g, roundRect); GDIHelper.DrawPathInnerBorder(g, roundRect); break; } }
private void DrawButton(Graphics g) { EnumControlState enumControlState = (!GetComboBoxButtonPressed()) ? EnumControlState.Default : EnumControlState.HeightLight; Rectangle rect = new Rectangle(ButtonRect.X - 2, ButtonRect.Y - 1, ButtonRect.Width + 1 + _Margin, ButtonRect.Height + 2); RoundRectangle roundRect = new RoundRectangle(rect, new CornerRadius(0, _CornerRadius, 0, _CornerRadius)); Blend blend = new Blend(3); blend.Positions = new float[3] { 0f, 0.5f, 1f }; blend.Factors = new float[3] { 0f, 1f, 0f }; GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.DefaultControlColor); Size arrowSize = new Size(12, 7); System.Windows.Forms.ArrowDirection direction = System.Windows.Forms.ArrowDirection.Down; GDIHelper.DrawArrow(g, direction, rect, arrowSize, 0f, Color.FromArgb(30, 178, 239)); Color borderColor = SkinManager.CurrentSkin.BorderColor; GDIHelper.DrawGradientLine(g, borderColor, 90, rect.X, rect.Y, rect.X, rect.Bottom - 1); }
public static void DrawCheckBox(Graphics g, RoundRectangle roundRect) { using (GraphicsPath path = roundRect.ToGraphicsBezierPath()) { using (PathGradientBrush pathGradientBrush = new PathGradientBrush(path)) { pathGradientBrush.CenterColor = SkinManager.CurrentSkin.BaseColor; pathGradientBrush.SurroundColors = new Color[1] { SkinManager.CurrentSkin.BorderColor }; Blend blend = new Blend(); blend.Positions = new float[3] { 0f, 0.18f, 1f }; blend.Factors = new float[3] { 0f, 0.89f, 1f }; pathGradientBrush.Blend = blend; g.FillPath(pathGradientBrush, path); } DrawPathBorder(g, roundRect); } }
protected override void OnRenderImageMargin(ToolStripRenderEventArgs e) { ToolStrip toolStrip = e.ToolStrip; Graphics graphics = e.Graphics; GDIHelper.InitializeGraphics(graphics); Rectangle affectedBounds = e.AffectedBounds; affectedBounds.Width--; affectedBounds.Height--; if (toolStrip is ToolStripDropDown) { affectedBounds.Width = _OffsetMargin; Color menuImageMarginBackColor = MenuImageMarginBackColor; RoundRectangle roundRectangle = new RoundRectangle(cornerRadius: new CornerRadius(MenuCornerRadius), rect: affectedBounds); GDIHelper.FillPath(graphics, new RoundRectangle(affectedBounds, new CornerRadius(MenuCornerRadius, 0, MenuCornerRadius, 0)), menuImageMarginBackColor, menuImageMarginBackColor); Image menuImageBackImage = MenuImageBackImage; if (menuImageBackImage != null && ShowMenuBackImage) { ImageAttributes imageAttributes = new ImageAttributes(); GDIHelper.SetImageOpacity(imageAttributes, MenuImageBackImageOpacity); graphics.DrawImage(Resources.logo_mini, new Rectangle(affectedBounds.X + 1, affectedBounds.Y + 2, menuImageBackImage.Width, menuImageBackImage.Height), 0, 0, menuImageBackImage.Width, menuImageBackImage.Height, GraphicsUnit.Pixel, imageAttributes); } Point pt = new Point(affectedBounds.X + _OffsetMargin, affectedBounds.Y + 3); Point pt2 = new Point(affectedBounds.X + _OffsetMargin, affectedBounds.Bottom - 3); using (Pen pen = new Pen(SkinManager.CurrentSkin.BorderColor)) { graphics.DrawLine(pen, pt, pt2); } } else { base.OnRenderImageMargin(e); } }
public static void DrawPathOuterBorder(Graphics g, RoundRectangle roundRect, Color color, int borderWidth) { Rectangle rect = roundRect.Rect; rect.X--; rect.Y--; rect.Width += 2; rect.Height += 2; DrawPathBorder(g, new RoundRectangle(rect, roundRect.CornerRadius), color, borderWidth); }
public static void DrawPathInnerBorder(Graphics g, RoundRectangle roundRect, Color color) { Rectangle rect = roundRect.Rect; rect.X++; rect.Y++; rect.Width -= 2; rect.Height -= 2; DrawPathBorder(g, new RoundRectangle(rect, roundRect.CornerRadius), color); }
public static void DrawPathBorder(Graphics g, RoundRectangle roundRect, Color color, int borderWidth) { using (GraphicsPath path = roundRect.ToGraphicsBezierPath()) { using (Pen pen = new Pen(color, (float)borderWidth)) { g.DrawPath(pen, path); } } }
protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e) { ToolStripItem item = e.Item; Graphics graphics = e.Graphics; GDIHelper.InitializeGraphics(graphics); if (item.Tag != null && item.Tag.Equals("Vicky")) { int num = (item.Width >= item.Height) ? item.Height : item.Width; Rectangle rect = new Rectangle(0, 0, num, num); rect.Inflate(-1, -1); Color empty = Color.Empty; Color empty2 = Color.Empty; Color lightColor = Color.FromArgb(255, 220, 102); Blend blend = new Blend(); blend.Positions = new float[3] { 0f, 0.5f, 1f }; blend.Factors = new float[3] { 0.25f, 0.75f, 1f }; Color color = (item.Selected || item.Pressed) ? Color.FromArgb(24, 116, 205) : SkinManager.CurrentSkin.BorderColor; float width = 1f; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; if (item.Selected || item.Pressed) { width = 2f; empty = Color.FromArgb(255, 226, 48); empty2 = Color.FromArgb(255, 220, 102); GDIHelper.DrawCrystalButton(graphics, rect, empty, empty2, lightColor, blend); } using (Pen pen = new Pen(color, width)) { graphics.DrawEllipse(pen, rect); } } else { Rectangle rect = new Rectangle(1, 1, item.Width - 4, item.Height - 3); RoundRectangle roundRect = new RoundRectangle(rect, ItemCornerRadius); if (item.Selected || item.Pressed) { GDIHelper.FillRectangle(graphics, roundRect, SkinManager.CurrentSkin.HeightLightControlColor); GDIHelper.DrawPathBorder(graphics, roundRect); } } }
private void DrawButton(Graphics g) { EnumControlState enumControlState = (!GetComboBoxButtonPressed()) ? EnumControlState.Default : EnumControlState.HeightLight; Rectangle rect = new Rectangle(ButtonRect.X, ButtonRect.Y - 1, ButtonRect.Width + 1 + _Margin, ButtonRect.Height + 2); RoundRectangle roundRect = new RoundRectangle(rect, new CornerRadius(0)); GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.DefaultControlColor); GDIHelper.DrawArrow(arrowSize: new Size(12, 7), g: g, direction: System.Windows.Forms.ArrowDirection.Down, rect: rect, offset: 0f, c: Color.FromArgb(30, 178, 239)); Color borderColor = SkinManager.CurrentSkin.BorderColor; GDIHelper.DrawGradientLine(g, borderColor, 90, rect.X, rect.Y, rect.X, rect.Bottom - 1); }
public static void FillPath(Graphics g, RoundRectangle roundRect, Color color1, Color color2) { if (roundRect.Rect.Width > 0 && roundRect.Rect.Height > 0) { using (GraphicsPath path = roundRect.ToGraphicsBezierPath()) { using (LinearGradientBrush brush = new LinearGradientBrush(roundRect.Rect, color1, color2, LinearGradientMode.Vertical)) { g.FillPath(brush, path); } } } }
public static void FillRectangle(Graphics g, RoundRectangle roundRect, Color color) { if (roundRect.Rect.Width > 0 && roundRect.Rect.Height > 0) { using (GraphicsPath path = roundRect.ToGraphicsBezierPath()) { using (Brush brush = new SolidBrush(color)) { g.FillPath(brush, path); } } } }
private void ResetRegion() { if (_CornerRadius > 0) { Rectangle rect = new Rectangle(Point.Empty, base.Size); RoundRectangle roundRectangle = new RoundRectangle(rect, new CornerRadius(_CornerRadius)); if (base.Region != null) { base.Region.Dispose(); } base.Region = new Region(roundRectangle.ToGraphicsBezierPath()); } }
internal void CreateToolStripRegion(ToolStrip toolStrip, RoundRectangle roundRect) { using (GraphicsPath graphicsPath = roundRect.ToGraphicsBezierPath()) { Region region = new Region(graphicsPath); graphicsPath.Widen(new Pen(MenuBorderColor)); region.Union(graphicsPath); if (toolStrip.Region != null) { toolStrip.Region.Dispose(); } toolStrip.Region = region; } }
private void DrawDefaultBorder(Graphics g, Rectangle textRect) { Rectangle rect = default(Rectangle); rect.X = 0; rect.Y = textRect.Height / 2; rect.Height = base.Height - textRect.Height / 2 - 1; rect.Width = base.Width - 1; RoundRectangle roundRect = new RoundRectangle(rect, new CornerRadius(_CornerRadius)); g.SetClip(textRect, CombineMode.Exclude); GDIHelper.DrawPathBorder(g, roundRect, _BorderColor, _BorderWidth); g.ResetClip(); }
public static void FillRectangle(Graphics g, RoundRectangle roundRect, GradientColor color) { if (roundRect.Rect.Width > 0 && roundRect.Rect.Height > 0) { using (GraphicsPath path = roundRect.ToGraphicsBezierPath()) { using (LinearGradientBrush linearGradientBrush = new LinearGradientBrush(roundRect.Rect, color.First, color.Second, LinearGradientMode.Vertical)) { linearGradientBrush.Blend.Factors = color.Factors; linearGradientBrush.Blend.Positions = color.Positions; g.FillPath(linearGradientBrush, path); } } } }
protected override void OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs e) { ToolStripItem item = e.Item; Graphics graphics = e.Graphics; GDIHelper.InitializeGraphics(graphics); Rectangle rect = new Rectangle(0, 0, item.Width - 1, item.Height - 1); RoundRectangle roundRect = new RoundRectangle(rect, ItemCornerRadius); if (item.Selected || item.Pressed) { GDIHelper.FillRectangle(graphics, roundRect, SkinManager.CurrentSkin.HeightLightControlColor); GDIHelper.DrawPathBorder(graphics, roundRect); } }
private void DrawFormBorder(Graphics g) { if (base.WindowState != FormWindowState.Maximized) { Rectangle rect = new Rectangle(0, 0, base.Width - 2, base.Height - 2); RoundRectangle roundRectangle = new RoundRectangle(rect, new CornerRadius(CornerRadius)); GDIHelper.DrawPathBorder(g, roundRectangle); using (GraphicsPath path = (_CornerRadius == 0) ? roundRectangle.ToGraphicsBezierPath() : roundRectangle.ToGraphicsArcPath()) { using (Pen pen = new Pen(SkinManager.CurrentSkin.BorderColor)) { g.DrawPath(pen, path); } } } }
private void DrawComboBox(Graphics g) { GDIHelper.InitializeGraphics(g); Rectangle rect = new Rectangle(Point.Empty, base.Size); rect.Width--; rect.Height--; RoundRectangle roundRect = new RoundRectangle(rect, 0); Color color = base.Enabled ? _BackColor : SystemColors.Control; g.SetClip(EditRect, CombineMode.Exclude); GDIHelper.FillRectangle(g, roundRect, color); g.ResetClip(); DrawButton(g); GDIHelper.DrawPathBorder(g, roundRect); }
private void DrawBorder(Graphics g) { GDIHelper.InitializeGraphics(g); Rectangle rect = new Rectangle(1, 1, base.Width - 3, base.Height - 3); RoundRectangle roundRect = new RoundRectangle(rect, _CornerRadius); Color color = (!_TextBox.Enabled || _TextBox.ReadOnly) ? Color.FromArgb(215, 250, 243) : Color.White; _TextBox.BackColor = color; GDIHelper.FillPath(g, roundRect, color, color); GDIHelper.DrawPathBorder(g, roundRect, _BorderColor); if (_ControlState == EnumControlState.HeightLight) { GDIHelper.DrawPathBorder(g, roundRect, SkinManager.CurrentSkin.HeightLightControlColor.Second); GDIHelper.DrawPathOuterBorder(g, roundRect, SkinManager.CurrentSkin.HeightLightControlColor.First); } }
protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) { ToolStripItem item = e.Item; Graphics graphics = e.Graphics; GDIHelper.InitializeGraphics(graphics); Rectangle rect = new Rectangle(2, -1, item.Width - 4, item.Height + 1); RoundRectangle roundRectangle = new RoundRectangle(rect, new CornerRadius(0)); if (item.Selected || item.Pressed) { Color baseColor = Color.FromArgb(200, SkinManager.CurrentSkin.HeightLightControlColor.First); Color color = Color.FromArgb(250, baseColor); GDIHelper.FillRectangle(graphics, rect, SkinManager.CurrentSkin.HeightLightControlColor); } }
private void DrawContent(Graphics g) { GDIHelper.InitializeGraphics(g); int width = base.Width; int height = base.Height; Rectangle rectangle = new Rectangle(_Margin, height / 2 - _BoxSize.Height / 2, _BoxSize.Width, _BoxSize.Height); Size size = g.MeasureString(Text, Font).ToSize(); Rectangle rect = default(Rectangle); rect.X = rectangle.Right + _Margin; rect.Y = _Margin; rect.Height = base.Height - _Margin * 2; rect.Width = size.Width; RoundRectangle roundRect = new RoundRectangle(rectangle, _CornerRadius); EnumControlState controlState = _ControlState; if (controlState == EnumControlState.HeightLight) { GDIHelper.DrawPathBorder(g, roundRect, SkinManager.CurrentSkin.OuterBorderColor); GDIHelper.DrawPathInnerBorder(g, roundRect, SkinManager.CurrentSkin.HeightLightControlColor.First); } else { GDIHelper.DrawCheckBox(g, roundRect); } Color forceColor = base.Enabled ? ForeColor : SkinManager.CurrentSkin.UselessColor; GDIHelper.DrawImageAndString(g, rect, null, Size.Empty, Text, Font, forceColor); switch (base.CheckState) { case CheckState.Checked: GDIHelper.DrawCheckedStateByImage(g, rectangle); break; case CheckState.Indeterminate: { Rectangle rect2 = rectangle; rect2.Inflate(-3, -3); Color color = Color.FromArgb(46, 117, 35); GDIHelper.FillRectangle(g, new RoundRectangle(rect2, _CornerRadius), color); break; } } }
protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) { ToolStrip toolStrip = e.ToolStrip; Graphics graphics = e.Graphics; GDIHelper.InitializeGraphics(graphics); Rectangle affectedBounds = e.AffectedBounds; if (toolStrip is ToolStripDropDown) { affectedBounds.Width--; affectedBounds.Height--; RoundRectangle roundRect = new RoundRectangle(cornerRadius: new CornerRadius(MenuCornerRadius), rect: affectedBounds); GDIHelper.DrawPathBorder(graphics, roundRect, MenuBorderColor); } else { base.OnRenderToolStripBorder(e); } }
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) { ToolStrip toolStrip = e.ToolStrip; Graphics graphics = e.Graphics; GDIHelper.InitializeGraphics(graphics); Rectangle imageRectangle = e.ImageRectangle; if (toolStrip is ToolStripDropDown) { imageRectangle.Width -= 2; imageRectangle.Height -= 2; RoundRectangle roundRect = new RoundRectangle(imageRectangle, 1); GDIHelper.DrawCheckBox(graphics, roundRect); GDIHelper.DrawCheckedStateByImage(graphics, imageRectangle); } else { base.OnRenderItemCheck(e); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); int num = (BorderWidth > 0) ? BorderWidth : 0; Graphics graphics = e.Graphics; GDIHelper.InitializeGraphics(graphics); GradientColor color = new GradientColor(_BackBeginColor, _BackEndColor, null, null); Rectangle rect = new Rectangle(0, 0, base.Size.Width - 1, base.Size.Height - 1); RoundRectangle roundRect = new RoundRectangle(rect, new CornerRadius(_CornerRadius)); GDIHelper.FillRectangle(graphics, roundRect, color); if (_BorderWidth > 0) { rect.X += _BorderWidth - 1; rect.Y += _BorderWidth - 1; rect.Width -= _BorderWidth - 1; rect.Height -= _BorderWidth - 1; GDIHelper.DrawPathBorder(graphics, new RoundRectangle(rect, new CornerRadius(_CornerRadius)), _BorderColor, BorderWidth); } }
internal void RenderButton(Graphics g, Rectangle rect, Color baseColor, Color borderColor, Color arrowColor, ArrowDirection direction) { CornerRadius cornerRadius = default(CornerRadius); switch (direction) { case ArrowDirection.Left: cornerRadius = new CornerRadius(2, 0, 2, 0); break; case ArrowDirection.Right: cornerRadius = new CornerRadius(0, 2, 0, 2); break; } RoundRectangle roundRect = new RoundRectangle(rect, cornerRadius); GDIHelper.FillPath(g, roundRect, baseColor, baseColor); GDIHelper.DrawPathBorder(g, roundRect); using (SolidBrush brush = new SolidBrush(arrowColor)) { RenderArrowInternal(g, rect, direction, brush); } }
protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) { ToolStrip toolStrip = e.ToolStrip; Graphics graphics = e.Graphics; GDIHelper.InitializeGraphics(graphics); Rectangle affectedBounds = e.AffectedBounds; RoundRectangle roundRect = new RoundRectangle(cornerRadius: new CornerRadius(MenuCornerRadius), rect: affectedBounds); if (toolStrip is ToolStripDropDown || toolStrip is ContextMenuStrip) { CreateToolStripRegion(toolStrip, roundRect); GDIHelper.FillPath(graphics, roundRect, BackColor, BackColor); } else if (toolStrip is TXMenuStrip) { TXMenuStrip tXMenuStrip = toolStrip as TXMenuStrip; Color beginBackColor = tXMenuStrip.BeginBackColor; Color endBackColor = tXMenuStrip.EndBackColor; GDIHelper.FillPath(graphics, new RoundRectangle(affectedBounds, new CornerRadius(0)), beginBackColor, endBackColor); } else if (toolStrip is TXToolStrip) { affectedBounds.Inflate(1, 1); TXToolStrip tXToolStrip = toolStrip as TXToolStrip; Color beginBackColor = tXToolStrip.BeginBackColor; Color endBackColor = tXToolStrip.EndBackColor; GDIHelper.FillPath(graphics, new RoundRectangle(affectedBounds, new CornerRadius(0)), beginBackColor, endBackColor); } else if (toolStrip is TXStatusStrip) { TXStatusStrip tXStatusStrip = toolStrip as TXStatusStrip; Color beginBackColor = tXStatusStrip.BeginBackColor; Color endBackColor = tXStatusStrip.EndBackColor; GDIHelper.FillPath(graphics, new RoundRectangle(affectedBounds, new CornerRadius(0)), beginBackColor, endBackColor); } }
public static void FillPath(Graphics g, RoundRectangle roundRect, Color color1, Color color2, Blend blend) { GradientColor color3 = new GradientColor(color1, color2, blend.Factors, blend.Positions); FillRectangle(g, roundRect, color3); }
public static void DrawPathBorder(Graphics g, RoundRectangle roundRect, Color color) { DrawPathBorder(g, roundRect, color, 1); }
public static void DrawPathInnerBorder(Graphics g, RoundRectangle roundRect) { Color innerBorderColor = SkinManager.CurrentSkin.InnerBorderColor; DrawPathInnerBorder(g, roundRect, innerBorderColor); }
public static void DrawPathOuterBorder(Graphics g, RoundRectangle roundRect) { DrawPathOuterBorder(g, roundRect, SkinManager.CurrentSkin.OuterBorderColor); }