void DrawPixel() { if (Mouse.LeftButton == MouseButtonState.Pressed) { System.Windows.Point pos = Mouse.GetPosition(MatrixImage); int x = (int)(pos.X / MatrixImage.ActualWidth * MatrixFrame.Width); int y = (int)(pos.Y / MatrixImage.ActualHeight * MatrixFrame.Height); x = x > MatrixFrame.Width - 1 ? MatrixFrame.Width - 1 : x < 0 ? 0 : x; y = y > MatrixFrame.Height - 1 ? MatrixFrame.Height - 1 : y < 0 ? 0 : y; MatrixFrame.SetPixel(x, y, new Pixel(255, 32, 255)); FrameToPreview(); SerialManager.PushFrame(); } }
void DrawPixel() { if (Mouse.LeftButton == MouseButtonState.Pressed || Mouse.RightButton == MouseButtonState.Pressed) { System.Windows.Point pos = Mouse.GetPosition(MatrixImage); int x = (int)(pos.X / MatrixImage.ActualWidth * MatrixFrame.Width); int y = (int)(pos.Y / MatrixImage.ActualHeight * MatrixFrame.Height); x = x > MatrixFrame.Width - 1 ? MatrixFrame.Width - 1 : x < 0 ? 0 : x; y = y > MatrixFrame.Height - 1 ? MatrixFrame.Height - 1 : y < 0 ? 0 : y; if (Mouse.LeftButton == MouseButtonState.Pressed) { MatrixFrame.SetPixel(x, y, new Pixel(255, 255, 255)); } else { MatrixFrame.SetPixel(x, y, new Pixel(0, 0, 0)); } } }