mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
Merge remote-tracking branch 'remotes/origin/master' into release/1.2.9
This commit is contained in:
commit
0323705513
276 changed files with 5382 additions and 3666 deletions
|
@ -29,28 +29,28 @@ namespace GreenshotPlugin.Controls {
|
|||
/// <summary>
|
||||
/// Specifies the column to be sorted
|
||||
/// </summary>
|
||||
private int ColumnToSort;
|
||||
private int _columnToSort;
|
||||
/// <summary>
|
||||
/// Specifies the order in which to sort (i.e. 'Ascending').
|
||||
/// </summary>
|
||||
private SortOrder OrderOfSort;
|
||||
private SortOrder _orderOfSort;
|
||||
/// <summary>
|
||||
/// Case insensitive comparer object
|
||||
/// </summary>
|
||||
private CaseInsensitiveComparer ObjectCompare;
|
||||
private readonly CaseInsensitiveComparer _objectCompare;
|
||||
|
||||
/// <summary>
|
||||
/// Class constructor. Initializes various elements
|
||||
/// </summary>
|
||||
public GreenshotColumnSorter() {
|
||||
// Initialize the column to '0'
|
||||
ColumnToSort = 0;
|
||||
_columnToSort = 0;
|
||||
|
||||
// Initialize the sort order to 'none'
|
||||
OrderOfSort = SortOrder.None;
|
||||
_orderOfSort = SortOrder.None;
|
||||
|
||||
// Initialize the CaseInsensitiveComparer object
|
||||
ObjectCompare = new CaseInsensitiveComparer();
|
||||
_objectCompare = new CaseInsensitiveComparer();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -60,34 +60,33 @@ namespace GreenshotPlugin.Controls {
|
|||
/// <param name="y">Second object to be compared</param>
|
||||
/// <returns>The result of the comparison. "0" if equal, negative if 'x' is less than 'y' and positive if 'x' is greater than 'y'</returns>
|
||||
public int Compare(object x, object y) {
|
||||
int compareResult;
|
||||
ListViewItem listviewX, listviewY;
|
||||
|
||||
if (x == null && y == null) {
|
||||
return 0;
|
||||
} else if (x == null && y != null) {
|
||||
return -1;
|
||||
} else if (x != null && y == null) {
|
||||
return 1;
|
||||
}
|
||||
if (x == null) {
|
||||
return -1;
|
||||
}
|
||||
if (y == null) {
|
||||
return 1;
|
||||
}
|
||||
// Cast the objects to be compared to ListViewItem objects
|
||||
listviewX = (ListViewItem)x;
|
||||
listviewY = (ListViewItem)y;
|
||||
var listviewX = (ListViewItem)x;
|
||||
var listviewY = (ListViewItem)y;
|
||||
|
||||
// Compare the two items
|
||||
compareResult = ObjectCompare.Compare(listviewX.SubItems[ColumnToSort].Text, listviewY.SubItems[ColumnToSort].Text);
|
||||
var compareResult = _objectCompare.Compare(listviewX.SubItems[_columnToSort].Text, listviewY.SubItems[_columnToSort].Text);
|
||||
|
||||
// Calculate correct return value based on object comparison
|
||||
if (OrderOfSort == SortOrder.Ascending) {
|
||||
if (_orderOfSort == SortOrder.Ascending) {
|
||||
// Ascending sort is selected, return normal result of compare operation
|
||||
return compareResult;
|
||||
} else if (OrderOfSort == SortOrder.Descending) {
|
||||
// Descending sort is selected, return negative result of compare operation
|
||||
return (-compareResult);
|
||||
} else {
|
||||
// Return '0' to indicate they are equal
|
||||
return 0;
|
||||
}
|
||||
if (_orderOfSort == SortOrder.Descending) {
|
||||
// Descending sort is selected, return negative result of compare operation
|
||||
return -compareResult;
|
||||
}
|
||||
// Return '0' to indicate they are equal
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -95,10 +94,10 @@ namespace GreenshotPlugin.Controls {
|
|||
/// </summary>
|
||||
public int SortColumn {
|
||||
set {
|
||||
ColumnToSort = value;
|
||||
_columnToSort = value;
|
||||
}
|
||||
get {
|
||||
return ColumnToSort;
|
||||
return _columnToSort;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,10 +106,10 @@ namespace GreenshotPlugin.Controls {
|
|||
/// </summary>
|
||||
public SortOrder Order {
|
||||
set {
|
||||
OrderOfSort = value;
|
||||
_orderOfSort = value;
|
||||
}
|
||||
get {
|
||||
return OrderOfSort;
|
||||
return _orderOfSort;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue