예제 #1
0
 public bool IsIdSelected(Guid id)
 {
     if (SelectedNodes == null || !SelectedNodes.Any())
     {
         return(true);
     }
     if (SelectedNodes.Contains(id))
     {
         return(true);
     }
     return(false);
 }
        public async ValueTask OnSelectCallback(InteropNodeEventData evt)
        {
            switch (evt.Type)
            {
            case "select_node":
                // this.invoke_event_handle(jm.event_type.select, { evt: 'select_node', data: [], node: node.id });

                var node = FindNode(evt.NodeId);

                await OnSelectNode.InvokeAsync(new MindMapSingleSelectEventArgs <T>
                {
                    Node     = node,
                    Selected = node is not null && SelectedNodes.Any(n => n.Id == node.Id)
                });

                break;
            }
예제 #3
0
        internal void ExcludeSelected()
        {
            if (!SelectedNodes.Any() || _currentCsprojFile == null)
            {
                return;
            }

            var content = SelectedNodes
                          .Where(n => n.NodeModel != null)
                          .Select(p => p.NodeModel)
                          .ToArray();

            _writer.WriteExclusions(content, _currentCsprojFile);

            foreach (var node in Tree)
            {
                foreach (var desc in node.Descendents)
                {
                    desc.IsSelected = false;
                }
            }
            SelectedNodes.Clear();
        }
        /*
         * public void DoDynamicAnimation(object sender, MouseButtonEventArgs args)
         * {
         *  for (var i = 0; i < 36; ++i)
         *  {
         *      // var e = new Button { Width = 50, Height = 16, Content="Test" };
         *
         *      //var e = new Ellipse { Width = 16, Height = 16, Fill = SystemColors.HighlightBrush };
         *      //var e = new Ellipse { Width = 6, Height = 6, Fill=Brushes.HotPink };
         *
         *      var e = new SliderNode(this) {Left = Mouse.GetPosition(this).X, Top = Mouse.GetPosition(this).Y};
         *
         *      // var e = new TextBlock { Text = "Test" };
         *      // var e = new Slider { Width = 100 };
         *
         *      // var e = new ProgressBar { Width = 100 , Height =10, Value=i };
         *
         *      // var e = =new DataGrid{Width=100, Height=100};
         *      // var e = new TextBox { Text = "Hallo" };
         *      // var e = new Label { Content = "Halllo" };
         *      // var e = new RadioButton { Content="dfsdf" };
         *
         *      //Canvas.SetLeft(e, Mouse.GetPosition(this).X);
         *      //Canvas.SetTop(e, Mouse.GetPosition(this).Y);
         *
         *      var tg = new TransformGroup();
         *      var translation = new TranslateTransform(30, 0);
         *      var translationName = "myTranslation" + translation.GetHashCode();
         *      RegisterName(translationName, translation);
         *      tg.Children.Add(translation);
         *      tg.Children.Add(new RotateTransform(i*10));
         *      e.RenderTransform = tg;
         *
         *      NodeCollection.Add(e);
         *      Children.Add(e);
         *
         *      var anim = new DoubleAnimation(3, 250, new Duration(new TimeSpan(0, 0, 0, 2, 0)))
         *      {
         *          EasingFunction = new PowerEase {EasingMode = EasingMode.EaseOut}
         *      };
         *
         *      var s = new Storyboard();
         *      Storyboard.SetTargetName(s, translationName);
         *      Storyboard.SetTargetProperty(s, new PropertyPath(TranslateTransform.YProperty));
         *      var storyboardName = "s" + s.GetHashCode();
         *      Resources.Add(storyboardName, s);
         *
         *      s.Children.Add(anim);
         *
         *      s.Completed +=
         *          (sndr, evtArgs) =>
         *          {
         *              //panel.Children.Remove(e);
         *              Resources.Remove(storyboardName);
         *              UnregisterName(translationName);
         *          };
         *      s.Begin();
         *  }
         * }
         */


        public void VplControl_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.Delete:

                // Do not Delete if there is an ScriptingNode in the selection -> Delete Key is used several times inside ...
                foreach (var node in SelectedNodes)
                {
                    if (node.GetType().ToString() == "TUM.CMS.VPL.Scripting.Nodes.ScriptingNode")
                    {
                        return;
                    }
                    node.Delete();
                }


                SelectedNodes.Clear();
                break;

            case Key.C:
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    tempCollection = new TrulyObservableCollection <Node>();


                    foreach (var node in SelectedNodes)
                    {
                        tempCollection.Add(node);
                    }
                }
            }
            break;

            case Key.V:
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    // Do not copy if there is an ScriptingNode in the selection
                    if (SelectedNodes.Any(node => node.GetType().ToString() == "TUM.CMS.VPL.Scripting.Nodes.ScriptingNode"))
                    {
                        return;
                    }

                    if (tempCollection == null)
                    {
                        return;
                    }
                    if (tempCollection.Count == 0)
                    {
                        return;
                    }

                    var bBox = Node.GetBoundingBoxOfNodes(tempCollection.ToList());

                    var copyPoint  = new Point(bBox.Left + bBox.Size.Width / 2, bBox.Top + bBox.Size.Height / 2);
                    var pastePoint = Mouse.GetPosition(this);

                    var delta = Point.Subtract(pastePoint, copyPoint);

                    SelectedNodes.Clear();

                    var alreadyClonedConnectors = new List <Connector>();
                    var copyConnections         = new List <CopyConnection>();

                    // copy nodes from clipboard to canvas
                    foreach (var node in tempCollection)
                    {
                        var newNode = node.Clone();

                        newNode.Left += delta.X;
                        newNode.Top  += delta.Y;

                        newNode.Left = Convert.ToInt32(newNode.Left);
                        newNode.Top  = Convert.ToInt32(newNode.Top);

                        NodeCollection.Add(newNode);

                        copyConnections.Add(new CopyConnection {
                                NewNode = newNode, OldNode = node
                            });
                    }

                    foreach (var cc in copyConnections)
                    {
                        var counter = 0;

                        foreach (var conn in cc.OldNode.InputPorts)
                        {
                            foreach (var connector in conn.ConnectedConnectors)
                            {
                                if (!alreadyClonedConnectors.Contains(connector))
                                {
                                    Connector newConnector = null;

                                    // start and end node are contained in selection
                                    if (tempCollection.Contains(connector.StartPort.ParentNode))
                                    {
                                        var cc2 =
                                            copyConnections.FirstOrDefault(
                                                i => Equals(i.OldNode, connector.StartPort.ParentNode));

                                        if (cc2 != null)
                                        {
                                            newConnector = new Connector(this, cc2.NewNode.OutputPorts[0],
                                                                         cc.NewNode.InputPorts[counter]);
                                        }
                                    }
                                    // only end node is contained in selection
                                    else
                                    {
                                        newConnector = new Connector(this, connector.StartPort,
                                                                     cc.NewNode.InputPorts[counter]);
                                    }

                                    if (newConnector != null)
                                    {
                                        alreadyClonedConnectors.Add(connector);
                                        ConnectorCollection.Add(newConnector);
                                    }
                                }
                            }
                            counter++;
                        }
                    }
                }
            }
            break;

            case Key.G:
            {
                if (Keyboard.Modifiers == ModifierKeys.Control)
                {
                    GroupNodes();
                }
            }
            break;

            case Key.S:
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    SaveFile();
                }
            }
            break;

            case Key.O:
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    OpenFile();
                }
            }
            break;

            case Key.A:
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    SelectedNodes.Clear();

                    foreach (var node in NodeCollection)
                    {
                        node.IsSelected = true;
                        SelectedNodes.Add(node);
                    }
                }
            }
            break;
            }
        }