private void DrawTicks(ref GraphicsX gx, int minutes) { for (minutes = 0; minutes <= 60; minutes++) { int degree = -90 - minutes * 6; double d = degree * Math.PI / 180.0; int r = this.arcRect.Width / 2; int x = this.arcRect.X + r; int y = this.arcRect.Y + r; int width = (int)Math.Round(r * Math.Cos(d)); int height = (int)Math.Round(r * Math.Sin(d)); int x1 = x + width; int y1 = y + height; if (minutes % 5 == 0) { r -= LONG_LINE_LENGTH; } else { r -= SHORT_LINE_LENGTH; } width = (int)Math.Round(r * Math.Cos(d)); height = (int)Math.Round(r * Math.Sin(d)); int x2 = x + width; int y2 = y + height; gx.DrawLine(linePenX, x1, y1, x2, y2); } }
internal RedarwHelper(Rectangle clientRectangle) { this.currentMinute = -1; this.nextMinute = -1; this.clientRectangle = clientRectangle; this.arcRect = clientRectangle; this.brushX = new SolidBrushX(Color.Red); this.penX = new PenX(Color.Gray, BORDER_WIDTH); this.linePenX = new PenX(Color.Black); this.gx = new GraphicsX(arcRect.Width, arcRect.Height); this.gxNextMinute = new GraphicsX(arcRect.Width, arcRect.Height); this.arcRect.Width--; this.arcRect.Height--; this.arcRect.Inflate(-25, -25); int delta = BORDER_WIDTH / 2; boarderRect = new Rectangle(arcRect.Left + delta, arcRect.Top + delta, arcRect.Width - BORDER_WIDTH, arcRect.Height - BORDER_WIDTH); this.boarderRect = this.arcRect; this.currentMinuteRedrawRect = clientRectangle; }
internal Rectangle prepareGx(int minutes) { Rectangle newRedrawRect; if (this.currentMinute == minutes) { return(new Rectangle()); } else if (this.nextMinute == minutes) { GraphicsX g = this.gx; this.gx = this.gxNextMinute; this.gxNextMinute = g; newRedrawRect = this.nextMinuteRedrawRect; } else { newRedrawRect = this.prepareGxSync(ref this.gx, minutes); } Rectangle rect; if (!this.timerEnabled) { rect = this.clientRectangle; } else { if (minutes > 0) { this.prepareNextGx(minutes - 1); } if (this.currentMinuteRedrawRect.IsEmpty) { rect = newRedrawRect; } else { rect = Rectangle.Union(newRedrawRect, this.currentMinuteRedrawRect); } } this.currentMinute = minutes; this.currentMinuteRedrawRect = newRedrawRect; return(rect); }
private Rectangle prepareGxSync(ref GraphicsX gx, int minutes) { gx.Clear(Color.White); int degree = minutes * 6; if (degree == 360) { gx.FillEllipse(this.brushX, arcRect); } else { gx.FillPie(this.brushX, arcRect, -90, -degree); } this.DrawTicks(ref gx, minutes); gx.DrawEllipse(this.penX, this.boarderRect); return(this.CalculateRedrawRect(minutes)); }