Changeset 9041
- Timestamp:
- 12/12/12 16:50:46 (12 years ago)
- Location:
- branches/RuntimeOptimizer
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RuntimeOptimizer/HeuristicLab.Common/3.3/HeuristicLab.Common-3.3.csproj
r8600 r9041 135 135 <Compile Include="Plugin.cs" /> 136 136 <Compile Include="ReferenceEqualityComparer.cs" /> 137 <Compile Include="TimeSpanHelper.cs" /> 137 138 <Compile Include="TypeEqualityComparer.cs" /> 138 139 <Compile Include="TypeExtensions.cs" /> … … 180 181 --> 181 182 <PropertyGroup> 182 <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)183 <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir) 183 184 set ProjectDir=$(ProjectDir) 184 185 set SolutionDir=$(SolutionDir) … … 187 188 call PreBuildEvent.cmd 188 189 </PreBuildEvent> 189 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">190 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' "> 190 191 export ProjectDir=$(ProjectDir) 191 192 export SolutionDir=$(SolutionDir) -
branches/RuntimeOptimizer/HeuristicLab.MainForm.WindowsForms/3.3/HeuristicLab.MainForm.WindowsForms-3.3.csproj
r8975 r9041 126 126 <DependentUpon>DragOverTabControl.cs</DependentUpon> 127 127 </Compile> 128 <Compile Include="Dialogs\DefineArithmeticProgressionTimeDialog.cs"> 129 <SubType>Form</SubType> 130 </Compile> 131 <Compile Include="Dialogs\DefineArithmeticProgressionTimeDialog.Designer.cs"> 132 <DependentUpon>DefineArithmeticProgressionTimeDialog.cs</DependentUpon> 133 </Compile> 128 134 <Compile Include="Dialogs\DefineArithmeticProgressionDialog.cs"> 129 135 <SubType>Form</SubType> -
branches/RuntimeOptimizer/HeuristicLab.Optimization.Views/3.3/TimeLimitRunView.Designer.cs
r9040 r9041 202 202 // openAlgorithmButton 203 203 // 204 this.openAlgorithmButton.Image = ((System.Drawing.Image)(resources.GetObject("openAlgorithmButton.Image")));204 this.openAlgorithmButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open; 205 205 this.openAlgorithmButton.Location = new System.Drawing.Point(36, 6); 206 206 this.openAlgorithmButton.Name = "openAlgorithmButton"; … … 213 213 // newAlgorithmButton 214 214 // 215 this.newAlgorithmButton.Image = ((System.Drawing.Image)(resources.GetObject("newAlgorithmButton.Image")));215 this.newAlgorithmButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument; 216 216 this.newAlgorithmButton.Location = new System.Drawing.Point(6, 6); 217 217 this.newAlgorithmButton.Name = "newAlgorithmButton"; -
branches/RuntimeOptimizer/HeuristicLab.Optimization.Views/3.3/TimeLimitRunView.cs
r9040 r9041 84 84 try { 85 85 if (Content == null) { 86 timeLimitTextBox.Text = FormatTimeSpan(TimeSpan.FromSeconds(60));86 timeLimitTextBox.Text = TimeSpanHelper.FormatNatural(TimeSpan.FromSeconds(60)); 87 87 snapshotsTextBox.Text = String.Empty; 88 88 storeAlgorithmInEachSnapshotCheckBox.Checked = false; … … 91 91 runsView.Content = null; 92 92 } else { 93 timeLimitTextBox.Text = FormatTimeSpan(Content.MaximumExecutionTime);94 snapshotsTextBox.Text = String.Join(" ; ", Content.SnapshotTimes.Select(x => FormatTimeSpan(x, true)));93 timeLimitTextBox.Text = TimeSpanHelper.FormatNatural(Content.MaximumExecutionTime); 94 snapshotsTextBox.Text = String.Join(" ; ", Content.SnapshotTimes.Select(x => TimeSpanHelper.FormatNatural(x, true))); 95 95 storeAlgorithmInEachSnapshotCheckBox.Checked = Content.StoreAlgorithmInEachSnapshot; 96 96 algorithmViewHost.Content = Content.Algorithm; … … 137 137 SuppressEvents = true; 138 138 try { 139 timeLimitTextBox.Text = FormatTimeSpan(Content.MaximumExecutionTime);139 timeLimitTextBox.Text = TimeSpanHelper.FormatNatural(Content.MaximumExecutionTime); 140 140 } finally { SuppressEvents = false; } 141 141 break; … … 144 144 try { 145 145 if (Content.SnapshotTimes.Any()) 146 snapshotsTextBox.Text = String.Join(" ; ", Content.SnapshotTimes.Select(x => FormatTimeSpan(x, true)));146 snapshotsTextBox.Text = String.Join(" ; ", Content.SnapshotTimes.Select(x => TimeSpanHelper.FormatNatural(x, true))); 147 147 else snapshotsTextBox.Text = String.Empty; 148 148 Content.SnapshotTimes.ItemsAdded += Content_SnapshotTimes_Changed; … … 184 184 try { 185 185 if (Content.SnapshotTimes.Any()) 186 snapshotsTextBox.Text = string.Join(" ; ", Content.SnapshotTimes.Select(x => FormatTimeSpan(x, true)));186 snapshotsTextBox.Text = string.Join(" ; ", Content.SnapshotTimes.Select(x => TimeSpanHelper.FormatNatural(x, true))); 187 187 else snapshotsTextBox.Text = String.Empty; 188 188 } finally { SuppressEvents = false; } … … 194 194 if (SuppressEvents) return; 195 195 TimeSpan ts; 196 if (!T ryGetTimeSpanFromFormat(timeLimitTextBox.Text, out ts)) {196 if (!TimeSpanHelper.TryGetFromNaturalFormat(timeLimitTextBox.Text, out ts)) { 197 197 e.Cancel = true; 198 198 errorProvider.SetError(timeLimitTextBox, "Please enter a valid time span, e.g. 60, 20s, 45 seconds, 3h, 1 hour, 4 d, 2 days"); … … 200 200 Content.MaximumExecutionTime = ts; 201 201 e.Cancel = false; 202 errorProvider.SetError(timeLimitTextBox, String.Empty);202 errorProvider.SetError(timeLimitTextBox, null); 203 203 } 204 204 } … … 207 207 if (SuppressEvents) return; 208 208 e.Cancel = false; 209 errorProvider.SetError( timeLimitTextBox, String.Empty);209 errorProvider.SetError(snapshotsTextBox, null); 210 210 211 211 var snapshotTimes = new ObservableList<TimeSpan>(); … … 213 213 foreach (Match m in matches) { 214 214 TimeSpan value; 215 if (!T ryGetTimeSpanFromFormat(m.Value, out value)) {215 if (!TimeSpanHelper.TryGetFromNaturalFormat(m.Value, out value)) { 216 216 e.Cancel = !snapshotsTextBox.ReadOnly && snapshotsTextBox.Enabled; // don't cancel an operation that cannot be edited 217 217 errorProvider.SetError(snapshotsTextBox, "Error parsing " + m.Value + ", please provide a valid time span, e.g. 60, 20s, 45 seconds, 3h, 1 hour, 4 d, 2 days"); … … 297 297 298 298 private void sequenceButton_Click(object sender, EventArgs e) { 299 using (var dialog = new DefineArithmetic ProgressionDialog(false, 1, Content.MaximumExecutionTime.TotalSeconds, 1)) {299 using (var dialog = new DefineArithmeticTimeSpanProgressionDialog(TimeSpan.FromSeconds(1), Content.MaximumExecutionTime, TimeSpan.FromSeconds(1))) { 300 300 if (dialog.ShowDialog() == DialogResult.OK) { 301 301 if (dialog.Values.Any()) 302 Content.SnapshotTimes = new ObservableList<TimeSpan>(dialog.Values .Select(TimeSpan.FromSeconds));302 Content.SnapshotTimes = new ObservableList<TimeSpan>(dialog.Values); 303 303 else Content.SnapshotTimes = new ObservableList<TimeSpan>(); 304 304 } … … 307 307 #endregion 308 308 #endregion 309 310 private string FormatTimeSpan(TimeSpan ts, bool abbrevUnit = false) {311 if (ts.TotalSeconds < 180) return ts.TotalSeconds + (abbrevUnit ? "s" : " seconds");312 if (ts.TotalMinutes < 180) return ts.TotalMinutes + (abbrevUnit ? "min" : " minutes");313 if (ts.TotalHours < 96) return ts.TotalHours + (abbrevUnit ? "h" : " hours");314 return ts.TotalDays + (abbrevUnit ? "d" : " days");315 }316 317 private bool TryGetTimeSpanFromFormat(string text, out TimeSpan result) {318 double value;319 result = TimeSpan.Zero;320 321 var numberMatch = Regex.Match(text, @"\d+");322 if (!numberMatch.Success) return false;323 324 if (!double.TryParse(numberMatch.Value, out value))325 return false;326 327 var unitMatch = Regex.Match(text, @"[a-zA-Z]+$");328 if (!unitMatch.Success) return false;329 330 switch (unitMatch.Value) {331 case "d":332 case "day":333 case "days": result = TimeSpan.FromDays(value); break;334 case "h":335 case "hour":336 case "hours": result = TimeSpan.FromHours(value); break;337 case "min":338 case "minute":339 case "minutes": result = TimeSpan.FromMinutes(value); break;340 case "s":341 case "second":342 case "seconds": result = TimeSpan.FromSeconds(value); break;343 default: return false;344 }345 return true;346 }347 309 } 348 310 }
Note: See TracChangeset
for help on using the changeset viewer.