Example #1
0
        private static void AnimateCursorOnWindow(SystemWindow window, Point point)
        {
            new Thread(new ThreadStart(delegate
                                           {
                                               // Create a device context that cover the whole display (all monitors)
                                               IntPtr hDC = CreateDC("DISPLAY", "", "", IntPtr.Zero);

                                               // Get a graphics
                                               using (Graphics g = Graphics.FromHdc(hDC))
                                               {
                                                   const int radius = 30;

                                                   g.SmoothingMode = SmoothingMode.AntiAlias;
                                                   g.CompositingMode = CompositingMode.SourceOver;
                                                   g.Clip = new Region(new Rectangle(point.X - (radius + 10) / 2, point.Y - (radius + 10) / 2,
                                                                                     radius + 10, radius + 10));

                                                   // Draw a growing circle upon the cursor
                                                   Brush trans = Brushes.Transparent;
                                                   Pen penGr = new Pen(Color.LightGray, 1);
                                                   Pen penDG = new Pen(Color.DimGray, 1);
                                                   Pen penLG = new Pen(Color.LightGray, 1);

                                                   for (int j = 0; j < 2; j++)
                                                   {
                                                       for (int i = 0; i < radius; i+=2)
                                                       {
                                                           Rectangle ellRect = new Rectangle(point.X - i / 2, point.Y - i / 2, i, i);

                                                           g.FillEllipse(trans, ellRect);
                                                           ellRect.Inflate(1, 1);
                                                           g.DrawEllipse(penGr, ellRect);
                                                           ellRect.Inflate(1, 1);
                                                           g.DrawEllipse(penDG, ellRect);
                                                           ellRect.Inflate(1, 1);
                                                           g.DrawEllipse(penLG, ellRect);

                                                           //g.Clear(Color.Transparent);

                                                           window.Refresh();
                                                       }

                                                       window.Refresh();
                                                   }
                                               }

                                               // Delete the device context
                                               DeleteDC(hDC);
                                           }
                           )).Start();
        }