- Timestamp:
- 07/23/18 12:26:36 (6 years ago)
- Location:
- trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.Designer.cs
r15752 r15998 19 19 */ 20 20 #endregion 21 22 using System; 21 23 22 24 namespace HeuristicLab.Problems.DataAnalysis.Views { … … 86 88 this.sortByComboBox.TabIndex = 5; 87 89 this.sortByComboBox.SelectedIndexChanged += new System.EventHandler(this.sortByComboBox_SelectedIndexChanged); 90 this.sortByComboBox.DataSource = Enum.GetValues(typeof(SortingCriteria)); 88 91 // 89 92 // factorVarReplComboBox … … 159 162 // variableImactsArrayView 160 163 // 161 this.variableImactsArrayView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 162 | System.Windows.Forms.AnchorStyles.Left) 164 this.variableImactsArrayView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 165 | System.Windows.Forms.AnchorStyles.Left) 163 166 | System.Windows.Forms.AnchorStyles.Right))); 164 167 this.variableImactsArrayView.Caption = "StringConvertibleArray View"; -
trunk/HeuristicLab.Problems.DataAnalysis.Views/3.4/Regression/RegressionSolutionVariableImpactsView.cs
r15799 r15998 39 39 VariableName 40 40 } 41 private IProgress progress; 42 private Dictionary<string, double> rawVariableImpacts = new Dictionary<string, double>(); 41 private List<Tuple<string, double>> rawVariableImpacts = new List<Tuple<string, double>>(); 43 42 44 43 public new IRegressionSolution Content { … … 53 52 InitializeComponent(); 54 53 55 //Little workaround. If you fill the ComboBox-Items in the other partial class, the UI-Designer will moan.56 this.sortByComboBox.Items.AddRange(Enum.GetValues(typeof(SortingCriteria)).Cast<object>().ToArray());57 this.sortByComboBox.SelectedItem = SortingCriteria.ImpactValue;58 59 54 //Set the default values 60 55 this.dataPartitionComboBox.SelectedIndex = 0; 61 56 this.replacementComboBox.SelectedIndex = 0; 62 57 this.factorVarReplComboBox.SelectedIndex = 0; 58 this.sortByComboBox.SelectedItem = SortingCriteria.ImpactValue; 63 59 } 64 60 … … 93 89 94 90 private void RegressionSolutionVariableImpactsView_VisibleChanged(object sender, EventArgs e) { 95 if (!cancellationToken.IsCancellationRequested) { 96 cancellationToken.Cancel(); 97 } 91 cancellationToken.Cancel(); 98 92 } 99 93 … … 110 104 //Update the default ordering (asc,desc), but remove the eventHandler beforehand (otherwise the data would be ordered twice) 111 105 ascendingCheckBox.CheckedChanged -= ascendingCheckBox_CheckedChanged; 112 switch ((SortingCriteria)sortByComboBox.SelectedItem) { 113 case SortingCriteria.ImpactValue: 114 ascendingCheckBox.Checked = false; 115 break; 116 case SortingCriteria.Occurrence: 117 ascendingCheckBox.Checked = true; 118 break; 119 case SortingCriteria.VariableName: 120 ascendingCheckBox.Checked = true; 121 break; 122 default: 123 throw new NotImplementedException("Ordering for selected SortingCriteria not implemented"); 124 } 106 ascendingCheckBox.Checked = (SortingCriteria)sortByComboBox.SelectedItem != SortingCriteria.ImpactValue; 125 107 ascendingCheckBox.CheckedChanged += ascendingCheckBox_CheckedChanged; 126 108 127 Update DataOrdering();109 UpdateOrdering(); 128 110 } 129 111 130 112 private void ascendingCheckBox_CheckedChanged(object sender, EventArgs e) { 131 Update DataOrdering();113 UpdateOrdering(); 132 114 } 133 115 134 116 135 117 private async void UpdateVariableImpact() { 118 IProgress progress; 119 136 120 //Check if the selection is valid 137 121 if (Content == null) { return; } … … 166 150 167 151 rawVariableImpacts.Clear(); 168 originalVariableOrdering.ForEach(v => rawVariableImpacts.Add( v, impacts.First(vv => vv.Item1 == v).Item2));169 Update DataOrdering();152 originalVariableOrdering.ForEach(v => rawVariableImpacts.Add(new Tuple<string, double>(v, impacts.First(vv => vv.Item1 == v).Item2))); 153 UpdateOrdering(); 170 154 } finally { 171 155 ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).RemoveOperationProgressFromView(this); … … 177 161 /// The default is "Descending" by "VariableImpact" (as in previous versions) 178 162 /// </summary> 179 private void Update DataOrdering() {163 private void UpdateOrdering() { 180 164 //Check if valid sortingCriteria is selected and data exists 181 165 if (sortByComboBox.SelectedIndex == -1) { return; } … … 186 170 bool ascending = ascendingCheckBox.Checked; 187 171 188 IEnumerable< KeyValuePair<string, double>> orderedEntries = null;172 IEnumerable<Tuple<string, double>> orderedEntries = null; 189 173 190 174 //Sort accordingly 191 175 switch (selectedItem) { 192 176 case SortingCriteria.ImpactValue: 193 orderedEntries = rawVariableImpacts.OrderBy(v => v. Value);177 orderedEntries = rawVariableImpacts.OrderBy(v => v.Item2); 194 178 break; 195 179 case SortingCriteria.Occurrence: … … 197 181 break; 198 182 case SortingCriteria.VariableName: 199 orderedEntries = rawVariableImpacts.OrderBy(v => v. Key, new NaturalStringComparer());183 orderedEntries = rawVariableImpacts.OrderBy(v => v.Item1, new NaturalStringComparer()); 200 184 break; 201 185 default: … … 206 190 207 191 //Write the data back 208 var impactArray = new DoubleArray(orderedEntries.Select(i => i. Value).ToArray()) {209 ElementNames = orderedEntries.Select(i => i. Key)192 var impactArray = new DoubleArray(orderedEntries.Select(i => i.Item2).ToArray()) { 193 ElementNames = orderedEntries.Select(i => i.Item1) 210 194 }; 211 195
Note: See TracChangeset
for help on using the changeset viewer.