Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7839


Ignore:
Timestamp:
05/16/12 15:40:36 (13 years ago)
Author:
ascheibe
Message:

#1174 added drag and drop support for the experiment upload view

Location:
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBExperimentUploadView.Designer.cs

    r7742 r7839  
    5353      // dataGridView
    5454      //
     55      this.dataGridView.AllowDrop = true;
    5556      this.dataGridView.AllowUserToAddRows = false;
    5657      this.dataGridView.AllowUserToDeleteRows = false;
     
    7576      this.dataGridView.TabIndex = 2;
    7677      this.dataGridView.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView_CellMouseClick);
     78      this.dataGridView.DragDrop += new System.Windows.Forms.DragEventHandler(this.dataGridView_DragDrop);
     79      this.dataGridView.DragEnter += new System.Windows.Forms.DragEventHandler(this.dataGridView_DragEnter);
    7780      //
    7881      // RunNameColumn
     
    136139      // OKBExperimentUploadView
    137140      //
     141      this.AllowDrop = true;
    138142      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    139143      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBExperimentUploadView.cs

    r7742 r7839  
    3535namespace HeuristicLab.Clients.OKB.RunCreation {
    3636  [View("OKBExperimentUpload View")]
    37   [Content(typeof(Experiment), false)]
    3837  [Content(typeof(RunCollection), false)]
    3938  [Content(typeof(IOptimizer), false)]
    4039  public partial class OKBExperimentUploadView : ItemView {
    41     public new IItem Content {
    42       get { return base.Content; }
     40    public new IOptimizer Content {
     41      get { return (IOptimizer)base.Content; }
    4342      set {
    4443        base.Content = value;
     
    6968        ClearRuns();
    7069      } else {
    71         if (Content is Experiment) {
    72           runs.AddRange((Content as Experiment).Runs);
    73         } else if (Content is RunCollection) {
    74           runs.AddRange((Content as RunCollection));
    75         } else if (Content is IOptimizer) {
    76           runs.AddRange((Content as IOptimizer).Runs);
    77         }
    78 
     70        AddRuns(Content);
    7971        DisplayRuns();
     72      }
     73    }
     74
     75    private void AddRuns(IItem item) {
     76      if (item is Experiment) {
     77        runs.AddRange((item as Experiment).Runs);
     78      } else if (item is RunCollection) {
     79        runs.AddRange((item as RunCollection));
     80      } else if (item is IOptimizer) {
     81        runs.AddRange((item as IOptimizer).Runs);
     82      } else if (item is IRun) {
     83        runs.Add(item as IRun);
    8084      }
    8185    }
     
    124128      cmbProblem.DisplayMember = "Name";
    125129
     130      dataGridView.Rows.Clear();
    126131      foreach (IRun run in runs) {
    127132        int idx = dataGridView.Rows.Add(run.Name);
     
    268273      selectedProblem = null;
    269274    }
     275
     276    private void dataGridView_DragEnter(object sender, DragEventArgs e) {
     277      e.Effect = DragDropEffects.None;
     278      if (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IRun
     279        || e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IOptimizer) {
     280        if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
     281        else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move;  // SHIFT key
     282        else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
     283        else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move;
     284        else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link;
     285      }
     286    }
     287
     288    private void dataGridView_DragDrop(object sender, DragEventArgs e) {
     289      if (e.Effect != DragDropEffects.None) {
     290        IItem optimizer = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as IItem;
     291        if (e.Effect.HasFlag(DragDropEffects.Copy)) optimizer = (IItem)optimizer.Clone();
     292        AddRuns(optimizer);
     293        DisplayRuns();
     294      }
     295    }
    270296  }
    271297}
Note: See TracChangeset for help on using the changeset viewer.