[15106] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[15583] | 3 | * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[15106] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
[15730] | 22 | using System;
|
---|
| 23 | using System.Diagnostics;
|
---|
| 24 | using System.Linq;
|
---|
| 25 | using System.Windows.Forms;
|
---|
[15106] | 26 | using HeuristicLab.Common;
|
---|
[15124] | 27 | using HeuristicLab.Core.Views;
|
---|
[15106] | 28 | using HeuristicLab.MainForm;
|
---|
| 29 | using HeuristicLab.MainForm.WindowsForms;
|
---|
[15730] | 30 | using HeuristicLab.Problems.DataAnalysis;
|
---|
[15106] | 31 |
|
---|
| 32 | namespace HeuristicLab.Algorithms.DataAnalysis.Views {
|
---|
| 33 | [View("Gradient boosted trees model")]
|
---|
| 34 | [Content(typeof(IGradientBoostedTreesModel), true)]
|
---|
[15124] | 35 | public partial class GradientBoostedTreesModelView : ItemView {
|
---|
[15730] | 36 | #region Getter/Setter
|
---|
[15106] | 37 | public new IGradientBoostedTreesModel Content {
|
---|
| 38 | get { return (IGradientBoostedTreesModel)base.Content; }
|
---|
| 39 | set { base.Content = value; }
|
---|
| 40 | }
|
---|
[15730] | 41 | #endregion
|
---|
[15106] | 42 |
|
---|
[15730] | 43 | #region Ctor
|
---|
| 44 | public GradientBoostedTreesModelView()
|
---|
| 45 | : base() {
|
---|
| 46 | InitializeComponent();
|
---|
| 47 | }
|
---|
| 48 | #endregion
|
---|
| 49 |
|
---|
| 50 | #region Events
|
---|
[15106] | 51 | protected override void SetEnabledStateOfControls() {
|
---|
| 52 | base.SetEnabledStateOfControls();
|
---|
[15730] | 53 | listView.Enabled = Content != null;
|
---|
[15106] | 54 | viewHost.Enabled = Content != null;
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | protected override void OnContentChanged() {
|
---|
| 58 | base.OnContentChanged();
|
---|
| 59 | if (Content == null) {
|
---|
| 60 | viewHost.Content = null;
|
---|
[15730] | 61 | listView.Items.Clear();
|
---|
[15106] | 62 | } else {
|
---|
| 63 | viewHost.Content = null;
|
---|
[15730] | 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();
|
---|
[15106] | 73 | }
|
---|
| 74 | }
|
---|
| 75 |
|
---|
[15730] | 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);
|
---|
[15106] | 81 | }
|
---|
| 82 | }
|
---|
| 83 |
|
---|
[15730] | 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); }
|
---|
| 89 | }
|
---|
[15106] | 90 | }
|
---|
[15730] | 91 | #endregion
|
---|
[15106] | 92 |
|
---|
[15730] | 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;
|
---|
[15106] | 101 | }
|
---|
| 102 | }
|
---|
[15730] | 103 | #endregion
|
---|
[15106] | 104 | }
|
---|
| 105 | }
|
---|