Ejemplo n.º 1
0
        /// <summary>
        /// Paints a representation of the value of an object using the specified <see cref="T:System.Drawing.Design.PaintValueEventArgs" />.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Drawing.Design.PaintValueEventArgs" /> that indicates what to paint and where to paint it.</param>
        public override void PaintValue(PaintValueEventArgs e)
        {
            // Erase the area.
            e.Graphics.FillRectangle(Brushes.White, e.Bounds);

            ColorLinearGradient cLinearGradient = null;

            if ((e.Context == null))
            {
                cLinearGradient = new ColorLinearGradient();
            }
            else
            {
                cLinearGradient = (ColorLinearGradient)e.Value;
            }
            // Draw the sample.
            using (Pen border_pen = new Pen(Color.Black, 1F))
            {
                using (LinearGradientBrush br = new LinearGradientBrush(e.Bounds, cLinearGradient.ColorA, cLinearGradient.ColorB, LinearGradientMode.Horizontal))
                {
                    e.Graphics.FillRectangle(br, e.Bounds);
                }

                e.Graphics.DrawRectangle(border_pen, 1, 1, e.Bounds.Width - 1, e.Bounds.Height - 1);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates an instance of the type that this <see cref="T:System.ComponentModel.TypeConverter" /> is associated with, using the specified context, given a set of property values for the object.
        /// </summary>
        /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context.</param>
        /// <param name="propertyValues">An <see cref="T:System.Collections.IDictionary" /> of new property values.</param>
        /// <returns>An <see cref="T:System.Object" /> representing the given <see cref="T:System.Collections.IDictionary" />, or null if the object cannot be created. This method always returns null.</returns>
        public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues)
        {
            ColorLinearGradient Item = new ColorLinearGradient();

            Item.ColorA = (Color)propertyValues["ColorA"];
            Item.ColorB = (Color)propertyValues["ColorB"];
            return(Item);
        }