private void GetColorUnderCursor() { Point position = Mouse.GetPosition(ColorImage); BitmapSource image = ColorImage.Source as BitmapSource; CroppedBitmap cb = new CroppedBitmap(image, new Int32Rect((int)(position.X / ColorImage.ActualWidth * image.PixelWidth), (int)(position.Y / ColorImage.ActualHeight * image.PixelHeight), 1, 1)); byte[] pixels = new byte[4]; cb.CopyPixels(pixels, 4, 0); Color SelectedColor = Color.FromArgb(255, pixels[2], pixels[1], pixels[0]); CurrentColor.Color = SelectedColor; // Update labels UpdateLabels(); // Inform Listener SelectedColorChangedEvent.Invoke(CurrentColor); }
remove => RemoveHandler(SelectedColorChangedEvent, value);
add => AddHandler(SelectedColorChangedEvent, value);