Exemplo n.º 1
0
        private void viewPort_MouseClick(object sender, MouseEventArgs e)
        {
            if (DrawLineButton.Checked)
            {
                float X1 = e.X;
                float Y1 = e.Y;

                dialogProcessor.AddLine(X, Y, X1, Y1);

                viewPort.Invalidate();
            }
        }
Exemplo n.º 2
0
        PointF pt1;// = new PointF();
        void ViewPortMouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (drawRectangleSpeedButton.Checked)
            {
                if (drawing == false)
                {
                    dialogProcessor.pressedAt  = e.Location;
                    dialogProcessor.currentPos = e.Location;
                    dialogProcessor.AddRectangle();
                    if (dialogProcessor.Selection != null)
                    {
                        setProperties(dialogProcessor.Selection);
                    }
                    drawing = true;
                }
                else
                {
                    dialogProcessor.Selection.Translate(e.Location);
                    setProperties(dialogProcessor.Selection);
                    drawing = false;
                }
            }
            else if (lineBtn.Checked)
            {
                if (drawing == false)
                {
                    dialogProcessor.pressedAt  = e.Location;
                    dialogProcessor.currentPos = e.Location;
                    pt1 = new PointF();
                    pt1 = e.Location;
                    if (pt1 != null)
                    {
                        dialogProcessor.AddLine(pt1, e.Location);
                    }
                    if (dialogProcessor.Selection != null)
                    {
                        setProperties(dialogProcessor.Selection);
                    }
                    drawing = true;
                }
                else
                {
                    dialogProcessor.Selection.Translate(e.Location);
                    setProperties(dialogProcessor.Selection);
                    drawing = false;
                }
            }
            else if (ellipseBtn.Checked)
            {
                if (drawing == false)
                {
                    dialogProcessor.pressedAt  = e.Location;
                    dialogProcessor.currentPos = e.Location;
                    pt1 = new PointF();
                    pt1 = e.Location;
                    if (pt1 != null)
                    {
                        dialogProcessor.AddCircle(pt1, e.Location);
                    }
                    if (dialogProcessor.Selection != null)
                    {
                        setProperties(dialogProcessor.Selection);
                    }
                    drawing = true;
                }
                else
                {
                    dialogProcessor.Selection.Translate(e.Location);
                    setProperties(dialogProcessor.Selection);
                    drawing = false;
                }
            }

            if (dialogProcessor.Selection == null)
            {
                nameTxt.Text       = "";
                colorBtn.BackColor = SystemColors.Control;
                opacityTxt.Text    = "";
                xtxt.Text          = "";
                ytxt.Text          = "";
                typeTxt.Text       = "";
                widthTxt.Text      = "";
                heightTxt.Text     = "";
                foreach (Shape shape in dialogProcessor.ShapeList)
                {
                    shape.Selected = false;
                }
            }

            dialogProcessor.releasedAt     = e.Location;
            dialogProcessor.IsDragging     = false;
            dialogProcessor.isTransforming = false;
            viewPort.Invalidate();
        }
Exemplo n.º 3
0
        private void ViewPortMouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (dialogProcessor.IsDragging && !ButtonMultiMove.Checked)
            {
                dialogProcessor.TranslateTo(dialogProcessor.Selection, dialogProcessor.LastLocation, e.Location);
                dialogProcessor.LastLocation = e.Location;
            }
            if (ButtonMultiMove.Checked && dialogProcessor.IsDragging && dialogProcessor.MultiSelection != null)
            {
                dialogProcessor.MultiMoveTo(dialogProcessor.LastLocation, e.Location);
                dialogProcessor.LastLocation = e.Location;
            }

            var startPoint  = dialogProcessor.OnMouseDownPoint;
            var endPoint    = e.Location;
            var shapeParams = DimentionCalculator.GetShapesParamsByTwoPoints(startPoint, endPoint);

            if (ButtonMultiSelect.Checked && dialogProcessor.MultiSelectFlag)
            {
                dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag);
                dialogProcessor.AddRectangle(
                    shapeParams.Item1, shapeParams.Item2, shapeParams.Item5, shapeParams.Item6, DashStyle.Dot, true, 0);
            }

            if (ButtonDrawRectangle.Checked && dialogProcessor.DrawTemporaryRectangle)
            {
                dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag);
                dialogProcessor.AddRectangle(
                    shapeParams.Item1, shapeParams.Item2, shapeParams.Item5, shapeParams.Item6, DashStyle.Dot, true);
            }
            if (ButtonDrowTriangle.Checked && dialogProcessor.DrawTemporaryTriangle)
            {
                dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag);
                dialogProcessor.AddTriangle(
                    new PointF(shapeParams.Item1, shapeParams.Item4),
                    new PointF(shapeParams.Item1, shapeParams.Item2),
                    new PointF(shapeParams.Item3, shapeParams.Item2), DashStyle.Dot, true);
            }
            if (ButtonDrawLine.Checked && dialogProcessor.DrawTemporaryLine)
            {
                dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag);
                dialogProcessor.AddLine(startPoint, endPoint, DashStyle.Dot, true);
            }
            if (ButtonDrawEllipse.Checked && dialogProcessor.DrawTemporaryEllipse)
            {
                dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag);
                dialogProcessor.AddEllipse(
                    shapeParams.Item1, shapeParams.Item2, shapeParams.Item5, shapeParams.Item6, DashStyle.Dot, true);
            }
            if (ButtonDrawReuleauxTriangle.Checked && dialogProcessor.DrawTemporaryReuleauxTriangle)
            {
                dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag);
                dialogProcessor.AddReuleauxTriangle(startPoint, endPoint, DashStyle.Dot, true);
            }
            if (ButtonDrawEnvelope.Checked && dialogProcessor.DrawTemporaryEnvelope)
            {
                dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag);
                dialogProcessor.AddEnvelope(
                    shapeParams.Item1, shapeParams.Item2, shapeParams.Item5, shapeParams.Item6, DashStyle.Dot, true);
            }
            if (ButtonDrawGenericCircle.Checked && dialogProcessor.DrawTemporaryGenericCircle)
            {
                dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag);
                dialogProcessor.AddGenericCircle(
                    shapeParams.Item1, shapeParams.Item2, shapeParams.Item5, shapeParams.Item6, DashStyle.Dot, true);
            }
            if (ButtonCopy.Checked && dialogProcessor.DrawTemporaryCopyShape && dialogProcessor.SelectionCopy != null)
            {
                dialogProcessor.ShapeList[dialogProcessor.CurrentTab].RemoveAll(s => s.TemporaryFlag);
                dialogProcessor.SelectionCopy.MoveToNextDestination(e.Location, dialogProcessor.LastLocation);
                dialogProcessor.SelectionCopy.UniqueIdentifier = Guid.NewGuid();
                dialogProcessor.ShapeList[dialogProcessor.CurrentTab].Add(dialogProcessor.SelectionCopy);
                dialogProcessor.LastLocation = e.Location;
            }
            RerenderMainCanvas();
        }