private void HandleInvokeCombo(object sender, EventArgs e) { OleMenuCmdEventArgs oleEventArgs = e as OleMenuCmdEventArgs; if (oleEventArgs == null) { throw new ArgumentException("EventArgs required."); } string newChoice = oleEventArgs.InValue as string; if (newChoice != null) { bool acceptNewChoice = true; if (newChoice == CommandLineEditorName) { //Show editor CommandLineEditor editorDialog = new CommandLineEditor(RecentCommandLines); editorDialog.Location = System.Windows.Forms.Cursor.Position; if (editorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { RecentCommandLines = editorDialog.getCommandLines(); if (RecentCommandLines.Count <= 0) { newChoice = ""; } else { newChoice = RecentCommandLines[0]; } } else { acceptNewChoice = false; } } if (acceptNewChoice) { SetStartupCommandArguments(newChoice); SetMostRecentString(newChoice); } } if (oleEventArgs.OutValue != IntPtr.Zero) { string commandArguments = TryGetStartupCommandArguments(); SetMostRecentString(commandArguments); Marshal.GetNativeVariantForObject(commandArguments, oleEventArgs.OutValue); return; } }
private void HandleInvokeCombo(object sender, EventArgs e) { OleMenuCmdEventArgs oleEventArgs = e as OleMenuCmdEventArgs; if (oleEventArgs == null) throw new ArgumentException("EventArgs required."); string newChoice = oleEventArgs.InValue as string; if (newChoice != null) { bool acceptNewChoice = true; if(newChoice == CommandLineEditorName) { //Show editor CommandLineEditor editorDialog = new CommandLineEditor(RecentCommandLines); editorDialog.Location = System.Windows.Forms.Cursor.Position; if(editorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { RecentCommandLines = editorDialog.getCommandLines(); if (RecentCommandLines.Count <= 0) { newChoice = ""; } else { newChoice = RecentCommandLines[0]; } } else { acceptNewChoice = false; } } if (acceptNewChoice) { SetStartupCommandArguments(newChoice); SetMostRecentString(newChoice); } } if (oleEventArgs.OutValue != IntPtr.Zero) { string commandArguments = TryGetStartupCommandArguments(); SetMostRecentString(commandArguments); Marshal.GetNativeVariantForObject(commandArguments, oleEventArgs.OutValue); return; } }