Changed the destination-selection to a listview with icons and checkboxes.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1736 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-04-01 17:38:40 +00:00
parent 20ab020ae2
commit 1422bcb680
3 changed files with 122 additions and 57 deletions

View file

@ -70,7 +70,9 @@ namespace Greenshot {
this.textBoxJpegQuality = new System.Windows.Forms.TextBox(); this.textBoxJpegQuality = new System.Windows.Forms.TextBox();
this.trackBarJpegQuality = new System.Windows.Forms.TrackBar(); this.trackBarJpegQuality = new System.Windows.Forms.TrackBar();
this.groupbox_destination = new System.Windows.Forms.GroupBox(); this.groupbox_destination = new System.Windows.Forms.GroupBox();
this.checkedDestinationsListBox = new System.Windows.Forms.CheckedListBox(); this.checkbox_picker = new System.Windows.Forms.CheckBox();
this.destinationsListView = new System.Windows.Forms.ListView();
this.destination = new System.Windows.Forms.ColumnHeader();
this.tabcontrol = new System.Windows.Forms.TabControl(); this.tabcontrol = new System.Windows.Forms.TabControl();
this.tab_general = new System.Windows.Forms.TabPage(); this.tab_general = new System.Windows.Forms.TabPage();
this.groupbox_network = new System.Windows.Forms.GroupBox(); this.groupbox_network = new System.Windows.Forms.GroupBox();
@ -118,7 +120,6 @@ namespace Greenshot {
this.groupbox_plugins = new System.Windows.Forms.GroupBox(); this.groupbox_plugins = new System.Windows.Forms.GroupBox();
this.listview_plugins = new System.Windows.Forms.ListView(); this.listview_plugins = new System.Windows.Forms.ListView();
this.button_pluginconfigure = new System.Windows.Forms.Button(); this.button_pluginconfigure = new System.Windows.Forms.Button();
this.checkbox_picker = new System.Windows.Forms.CheckBox();
this.groupbox_preferredfilesettings.SuspendLayout(); this.groupbox_preferredfilesettings.SuspendLayout();
this.groupbox_applicationsettings.SuspendLayout(); this.groupbox_applicationsettings.SuspendLayout();
this.groupbox_jpegsettings.SuspendLayout(); this.groupbox_jpegsettings.SuspendLayout();
@ -349,23 +350,46 @@ namespace Greenshot {
// groupbox_destination // groupbox_destination
// //
this.groupbox_destination.Controls.Add(this.checkbox_picker); this.groupbox_destination.Controls.Add(this.checkbox_picker);
this.groupbox_destination.Controls.Add(this.checkedDestinationsListBox); this.groupbox_destination.Controls.Add(this.destinationsListView);
this.groupbox_destination.Location = new System.Drawing.Point(2, 6); this.groupbox_destination.Location = new System.Drawing.Point(2, 6);
this.groupbox_destination.Name = "groupbox_destination"; this.groupbox_destination.Name = "groupbox_destination";
this.groupbox_destination.Size = new System.Drawing.Size(412, 294); this.groupbox_destination.Size = new System.Drawing.Size(412, 311);
this.groupbox_destination.TabIndex = 16; this.groupbox_destination.TabIndex = 16;
this.groupbox_destination.TabStop = false; this.groupbox_destination.TabStop = false;
this.groupbox_destination.Text = "Screenshot Destination"; this.groupbox_destination.Text = "Screenshot Destination";
// //
// checkedDestinationsListBox // checkbox_picker
// //
this.checkedDestinationsListBox.FormattingEnabled = true; this.checkbox_picker.Location = new System.Drawing.Point(6, 14);
this.checkedDestinationsListBox.Location = new System.Drawing.Point(5, 50); this.checkbox_picker.Name = "checkbox_picker";
this.checkedDestinationsListBox.Name = "checkedDestinationsListBox"; this.checkbox_picker.Size = new System.Drawing.Size(394, 24);
this.checkedDestinationsListBox.ScrollAlwaysVisible = true; this.checkbox_picker.TabIndex = 19;
this.checkedDestinationsListBox.Size = new System.Drawing.Size(401, 244); this.checkbox_picker.Text = "Destination picker";
this.checkedDestinationsListBox.TabIndex = 0; this.checkbox_picker.UseVisualStyleBackColor = true;
this.checkedDestinationsListBox.SelectedValueChanged += new System.EventHandler(this.DestinationsCheckStateChanged); this.checkbox_picker.CheckStateChanged += new System.EventHandler(this.DestinationsCheckStateChanged);
//
// destinationsListView
//
this.destinationsListView.Alignment = System.Windows.Forms.ListViewAlignment.Left;
this.destinationsListView.AutoArrange = false;
this.destinationsListView.CheckBoxes = true;
this.destinationsListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.destination});
this.destinationsListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.destinationsListView.LabelWrap = false;
this.destinationsListView.Location = new System.Drawing.Point(6, 38);
this.destinationsListView.Name = "destinationsListView";
this.destinationsListView.ShowGroups = false;
this.destinationsListView.Size = new System.Drawing.Size(401, 267);
this.destinationsListView.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.destinationsListView.TabIndex = 0;
this.destinationsListView.UseCompatibleStateImageBehavior = false;
this.destinationsListView.View = System.Windows.Forms.View.Details;
//
// destination
//
this.destination.Text = "Destination";
this.destination.Width = 380;
// //
// tabcontrol // tabcontrol
// //
@ -882,16 +906,6 @@ namespace Greenshot {
this.button_pluginconfigure.UseVisualStyleBackColor = true; this.button_pluginconfigure.UseVisualStyleBackColor = true;
this.button_pluginconfigure.Click += new System.EventHandler(this.Button_pluginconfigureClick); this.button_pluginconfigure.Click += new System.EventHandler(this.Button_pluginconfigureClick);
// //
// checkbox_picker
//
this.checkbox_picker.Location = new System.Drawing.Point(6, 19);
this.checkbox_picker.Name = "checkbox_picker";
this.checkbox_picker.Size = new System.Drawing.Size(394, 24);
this.checkbox_picker.TabIndex = 19;
this.checkbox_picker.Text = "Destination picker";
this.checkbox_picker.UseVisualStyleBackColor = true;
this.checkbox_picker.CheckStateChanged += new System.EventHandler(this.DestinationsCheckStateChanged);
//
// SettingsForm // SettingsForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
@ -935,8 +949,9 @@ namespace Greenshot {
this.groupbox_plugins.PerformLayout(); this.groupbox_plugins.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
private System.Windows.Forms.ColumnHeader destination;
private System.Windows.Forms.CheckBox checkbox_picker; private System.Windows.Forms.CheckBox checkbox_picker;
private System.Windows.Forms.CheckedListBox checkedDestinationsListBox; private System.Windows.Forms.ListView destinationsListView;
private System.Windows.Forms.GroupBox groupbox_editor; private System.Windows.Forms.GroupBox groupbox_editor;
private System.Windows.Forms.CheckBox checkbox_editor_match_capture_size; private System.Windows.Forms.CheckBox checkbox_editor_match_capture_size;
private System.Windows.Forms.NumericUpDown numericUpDown_daysbetweencheck; private System.Windows.Forms.NumericUpDown numericUpDown_daysbetweencheck;

View file

@ -279,13 +279,37 @@ namespace Greenshot {
checkbox_playsound.Checked = coreConfiguration.PlayCameraSound; checkbox_playsound.Checked = coreConfiguration.PlayCameraSound;
checkbox_picker.Checked = false; checkbox_picker.Checked = false;
checkedDestinationsListBox.Items.Clear();
destinationsListView.Items.Clear();
destinationsListView.ListViewItemSorter = new ListviewWithDestinationComparer();
ImageList imageList = new ImageList();
destinationsListView.SmallImageList = imageList;
int imageNr = -1;
foreach(IDestination destination in DestinationHelper.GetAllDestinations()) { foreach(IDestination destination in DestinationHelper.GetAllDestinations()) {
Image destinationImage = destination.DisplayIcon;
if (destinationImage != null) {
imageList.Images.Add(destination.DisplayIcon);
imageNr++;
}
if (PickerDestination.DESIGNATION.Equals(destination.Designation)) { if (PickerDestination.DESIGNATION.Equals(destination.Designation)) {
checkbox_picker.Checked = true; checkbox_picker.Checked = true;
checkbox_picker.Text = destination.Description; checkbox_picker.Text = destination.Description;
} else { } else {
checkedDestinationsListBox.Items.Add(destination, coreConfiguration.OutputDestinations.Contains(destination.Designation)); ListViewItem item;
if (destinationImage != null) {
item = destinationsListView.Items.Add(destination.Description, imageNr);
} else {
item = destinationsListView.Items.Add(destination.Description);
}
item.Tag = destination;
item.Checked = coreConfiguration.OutputDestinations.Contains(destination.Designation);
}
}
if (checkbox_picker.Checked) {
destinationsListView.Enabled = false;
foreach(int index in destinationsListView.CheckedIndices) {
ListViewItem item = destinationsListView.Items[index];
item.Checked = false;
} }
} }
// checkbox_clipboard.Checked = coreConfiguration.OutputDestinations.Contains("Clipboard"); // checkbox_clipboard.Checked = coreConfiguration.OutputDestinations.Contains("Clipboard");
@ -352,9 +376,11 @@ namespace Greenshot {
if (checkbox_picker.Checked) { if (checkbox_picker.Checked) {
destinations.Add(PickerDestination.DESIGNATION); destinations.Add(PickerDestination.DESIGNATION);
} }
foreach(int index in checkedDestinationsListBox.CheckedIndices) { foreach(int index in destinationsListView.CheckedIndices) {
IDestination destination = (IDestination)checkedDestinationsListBox.Items[index]; ListViewItem item = destinationsListView.Items[index];
if (checkedDestinationsListBox.GetItemCheckState(index) == CheckState.Checked) {
IDestination destination = item.Tag as IDestination;
if (item.Checked) {
destinations.Add(destination.Designation); destinations.Add(destination.Designation);
} }
} }
@ -499,8 +525,11 @@ namespace Greenshot {
void CheckDestinationSettings() { void CheckDestinationSettings() {
bool clipboardDestinationChecked = false; bool clipboardDestinationChecked = false;
bool pickerSelected = checkbox_picker.Checked; bool pickerSelected = checkbox_picker.Checked;
destinationsListView.Enabled = true;
foreach(IDestination destination in checkedDestinationsListBox.CheckedItems) { foreach(int index in destinationsListView.CheckedIndices) {
ListViewItem item = destinationsListView.Items[index];
IDestination destination = item.Tag as IDestination;
if (destination.Designation.Equals(ClipboardDestination.DESIGNATION)) { if (destination.Designation.Equals(ClipboardDestination.DESIGNATION)) {
clipboardDestinationChecked = true; clipboardDestinationChecked = true;
break; break;
@ -508,16 +537,12 @@ namespace Greenshot {
} }
if (pickerSelected) { if (pickerSelected) {
foreach(int index in checkedDestinationsListBox.CheckedIndices) { destinationsListView.Enabled = false;
IDestination destination = (IDestination)checkedDestinationsListBox.Items[index]; foreach(int index in destinationsListView.CheckedIndices) {
checkedDestinationsListBox.SetItemCheckState(index, CheckState.Indeterminate); ListViewItem item = destinationsListView.Items[index];
item.Checked = false;
} }
} else { } else {
foreach(int index in checkedDestinationsListBox.CheckedIndices) {
if (checkedDestinationsListBox.GetItemCheckState(index) == CheckState.Indeterminate) {
checkedDestinationsListBox.SetItemCheckState(index, CheckState.Checked);
}
}
// Prevent multiple clipboard settings at once, see bug #3435056 // Prevent multiple clipboard settings at once, see bug #3435056
if (clipboardDestinationChecked) { if (clipboardDestinationChecked) {
checkbox_copypathtoclipboard.Checked = false; checkbox_copypathtoclipboard.Checked = false;
@ -532,4 +557,29 @@ namespace Greenshot {
CheckDestinationSettings(); CheckDestinationSettings();
} }
} }
public class ListviewWithDestinationComparer : 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;
IDestination firstDestination = l1.Tag as IDestination;
IDestination secondDestination = l2.Tag as IDestination;
if (secondDestination == null) {
return 1;
}
if (firstDestination.Priority == secondDestination.Priority) {
return firstDestination.Description.CompareTo(secondDestination.Description);
}
return firstDestination.Priority - secondDestination.Priority;
}
}
} }

View file

@ -112,29 +112,29 @@
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<data name="colorButton_window_background.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABcAAAAYCAYAAAARfGZ1AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAOwAAA
DsABataJCQAAAhhJREFUSEu109Fu0mAYxvHXK/AWvAXjHXjiFRATT/TEuGk2D1zs5olxooYDncahAUdk
NWIz0Gm3ocS6xdVRHQhRsggilgnrZGNdnNGYBXikX8JSodQD0ib/pEnf95fmS7tvVQfIqUutNuBUVGji
TkX5zQacinKVBuwSF7PwBp/iwTPFds7KoE/fG7DLH4oi8XUXA+fduHKLR2guaTtvtmhlvQ67JoQYvJMi
OI6DrusYvjyO4HTcdqflUWatjm7NvckzuFqtMlxRFGjaBk70c5iYWui61/LoQxO3qgVXKhXIsszwcDgM
UYwilVJxZmgUJ90F3H7yw3LfMCldrqO9FqxpGnK5HHw+H5LJJDye6wgEIggGReTzWzh78SGOjqiYjG13
GIZJ77/V0J5xFKVSicHGUfA8D5fL1cTvMHh2No5y+Rdu3gvjSH8axy6sdBiGSYnVGtozvgpVVRksSRI7
itYbG3CxuMPgGfkzDrlesqwcSzwUTWLE7UU8rnTAhYKOMf8UHkUTDDxwWGBZ4svFGqzixbcY4K5CEF7s
HUU2uwH32H08lj7u7ew/eBeDnmVLg5a+7KJbgcgiTp+7hPn5NDKZNQwOXwPf/FPN86dG5a77tJD9A7t8
wisc7xtiGff/mzc/p1jmN5yKxNRPmEOPl9miyLsdmOvR/sei0NI2zPWKmy0Kvt6CU5Ff2oRT0fjzCpyK
bsysw6n+AqcLNUDQ5d5JAAAAAElFTkSuQmCC
</value>
</data>
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>116, 17</value> <value>116, 17</value>
</metadata> </metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="colorButton_window_background.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABcAAAAYCAYAAAARfGZ1AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6
JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAA68AAAOvAGVvHJJAAACF0lE
QVRIS7XT327SYBjH8ecOvAVvwXgHnngFxMQTPTE6zeaBi908MU6m4UCncWjAEVmN2Az8s25DibjF1VEd
FaJkEUQsE9bZjbG4RWMW4Cd9E5YKpR6QNvkmTfo+nzRPWlqtAk5FaqUBp6JCE3cqym824FSU0xuwS1zM
wht8jofTsu05K4M+/2jALn8oiuS3PfRfdGP0No/QnGJ73mzRynoddk0IMXgnRXAch2q1iqGr4wg+S9jO
tDzKrNXRrbm3eQZXKhWGy7IMTdvAyT4OE1MLXedaHn1s4la1YF3XIUkSw8PhMEQxilRKxbnBEZxyF3Dn
6U/LecOkdLmO9lqwpmnI5XLw+XxQFAUezw0EAhEEgyLy+S2cv/wIx4ZVTMa2OwzDpA/fa2jPWEWpVGKw
sQqe5+FyuZr4XQbPziZQLv/CrfthHO1L4/illQ7DMCm5WkN7xlehqiqD4/E4W0XrjQ24WNxh8Iz0BYdd
r1hWjiUeiioYdnuRSMgdcKFQxZh/Co+jSQYePCKwLPHlYg1W8eI79HPXIAgv91eRzW7APfYAT+Kf9mcO
HLqHAc+ypUFLX/fQrUBkEWcvXMH8fBqZzBoGhq6Db/6p5vOnR6Su87SQ/QO7fMJrnDgzyDLu/3fe/Jxi
md9wKhJTuzCHHi+zRZH3OzDXo/2PRaGlbZjrFTdbFHyzBacif3wTTkXjL3Q4Fd2cWYdT/QX1oojdNG2w
yQAAAABJRU5ErkJggg==
</value>
</data>
</root> </root>