Esempio n. 1
0
 public static void SetMarkerData(VisualTextMarker marker)
 {
     TextMarkerInputBox inputBox = new TextMarkerInputBox(marker);
     inputBox.ShowDialog();
 }
        /// <summary>
        /// Event raised on mouse up in the ZoomAndPanControl.
        /// </summary>
        private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (mouseHandlingMode != MouseHandlingMode.None)
            {
                if (mouseHandlingMode == MouseHandlingMode.Zooming)
                {
                    if (mouseButtonDown == MouseButton.Left)
                    {
                        // Shift + left-click zooms in on the content.
                        ZoomIn(origContentMouseDownPoint);
                    }
                    else if (mouseButtonDown == MouseButton.Right)
                    {
                        // Shift + left-click zooms out from the content.
                        ZoomOut(origContentMouseDownPoint);
                    }
                }
                else if (mouseHandlingMode == MouseHandlingMode.DragZooming)
                {
                    // When drag-zooming has finished we zoom in on the rectangle that was highlighted by the user.
                    ApplyDragZoomRect();
                }
                if (mouseHandlingMode == MouseHandlingMode.DragObject)
                {
                    // When releasing dragged objects
                    Gizmo_TransformationChanged(Gizmo, TransformationEvent.TranslationEnded);
                }
                if (mouseHandlingMode == MouseHandlingMode.CreateRectangle)
                {
                    // mouse rectangle location to center of shape
                    VisualRectangularBuilding building = GlobalManagement.Instance.NewRectangleBuilding;
                    Point diagonal = building.C.Sub(building.A);
                    building.X += diagonal.X / 2;
                    building.Y += diagonal.Y / 2;
                    building.A  = building.A.Sub(diagonal.Mult(0.5));
                    building.C  = building.C.Sub(diagonal.Mult(0.5));
                    building.CreateFloorFromDimensions();

                    // When releasing during the creation of a rectangle
                    CreateRectangleAction createAction = new CreateRectangleAction(null, _vm)
                    {
                        Building = GlobalManagement.Instance.NewRectangleBuilding
                    };
                    GlobalManagement.Instance.UndoStack.Push(createAction);
                    _vm.SelectedEntities.Clear();
                    GlobalManagement.Instance.NewRectangleBuilding.IsSelected = true;
                    GlobalManagement.Instance.NewRectangleBuilding            = null;
                }
                if (mouseHandlingMode == MouseHandlingMode.CreatePolygon)
                {
                    // don't stop if polygon being is created -> this is done via doubleclick
                    return;
                }
                if (mouseHandlingMode == MouseHandlingMode.CreateTextMarker)
                {
                    // place text marker
                    CreateTextMarkerAction action = new CreateTextMarkerAction(null, _vm);
                    action.Marker = new VisualTextMarker(new TextMarker()
                    {
                        X    = Utils.PxToMeter(_vm.MousePosition.X),
                        Y    = Utils.PxToMeter(_vm.MousePosition.Y),
                        Text = "Text",
                        Name = Constants.DefaultMarkerName,
                    });
                    TextMarkerInputBox.SetMarkerData(action.Marker);
                    action.Marker.Name = Constants.DefaultMarkerName + "_" + action.Marker.Text.Replace(' ', '_');
                    action.Do();
                    zoomAndPanControl.Cursor = Cursors.Arrow;
                    GlobalManagement.Instance.UndoStack.Push(action);
                }
                if (mouseHandlingMode == MouseHandlingMode.CreateWall)
                {
                    // don't stop if wall being is created
                    if (_vm.CurrentWall != null)
                    {
                        _vm.CurrentWall   = null;
                        mouseHandlingMode = MouseHandlingMode.None;
                        zoomAndPanControl.ReleaseMouseCapture();
                    }
                    return;
                }

                zoomAndPanControl.ReleaseMouseCapture();
                mouseHandlingMode = MouseHandlingMode.None;
                GlobalManagement.Instance.IsCreatingRectangularBuilding = false;
                _vm.GizmoDragX = false;
                _vm.GizmoDragY = false;
                GlobalManagement.Instance.NewRectangleBuilding = null;
                e.Handled = true;
            }
        }