mirror of
https://github.com/greenshot/greenshot
synced 2025-07-30 11:40:40 -07:00
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:
parent
5780560fbe
commit
cdba70d227
8 changed files with 109 additions and 22 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue