Form Instance


Node Information
Creates an instance of the specified Form.
General Information
• This node has other options, you can view them by clicking on the info button, this also means according to the node you might be able to add more ports than what is already listed.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Instance OUT Form MULTIPLE FALSE FALSE
New IN RUN MULTIPLE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.UI.Form
{
    [IsNode("Form Instance")]
    public class FormInstance : Node
    {
        Port frminstance = new Port(PortType.OUT, typeof(System.Windows.Forms.Form), AcceptsLinks.MULTIPLE, "Instance");
        Port newinstance = new Port(PortType.IN, typeof(RUN), AcceptsLinks.MULTIPLE, "New");
        Variable var1 = new Variable(string.Empty, string.Empty);
        [System.ComponentModel.TypeConverter(typeof(FormsToList))]
        public string FormName
        {
            set { frminstance.Value = value; }
            get { return frminstance.Value; }
        }
        public FormInstance()
        {
            this.Name = "Form Instance";
            FormName = "(None)";
            AddPort(frminstance);
            AddPort(newinstance);
            Variables.Add(var1);
            OptionsAvilable = true;
            frminstance.Instructions = "init";
            Information = "Creates an instance of the specified Form.";
        }
        public override void UpdateResults()
        {
            if (!string.IsNullOrWhiteSpace(FormName) && FormName != "(None)")
            {
                InfoContextMenu = GraphCore.NodeFunctions.GlobalReferencesMenu(FormName, this);
            }
            else
            {
                InfoContextMenu = null;
            }
            newinstance.Instructions = frminstance.ID + " = new " + FormName + "();";
            frminstance.Instructions = frminstance.ID;
            if (FormName != "(None)")
            {
                var1.Name = frminstance.ID;
                var1.VariableType = FormName;
                var1.Initialize = " new " + FormName + "()";
            }
            else
            {
                var1.Name = frminstance.ID;
                var1.VariableType = "Type";
                var1.Initialize = "null";
            }
            ReferenceName = frminstance.ID;
        }
        public override void OnReferenceSelected(Project.ReferenceEntry entry)
        {
            if (entry.ReferenceType == Project.ReferenceType.Variable)
            {
                Port port = new Port(PortType.OUT, entry.Type, AcceptsLinks.MULTIPLE, entry.Name, true);
                port.Instructions = frminstance.ID + "." + entry.Name;
                port.IsRemovable = true;
                AddPort(port);
            }
            else if (entry.ReferenceType == Project.ReferenceType.Function)
            {
                Port port = new Port(PortType.OUT, entry.Type, AcceptsLinks.MULTIPLE, entry.Name, true);
                port.Instructions = frminstance.ID + "." + entry.Name + "()";
                port.IsRemovable = true;
                AddPort(port);
            }
            else if (entry.ReferenceType == Project.ReferenceType.Method)
            {
                Port port = new Port(PortType.IN, entry.Type, AcceptsLinks.MULTIPLE, entry.Name, true);
                port.Instructions = frminstance.ID + "." + entry.Name + "();";
                port.IsRemovable = true;
                AddPort(port);
            }
            else if (entry.ReferenceType == Project.ReferenceType.ObjectReference)
            {
                Port port = new Port(PortType.OUT, entry.Type, AcceptsLinks.MULTIPLE, entry.Name, true);
                port.Instructions = frminstance.ID + "." + entry.Name;
                port.IsRemovable = true;
                AddPort(port);
            }
        }
    }
}