Example #1
0
        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();
                }
            }
        }
Example #2
0
 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();
 }
Example #3
0
 private void DeleteBtn_Click(object sender, EventArgs e)
 {
     if (_bl.isBoolCount() && _isSelected)
     {
         _currentBitmap       = new PaintBitmap(pictureBoxMain.Width, pictureBoxMain.Height);
         pictureBoxMain.Image = _currentBitmap.ToImage();
         _bl.Delete(_currentBitmap);
         _isSelected = false;
     }
 }
Example #4
0
 private void BrushSizeTrackBar_Scroll(object sender, EventArgs e)
 {
     _currentBrashSize = trackBar1.Value;
     if (_bl.isBoolCount() && _isSelected)
     {
         _currentBitmap       = new PaintBitmap(pictureBoxMain.Width, pictureBoxMain.Height);
         pictureBoxMain.Image = _currentBitmap.ToImage();
         _bl.ChanhgeFirgureThickness(_currentBitmap, _currentBrashSize);
     }
 }
Example #5
0
        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();
        }
Example #6
0
        private void ColorButton_Click(object sender, EventArgs e)
        {
            Button b = (Button)sender;

            CurrentColorButton.BackColor = b.BackColor;
            _curentcolor = new PaintColor(CurrentColorButton.BackColor);

            if (_bl.isBoolCount() && _isSelected)
            {
                _currentBitmap       = new PaintBitmap(pictureBoxMain.Width, pictureBoxMain.Height);
                pictureBoxMain.Image = _currentBitmap.ToImage();
                _bl.ChangeFigureColor(_currentBitmap, _curentcolor);
            }
        }
Example #7
0
        private void ChangeColorButton_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                CurrentColorButton.BackColor = colorDialog1.Color;
                _curentcolor = new PaintColor(colorDialog1.Color);
            }

            if (_bl.isBoolCount() && _isSelected)
            {
                _currentBitmap       = new PaintBitmap(pictureBoxMain.Width, pictureBoxMain.Height);
                pictureBoxMain.Image = _currentBitmap.ToImage();
                _bl.ChangeFigureColor(_currentBitmap, _curentcolor);
            }
        }
Example #8
0
        public void ToImageTest()
        {
            Image      image       = new Bitmap(1, 1);
            PaintImage paintImage  = new PaintBitmap(image);
            Image      actualImage = paintImage.ToImage();

            Assert.AreSame(image, actualImage);
            Assert.AreEqual(1, actualImage.Width);
            Assert.AreEqual(1, actualImage.Height);

            paintImage  = new PaintBitmap(100, 100);
            actualImage = paintImage.ToImage();
            Assert.AreEqual(100, actualImage.Width);
            Assert.AreEqual(100, actualImage.Height);
        }
Example #9
0
 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();
         }
     }
 }