Example #1
0
        private void LoadCommands()
        {
            string[] paths = Directory.GetFiles(_commandsDirectoryPath);
            string   cmdId;
            string   cmdName;
            string   cmdDescription;
            CustomCommandUIWrapper cmd;
            List <string>          cmdLines;

            for (int i = 0; i < paths.Length; ++i)
            {
                if (!paths[i].EndsWith(".arts"))
                {
                    continue;
                }
                cmdLines = new List <string>();
                string[] commandLineContents = File.ReadAllLines(paths[i]);
                cmdId          = "0" + (300001 + i).ToString();
                cmdName        = commandLineContents[1];
                cmdDescription = commandLineContents[2];
                for (int j = 3; j < commandLineContents.Length; ++j)
                {
                    cmdLines.Add(commandLineContents[j]);
                }

                Button UIButton = new Button();
                UIButton.Size   = new Size(150, 50);
                UIButton.Text   = cmdName;
                UIButton.Click += SelectButton;
                commandsPanel.Controls.Add(UIButton);
                cmd = new CustomCommandUIWrapper(new CustomCommand(cmdId, cmdName, cmdDescription, cmdLines), UIButton, paths[i]);
                _customCommands.Add(cmd);
            }
        }
Example #2
0
 private void DeleteCommandButton_Click(object sender, EventArgs e)
 {
     commandsPanel.Controls.Remove(_selectedCommand.UIbutton);
     _selectedCommand.command.name = "----";
     _selectedCommand.FlagForDeletion();
     _selectedCommand = _customCommands.First();
     UpdateSelectedCommand();
 }
Example #3
0
        private void SelectButton(object sender, EventArgs e) /// this gets confused when you have 2 commands of the same name.
        {
            string clickedCommandName = ((Button)sender).Text;

            QuickSave();
            foreach (CustomCommandUIWrapper cmd in _customCommands)
            {
                if (cmd.command.name == clickedCommandName && !cmd.FlaggedForDeletion)
                {
                    _selectedCommand = cmd;
                }
            }
            UpdateSelectedCommand();
        }
Example #4
0
        private void NewCommandButton_Click(object sender, EventArgs e)
        {
            Button UIButton = new Button();

            UIButton.Size   = new Size(150, 50);
            UIButton.Text   = "New Command";
            UIButton.Click += SelectButton;
            commandsPanel.Controls.Add(UIButton);
            CustomCommandUIWrapper cmd = new CustomCommandUIWrapper(new CustomCommand("0" + (300001 + _customCommands.Count), "New Command", "", new List <string>()), UIButton, "");

            _customCommands.Add(cmd);
            _selectedCommand = cmd;
            cmd.FlagForAddition();
            UpdateSelectedCommand();
        }
Example #5
0
 private void CustomCommandPanel_Load(object sender, EventArgs e)
 {
     _commandsDirectoryPath = Path.Combine(Directory.GetCurrentDirectory(), "CustomCommands");
     _emptyCommand          = new CustomCommandUIWrapper(new CustomCommand("", "", "", new List <string>()), new Button(), "");
     LoadCommands();
     if (_customCommands.Count > 0)
     {
         _selectedCommand = _customCommands.First();
     }
     else
     {
         _selectedCommand = _emptyCommand;
     }
     UpdateSelectedCommand();
     FormClosed += SaveCommandButton_Click;
 }
Example #6
0
        private void UpdateSelectedCommand()
        {
            if (_selectedCommand == null)
            {
                _selectedCommand = _emptyCommand;
            }

            commandName.Text        = _selectedCommand.command.name;
            commandDescription.Text = _selectedCommand.command.description;
            commandCodeLines.Clear();
            if (_selectedCommand.command.instructionLines.Count > 0)
            {
                commandCodeLines.AppendText(_selectedCommand.command.instructionLines.First());
            }

            for (int i = 1; i < _selectedCommand.command.instructionLines.Count; ++i)
            {
                commandCodeLines.AppendText(Environment.NewLine + _selectedCommand.command.instructionLines[i]);
            }
        }