Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/18/11 01:38:23 (13 years ago)
Author:
swagner
Message:

Implemented dragging of multiple items in all collection views and refactored drag & drop code (#1112)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis.Views/3.3/CrossValidationView.cs

    r5445 r5744  
    317317    private void algorithmTabPage_DragEnterOver(object sender, DragEventArgs e) {
    318318      e.Effect = DragDropEffects.None;
    319       if (ReadOnly) return;
    320       Type type = e.Data.GetData("Type") as Type;
    321       IAlgorithm algorithm = e.Data.GetData("Value") as IAlgorithm;
    322       if ((type != null) && (typeof(IAlgorithm).IsAssignableFrom(type)) &&
    323         algorithm != null && Content.ProblemType.IsAssignableFrom(algorithm.Problem.GetType())) {
     319      IAlgorithm algorithm = e.Data.GetData("HeuristicLab") as IAlgorithm;
     320      if (!ReadOnly && (algorithm != null) && Content.ProblemType.IsAssignableFrom(algorithm.Problem.GetType())) {
    324321        if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
    325322        else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move;  // SHIFT key
    326         else if ((e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy;
    327         else if ((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) e.Effect = DragDropEffects.Move;
    328         else if ((e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) e.Effect = DragDropEffects.Link;
     323        else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
     324        else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move;
     325        else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link;
    329326      }
    330327    }
    331328    private void algorithmTabPage_DragDrop(object sender, DragEventArgs e) {
    332329      if (e.Effect != DragDropEffects.None) {
    333         IAlgorithm algorithm = e.Data.GetData("Value") as IAlgorithm;
    334         if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) algorithm = (IAlgorithm)algorithm.Clone();
     330        IAlgorithm algorithm = e.Data.GetData("HeuristicLab") as IAlgorithm;
     331        if (e.Effect.HasFlag(DragDropEffects.Copy)) algorithm = (IAlgorithm)algorithm.Clone();
    335332        Content.Algorithm = algorithm;
    336333      }
     
    339336    private void algorithmProblemTabPage_DragEnterOver(object sender, DragEventArgs e) {
    340337      e.Effect = DragDropEffects.None;
    341       if (ReadOnly) return;
    342       Type type = e.Data.GetData("Type") as Type;
    343       if ((type != null) && (Content.ProblemType.IsAssignableFrom(type)) &&
    344         (Content.Algorithm.ProblemType.IsAssignableFrom(type))) {
     338      Type type = e.Data.GetData("HeuristicLab") != null ? e.Data.GetData("HeuristicLab").GetType() : null;
     339      if (!ReadOnly && (type != null) && Content.ProblemType.IsAssignableFrom(type) && Content.Algorithm.ProblemType.IsAssignableFrom(type)) {
    345340        if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
    346341        else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move;  // SHIFT key
    347         else if ((e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy;
    348         else if ((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) e.Effect = DragDropEffects.Move;
    349         else if ((e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) e.Effect = DragDropEffects.Link;
     342        else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
     343        else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move;
     344        else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link;
    350345      }
    351346    }
    352347    private void algorithmProblemTabPage_DragDrop(object sender, DragEventArgs e) {
    353348      if (e.Effect != DragDropEffects.None) {
    354         ISingleObjectiveDataAnalysisProblem problem = e.Data.GetData("Value") as ISingleObjectiveDataAnalysisProblem;
    355         if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) problem = (ISingleObjectiveDataAnalysisProblem)problem.Clone();
     349        ISingleObjectiveDataAnalysisProblem problem = e.Data.GetData("HeuristicLab") as ISingleObjectiveDataAnalysisProblem;
     350        if (e.Effect.HasFlag(DragDropEffects.Copy)) problem = (ISingleObjectiveDataAnalysisProblem)problem.Clone();
    356351        Content.Problem = problem;
    357352      }
Note: See TracChangeset for help on using the changeset viewer.