private void DrawShape(Graphics g, DecorationMode mode, DecorationShape ds, Pen pen, Rectangle rect) { const int margin = 5; Rectangle where = rect; where.Inflate(-margin, 0); if (mode == DecorationMode.None) { return; } switch (ds) { case DecorationShape.Rectangle: g.DrawRectangle(pen, where); break; case DecorationShape.Ellipse: g.DrawEllipse(pen, where); break; case DecorationShape.Cross: g.DrawLine(pen, new Point(where.X, where.Y), new Point(where.X + where.Width, where.Y + where.Height)); g.DrawLine(pen, new Point(where.X + where.Width, where.Y), new Point(where.X, where.Y + where.Height)); break; default: throw new Exception("Unknown shape"); } }
public Decoration(DecorationMode mode, DecorationShape shape, PenStyle penstyle, int padding) { this.mode = mode; this.shape = shape; this.penstyle = penstyle; this.padding = padding; }
public Decoration(DecorationMode mode, DecorationShape shape) { this.mode = mode; this.shape = shape; this.penstyle = new PenStyle(Color.Black, 1.0f, DashStyle.Solid, ArrowStyle.None); this.padding = 4; }
private void shapeComboBox_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); const int margin = 5; Rectangle where = e.Bounds; where.Inflate(-margin, -margin); DecorationShape shape = shapes[e.Index]; using (Graphics g = e.Graphics) using (Pen pen = new Pen(DrawItemStateToColor(e.State))) { DrawShape(g, DecorationMode.Node, shape, pen, where); } }
private void DrawShape(Graphics g, DecorationMode mode, DecorationShape ds, Pen pen, Rectangle rect) { const int margin = 5; Rectangle where = rect; where.Inflate(-margin, 0); if (mode == DecorationMode.None) return; switch (ds) { case DecorationShape.Rectangle: g.DrawRectangle(pen, where); break; case DecorationShape.Ellipse: g.DrawEllipse(pen, where); break; case DecorationShape.Cross: g.DrawLine(pen, new Point(where.X, where.Y), new Point(where.X + where.Width, where.Y + where.Height)); g.DrawLine(pen, new Point(where.X + where.Width, where.Y), new Point(where.X, where.Y + where.Height)); break; default: throw new Exception("Unknown shape"); } }