Changeset 3402 for trunk/sources
- Timestamp:
- 04/18/10 22:16:08 (15 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleValueView.cs
r3362 r3402 105 105 Content.SetValue(valueTextBox.Text); 106 106 errorProvider.SetError(valueTextBox, string.Empty); 107 valueTextBox.Text = Content.GetValue(); 107 108 } 108 109 } -
trunk/sources/HeuristicLab.Data/3.3/PercentValue.cs
r3376 r3402 40 40 41 41 public override string ToString() { 42 return (Value * 100).ToString("r") + " %"; // round-tripformat42 return Value.ToString("#0.#################### %"); // percent format 43 43 } 44 44 45 45 protected override bool Validate(string value, out string errorMessage) { 46 value = value.Replace("%", string.Empty);46 value = value.Replace("%", " "); 47 47 return base.Validate(value, out errorMessage); 48 48 } 49 49 protected override string GetValue() { 50 return (Value * 100).ToString("r") + " %"; // round-tripformat50 return Value.ToString("#0.#################### %"); // percent format 51 51 } 52 52 protected override bool SetValue(string value) { 53 value = value.Replace("%", string.Empty); 53 bool percent = value.Contains("%"); 54 value = value.Replace("%", " "); 54 55 double val; 55 56 if (double.TryParse(value, out val)) { 56 Value = val == 0 ? 0 : val / 100; 57 if (percent) { 58 if (!(val).IsAlmost(Value * 100.0)) 59 Value = val == 0 ? 0 : val / 100.0; 60 } else { 61 Value = val; 62 } 57 63 return true; 58 64 } else {
Note: See TracChangeset
for help on using the changeset viewer.