Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/28/12 18:36:11 (12 years ago)
Author:
ascheibe
Message:

#1959 implemented reviewing comments

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  
    9797  <ItemGroup>
    9898    <Compile Include="ExtensionMethods\TreeNodeExtensions.cs" />
    99     <Compile Include="ListViewDateComparer.cs" />
     99    <Compile Include="ListViewItemComparer.cs" />
    100100    <Compile Include="Plugin.cs" />
    101101    <Compile Include="Views\HiveJobManagerView.cs">
  • trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/ListViewItemComparer.cs

    r8707 r8708  
    2929  /// See: http://msdn.microsoft.com/en-us/library/ms996467.aspx
    3030  /// </summary>
    31   public class ListViewDateComparer : IComparer {
     31  public class ListViewItemComparer : IComparer {
    3232    private int col;
    3333    private SortOrder order;
    3434
    35     public ListViewDateComparer() {
     35    public ListViewItemComparer() {
    3636      col = 0;
    3737      order = SortOrder.Ascending;
    3838    }
    3939
    40     public ListViewDateComparer(int column, SortOrder order) {
     40    public ListViewItemComparer(int column, SortOrder order) {
    4141      col = column;
    4242      this.order = order;
     
    4545    public int Compare(object x, object y) {
    4646      int returnVal;
     47      bool result;
     48      DateTime firstDate, secondDate;
     49      ListViewItem listViewItemX, listViewItemY;
     50      listViewItemX = x as ListViewItem;
     51      listViewItemY = y as ListViewItem;
    4752
    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}.",
    5055          x.GetType().ToString(), y.GetType().ToString()));
    5156      }
    5257
    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) {
    5662        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);
    6166      }
    6267
  • trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobListView.cs

    r8702 r8708  
    4444      this.itemsListView.FullRowSelect = true;
    4545
    46       this.itemsListView.ListViewItemSorter = new ListViewDateComparer(0, SortOrder.Ascending);
     46      this.itemsListView.ListViewItemSorter = new ListViewItemComparer(0, SortOrder.Ascending);
    4747      this.itemsListView.Sorting = SortOrder.Ascending;
    4848      this.itemsListView.Sort();
Note: See TracChangeset for help on using the changeset viewer.