Changeset 7641 for trunk/sources/HeuristicLab.Optimization.Views/3.3
- Timestamp:
- 03/20/12 17:26:56 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Optimization.Views/3.3
- Files:
-
- 2 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj
r7558 r7641 264 264 <DependentUpon>EngineAlgorithmView.cs</DependentUpon> 265 265 </Compile> 266 <Compile Include="HeuristicOptimizationProblemView.cs">267 <SubType>UserControl</SubType>268 </Compile>269 <Compile Include="HeuristicOptimizationProblemView.Designer.cs">270 <DependentUpon>HeuristicOptimizationProblemView.cs</DependentUpon>271 </Compile>272 266 <Compile Include="Properties\AssemblyInfo.cs" /> 273 267 <Compile Include="ResultCollectionView.cs"> -
trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemInstanceProviderView.cs
r7558 r7641 45 45 toolTip.SetToolTip(importButton, "Import a " + GetProblemType() + " instance from file."); 46 46 loadButton.Text = String.Empty; 47 loadButton.Image = VSImageLibrary. Checkout;47 loadButton.Image = VSImageLibrary.RefreshDocument; 48 48 toolTip.SetToolTip(loadButton, "Load the selected instance."); 49 49 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemView.Designer.cs
r7259 r7641 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.problemInstanceProviderComboBox = new System.Windows.Forms.ComboBox(); 48 this.libraryLabel = new System.Windows.Forms.Label(); 49 this.libraryInfoButton = new System.Windows.Forms.Button(); 50 this.problemInstanceSplitContainer = new System.Windows.Forms.SplitContainer(); 51 this.problemInstanceProviderViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 47 52 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 53 ((System.ComponentModel.ISupportInitialize)(this.problemInstanceSplitContainer)).BeginInit(); 54 this.problemInstanceSplitContainer.Panel1.SuspendLayout(); 55 this.problemInstanceSplitContainer.Panel2.SuspendLayout(); 56 this.problemInstanceSplitContainer.SuspendLayout(); 48 57 this.SuspendLayout(); 58 // 59 // parameterCollectionView 60 // 61 this.parameterCollectionView.Location = new System.Drawing.Point(6, 27); 62 this.parameterCollectionView.Size = new System.Drawing.Size(501, 303); 49 63 // 50 64 // nameTextBox … … 52 66 this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft); 53 67 this.errorProvider.SetIconPadding(this.nameTextBox, 2); 68 this.nameTextBox.Location = new System.Drawing.Point(47, 1); 69 this.nameTextBox.Size = new System.Drawing.Size(438, 20); 70 // 71 // nameLabel 72 // 73 this.nameLabel.Location = new System.Drawing.Point(3, 6); 74 // 75 // infoLabel 76 // 77 this.infoLabel.Location = new System.Drawing.Point(491, 4); 78 // 79 // problemInstanceProviderComboBox 80 // 81 this.problemInstanceProviderComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 82 this.problemInstanceProviderComboBox.FormattingEnabled = true; 83 this.problemInstanceProviderComboBox.Location = new System.Drawing.Point(47, 2); 84 this.problemInstanceProviderComboBox.Name = "problemInstanceProviderComboBox"; 85 this.problemInstanceProviderComboBox.Size = new System.Drawing.Size(171, 21); 86 this.problemInstanceProviderComboBox.TabIndex = 13; 87 this.problemInstanceProviderComboBox.SelectedIndexChanged += new System.EventHandler(this.problemInstanceProviderComboBox_SelectedIndexChanged); 88 this.problemInstanceProviderComboBox.DataSourceChanged += new System.EventHandler(this.comboBox_DataSourceChanged); 89 // 90 // libraryLabel 91 // 92 this.libraryLabel.AutoSize = true; 93 this.libraryLabel.Location = new System.Drawing.Point(3, 6); 94 this.libraryLabel.Name = "libraryLabel"; 95 this.libraryLabel.Size = new System.Drawing.Size(41, 13); 96 this.libraryLabel.TabIndex = 12; 97 this.libraryLabel.Text = "Library:"; 98 // 99 // libraryInfoButton 100 // 101 this.libraryInfoButton.Location = new System.Drawing.Point(224, 1); 102 this.libraryInfoButton.Name = "libraryInfoButton"; 103 this.libraryInfoButton.Size = new System.Drawing.Size(26, 23); 104 this.libraryInfoButton.TabIndex = 14; 105 this.libraryInfoButton.Text = "Info"; 106 this.libraryInfoButton.UseVisualStyleBackColor = true; 107 this.libraryInfoButton.Click += new System.EventHandler(this.libraryInfoButton_Click); 108 // 109 // problemInstanceSplitContainer 110 // 111 this.problemInstanceSplitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 112 | System.Windows.Forms.AnchorStyles.Left) 113 | System.Windows.Forms.AnchorStyles.Right))); 114 this.problemInstanceSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; 115 this.problemInstanceSplitContainer.IsSplitterFixed = true; 116 this.problemInstanceSplitContainer.Location = new System.Drawing.Point(0, 0); 117 this.problemInstanceSplitContainer.Name = "problemInstanceSplitContainer"; 118 this.problemInstanceSplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal; 119 // 120 // problemInstanceSplitContainer.Panel1 121 // 122 this.problemInstanceSplitContainer.Panel1.Controls.Add(this.problemInstanceProviderViewHost); 123 this.problemInstanceSplitContainer.Panel1.Controls.Add(this.problemInstanceProviderComboBox); 124 this.problemInstanceSplitContainer.Panel1.Controls.Add(this.libraryInfoButton); 125 this.problemInstanceSplitContainer.Panel1.Controls.Add(this.libraryLabel); 126 this.problemInstanceSplitContainer.Panel1MinSize = 10; 127 // 128 // problemInstanceSplitContainer.Panel2 129 // 130 this.problemInstanceSplitContainer.Panel2.Controls.Add(this.nameLabel); 131 this.problemInstanceSplitContainer.Panel2.Controls.Add(this.nameTextBox); 132 this.problemInstanceSplitContainer.Panel2.Controls.Add(this.parameterCollectionView); 133 this.problemInstanceSplitContainer.Panel2.Controls.Add(this.infoLabel); 134 this.problemInstanceSplitContainer.Size = new System.Drawing.Size(511, 363); 135 this.problemInstanceSplitContainer.SplitterDistance = 26; 136 this.problemInstanceSplitContainer.TabIndex = 13; 137 // 138 // problemInstanceProviderViewHost 139 // 140 this.problemInstanceProviderViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 141 | System.Windows.Forms.AnchorStyles.Right))); 142 this.problemInstanceProviderViewHost.Caption = "View"; 143 this.problemInstanceProviderViewHost.Content = null; 144 this.problemInstanceProviderViewHost.Enabled = false; 145 this.problemInstanceProviderViewHost.Location = new System.Drawing.Point(256, 3); 146 this.problemInstanceProviderViewHost.Name = "problemInstanceProviderViewHost"; 147 this.problemInstanceProviderViewHost.ReadOnly = false; 148 this.problemInstanceProviderViewHost.Size = new System.Drawing.Size(251, 22); 149 this.problemInstanceProviderViewHost.TabIndex = 15; 150 this.problemInstanceProviderViewHost.ViewsLabelVisible = false; 151 this.problemInstanceProviderViewHost.ViewType = null; 54 152 // 55 153 // ProblemView … … 57 155 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 58 156 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 157 this.Controls.Add(this.problemInstanceSplitContainer); 59 158 this.Name = "ProblemView"; 159 this.Size = new System.Drawing.Size(511, 363); 60 160 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 161 this.problemInstanceSplitContainer.Panel1.ResumeLayout(false); 162 this.problemInstanceSplitContainer.Panel1.PerformLayout(); 163 this.problemInstanceSplitContainer.Panel2.ResumeLayout(false); 164 this.problemInstanceSplitContainer.Panel2.PerformLayout(); 165 ((System.ComponentModel.ISupportInitialize)(this.problemInstanceSplitContainer)).EndInit(); 166 this.problemInstanceSplitContainer.ResumeLayout(false); 61 167 this.ResumeLayout(false); 62 this.PerformLayout();63 168 64 169 } … … 66 171 #endregion 67 172 68 173 protected System.Windows.Forms.ComboBox problemInstanceProviderComboBox; 174 protected System.Windows.Forms.Label libraryLabel; 175 protected System.Windows.Forms.Button libraryInfoButton; 176 protected System.Windows.Forms.SplitContainer problemInstanceSplitContainer; 177 protected MainForm.WindowsForms.ViewHost problemInstanceProviderViewHost; 69 178 } 70 179 } -
trunk/sources/HeuristicLab.Optimization.Views/3.3/ProblemView.cs
r7259 r7641 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Diagnostics; 25 using System.Linq; 26 using System.Windows.Forms; 27 using HeuristicLab.Common.Resources; 22 28 using HeuristicLab.Core.Views; 23 29 using HeuristicLab.MainForm; 30 using HeuristicLab.PluginInfrastructure; 31 using HeuristicLab.Problems.Instances; 24 32 25 33 namespace HeuristicLab.Optimization.Views { … … 35 43 } 36 44 45 protected IProblemInstanceProvider SelectedProvider { 46 get { return (problemInstanceProviderComboBox.SelectedIndex >= 0 ? (IProblemInstanceProvider)problemInstanceProviderComboBox.SelectedItem : null); } 47 } 48 37 49 /// <summary> 38 50 /// Initializes a new instance of <see cref="ItemBaseView"/>. … … 40 52 public ProblemView() { 41 53 InitializeComponent(); 54 libraryInfoButton.Text = String.Empty; 55 libraryInfoButton.Image = VSImageLibrary.Internet; 42 56 } 43 57 44 58 protected override void OnContentChanged() { 45 59 base.OnContentChanged(); 60 if (Content == null) { 61 problemInstanceProviderComboBox.DataSource = null; 62 } else { 63 problemInstanceProviderComboBox.DisplayMember = "Name"; 64 problemInstanceProviderComboBox.DataSource = GetProblemInstanceProviders().ToList(); 65 problemInstanceSplitContainer.Panel1Collapsed = problemInstanceProviderComboBox.Items.Count <= 0; 66 67 } 68 SetEnabledStateOfControls(); 69 } 70 71 protected override void SetEnabledStateOfControls() { 72 base.SetEnabledStateOfControls(); 73 problemInstanceProviderComboBox.Enabled = !ReadOnly && !Locked && Content != null && problemInstanceProviderComboBox.Items.Count > 0; 74 libraryInfoButton.Enabled = SelectedProvider != null && SelectedProvider.WebLink != null; 75 } 76 77 protected virtual void problemInstanceProviderComboBox_SelectedIndexChanged(object sender, System.EventArgs e) { 78 if (problemInstanceProviderComboBox.SelectedIndex >= 0) { 79 dynamic provider = SelectedProvider; 80 dynamic consumer = Content; 81 provider.Consumer = consumer; 82 problemInstanceProviderViewHost.Content = SelectedProvider; 83 SetTooltip(); 84 } 85 SetEnabledStateOfControls(); 86 } 87 88 private void comboBox_DataSourceChanged(object sender, EventArgs e) { 89 var comboBox = (ComboBox)sender; 90 if (comboBox.DataSource == null) 91 comboBox.Items.Clear(); 92 } 93 94 protected virtual void libraryInfoButton_Click(object sender, EventArgs e) { 95 if (problemInstanceProviderComboBox.SelectedIndex >= 0) { 96 if (SelectedProvider != null && SelectedProvider.WebLink != null) 97 Process.Start(SelectedProvider.WebLink.ToString()); 98 } 99 } 100 101 protected virtual IEnumerable<IProblemInstanceProvider> GetProblemInstanceProviders() { 102 var consumerTypes = Content.GetType().GetInterfaces() 103 .Where(x => x.IsGenericType 104 && x.GetGenericTypeDefinition() == typeof(IProblemInstanceConsumer<>)); 105 106 if (consumerTypes.Any()) { 107 var instanceTypes = consumerTypes 108 .Select(x => x.GetGenericArguments().First()) 109 .Select(x => typeof(IProblemInstanceProvider<>).MakeGenericType(x)); 110 111 foreach (var type in instanceTypes) { 112 foreach (var provider in ApplicationManager.Manager.GetInstances(type)) 113 yield return (IProblemInstanceProvider)provider; 114 } 115 } 116 } 117 118 protected virtual void SetTooltip() { 119 toolTip.SetToolTip(problemInstanceProviderComboBox, GetProviderToolTip()); 120 if (SelectedProvider.WebLink != null) 121 toolTip.SetToolTip(libraryInfoButton, "Browse to " + SelectedProvider.WebLink.ToString()); 122 else toolTip.SetToolTip(libraryInfoButton, "Library does not have a web reference."); 123 } 124 125 protected virtual string GetProviderToolTip() { 126 var provider = SelectedProvider; 127 string toolTip = provider.Name; 128 129 if (!String.IsNullOrEmpty(provider.ReferencePublication)) { 130 toolTip = toolTip 131 + Environment.NewLine + Environment.NewLine 132 + provider.ReferencePublication; 133 } 134 if (provider.WebLink != null) { 135 toolTip = toolTip 136 + Environment.NewLine 137 + provider.WebLink.ToString(); 138 } 139 140 return toolTip; 46 141 } 47 142 }
Note: See TracChangeset
for help on using the changeset viewer.