void SelectorItem_MouseLeftButtonDown(object sender, MouseEventArgs e)
        {
            CustomSelector selectorViewModel = this.DataContext as CustomSelector;

            if (e.LeftButton == MouseButtonState.Pressed && Command != null)
            {
                INode         n     = (INode)(selectorViewModel.Nodes as ICollection <object>).FirstOrDefault();
                DrawParameter param = new DrawParameter(DrawingTool.Connector, e, null,
                                                        n, null);
                this.Command.Execute(param);
                isPressed = false;
            }
            e.Handled = true;
        }
Exemple #2
0
        private QuickCommandViewModel AddQuickCommand(Thickness margin, Point offset, string content, ICommand command)
        {
            QuickCommandViewModel quickCommand = new QuickCommandViewModel()
            {
                Margin              = margin,
                OffsetX             = offset.X,
                OffsetY             = offset.Y,
                Command             = command,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
                VisibilityMode      = VisibilityMode.Node,
                Content             = GetTemplate(content),
                Shape      = "F1M23.467,11.733C23.467,18.213 18.214,23.466 11.734,23.466 5.253,23.466 0,18.213 0,11.733 0,5.253 5.253,0 11.734,0 18.214,0 23.467,5.253 23.467,11.733",
                ShapeStyle = this.Resources["QuickCommandstyle"] as Style,
            };

            if (content == "Bringtofront")
            {
                quickCommand.ShapeStyle = this.Resources["BringToFrontQuickCommandstyle"] as Style;
            }
            if (content == "SendToBack")
            {
                quickCommand.ShapeStyle = this.Resources["SendToBackQuickCommandstyle"] as Style;
            }

            if (content == "Draw" || content == "Draw1" || content == "Duplicate")
            {
                DrawParameter       drawParameter      = new DrawParameter(DrawingTool.Connector, null, null, null, null, NullSourceTarget.SelectionAsSource | NullSourceTarget.CloneSourceAsTarget);
                DupilicateParameter duplicateParameter = new DupilicateParameter()
                {
                    DragClone = true
                };
                quickCommand.DragCommand = command;
                if (content == "Duplicate")
                {
                    quickCommand.CommandParameter = duplicateParameter;
                }
                else
                {
                    quickCommand.CommandParameter = drawParameter;
                }
            }
            ((DiagramControl.SelectedItems as SelectorViewModel).Commands as QuickCommandCollection).Add(quickCommand);
            return(quickCommand);
        }
 internal override void Draw(DrawParameter drawParameter)
 {
 }
 internal override void Draw(DrawParameter drawParameter)
 {
     base.Draw(drawParameter);
 }//子类重写一下