Exemple #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)
             }
         }
         );
     }
 }
Exemple #2
0
            private Either <GraphAndUI <TUIRawData>, LoadError> ReadEditable(XElement node, IDataSource datasource, object documentID)
            {
                Id <NodeTemp> id = Id <NodeTemp> .Parse(node.Attribute("Id").Value);

                Id <NodeTypeTemp> guid = ReadType(node);

                INodeDataGenerator editableGenerator = datasource.GetNode(guid);

                Either <GraphAndUI <TUIRawData>, LoadError> result;

                var parameterNodes = node.Elements("Parameter");
                var parameterData  = parameterNodes.Select(p => new NodeDataGeneratorParameterData(Id <Parameter> .Parse(p.Attribute("guid").Value), p.Attribute("value").Value)).ToList();

                if (editableGenerator != null)
                {
                    IConversationNodeData editable = editableGenerator.Generate(id, parameterData, documentID);
                    result = new GraphAndUI <TUIRawData>(editable, m_nodeUIDeserializer.Read(node));
                }
                else
                {
                    var             parameters = parameterData.Select(p => new UnknownParameter(p.Guid, p.Value));
                    UnknownEditable editable   = new UnknownEditable(id, guid, parameters);
                    result = new GraphAndUI <TUIRawData>(editable, m_nodeUIDeserializer.Read(node));
                }

                return(result);
            }