Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/02/17 14:06:38 (6 years ago)
Author:
jzenisek
Message:

#2719 added datastream type; updated the optimizer view and control functionality

Location:
branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis.Views/3.4
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis.Views/3.4/DatastreamAnalysisOptimizerView.Designer.cs

    r14488 r14536  
    3030      this.datastreamViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    3131      this.resultsTab = new System.Windows.Forms.TabPage();
    32       this.resultsViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     32      this.resultsView = new HeuristicLab.Optimization.Views.ResultCollectionView();
     33      this.runsTab = new System.Windows.Forms.TabPage();
     34      this.runsView = new HeuristicLab.Optimization.Views.RunCollectionView();
    3335      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    3436      this.tabControl.SuspendLayout();
     
    3638      this.datastreamTab.SuspendLayout();
    3739      this.resultsTab.SuspendLayout();
     40      this.runsTab.SuspendLayout();
    3841      this.SuspendLayout();
    3942      //
     
    8588      this.tabControl.Controls.Add(this.datastreamTab);
    8689      this.tabControl.Controls.Add(this.resultsTab);
     90      this.tabControl.Controls.Add(this.runsTab);
    8791      this.tabControl.Location = new System.Drawing.Point(3, 26);
    8892      this.tabControl.Name = "tabControl";
     
    103107      this.ensemblesTab.UseVisualStyleBackColor = true;
    104108      this.ensemblesTab.DragDrop += new System.Windows.Forms.DragEventHandler(this.ensemblesTab_DragDrop);
    105       this.ensemblesTab.DragEnter += new System.Windows.Forms.DragEventHandler(this.ensemblesTab_DragEnter);
     109      this.ensemblesTab.DragEnter += new System.Windows.Forms.DragEventHandler(this.ensemblesTab_DragEnterOver);
     110      this.ensemblesTab.DragOver += new System.Windows.Forms.DragEventHandler(this.ensemblesTab_DragEnterOver);
    106111      //
    107112      // ensemblesViewHost
     
    133138      this.datastreamTab.UseVisualStyleBackColor = true;
    134139      this.datastreamTab.DragDrop += new System.Windows.Forms.DragEventHandler(this.datastreamTab_DragDrop);
    135       this.datastreamTab.DragEnter += new System.Windows.Forms.DragEventHandler(this.datastreamTab_DragEnter);
     140      this.datastreamTab.DragEnter += new System.Windows.Forms.DragEventHandler(this.datastreamTab_DragEnterOver);
     141      this.datastreamTab.DragOver += new System.Windows.Forms.DragEventHandler(this.datastreamTab_DragEnterOver);
    136142      //
    137143      // datastreamViewHost
     
    151157      // resultsTab
    152158      //
    153       this.resultsTab.Controls.Add(this.resultsViewHost);
     159      this.resultsTab.Controls.Add(this.resultsView);
    154160      this.resultsTab.Location = new System.Drawing.Point(4, 22);
    155161      this.resultsTab.Name = "resultsTab";
     
    161167      // resultsViewHost
    162168      //
    163       this.resultsViewHost.Caption = "View";
    164       this.resultsViewHost.Content = null;
    165       this.resultsViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
    166       this.resultsViewHost.Enabled = false;
    167       this.resultsViewHost.Location = new System.Drawing.Point(0, 0);
    168       this.resultsViewHost.Name = "resultsViewHost";
    169       this.resultsViewHost.ReadOnly = false;
    170       this.resultsViewHost.Size = new System.Drawing.Size(950, 554);
    171       this.resultsViewHost.TabIndex = 0;
    172       this.resultsViewHost.ViewsLabelVisible = true;
    173       this.resultsViewHost.ViewType = null;
     169      this.resultsView.Caption = "View";
     170      this.resultsView.Content = null;
     171      this.resultsView.Dock = System.Windows.Forms.DockStyle.Fill;
     172      this.resultsView.Enabled = false;
     173      this.resultsView.Location = new System.Drawing.Point(0, 0);
     174      this.resultsView.Name = "resultsViewHost";
     175      this.resultsView.ReadOnly = false;
     176      this.resultsView.Size = new System.Drawing.Size(950, 554);
     177      this.resultsView.TabIndex = 0;
     178      //
     179      // runsTab
     180      //
     181      //this.runsTabPage.Controls.Add(this.storeAlgorithmInEachRunCheckBox);
     182      this.runsTab.Controls.Add(this.runsView);
     183      this.runsTab.Location = new System.Drawing.Point(4, 22);
     184      this.runsTab.Name = "runsTabPage";
     185      this.runsTab.Padding = new System.Windows.Forms.Padding(3);
     186      this.runsTab.Size = new System.Drawing.Size(950, 554);
     187      this.runsTab.TabIndex = 3;
     188      this.runsTab.Text = "Runs";
     189      this.runsTab.UseVisualStyleBackColor = true;
     190      //
     191      // runsView
     192      //
     193      this.runsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     194      | System.Windows.Forms.AnchorStyles.Left)
     195      | System.Windows.Forms.AnchorStyles.Right)));
     196      this.runsView.Caption = "RunCollection View";
     197      this.runsView.Content = null;
     198      this.runsView.Location = new System.Drawing.Point(0, 0);
     199      this.runsView.Name = "runsView";
     200      this.runsView.ReadOnly = false;
     201      this.runsView.Size = new System.Drawing.Size(950, 554);
     202      this.runsView.TabIndex = 0;
    174203      //
    175204      // DatastreamAnalysisOptimizerView
     
    206235    private System.Windows.Forms.TabPage ensemblesTab;
    207236    private System.Windows.Forms.TabPage datastreamTab;
    208     private System.Windows.Forms.TabPage resultsTab;
     237    protected System.Windows.Forms.TabPage resultsTab;
     238    protected System.Windows.Forms.TabPage runsTab;
    209239    private MainForm.WindowsForms.ViewHost ensemblesViewHost;
    210240    private MainForm.WindowsForms.ViewHost datastreamViewHost;
    211     private MainForm.WindowsForms.ViewHost resultsViewHost;
     241    protected HeuristicLab.Optimization.Views.ResultCollectionView resultsView;
     242    protected HeuristicLab.Optimization.Views.RunCollectionView runsView;
    212243  }
    213244}
  • branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis.Views/3.4/DatastreamAnalysisOptimizerView.cs

    r14488 r14536  
    11#region License Information
     2
    23/* HeuristicLab
    34 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     
    1819 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
    1920 */
     21
    2022#endregion
    2123
    2224using System;
     25using System.Collections.Generic;
     26using System.Linq;
    2327using System.Windows.Forms;
     28using HeuristicLab.Core;
    2429using HeuristicLab.MainForm;
    2530using HeuristicLab.Optimization;
     
    3742
    3843    public new DatastreamAnalysisOptimizer Content {
    39       get { return (DatastreamAnalysisOptimizer)base.Content; }
     44      get { return (DatastreamAnalysisOptimizer) base.Content; }
    4045      set { base.Content = value; }
     46    }
     47
     48    //protected override void Dispose(bool disposing) {
     49    //  if (disposing) {
     50    //    if (components != null) components.Dispose();
     51    //  }
     52    //  base.Dispose(disposing);
     53    //}
     54
     55    protected override void OnInitialized(EventArgs e) {
     56      // set order of tab pages according to z order.
     57      // NOTE: this is required due to a bug in the VS designer.
     58      List<Control> tabPages = new List<Control>();
     59      for (int i = 0; i < tabControl.Controls.Count; i++) {
     60        tabPages.Add(tabControl.Controls[i]);
     61      }
     62      tabControl.Controls.Clear();
     63      foreach(Control control in tabPages)
     64        tabControl.Controls.Add(control);
     65
     66      base.OnInitialized(e);
    4167    }
    4268
    4369    protected override void OnContentChanged() {
    4470      base.OnContentChanged();
    45       if (Content == null)
    46         return;
    47 
    48       // TODO
     71      if (Content == null) {
     72        ensemblesViewHost.Content = null;
     73        datastreamViewHost.Content = null;
     74        resultsView.Content = null;
     75        runsView.Content = null;
     76      } else {
     77        ensemblesViewHost.Content = Content.Ensembles;
     78        datastreamViewHost.Content = Content.Datastream;
     79        resultsView.Content = Content.Results.AsReadOnly();
     80        runsView.Content = Content.Runs;
     81      }
     82    }
     83
     84    protected override void SetEnabledStateOfControls() {
     85      base.SetEnabledStateOfControls();
     86      resultsView.Enabled = Content != null;
     87      runsView.Enabled = Content != null;
     88    }
     89
     90    protected override void OnClosed(FormClosedEventArgs e) {
     91      if ((Content != null) && (Content.ExecutionState == ExecutionState.Started)) {
     92        //The content must be stopped if no other view showing the content is available
     93        var optimizers =
     94          MainFormManager.MainForm.Views.OfType<IContentView>()
     95            .Where(v => v != this)
     96            .Select(v => v.Content)
     97            .OfType<IOptimizer>();
     98        if (!optimizers.Contains(Content)) {
     99          var nestedOptimizers = optimizers.SelectMany(opt => opt.NestedOptimizers);
     100          if (!nestedOptimizers.Contains(Content)) Content.Stop();
     101        }
     102      }
     103      base.OnClosed(e);
    49104    }
    50105
     
    52107      base.RegisterContentEvents();
    53108
    54       // TODO
     109      Content.EnsemblesChanged += new EventHandler(Content_EnsemblesChanged);
     110      Content.DatastreamChanged += new EventHandler(Content_DatastreamChanged);
    55111    }
    56112
    57113    protected override void DeregisterContentEvents() {
     114      Content.EnsemblesChanged -= new EventHandler(Content_EnsemblesChanged);
     115      Content.DatastreamChanged -= new EventHandler(Content_DatastreamChanged);
     116
    58117      base.DeregisterContentEvents();
    59118    }
    60119
     120    #region
     121    protected override void Content_Prepared(object sender, EventArgs e) {
     122      if (InvokeRequired)
     123        Invoke(new EventHandler(Content_Prepared), sender, e);
     124      else {
     125        base.Content_Prepared(sender,e);
     126        resultsView.Content = Content.Results.AsReadOnly();
     127      }
     128    }
     129
     130    protected void Content_EnsemblesChanged(object sender, EventArgs e) {
     131      if (InvokeRequired)
     132        Invoke(new EventHandler(Content_EnsemblesChanged), sender, e);
     133      else {
     134        ensemblesViewHost.Content = Content.Ensembles;
     135      }
     136    }
     137
     138    protected void Content_DatastreamChanged(object sender, EventArgs e) {
     139      if (InvokeRequired)
     140        Invoke(new EventHandler(Content_DatastreamChanged), sender, e);
     141      else {
     142        if (datastreamViewHost.Content != null && Content.Datastream != null &&
     143            datastreamViewHost.Content.GetType() != Content.Datastream.GetType())
     144          datastreamViewHost.ViewType = null;
     145        datastreamViewHost.Content = Content.Datastream;
     146      }
     147    }
     148    #endregion
     149
    61150    #region event handlers
    62 
    63151    private void ensemblesTab_DragDrop(object sender, DragEventArgs e) {
    64152      if (e.Data.GetDataPresent(HeuristicLab.Common.Constants.DragDropDataFormat)) {
    65153        try {
    66           // TODO
     154          var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
     155          if (data is IRegressionEnsembleModel) {
     156            data = (IRegressionEnsembleModel) data;
     157            Content.Ensembles.Add((RegressionEnsembleModel) data);
     158          }
    67159        }
    68160        catch (Exception ex) {
     
    72164    }
    73165
    74     private void ensemblesTab_DragEnter(object sender, DragEventArgs e) {
     166    private void ensemblesTab_DragEnterOver(object sender, DragEventArgs e) {
    75167      e.Effect = DragDropEffects.None;
    76       if (!e.Data.GetDataPresent(HeuristicLab.Common.Constants.DragDropDataFormat))
     168      if (ReadOnly || !e.Data.GetDataPresent(HeuristicLab.Common.Constants.DragDropDataFormat))
    77169        return;
    78170
    79171      var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
    80172
    81       // TODO: check if data is taggedEnsembles-data
    82       if(data is IRegressionEnsembleModel)
    83         e.Effect = DragDropEffects.Copy;
     173      if (data is IRegressionEnsembleModel) {
     174        if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key
     175        else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key
     176        else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
     177        else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move;
     178        else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link;
     179      }
    84180    }
    85181
     
    87183      if (e.Data.GetDataPresent(HeuristicLab.Common.Constants.DragDropDataFormat)) {
    88184        try {
    89           // TODO
     185          var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
     186          if (data is IValueParameter) data = ((IValueParameter) data).Value;
     187          if (data is IRegressionProblemData)
     188            Content.Datastream.ProblemData = (RegressionProblemData) data;
    90189        }
    91190        catch (Exception ex) {
     
    95194    }
    96195
    97     private void datastreamTab_DragEnter(object sender, DragEventArgs e) {
     196    private void datastreamTab_DragEnterOver(object sender, DragEventArgs e) {
    98197      e.Effect = DragDropEffects.None;
    99       if (!e.Data.GetDataPresent(HeuristicLab.Common.Constants.DragDropDataFormat))
     198
     199      if (ReadOnly || !e.Data.GetDataPresent(HeuristicLab.Common.Constants.DragDropDataFormat))
    100200        return;
    101201
    102202      var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
    103       if (data is IRegressionProblemData)
    104         e.Effect = DragDropEffects.Copy;
     203      if (data is IValueParameter) data = ((IValueParameter) data).Value;
     204      if (data is IRegressionProblemData) {
     205        if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key
     206        else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key
     207        else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
     208        else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move;
     209        else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link;
     210      }
    105211    }
    106212
  • branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis.Views/3.4/HeuristicLab.DatastreamAnalysis.Views.csproj

    r14491 r14536  
    5858      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Core.Views-3.3.dll</HintPath>
    5959    </Reference>
     60    <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     61      <SpecificVersion>False</SpecificVersion>
     62      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath>
     63    </Reference>
    6064    <Reference Include="HeuristicLab.MainForm-3.3">
    6165      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.MainForm-3.3.dll</HintPath>
     
    116120    </ProjectReference>
    117121  </ItemGroup>
     122  <ItemGroup>
     123    <EmbeddedResource Include="RegressionEnsembleModelView.resx">
     124      <DependentUpon>RegressionEnsembleModelView.cs</DependentUpon>
     125    </EmbeddedResource>
     126  </ItemGroup>
    118127  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    119128  <PropertyGroup>
  • branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis.Views/3.4/Plugin.cs

    r14491 r14536  
    2323
    2424namespace HeuristicLab.DatastreamAnalysis.Views {
    25   [Plugin("HeuristicLab.DatastreamAnalysis.Views", "3.4.14.14488")]
     25  [Plugin("HeuristicLab.DatastreamAnalysis.Views", "3.4.14.14491")]
    2626  [PluginFile("HeuristicLab.DatastreamAnalysis.Views-3.4.dll", PluginFileType.Assembly)]
    2727  [PluginDependency("HeuristicLab.Collections", "3.3")]
  • branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis.Views/3.4/Properties/AssemblyInfo.cs

    r14491 r14536  
    5454// [assembly: AssemblyVersion("1.0.*")]
    5555[assembly: AssemblyVersion("3.4.0.0")]
    56 [assembly: AssemblyFileVersion("3.4.14.14488")]
     56[assembly: AssemblyFileVersion("3.4.14.14491")]
  • branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis.Views/3.4/RegressionEnsembleModelView.Designer.cs

    r14488 r14536  
    1919 */
    2020#endregion
     21
     22using HeuristicLab.Core.Views;
     23using HeuristicLab.Problems.DataAnalysis;
     24
    2125namespace HeuristicLab.DatastreamAnalysis.Views {
    2226  partial class RegressionEnsembleModelView {
     
    4448    /// </summary>
    4549    private void InitializeComponent() {
     50      this.modelsView = new HeuristicLab.DatastreamAnalysis.Views.RegressionEnsembleModelView.ModelsView();
     51      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    4652      this.SuspendLayout();
    47 
     53      //
     54      // nameTextBox
     55      //
     56      this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
     57      this.errorProvider.SetIconPadding(this.nameTextBox, 2);
     58      this.nameTextBox.Size = new System.Drawing.Size(468, 20);
     59      //
     60      // infoLabel
     61      //
     62      this.infoLabel.Location = new System.Drawing.Point(532, 3);
     63      //
     64      // modelsView
     65      //
     66      this.modelsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     67            | System.Windows.Forms.AnchorStyles.Left)
     68            | System.Windows.Forms.AnchorStyles.Right)));
     69      this.modelsView.Caption = "Models View";
     70      this.modelsView.Content = null;
     71      this.modelsView.Location = new System.Drawing.Point(6, 35);
     72      this.modelsView.Name = "modelsView";
     73      this.modelsView.ReadOnly = false;
     74      this.modelsView.ShowDetails = true;
     75      this.modelsView.Size = new System.Drawing.Size(532, 383);
     76      this.modelsView.TabIndex = 1;
    4877      //
    4978      // RegressionEnsembleModelView
    5079      //
    51       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    5280      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
     81      this.Controls.Add(this.modelsView);
    5382      this.Name = "RegressionEnsembleModelView";
     83      this.Size = new System.Drawing.Size(551, 425);
     84      this.Controls.SetChildIndex(this.modelsView, 0);
     85      this.Controls.SetChildIndex(this.nameLabel, 0);
     86      this.Controls.SetChildIndex(this.nameTextBox, 0);
     87      this.Controls.SetChildIndex(this.infoLabel, 0);
     88      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    5489      this.ResumeLayout(false);
     90      this.PerformLayout();
     91
    5592    }
    5693
    5794    #endregion
     95
     96    private ModelsView modelsView;
    5897  }
    5998}
  • branches/HeuristicLab.DatastreamAnalysis/HeuristicLab.DatastreamAnalysis.Views/3.4/RegressionEnsembleModelView.cs

    r14491 r14536  
    3434  [Content(typeof(RegressionEnsembleModel), true)]
    3535  internal sealed partial class RegressionEnsembleModelView : NamedItemView {
    36     private ModelsView view;
    37     private ItemCollection<IRegressionModel> models;
     36    //private ItemCollectionView<IRegressionModel> view;
     37    private ItemCollection<IRegressionModel> models = new ItemCollection<IRegressionModel>();
    3838
    3939    public RegressionEnsembleModelView() {
    4040      InitializeComponent();
    41       view = new ModelsView();
    42       view.Dock = DockStyle.Fill;
    43       Controls.Add(view);
     41      models = new ItemCollection<IRegressionModel>();
     42
     43      models.ItemsAdded += Models_ItemsAdded;
     44      models.ItemsRemoved += Models_ItemsRemoved;
     45      models.CollectionReset += Models_CollectionReset;
     46
    4447    }
    4548
     
    4952    }
    5053
    51 
    52 
     54 
    5355    protected override void OnContentChanged() {
    5456      base.OnContentChanged();
    5557      if (Content != null) {
    56          models = new ItemCollection<IRegressionModel>(Content.Models);
    57         view.Content = models;
     58        models.ItemsAdded -= Models_ItemsAdded;
     59        models.ItemsRemoved -= Models_ItemsRemoved;
     60        models.CollectionReset -= Models_CollectionReset;
     61
     62        models.Clear();
     63        models.AddRange(Content.Models);
     64        modelsView.Content = models;
     65
     66        models.ItemsAdded += Models_ItemsAdded;
     67        models.ItemsRemoved += Models_ItemsRemoved;
     68        models.CollectionReset += Models_CollectionReset;
    5869      } else {
    59         view.Content = null;
     70        modelsView.Content = null;
    6071      }
    6172    }
    6273
     74    private void Models_CollectionReset(object sender, Collections.CollectionItemsChangedEventArgs<IRegressionModel> e) {
     75      Content = null;
     76    }
     77
     78    private void Models_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IRegressionModel> e) {
     79      Content.AddRange(e.Items);
     80    }
     81
     82    private void Models_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IRegressionModel> e) {
     83      Content.RemoveRange(e.Items);
     84    }
     85
    6386    private class ModelsView : ItemCollectionView<IRegressionModel> {
    64       protected override void SetEnabledStateOfControls() {
    65         base.SetEnabledStateOfControls();
    66         addButton.Enabled = false;
    67         removeButton.Enabled = Content != null && !Content.IsReadOnly && !Locked && !ReadOnly && itemsListView.SelectedItems.Count > 0;
    68         itemsListView.Enabled = Content != null && !Locked;
    69         detailsGroupBox.Enabled = Content != null && itemsListView.SelectedItems.Count == 1;
    70         sortAscendingButton.Enabled = false;
    71         sortDescendingButton.Enabled = false;
     87      public ModelsView() : base() {
    7288      }
     89    }
    7390
    74       protected override void SortItemsListView(SortOrder sortOrder) { }
     91    //private class ModelsView : ItemCollectionView<IRegressionModel> {
     92    //  protected override void SetEnabledStateOfControls() {
     93    //    base.SetEnabledStateOfControls();
     94    //    addButton.Enabled = false;
     95    //    removeButton.Enabled = Content != null && !Content.IsReadOnly && !Locked && !ReadOnly && itemsListView.SelectedItems.Count > 0;
     96    //    itemsListView.Enabled = Content != null && !Locked;
     97    //    detailsGroupBox.Enabled = Content != null && itemsListView.SelectedItems.Count == 1;
     98    //    sortAscendingButton.Enabled = false;
     99    //    sortDescendingButton.Enabled = false;
     100    //  }
     101
     102    //  protected override void SortItemsListView(SortOrder sortOrder) { }
    75103
    76104
    77       protected override void itemsListView_DragEnter(object sender, DragEventArgs e) {
    78         validDragOperation = false;
    79         if (ReadOnly || Locked) return;
    80         if (Content.IsReadOnly) return;
     105    //  protected override void itemsListView_DragEnter(object sender, DragEventArgs e) {
     106    //    validDragOperation = false;
     107    //    if (ReadOnly || Locked) return;
     108    //    if (Content.IsReadOnly) return;
    81109
    82         var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
    83         validDragOperation = dropData.GetObjectGraphObjects().OfType<IRegressionModel>().Any();
    84       }
    85       protected override void itemsListView_DragDrop(object sender, DragEventArgs e) {
    86         if (e.Effect != DragDropEffects.None) {
    87           var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
    88           var solutions = dropData.GetObjectGraphObjects().OfType<IRegressionModel>();
    89           if (e.Effect.HasFlag(DragDropEffects.Copy)) {
    90             Cloner cloner = new Cloner();
    91             solutions = solutions.Select(s => cloner.Clone(s));
    92           }
    93           var solutionCollection = Content as ItemCollection<IRegressionModel>;
    94           if (solutionCollection != null) {
    95             solutionCollection.AddRange(solutions);
    96           } else {
    97             foreach (var solution in solutions)
    98               Content.Add(solution);
    99           }
    100         }
    101       }
    102       protected override void itemsListView_KeyDown(object sender, KeyEventArgs e) {
    103         var solutionCollection = Content as ItemCollection<IRegressionModel>;
    104         if (e.KeyCode == Keys.Delete && solutionCollection != null) {
    105           if ((itemsListView.SelectedItems.Count > 0) && !Content.IsReadOnly && !ReadOnly) {
    106             solutionCollection.RemoveRange(itemsListView.SelectedItems.Cast<ListViewItem>().Select(x => (IRegressionModel)x.Tag));
    107           }
    108         } else {
    109           base.itemsListView_KeyDown(sender, e);
    110         }
    111       }
    112       protected override void removeButton_Click(object sender, EventArgs e) {
    113         var solutionCollection = Content as ItemCollection<IRegressionModel>;
    114         if (itemsListView.SelectedItems.Count > 0 && solutionCollection != null) {
    115           solutionCollection.RemoveRange(itemsListView.SelectedItems.Cast<ListViewItem>().Select(x => (IRegressionModel)x.Tag));
    116           itemsListView.SelectedItems.Clear();
    117         } else {
    118           base.removeButton_Click(sender, e);
    119         }
    120       }
    121 
    122 
    123     }
     110    //    var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
     111    //    validDragOperation = dropData.GetObjectGraphObjects().OfType<IRegressionModel>().Any();
     112    //  }
     113    //  protected override void itemsListView_DragDrop(object sender, DragEventArgs e) {
     114    //    if (e.Effect != DragDropEffects.None) {
     115    //      var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
     116    //      var solutions = dropData.GetObjectGraphObjects().OfType<IRegressionModel>();
     117    //      if (e.Effect.HasFlag(DragDropEffects.Copy)) {
     118    //        Cloner cloner = new Cloner();
     119    //        solutions = solutions.Select(s => cloner.Clone(s));
     120    //      }
     121    //      var solutionCollection = Content as ItemCollection<IRegressionModel>;
     122    //      if (solutionCollection != null) {
     123    //        solutionCollection.AddRange(solutions);
     124    //      } else {
     125    //        foreach (var solution in solutions)
     126    //          Content.Add(solution);
     127    //      }
     128    //    }
     129    //  }
     130    //  protected override void itemsListView_KeyDown(object sender, KeyEventArgs e) {
     131    //    var solutionCollection = Content as ItemCollection<IRegressionModel>;
     132    //    if (e.KeyCode == Keys.Delete && solutionCollection != null) {
     133    //      if ((itemsListView.SelectedItems.Count > 0) && !Content.IsReadOnly && !ReadOnly) {
     134    //        solutionCollection.RemoveRange(itemsListView.SelectedItems.Cast<ListViewItem>().Select(x => (IRegressionModel)x.Tag));
     135    //      }
     136    //    } else {
     137    //      base.itemsListView_KeyDown(sender, e);
     138    //    }
     139    //  }
     140    //  protected override void removeButton_Click(object sender, EventArgs e) {
     141    //    var solutionCollection = Content as ItemCollection<IRegressionModel>;
     142    //    if (itemsListView.SelectedItems.Count > 0 && solutionCollection != null) {
     143    //      solutionCollection.RemoveRange(itemsListView.SelectedItems.Cast<ListViewItem>().Select(x => (IRegressionModel)x.Tag));
     144    //      itemsListView.SelectedItems.Clear();
     145    //    } else {
     146    //      base.removeButton_Click(sender, e);
     147    //    }
     148    //  }
     149    //}
    124150
    125151  }
Note: See TracChangeset for help on using the changeset viewer.