Changeset 16311 for branches/2845_EnhancedProgress/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/GradientBoostedTreesModelView.cs
- Timestamp:
- 11/20/18 15:26:57 (6 years ago)
- Location:
- branches/2845_EnhancedProgress
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2845_EnhancedProgress
- Property svn:mergeinfo changed
-
branches/2845_EnhancedProgress/HeuristicLab.Algorithms.DataAnalysis.Views
- Property svn:mergeinfo changed
-
branches/2845_EnhancedProgress/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/GradientBoostedTreesModelView.cs
r16308 r16311 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 6Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System; 23 using System.Diagnostics; 24 using System.Linq; 25 using System.Windows.Forms; 22 26 using HeuristicLab.Common; 23 27 using HeuristicLab.Core.Views; 24 28 using HeuristicLab.MainForm; 25 29 using HeuristicLab.MainForm.WindowsForms; 26 using HeuristicLab.Problems.DataAnalysis; 30 using HeuristicLab.Problems.DataAnalysis; 27 31 28 32 namespace HeuristicLab.Algorithms.DataAnalysis.Views { … … 30 34 [Content(typeof(IGradientBoostedTreesModel), true)] 31 35 public partial class GradientBoostedTreesModelView : ItemView { 32 36 #region Getter/Setter 33 37 public new IGradientBoostedTreesModel Content { 34 38 get { return (IGradientBoostedTreesModel)base.Content; } 35 39 set { base.Content = value; } 36 40 } 41 #endregion 37 42 38 protected override void SetEnabledStateOfControls() { 39 base.SetEnabledStateOfControls(); 40 listBox.Enabled = Content != null; 41 viewHost.Enabled = Content != null; 42 } 43 43 #region Ctor 44 44 public GradientBoostedTreesModelView() 45 45 : base() { 46 46 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; 47 55 } 48 56 … … 51 59 if (Content == null) { 52 60 viewHost.Content = null; 53 list Box.Items.Clear();61 listView.Items.Clear(); 54 62 } else { 55 63 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(); 60 73 } 61 74 } 62 75 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); 68 81 } 69 82 } 70 83 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); } 84 89 } 85 90 } 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 86 104 } 87 105 }
Note: See TracChangeset
for help on using the changeset viewer.