private void OpenFileButton_Click(object sender, EventArgs e) { openFileDialog1.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|PNG Image|*.png|JSON File|*.json"; openFileDialog1.ShowDialog(); if (openFileDialog1.FileName != "" && openFileDialog1.FileName != "openFileDialog1") { _bl.Clear(); _currentBitmap = new PaintBitmap(pictureBoxMain.Width, pictureBoxMain.Height); _bufferedBitmap = _currentBitmap.Clone() as PaintBitmap; pictureBoxMain.Image = _currentBitmap.ToImage(); Repaint(); if (openFileDialog1.FilterIndex == 4) { var strings = File.ReadAllText(openFileDialog1.FileName); if (_bl.JsonOpen(strings, _currentBitmap)) { Repaint(); } } else { _currentBitmap = (PaintBitmap)PaintImage.FromFile(openFileDialog1.FileName); pictureBoxMain.Image = _currentBitmap.ToImage(); Repaint(); } } }
private void ClearButton_Click(object sender, EventArgs e) { _bl.Clear(); _currentBitmap = new PaintBitmap(pictureBoxMain.Width, pictureBoxMain.Height); _bufferedBitmap = _currentBitmap.Clone() as PaintBitmap; pictureBoxMain.Image = _currentBitmap.ToImage(); Repaint(); }
public Paint() { InitializeComponent(); _currentMode = EShapeType.Curve; _bl = new BusinessLogic(new Storage(), new ShapeFactory(), new JsonLogic()); _bl.Init(_currentMode, _currentBrashSize, _curentcolor); _currentBitmap = new PaintBitmap(pictureBoxMain.Width, pictureBoxMain.Height); _bufferedBitmap = _currentBitmap.Clone() as PaintBitmap; pictureBoxMain.Image = _currentBitmap.ToImage(); }
public void CloneTest() { Image image = new Bitmap(1, 1); PaintImage paintImage = new PaintBitmap(image); PaintImage actualImage = paintImage.Clone() as PaintImage; Assert.AreNotSame(paintImage, actualImage); Image actuaPaintlImage = actualImage.ToImage(); Assert.AreNotSame(actuaPaintlImage, image); Assert.AreEqual(1, actuaPaintlImage.Width); Assert.AreEqual(1, actuaPaintlImage.Height); }
private void Repaint() { if (_bl.isBoolCount()) { IShape currentShape = _bl.Last(); _bufferedBitmap = _currentBitmap.Clone() as PaintBitmap; PaintGraphics _bufferedGraphics = PaintGraphics.FromImage(_bufferedBitmap); currentShape.Draw(_bufferedGraphics); if (currentShape.EShapeStatus == EShapeStatus.IN_PROGRESS) { pictureBoxMain.Image = _bufferedBitmap?.ToImage(); } if (currentShape.EShapeStatus == EShapeStatus.DONE) { _currentBitmap = _bufferedBitmap?.Clone() as PaintBitmap; pictureBoxMain.Image = _currentBitmap?.ToImage(); } } }