Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/17/11 14:37:34 (13 years ago)
Author:
mkommend
Message:

#1592: Enabled creation of empty ensemble solutions and problem data changes.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Classification/ClassificationEnsembleSolutionModelView.cs

    r6642 r6666  
    1919 */
    2020#endregion
     21
     22using System.Linq;
    2123using System.Windows.Forms;
     24using HeuristicLab.Common;
    2225using HeuristicLab.Core.Views;
    2326using HeuristicLab.MainForm;
     
    4447    protected override void OnContentChanged() {
    4548      base.OnContentChanged();
    46       if (Content != null)
     49      if (Content != null) {
     50        view.Locked = Content.ProblemData == ClassificationEnsembleProblemData.EmptyProblemData;
    4751        view.Content = Content.ClassificationSolutions;
    48       else
     52      } else
    4953        view.Content = null;
    5054    }
     
    6266        detailsGroupBox.Enabled = Content != null && itemsListView.SelectedItems.Count == 1;
    6367      }
     68
     69      protected override void itemsListView_DragEnter(object sender, DragEventArgs e) {
     70        validDragOperation = false;
     71        if (ReadOnly || Locked) return;
     72        if (Content.IsReadOnly) return;
     73
     74        var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
     75        validDragOperation = dropData.GetObjectGraphObjects().OfType<IClassificationSolution>().Any();
     76      }
     77      protected override void itemsListView_DragDrop(object sender, DragEventArgs e) {
     78        if (e.Effect != DragDropEffects.None) {
     79          var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
     80          var solutions = dropData.GetObjectGraphObjects().OfType<IClassificationSolution>();
     81          if (e.Effect.HasFlag(DragDropEffects.Copy)) {
     82            Cloner cloner = new Cloner();
     83            solutions = solutions.Select(s => cloner.Clone(s));
     84          }
     85          foreach (var solution in solutions)
     86            Content.Add(solution);
     87        }
     88      }
    6489    }
    6590  }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj

    r6652 r6666  
    182182      <DependentUpon>ClusteringSolutionView.cs</DependentUpon>
    183183    </Compile>
     184    <Compile Include="Solution Views\ClassificationEnsembleSolutionView.cs">
     185      <SubType>UserControl</SubType>
     186    </Compile>
     187    <Compile Include="Solution Views\ClassificationEnsembleSolutionView.Designer.cs">
     188      <DependentUpon>ClassificationEnsembleSolutionView.cs</DependentUpon>
     189    </Compile>
    184190    <Compile Include="Solution Views\DiscriminantFunctionClassificationSolutionView.cs">
    185191      <SubType>UserControl</SubType>
     
    207213    <Compile Include="Solution Views\NamedDataAnalysisSolutionView.Designer.cs">
    208214      <DependentUpon>NamedDataAnalysisSolutionView.cs</DependentUpon>
     215    </Compile>
     216    <Compile Include="Solution Views\RegressionEnsembleSolutionView.cs">
     217      <SubType>UserControl</SubType>
     218    </Compile>
     219    <Compile Include="Solution Views\RegressionEnsembleSolutionView.Designer.cs">
     220      <DependentUpon>RegressionEnsembleSolutionView.cs</DependentUpon>
    209221    </Compile>
    210222    <Compile Include="Solution Views\RegressionSolutionView.cs">
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionEnsembleSolutionModelView.cs

    r6642 r6666  
    1919 */
    2020#endregion
     21
     22using System.Linq;
    2123using System.Windows.Forms;
     24using HeuristicLab.Common;
    2225using HeuristicLab.Core.Views;
    2326using HeuristicLab.MainForm;
     
    4447    protected override void OnContentChanged() {
    4548      base.OnContentChanged();
    46       if (Content != null)
     49      if (Content != null) {
     50        view.Locked = Content.ProblemData == RegressionEnsembleProblemData.EmptyProblemData;
    4751        view.Content = Content.RegressionSolutions;
    48       else
     52      } else
    4953        view.Content = null;
    5054    }
     
    5963        addButton.Enabled = Content != null && !Content.IsReadOnly && !Locked;
    6064        removeButton.Enabled = Content != null && !Content.IsReadOnly && !Locked && itemsListView.SelectedItems.Count > 0;
    61         itemsListView.Enabled = Content != null;
     65        itemsListView.Enabled = Content != null && !Locked;
    6266        detailsGroupBox.Enabled = Content != null && itemsListView.SelectedItems.Count == 1;
     67      }
     68
     69      protected override void itemsListView_DragEnter(object sender, DragEventArgs e) {
     70        validDragOperation = false;
     71        if (ReadOnly || Locked) return;
     72        if (Content.IsReadOnly) return;
     73
     74        var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
     75        validDragOperation = dropData.GetObjectGraphObjects().OfType<IRegressionSolution>().Any();
     76      }
     77      protected override void itemsListView_DragDrop(object sender, DragEventArgs e) {
     78        if (e.Effect != DragDropEffects.None) {
     79          var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
     80          var solutions = dropData.GetObjectGraphObjects().OfType<IRegressionSolution>();
     81          if (e.Effect.HasFlag(DragDropEffects.Copy)) {
     82            Cloner cloner = new Cloner();
     83            solutions = solutions.Select(s => cloner.Clone(s));
     84          }
     85          foreach (var solution in solutions)
     86            Content.Add(solution);
     87        }
    6388      }
    6489    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/ClassificationSolutionView.cs

    r6653 r6666  
    2121
    2222using System.Windows.Forms;
     23using HeuristicLab.Core;
    2324using HeuristicLab.MainForm;
    2425
     
    3940    protected override void itemsListView_DragEnter(object sender, DragEventArgs e) {
    4041      validDragOperation = false;
    41       if (!ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is ClassificationProblemData)) {
    42         validDragOperation = true;
     42      if (ReadOnly) return;
     43
     44      var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
     45      if (dropData is ClassificationProblemData) validDragOperation = true;
     46      else if (dropData is IValueParameter) {
     47        var param = (IValueParameter)dropData;
     48        if (param.Value is ClassificationProblemData) validDragOperation = true;
    4349      }
    4450    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.cs

    r6653 r6666  
    4444    }
    4545
     46    protected override void SetEnabledStateOfControls() {
     47      base.SetEnabledStateOfControls();
     48      addButton.Enabled = false;
     49      removeButton.Enabled = false;
     50    }
     51
     52    protected override void RegisterContentEvents() {
     53      base.RegisterContentEvents();
     54      Content.ProblemDataChanged += new EventHandler(Content_ProblemDataChanged);
     55    }
     56    protected override void DeregisterContentEvents() {
     57      base.DeregisterContentEvents();
     58      Content.ProblemDataChanged -= new EventHandler(Content_ProblemDataChanged);
     59    }
     60    private void Content_ProblemDataChanged(object sender, EventArgs e) {
     61      OnContentChanged();
     62    }
     63
    4664    protected override void OnContentChanged() {
    4765      string selectedName = null;
     
    6684
    6785    protected virtual void AddEvaluationViewTypes() {
    68       if (Content != null) {
     86      if (Content != null && !Content.ProblemData.IsEmpty) {
    6987        var viewTypes = MainFormManager.GetViewTypes(Content.GetType(), true)
    7088          .Where(t => typeof(IDataAnalysisSolutionEvaluationView).IsAssignableFrom(t));
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.cs

    r6653 r6666  
    2121
    2222using System.Windows.Forms;
     23using HeuristicLab.Core;
    2324using HeuristicLab.MainForm;
    2425
     
    3940    protected override void itemsListView_DragEnter(object sender, DragEventArgs e) {
    4041      validDragOperation = false;
    41       if (!ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is RegressionProblemData)) {
    42         validDragOperation = true;
     42      if (ReadOnly) return;
     43
     44      var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
     45      if (dropData is RegressionProblemData) validDragOperation = true;
     46      else if (dropData is IValueParameter) {
     47        var param = (IValueParameter)dropData;
     48        if (param.Value is RegressionProblemData) validDragOperation = true;
    4349      }
    4450    }
Note: See TracChangeset for help on using the changeset viewer.