Changeset 13561 for branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/ExpertSystemView.cs
- Timestamp:
- 01/21/16 11:15:23 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/ExpertSystemView.cs
r13551 r13561 21 21 22 22 using System; 23 using System.Collections;24 23 using System.ComponentModel; 25 24 using System.Linq; 25 using System.Text.RegularExpressions; 26 26 using System.Windows.Forms; 27 using HeuristicLab.Common;27 using System.Windows.Forms.DataVisualization.Charting; 28 28 using HeuristicLab.Common.Resources; 29 29 using HeuristicLab.Core.Views; … … 172 172 173 173 #region Control events 174 private void maxEvaluationsTextBox_Validating(object sender, CancelEventArgs e) {174 private void MaxEvaluationsTextBoxOnValidating(object sender, CancelEventArgs e) { 175 175 if (SuppressEvents) return; 176 176 if (InvokeRequired) { 177 Invoke((Action<object, CancelEventArgs>) maxEvaluationsTextBox_Validating, sender, e);177 Invoke((Action<object, CancelEventArgs>)MaxEvaluationsTextBoxOnValidating, sender, e); 178 178 return; 179 179 } … … 189 189 } 190 190 #endregion 191 192 private bool validDragOperation;193 private void instancesDropPanel_DragEnter(object sender, DragEventArgs e) {194 validDragOperation = false;195 if (!ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IRun)) {196 validDragOperation = true;197 } else if (!ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IEnumerable)) {198 validDragOperation = true;199 var items = (IEnumerable)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);200 foreach (object item in items)201 validDragOperation = validDragOperation && (item is IRun);202 }203 }204 private void instancesDropPanel_DragOver(object sender, DragEventArgs e) {205 e.Effect = DragDropEffects.None;206 if (!validDragOperation) return;207 if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key208 else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move; // SHIFT key209 else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;210 else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move;211 else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link;212 }213 private void instancesDropPanel_DragDrop(object sender, DragEventArgs e) {214 if (e.Effect == DragDropEffects.None) return;215 if (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IRun) {216 var item = (IRun)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);217 Content.ProblemInstances.Add(e.Effect.HasFlag(DragDropEffects.Copy) ? (IRun)item.Clone() : item);218 } else if (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IEnumerable) {219 var items = ((IEnumerable)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat)).Cast<IRun>();220 if (e.Effect.HasFlag(DragDropEffects.Copy)) {221 var cloner = new Cloner();222 items = items.Select(x => cloner.Clone(x));223 }224 Content.ProblemInstances.AddRange(items);225 }226 }227 191 #endregion 228 192 229 private void refreshMapButton_Click(object sender, EventArgs e) { 230 Content.UpdateInstanceMap(); 231 } 232 233 private void okbDownloadButton_Click(object sender, EventArgs e) { 193 private void RefreshMapButtonOnClick(object sender, EventArgs e) { 194 Content.UpdateInstanceProjection(); 195 UpdateProjectionComboBox(); 196 } 197 198 private void UpdateProjectionComboBox() { 199 projectionComboBox.Items.Clear(); 200 var projStrings = Content.ProblemInstances 201 .SelectMany(x => x.Results.Where(y => Regex.IsMatch(y.Key, "^Projection[.].*[.][XY]$"))) 202 .Select(x => Regex.Match(x.Key, "Projection[.](?<g>.*)[.][XY]").Groups["g"].Value) 203 .Distinct(); 204 foreach (var str in projStrings) { 205 projectionComboBox.Items.Add(str); 206 } 207 } 208 209 private void OkbDownloadButtonOnClick(object sender, EventArgs e) { 234 210 if (Content.Problem.ProblemId < 0) { 235 211 MessageBox.Show("Please select a problem instance first."); … … 254 230 } 255 231 256 private void algorithmStartButton_Click(object sender, EventArgs e) {232 private void AlgorithmStartButtonOnClick(object sender, EventArgs e) { 257 233 var selectedInstance = (IAlgorithm)suggestedInstancesComboBox.SelectedItem; 258 234 var clone = (IAlgorithm)selectedInstance.Clone(); … … 261 237 algorithmViewHost.Content = clone.Results; 262 238 } 239 240 private void ProjectionComboBoxOnSelectedIndexChanged(object sender, EventArgs e) { 241 if (projectionComboBox.SelectedIndex < 0) return; 242 var projection = (string)projectionComboBox.SelectedItem; 243 var instancesSeries = instanceMapChart.Series["InstancesSeries"]; 244 var currentInstanceSeries = instanceMapChart.Series["CurrentInstanceSeries"]; 245 246 instancesSeries.Points.Clear(); 247 currentInstanceSeries.Points.Clear(); 248 249 foreach (var run in Content.ProblemInstances) { 250 var xKey = "Projection." + projection + ".X"; 251 var yKey = "Projection." + projection + ".Y"; 252 if (!run.Results.ContainsKey(xKey) || !run.Results.ContainsKey(yKey) 253 || !(run.Results[xKey] is Data.DoubleValue) || !(run.Results[yKey] is Data.DoubleValue)) continue; 254 var x = ((Data.DoubleValue)run.Results[xKey]).Value; 255 var y = ((Data.DoubleValue)run.Results[yKey]).Value; 256 var dataPoint = new DataPoint(x, y) { 257 Label = run.Name 258 }; 259 instancesSeries.Points.Add(dataPoint); 260 } 261 262 var curPoint = Content.ProjectCurrentInstance(projection); 263 if (curPoint != null) { 264 var dp = new DataPoint(curPoint.Item1, curPoint.Item2) { 265 Label = Content.Problem.Problem.Name 266 }; 267 currentInstanceSeries.Points.Add(dp); 268 } 269 } 263 270 } 264 271 }
Note: See TracChangeset
for help on using the changeset viewer.