Exemple #1
0
        public static List <EXECUTABLE> getExecutables()
        {
            List <EXECUTABLE> exes = new List <EXECUTABLE>();

            string jsonFile = getJsonFilePath();

            if (!File.Exists(jsonFile))
            {
                EXECUTABLE exe = new EXECUTABLE();
                exe.Name    = "Armips";
                exe.Enabled = true;
                exes.Add(exe);
                return(exes);
            }

            JArray jarray = (JArray)JObject.Parse(File.ReadAllText(jsonFile))["executables"];

            foreach (JObject obj in jarray)
            {
                EXECUTABLE exe = new EXECUTABLE();
                if (obj["Name"] != null && obj["Path"] != null &&
                    obj["Arguments"] != null && obj["Enabled"] != null)
                {
                    exe.Name      = obj["Name"].ToString();
                    exe.Path      = obj["Path"].ToString();
                    exe.Arguments = obj["Arguments"].ToString();

                    if (obj["Enabled"].Type == JTokenType.Boolean)
                    {
                        exe.Enabled = (bool)obj["Enabled"];
                    }
                    else
                    {
                        exe.Enabled = bool.Parse(obj["Enabled"].ToString());
                    }
                }

                exes.Add(exe);
            }
            return(exes);
        }
Exemple #2
0
        private bool run_executable(EXECUTABLE exe)
        {
            if (exe.Enabled)
            {
                if (exe.Name.ToUpper().Equals("ARMIPS"))
                {
                    createTempFile("temp.asm", romTextBox.Text);

                    string errorOutput      = "";
                    bool   successfulImport = runArmipsImport("temp.asm", ref errorOutput);

                    if (!successfulImport)
                    {
                        Form2 form2 = new Form2(errorOutput);
                        form2.ShowDialog();
                        return(false);
                    }

                    DeleteTempFile("temp.asm");
                }
                else
                {
                    if (exe.Path.StartsWith("./"))
                    {
                        string replace_with = Directory.GetCurrentDirectory().Replace("\\", "/") + "/";
                        //Console.WriteLine(replace_with);
                        exe.Path = exe.Path.Replace("./", replace_with);
                    }
                    //Console.WriteLine("Running... " + exe.Path);
                    Process proc = new Process();
                    proc.StartInfo.FileName         = "\"" + exe.Path + "\"";
                    proc.StartInfo.Arguments        = parse_exe_arg_variables(exe.Arguments);
                    proc.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory();
                    proc.Start();
                    proc.WaitForExit();
                    proc.Close();
                }
            }
            return(true);
        }
Exemple #3
0
        private EXECUTABLE[] getExecutablesFromBoxes()
        {
            EXECUTABLE[] exe_arr = new EXECUTABLE[panel_boxes.Controls.Count];
            for (int i = 0; i < panel_boxes.Controls.Count; i++)
            {
                EXECUTABLE exe = new EXECUTABLE();
                exe.Name = panel_boxes.Controls[i].Controls[0].Text;
                if (panel_boxes.Controls[i].Controls[0].Tag != null)
                {
                    exe.Path = panel_boxes.Controls[i].Controls[0].Tag.ToString();
                }
                else
                {
                    exe.Path = "";
                }
                exe.Arguments = panel_boxes.Controls[i].Controls[3].Text;
                exe.Enabled   = ((CheckBox)panel_boxes.Controls[i].Controls[6]).Checked;

                exe_arr[i] = exe;
            }
            return(exe_arr);
        }
Exemple #4
0
        private void addExeButton_Click(object sender, System.EventArgs e)
        {
            EXECUTABLE add = new EXECUTABLE();

            OpenFileDialog file = new OpenFileDialog();

            file.Filter = "Executable files (*.exe, *.bat) | *.exe; *.bat |Any files |*";
            if (file.ShowDialog() == DialogResult.OK)
            {
                add.Path = file.FileName.Replace("\\", "/");
                string current_dir = Directory.GetCurrentDirectory().Replace("\\", "/");
                if (add.Path.StartsWith(current_dir))
                {
                    add.Path = add.Path.Replace(current_dir, ".");
                }
                //Console.WriteLine(add.Path);
                add.Arguments = "";
                add.Enabled   = true;
                if (add.Path.LastIndexOf("/") != -1)
                {
                    add.Name = add.Path.Substring(add.Path.LastIndexOf("/") + 1);
                }
                else
                {
                    add.Name = add.Path;
                }
            }
            else
            {
                return;
            }

            int oldSize = panel_boxes.Controls.Count;

            createBox(add, oldSize, oldSize + 1);
            updateBoxesIfMajorChange(oldSize, oldSize + 1);
            UpdateUpDownButtons();
        }
