Esempio n. 1
0
 public void AddNode(INodeDataGenerator node, Point p)
 {
     if (CurrentFile.File.Exists)
     {
         TNode  g       = CurrentFile.MakeNode(node.Generate(Id <NodeTemp> .New(), new List <NodeDataGeneratorParameterData>(), CurrentFile), new NodeUIData(p));
         Action addNode = () => { CurrentFile.Add(g.Only(), Enumerable.Empty <NodeGroup>(), m_localization); };
         g.Configure(MyEdit).Do
         (
             //Configure the node and then add it. We need to configure the node before adding so that it is in a valid state
             //when added. Failure to do so results in localized string parameters having a null value meaning their undo
             //behavior can't be set up correctly.
             simpleUndoPair => { simpleUndoPair.Redo(); addNode(); },
             resultNotOk =>
         {
             if (resultNotOk == ConfigureResult.Cancel)
             {
                 //Merge the parameter into a junk source so it doesn't count towards the real source
                 foreach (var parameter in g.Data.Parameters.OfType <IDynamicEnumParameter>())
                 {
                     parameter.MergeInto(new DynamicEnumParameter.Source());
                 }
             }
             else
             {
                 addNode();      //Add the node if the user didn't cancel (i.e. no editing was required)
             }
         }
         );
     }
 }
Esempio n. 2
0
        public void GroupSelection()
        {
            if (Selected.Nodes.Any())
            {
                NodeGroup newGroup = NodeGroup.Make(Selected.Nodes.Select(CurrentFile.GetNode));
                CurrentFile.Add(Enumerable.Empty <TNode>(), newGroup.Only(), m_localization);
                SetSelection(Selected.Nodes.Evaluate(), Selected.Groups.Concat(newGroup.Only()).Evaluate());

                Redraw();
            }
        }