예제 #1
0
파일: MainForm.cs 프로젝트: VladaCat/Paint
        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();
                }
            }
        }
예제 #2
0
파일: MainForm.cs 프로젝트: VladaCat/Paint
 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();
 }
예제 #3
0
파일: MainForm.cs 프로젝트: VladaCat/Paint
 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;
     }
 }
예제 #4
0
파일: MainForm.cs 프로젝트: VladaCat/Paint
 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);
     }
 }
예제 #5
0
파일: MainForm.cs 프로젝트: VladaCat/Paint
        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();
        }
예제 #6
0
파일: MainForm.cs 프로젝트: VladaCat/Paint
        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);
            }
        }
예제 #7
0
파일: MainForm.cs 프로젝트: VladaCat/Paint
        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);
            }
        }
예제 #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);
        }
예제 #9
0
파일: MainForm.cs 프로젝트: VladaCat/Paint
 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();
         }
     }
 }