Skip to content

Commit

Permalink
Changed context menu sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
aalbng committed Dec 13, 2016
1 parent 6347870 commit 8a787ff
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions AdvancedConnectPlugin/GUI/ContextMenuExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,11 @@ private void entryContextMenu_Opened(object sender, EventArgs e)
//Define menuItem var
ToolStripMenuItem menuItem = null;

//Add seperator to list
menuItemList.Add(new ToolStripSeparator());

//Load connection methods into array (splitted by new line)
String[] methodArr = Tools.StringCustom.splitByNewLine(selectedEntries[0].Strings.ReadSafe(this.plugin.settings.connectionMethodField));

//Add a menuItem for each connection method and each programm with this connection method
//Add a menuItem for each connection method and each programm with this connection method
Array.Sort<String>(methodArr);
foreach (var method in methodArr)
{
//Add Builtin RDP support entries
Expand All @@ -76,7 +74,7 @@ private void entryContextMenu_Opened(object sender, EventArgs e)
//Add Custom applications (loop)
foreach (var application in this.plugin.settings.applicationsBindingList)
{
if(method == application.method)
if (method == application.method)
{
menuItem = new ToolStripMenuItem();
menuItem.Text = application.name;
Expand All @@ -86,15 +84,19 @@ private void entryContextMenu_Opened(object sender, EventArgs e)
menuItemList.Add(menuItem);
}
}

}


//Insert all items to the top of the context menu (Item order will be reversed)
foreach (var item in menuItemList)

//Add seperator to list
menuItemList.Add(new ToolStripSeparator());


//Insert all items to the top of the context menu (reverse order)
for (int i = menuItemList.Count - 1; i >= 0; i--)
{
this.entryContextMenu.Items.Insert(0, item);
this.entryContextMenu.Items.Insert(0, menuItemList[i]);
}

}
}

Expand Down

0 comments on commit 8a787ff

Please sign in to comment.