Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7195


Ignore:
Timestamp:
12/16/11 15:00:24 (13 years ago)
Author:
mkommend
Message:

#1713: Implemented drag & drop operations for the checked state.

Location:
trunk/sources/HeuristicLab.Core.Views/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core.Views/3.3/CheckedItemCollectionView.cs

    r6233 r7195  
    2020#endregion
    2121
     22using System.Linq;
    2223using System.Drawing;
    2324using System.Windows.Forms;
     
    8586        doubleClick = true;
    8687    }
     88
     89    protected override void itemsListView_DragEnter(object sender, DragEventArgs e) {
     90      validDragOperation = false;
     91      if (Locked || ReadOnly) return;
     92
     93      var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as ICheckedItemCollection<T>;
     94      if (data != null)
     95        validDragOperation = Content.Select(x => x.ToString()).SequenceEqual(data.Select(x => x.ToString()));
     96      else
     97        base.itemsListView_DragEnter(sender, e);
     98    }
     99
     100    protected override void itemsListView_DragOver(object sender, DragEventArgs e) {
     101      e.Effect = DragDropEffects.None;
     102      if (!validDragOperation) return;
     103
     104      var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as ICheckedItemCollection<T>;
     105      if (data != null)
     106        e.Effect = DragDropEffects.Copy;
     107      else
     108        base.itemsListView_DragOver(sender, e);
     109    }
     110
     111    protected override void itemsListView_DragDrop(object sender, DragEventArgs e) {
     112      if (e.Effect == DragDropEffects.None) return;
     113      var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as ICheckedItemCollection<T>;
     114      if (data != null) {
     115        for (int i = 0; i < Content.Count; i++) {
     116          Content.SetItemCheckedState(Content.ElementAt(i), data.ItemChecked(data.ElementAt(i)));
     117        }
     118      } else
     119        base.itemsListView_DragDrop(sender, e);
     120    }
    87121    #endregion
    88122
  • trunk/sources/HeuristicLab.Core.Views/3.3/CheckedItemListView.cs

    r6233 r7195  
    2020#endregion
    2121
     22using System.Linq;
    2223using System.Drawing;
    2324using System.Windows.Forms;
     
    5455    private Color backupColor = Color.Empty;
    5556    protected override void SetEnabledStateOfControls() {
    56       if(backupColor == Color.Empty) backupColor = base.itemsListView.BackColor;
     57      if (backupColor == Color.Empty) backupColor = base.itemsListView.BackColor;
    5758      base.SetEnabledStateOfControls();
    5859      if (ReadOnly || Locked)
     
    8889        doubleClick = true;
    8990    }
     91
     92    protected override void itemsListView_DragEnter(object sender, DragEventArgs e) {
     93      validDragOperation = false;
     94      if (Locked || ReadOnly) return;
     95
     96      var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as ICheckedItemList<T>;
     97      if (data != null)
     98        validDragOperation = Content.Select(x => x.ToString()).SequenceEqual(data.Select(x => x.ToString()));
     99      else
     100        base.itemsListView_DragEnter(sender, e);
     101    }
     102
     103    protected override void itemsListView_DragOver(object sender, DragEventArgs e) {
     104      e.Effect = DragDropEffects.None;
     105      if (!validDragOperation) return;
     106
     107      var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as ICheckedItemList<T>;
     108      if (data != null)
     109        e.Effect = DragDropEffects.Copy;
     110      else
     111        base.itemsListView_DragOver(sender, e);
     112    }
     113
     114    protected override void itemsListView_DragDrop(object sender, DragEventArgs e) {
     115      if (e.Effect == DragDropEffects.None) return;
     116      var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as ICheckedItemList<T>;
     117      if (data != null) {
     118        for (int i = 0; i < Content.Count; i++) {
     119          Content.SetItemCheckedState(Content[i], data.ItemChecked(data[i]));
     120        }
     121      } else
     122        base.itemsListView_DragDrop(sender, e);
     123    }
    90124    #endregion
    91125
Note: See TracChangeset for help on using the changeset viewer.