Changeset 8708
- Timestamp:
- 09/28/12 18:36:11 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3
- Files:
-
- 2 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/HeuristicLab.Clients.Hive.JobManager-3.3.csproj
r8702 r8708 97 97 <ItemGroup> 98 98 <Compile Include="ExtensionMethods\TreeNodeExtensions.cs" /> 99 <Compile Include="ListView DateComparer.cs" />99 <Compile Include="ListViewItemComparer.cs" /> 100 100 <Compile Include="Plugin.cs" /> 101 101 <Compile Include="Views\HiveJobManagerView.cs"> -
trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/ListViewItemComparer.cs
r8707 r8708 29 29 /// See: http://msdn.microsoft.com/en-us/library/ms996467.aspx 30 30 /// </summary> 31 public class ListView DateComparer : IComparer {31 public class ListViewItemComparer : IComparer { 32 32 private int col; 33 33 private SortOrder order; 34 34 35 public ListView DateComparer() {35 public ListViewItemComparer() { 36 36 col = 0; 37 37 order = SortOrder.Ascending; 38 38 } 39 39 40 public ListView DateComparer(int column, SortOrder order) {40 public ListViewItemComparer(int column, SortOrder order) { 41 41 col = column; 42 42 this.order = order; … … 45 45 public int Compare(object x, object y) { 46 46 int returnVal; 47 bool result; 48 DateTime firstDate, secondDate; 49 ListViewItem listViewItemX, listViewItemY; 50 listViewItemX = x as ListViewItem; 51 listViewItemY = y as ListViewItem; 47 52 48 if ( !(x is ListViewItem) || !(y is ListViewItem)) {49 throw new InvalidCastException(string.Format("The ListViewDateComparer expects ListViewItems but received {0} and {1}.",53 if (listViewItemX == null || listViewItemY == null) { 54 throw new ArgumentException(string.Format("The ListViewItemComparer expects ListViewItems but received {0} and {1}.", 50 55 x.GetType().ToString(), y.GetType().ToString())); 51 56 } 52 57 53 try { 54 DateTime firstDate = DateTime.Parse(((ListViewItem)x).SubItems[col].Text); 55 DateTime secondDate = DateTime.Parse(((ListViewItem)y).SubItems[col].Text); 58 result = DateTime.TryParse(listViewItemX.SubItems[col].Text, out firstDate); 59 result = DateTime.TryParse(listViewItemY.SubItems[col].Text, out secondDate) && result; 60 61 if (result) { 56 62 returnVal = DateTime.Compare(firstDate, secondDate); 57 } 58 // if neither compared object has a valid date format, compare as a string 59 catch { 60 returnVal = String.Compare(((ListViewItem)x).SubItems[col].Text, ((ListViewItem)y).SubItems[col].Text); 63 } else { 64 // if neither compared object has a valid date format, compare as a string 65 returnVal = String.Compare(listViewItemX.SubItems[col].Text, listViewItemY.SubItems[col].Text); 61 66 } 62 67 -
trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobListView.cs
r8702 r8708 44 44 this.itemsListView.FullRowSelect = true; 45 45 46 this.itemsListView.ListViewItemSorter = new ListView DateComparer(0, SortOrder.Ascending);46 this.itemsListView.ListViewItemSorter = new ListViewItemComparer(0, SortOrder.Ascending); 47 47 this.itemsListView.Sorting = SortOrder.Ascending; 48 48 this.itemsListView.Sort();
Note: See TracChangeset
for help on using the changeset viewer.