Added icons to the external commands editor & added a check for the OK button

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1746 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-04-04 12:09:33 +00:00
parent 5780560fbe
commit cdba70d227
8 changed files with 109 additions and 22 deletions

View file

@ -72,8 +72,19 @@ namespace ExternalCommand {
void UpdateView() {
listView1.Items.Clear();
if (config.commands != null) {
foreach(string commando in config.commands) {
ListViewItem item = new ListViewItem(commando);
listView1.ListViewItemSorter = new ListviewComparer();
ImageList imageList = new ImageList();
listView1.SmallImageList = imageList;
int imageNr = 0;
foreach (string commando in config.commands) {
ListViewItem item = null;
Image iconForExe = IconCache.IconForExe(commando);
if (iconForExe != null) {
imageList.Images.Add(iconForExe);
item = new ListViewItem(commando, imageNr++);
} else {
item = new ListViewItem(commando);
}
item.Tag = commando;
listView1.Items.Add(item);
}
@ -99,4 +110,21 @@ namespace ExternalCommand {
UpdateView();
}
}
public class ListviewComparer : System.Collections.IComparer {
public int Compare(object x, object y) {
if (!(x is ListViewItem)) {
return (0);
}
if (!(y is ListViewItem)) {
return (0);
}
ListViewItem l1 = (ListViewItem)x;
ListViewItem l2 = (ListViewItem)y;
if (l2 == null) {
return 1;
}
return l1.Text.CompareTo(l2.Text);
}
}
}