Пример #1
0
        protected override void PreRendering(Graphics targetGraphics)
        {
            base.PreRendering(targetGraphics);
            float angle  = (ValueAsFloat - 1 / 4f) * (float)Math.PI * 2,
                  width  = Width,
                  height = Height,
                  size   = Math.Min(Width, Height),
                  cx     = width / 2,
                  cy     = height / 2,
                  pw     = size * .08f,
                  pw2    = pw / 2f;

            targetGraphics.DrawLine(new Pen(new SolidBrush(ForeColor.Blend(Color.Black, .6)), size * .06f), new PointF(cx, cy), new PointF(cx + (float)Math.Cos(-angle) * cx, cy - (float)Math.Sin(-angle) * cy));

            var pen = new Pen(Color.FromArgb(51, 0, 0, 0), pw);

            pen.EndCap = LineCap.Round;
            targetGraphics.DrawLine(pen, new PointF(cx, cy), new PointF(cx + pw / 4f, cy + pw / 4f));
            pen.Color = Color.FromArgb(151, 0, 0, 0);
            targetGraphics.DrawLine(pen, new PointF(cx, cy), new PointF(cx - pw2, cy + pw2));

            var rect  = new RectangleF(cx - pw2, cy - pw2, pw, pw);
            var lgrad = new LinearGradientBrush(rect, Color.DimGray, Color.Gainsboro, -45f);

            targetGraphics.FillEllipse(lgrad, rect);

            var rgrad = CustomControlShapes.GetRadialGradientBrush(rect, new Color[] { Color.FromArgb(71, 0, 0, 0) }, Color.White);

            targetGraphics.FillEllipse(rgrad, rect);
        }
Пример #2
0
 protected override GraphicsPath GetRenderShape(float margin = 0)
 {
     return(CustomControlShapes.GetRoundShape(Width, Height, margin));
 }
Пример #3
0
 /// <summary>
 /// Gets a new rendering shape.
 /// </summary>
 /// <param name="margin"></param>
 /// <returns>A GraphicsPath representing the control shape.</returns>
 protected virtual GraphicsPath GetRenderShape(float margin = 0)
 {
     return(CustomControlShapes.GetRectShape(Width, Height, margin));
 }