// This code allows the designer to generate the Shape 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 (destinationType == typeof(string)) { // Display string in designer return("(Customize)"); } else if (destinationType == typeof(InstanceDescriptor) && value is PolygonInput) { PolygonInput polygonInput = (PolygonInput)value; ConstructorInfo ctor = typeof(PolygonInput).GetConstructor(new Type[] { typeof(List <List <Point> >), typeof(PolygonInput.FillModes), typeof(PolygonInput.ShapeTypes) }); if (ctor != null) { return(new InstanceDescriptor(ctor, new object[] { polygonInput.Points, polygonInput.FillMode, polygonInput.ShapeType })); } } return(base.ConvertTo(context, culture, value, destinationType)); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param> protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Rectangle reflection = new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height / 2); Rectangle bounds = this.ClientRectangle; bounds.Inflate(-2, -2); GraphicsPath shape = RoundRect(bounds, RectangleInfo.UpperLeft, RectangleInfo.UpperRight, RectangleInfo.DownLeft, RectangleInfo.DownRight); Bitmap B = new Bitmap(Width, Height); Graphics G = Graphics.FromImage(B); G.SmoothingMode = Smoothing; G.TextRenderingHint = TextRendering; G.CompositingQuality = CompositingQuality; G.InterpolationMode = InterpolationMode; if (EnableHatchAnimation) { G.RenderingOrigin = new Point(reactorOFS, 0); } if (AllowTransparency) { MakeTransparent(this, G); } switch (Shape) { case Shapes.Rectangle: if (RectangleInfo.Rounding) { switch (FillMode) { case PolygonInput.FillModes.Fill: G.FillPath(Fill.GetBrush(bounds), shape); break; case PolygonInput.FillModes.Border: G.DrawPath(Border.GetPen(), shape); break; case PolygonInput.FillModes.Both: G.FillPath(Fill.GetBrush(bounds), shape); G.DrawPath(Border.GetPen(), shape); break; default: break; } } else { switch (FillMode) { case PolygonInput.FillModes.Fill: G.FillRectangle(Fill.GetBrush(bounds), bounds); break; case PolygonInput.FillModes.Border: G.DrawRectangle(Border.GetPen(), bounds); break; case PolygonInput.FillModes.Both: G.FillRectangle(Fill.GetBrush(bounds), bounds); G.DrawRectangle(Border.GetPen(), bounds); break; default: break; } } break; case Shapes.Circle: switch (FillMode) { case PolygonInput.FillModes.Fill: G.FillEllipse(Fill.GetBrush(bounds), bounds); break; case PolygonInput.FillModes.Border: G.DrawEllipse(Border.GetPen(), bounds); break; case PolygonInput.FillModes.Both: G.FillEllipse(Fill.GetBrush(bounds), bounds); G.DrawEllipse(Border.GetPen(), bounds); break; default: break; } break; case Shapes.Pie: switch (FillMode) { case PolygonInput.FillModes.Fill: G.FillPie(Fill.GetBrush(bounds), bounds, Pie.StartAngle, Pie.SweepAngle); break; case PolygonInput.FillModes.Border: G.DrawPie(Border.GetPen(), bounds, Pie.StartAngle, Pie.SweepAngle); break; case PolygonInput.FillModes.Both: G.FillPie(Fill.GetBrush(bounds), bounds, Pie.StartAngle, Pie.SweepAngle); G.DrawPie(Border.GetPen(), bounds, Pie.StartAngle, Pie.SweepAngle); break; default: break; } break; case Shapes.Polygon: PolygonInput.DrawShape(G, Fill.GetBrush(ClientRectangle), Border.GetPen()); if (ShowReflection) { e.Graphics.DrawReflection(B, reflection, Reflection.Gap, Reflection.Height, Reflection.StartAlpha, Reflection.EndAlpha); } break; default: break; } //this.CreateDropShadow(); DrawImage(G, bounds); e.Graphics.DrawImage(B, 0, 0); G.Dispose(); B.Dispose(); if (!DesignMode) { GC.Collect(); } }