protected void BuildTickPath() { tickBrush = new LinearGradientBrush(Point.Empty, new Point(0, width), color, Color.FromArgb(color.R / 2, color.G / 2, color.B / 2)); tickBrush.SetSigmaBellShape(.5f, 1); tickPath = PredefinedShapes.Rectangle(width, height); }
public void Paint(Graphics g, float angle) { Matrix centerMatrix = g.Transform; //double valueRange = (max - min); //float vAngle = (float)(value * sweepAngle / valueRange); Brush shadow = new SolidBrush(Color.FromArgb(50, Color.Black)); Brush capBrush = new LinearGradientBrush( new PointF(-capWidth * 0.707f, -capWidth * 0.707f), new PointF(capWidth * 0.707f, capWidth * 0.707f), Color.LightGray, Color.Black); Brush brush = new LinearGradientBrush(new PointF(0, width), new PointF(0, -width), Color.White, Color.Red); GraphicsPath path = PredefinedShapes.Needle(width, (int)radius); GraphicsPath capPath = new GraphicsPath(); capPath.AddArc(capWidth * -0.5f, capWidth * -0.5f, capWidth, capWidth, 0, 360); Region needleRegion = new Region(path); needleRegion.Union(capPath); // shadow Matrix old = g.Transform; // shadow offset g.TranslateTransform(shadowOffset, shadowOffset); g.RotateTransform(angle); g.FillRegion(shadow, needleRegion); // restore matrix g.Transform = old; g.RotateTransform(angle); // draw needle g.FillPath(brush, path); g.DrawPath(Pens.Black, path); g.Transform = centerMatrix; // draw cap g.FillPath(capBrush, capPath); g.DrawPath(Pens.Black, capPath); //g.DrawLine(Pens.White, Point.Empty, new PointF(radius, 0)); }