Пример #1
0
        private static void IsDrawingPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs args)
        {
            DDPenTool sender   = (DDPenTool)d;
            bool      newValue = (bool)args.NewValue;

            if (newValue)
            {
                sender.ToolCursor = sender.PenCursor;
            }
            else
            {
                sender.ToolCursor = sender.EditCursor;
            }
        }
Пример #2
0
        protected void CheckExpanders()
        {
            if (ToolManager.ActiveTool is DDPickTool)
            {
                xamlExpanderPickTool.Visibility = Visibility.Visible;
                DDPickTool pickTool = (ToolManager.ActiveTool as DDPickTool);
                xamlAllowPartialSelection.SetBinding(ToggleButton.IsCheckedProperty,
                                                     new Binding("AllowIntersectionHits")
                {
                    Source = pickTool, Mode = BindingMode.TwoWay
                });

                if (pickTool != _lastConnectedPickTool)
                {
                    pickTool.FrameChanged   += TSFrameChangedHandler;
                    pickTool.ObjectsAdded   += AnyTool_UndoRelevantChange;
                    pickTool.ObjectsDeleted += AnyTool_UndoRelevantChange;
                    _lastConnectedPickTool   = pickTool;
                }
                TSFrameChangedHandler(null);
            }
            else
            {
                xamlExpanderPickTool.Visibility        = Visibility.Collapsed;
                xamlExpanderSelectionLayout.Visibility = Visibility.Collapsed;

                BindingOperations.ClearBinding(xamlAllowPartialSelection, ToggleButton.IsCheckedProperty);
            }

            if (ToolManager.ActiveTool is DDRectangleTool)
            {
                xamlExpanderFill.Visibility      = Visibility.Visible;
                xamlExpanderStroke.Visibility    = Visibility.Visible;
                xamlExpanderRectangle.Visibility = Visibility.Visible;
                BindFillAndStrokeObject(DDRectangleTool.PrototypeRectangle);

                if (_lastConnectedRectangleTool != ToolManager.ActiveTool)
                {
                    (ToolManager.ActiveTool as DDRectangleTool).ObjectCreated += AnyTool_UndoRelevantChange;
                    _lastConnectedRectangleTool = ToolManager.ActiveTool;
                }
            }
            else
            {
                xamlExpanderRectangle.Visibility = Visibility.Collapsed;
            }

            if (ToolManager.ActiveTool is DDEllipseTool)
            {
                xamlExpanderFill.Visibility   = Visibility.Visible;
                xamlExpanderStroke.Visibility = Visibility.Visible;
                BindFillAndStrokeObject(DDEllipseTool.PrototypeEllipse);

                if (_lastConnectedEllipseTool != ToolManager.ActiveTool)
                {
                    (ToolManager.ActiveTool as DDEllipseTool).ObjectCreated += AnyTool_UndoRelevantChange;
                    _lastConnectedEllipseTool = ToolManager.ActiveTool;
                }
            }

            if (ToolManager.ActiveTool is DDPenTool)
            {
                xamlExpanderFill.Visibility    = Visibility.Visible;
                xamlExpanderStroke.Visibility  = Visibility.Visible;
                xamlExpanderPenTool.Visibility = Visibility.Visible;

                DDPenTool penTool = ToolManager.ActiveTool as DDPenTool;
                xamlExpanderPolygonButton.SetBinding(UIElement.IsEnabledProperty,
                                                     new Binding("IsDrawing")
                {
                    Source = penTool, Converter = new DDBooleanInversionConverter()
                });
                xamlExpanderPolylineButton.SetBinding(UIElement.IsEnabledProperty,
                                                      new Binding("IsDrawing")
                {
                    Source = penTool, Converter = new DDBooleanInversionConverter()
                });
                xamlExpanderPolygonButton.SetBinding(ToggleButton.IsCheckedProperty,
                                                     new Binding("CreateClosed")
                {
                    Source = penTool
                });

                if (_lastConnectedPenTool != ToolManager.ActiveTool)
                {
                    (ToolManager.ActiveTool as DDPenTool).ObjectCreated += AnyTool_UndoRelevantChange;
                    _lastConnectedPenTool = ToolManager.ActiveTool;
                }

                BindFillAndStrokeObject(DDPenTool.PrototypeNodeObject);
            }
            else
            {
                xamlExpanderPenTool.Visibility = Visibility.Collapsed;

                BindingOperations.ClearBinding(xamlExpanderPolygonButton, UIElement.IsEnabledProperty);
                BindingOperations.ClearBinding(xamlExpanderPolylineButton, UIElement.IsEnabledProperty);
                BindingOperations.ClearBinding(xamlExpanderPolygonButton, ToggleButton.IsCheckedProperty);
            }

            xamlExpanderPolygon.Visibility  = Visibility.Collapsed;
            xamlExpanderPolyline.Visibility = Visibility.Collapsed;

            if ((ToolManager.ActiveTool == null) || (ToolManager.ActiveTool is DDEditTool))
            {
                xamlExpanderFill.Visibility   = Visibility.Collapsed;
                xamlExpanderStroke.Visibility = Visibility.Collapsed;
                BindFillAndStrokeObject(null);
            }

            if (ToolManager.ActiveTool == null)
            {
                xamlExpanderCanvasSettings.Visibility = Visibility.Visible;
            }
            else
            {
                xamlExpanderCanvasSettings.Visibility = Visibility.Collapsed;
            }
        }