public static RunCommandAction Parse(InputCore core, string parseable) { // Command,Arguments,WorkingDirectory,ErrorDialog,WindowStyle,RunOnRelease string[] props = parseable.Split(','); if (props.Length < 6) { throw new FormatException("Invalid property data for action 'Run Command'"); } string cmd = props[0].Replace("%comma;", ","); string args = props[1].Replace("%comma;", ","); string wd = props[2].Replace("%comma;", ","); bool ed = bool.Parse(props[3]); ProcessWindowStyle pws = (ProcessWindowStyle)Enum.Parse(typeof(ProcessWindowStyle), props[4]); bool runOnRelease = bool.Parse(props[5]); var a = new RunCommandAction(core, cmd, args, runOnRelease); a.WorkingDirectory = wd; a.ErrorDialog = ed; a.WindowStyle = pws; a.RunOnRelease = runOnRelease; return(a); }
public MapCommandDialog(PadTieForm main, Controller cc, RunCommandAction editing): this (main, cc) { this.editing = editing; cmd.Text = editing.Command; args.Text = editing.Arguments; onRelease.Checked = editing.RunOnRelease; workDir.Text = editing.WorkingDirectory; if (editing.WindowStyle == ProcessWindowStyle.Normal) startAs.SelectedIndex = 0; else if (editing.WindowStyle == ProcessWindowStyle.Maximized) startAs.SelectedIndex = 1; else if (editing.WindowStyle == ProcessWindowStyle.Minimized) startAs.SelectedIndex = 2; else if (editing.WindowStyle == ProcessWindowStyle.Hidden) startAs.SelectedIndex = 3; showError.Checked = editing.ErrorDialog; slotCapture.SetInput(editing.SlotDescription); }
private void okBtn_Click(object sender, EventArgs e) { if (slotCapture.Value == null) { MessageBox.Show("Please click Capture and press a button or axis direction on the gamepad."); return; } var input = slotCapture.Value; RunCommandAction action; if (editing == null) { action = new RunCommandAction(Controller.Core, cmd.Text, args.Text, onRelease.Checked); } else { action = editing; action.Command = cmd.Text; action.Arguments = args.Text; action.RunOnRelease = onRelease.Checked; if (action.SlotDescription != input) MapUtil.Map(MainForm, Controller.Virtual, action.SlotDescription, null); } action.WorkingDirectory = workDir.Text; action.ErrorDialog = showError.Checked; try { action.WindowStyle = (ProcessWindowStyle)Enum.Parse(typeof(ProcessWindowStyle), startAs.Text); } catch (Exception) { action.WindowStyle = ProcessWindowStyle.Normal; } MapUtil.Map(MainForm, Controller.Virtual, input, action); DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }
public static RunCommandAction Parse(InputCore core, string parseable) { // Command,Arguments,WorkingDirectory,ErrorDialog,WindowStyle,RunOnRelease string[] props = parseable.Split(','); if (props.Length < 6) throw new FormatException("Invalid property data for action 'Run Command'"); string cmd = props[0].Replace("%comma;", ","); string args = props[1].Replace("%comma;", ","); string wd = props[2].Replace("%comma;", ","); bool ed = bool.Parse(props[3]); ProcessWindowStyle pws = (ProcessWindowStyle)Enum.Parse(typeof(ProcessWindowStyle), props[4]); bool runOnRelease = bool.Parse(props[5]); var a = new RunCommandAction(core, cmd, args, runOnRelease); a.WorkingDirectory = wd; a.ErrorDialog = ed; a.WindowStyle = pws; a.RunOnRelease = runOnRelease; return a; }