public class ceas_g { System.Drawing.Graphics zona_des; System.Drawing.SolidBrush radiera = new System.Drawing.SolidBrush(Color.White); System.Drawing.Pen c_sec = new System.Drawing.Pen(System.Drawing.Color.Purple); System.Drawing.Pen c_min = new System.Drawing.Pen(System.Drawing.Color.Blue); System.Drawing.Pen c_5min = new System.Drawing.Pen(System.Drawing.Color.Red); System.Drawing.Pen c_ore = new System.Drawing.Pen(System.Drawing.Color.Lime,3); int x0; int y0; int w; public void des_ceas() { int x = x0 + w / 5; int y = y0 + w / 5; int d = w / 2; int x1 = x + d / 2; int y1 = y + d / 2; double g; zona_des.DrawEllipse(c_5min, x, y, d, d); for (g = 0; g < 360; g += 6) { double r = 2 * System.Math.PI * g / 360; int x2 = Convert.ToInt16(x1 + (d / 2) * System.Math.Cos(r)); int y2 = Convert.ToInt16(y1 - (d / 2) * System.Math.Sin(r)); zona_des.DrawLine(c_min, x1, y1, x2, y2); if (g % 30 == 0) zona_des.DrawLine(c_5min, x1, y1, x2, y2); else zona_des.DrawLine(c_min, x1, y1, x2, y2); } zona_des.FillEllipse(radiera, x + 5, y + 5, d - 10, d - 10); } public void setval(int fus_orar) { int x = x0 + w / 5; int y = y0 + w / 5; int d = w / 2; int x1 = x + d / 2; int y1 = y + d / 2; int i, x3, y3; double r; //secundar i = 90 - 6 * System.DateTime.Now.Second; r = (2 * System.Math.PI * i) / 360; x3 = Convert.ToInt16(x1 + (d / 2 - 6) * System.Math.Cos(r)); y3 = Convert.ToInt16(y1 - (d / 2 - 6) * System.Math.Sin(r)); zona_des.FillEllipse(radiera, x + 5, y + 5, d - 10, d - 10); zona_des.DrawLine(c_sec, x1, y1, x3, y3); //minutar i = 90 - 6 * System.DateTime.Now.Minute; r = (2 * System.Math.PI * i) / 360; x3 = Convert.ToInt16(x1 + (d / 2 - 10) * System.Math.Cos(r)); y3 = Convert.ToInt16(y1 - (d / 2 - 10) * System.Math.Sin(r)); zona_des.DrawLine(c_min, x1, y1, x3, y3); //ora i = 90 - (30 * (System.Convert.ToInt16(System.DateTime.Now.Hour) + fus_orar) + System.Convert.ToInt16(System.DateTime.Now.Minute) / 2); r = (2 * System.Math.PI * i) / 360; x3 = Convert.ToInt16(x1 + (d / 2 - 15) * System.Math.Cos(r)); y3 = Convert.ToInt16(y1 - (d / 2 - 15) * System.Math.Sin(r)); zona_des.DrawLine(c_ore, x1, y1, x3, y3); zona_des.DrawEllipse(c_ore, x1 - 2, y1 - 2, 4, 4); } public ceas_g(System.Drawing.Graphics desen, int pozx, int pozy, int lat) { zona_des = desen; x0 = pozx; y0 = pozy; w = lat; } }