private void LbxItemsDrawItem(object sender, DrawItemEventArgs e) { Rectangle outer = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { e.Graphics.FillRectangle(SystemBrushes.Highlight, outer); } else { Brush b = new SolidBrush(BackColor); e.Graphics.FillRectangle(b, outer); b.Dispose(); } Rectangle inner = new Rectangle(e.Bounds.X + 5, e.Bounds.Y + 1, e.Bounds.Width - 10, e.Bounds.Height - 3); e.Graphics.FillRectangle(Brushes.White, inner); e.Graphics.DrawRectangle(Pens.Black, inner); IStroke stroke = _lbxItems.Items[e.Index] as IStroke; if (stroke == null) { return; } GraphicsPath gp = new GraphicsPath(); gp.AddLine(new Point(e.Bounds.X + 10, e.Bounds.Y + e.Bounds.Height / 2), new Point(e.Bounds.Width - 10, e.Bounds.Y + e.Bounds.Height / 2)); stroke.DrawPath(e.Graphics, gp, 1); gp.Dispose(); }
/// <summary> /// This is an optional expression that allows drawing to the specified GraphicsPath. /// Overriding this allows for unconventional behavior to be included, such as /// specifying marker decorations, rather than simply returning a pen. A pen /// is also returned publicly for convenience. /// </summary> /// <param name="g">The Graphics device to draw to</param> /// <param name="path">the GraphicsPath to draw</param> /// <param name="scaleWidth">This is 1 for symbolic drawing, but could be /// any number for geographic drawing.</param> public virtual void DrawPath(Graphics g, GraphicsPath path, double scaleWidth) { if (_innerStroke != null) { _innerStroke.DrawPath(g, path, scaleWidth); return; } Pen p = ToPen(scaleWidth); try { g.DrawPath(p, path); } catch (Exception ex) { Debug.WriteLine("Writeline Stroke.DrawPath:" + ex); } p.Dispose(); }