Changeset 10000 for trunk/sources/HeuristicLab.Optimization.Views
- Timestamp:
- 09/24/13 11:49:28 (11 years ago)
- Location:
- trunk/sources/HeuristicLab.Optimization.Views/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemView.Designer.cs
r9456 r10000 46 46 private void InitializeComponent() { 47 47 this.problemInstanceSplitContainer = new System.Windows.Forms.SplitContainer(); 48 this.ProblemInstanceConsumerViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 48 this.libraryLabel = new System.Windows.Forms.Label(); 49 this.problemInstanceProviderComboBox = new System.Windows.Forms.ComboBox(); 50 this.problemInstanceProviderViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 49 51 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 50 52 ((System.ComponentModel.ISupportInitialize)(this.problemInstanceSplitContainer)).BeginInit(); … … 87 89 // problemInstanceSplitContainer.Panel1 88 90 // 89 this.problemInstanceSplitContainer.Panel1.Controls.Add(this.ProblemInstanceConsumerViewHost); 91 this.problemInstanceSplitContainer.Panel1.Controls.Add(this.libraryLabel); 92 this.problemInstanceSplitContainer.Panel1.Controls.Add(this.problemInstanceProviderComboBox); 93 this.problemInstanceSplitContainer.Panel1.Controls.Add(this.problemInstanceProviderViewHost); 90 94 this.problemInstanceSplitContainer.Panel1MinSize = 10; 91 95 // … … 100 104 this.problemInstanceSplitContainer.TabIndex = 13; 101 105 // 102 // ProblemInstanceConsumerViewHost106 // libraryLabel 103 107 // 104 this.ProblemInstanceConsumerViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 108 this.libraryLabel.AutoSize = true; 109 this.libraryLabel.Location = new System.Drawing.Point(3, 6); 110 this.libraryLabel.Name = "libraryLabel"; 111 this.libraryLabel.Size = new System.Drawing.Size(41, 13); 112 this.libraryLabel.TabIndex = 17; 113 this.libraryLabel.Text = "Library:"; 114 // 115 // problemInstanceProviderComboBox 116 // 117 this.problemInstanceProviderComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 118 this.problemInstanceProviderComboBox.FormattingEnabled = true; 119 this.problemInstanceProviderComboBox.Location = new System.Drawing.Point(50, 2); 120 this.problemInstanceProviderComboBox.Name = "problemInstanceProviderComboBox"; 121 this.problemInstanceProviderComboBox.Size = new System.Drawing.Size(208, 21); 122 this.problemInstanceProviderComboBox.TabIndex = 18; 123 this.problemInstanceProviderComboBox.SelectedIndexChanged += new System.EventHandler(this.problemInstanceProviderComboBox_SelectedIndexChanged); 124 // 125 // problemInstanceProviderViewHost 126 // 127 this.problemInstanceProviderViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 105 128 | System.Windows.Forms.AnchorStyles.Left) 106 129 | System.Windows.Forms.AnchorStyles.Right))); 107 this. ProblemInstanceConsumerViewHost.Caption = "ProblemInstanceConsumerView";108 this. ProblemInstanceConsumerViewHost.Content = null;109 this. ProblemInstanceConsumerViewHost.Enabled = false;110 this. ProblemInstanceConsumerViewHost.Location = new System.Drawing.Point(0, 1);111 this. ProblemInstanceConsumerViewHost.Name = "ProblemInstanceConsumerViewHost";112 this. ProblemInstanceConsumerViewHost.ReadOnly = false;113 this. ProblemInstanceConsumerViewHost.Size = new System.Drawing.Size(511, 23);114 this. ProblemInstanceConsumerViewHost.TabIndex = 0;115 this. ProblemInstanceConsumerViewHost.ViewsLabelVisible = false;116 this. ProblemInstanceConsumerViewHost.ViewType = null;130 this.problemInstanceProviderViewHost.Caption = "ProblemInstanceConsumerView"; 131 this.problemInstanceProviderViewHost.Content = null; 132 this.problemInstanceProviderViewHost.Enabled = false; 133 this.problemInstanceProviderViewHost.Location = new System.Drawing.Point(264, 1); 134 this.problemInstanceProviderViewHost.Name = "problemInstanceProviderViewHost"; 135 this.problemInstanceProviderViewHost.ReadOnly = false; 136 this.problemInstanceProviderViewHost.Size = new System.Drawing.Size(247, 23); 137 this.problemInstanceProviderViewHost.TabIndex = 0; 138 this.problemInstanceProviderViewHost.ViewsLabelVisible = false; 139 this.problemInstanceProviderViewHost.ViewType = null; 117 140 // 118 141 // ProblemView 119 142 // 120 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);121 143 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 122 144 this.Controls.Add(this.problemInstanceSplitContainer); … … 125 147 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 126 148 this.problemInstanceSplitContainer.Panel1.ResumeLayout(false); 149 this.problemInstanceSplitContainer.Panel1.PerformLayout(); 127 150 this.problemInstanceSplitContainer.Panel2.ResumeLayout(false); 128 151 this.problemInstanceSplitContainer.Panel2.PerformLayout(); … … 136 159 137 160 protected System.Windows.Forms.SplitContainer problemInstanceSplitContainer; 138 protected HeuristicLab.MainForm.WindowsForms.ViewHost ProblemInstanceConsumerViewHost; 161 protected HeuristicLab.MainForm.WindowsForms.ViewHost problemInstanceProviderViewHost; 162 protected System.Windows.Forms.Label libraryLabel; 163 protected System.Windows.Forms.ComboBox problemInstanceProviderComboBox; 139 164 } 140 165 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemView.cs
r9456 r10000 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using System.Windows.Forms;26 25 using HeuristicLab.Core.Views; 27 26 using HeuristicLab.MainForm; … … 37 36 public partial class ProblemView : ParameterizedNamedItemView { 38 37 39 private static Type neededViewType = typeof(ProblemInstanceConsumerView);40 41 38 public new IProblem Content { 42 39 get { return (IProblem)base.Content; } 43 40 set { base.Content = value; } 44 41 } 42 43 protected IEnumerable<IProblemInstanceProvider> problemInstanceProviders; 44 public IEnumerable<IProblemInstanceProvider> ProblemInstanceProviders { 45 get { return new List<IProblemInstanceProvider>(problemInstanceProviders); } 46 } 47 48 public IProblemInstanceProvider SelectedProvider { get; protected set; } 45 49 46 50 /// <summary> … … 53 57 protected override void OnContentChanged() { 54 58 base.OnContentChanged(); 55 IProblemInstanceConsumer consumer = Content as IProblemInstanceConsumer; 56 if (consumer != null) { 57 IEnumerable<Type> viewTypes = MainFormManager.GetViewTypes(consumer.GetType(), true); 58 Type genericView = viewTypes.Where(x => x.IsSubclassOf(neededViewType)).First(); 59 ProblemInstanceConsumerViewHost.Content = null; //necessary to enable the change of the ViewType 60 ProblemInstanceConsumerViewHost.ViewType = genericView; 61 ProblemInstanceConsumerViewHost.Content = consumer; 62 ProblemInstanceConsumerView view = (ProblemInstanceConsumerView)ProblemInstanceConsumerViewHost.ActiveView; 63 problemInstanceSplitContainer.Panel1Collapsed = !view.ProblemInstanceProviders.Any(); 59 if (Content == null) { 60 problemInstanceProviders = null; 61 problemInstanceProviderComboBox.DataSource = null; 62 problemInstanceSplitContainer.Panel1Collapsed = true; 64 63 } else { 65 problemInstanceSplitContainer.Panel1Collapsed = true; 64 var consumer = Content as IProblemInstanceConsumer; 65 if (consumer != null) { 66 problemInstanceProviders = ProblemInstanceManager.GetProviders(Content); 67 bool expand = problemInstanceProviders.Any(); 68 if (expand) { 69 problemInstanceProviderComboBox.DisplayMember = "Name"; 70 problemInstanceProviderComboBox.DataSource = ProblemInstanceProviders.OrderBy(x => x.Name).ToList(); 71 } 72 problemInstanceSplitContainer.Panel1Collapsed = !expand; 73 } 66 74 } 67 75 SetEnabledStateOfControls(); 68 76 } 69 77 78 protected virtual void problemInstanceProviderComboBox_SelectedIndexChanged(object sender, System.EventArgs e) { 79 if (problemInstanceProviderComboBox.SelectedIndex >= 0) { 80 SelectedProvider = (IProblemInstanceProvider)problemInstanceProviderComboBox.SelectedItem; 81 problemInstanceProviderViewHost.Content = SelectedProvider; 82 var view = (ProblemInstanceProviderView)problemInstanceProviderViewHost.ActiveView; 83 var consumer = (IProblemInstanceConsumer)Content; 84 view.Consumer = consumer; 85 if (CheckForIProblemInstanceExporter(consumer)) 86 view.Exporter = (IProblemInstanceExporter)Content; 87 else view.Exporter = null; 88 SetTooltip(); 89 } else { 90 SelectedProvider = null; 91 } 92 SetEnabledStateOfControls(); 93 } 94 95 protected bool CheckForIProblemInstanceExporter(IProblemInstanceConsumer content) { 96 return Content.GetType().GetInterfaces() 97 .Any(x => x == typeof(IProblemInstanceExporter)); 98 } 99 100 #region ToolTip 101 protected void SetTooltip() { 102 toolTip.SetToolTip(problemInstanceProviderComboBox, GetProviderToolTip()); 103 } 104 105 private string GetProviderToolTip() { 106 var provider = SelectedProvider; 107 string toolTip = provider.Name; 108 109 if (!String.IsNullOrEmpty(provider.ReferencePublication)) { 110 toolTip = toolTip 111 + Environment.NewLine + Environment.NewLine 112 + provider.ReferencePublication; 113 } 114 if (provider.WebLink != null) { 115 toolTip = toolTip 116 + Environment.NewLine 117 + provider.WebLink.ToString(); 118 } 119 120 return toolTip; 121 } 122 #endregion 70 123 } 71 124 }
Note: See TracChangeset
for help on using the changeset viewer.