Changeset 15997


Ignore:
Timestamp:
07/19/18 15:20:50 (14 months ago)
Author:
mkommend
Message:

#2890: Merged r15730, r15782 into stable.

Location:
stable
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Algorithms.DataAnalysis.Views

  • stable/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/GradientBoostedTreesModelView.Designer.cs

    r15584 r15997  
    4545    /// </summary>
    4646    private void InitializeComponent() {
     47      this.groupBoxVisualisation = new System.Windows.Forms.GroupBox();
    4748      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    48       this.listBox = new System.Windows.Forms.ListBox();
     49      this.listView = new System.Windows.Forms.ListView();
     50      this.columnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
     51      this.groupBoxVisualisation.SuspendLayout();
    4952      this.SuspendLayout();
     53      //
     54      // groupBoxVisualisation
     55      //
     56      this.groupBoxVisualisation.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     57            | System.Windows.Forms.AnchorStyles.Left)
     58            | System.Windows.Forms.AnchorStyles.Right)));
     59      this.groupBoxVisualisation.Controls.Add(this.viewHost);
     60      this.groupBoxVisualisation.Location = new System.Drawing.Point(169, 3);
     61      this.groupBoxVisualisation.Name = "groupBoxVisualisation";
     62      this.groupBoxVisualisation.Size = new System.Drawing.Size(177, 277);
     63      this.groupBoxVisualisation.TabIndex = 2;
     64      this.groupBoxVisualisation.TabStop = false;
     65      this.groupBoxVisualisation.Text = "Representation";
    5066      //
    5167      // viewHost
    5268      //
    53       this.viewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    54             | System.Windows.Forms.AnchorStyles.Left)
    55             | System.Windows.Forms.AnchorStyles.Right)));
    5669      this.viewHost.Caption = "View";
    5770      this.viewHost.Content = null;
     71      this.viewHost.Dock = System.Windows.Forms.DockStyle.Fill;
    5872      this.viewHost.Enabled = false;
    59       this.viewHost.Location = new System.Drawing.Point(126, 3);
     73      this.viewHost.Location = new System.Drawing.Point(3, 16);
    6074      this.viewHost.Name = "viewHost";
    6175      this.viewHost.ReadOnly = false;
    62       this.viewHost.Size = new System.Drawing.Size(220, 277);
     76      this.viewHost.Size = new System.Drawing.Size(171, 258);
    6377      this.viewHost.TabIndex = 0;
    6478      this.viewHost.ViewsLabelVisible = true;
    6579      this.viewHost.ViewType = null;
    6680      //
    67       // listBox
     81      // listView
    6882      //
    69       this.listBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     83      this.listView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    7084            | System.Windows.Forms.AnchorStyles.Left)));
    71       this.listBox.Location = new System.Drawing.Point(3, 3);
    72       this.listBox.Name = "listBox";
    73       this.listBox.Size = new System.Drawing.Size(117, 277);
    74       this.listBox.TabIndex = 1;
    75       this.listBox.SelectedIndexChanged += new System.EventHandler(this.listBox_SelectedIndexChanged);
    76       this.listBox.DoubleClick += new System.EventHandler(this.listBox_DoubleClick);
     85      this.listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
     86            this.columnHeader});
     87      this.listView.FullRowSelect = true;
     88      this.listView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
     89      this.listView.LabelWrap = false;
     90      this.listView.Location = new System.Drawing.Point(3, 9);
     91      this.listView.MultiSelect = false;
     92      this.listView.Name = "listView";
     93      this.listView.ShowGroups = false;
     94      this.listView.Size = new System.Drawing.Size(160, 271);
     95      this.listView.TabIndex = 1;
     96      this.listView.UseCompatibleStateImageBehavior = false;
     97      this.listView.View = System.Windows.Forms.View.Details;
     98      this.listView.SelectedIndexChanged += new System.EventHandler(this.listView_SelectedIndexChanged);
     99      this.listView.DoubleClick += new System.EventHandler(this.listView_DoubleClick);
     100      //
     101      // columnHeader
     102      //
     103      this.columnHeader.Width = 130;
    77104      //
    78105      // GradientBoostedTreesModelView
     
    80107      this.AllowDrop = true;
    81108      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    82       this.Controls.Add(this.viewHost);
    83       this.Controls.Add(this.listBox);
     109      this.Controls.Add(this.groupBoxVisualisation);
     110      this.Controls.Add(this.listView);
    84111      this.Name = "GradientBoostedTreesModelView";
    85112      this.Size = new System.Drawing.Size(349, 289);
     113      this.groupBoxVisualisation.ResumeLayout(false);
    86114      this.ResumeLayout(false);
    87115
     
    91119
    92120    private MainForm.WindowsForms.ViewHost viewHost;
    93     private System.Windows.Forms.ListBox listBox;
    94 
    95 
    96 
    97 
     121    private System.Windows.Forms.ListView listView;
     122    private System.Windows.Forms.GroupBox groupBoxVisualisation;
     123    private System.Windows.Forms.ColumnHeader columnHeader;
    98124  }
    99125}
  • stable/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/GradientBoostedTreesModelView.cs

    r15584 r15997  
    2020#endregion
    2121
     22using System;
     23using System.Diagnostics;
     24using System.Linq;
     25using System.Windows.Forms;
    2226using HeuristicLab.Common;
    2327using HeuristicLab.Core.Views;
    2428using HeuristicLab.MainForm;
    2529using HeuristicLab.MainForm.WindowsForms;
    26 using HeuristicLab.Problems.DataAnalysis;                 
     30using HeuristicLab.Problems.DataAnalysis;
    2731
    2832namespace HeuristicLab.Algorithms.DataAnalysis.Views {
     
    3034  [Content(typeof(IGradientBoostedTreesModel), true)]
    3135  public partial class GradientBoostedTreesModelView : ItemView {
    32 
     36    #region Getter/Setter
    3337    public new IGradientBoostedTreesModel Content {
    3438      get { return (IGradientBoostedTreesModel)base.Content; }
    3539      set { base.Content = value; }
    3640    }
     41    #endregion
    3742
    38     protected override void SetEnabledStateOfControls() {
    39       base.SetEnabledStateOfControls();
    40       listBox.Enabled = Content != null;
    41       viewHost.Enabled = Content != null;
    42     }
    43 
     43    #region Ctor
    4444    public GradientBoostedTreesModelView()
    4545      : base() {
    4646      InitializeComponent();
     47    }
     48    #endregion
     49
     50    #region Events
     51    protected override void SetEnabledStateOfControls() {
     52      base.SetEnabledStateOfControls();
     53      listView.Enabled = Content != null;
     54      viewHost.Enabled = Content != null;
    4755    }
    4856
     
    5159      if (Content == null) {
    5260        viewHost.Content = null;
    53         listBox.Items.Clear();
     61        listView.Items.Clear();
    5462      } else {
    5563        viewHost.Content = null;
    56         listBox.Items.Clear();
    57         foreach (var e in Content.Models) {
    58           listBox.Items.Add(e);
    59         }
     64        listView.BeginUpdate();
     65        listView.Items.Clear();
     66        int i = 1;
     67        listView.Items.AddRange(
     68          new ListViewItem(Content.Models.First().ToString()) { Tag = Content.Models.First() }.ToEnumerable()
     69          .Union(Content.Models.Skip(1).Select(v => new ListViewItem("Model " + i++) { Tag = v }))
     70          .ToArray()
     71        );
     72        listView.EndUpdate();
    6073      }
    6174    }
    6275
    63     private void listBox_SelectedIndexChanged(object sender, System.EventArgs e) {
    64       var model = listBox.SelectedItem;
    65       if (model == null) viewHost.Content = null;
    66       else {
    67         viewHost.Content = ConvertModel(model);
     76
     77    private void listView_SelectedIndexChanged(object sender, EventArgs e) {
     78      if (listView.SelectedItems.Count == 1) {
     79        var item = listView.SelectedItems[0];
     80        viewHost.Content = ConvertModel(item);
    6881      }
    6982    }
    7083
    71     private void listBox_DoubleClick(object sender, System.EventArgs e) {
    72       var selectedItem = listBox.SelectedItem;
    73       if (selectedItem == null) return;
    74       MainFormManager.MainForm.ShowContent(ConvertModel(selectedItem));
    75     }
    76 
    77     private IContent ConvertModel(object model) {
    78       var treeModel = model as RegressionTreeModel;
    79       if (treeModel != null)
    80         return treeModel.CreateSymbolicRegressionModel();
    81       else {
    82         var regModel = model as IRegressionModel;
    83         return regModel;
     84    private void listView_DoubleClick(object sender, EventArgs e) {
     85      if (listView.SelectedItems.Count == 1) {
     86        var item = listView.SelectedItems[0];
     87        var content = ConvertModel(item);
     88        if (content != null) { MainFormManager.MainForm.ShowContent(content); }
    8489      }
    8590    }
     91    #endregion
     92
     93    #region Helper Methods
     94    private IContent ConvertModel(ListViewItem item) {
     95      if (item.Tag is RegressionTreeModel) {
     96        return (item.Tag as RegressionTreeModel).CreateSymbolicRegressionModel();
     97      } else if (item.Tag is IRegressionModel) {
     98        return item.Tag as IRegressionModel;
     99      } else {
     100        return null;
     101      }
     102    }
     103    #endregion
    86104  }
    87105}
Note: See TracChangeset for help on using the changeset viewer.