Changeset 15730
- Timestamp:
- 02/07/18 14:27:54 (7 years ago)
- Location:
- trunk/HeuristicLab.Algorithms.DataAnalysis.Views/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/GradientBoostedTreesModelView.Designer.cs
r15583 r15730 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.groupBoxVisualisation = new System.Windows.Forms.GroupBox(); 47 48 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(); 49 52 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 = "Visualization"; 50 66 // 51 67 // viewHost 52 68 // 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)));56 69 this.viewHost.Caption = "View"; 57 70 this.viewHost.Content = null; 71 this.viewHost.Dock = System.Windows.Forms.DockStyle.Fill; 58 72 this.viewHost.Enabled = false; 59 this.viewHost.Location = new System.Drawing.Point( 126, 3);73 this.viewHost.Location = new System.Drawing.Point(3, 16); 60 74 this.viewHost.Name = "viewHost"; 61 75 this.viewHost.ReadOnly = false; 62 this.viewHost.Size = new System.Drawing.Size( 220, 277);76 this.viewHost.Size = new System.Drawing.Size(171, 258); 63 77 this.viewHost.TabIndex = 0; 64 78 this.viewHost.ViewsLabelVisible = true; 65 79 this.viewHost.ViewType = null; 66 80 // 67 // list Box81 // listView 68 82 // 69 this.list Box.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) 70 84 | 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, 3); 91 this.listView.MultiSelect = false; 92 this.listView.Name = "listView"; 93 this.listView.ShowGroups = false; 94 this.listView.Size = new System.Drawing.Size(160, 283); 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; 77 104 // 78 105 // GradientBoostedTreesModelView … … 80 107 this.AllowDrop = true; 81 108 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 82 this.Controls.Add(this. viewHost);83 this.Controls.Add(this.list Box);109 this.Controls.Add(this.groupBoxVisualisation); 110 this.Controls.Add(this.listView); 84 111 this.Name = "GradientBoostedTreesModelView"; 85 112 this.Size = new System.Drawing.Size(349, 289); 113 this.groupBoxVisualisation.ResumeLayout(false); 86 114 this.ResumeLayout(false); 87 115 … … 91 119 92 120 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; 98 124 } 99 125 } -
trunk/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/GradientBoostedTreesModelView.cs
r15583 r15730 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.