- Timestamp:
- 07/08/16 14:40:02 (8 years ago)
- Location:
- branches/crossvalidation-2434
- Files:
-
- 10 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/crossvalidation-2434
- Property svn:mergeinfo changed
-
branches/crossvalidation-2434/HeuristicLab.Clients.OKB.Views/3.3/HeuristicLab.Clients.OKB.Views-3.3.csproj
r11623 r14029 286 286 <DependentUpon>OKBRunView.cs</DependentUpon> 287 287 </Compile> 288 <Compile Include="RunCreation\Views\SingleObjectiveOKBSolutionView.cs"> 289 <SubType>UserControl</SubType> 290 </Compile> 291 <Compile Include="RunCreation\Views\SingleObjectiveOKBSolutionView.Designer.cs"> 292 <DependentUpon>SingleObjectiveOKBSolutionView.cs</DependentUpon> 293 </Compile> 288 294 <None Include="Plugin.cs.frame" /> 289 295 <None Include="Properties\AssemblyInfo.cs.frame" /> … … 332 338 <Name>HeuristicLab.Core-3.3</Name> 333 339 <Private>False</Private> 340 </ProjectReference> 341 <ProjectReference Include="..\..\HeuristicLab.Data.Views\3.3\HeuristicLab.Data.Views-3.3.csproj"> 342 <Project>{72104A0B-90E7-42F3-9ABE-9BBBADD4B943}</Project> 343 <Name>HeuristicLab.Data.Views-3.3</Name> 334 344 </ProjectReference> 335 345 <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj"> -
branches/crossvalidation-2434/HeuristicLab.Clients.OKB.Views/3.3/Plugin.cs.frame
r12753 r14029 26 26 /// Plugin class for HeuristicLab.Clients.OKB.Views plugin. 27 27 /// </summary> 28 [Plugin("HeuristicLab.Clients.OKB.Views", "3.3.1 2.$WCREV$")]28 [Plugin("HeuristicLab.Clients.OKB.Views", "3.3.13.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Clients.OKB.Views-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Clients.OKB", "3.3")] … … 37 37 [PluginDependency("HeuristicLab.Core.Views", "3.3")] 38 38 [PluginDependency("HeuristicLab.Data", "3.3")] 39 [PluginDependency("HeuristicLab.Data.Views", "3.3")] 39 40 [PluginDependency("HeuristicLab.MainForm", "3.3")] 40 41 [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")] -
branches/crossvalidation-2434/HeuristicLab.Clients.OKB.Views/3.3/Properties/AssemblyInfo.cs.frame
r12753 r14029 55 55 // [assembly: AssemblyVersion("1.0.*")] 56 56 [assembly: AssemblyVersion("3.3.0.0")] 57 [assembly: AssemblyFileVersion("3.3.1 2.$WCREV$")]57 [assembly: AssemblyFileVersion("3.3.13.$WCREV$")] -
branches/crossvalidation-2434/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/QueryView.cs
r12012 r14029 23 23 using System.Collections; 24 24 using System.Collections.Generic; 25 using System.IO;26 25 using System.Linq; 27 26 using System.Threading; 28 27 using System.Threading.Tasks; 29 28 using System.Windows.Forms; 30 using HeuristicLab.Core;31 29 using HeuristicLab.MainForm; 32 30 using HeuristicLab.MainForm.WindowsForms; 33 31 using HeuristicLab.Optimization; 34 using HeuristicLab.Persistence.Default.Xml;35 32 using HeuristicLab.PluginInfrastructure; 36 33 … … 103 100 cancellationToken.ThrowIfCancellationRequested(); 104 101 if (AllValueNamesChecked()) { 105 runs.AddRange(QueryClient.Instance.GetRuns(ids.Take(batchSize), includeBinaryValues).Select(x => ConvertToOptimizationRun(x)));102 runs.AddRange(QueryClient.Instance.GetRuns(ids.Take(batchSize), includeBinaryValues).Select(x => QueryClient.Instance.ConvertToOptimizationRun(x))); 106 103 } else { 107 runs.AddRange(QueryClient.Instance.GetRunsWithValues(ids.Take(batchSize), includeBinaryValues, valueNames).Select(x => ConvertToOptimizationRun(x)));104 runs.AddRange(QueryClient.Instance.GetRunsWithValues(ids.Take(batchSize), includeBinaryValues, valueNames).Select(x => QueryClient.Instance.ConvertToOptimizationRun(x))); 108 105 } 109 106 ids = ids.Skip(batchSize); … … 124 121 try { 125 122 t.Wait(); 126 } 127 catch (AggregateException ex) { 123 } catch (AggregateException ex) { 128 124 try { 129 125 ex.Flatten().Handle(x => x is OperationCanceledException); 130 } 131 catch (AggregateException remaining) { 126 } catch (AggregateException remaining) { 132 127 if (remaining.InnerExceptions.Count == 1) ErrorHandling.ShowErrorDialog(this, "Refresh results failed.", remaining.InnerExceptions[0]); 133 128 else ErrorHandling.ShowErrorDialog(this, "Refresh results failed.", remaining); … … 195 190 } 196 191 197 private Optimization.IRun ConvertToOptimizationRun(Run run) {198 Optimization.Run optRun = new Optimization.Run();199 foreach (Value value in run.ParameterValues)200 optRun.Parameters.Add(value.Name, ConvertToItem(value));201 foreach (Value value in run.ResultValues)202 optRun.Results.Add(value.Name, ConvertToItem(value));203 return optRun;204 }205 206 private IItem ConvertToItem(Value value) {207 if (value is BinaryValue) {208 IItem item = null;209 BinaryValue binaryValue = (BinaryValue)value;210 if (binaryValue.Value != null) {211 using (MemoryStream stream = new MemoryStream(binaryValue.Value)) {212 try {213 item = XmlParser.Deserialize<IItem>(stream);214 }215 catch (Exception) { }216 stream.Close();217 }218 }219 return item != null ? item : new Data.StringValue(value.DataType.Name);220 } else if (value is BoolValue) {221 return new Data.BoolValue(((BoolValue)value).Value);222 } else if (value is FloatValue) {223 return new Data.DoubleValue(((FloatValue)value).Value);224 } else if (value is PercentValue) {225 return new Data.PercentValue(((PercentValue)value).Value);226 } else if (value is DoubleValue) {227 return new Data.DoubleValue(((DoubleValue)value).Value);228 } else if (value is IntValue) {229 return new Data.IntValue((int)((IntValue)value).Value);230 } else if (value is LongValue) {231 return new Data.IntValue((int)((LongValue)value).Value);232 } else if (value is StringValue) {233 return new Data.StringValue(((StringValue)value).Value);234 } else if (value is TimeSpanValue) {235 return new Data.TimeSpanValue(TimeSpan.FromSeconds((long)((TimeSpanValue)value).Value));236 }237 return null;238 }239 240 192 private void SetCheckedState(bool val) { 241 193 for (int i = 0; i < constraintsCheckedListBox.Items.Count; i++) { -
branches/crossvalidation-2434/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/CreateFromExperimentMenuItem.cs
r12012 r14029 22 22 using System; 23 23 using System.Collections.Generic; 24 using HeuristicLab.Core; 24 25 using HeuristicLab.MainForm; 25 26 using HeuristicLab.Optimization; … … 45 46 public override void Execute() { 46 47 IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; 47 MainFormManager.MainForm.ShowContent(activeView.Content, typeof(OKBExperimentUploadView)); 48 var view = new OKBExperimentUploadView(); 49 view.AddRuns((IItem)activeView.Content); 50 view.Show(); 48 51 } 49 52 } -
branches/crossvalidation-2434/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBExperimentUploadView.Designer.cs
r12012 r14029 35 35 components.Dispose(); 36 36 } 37 DisposeSpecific(); 37 38 base.Dispose(disposing); 38 39 } … … 48 49 this.btnUpload = new System.Windows.Forms.Button(); 49 50 this.dataGridView = new System.Windows.Forms.DataGridView(); 51 this.contextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); 52 this.setColumnToThisValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 53 this.clearButton = new System.Windows.Forms.Button(); 50 54 this.RunNameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); 51 55 this.AlgorithmNameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); … … 55 59 this.ProblemTypeColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); 56 60 this.OKBProblemColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); 57 this.contextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); 58 this.setColumnToThisValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 59 this.clearButton = new System.Windows.Forms.Button(); 61 this.UploadColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn(); 60 62 ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); 61 63 this.contextMenu.SuspendLayout(); … … 80 82 this.dataGridView.AllowUserToOrderColumns = true; 81 83 this.dataGridView.AllowUserToResizeRows = false; 82 this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 83 | System.Windows.Forms.AnchorStyles.Left)84 84 this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 85 | System.Windows.Forms.AnchorStyles.Left) 86 | System.Windows.Forms.AnchorStyles.Right))); 85 87 this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; 86 88 this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; … … 92 94 this.ProblemNameColumn, 93 95 this.ProblemTypeColumn, 94 this.OKBProblemColumn}); 96 this.OKBProblemColumn, 97 this.UploadColumn}); 95 98 this.dataGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter; 96 99 this.dataGridView.Location = new System.Drawing.Point(3, 3); … … 102 105 this.dataGridView.DragEnter += new System.Windows.Forms.DragEventHandler(this.dataGridView_DragEnter); 103 106 // 104 // RunNameColumn105 //106 this.RunNameColumn.HeaderText = "Run Name";107 this.RunNameColumn.Name = "RunNameColumn";108 this.RunNameColumn.ReadOnly = true;109 //110 // AlgorithmNameColumn111 //112 this.AlgorithmNameColumn.HeaderText = "Algorithm Name";113 this.AlgorithmNameColumn.Name = "AlgorithmNameColumn";114 this.AlgorithmNameColumn.ReadOnly = true;115 //116 // AlgorithmTypeColumn117 //118 this.AlgorithmTypeColumn.HeaderText = "Algorithm Type";119 this.AlgorithmTypeColumn.Name = "AlgorithmTypeColumn";120 this.AlgorithmTypeColumn.ReadOnly = true;121 //122 // OKBAlgorithmColumn123 //124 this.OKBAlgorithmColumn.HeaderText = "OKB Algorithm";125 this.OKBAlgorithmColumn.Name = "OKBAlgorithmColumn";126 //127 // ProblemNameColumn128 //129 this.ProblemNameColumn.HeaderText = "Problem Name";130 this.ProblemNameColumn.Name = "ProblemNameColumn";131 this.ProblemNameColumn.ReadOnly = true;132 this.ProblemNameColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;133 this.ProblemNameColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;134 //135 // ProblemTypeColumn136 //137 this.ProblemTypeColumn.HeaderText = "Problem Type";138 this.ProblemTypeColumn.Name = "ProblemTypeColumn";139 this.ProblemTypeColumn.ReadOnly = true;140 this.ProblemTypeColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;141 this.ProblemTypeColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;142 //143 // OKBProblemColumn144 //145 this.OKBProblemColumn.HeaderText = "OKB Problem";146 this.OKBProblemColumn.Name = "OKBProblemColumn";147 //148 107 // contextMenu 149 108 // … … 170 129 this.clearButton.UseVisualStyleBackColor = true; 171 130 this.clearButton.Click += new System.EventHandler(this.clearButton_Click); 131 // 132 // RunNameColumn 133 // 134 this.RunNameColumn.HeaderText = "Run Name"; 135 this.RunNameColumn.Name = "RunNameColumn"; 136 this.RunNameColumn.ReadOnly = true; 137 // 138 // AlgorithmNameColumn 139 // 140 this.AlgorithmNameColumn.HeaderText = "Algorithm Name"; 141 this.AlgorithmNameColumn.Name = "AlgorithmNameColumn"; 142 this.AlgorithmNameColumn.ReadOnly = true; 143 // 144 // AlgorithmTypeColumn 145 // 146 this.AlgorithmTypeColumn.HeaderText = "Algorithm Type"; 147 this.AlgorithmTypeColumn.Name = "AlgorithmTypeColumn"; 148 this.AlgorithmTypeColumn.ReadOnly = true; 149 // 150 // OKBAlgorithmColumn 151 // 152 this.OKBAlgorithmColumn.HeaderText = "OKB Algorithm"; 153 this.OKBAlgorithmColumn.Name = "OKBAlgorithmColumn"; 154 // 155 // ProblemNameColumn 156 // 157 this.ProblemNameColumn.HeaderText = "Problem Name"; 158 this.ProblemNameColumn.Name = "ProblemNameColumn"; 159 this.ProblemNameColumn.ReadOnly = true; 160 this.ProblemNameColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True; 161 this.ProblemNameColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; 162 // 163 // ProblemTypeColumn 164 // 165 this.ProblemTypeColumn.HeaderText = "Problem Type"; 166 this.ProblemTypeColumn.Name = "ProblemTypeColumn"; 167 this.ProblemTypeColumn.ReadOnly = true; 168 this.ProblemTypeColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True; 169 this.ProblemTypeColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; 170 // 171 // OKBProblemColumn 172 // 173 this.OKBProblemColumn.HeaderText = "OKB Problem"; 174 this.OKBProblemColumn.Name = "OKBProblemColumn"; 175 // 176 // UploadColumn 177 // 178 this.UploadColumn.HeaderText = "Upload?"; 179 this.UploadColumn.Name = "UploadColumn"; 180 this.UploadColumn.ToolTipText = "Whether the run should be uploaded or not."; 172 181 // 173 182 // OKBExperimentUploadView … … 191 200 private System.Windows.Forms.Button btnUpload; 192 201 private System.Windows.Forms.DataGridView dataGridView; 202 private System.Windows.Forms.ContextMenuStrip contextMenu; 203 private System.Windows.Forms.ToolStripMenuItem setColumnToThisValueToolStripMenuItem; 204 private System.Windows.Forms.Button clearButton; 193 205 private System.Windows.Forms.DataGridViewTextBoxColumn RunNameColumn; 194 206 private System.Windows.Forms.DataGridViewTextBoxColumn AlgorithmNameColumn; … … 198 210 private System.Windows.Forms.DataGridViewTextBoxColumn ProblemTypeColumn; 199 211 private System.Windows.Forms.DataGridViewComboBoxColumn OKBProblemColumn; 200 private System.Windows.Forms.ContextMenuStrip contextMenu; 201 private System.Windows.Forms.ToolStripMenuItem setColumnToThisValueToolStripMenuItem; 202 private System.Windows.Forms.Button clearButton; 212 private System.Windows.Forms.DataGridViewCheckBoxColumn UploadColumn; 203 213 } 204 214 } -
branches/crossvalidation-2434/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBExperimentUploadView.cs
r12012 r14029 28 28 using HeuristicLab.Clients.Access; 29 29 using HeuristicLab.Core; 30 using HeuristicLab.Core.Views;31 30 using HeuristicLab.MainForm; 32 using HeuristicLab.MainForm.WindowsForms;33 31 using HeuristicLab.Optimization; 32 using View = HeuristicLab.MainForm.WindowsForms.View; 34 33 35 34 namespace HeuristicLab.Clients.OKB.RunCreation { 36 35 [View("OKBExperimentUpload View")] 37 [Content(typeof(IOptimizer), false)] 38 public partial class OKBExperimentUploadView : ItemView { 39 public new IOptimizer Content { 40 get { return (IOptimizer)base.Content; } 41 set { base.Content = value; } 42 } 43 44 private const string algorithmTypeParameterName = "Algorithm Type"; 45 private const string problemTypeParameterName = "Problem Type"; 46 private const string algorithmNameParameterName = "Algorithm Name"; 47 private const string problemNameParameterName = "Problem Name"; 48 private const int algorithmColumnIndex = 3; 49 private const int problemColumnIndex = 6; 36 public partial class OKBExperimentUploadView : View { 37 38 private const string AlgorithmTypeParameterName = "Algorithm Type"; 39 private const string ProblemTypeParameterName = "Problem Type"; 40 private const string AlgorithmNameParameterName = "Algorithm Name"; 41 private const string ProblemNameParameterName = "Problem Name"; 50 42 51 43 private List<IRun> runs = new List<IRun>(); … … 57 49 public OKBExperimentUploadView() { 58 50 InitializeComponent(); 59 } 60 61 protected override void OnContentChanged() { 62 base.OnContentChanged(); 63 if (Content == null) { 64 ClearRuns(); 65 } else { 66 AddRuns(Content); 67 } 68 } 69 70 private void AddRuns(IItem item) { 51 OKBAlgorithmColumn.ValueType = typeof(Algorithm); 52 OKBAlgorithmColumn.ValueMember = "Name"; 53 OKBAlgorithmColumn.DisplayMember = "Name"; 54 OKBProblemColumn.ValueType = typeof(Problem); 55 OKBProblemColumn.ValueMember = "Name"; 56 OKBProblemColumn.DisplayMember = "Name"; 57 RunCreationClient.Instance.Refreshing += RunCreationClient_Refreshing; 58 RunCreationClient.Instance.Refreshed += RunCreationClient_Refreshed; 59 } 60 61 private void DisposeSpecific() { 62 RunCreationClient.Instance.Refreshing -= RunCreationClient_Refreshing; 63 RunCreationClient.Instance.Refreshed -= RunCreationClient_Refreshed; 64 } 65 66 private bool refreshing; 67 68 protected override void SetEnabledStateOfControls() { 69 if (InvokeRequired) { Invoke((Action)SetEnabledStateOfControls); return; } 70 base.SetEnabledStateOfControls(); 71 btnUpload.Enabled = runs.Count > 0 && !refreshing; 72 } 73 74 public void AddRuns(IItem item) { 75 if (InvokeRequired) { Invoke((Action<IItem>)AddRuns, item); return; } 71 76 if (item is Experiment) { 72 77 runs.AddRange((item as Experiment).Runs); … … 84 89 DisplayRuns(tmp); 85 90 } 86 } 87 88 protected override void RegisterContentEvents() { 89 base.RegisterContentEvents(); 90 RunCreationClient.Instance.Refreshing += new EventHandler(RunCreationClient_Refreshing); 91 RunCreationClient.Instance.Refreshed += new EventHandler(RunCreationClient_Refreshed); 92 } 93 94 protected override void DeregisterContentEvents() { 95 RunCreationClient.Instance.Refreshing -= new EventHandler(RunCreationClient_Refreshing); 96 RunCreationClient.Instance.Refreshed -= new EventHandler(RunCreationClient_Refreshed); 97 98 base.DeregisterContentEvents(); 91 SetEnabledStateOfControls(); 99 92 } 100 93 … … 117 110 118 111 private void CreateUI(RunCollection runs) { 119 if (InvokeRequired) { 120 Invoke(new Action<RunCollection>(CreateUI), runs); 121 } else { 122 if (problems.Count == 0) 123 problems.AddRange(RunCreationClient.Instance.Problems); 124 if (algorithms.Count == 0) 125 algorithms.AddRange(RunCreationClient.Instance.Algorithms); 126 127 IItem algorithmType; 128 IItem problemType; 129 IItem algorithmName; 130 IItem problemName; 131 132 DataGridViewComboBoxColumn cmbAlgorithm = dataGridView.Columns[algorithmColumnIndex] as DataGridViewComboBoxColumn; 133 cmbAlgorithm.DataSource = algorithms; 134 cmbAlgorithm.DisplayMember = "Name"; 135 136 DataGridViewComboBoxColumn cmbProblem = dataGridView.Columns[problemColumnIndex] as DataGridViewComboBoxColumn; 137 cmbProblem.DataSource = problems; 138 cmbProblem.DisplayMember = "Name"; 139 140 foreach (IRun run in runs) { 141 int idx = dataGridView.Rows.Add(run.Name); 142 DataGridViewRow curRow = dataGridView.Rows[idx]; 143 curRow.Tag = run; 144 145 if (run.Parameters.TryGetValue(algorithmTypeParameterName, out algorithmType)) { 146 HeuristicLab.Data.StringValue algStr = algorithmType as HeuristicLab.Data.StringValue; 147 if (algStr != null) { 148 curRow.Cells[1].Value = algStr; 149 } 150 } 151 152 if (run.Parameters.TryGetValue(algorithmNameParameterName, out algorithmName)) { 153 HeuristicLab.Data.StringValue algStr = algorithmName as HeuristicLab.Data.StringValue; 154 if (algStr != null) { 155 curRow.Cells[2].Value = algStr; 156 } 157 } 158 159 if (run.Parameters.TryGetValue(problemTypeParameterName, out problemType)) { 160 HeuristicLab.Data.StringValue prbStr = problemType as HeuristicLab.Data.StringValue; 161 if (prbStr != null) { 162 curRow.Cells[4].Value = prbStr; 163 } 164 } 165 166 if (run.Parameters.TryGetValue(problemNameParameterName, out problemName)) { 167 HeuristicLab.Data.StringValue prbStr = problemName as HeuristicLab.Data.StringValue; 168 if (prbStr != null) { 169 curRow.Cells[5].Value = prbStr; 170 } 171 } 172 } 173 } 174 } 175 176 private void ClearRuns() { 177 if (InvokeRequired) { 178 Invoke(new Action(ClearRuns)); 179 } else { 180 dataGridView.Rows.Clear(); 181 runs.Clear(); 182 } 112 if (InvokeRequired) { Invoke((Action<RunCollection>)CreateUI, runs); return; } 113 if (problems.Count == 0) 114 problems.AddRange(RunCreationClient.Instance.Problems); 115 if (algorithms.Count == 0) 116 algorithms.AddRange(RunCreationClient.Instance.Algorithms); 117 118 IItem algorithmType; 119 IItem problemType; 120 IItem algorithmName; 121 IItem problemName; 122 123 OKBAlgorithmColumn.DataSource = algorithms; 124 OKBProblemColumn.DataSource = problems; 125 126 foreach (IRun run in runs) { 127 int idx = dataGridView.Rows.Add(run.Name); 128 DataGridViewRow curRow = dataGridView.Rows[idx]; 129 curRow.Tag = run; 130 131 HeuristicLab.Data.StringValue algStr = null, algTypeStr = null, prbStr = null, prbTypeStr = null; 132 if (run.Parameters.TryGetValue(AlgorithmNameParameterName, out algorithmName)) { 133 algStr = algorithmName as HeuristicLab.Data.StringValue; 134 if (algStr != null) { 135 curRow.Cells[AlgorithmNameColumn.Name].Value = algStr; 136 } 137 } 138 139 if (run.Parameters.TryGetValue(AlgorithmTypeParameterName, out algorithmType)) { 140 algTypeStr = algorithmType as HeuristicLab.Data.StringValue; 141 if (algTypeStr != null) { 142 curRow.Cells[AlgorithmTypeColumn.Name].Value = algTypeStr; 143 } 144 } 145 146 var uploadOk = false; 147 if (algStr != null && algTypeStr != null) { 148 var alg = algorithms.FirstOrDefault(x => x.DataType.Name == algTypeStr.Value && x.Name == algStr.Value); 149 if (alg != null) { 150 curRow.Cells[OKBAlgorithmColumn.Name].Value = alg.Name; 151 uploadOk = true; 152 } 153 } 154 155 if (run.Parameters.TryGetValue(ProblemNameParameterName, out problemName)) { 156 prbStr = problemName as HeuristicLab.Data.StringValue; 157 if (prbStr != null) { 158 curRow.Cells[ProblemNameColumn.Name].Value = prbStr; 159 } 160 } 161 162 if (run.Parameters.TryGetValue(ProblemTypeParameterName, out problemType)) { 163 prbTypeStr = problemType as HeuristicLab.Data.StringValue; 164 if (prbTypeStr != null) { 165 curRow.Cells[ProblemTypeColumn.Name].Value = prbTypeStr; 166 } 167 } 168 169 if (prbStr != null && prbTypeStr != null) { 170 var prb = problems.FirstOrDefault(x => x.DataType.Name == prbTypeStr.Value && x.Name == prbStr.Value); 171 if (prb != null) { 172 curRow.Cells[OKBProblemColumn.Name].Value = prb.Name; 173 } else uploadOk = false; 174 } 175 176 curRow.Cells[UploadColumn.Name].Value = uploadOk; 177 } 178 } 179 180 public void ClearRuns() { 181 if (InvokeRequired) { Invoke((Action)ClearRuns); return; } 182 dataGridView.Rows.Clear(); 183 runs.Clear(); 184 SetEnabledStateOfControls(); 183 185 } 184 186 185 187 private void RunCreationClient_Refreshing(object sender, EventArgs e) { 186 if (InvokeRequired) { 187 Invoke(new EventHandler(RunCreationClient_Refreshing), sender, e); 188 } else { 189 var message = "Refreshing algorithms and problems..."; 190 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message); 191 } 188 if (InvokeRequired) { Invoke((Action<object, EventArgs>)RunCreationClient_Refreshing, sender, e); return; } 189 var message = "Refreshing algorithms and problems..."; 190 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message); 191 refreshing = true; 192 SetEnabledStateOfControls(); 192 193 } 193 194 194 195 private void RunCreationClient_Refreshed(object sender, EventArgs e) { 195 if (InvokeRequired) { 196 Invoke(new EventHandler(RunCreationClient_Refreshed), sender, e); 197 } else { 198 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 199 SetEnabledStateOfControls(); 200 } 196 if (InvokeRequired) { Invoke((Action<object, EventArgs>)RunCreationClient_Refreshed, sender, e); return; } 197 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 198 refreshing = false; 199 SetEnabledStateOfControls(); 201 200 } 202 201 … … 215 214 int i = 0; 216 215 foreach (DataGridViewRow row in dataGridView.Rows) { 217 selectedAlgorithm = algorithms.Where(x => x.Name == row.Cells[algorithmColumnIndex].Value.ToString()).FirstOrDefault(); 218 selectedProblem = problems.Where(x => x.Name == row.Cells[problemColumnIndex].Value.ToString()).FirstOrDefault(); 216 i++; 217 if (!Convert.ToBoolean(row.Cells[UploadColumn.Name].Value)) continue; 218 selectedAlgorithm = algorithms.FirstOrDefault(x => x.Name == row.Cells[OKBAlgorithmColumn.Name].Value.ToString()); 219 selectedProblem = problems.FirstOrDefault(x => x.Name == row.Cells[OKBProblemColumn.Name].Value.ToString()); 219 220 if (selectedAlgorithm == null || selectedProblem == null) { 220 221 throw new ArgumentException("Can't retrieve the algorithm/problem to upload"); … … 223 224 OKBRun run = new OKBRun(selectedAlgorithm.Id, selectedProblem.Id, row.Tag as IRun, UserInformation.Instance.User.Id); 224 225 run.Store(); 225 i++;226 226 progress.ProgressValue = ((double)i) / count; 227 227 } … … 233 233 if (e.Button == System.Windows.Forms.MouseButtons.Right && dataGridView[e.ColumnIndex, e.RowIndex].Value != null) { 234 234 string curVal = dataGridView[e.ColumnIndex, e.RowIndex].Value.ToString(); 235 selectedAlgorithm = algorithms. Where(x => x.Name == curVal).FirstOrDefault();236 selectedProblem = problems. Where(x => x.Name == curVal).FirstOrDefault();235 selectedAlgorithm = algorithms.FirstOrDefault(x => x.Name == curVal); 236 selectedProblem = problems.FirstOrDefault(x => x.Name == curVal); 237 237 238 238 if (selectedAlgorithm != null || selectedProblem != null) { … … 247 247 for (int i = 0; i < dataGridView.Rows.Count; i++) { 248 248 var row = dataGridView.Rows[i]; 249 row.Cells[ algorithmColumnIndex].Value = selectedAlgorithm.Name;249 row.Cells[OKBAlgorithmColumn.Name].Value = selectedAlgorithm.Name; 250 250 } 251 251 } else if (selectedProblem != null) { 252 252 for (int i = 0; i < dataGridView.Rows.Count; i++) { 253 253 var row = dataGridView.Rows[i]; 254 row.Cells[ problemColumnIndex].Value = selectedProblem.Name;254 row.Cells[OKBProblemColumn.Name].Value = selectedProblem.Name; 255 255 } 256 256 } -
branches/crossvalidation-2434/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBProblemView.Designer.cs
r12012 r14029 49 49 this.refreshButton = new System.Windows.Forms.Button(); 50 50 this.cloneProblemButton = new System.Windows.Forms.Button(); 51 this.tabControl = new System.Windows.Forms.TabControl(); 52 this.parametersTabPage = new System.Windows.Forms.TabPage(); 51 53 this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView(); 54 this.solutionsTabPage = new System.Windows.Forms.TabPage(); 55 this.flaAnalysisTabPage = new System.Windows.Forms.TabPage(); 56 this.flaSplitContainer = new System.Windows.Forms.SplitContainer(); 57 this.calculateButton = new System.Windows.Forms.Button(); 58 this.characteristicsMatrixView = new HeuristicLab.Data.Views.StringConvertibleMatrixView(); 59 this.uploadCharacteristicsButton = new System.Windows.Forms.Button(); 60 this.downloadCharacteristicsButton = new System.Windows.Forms.Button(); 61 this.solutionsViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 62 this.refreshSolutionsButton = new System.Windows.Forms.Button(); 63 this.uploadSolutionsButton = new System.Windows.Forms.Button(); 52 64 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 65 this.tabControl.SuspendLayout(); 66 this.parametersTabPage.SuspendLayout(); 67 this.solutionsTabPage.SuspendLayout(); 68 this.flaAnalysisTabPage.SuspendLayout(); 69 ((System.ComponentModel.ISupportInitialize)(this.flaSplitContainer)).BeginInit(); 70 this.flaSplitContainer.Panel1.SuspendLayout(); 71 this.flaSplitContainer.Panel2.SuspendLayout(); 72 this.flaSplitContainer.SuspendLayout(); 53 73 this.SuspendLayout(); 54 74 // … … 58 78 this.errorProvider.SetIconPadding(this.nameTextBox, 2); 59 79 this.nameTextBox.Location = new System.Drawing.Point(72, 27); 60 this.nameTextBox.Size = new System.Drawing.Size(6 04, 20);80 this.nameTextBox.Size = new System.Drawing.Size(640, 20); 61 81 this.nameTextBox.TabIndex = 5; 62 82 // … … 68 88 // infoLabel 69 89 // 70 this.infoLabel.Location = new System.Drawing.Point( 687, 30);90 this.infoLabel.Location = new System.Drawing.Point(723, 30); 71 91 this.infoLabel.TabIndex = 6; 72 92 // 73 93 // problemComboBox 74 94 // 75 this.problemComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 76 95 this.problemComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 96 | System.Windows.Forms.AnchorStyles.Right))); 77 97 this.problemComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 78 98 this.problemComboBox.FormattingEnabled = true; 79 99 this.problemComboBox.Location = new System.Drawing.Point(72, 0); 80 100 this.problemComboBox.Name = "problemComboBox"; 81 this.problemComboBox.Size = new System.Drawing.Size( 574, 21);101 this.problemComboBox.Size = new System.Drawing.Size(610, 21); 82 102 this.problemComboBox.TabIndex = 1; 83 103 this.problemComboBox.SelectedValueChanged += new System.EventHandler(this.problemComboBox_SelectedValueChanged); … … 95 115 // 96 116 this.refreshButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 97 this.refreshButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Refresh; 98 this.refreshButton.Location = new System.Drawing.Point(682, -1); 117 this.refreshButton.Location = new System.Drawing.Point(718, -1); 99 118 this.refreshButton.Name = "refreshButton"; 100 119 this.refreshButton.Size = new System.Drawing.Size(24, 24); … … 107 126 // 108 127 this.cloneProblemButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 109 this.cloneProblemButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Clone; 110 this.cloneProblemButton.Location = new System.Drawing.Point(652, -1); 128 this.cloneProblemButton.Location = new System.Drawing.Point(688, -1); 111 129 this.cloneProblemButton.Name = "cloneProblemButton"; 112 130 this.cloneProblemButton.Size = new System.Drawing.Size(24, 24); … … 116 134 this.cloneProblemButton.Click += new System.EventHandler(this.cloneProblemButton_Click); 117 135 // 136 // tabControl 137 // 138 this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 139 | System.Windows.Forms.AnchorStyles.Left) 140 | System.Windows.Forms.AnchorStyles.Right))); 141 this.tabControl.Controls.Add(this.parametersTabPage); 142 this.tabControl.Controls.Add(this.solutionsTabPage); 143 this.tabControl.Controls.Add(this.flaAnalysisTabPage); 144 this.tabControl.Location = new System.Drawing.Point(6, 53); 145 this.tabControl.Name = "tabControl"; 146 this.tabControl.SelectedIndex = 0; 147 this.tabControl.Size = new System.Drawing.Size(736, 473); 148 this.tabControl.TabIndex = 8; 149 // 150 // parametersTabPage 151 // 152 this.parametersTabPage.Controls.Add(this.parameterCollectionView); 153 this.parametersTabPage.Location = new System.Drawing.Point(4, 22); 154 this.parametersTabPage.Name = "parametersTabPage"; 155 this.parametersTabPage.Padding = new System.Windows.Forms.Padding(3); 156 this.parametersTabPage.Size = new System.Drawing.Size(728, 447); 157 this.parametersTabPage.TabIndex = 0; 158 this.parametersTabPage.Text = "Parameters"; 159 this.parametersTabPage.UseVisualStyleBackColor = true; 160 // 118 161 // parameterCollectionView 119 162 // 120 163 this.parameterCollectionView.AllowEditingOfHiddenParameters = false; 121 this.parameterCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)122 | System.Windows.Forms.AnchorStyles.Left)123 | System.Windows.Forms.AnchorStyles.Right)));124 164 this.parameterCollectionView.Caption = "ParameterCollection View"; 125 165 this.parameterCollectionView.Content = null; 126 this.parameterCollectionView.Location = new System.Drawing.Point(0, 53); 166 this.parameterCollectionView.Dock = System.Windows.Forms.DockStyle.Fill; 167 this.parameterCollectionView.Location = new System.Drawing.Point(3, 3); 127 168 this.parameterCollectionView.Name = "parameterCollectionView"; 128 this.parameterCollectionView.ReadOnly = false; 129 this.parameterCollectionView.Size = new System.Drawing.Size(706, 340); 130 this.parameterCollectionView.TabIndex = 7; 169 this.parameterCollectionView.ReadOnly = true; 170 this.parameterCollectionView.ShowDetails = true; 171 this.parameterCollectionView.Size = new System.Drawing.Size(722, 441); 172 this.parameterCollectionView.TabIndex = 8; 173 // 174 // solutionsTabPage 175 // 176 this.solutionsTabPage.Controls.Add(this.uploadSolutionsButton); 177 this.solutionsTabPage.Controls.Add(this.refreshSolutionsButton); 178 this.solutionsTabPage.Controls.Add(this.solutionsViewHost); 179 this.solutionsTabPage.Location = new System.Drawing.Point(4, 22); 180 this.solutionsTabPage.Name = "solutionsTabPage"; 181 this.solutionsTabPage.Padding = new System.Windows.Forms.Padding(3); 182 this.solutionsTabPage.Size = new System.Drawing.Size(728, 447); 183 this.solutionsTabPage.TabIndex = 3; 184 this.solutionsTabPage.Text = "Solutions"; 185 this.solutionsTabPage.UseVisualStyleBackColor = true; 186 // 187 // flaAnalysisTabPage 188 // 189 this.flaAnalysisTabPage.Controls.Add(this.flaSplitContainer); 190 this.flaAnalysisTabPage.Location = new System.Drawing.Point(4, 22); 191 this.flaAnalysisTabPage.Name = "flaAnalysisTabPage"; 192 this.flaAnalysisTabPage.Padding = new System.Windows.Forms.Padding(3); 193 this.flaAnalysisTabPage.Size = new System.Drawing.Size(728, 447); 194 this.flaAnalysisTabPage.TabIndex = 2; 195 this.flaAnalysisTabPage.Text = "Fitness Landscape Analysis"; 196 this.flaAnalysisTabPage.UseVisualStyleBackColor = true; 197 // 198 // flaSplitContainer 199 // 200 this.flaSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill; 201 this.flaSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; 202 this.flaSplitContainer.Location = new System.Drawing.Point(3, 3); 203 this.flaSplitContainer.Name = "flaSplitContainer"; 204 // 205 // flaSplitContainer.Panel1 206 // 207 this.flaSplitContainer.Panel1.Controls.Add(this.calculateButton); 208 // 209 // flaSplitContainer.Panel2 210 // 211 this.flaSplitContainer.Panel2.Controls.Add(this.characteristicsMatrixView); 212 this.flaSplitContainer.Panel2.Controls.Add(this.uploadCharacteristicsButton); 213 this.flaSplitContainer.Panel2.Controls.Add(this.downloadCharacteristicsButton); 214 this.flaSplitContainer.Size = new System.Drawing.Size(722, 441); 215 this.flaSplitContainer.SplitterDistance = 363; 216 this.flaSplitContainer.TabIndex = 7; 217 // 218 // calculateButton 219 // 220 this.calculateButton.Location = new System.Drawing.Point(3, 3); 221 this.calculateButton.Name = "calculateButton"; 222 this.calculateButton.Size = new System.Drawing.Size(26, 23); 223 this.calculateButton.TabIndex = 8; 224 this.calculateButton.Text = "Calculate"; 225 this.calculateButton.UseVisualStyleBackColor = true; 226 this.calculateButton.Click += new System.EventHandler(this.calculateButton_Click); 227 // 228 // characteristicsMatrixView 229 // 230 this.characteristicsMatrixView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 231 | System.Windows.Forms.AnchorStyles.Left) 232 | System.Windows.Forms.AnchorStyles.Right))); 233 this.characteristicsMatrixView.Caption = "StringConvertibleMatrix View"; 234 this.characteristicsMatrixView.Content = null; 235 this.characteristicsMatrixView.Location = new System.Drawing.Point(3, 32); 236 this.characteristicsMatrixView.Name = "characteristicsMatrixView"; 237 this.characteristicsMatrixView.ReadOnly = false; 238 this.characteristicsMatrixView.ShowRowsAndColumnsTextBox = false; 239 this.characteristicsMatrixView.ShowStatisticalInformation = false; 240 this.characteristicsMatrixView.Size = new System.Drawing.Size(349, 406); 241 this.characteristicsMatrixView.TabIndex = 4; 242 // 243 // uploadCharacteristicsButton 244 // 245 this.uploadCharacteristicsButton.Location = new System.Drawing.Point(35, 3); 246 this.uploadCharacteristicsButton.Name = "uploadCharacteristicsButton"; 247 this.uploadCharacteristicsButton.Size = new System.Drawing.Size(26, 23); 248 this.uploadCharacteristicsButton.TabIndex = 5; 249 this.uploadCharacteristicsButton.Text = "Upload"; 250 this.uploadCharacteristicsButton.UseVisualStyleBackColor = true; 251 this.uploadCharacteristicsButton.Click += new System.EventHandler(this.uploadCharacteristicsButton_Click); 252 // 253 // downloadCharacteristicsButton 254 // 255 this.downloadCharacteristicsButton.Location = new System.Drawing.Point(3, 3); 256 this.downloadCharacteristicsButton.Name = "downloadCharacteristicsButton"; 257 this.downloadCharacteristicsButton.Size = new System.Drawing.Size(26, 23); 258 this.downloadCharacteristicsButton.TabIndex = 6; 259 this.downloadCharacteristicsButton.Text = "Download"; 260 this.downloadCharacteristicsButton.UseVisualStyleBackColor = true; 261 this.downloadCharacteristicsButton.Click += new System.EventHandler(this.downloadCharacteristicsButton_Click); 262 // 263 // solutionsViewHost 264 // 265 this.solutionsViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 266 | System.Windows.Forms.AnchorStyles.Left) 267 | System.Windows.Forms.AnchorStyles.Right))); 268 this.solutionsViewHost.Caption = "View"; 269 this.solutionsViewHost.Content = null; 270 this.solutionsViewHost.Enabled = false; 271 this.solutionsViewHost.Location = new System.Drawing.Point(0, 35); 272 this.solutionsViewHost.Name = "solutionsViewHost"; 273 this.solutionsViewHost.ReadOnly = false; 274 this.solutionsViewHost.Size = new System.Drawing.Size(728, 412); 275 this.solutionsViewHost.TabIndex = 0; 276 this.solutionsViewHost.ViewsLabelVisible = true; 277 this.solutionsViewHost.ViewType = null; 278 // 279 // refreshSolutionsButton 280 // 281 this.refreshSolutionsButton.Location = new System.Drawing.Point(6, 6); 282 this.refreshSolutionsButton.Name = "refreshSolutionsButton"; 283 this.refreshSolutionsButton.Size = new System.Drawing.Size(26, 23); 284 this.refreshSolutionsButton.TabIndex = 1; 285 this.refreshSolutionsButton.Text = "Refresh"; 286 this.refreshSolutionsButton.UseVisualStyleBackColor = true; 287 this.refreshSolutionsButton.Click += new System.EventHandler(this.refreshSolutionsButton_Click); 288 // 289 // uploadSolutionsButton 290 // 291 this.uploadSolutionsButton.Location = new System.Drawing.Point(38, 6); 292 this.uploadSolutionsButton.Name = "uploadSolutionsButton"; 293 this.uploadSolutionsButton.Size = new System.Drawing.Size(26, 23); 294 this.uploadSolutionsButton.TabIndex = 1; 295 this.uploadSolutionsButton.Text = "Upload"; 296 this.uploadSolutionsButton.UseVisualStyleBackColor = true; 297 this.uploadSolutionsButton.Click += new System.EventHandler(this.uploadSolutionsButton_Click); 131 298 // 132 299 // OKBProblemView … … 134 301 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 135 302 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 303 this.Controls.Add(this.tabControl); 136 304 this.Controls.Add(this.problemComboBox); 137 this.Controls.Add(this.parameterCollectionView);138 305 this.Controls.Add(this.problemLabel); 139 306 this.Controls.Add(this.cloneProblemButton); 140 307 this.Controls.Add(this.refreshButton); 141 308 this.Name = "OKBProblemView"; 142 this.Size = new System.Drawing.Size(7 06, 393);309 this.Size = new System.Drawing.Size(742, 526); 143 310 this.Controls.SetChildIndex(this.refreshButton, 0); 144 311 this.Controls.SetChildIndex(this.cloneProblemButton, 0); 145 312 this.Controls.SetChildIndex(this.problemLabel, 0); 146 this.Controls.SetChildIndex(this.parameterCollectionView, 0); 313 this.Controls.SetChildIndex(this.problemComboBox, 0); 314 this.Controls.SetChildIndex(this.tabControl, 0); 147 315 this.Controls.SetChildIndex(this.nameTextBox, 0); 148 316 this.Controls.SetChildIndex(this.nameLabel, 0); 149 317 this.Controls.SetChildIndex(this.infoLabel, 0); 150 this.Controls.SetChildIndex(this.problemComboBox, 0);151 318 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 319 this.tabControl.ResumeLayout(false); 320 this.parametersTabPage.ResumeLayout(false); 321 this.solutionsTabPage.ResumeLayout(false); 322 this.flaAnalysisTabPage.ResumeLayout(false); 323 this.flaSplitContainer.Panel1.ResumeLayout(false); 324 this.flaSplitContainer.Panel2.ResumeLayout(false); 325 ((System.ComponentModel.ISupportInitialize)(this.flaSplitContainer)).EndInit(); 326 this.flaSplitContainer.ResumeLayout(false); 152 327 this.ResumeLayout(false); 153 328 this.PerformLayout(); … … 161 336 private System.Windows.Forms.Button refreshButton; 162 337 private System.Windows.Forms.Button cloneProblemButton; 163 private HeuristicLab.Core.Views.ParameterCollectionView parameterCollectionView; 338 private System.Windows.Forms.TabControl tabControl; 339 private System.Windows.Forms.TabPage parametersTabPage; 340 private Core.Views.ParameterCollectionView parameterCollectionView; 341 private System.Windows.Forms.TabPage flaAnalysisTabPage; 342 private System.Windows.Forms.Button calculateButton; 343 private System.Windows.Forms.SplitContainer flaSplitContainer; 344 private Data.Views.StringConvertibleMatrixView characteristicsMatrixView; 345 private System.Windows.Forms.Button uploadCharacteristicsButton; 346 private System.Windows.Forms.Button downloadCharacteristicsButton; 347 private System.Windows.Forms.TabPage solutionsTabPage; 348 private MainForm.WindowsForms.ViewHost solutionsViewHost; 349 private System.Windows.Forms.Button uploadSolutionsButton; 350 private System.Windows.Forms.Button refreshSolutionsButton; 164 351 165 352 -
branches/crossvalidation-2434/HeuristicLab.Clients.OKB.Views/3.3/RunCreation/Views/OKBProblemView.cs
r12012 r14029 20 20 #endregion 21 21 22 using HeuristicLab.Common.Resources; 23 using HeuristicLab.Core; 24 using HeuristicLab.Core.Views; 25 using HeuristicLab.Data; 26 using HeuristicLab.MainForm; 27 using HeuristicLab.Optimization; 28 using HeuristicLab.PluginInfrastructure; 22 29 using System; 30 using System.Collections.Generic; 31 using System.Drawing; 23 32 using System.Linq; 24 33 using System.Windows.Forms; 25 using HeuristicLab.Core.Views;26 using HeuristicLab.MainForm;27 34 28 35 namespace HeuristicLab.Clients.OKB.RunCreation { … … 31 38 [Content(typeof(MultiObjectiveOKBProblem), true)] 32 39 public sealed partial class OKBProblemView : NamedItemView { 40 private readonly CheckedItemList<ICharacteristicCalculator> calculatorList; 41 33 42 public new OKBProblem Content { 34 43 get { return (OKBProblem)base.Content; } … … 38 47 public OKBProblemView() { 39 48 InitializeComponent(); 49 var calculatorListView = new CheckedItemListView<ICharacteristicCalculator>() { 50 Anchor = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top, 51 Location = new Point(flaSplitContainer.Padding.Left, calculateButton.Location.Y + calculateButton.Height + calculateButton.Padding.Bottom + 3), 52 }; 53 calculatorListView.Size = new Size(flaSplitContainer.Panel1.Size.Width - flaSplitContainer.Panel1.Padding.Horizontal, 54 flaSplitContainer.Panel1.Height - calculatorListView.Location.Y - flaSplitContainer.Panel1.Padding.Bottom); 55 calculatorList = new CheckedItemList<ICharacteristicCalculator>(); 56 calculatorList.ItemsAdded += CalculatorListOnChanged; 57 calculatorList.ItemsRemoved += CalculatorListOnChanged; 58 calculatorList.ItemsReplaced += CalculatorListOnChanged; 59 calculatorList.CollectionReset += CalculatorListOnChanged; 60 calculatorList.CheckedItemsChanged += CalculatorListOnChanged; 61 62 calculatorListView.Content = calculatorList.AsReadOnly(); 63 64 flaSplitContainer.Panel1.Controls.Add(calculatorListView); 65 calculateButton.Text = string.Empty; 66 calculateButton.Image = VSImageLibrary.Play; 67 refreshButton.Text = string.Empty; 68 refreshButton.Image = VSImageLibrary.Refresh; 69 cloneProblemButton.Text = string.Empty; 70 cloneProblemButton.Image = VSImageLibrary.Clone; 71 downloadCharacteristicsButton.Text = string.Empty; 72 downloadCharacteristicsButton.Image = VSImageLibrary.Refresh; 73 uploadCharacteristicsButton.Text = string.Empty; 74 uploadCharacteristicsButton.Image = VSImageLibrary.PublishToWeb; 75 refreshSolutionsButton.Text = string.Empty; 76 refreshSolutionsButton.Image = VSImageLibrary.Refresh; 77 uploadSolutionsButton.Text = string.Empty; 78 uploadSolutionsButton.Image = VSImageLibrary.PublishToWeb; 79 } 80 81 private void CalculatorListOnChanged(object sender, EventArgs e) { 82 SetEnabledStateOfControls(); 40 83 } 41 84 … … 54 97 base.RegisterContentEvents(); 55 98 Content.ProblemChanged += new EventHandler(Content_ProblemChanged); 99 Content.Solutions.ItemsAdded += SolutionsOnChanged; 100 Content.Solutions.ItemsReplaced += SolutionsOnChanged; 101 Content.Solutions.ItemsRemoved += SolutionsOnChanged; 102 Content.Solutions.CollectionReset += SolutionsOnChanged; 103 } 104 105 private void SolutionsOnChanged(object sender, EventArgs e) { 106 if (InvokeRequired) { Invoke((Action<object, EventArgs>)SolutionsOnChanged, sender, e); return; } 107 SetEnabledStateOfControls(); 56 108 } 57 109 … … 61 113 problemComboBox.SelectedIndex = -1; 62 114 parameterCollectionView.Content = null; 115 solutionsViewHost.Content = null; 63 116 } else { 64 117 problemComboBox.SelectedItem = RunCreationClient.Instance.Problems.FirstOrDefault(x => x.Id == Content.ProblemId); 65 118 parameterCollectionView.Content = Content.Parameters; 66 } 119 solutionsViewHost.Content = Content.Solutions; 120 } 121 UpdateCharacteristicCalculators(); 67 122 } 68 123 … … 73 128 refreshButton.Enabled = (Content != null) && !ReadOnly && !Locked; 74 129 parameterCollectionView.Enabled = Content != null; 130 characteristicsMatrixView.Enabled = Content != null; 131 downloadCharacteristicsButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked; 132 uploadCharacteristicsButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked && !ReadOnly 133 && characteristicsMatrixView.Content != null && characteristicsMatrixView.Content.Rows > 0; 134 calculateButton.Enabled = Content != null && Content.ProblemId != -1 && !Locked && !ReadOnly && calculatorList.CheckedItems.Any(); 135 refreshSolutionsButton.Enabled = Content != null && !ReadOnly && !Locked && Content.ProblemId != -1; 136 uploadSolutionsButton.Enabled = Content != null && !ReadOnly && !Locked && Content.ProblemId != -1 && Content.Solutions.Any(x => x.SolutionId == -1); 75 137 } 76 138 … … 79 141 RunCreationClient.Instance.Refreshed -= new EventHandler(RunCreationClient_Refreshed); 80 142 base.OnClosed(e); 143 } 144 145 private void UpdateCharacteristicCalculators() { 146 calculatorList.Clear(); 147 if (Content == null || Content.ProblemId == -1) return; 148 var problem = Content.CloneProblem(); 149 var calculators = ApplicationManager.Manager.GetInstances<ICharacteristicCalculator>().ToList(); 150 foreach (var calc in calculators) { 151 calc.Problem = problem; 152 if (!calc.CanCalculate()) continue; 153 calculatorList.Add(calc, true); 154 } 81 155 } 82 156 … … 103 177 if (InvokeRequired) 104 178 Invoke(new EventHandler(Content_ProblemChanged), sender, e); 105 else 179 else { 106 180 OnContentChanged(); 181 SetEnabledStateOfControls(); 182 } 107 183 } 108 184 #endregion … … 123 199 } 124 200 } 201 private void downloadCharacteristicsButton_Click(object sender, EventArgs e) { 202 var values = RunCreationClient.Instance.GetCharacteristicValues(Content.ProblemId).ToList(); 203 var content = new StringMatrix(values.Count, 3); 204 for (var i = 0; i < values.Count; i++) { 205 content[i, 0] = values[i].Name; 206 content[i, 1] = values[i].GetValue(); 207 content[i, 2] = values[i].GetType().Name; 208 } 209 characteristicsMatrixView.Content = content; 210 SetEnabledStateOfControls(); 211 } 212 private void uploadCharacteristicsButton_Click(object sender, EventArgs e) { 213 var matrix = characteristicsMatrixView.Content as StringMatrix; 214 if (matrix == null) return; 215 var values = new List<Value>(matrix.Rows); 216 for (var i = 0; i < matrix.Rows; i++) { 217 var name = matrix[i, 0]; 218 var strValue = matrix[i, 1]; 219 var type = matrix[i, 2]; 220 values.Add(Value.Create(name, strValue, type)); 221 } 222 try { 223 RunCreationClient.Instance.SetCharacteristicValues(Content.ProblemId, values); 224 } catch (Exception ex) { ErrorHandling.ShowErrorDialog(ex); } 225 } 226 private void calculateButton_Click(object sender, EventArgs e) { 227 var calculators = calculatorList.CheckedItems.Select(x => x.Value).Where(x => x.CanCalculate()).ToList(); 228 if (calculators.Count == 0) return; 229 230 var results = new Dictionary<string, Value>(); 231 foreach (var calc in calculators) { 232 foreach (var result in calc.Calculate()) 233 results[result.Name] = RunCreationClient.Instance.ConvertToValue(result.Value, result.Name); 234 } 235 var matrix = (characteristicsMatrixView.Content as StringMatrix) ?? (new StringMatrix(results.Count, 3)); 236 try { 237 for (var i = 0; i < matrix.Rows; i++) { 238 Value r; 239 if (results.TryGetValue(matrix[i, 0], out r)) { 240 matrix[i, 1] = r.GetValue(); 241 matrix[i, 2] = r.GetType().Name; 242 results.Remove(matrix[i, 0]); 243 } 244 } 245 if (results.Count == 0) return; 246 var resultsList = results.ToList(); 247 var counter = resultsList.Count - 1; 248 for (var i = 0; i < matrix.Rows; i++) { 249 if (string.IsNullOrEmpty(matrix[i, 0])) { 250 matrix[i, 0] = resultsList[counter].Key; 251 matrix[i, 1] = resultsList[counter].Value.GetValue(); 252 matrix[i, 2] = resultsList[counter].Value.GetType().Name; 253 resultsList.RemoveAt(counter); 254 counter--; 255 if (counter < 0) return; 256 } 257 } 258 if (counter >= 0) { 259 ((IStringConvertibleMatrix)matrix).Rows += counter + 1; 260 for (var i = matrix.Rows - 1; counter >= 0; i--) { 261 matrix[i, 0] = resultsList[0].Key; 262 matrix[i, 1] = resultsList[0].Value.GetValue(); 263 matrix[i, 2] = resultsList[0].Value.GetType().Name; 264 resultsList.RemoveAt(0); 265 counter--; 266 } 267 } 268 } finally { 269 characteristicsMatrixView.Content = matrix; 270 SetEnabledStateOfControls(); 271 } 272 } 125 273 #endregion 126 274 … … 132 280 } 133 281 #endregion 282 283 private void refreshSolutionsButton_Click(object sender, EventArgs e) { 284 Content.RefreshSolutions(); 285 } 286 287 private void uploadSolutionsButton_Click(object sender, EventArgs e) { 288 foreach (var solution in Content.Solutions.Where(x => x.SolutionId == -1)) 289 solution.Upload(); 290 SetEnabledStateOfControls(); 291 } 292 134 293 } 135 294 }
Note: See TracChangeset
for help on using the changeset viewer.