예제 #1
0
        public void MouseMove(Pen pen, MouseEventArgs e)
        {
            if ((_figure.Reaction is FreeLineIRightClickReaction ||
                 _figure.Reaction is FreeFigureIRightClickReaction ||
                 _figure.Reaction is Triangle3DIRightClickReaction) && (_mouseMove == false))
            {
                _figure.AnglesNumber++;
                _figure.PointsList.Add(_figure.TmpPoint); //точка добавляется в лист в начале движения мыши
            }
            _figure.Update(_startPoint, e.Location);
            _mouseMove = true; //после записи точки запись заканчивается
            _singletone.PictureBox1.Image = _singletone.Canvas.DrawIt(_figure, pen);
            _figure.SecondPoint           = e.Location;
            if (_figure is BrushIFigure)
            {
                _startPoint = e.Location;
            }

            GC.Collect();
        }
예제 #2
0
        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;
        }