/// <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) { ColorPack Item = new ColorPack(); Item.Border = (Color)propertyValues["Border"]; Item.Face = (Color)propertyValues["Face"]; Item.Highlight = (Color)propertyValues["Highlight"]; return(Item); }
/// <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); ColorPack cPack = null; if ((e.Context == null)) { cPack = new ColorPack(); } else { cPack = (ColorPack)e.Value; } // Draw the sample. using (Pen border_pen = new Pen(cPack.Border, 2F)) { using (GraphicsPath gp = new GraphicsPath()) { gp.AddRectangle(e.Bounds); if (e.Context.PropertyDescriptor.DisplayName == "AButColor" || (((ZeroitMultiTrackBar)e.Context.Instance).BrushStyle == ZeroitMultiTrackBar.eBrushStyle.Linear || ((ZeroitMultiTrackBar)e.Context.Instance).BrushStyle == ZeroitMultiTrackBar.eBrushStyle.Linear2)) { using (LinearGradientBrush br = new LinearGradientBrush(gp.GetBounds(), cPack.Highlight, cPack.Face, LinearGradientMode.Horizontal)) { e.Graphics.FillPath(br, gp); } } else { using (PathGradientBrush br = new PathGradientBrush(gp)) { br.SurroundColors = new Color[] { cPack.Face }; br.CenterColor = cPack.Highlight; br.CenterPoint = new PointF(br.CenterPoint.X - 5, Convert.ToSingle(br.CenterPoint.Y - 2.5)); br.FocusScales = new PointF(0F, 0F); e.Graphics.FillPath(br, gp); } } e.Graphics.DrawRectangle(border_pen, 2, 2, e.Bounds.Width - 2, e.Bounds.Height - 2); } } }