public PenDialog(PenData pd) { InitializeComponent(); InitCmb(); penData = (PenData)pd.Clone(); UserControl1.brushData = penData._brushData; UserControl1.BrushChanged += BrushDataChanged; HScrollBarUserControl_Alpha.valueChange += HScrollBarUserControl_Alpha_ValueChanged; UpdateData(true); }
public object Clone() { PenData p = new PenData(); p._dashStyle = this._dashStyle; p._width = this._width; p._startCap = this._startCap; p._endCap = this._endCap; p._lineJoin = this._lineJoin; p._dashCap = this._dashCap; p._isPiple = this._isPiple; p._brushData = (BrushData)this._brushData.Clone(); p._pipleData = (PipleData)this.PipleData.Clone(); return(p); }
public override object EditValue(ITypeDescriptorContext context, System. IServiceProvider provider, object value) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { PenData pd = (value as ICloneable).Clone() as PenData; PenDialog dlg = new PenDialog(pd); if (dlg.ShowDialog() == DialogResult.OK) { value = dlg.penData; } } return(value); }
public override void PaintValue(PaintValueEventArgs e) { Rectangle rect = e.Bounds; PenData pd = (e.Value as PenData); Pen pen = pd.CreatePen(rect, null); if (!pd.IsPiple) { e.Graphics.DrawLine(pen, rect.Left + 3, rect.Top + rect.Height / 2, rect.Right - 5, rect.Top + rect.Height / 2); } else { GraphicsPath path = new GraphicsPath(); PointF[] pts = new PointF[2]; pts[0] = new PointF(rect.Left + 3, rect.Top + rect.Height / 2); pts[1] = new PointF(rect.Right - 5, rect.Top + rect.Height / 2); path.AddLine(pts[0], pts[1]); path.CloseAllFigures(); pd.DrawPath(e.Graphics, path); path.Dispose(); } pen.Dispose(); }