public void MouseMove(Pen pen, MouseEventArgs e) { if (_movingFigure != null) { PointF delta = new PointF(e.X - _startPoint.X, e.Y - _startPoint.Y); _startPoint = e.Location; _movingFigure.Move(delta); _singletone.PictureBox1.Image = _singletone.Canvas.DrawIt(_movingFigure, new Pen(_movingFigure.Color, _movingFigure.Width)); GC.Collect(); } }
public override void DoLogicOnMouseMove(Point preLocation, Point location, AFigure figure) { sBitmap.Copy(); figure.Move(preLocation, location, figure); sBitmap.vDrawFigure(figure); }
private void pictureBox_MouseMove(object sender, MouseEventArgs e) { bitmap.CopyInNew(); if (mouseDown) { if (_reversal && ActiveFigure != null) { int rev = e.Y - FirstPoint.Y; ActiveFigure.SetAngle(rev); bitmap.DeleteFigure(ActiveFigure); bitmap.DrawFigure(ActiveFigure); } if (_changeLocation) { fill = false; _deletingFigure = false; Point delta = new Point(); delta.X = e.X - FirstPoint.X; delta.Y = e.Y - FirstPoint.Y; FirstPoint = e.Location; if (CurrentFigure == null) { CurrentFigure = bitmap.SelectFigureByPoint(e.Location); if (CurrentFigure != null) { bitmap.Bitmap = new Bitmap(pictureBox.Width, pictureBox.Height); bitmap.DeleteFigure(CurrentFigure); } } if (CurrentFigure != null) { bitmap.ShowOnTheScreen(); CurrentFigure.Move(delta); bitmap.DrawFigure(CurrentFigure); mode = "Рисуем"; } } else if (toolBox.SelectedIndex == 0) { SecondPoint = FirstPoint; FirstPoint = e.Location; bitmap.DrawLine(FirstPoint, SecondPoint, _currentThickness, _currentColor); bitmap.CopyInOld(); pictureBox.Image = bitmap.Bitmap; } else if (toolBox.SelectedIndex != 6 && toolBox.SelectedIndex != -1 && mode == "Рисуем") { if (CurrentFigure == null && factoryFigure != null) { CurrentFigure = factoryFigure.Create(FirstPoint, n, _currentColor, _fillColor, _currentThickness); } if (CurrentFigure != null) { CurrentFigure.Update(e.Location); bitmap.DrawFigure(CurrentFigure); } } } if (mode == "Изменить" && mouseDown) //mode == "Изменить" { ActiveFigure.Update(e.Location); bitmap.DrawFigure(ActiveFigure); } if (bitmap.SelectFigureByPointq(e.Location) && mode != "Выбрал" && mode != "Изменить" && mode != "Заливка") { CurrentFigure = bitmap.GetAFigure(); bitmap.HighlightSelectedFigure(CurrentFigure); mode = "Навел"; } else if (mode != "Выбрал" && mode != "Изменить" && mode != "Заливка") { mode = "Рисуем"; } if (mode == "Выбрал") { q = bitmap.PointInPoint(ActiveFigure, e.Location); } if (toolBox.SelectedIndex != -1 && mode != "Изменить") { _changeLocation = false; _deletingFigure = false; _editFigure = false; _reversal = false; } xLabel.Text = $"X = {e.X}"; Ylabel.Text = $"Y = {e.Y}"; modeLabel.Text = mode; GC.Collect(); pictureBox.Image = bitmap.tmpBitmap; }