示例#1
0
    public static WiringDocument CreateBlankWiringDocument(string docName)
    {
        WiringDocument wd = new WiringDocument(true, string.Empty);

        wd.SetName(docName);
        return(wd);
    }
示例#2
0
    public WiringDocument AddNewWiringDocument(string docName, bool setActive)
    {
        WiringDocument wd = new WiringDocument(true, string.Empty);

        wd.SetName(docName);

        if (this.AddDocument(wd) == false)
        {
            return(null);
        }

        if (setActive == true)
        {
            this.SetActiveDocument(wd);
        }

        return(wd);
    }
示例#3
0
    public WiringDocument Clone(string newName)
    {
        // Fill up the directory. Used so we can use existing
        // cloning utilities for cloning connection params.
        Dictionary <string, LLDNBase> thisLookup =
            new Dictionary <string, LLDNBase>();

        foreach (LLDNBase gnb in this.generators)
        {
            thisLookup.Add(gnb.GUID, gnb);
        }

        // Copy all the generators.
        Dictionary <LLDNBase, LLDNBase> thisToThatMap =
            new Dictionary <LLDNBase, LLDNBase>();

        WiringDocument wd = new WiringDocument(false, null);

        foreach (LLDNBase gnb in this.generators)
        {
            LLDNBase clone = gnb.Clone(thisLookup);
            clone.cachedUILocation = gnb.cachedUILocation;
            wd.generators.Add(clone);
            thisToThatMap.Add(gnb, clone);
        }

        // Convert the connections to point to their own equivalents.
        foreach (LLDNBase gnb in wd.generators)
        {
            foreach (ParamBase pb in gnb.nodeParams)
            {
                if (pb.type == ParamBase.Type.PCMInput)
                {
                    ParamConnection pcon = pb as ParamConnection;
                    if (pcon.IsConnected() == false)
                    {
                        continue;
                    }

                    LLDNBase conv;
                    if (thisToThatMap.TryGetValue(pcon.Reference, out conv) == true)
                    {
                        pcon.SetReference(conv);
                    }
                    else
                    {
                        pcon.ClearReference();
                    }
                }
            }
        }

        // Fix up the output
        if (this.output != null)
        {
            LLDNBase gbOutput = thisToThatMap[this.output];
            if (gbOutput != null && gbOutput.nodeType == LLDNBase.NodeType.Output)
            {
                wd.output = (LLDNOutput)gbOutput;
            }
        }

        // Finish
        if (string.IsNullOrEmpty(newName) == false)
        {
            wd.SetName(newName);
        }
        else
        {
            wd.SetName(this.name);
        }

        return(wd);
    }