Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced DropDownComboBox with MRUComboBox #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Tvl.DebugCommandLine/DebugCommandLine.vsct
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<Commands package="guidDebugCommandLinePackage">
<Combos>
<Combo guid="guidDebugCommandLineCommandSet" id="cmdidDebugCommandLineCombo" priority="0x0000" type="DropDownCombo" defaultWidth="135" idCommandList="cmdidDebugCommandLineComboGetList">
<Combo guid="guidDebugCommandLineCommandSet" id="cmdidDebugCommandLineCombo" priority="0x0000" type="MRUCombo" defaultWidth="135" idCommandList="cmdidDebugCommandLineComboGetList">
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<CommandFlag>CommandWellOnly</CommandFlag>
Expand Down
74 changes: 69 additions & 5 deletions Tvl.DebugCommandLine/DebugCommandLinePackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,25 @@ protected override void Initialize()
if (menuCommandService != null)
{
// This is the drop down combo box itself
/*
CommandID comboBoxCommandID = new DebugCommandLineCommandID(DebugCommandLineCommand.DebugCommandLineCombo);
OleMenuCommand comboBoxCommand = new OleMenuCommand(HandleInvokeCombo, HandleChangeCombo, HandleBeforeQueryStatusCombo, comboBoxCommandID);
menuCommandService.AddCommand(comboBoxCommand);
menuCommandService.AddCommand(comboBoxCommand);*/

// This is the special command to get the list of drop down items
CommandID comboBoxGetListCommandID = new DebugCommandLineCommandID(DebugCommandLineCommand.DebugCommandLineComboGetList);
/*CommandID comboBoxGetListCommandID = new DebugCommandLineCommandID(DebugCommandLineCommand.DebugCommandLineComboGetList);
OleMenuCommand comboBoxGetListCommand = new OleMenuCommand(HandleInvokeComboGetList, comboBoxGetListCommandID);
menuCommandService.AddCommand(comboBoxGetListCommand);
menuCommandService.AddCommand(comboBoxGetListCommand);*/

// This MRU combo box contains an editable text-field and a drop down menu which is saved on an application and user basis
CommandID comboBoxCommandID = new DebugCommandLineCommandID(DebugCommandLineCommand.DebugCommandLineCombo);
OleMenuCommand comboBoxCommand = new OleMenuCommand(new EventHandler(HandleOnMRUCombo), comboBoxCommandID);
menuCommandService.AddCommand(comboBoxCommand);
}

var shellSettingsManager = new ShellSettingsManager(this);
/*var shellSettingsManager = new ShellSettingsManager(this);
SettingsStore = shellSettingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
LoadSettings();
LoadSettings();*/
}

private void LoadSettings()
Expand Down Expand Up @@ -101,6 +107,64 @@ private void HandleInvokeCombo(object sender, EventArgs e)
}
}

private string currentMRUComboChoice = null;

private void HandleOnMRUCombo(object sender, EventArgs e)
{
if (e == EventArgs.Empty)
{
// We should never get here; EventArgs are required.
throw new ArgumentException("EventArgs required."); // force an exception to be thrown
}

OleMenuCmdEventArgs eventArgs = e as OleMenuCmdEventArgs;

if (eventArgs != null)
{
object input = eventArgs.InValue;
IntPtr vOut = eventArgs.OutValue;

if (vOut != IntPtr.Zero && input != null)
{
throw new ArgumentException("BothInOutParamsIllegal"); // force an exception to be thrown
}
else if (vOut != IntPtr.Zero)
{
// when vOut is non-NULL, the IDE is requesting the current value for the combo
string commandArguments = TryGetStartupCommandArguments();
Marshal.GetNativeVariantForObject(commandArguments, vOut);
}

else if (input != null)
{
string newChoice = input.ToString();

// new value was selected or typed in
if (!string.IsNullOrEmpty(newChoice))
{
currentMRUComboChoice = newChoice;
SetStartupCommandArguments(newChoice);

//ShowMessage(Resources.MyMRUCombo, currentMRUComboChoice);
}
else
{
// We should never get here
throw new ArgumentException("EmptyStringIllegal"); // force an exception to be thrown
}
}
else
{
throw new ArgumentException("BothInOutParamsIllegal"); // force an exception to be thrown
}
}
else
{
// We should never get here; EventArgs are required.
throw new ArgumentException("EventArgs required."); // force an exception to be thrown
}
}

private void HandleChangeCombo(object sender, EventArgs e)
{
}
Expand Down