Ejemplo n.º 1
0
 void timer_Tick(object sender, EventArgs e)
 {
     System.Drawing.Point _point = System.Windows.Forms.Control.MousePosition;
     System.Windows.Point point  = new System.Windows.Point(_point.X, _point.Y);
     if (previousposition == null || previousposition != point)
     {
         if (screenimage != null)
         {
             int stride = (screenimage.PixelWidth * screenimage.Format.BitsPerPixel + 7) / 8;
             pixels = new byte[screenimage.PixelHeight * stride];
             Int32Rect rect = new Int32Rect((int)point.X, (int)point.Y, 1, 1);
             screenimage.CopyPixels(rect, pixels, stride, 0);
             rectcolor.BackColor = Color.FromArgb(255, pixels[2], pixels[1], pixels[0]);
             txt.Text            = InteropHelper.ConvertToString(rectcolor.BackColor);
             SetColor(Color.FromArgb(255, pixels[2], pixels[1], pixels[0]), false, "picker");
         }
     }
     if (System.Windows.Forms.Control.MouseButtons != System.Windows.Forms.MouseButtons.Left)
     {
         timer.Stop();
         ResetCursorToDefault();
     }
     previousposition = point;
 }