motionless analog clock
-
Hi.. I want to display motionless analog clock. (asp.net + C#) I have 3 textboxes and entering HH, MM, SS. Clicking the button would generate analog clock with the respective time. Did lot of searching but didnt get my way out.. please suggest me some way. thanks,
By: Hemant Thaker
-
Hi.. I want to display motionless analog clock. (asp.net + C#) I have 3 textboxes and entering HH, MM, SS. Clicking the button would generate analog clock with the respective time. Did lot of searching but didnt get my way out.. please suggest me some way. thanks,
By: Hemant Thaker
Hemant Thaker wrote:
Did lot of searching but didnt get my way out..
Apart from searching what have your tried from your side in order to write code for it? Sound's like a typical homework question. What are the things you plan to use in order to generate this analog clock? Graphics? Javascript? Image? What's your thought and plan?
-
Hemant Thaker wrote:
Did lot of searching but didnt get my way out..
Apart from searching what have your tried from your side in order to write code for it? Sound's like a typical homework question. What are the things you plan to use in order to generate this analog clock? Graphics? Javascript? Image? What's your thought and plan?
private void drawclock4(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Rectangle rec = new Rectangle(20, 20, 250, 250); LinearGradientBrush linearbrush = new LinearGradientBrush(rec, Color.Black, Color.Black, 225); g.FillEllipse(linearbrush, 20, 20, 200, 200); linearbrush.LinearColors = new Color[] { Color.White, Color.White, }; g.FillEllipse(linearbrush, 30, 30, 180, 180); linearbrush.LinearColors = new Color[] { Color.White, Color.White }; g.FillEllipse(linearbrush, 33, 33, 174, 174); SolidBrush solidbrush = new SolidBrush(Color.Black); Font textFont = new Font("Arial Black", 12F); g.DrawString("12", textFont, solidbrush, 109, 40); g.DrawString("11", textFont, solidbrush, 75, 50); g.DrawString("10", textFont, solidbrush, 47, 75); g.DrawString("9", textFont, solidbrush, 43, 110); g.DrawString("8", textFont, solidbrush, 52, 145); g.DrawString("7", textFont, solidbrush, 75, 170); g.DrawString("6", textFont, solidbrush, 113, 180); g.DrawString("5", textFont, solidbrush, 150, 170); g.DrawString("4", textFont, solidbrush, 173, 145); g.DrawString("3", textFont, solidbrush, 182, 110); g.DrawString("2", textFont, solidbrush, 173, 75); g.DrawString("1", textFont, solidbrush, 150, 50); g.TranslateTransform(120, 120, MatrixOrder.Append); int hour = DateTime.Now.Hour; int min = DateTime.Now.Minute; int sec = DateTime.Now.Second; // Create Pens Pen hourPen = new Pen(Color.DarkBlue, 4); Pen minutePen = new Pen(Color.DarkGreen, 3); Pen secondPen = new Pen(Color.DarkRed, 2); // Create angles double secondAngle = 2.0 * Math.PI * sec / 60.0; double minuteAngle = 2.0 * Math.PI * (min + sec / 60.0) / 60.0; double hourAngle = 2.0 * Math.PI * (hour + min / 60.0) / 12.0; // Set centre point Point centre = new Point(0, 0); // Draw Hour Hand //Point hourHand = new Point((int)(40 * Math.Sin(hourAngle)), (int)(-40 * Math.Cos(hourAngle))); //g.DrawLine(hourPen, centre, hourHand); // Draw Minute Hand