Ejemplo n.º 1
0
 /// <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;
 }
Ejemplo n.º 2
0
        private void ShowPenPainter()
        {
            PenPainter line = PenPainter;

            linePanel1.PenPainter = line;
            linePanel2.PenPainter = line;
        }
Ejemplo n.º 3
0
 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();
 }
Ejemplo n.º 4
0
        /// <summary>
        ///     Default constructor.
        /// </summary>
        public PenPainterPanel()
        {
            InitializeComponent();

            this.SetStyle(ControlStyles.OptimizedDoubleBuffer |
                          ControlStyles.AllPaintingInWmPaint |
                          ControlStyles.ResizeRedraw |
                          ControlStyles.UserPaint, true);

            this.UpdateStyles();

            line = new PenPainter();
        }
Ejemplo n.º 5
0
            // This code allows the designer to generate the Fill constructor

            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));
            }
Ejemplo n.º 6
0
 /// <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);
 }
Ejemplo n.º 7
0
 /// <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();
 }