// This code allows the designer to generate the Fill constructor

            public override object ConvertTo(ITypeDescriptorContext context,
                                             CultureInfo culture,
                                             object value,
                                             Type destinationType)
            {
                if (destinationType == typeof(string))
                {
                    // Display string in designer
                    return("(Filler2)");
                }
                else if (destinationType == typeof(InstanceDescriptor) && value is Filler2)
                {
                    Filler2 filler = (Filler2)value;

                    if (filler.FillType == Filler2Type.Solid)
                    {
                        ConstructorInfo ctor = typeof(Filler2).GetConstructor(new Type[] { typeof(Color) });
                        if (ctor != null)
                        {
                            return(new InstanceDescriptor(ctor, new object[] { filler.SolidColor }));
                        }
                    }
                    else if (filler.FillType == Filler2Type.Hatch)
                    {
                        ConstructorInfo ctor = typeof(Filler2).GetConstructor(new Type[] { typeof(HatchStyle),
                                                                                           typeof(Color),
                                                                                           typeof(Color) });
                        if (ctor != null)
                        {
                            return(new InstanceDescriptor(ctor, new object[] { filler.HatchStyle,
                                                                               filler.HatchColor,
                                                                               filler.BackColor }));
                        }
                    }
                    else if (filler.FillType == Filler2Type.Gradient)
                    {
                        ConstructorInfo ctor = typeof(Filler2).GetConstructor(new Type[] { typeof(Color[]),
                                                                                           typeof(float[]) });
                        if (ctor != null)
                        {
                            return(new InstanceDescriptor(ctor, new object[] { filler.GradientColors.Colors,
                                                                               filler.GradientColors.Positions }));
                        }
                    }
                    else
                    {
                        ConstructorInfo ctor = typeof(Filler2).GetConstructor(Type.EmptyTypes);
                        if (ctor != null)
                        {
                            return(new InstanceDescriptor(ctor, null));
                        }
                    }
                }

                return(base.ConvertTo(context, culture, value, destinationType));
            }
Esempio n. 2
0
        /// <summary>
        ///		Initializes a new instance of <c>Filler2EditorDialog</c> using an existing <c>Filler2</c>
        ///     at the default window position.
        /// </summary>
        /// <param name="filler">Existing <c>Filler2</c> object.</param>
        /// <exception cref="System.ArgumentNullException">
        ///		Thrown if <paramref name="filler" /> is null.
        ///	</exception>
        public Filler2EditorDialog(Filler2 filler)
        {
            if (filler == null)
            {
                throw new ArgumentNullException("filler");
            }

            InitializeComponent();
            AdjustDialogSize();
            SetControlsToInitialValues(filler);
        }
Esempio n. 3
0
 private void okButton_Click(object sender, EventArgs e)
 {
     if (solidRadioButton.Checked)
     {
         filler = new Filler2(FromLabelNud(solidColorLabel, solidAlphaNud));
     }
     else if (hatchRadioButton.Checked)
     {
         filler = new Filler2(hatchComboBox.SelectedHatchStyle,
                              FromLabelNud(hatchColorLabel, hatchAlphaNud),
                              FromLabelNud(backColorLabel, backAlphaNud));
     }
     else if (gradientRadioButton.Checked)
     {
         filler = new Filler2(gradientEditor.Blend);
     }
     else
     {
         filler = Filler2.Empty();
     }
     DialogResult = DialogResult.OK;
 }
Esempio n. 4
0
        private void SetControlsToInitialValues(Filler2 filler)
        {
            Init(filler.SolidColor, solidColorLabel, solidAlphaNud);
            Init(filler.HatchColor, hatchColorLabel, hatchAlphaNud);
            Init(filler.BackColor, backColorLabel, backAlphaNud);
            gradientEditor.Blend = filler.GradientColors;

            hatchComboBox.SelectedIndex = 0;
            for (int i = 0; i < hatchComboBox.Items.Count; i++)
            {
                if (filler.HatchStyle == (HatchStyle)(hatchComboBox.Items[i]))
                {
                    hatchComboBox.SelectedIndex = i;
                }
            }
            UpdateHatch();

            UpdateSolid();

            if (filler.FillType == Filler2Type.None)
            {
                noneRadioButton.Checked = true;
            }
            else if (filler.FillType == Filler2Type.Solid)
            {
                solidRadioButton.Checked = true;
            }
            else if (filler.FillType == Filler2Type.Hatch)
            {
                hatchRadioButton.Checked = true;
            }
            else
            {
                gradientRadioButton.Checked = true;
            }
        }
Esempio n. 5
0
 /// <summary>
 ///		Initializes a new instance of <c>Filler2EditorDialog</c> using an existing <c>Filler2</c>
 ///		and positioned beneath the specified control.
 /// </summary>
 /// <param name="filler">Existing <c>Filler2</c> object.</param>
 /// <param name="c">Control beneath which the dialog should be placed.</param>
 /// <exception cref="System.ArgumentNullException">
 ///		Thrown if <paramref name="filler" /> is null.
 ///	</exception>
 public Filler2EditorDialog(Filler2 filler, Control c) : this(filler)
 {
     Utils.SetStartPositionBelowControl(this, c);
 }
Esempio n. 6
0
 /// <summary>
 ///		Initializes a new instance of <c>Filler2EditorDialog</c> using an empty <c>Filler2</c>
 ///		and positioned beneath the specified control.
 /// </summary>
 /// <param name="c">Control beneath which the dialog should be placed.</param>
 public Filler2EditorDialog(Control c) : this(Filler2.Empty(), c)
 {
 }
Esempio n. 7
0
 /// <summary>
 ///		Initializes a new instance of <c>Filler2EditorDialog</c> using an empty <c>Filler2</c>
 ///     at the default window position.
 /// </summary>
 public Filler2EditorDialog() : this(Filler2.Empty())
 {
 }