From 6c3fa4bb2eb3ed530e77a883c41625cd746b1592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Erbsh=C3=A4u=C3=9Fer?= Date: Thu, 18 Jun 2020 15:58:19 +0200 Subject: [PATCH] Added cost details window. --- ucalc/Constants.cs | 9 +- ucalc/Controls/Helpers.cs | 5 + ucalc/CostEntryDetailsWindow.xaml | 207 ++++++++++++++++ ucalc/CostEntryDetailsWindow.xaml.cs | 346 +++++++++++++++++++++++++++ ucalc/CostWindow.xaml | 77 ++++-- ucalc/CostWindow.xaml.cs | 11 + ucalc/Models/CostEntriesProperty.cs | 2 + ucalc/Models/CostEntryProperty.cs | 134 ++++++++++- ucalc/Models/Model.cs | 34 ++- ucalc/Models/Properties.cs | 36 ++- ucalc/ucalc.csproj | 6 + 11 files changed, 824 insertions(+), 43 deletions(-) create mode 100644 ucalc/CostEntryDetailsWindow.xaml create mode 100644 ucalc/CostEntryDetailsWindow.xaml.cs diff --git a/ucalc/Constants.cs b/ucalc/Constants.cs index d850bf3..c44ebbc 100644 --- a/ucalc/Constants.cs +++ b/ucalc/Constants.cs @@ -2,6 +2,7 @@ using System.Collections.Immutable; using System.Linq; using System.Windows.Media; +using UCalc.Controls; using UCalc.Data; namespace UCalc @@ -11,9 +12,15 @@ namespace UCalc public static readonly SolidColorBrush MainColor = Brushes.White; public static readonly SolidColorBrush SubMainColor = new SolidColorBrush(Color.FromRgb(0x00, 0x7A, 0xCC)); - public const string DecimalFormat = "0.00"; + public const int InternalPrecision = 6; + public const int DisplayPrecision = 2; public const string DateFormat = "dd.MM.yyyy"; + public static readonly string InternalPrecisionFormat = + Helpers.PrecisionToFormat(InternalPrecision, InternalPrecision - 2); + + public static readonly string DisplayPrecisionFormat = Helpers.PrecisionToFormat(DisplayPrecision); + public static readonly ImmutableList SalutationStrs = ((Salutation[]) Enum.GetValues(typeof(Salutation))).Select(value => value.AsString()).ToImmutableList(); diff --git a/ucalc/Controls/Helpers.cs b/ucalc/Controls/Helpers.cs index c3cfab3..bc974e7 100644 --- a/ucalc/Controls/Helpers.cs +++ b/ucalc/Controls/Helpers.cs @@ -37,5 +37,10 @@ namespace UCalc.Controls { return start1.IsBetween(start2, end2) || start2.IsBetween(start1, end1); } + + public static string PrecisionToFormat(int precision, int optional = 0) + { + return $"0.{new string('0', precision - optional)}{new string('#', optional)}"; + } } } \ No newline at end of file diff --git a/ucalc/CostEntryDetailsWindow.xaml b/ucalc/CostEntryDetailsWindow.xaml new file mode 100644 index 0000000..d098d48 --- /dev/null +++ b/ucalc/CostEntryDetailsWindow.xaml @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + +