Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3299


Ignore:
Timestamp:
04/11/10 03:59:22 (15 years ago)
Author:
swagner
Message:

Enabled dragging and dropping of problems and algorithms in AlgorithmView and BatchRunView (#965).

Location:
trunk/sources
Files:
6 edited

Legend:

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

    r3298 r3299  
    8383      this.listView.View = System.Windows.Forms.View.Details;
    8484      this.listView.SelectedIndexChanged += new System.EventHandler(this.listView_SelectedIndexChanged);
    85       this.listView.SizeChanged += new System.EventHandler(this.listView_SizeChanged);
    8685      this.listView.DoubleClick += new System.EventHandler(this.listView_DoubleClick);
    8786      this.listView.DragDrop += new System.Windows.Forms.DragEventHandler(this.listView_DragDrop);
     
    178177      // saveButton
    179178      //
    180       this.saveButton.Enabled = false;
    181179      this.saveButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Save;
    182180      this.saveButton.Location = new System.Drawing.Point(120, 0);
  • trunk/sources/HeuristicLab.Core.Views/3.3/Clipboard.cs

    r3298 r3299  
    101101          item.ToStringChanged += new EventHandler(Item_ToStringChanged);
    102102          sortAscendingButton.Enabled = sortDescendingButton.Enabled = listView.Items.Count > 1;
    103           saveButton.Enabled = listView.Items.Count > 0;
     103          AdjustListViewColumnSizes();
    104104        }
    105105      }
     
    114114          itemListViewItemTable.Remove(item);
    115115          sortAscendingButton.Enabled = sortDescendingButton.Enabled = listView.Items.Count > 1;
    116           saveButton.Enabled = listView.Items.Count > 0;
    117116        }
    118117      }
     
    204203    private void listView_SelectedIndexChanged(object sender, EventArgs e) {
    205204      removeButton.Enabled = listView.SelectedItems.Count > 0;
    206     }
    207     private void listView_SizeChanged(object sender, EventArgs e) {
    208       if (listView.Columns.Count > 0)
    209         listView.Columns[0].Width = Math.Max(0, listView.Width - 25);
    210205    }
    211206    private void listView_KeyDown(object sender, KeyEventArgs e) {
     
    294289        itemListViewItemTable[item].Text = item.ToString();
    295290        listView.Sort();
     291        AdjustListViewColumnSizes();
     292      }
     293    }
     294    #endregion
     295
     296    #region Helpers
     297    private void AdjustListViewColumnSizes() {
     298      if (listView.Items.Count > 0) {
     299        for (int i = 0; i < listView.Columns.Count; i++)
     300          listView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
    296301      }
    297302    }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.Designer.cs

    r3281 r3299  
    5050      this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView();
    5151      this.problemTabPage = new System.Windows.Forms.TabPage();
     52      this.problemPanel = new System.Windows.Forms.Panel();
     53      this.problemViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    5254      this.saveProblemButton = new System.Windows.Forms.Button();
    5355      this.openProblemButton = new System.Windows.Forms.Button();
    5456      this.newProblemButton = new System.Windows.Forms.Button();
    55       this.problemViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    5657      this.resultsTabPage = new System.Windows.Forms.TabPage();
    5758      this.resultsView = new HeuristicLab.Optimization.Views.ResultCollectionView();
     59      this.runsTabPage = new System.Windows.Forms.TabPage();
     60      this.runsView = new HeuristicLab.Optimization.Views.RunCollectionView();
    5861      this.startButton = new System.Windows.Forms.Button();
    5962      this.pauseButton = new System.Windows.Forms.Button();
     
    6467      this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
    6568      this.stopButton = new System.Windows.Forms.Button();
    66       this.runsTabPage = new System.Windows.Forms.TabPage();
    67       this.runsView = new HeuristicLab.Optimization.Views.RunCollectionView();
    6869      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    6970      this.tabControl.SuspendLayout();
    7071      this.parametersTabPage.SuspendLayout();
    7172      this.problemTabPage.SuspendLayout();
     73      this.problemPanel.SuspendLayout();
    7274      this.resultsTabPage.SuspendLayout();
    7375      this.runsTabPage.SuspendLayout();
     
    124126      // problemTabPage
    125127      //
     128      this.problemTabPage.Controls.Add(this.problemPanel);
    126129      this.problemTabPage.Controls.Add(this.saveProblemButton);
    127130      this.problemTabPage.Controls.Add(this.openProblemButton);
    128131      this.problemTabPage.Controls.Add(this.newProblemButton);
    129       this.problemTabPage.Controls.Add(this.problemViewHost);
    130132      this.problemTabPage.Location = new System.Drawing.Point(4, 22);
    131133      this.problemTabPage.Name = "problemTabPage";
     
    135137      this.problemTabPage.Text = "Problem";
    136138      this.problemTabPage.UseVisualStyleBackColor = true;
     139      //
     140      // problemPanel
     141      //
     142      this.problemPanel.AllowDrop = true;
     143      this.problemPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     144                  | System.Windows.Forms.AnchorStyles.Left)
     145                  | System.Windows.Forms.AnchorStyles.Right)));
     146      this.problemPanel.Controls.Add(this.problemViewHost);
     147      this.problemPanel.Location = new System.Drawing.Point(6, 36);
     148      this.problemPanel.Name = "problemPanel";
     149      this.problemPanel.Size = new System.Drawing.Size(659, 332);
     150      this.problemPanel.TabIndex = 3;
     151      this.problemPanel.DragOver += new System.Windows.Forms.DragEventHandler(this.problemPanel_DragEnterOver);
     152      this.problemPanel.DragDrop += new System.Windows.Forms.DragEventHandler(this.problemPanel_DragDrop);
     153      this.problemPanel.DragEnter += new System.Windows.Forms.DragEventHandler(this.problemPanel_DragEnterOver);
     154      //
     155      // problemViewHost
     156      //
     157      this.problemViewHost.Content = null;
     158      this.problemViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
     159      this.problemViewHost.Location = new System.Drawing.Point(0, 0);
     160      this.problemViewHost.Name = "problemViewHost";
     161      this.problemViewHost.Size = new System.Drawing.Size(659, 332);
     162      this.problemViewHost.TabIndex = 0;
     163      this.problemViewHost.ViewType = null;
    137164      //
    138165      // saveProblemButton
     
    169196      this.newProblemButton.Click += new System.EventHandler(this.newProblemButton_Click);
    170197      //
    171       // problemViewHost
    172       //
    173       this.problemViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    174                   | System.Windows.Forms.AnchorStyles.Left)
    175                   | System.Windows.Forms.AnchorStyles.Right)));
    176       this.problemViewHost.Content = null;
    177       this.problemViewHost.Location = new System.Drawing.Point(6, 36);
    178       this.problemViewHost.Name = "problemViewHost";
    179       this.problemViewHost.Size = new System.Drawing.Size(659, 332);
    180       this.problemViewHost.TabIndex = 3;
    181       this.problemViewHost.ViewType = null;
    182       //
    183198      // resultsTabPage
    184199      //
     
    203218      this.resultsView.Size = new System.Drawing.Size(659, 362);
    204219      this.resultsView.TabIndex = 0;
     220      //
     221      // runsTabPage
     222      //
     223      this.runsTabPage.Controls.Add(this.runsView);
     224      this.runsTabPage.Location = new System.Drawing.Point(4, 22);
     225      this.runsTabPage.Name = "runsTabPage";
     226      this.runsTabPage.Padding = new System.Windows.Forms.Padding(3);
     227      this.runsTabPage.Size = new System.Drawing.Size(671, 374);
     228      this.runsTabPage.TabIndex = 3;
     229      this.runsTabPage.Text = "Runs";
     230      this.runsTabPage.UseVisualStyleBackColor = true;
     231      //
     232      // runsView
     233      //
     234      this.runsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     235                  | System.Windows.Forms.AnchorStyles.Left)
     236                  | System.Windows.Forms.AnchorStyles.Right)));
     237      this.runsView.Caption = "RunCollection";
     238      this.runsView.Content = null;
     239      this.runsView.Location = new System.Drawing.Point(6, 6);
     240      this.runsView.Name = "runsView";
     241      this.runsView.Size = new System.Drawing.Size(659, 362);
     242      this.runsView.TabIndex = 0;
    205243      //
    206244      // startButton
     
    285323      this.stopButton.UseVisualStyleBackColor = true;
    286324      this.stopButton.Click += new System.EventHandler(this.stopButton_Click);
    287       //
    288       // runsTabPage
    289       //
    290       this.runsTabPage.Controls.Add(this.runsView);
    291       this.runsTabPage.Location = new System.Drawing.Point(4, 22);
    292       this.runsTabPage.Name = "runsTabPage";
    293       this.runsTabPage.Padding = new System.Windows.Forms.Padding(3);
    294       this.runsTabPage.Size = new System.Drawing.Size(671, 374);
    295       this.runsTabPage.TabIndex = 3;
    296       this.runsTabPage.Text = "Runs";
    297       this.runsTabPage.UseVisualStyleBackColor = true;
    298       //
    299       // runsView
    300       //
    301       this.runsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    302                   | System.Windows.Forms.AnchorStyles.Left)
    303                   | System.Windows.Forms.AnchorStyles.Right)));
    304       this.runsView.Caption = "RunCollection";
    305       this.runsView.Content = null;
    306       this.runsView.Location = new System.Drawing.Point(6, 6);
    307       this.runsView.Name = "runsView";
    308       this.runsView.Size = new System.Drawing.Size(659, 362);
    309       this.runsView.TabIndex = 0;
    310325      //
    311326      // AlgorithmView
     
    337352      this.parametersTabPage.ResumeLayout(false);
    338353      this.problemTabPage.ResumeLayout(false);
     354      this.problemPanel.ResumeLayout(false);
    339355      this.resultsTabPage.ResumeLayout(false);
    340356      this.runsTabPage.ResumeLayout(false);
     
    366382    protected System.Windows.Forms.TabPage runsTabPage;
    367383    protected RunCollectionView runsView;
     384    protected System.Windows.Forms.Panel problemPanel;
    368385
    369386  }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs

    r3275 r3299  
    163163    #endregion
    164164
    165     #region Button events
     165    #region Control Events
    166166    protected virtual void newProblemButton_Click(object sender, EventArgs e) {
    167167      if (problemTypeSelectorDialog == null) {
     
    247247      }
    248248    }
     249    protected virtual void problemPanel_DragEnterOver(object sender, DragEventArgs e) {
     250      e.Effect = DragDropEffects.None;
     251      Type type = e.Data.GetData("Type") as Type;
     252      if ((type != null) && (Content.ProblemType.IsAssignableFrom(type))) {
     253        if ((e.KeyState & 8) == 8) e.Effect = DragDropEffects.Copy;  // CTRL key
     254        else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move;  // SHIFT key
     255        else if ((e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) e.Effect = DragDropEffects.Link;
     256        else if ((e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy;
     257        else if ((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) e.Effect = DragDropEffects.Move;
     258      }
     259    }
     260    protected virtual void problemPanel_DragDrop(object sender, DragEventArgs e) {
     261      if (e.Effect != DragDropEffects.None) {
     262        IProblem problem = e.Data.GetData("Value") as IProblem;
     263        if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) problem = (IProblem)problem.Clone();
     264        Content.Problem = problem;
     265      }
     266    }
    249267    #endregion
    250268
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.Designer.cs

    r3281 r3299  
    4848      this.tabControl = new System.Windows.Forms.TabControl();
    4949      this.algorithmTabPage = new System.Windows.Forms.TabPage();
     50      this.algorithmPanel = new System.Windows.Forms.Panel();
     51      this.algorithmViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    5052      this.saveAlgorithmButton = new System.Windows.Forms.Button();
    5153      this.openAlgorithmButton = new System.Windows.Forms.Button();
    5254      this.newAlgorithmButton = new System.Windows.Forms.Button();
    53       this.algorithmViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    5455      this.runsTabPage = new System.Windows.Forms.TabPage();
    5556      this.runsView = new HeuristicLab.Optimization.Views.RunCollectionView();
     
    6768      this.tabControl.SuspendLayout();
    6869      this.algorithmTabPage.SuspendLayout();
     70      this.algorithmPanel.SuspendLayout();
    6971      this.runsTabPage.SuspendLayout();
    7072      ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).BeginInit();
     
    9698      // algorithmTabPage
    9799      //
     100      this.algorithmTabPage.Controls.Add(this.algorithmPanel);
    98101      this.algorithmTabPage.Controls.Add(this.saveAlgorithmButton);
    99102      this.algorithmTabPage.Controls.Add(this.openAlgorithmButton);
    100103      this.algorithmTabPage.Controls.Add(this.newAlgorithmButton);
    101       this.algorithmTabPage.Controls.Add(this.algorithmViewHost);
    102104      this.algorithmTabPage.Location = new System.Drawing.Point(4, 22);
    103105      this.algorithmTabPage.Name = "algorithmTabPage";
     
    107109      this.algorithmTabPage.Text = "Algorithm";
    108110      this.algorithmTabPage.UseVisualStyleBackColor = true;
     111      //
     112      // algorithmPanel
     113      //
     114      this.algorithmPanel.AllowDrop = true;
     115      this.algorithmPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     116                  | System.Windows.Forms.AnchorStyles.Left)
     117                  | System.Windows.Forms.AnchorStyles.Right)));
     118      this.algorithmPanel.Controls.Add(this.algorithmViewHost);
     119      this.algorithmPanel.Location = new System.Drawing.Point(6, 36);
     120      this.algorithmPanel.Name = "algorithmPanel";
     121      this.algorithmPanel.Size = new System.Drawing.Size(659, 306);
     122      this.algorithmPanel.TabIndex = 3;
     123      this.algorithmPanel.DragOver += new System.Windows.Forms.DragEventHandler(this.algorithmPanel_DragEnterOver);
     124      this.algorithmPanel.DragDrop += new System.Windows.Forms.DragEventHandler(this.algorithmPanel_DragDrop);
     125      this.algorithmPanel.DragEnter += new System.Windows.Forms.DragEventHandler(this.algorithmPanel_DragEnterOver);
     126      //
     127      // algorithmViewHost
     128      //
     129      this.algorithmViewHost.Content = null;
     130      this.algorithmViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
     131      this.algorithmViewHost.Location = new System.Drawing.Point(0, 0);
     132      this.algorithmViewHost.Name = "algorithmViewHost";
     133      this.algorithmViewHost.Size = new System.Drawing.Size(659, 306);
     134      this.algorithmViewHost.TabIndex = 0;
     135      this.algorithmViewHost.ViewType = null;
    109136      //
    110137      // saveAlgorithmButton
     
    140167      this.newAlgorithmButton.UseVisualStyleBackColor = true;
    141168      this.newAlgorithmButton.Click += new System.EventHandler(this.newAlgorithmButton_Click);
    142       //
    143       // algorithmViewHost
    144       //
    145       this.algorithmViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    146                   | System.Windows.Forms.AnchorStyles.Left)
    147                   | System.Windows.Forms.AnchorStyles.Right)));
    148       this.algorithmViewHost.Content = null;
    149       this.algorithmViewHost.Location = new System.Drawing.Point(6, 36);
    150       this.algorithmViewHost.Name = "algorithmViewHost";
    151       this.algorithmViewHost.Size = new System.Drawing.Size(659, 306);
    152       this.algorithmViewHost.TabIndex = 3;
    153       this.algorithmViewHost.ViewType = null;
    154169      //
    155170      // runsTabPage
     
    279294            0,
    280295            0});
    281       this.repetitionsNumericUpDown.Validated += new System.EventHandler(repetitionsNumericUpDown_Validated);
    282296      this.repetitionsNumericUpDown.ValueChanged += new System.EventHandler(this.repetitionsNumericUpDown_ValueChanged);
     297      this.repetitionsNumericUpDown.Validated += new System.EventHandler(this.repetitionsNumericUpDown_Validated);
    283298      //
    284299      // pauseButton
     
    325340      this.tabControl.ResumeLayout(false);
    326341      this.algorithmTabPage.ResumeLayout(false);
     342      this.algorithmPanel.ResumeLayout(false);
    327343      this.runsTabPage.ResumeLayout(false);
    328344      ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).EndInit();
     
    351367    private RunCollectionView runsView;
    352368    private System.Windows.Forms.Button pauseButton;
     369    private System.Windows.Forms.Panel algorithmPanel;
    353370
    354371  }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs

    r3274 r3299  
    235235      }
    236236    }
     237    private void algorithmPanel_DragEnterOver(object sender, DragEventArgs e) {
     238      e.Effect = DragDropEffects.None;
     239      Type type = e.Data.GetData("Type") as Type;
     240      if ((type != null) && (typeof(IAlgorithm).IsAssignableFrom(type))) {
     241        if ((e.KeyState & 8) == 8) e.Effect = DragDropEffects.Copy;  // CTRL key
     242        else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move;  // SHIFT key
     243        else if ((e.AllowedEffect & DragDropEffects.Link) == DragDropEffects.Link) e.Effect = DragDropEffects.Link;
     244        else if ((e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy) e.Effect = DragDropEffects.Copy;
     245        else if ((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move) e.Effect = DragDropEffects.Move;
     246      }
     247    }
     248    private void algorithmPanel_DragDrop(object sender, DragEventArgs e) {
     249      if (e.Effect != DragDropEffects.None) {
     250        IAlgorithm algorithm = e.Data.GetData("Value") as IAlgorithm;
     251        if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) algorithm = (IAlgorithm)algorithm.Clone();
     252        Content.Algorithm = algorithm;
     253      }
     254    }
    237255    #endregion
    238256
Note: See TracChangeset for help on using the changeset viewer.