示例#1
0
        /// <summary>
        /// Прихващане на координатите при натискането на бутон на мишката и проверка (в обратен ред) дали не е
        /// щракнато върху елемент. Ако е така то той се отбелязва като селектиран и започва процес на "влачене".
        /// Промяна на статуса и инвалидиране на контрола, в който визуализираме.
        /// Реализацията се диалогът с потребителя, при който се избира "най-горния" елемент от екрана.
        /// </summary>
        void ViewPortMouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (dialogProcessor.CurrentTool == ToolSet.Selection)
            {
                Shape selectedShape = dialogProcessor.ContainsPoint(e.Location);

                if (selectedShape == null)
                {
                    return;
                }

                if (dialogProcessor.Selection.Contains(selectedShape))
                {
                    dialogProcessor.Selection.Remove(selectedShape);
                }
                else
                {
                    dialogProcessor.Selection.Add(selectedShape);
                }
                statusBar.Items[0].Text      = "Последно действие: Селекция на примитив";
                dialogProcessor.IsDragging   = true;
                dialogProcessor.LastLocation = e.Location;
                viewPort.Invalidate();
                //ReloadShapesList();
            }
            else if (dialogProcessor.CurrentTool == ToolSet.DrawEllipse)
            {
                dialogProcessor.AddEllipse(false, e.X, e.Y);
                viewPort.Invalidate();
                //ReloadShapesList();
            }
            else if (dialogProcessor.CurrentTool == ToolSet.DrawRectangle)
            {
                dialogProcessor.AddRectangle(false, e.X, e.Y);
                viewPort.Invalidate();
            }
            else if (dialogProcessor.CurrentTool == ToolSet.DrawCircle)
            {
                dialogProcessor.AddCircle(false, e.X, e.Y);
                viewPort.Invalidate();
                //ReloadShapesList();
            }
            else if (dialogProcessor.CurrentTool == ToolSet.DrawSquare)
            {
                dialogProcessor.AddSquare(false, e.X, e.Y);
                viewPort.Invalidate();
            }
        }
示例#2
0
 private void DrawingShape()
 {
     if (rectangleRadioButton.Checked)
     {
         statusBar.Items[0].Text = "Last action: Drawing rectangle";
         dialogProcessor.AddRectangle();
     }
     else if (ellipseRadioButton.Checked)
     {
         statusBar.Items[0].Text = "Last action: Drawing ellipse";
         dialogProcessor.AddEllipse();
     }
 }
示例#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();
        }