using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Drawing; using System.Drawing.Drawing2D; namespace DevComponents.DotNetBar.Layout { internal class InsertMarker : Control { #region Constructor /// /// Initializes a new instance of the InsertMarker class. /// public InsertMarker() { this.SetStyle(ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.OptimizedDoubleBuffer, true); } #endregion #region Implementation protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; using (SolidBrush brush = new SolidBrush(this.ForeColor)) { g.FillRectangle(brush, new Rectangle(0, 0, this.Width, 2)); g.FillRectangle(brush, new Rectangle(0, this.Height - 2, this.Width, 2)); g.FillRectangle(brush, this.Width / 2 - 1, 0, 2, this.Height); } base.OnPaint(e); } protected override void OnHandleCreated(EventArgs e) { UpdateRegion(); base.OnHandleCreated(e); } protected override void OnResize(EventArgs e) { UpdateRegion(); base.OnResize(e); } private void UpdateRegion() { GraphicsPath path = new GraphicsPath(); path.AddLine(0, 0, this.Width, 0); path.AddLine(this.Width, 0, this.Width, 2); path.AddLine(this.Width, 2, this.Width / 2 - 1, 2); path.AddLine(this.Width / 2 + 1, 2, this.Width / 2 + 1, this.Height-2); path.AddLine(this.Width / 2 + 1, this.Height - 2, this.Width, this.Height-2); path.AddLine(this.Width, this.Height - 2, this.Width, this.Height); path.AddLine(this.Width, this.Height, 0, this.Height); path.AddLine(0, this.Height, 0, this.Height-2); path.AddLine(0, this.Height - 2, this.Width/2-1, this.Height-2); path.AddLine(this.Width / 2 - 1, this.Height - 2, this.Width/2-1, 2); path.AddLine(this.Width / 2 - 1, 2, 0, 2); path.CloseAllFigures(); Region reg = new Region(); reg.MakeEmpty(); reg.Union(path); path.Widen(SystemPens.Control); //Region r2 = new Region(path); reg.Union(path); this.Region = reg; } #endregion } }