/// <summary> /// Constructor for a line from another line. /// </summary> /// <param name="other"><c>PenPainter</c> to copy.</param> public PenPainter(PenPainter other) { this.Color = other.Color; this.Width = other.Width; this.DashStyle = other.DashStyle; this.DashPattern = other.DashPattern; }
/// <summary> /// Shows the pen painter. /// </summary> private void ShowPenPainter() { PenPainter line = PenPainter; linePanel1.PenPainter = line; linePanel2.PenPainter = line; }
/// <summary> /// Sets the pen painter. /// </summary> /// <param name="line">The line.</param> private void SetPenPainter(PenPainter line) { if (line == null) { line = new PenPainter(); } colorLabel.BackColor = Color.FromArgb(255, line.Color); alphaNud.Value = (decimal)line.Color.A; dashStyleComboBox.SelectedDashStyle = line.DashStyle; widthNud.Value = (decimal)line.Width; ShowPenPainter(); }
/// <summary> /// Default constructor. /// </summary> public PenPainterPanel() { InitializeComponent(); this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true); this.UpdateStyles(); line = new PenPainter(); }
// This code allows the designer to generate the Fill constructor /// <summary> /// Converts the given value object to the specified type, using the specified context and culture information. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param> /// <param name="culture">A <see cref="T:System.Globalization.CultureInfo" />. If null is passed, the current culture is assumed.</param> /// <param name="value">The <see cref="T:System.Object" /> to convert.</param> /// <param name="destinationType">The <see cref="T:System.Type" /> to convert the <paramref name="value" /> parameter to.</param> /// <returns>An <see cref="T:System.Object" /> that represents the converted value.</returns> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (value is PenPainter) { if (destinationType == typeof(string)) { // Display string in designer return("(PenPainter)"); } else if (destinationType == typeof(InstanceDescriptor)) { PenPainter line = (PenPainter)value; if (line.DashStyle == DashStyle.Custom) { ConstructorInfo ctor = typeof(PenPainter).GetConstructor(new Type[] { typeof(Color), typeof(float), typeof(float[]) }); if (ctor != null) { return(new InstanceDescriptor(ctor, new object[] { line.Color, line.Width, line.DashPattern })); } } else { ConstructorInfo ctor = typeof(PenPainter).GetConstructor(new Type[] { typeof(Color), typeof(float), typeof(DashStyle) }); if (ctor != null) { return(new InstanceDescriptor(ctor, new object[] { line.Color, line.Width, line.DashStyle })); } } } } return(base.ConvertTo(context, culture, value, destinationType)); }
/// <summary> /// Initializes a new instance of <c>PenPainterEditorDialog</c> using an existing <c>PenPainter</c> /// and starting beneath a specified control. /// </summary> /// <param name="line">Existing <c>PenPainter</c>.</param> /// <param name="c">Control beneath which the dialog should be placed.</param> public PenPainterEditorDialog(PenPainter line, Control c) { InitializeComponent(); Utils.SetStartPositionBelowControl(this, c); SetPenPainter(line); }
/// <summary> /// Initializes a new instance of <c>PenPainterEditorDialog</c> using an existing <c>PenPainter</c> /// and default window position. /// </summary> /// <param name="line">Existing <c>PenPainter</c>.</param> public PenPainterEditorDialog(PenPainter line) { InitializeComponent(); SetPenPainter(line); ShowPenPainter(); }