Esempio n. 1
0
        static void DrawHands(DeviceContext dc, SYSTEMTIME pst, bool fChange)
        {
            int[] iAngle =
            {
                (pst.wHour * 30) % 360 + pst.wMinute / 2,
                pst.wMinute * 6,
                pst.wSecond * 6
            };

            POINT[][] pt =
            {
                new POINT[] { new POINT(0, -150), new POINT(100, 0), new POINT(0, 600), new POINT(-100, 0), new POINT(0, -150) },
                new POINT[] { new POINT(0, -200), new POINT(50, 0), new POINT(0, 800), new POINT(-50, 0), new POINT(0, -200), },
                new POINT[] { new POINT(0, 0), new POINT(0, 0), new POINT(0, 0), new POINT(0, 0), new POINT(0, 800) }
            };

            COLORREF color = GdiMethods.GetPenColor(dc.GetCurrentPen());
            bool erase = (color != new COLORREF());

#if GDIPLUS
            using (var graphics = GdiPlusMethods.CreateGraphics(dc))
            {
                if (erase)
                {
                    using (var brush = GdiPlusMethods.CreateSolidBrush(color))
                    {
                        GdiPlusMethods.FillEllipse(graphics, brush, -830, -830, 1660, 1660);
                    }
                    return;
                }

                using (var pen = GdiPlusMethods.CreatePen(color))
                {
                    GdiPlusMethods.SetSmoothingMode(graphics, SmoothingMode.HighQuality);

#endif

                    for (int i = fChange ? 0 : 2; i < 3; i++)
                    {
                        RotatePoint(pt[i], 5, iAngle[i]);

#if GDIPLUS
                        GdiPlusMethods.DrawLines(graphics, pen, pt[i]);
#else
                        dc.Polyline(pt[i]);
#endif
                    }
#if GDIPLUS
                }
            }
#endif
        }