MonoHotDraw.Samples.AnalogClockFigure.BasicDraw C# (CSharp) Method

BasicDraw() public method

public BasicDraw ( Context context ) : void
context Cairo.Context
return void
        public override void BasicDraw(Context context)
        {
            double hours   = 0;
            double minutes = 0;
            PointD moveToPoint;
            double seconds = 0;

            base.BasicDraw (context);

            _radius  = DisplayBox.Height / 2;
            _centerX = DisplayBox.Width  / 2;
            _centerY = DisplayBox.Height / 2;

            hours   = (_now.Hour % 12 + _now.Minute / 60) * 30 * Math.PI / 180;
            minutes = _now.Minute * 6 * Math.PI / 180;
            seconds = _now.Second * 6 * Math.PI / 180;

            context.Translate (DisplayBox.X, DisplayBox.Y);
            context.LineWidth = 0.5;

            _secondHandLength = _radius - (_radius / 6) * 1;
            DrawClockHands (context, seconds, 0.8, SecondHandLength, SecondColor);
            _minuteHandLength = _radius - (_radius / 7) * 1;
            DrawClockHands (context, minutes, 3, MinuteHandLength, MinuteColor);
            _secondHandLength = _radius - (_radius / 7) * 2;
            DrawClockHands (context, hours, 2.5, SecondHandLength, HourColor);

            //Draw ticks
            for (int i = 0; i < 60; i++) {
                if (i % 5 == 0) { //Five minute ticks
                    context.Color = new Color (0, 0, 0, 1);
                    context.LineWidth = 5;
                    moveToPoint = new PointD (_centerX + (_radius * Math.Sin (i * 6 * Math.PI / 180)),
                            _centerY - (_radius * Math.Cos (i * 6 * Math.PI / 180)));
                    context.MoveTo (moveToPoint);
                    context.LineTo (_centerX + (_radius / 1.05 * Math.Sin (i * 6 * Math.PI / 180)),
                        _centerY - (_radius / 1.08 * Math.Cos (i * 6 * Math.PI / 180)));
                    context.Stroke ();
                } else { //Other ticks
                    context.LineWidth = 1;
                    context.Color = new Color (0, 0, 0, 1);
                    moveToPoint = new PointD (_centerX + (_radius * Math.Sin (i * 6 * Math.PI / 180)),
                        _centerY - (_radius * Math.Cos (i * 6 * Math.PI / 180)));
                    context.MoveTo (moveToPoint);
                    context.LineTo (
                        _centerX + (_radius / 1.08 * Math.Sin (i * 6 * Math.PI / 180)),
                        _centerY - (_radius / 1.08 * Math.Cos (i * 6 * Math.PI / 180))
                    );
                }
                context.Stroke ();
            }
        }