Пример #1
0
 /// <summary>
 /// Pick a color from the current mouse position.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The <see cref="System.EventArgs"/> instance containing the event data.
 /// </param>
 private void Pick(object sender, EventArgs e)
 {
     if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
     {
         try
         {
             Point        pt     = CaptureScreenshot.GetMouseScreenPosition();
             BitmapSource bmp    = CaptureScreenshot.Capture(new Rect(pt, new Size(1, 1)));
             var          pixels = new byte[4];
             bmp.CopyPixels(pixels, 4, 0);
             this.SelectedColor = Color.FromArgb(0xFF, pixels[2], pixels[1], pixels[0]);
         }
         catch (Exception)
         {
         }
     }
 }
Пример #2
0
 /// <summary>
 /// Picks a color from the current mouse position.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
 private void Pick(object sender, EventArgs e)
 {
     if (this.IsPickKeyDown())
     {
         try
         {
             Point        pt     = CaptureScreenshot.GetMouseScreenPosition();
             BitmapSource bmp    = CaptureScreenshot.Capture(new Rect(pt, new Size(1, 1)));
             var          pixels = new byte[4];
             bmp.CopyPixels(pixels, 4, 0);
             this.SelectedColor = Color.FromArgb(0xFF, pixels[2], pixels[1], pixels[0]);
         }
         // ReSharper disable once EmptyGeneralCatchClause
         catch
         {
         }
     }
 }