public InternalItem(UserMenuEntry entry) : base() { internalData = entry; Text = internalData.Text; SubItems.Add(internalData.CommandText); }
public void SetEntry(UserMenuEntry entry) { internal_entry = entry; textBoxCommandText.Text = internal_entry.CommandText; textBoxMenuText.Text = internal_entry.Text; checkBoxNoWindow.Checked = (internal_entry.Options & ProcessStartFlags.NoWindow) == ProcessStartFlags.NoWindow; checkBoxUseShellexecute.Checked = (internal_entry.Options & ProcessStartFlags.UseShellexecute) == ProcessStartFlags.UseShellexecute; Text = internal_entry.Text; }
private void new_entry() { var new_entry = new UserMenuEntry(string.Empty, string.Empty); var dialog = new UserMenuEntryEditDialog(); dialog.SetEntry(new_entry); if (dialog.ShowDialog() != DialogResult.OK) { return; } dialog.Apply(); internal_menu.Add(new_entry); listViewInternal.Items.Add(new InternalItem(new_entry)); }
public void Add(UserMenuEntry entry) { ParentMenuItem.MenuItems.Add(entry); entry.Click += new EventHandler(MenuItem_Click); }
private void execute(UserMenuEntry entry) { string command_expanded = entry.CommandText; try { QueryPanelInfoEventArgs e_current = new QueryPanelInfoEventArgs(); QueryPanelInfoEventArgs e_other = new QueryPanelInfoEventArgs(); OnQueryCurrentPanel(e_current); OnQueryOtherPanel(e_other); string repl_text = string.Empty; //process %1 if (command_expanded.Contains("%1")) { repl_text = e_current.ItemCollection.GetCommandlineTextShort(e_current.FocusedIndex); if (repl_text.Contains(" ")) { repl_text = '"' + repl_text + '"'; } command_expanded = command_expanded.Replace("%1", repl_text); } //process %2 if (command_expanded.Contains("%2")) { repl_text = e_current.ItemCollection.GetCommandlineTextLong(e_current.FocusedIndex); if (repl_text.Contains(" ")) { repl_text = '"' + repl_text + '"'; } command_expanded = command_expanded.Replace("%2", repl_text); } //process %3 if (command_expanded.Contains("%3")) { DirectoryList dl = (DirectoryList)e_other.ItemCollection; repl_text = dl.DirectoryPath; if (repl_text.Contains(" ")) { repl_text = '"' + repl_text + '"'; } command_expanded = command_expanded.Replace("%3", repl_text); } string reg_pattern = Options.REGEX_PARSE_COMMAND; Regex rex = new Regex(reg_pattern); string[] splitted = rex.Split(command_expanded, 2); if (splitted.Length < 2) { throw new ApplicationException(Options.GetLiteral(Options.LANG_CANNOT_PARSE_COMMAND_LINE)); } string command_name = splitted[1]; string command_args = splitted.Length > 2 ? splitted[2] : string.Empty; ProcessStartInfo psi = new ProcessStartInfo(); psi.Arguments = command_args; psi.CreateNoWindow = (entry.Options & ProcessStartFlags.NoWindow) == ProcessStartFlags.NoWindow; psi.ErrorDialog = false; psi.FileName = command_name; psi.UseShellExecute = (entry.Options & ProcessStartFlags.UseShellexecute) == ProcessStartFlags.UseShellexecute; psi.WorkingDirectory = Directory.GetCurrentDirectory(); Process p = new Process(); p.StartInfo = psi; p.Start(); } catch (Exception ex) { Messages.ShowException (ex, string.Format (Options.GetLiteral(Options.LANG_CANNOT_EXECUTE_0), command_expanded)); } }