I want to draw a figure that will change shape when I move the track bar to a different value. For example for value=1
Next I draw for second figure for value=2
I want only one shape. What should I do? Shape should change in every value of Track Bar. Here some my code for DrawTickedCircle:
private void DrawTickedCircle(Graphics gr, Pen circle_pen, Pen tick_pen,float cx, float cy, float rx, float ry,
float num_theta, float num_ticks, float tick_fraction)
{
List<PointF> points = new List<PointF>();
float dalpha = (float)(2 * Math.PI / num_theta);
float alpha = 0;
for (int i = 0; i < num_theta; i++)
{
float x = (float)(cx + rx * Math.Cos(alpha));
float y = (float)(cy + ry * Math.Sin(alpha));
points.Add(new PointF(x, y));
alpha += dalpha;
}
gr.DrawPolygon(circle_pen, points.ToArray());
dalpha = (float)(2 * Math.PI / num_ticks);
alpha = 0;
float rx1 = rx * (1 - tick_fraction);
float ry1 = ry * (1 - tick_fraction);
for (int k = 0; k < num_ticks; k++)
{
float x1 = (float)(cx + rx * Math.Cos(alpha));
float y1 = (float)(cy + ry * Math.Sin(alpha));
float x2 = (float)(cx + rx1 * Math.Cos(alpha));
float y2 = (float)(cy + ry1 * Math.Sin(alpha));
gr.DrawLine(tick_pen, x1, y1, x2, y2);
alpha += dalpha;
}
}
For trackBarScroll function:
private void trackBar1_Scroll(object sender, EventArgs e)
{
var g = pictureBox1.CreateGraphics();
float cx = ClientRectangle.Width / 2;
float cy = ClientRectangle.Height / 2;
float rx = Math.Min(cx, cy);
float ry = rx;
rx *= 0.8f;
ry *= 0.6f;
if (trackBar1.Value == 1)
{
DrawTickedCircle(g, Pens.Black, Pens.Black, cx, cy, rx, ry, 8, 8, 0.1F);
}
else if (trackBar1.Value == 2)
{
DrawTickedCircle(g, Pens.Red, Pens.Red, cx, cy, rx, ry, 255, 255, 0.1f);
}
g.Dispose();
}
I don't want draw these in PaintEvent. Thanks for help!