コード例 #1
0
        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();
        }
コード例 #2
0
        private void addAssetMenuItem_Click(object sender, EventArgs e)
        {
            // Get asset name from dialog
            TextboxDialog dialog = new TextboxDialog("Create new asset", "New asset name");

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

            // Create new asset element with given name
            AssetElement ae = new AssetElement();

            ae.Name = dialog.StringValue;

            // Add asset to selected model
            TreeNode       modelNode = mainTreeView.SelectedNode;
            ModelComponent model     = ((ModelForm)mainTreeView.SelectedNode.Tag).Model;

            model.Assets.Add(ae);

            // Refresh to add node
            UpdateModelNode(model, modelNode.Parent);
            TreeNode newNode = getNodeFromElement(ae);

            mainTreeView.SelectedNode = newNode;
            PicassoSubform newForm = (PicassoSubform)newNode.Tag;

            newForm.Show();
        }
コード例 #3
0
        public static void SaveFileGameObject(String _fileExt, String _folderName, E _obj)
        {
            using (TextboxDialog fDialog = new TextboxDialog($"Save {_fileExt}:"))
            {
                DialogResult dg = fDialog.ShowDialog();
                if (dg == DialogResult.OK)
                {
                    String fileName         = fDialog.GetField();
                    String currentDirectory = $@"{Directory.GetCurrentDirectory()}\Content\{_folderName}\";
                    if (!Directory.Exists(currentDirectory))
                    {
                        Directory.CreateDirectory(currentDirectory);
                    }
                    String filePath = currentDirectory + fileName + _fileExt;

                    File.WriteAllText(filePath, SerializeObject(_obj));
                }
            }
        }
コード例 #4
0
        public void CreateNewScenario()
        {
            // Create a new scenario with the name entered in a textbox dialog
            TextboxDialog dialog = new TextboxDialog("Create new scenario", "New scenario name");

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

            // Create new scenario form with given name
            ScenarioForm newScenario = new ScenarioForm(this);

            newScenario.Scenario.ScenarioName = dialog.StringValue;

            // Add new scenario to scenario list and tree view
            _scenarios.Add(newScenario);
            UpdateScenarioNode(newScenario);
            _activeScenario = newScenario.Scenario;
        }
コード例 #5
0
        private void addNodeButton_Click(object sender, EventArgs e)
        {
            // Check for location
            TreeNode currentNode = subsystemTreeView.SelectedNode;

            if (currentNode == SubsystemNode)
            {
                // Do nothing to add to head node
                return;
            }
            if (currentNode.Parent != SubsystemNode)
            {
                // Shift to right level
                currentNode = currentNode.Parent;
            }
            if (currentNode.Text == "Scripted Functions")
            {
                // Create new function with name from textbox dialog
                ScriptedFunction newFunction = new ScriptedFunction();
                TextboxDialog    dialog      = new TextboxDialog("Create new function", "New function name");
                dialog.ShowDialog();
                if (dialog.Cancelled)
                {
                    return;
                }
                newFunction.Name = dialog.StringValue;

                // Add function node
                TreeNode newNode = new TreeNode(newFunction.Name + "()");
                newNode.Tag = newFunction;
                currentNode.Nodes.Add(newNode);
                currentNode.Expand();

                // Add function text at bottom, set cursor position to function parameters
                string header = "function " + newFunction.Name + "()";
                scriptingEditor.InsertLine("", -1);
                scriptingEditor.InsertLine(header, -1);
                scriptingEditor.InsertLine("end", -1);
                scriptingEditor.Focus();
                int focusCol = header.Length - 1;
                int focusRow = scriptingEditor.Lines.Length - 2;
                scriptingEditor.CursorPosition = new Point(focusCol, focusRow);

                // Add function to subsystem script
                Script.Functions.Add(newFunction);
            }
            if (currentNode.Text == "State Variables")
            {
                // Create new variable with name from textbox dialog
                StateVariable newVar = new StateVariable();
                TextboxDialog dialog = new TextboxDialog("Create new state variable", "New variable name");
                dialog.ShowDialog();
                if (dialog.Cancelled)
                {
                    return;
                }
                newVar.Name = dialog.StringValue;

                // Add variable node
                TreeNode newNode = new TreeNode(newVar.Name);
                newNode.Tag = newVar;
                currentNode.Nodes.Add(newNode);
                currentNode.Expand();

                // Add variable to global symbols
                ScriptingSymbol varSymb = new ScriptingSymbol();
                varSymb.Enabled = true;
                varSymb.Name    = newVar.Name;
                varSymb.Type    = LuaSymbolType.Global;
                scriptingEditor.ScriptingSymbolListbox.Symbols.Add(varSymb);
                scriptingEditor.ScriptingSymbolListbox.SortSymbols();

                // Add function to subsystem script
                Script.States.Add(newVar);
            }
            if (currentNode.Text == "Subsystem Parameters")
            {
                // Create new parameter with name from textbox dialog
                SubsystemParameter newParam = new SubsystemParameter();
                TextboxDialog      dialog   = new TextboxDialog("Create new parameter", "New parameter name");
                dialog.ShowDialog();
                if (dialog.Cancelled)
                {
                    return;
                }
                newParam.Name = dialog.StringValue;

                // Add parameter node
                TreeNode newNode = new TreeNode(newParam.Name);
                newNode.Tag = newParam;
                currentNode.Nodes.Add(newNode);
                currentNode.Expand();

                // Add parameter to global symbols
                ScriptingSymbol varSymb = new ScriptingSymbol();
                varSymb.Enabled = true;
                varSymb.Name    = newParam.Name;
                varSymb.Type    = LuaSymbolType.Global;
                scriptingEditor.ScriptingSymbolListbox.Symbols.Add(varSymb);
                scriptingEditor.ScriptingSymbolListbox.SortSymbols();

                // Add parameter to subsystem script
                Script.Parameters.Add(newParam);
            }
        }