private void MainPictureBox_MouseUp(object sender, MouseEventArgs e) { if (!_isStartMove && !_isSelectMode && !_isMoveMode && e.Button == MouseButtons.Left) { if (_bl.isBoolCount()) { IShape currentShape = _bl.Last(); currentShape.MouseUp(new ShapePoint(e.Location)); Repaint(); } } else if (_isStartMove && e.Button == MouseButtons.Left) { IShape currentShape = _bl.Last(); _bl.Move(e.X - _lastPonit.X, e.Y - _lastPonit.Y, currentShape); currentShape.Draw(PaintGraphics.FromImage(_currentBitmap)); if (currentShape.Name == EShapeType.Dot) { currentShape.EShapeStatus = EShapeStatus.DONE; Repaint(); } _isStartMove = false; _isSelected = false; } }
public override void Draw(PaintGraphics graphics) { (int x, int y, int width, int height) = CalculateHexagon(); if (width == 0 || height == 0) { return; } if (Cornes == 0) { Cornes = _cornes; } width += Thickness; height += Thickness; int Radius = (int)((double)Math.Min(width, height) / (double)2.0 * (double)0.8); ShapePointF Center = new ShapePointF((int)((double)width / (double)2.0), (int)((double)height / (double)2.0)); PaintRectangleF rectangle = new PaintRectangleF(Center, new ShaipSizeF(1, 1)); rectangle.Inflate(Radius, Radius); PaintImage img = new PaintBitmap(Size.Width, Size.Height); PaintGraphics tmpGraphics = PaintGraphics.FromImage(img); InscribePolygon(tmpGraphics, rectangle, _cornes); graphics.DrawImage(img, x, y); }
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(); } } }