private void DrawingCanvas_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            // If drawing canvas intercepts double-click, nothing exists here; create a new subsystem
            // Ask for subsystem name
            TextboxDialog dialog = new TextboxDialog("Create new subsystem", "New subsystem name");

            dialog.ShowDialog();
            if (dialog.Cancelled)
            {
                return;
            }

            // Create new element
            SubsystemElement newSubsystem = new SubsystemElement();

            newSubsystem.Name = dialog.StringValue;

            // Create new icon
            SubsystemIcon newIcon = new SubsystemIcon();

            newIcon.MouseDown += new MouseEventHandler(SubsystemClicked);
            newIcon.MouseMove += new MouseEventHandler(newIcon_MouseMove);
            newIcon.subsystem  = newSubsystem;
            newIcon.Location   = new Point(e.X, e.Y);
            newIcon.Parent     = this;
            SubsystemIcons.Add(newIcon);
            RefreshConnections();
        }
 public SubsystemForm(SubsystemElement subsystem, Form parentForm, TreeNode node)
 {
     MdiParent      = parentForm;
     node.Tag       = this;
     this.Subsystem = subsystem;
     Script         = new SubsystemScript();
     InitializeComponent();
     RefreshValues();
 }
Example #3
0
        public void LoadFromElements(SubsystemElement element)
        {
            // Refreshes subsystem information from element
            Name = element.Name;
            _id  = element.Id;

            States.Clear();
            foreach (IcElement ic in element.Ics)
            {
                StateVariable newVariable = new StateVariable();
                newVariable.Type  = ic.Type;
                newVariable.Key   = ic.Key;
                newVariable.Value = ic.Value;
            }

            Parameters.Clear();
            foreach (object key in element.Attributes.Keys)
            {
                SubsystemParameter newParam = new SubsystemParameter();
                newParam.Name  = key.ToString();
                newParam.Value = element.Attributes[key].ToString();
            }

            Functions.Clear();
            ScriptedFunction canPerform = new ScriptedFunction();

            canPerform.Name       = element.CanPerformLuaFcn;
            canPerform.IsRequired = true;
            Functions.Add(canPerform);
            ScriptedFunction canExtend = new ScriptedFunction();

            canExtend.Name       = element.CanExtendLuaFcn;
            canExtend.IsRequired = true;
            Functions.Add(canExtend);
            ScriptedFunction init = new ScriptedFunction();

            init.Name       = element.InitLuaFcn;
            init.IsRequired = true;
            Functions.Add(init);
        }