Exemple #5
0
        private void createBox(EXECUTABLE exe, int i, int new_total)
        {
            bool  scrollBarWillShow = (new_total * 60) > panel_boxes.Height;
            Panel newPanel          = new Panel();

            newPanel.BorderStyle = BorderStyle.FixedSingle;
            newPanel.Location    = new Point(1, yPos);
            newPanel.Size        = new Size(panel_boxes.Width - (scrollBarWillShow ? 20 : 2), 60);
            panel_boxes.Controls.Add(newPanel);
            newPanel.Font = new Font("Microsoft Sans Serif", 8, FontStyle.Regular);

            if (!exe.Enabled)
            {
                newPanel.BackColor = Color.LightGray;
            }

            Label nameLabel = new Label();

            nameLabel.Text = exe.Name;
            if (nameLabel.Text.Length > 30)
            {
                nameLabel.Text = nameLabel.Text.Substring(0, 30) + "...";
            }
            nameLabel.Location    = new Point(1, 1);
            nameLabel.BorderStyle = BorderStyle.FixedSingle;
            nameLabel.AutoSize    = true;
            nameLabel.Font        = new Font("Courier New", 14, FontStyle.Bold);
            newPanel.Controls.Add(nameLabel);
            nameLabel.Tag = exe.Path;

            Button editButton = new Button();

            editButton.Text     = "Edit";
            editButton.Location = new Point(nameLabel.Width + 2, 1);
            editButton.Size     = new Size(40, nameLabel.Height);
            editButton.Tag      = i;
            editButton.Click   += EditButton_Click;
            if (nameLabel.Text.ToUpper().Equals("ARMIPS"))
            {
                editButton.Visible = false;
            }
            newPanel.Controls.Add(editButton);

            Label argsLabel = new Label();

            argsLabel.Text     = "Arguments:";
            argsLabel.Location = new Point(1, nameLabel.Height + 10);
            argsLabel.Font     = new Font("Consolas", 9, FontStyle.Bold);
            argsLabel.AutoSize = true;
            if (nameLabel.Text.ToUpper().Equals("ARMIPS"))
            {
                argsLabel.Visible = false;
            }
            newPanel.Controls.Add(argsLabel);

            TextBox argsBox = new TextBox();

            argsBox.Text     = exe.Arguments;
            argsBox.Location = new Point(argsLabel.Width + 2, nameLabel.Height + 8);
            argsBox.Size     = new Size(panel_boxes.Width - 80 - argsBox.Location.X, argsLabel.Height);

            if (nameLabel.Text.ToUpper().Equals("ARMIPS"))
            {
                argsBox.Visible = false;
            }
            newPanel.Controls.Add(argsBox);

            Button moveUp = new Button();

            moveUp.Text     = "▲";
            moveUp.AutoSize = false;
            moveUp.Size     = new Size(20, 20);
            moveUp.Location = new Point(newPanel.Width - 26, 8);
            moveUp.Tag      = i;
            moveUp.Click   += moveEntryUp;
            if (i == 0)
            {
                moveUp.Enabled = false;
            }
            newPanel.Controls.Add(moveUp);

            Button moveDown = new Button();

            moveDown.Text     = "▼";
            moveDown.AutoSize = false;
            moveDown.Size     = new Size(20, 20);
            moveDown.Location = new Point(newPanel.Width - 26, 28);
            moveDown.Tag      = i;
            moveDown.Click   += moveEntryDown;
            if (i == m.executables.Count - 1)
            {
                moveDown.Enabled = false;
            }
            newPanel.Controls.Add(moveDown);

            int cb_xOff = (argsBox.Location.X + argsBox.Width);

            cb_xOff += (moveUp.Location.X - cb_xOff) / 2;
            CheckBox enableExecCB = new CheckBox();

            enableExecCB.Checked         = exe.Enabled;
            enableExecCB.AutoSize        = false;
            enableExecCB.Size            = new Size(13, 20);
            enableExecCB.Location        = new Point(cb_xOff - (enableExecCB.Width / 2), 18);
            enableExecCB.Tag             = i;
            enableExecCB.CheckedChanged += EnableExecCB_CheckedChanged;
            if (nameLabel.Text.ToUpper().Equals("ARMIPS"))
            {
                enableExecCB.Visible = false;
            }
            newPanel.Controls.Add(enableExecCB);

            yPos += newPanel.Height;
        }