diff --git a/ucalc/Constants.cs b/ucalc/Constants.cs index 5e77612..088da6f 100644 --- a/ucalc/Constants.cs +++ b/ucalc/Constants.cs @@ -1,4 +1,8 @@ -using System.Windows.Media; +using System; +using System.Collections.Immutable; +using System.Linq; +using System.Windows.Media; +using UCalc.Data; namespace UCalc { @@ -6,5 +10,8 @@ namespace UCalc { public static readonly SolidColorBrush MainColor = Brushes.White; public static readonly SolidColorBrush SubMainColor = new SolidColorBrush(Color.FromRgb(0x00, 0x7A, 0xCC)); + + public static readonly ImmutableList SalutationStrs = + ((Salutation[]) Enum.GetValues(typeof(Salutation))).Select(value => value.AsString()).ToImmutableList(); } } \ No newline at end of file diff --git a/ucalc/Controls/Converters.cs b/ucalc/Controls/Converters.cs new file mode 100644 index 0000000..d31dcdc --- /dev/null +++ b/ucalc/Controls/Converters.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Windows; +using System.Windows.Data; + +namespace UCalc.Controls +{ + public class ErrorsToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + return (((ICollection) value)?.Count ?? 0) == 0 ? Visibility.Collapsed : Visibility.Visible; + } + + public object ConvertBack(object value, Type targetType, object parameter, + System.Globalization.CultureInfo culture) + { + throw new InvalidOperationException(); + } + } + + public class ErrorsToInVisibilityConverter : IValueConverter + { + private readonly ErrorsToVisibilityConverter _converter = new ErrorsToVisibilityConverter(); + + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + var result = _converter.Convert(value, targetType, parameter, culture) as Visibility?; + return result == Visibility.Collapsed ? Visibility.Visible : Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, + System.Globalization.CultureInfo culture) + { + throw new InvalidOperationException(); + } + } + + + public class ErrorCountToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + return (int?) value != 0 ? Visibility.Visible : Visibility.Collapsed; + } + + public object ConvertBack(object value, Type targetType, object parameter, + System.Globalization.CultureInfo culture) + { + throw new InvalidOperationException(); + } + } +} \ No newline at end of file diff --git a/ucalc/Controls/ErrorCounter.xaml.cs b/ucalc/Controls/ErrorCounter.xaml.cs index 03d7dc0..a7071c0 100644 --- a/ucalc/Controls/ErrorCounter.xaml.cs +++ b/ucalc/Controls/ErrorCounter.xaml.cs @@ -1,24 +1,8 @@ -using System; -using System.Windows; -using System.Windows.Data; +using System.Windows; using UCalc.Models; namespace UCalc.Controls { - public class ErrorCountToVisibilityConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) - { - return ((int) value) != 0 ? Visibility.Visible : Visibility.Collapsed; - } - - public object ConvertBack(object value, Type targetType, object parameter, - System.Globalization.CultureInfo culture) - { - throw new InvalidOperationException(); - } - } - public partial class ErrorCounter { public Model Model { get; set; } diff --git a/ucalc/Controls/ErrorIcon.xaml b/ucalc/Controls/ErrorIcon.xaml index 67af572..6fdebc1 100644 --- a/ucalc/Controls/ErrorIcon.xaml +++ b/ucalc/Controls/ErrorIcon.xaml @@ -3,19 +3,19 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:local="clr-namespace:UCalc.Controls" + xmlns:controls="clr-namespace:UCalc.Controls" mc:Ignorable="d" Width="16" Height="16"> - - + + - + @@ -32,7 +32,7 @@ diff --git a/ucalc/Controls/ErrorIcon.xaml.cs b/ucalc/Controls/ErrorIcon.xaml.cs index de95dc7..90cc4e7 100644 --- a/ucalc/Controls/ErrorIcon.xaml.cs +++ b/ucalc/Controls/ErrorIcon.xaml.cs @@ -1,44 +1,11 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Windows; -using System.Windows.Data; using UCalc.Annotations; namespace UCalc.Controls { - public class ErrorsToVisibilityConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) - { - return (((ICollection) value)?.Count ?? 0) == 0 ? Visibility.Collapsed : Visibility.Visible; - } - - public object ConvertBack(object value, Type targetType, object parameter, - System.Globalization.CultureInfo culture) - { - throw new InvalidOperationException(); - } - } - - public class ErrorsToInVisibilityConverter : IValueConverter - { - private readonly ErrorsToVisibilityConverter _converter = new ErrorsToVisibilityConverter(); - - public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) - { - var result = _converter.Convert(value, targetType, parameter, culture) as Visibility?; - return result == Visibility.Collapsed ? Visibility.Visible : Visibility.Collapsed; - } - - public object ConvertBack(object value, Type targetType, object parameter, - System.Globalization.CultureInfo culture) - { - throw new InvalidOperationException(); - } - } - public partial class ErrorIcon : INotifyPropertyChanged { public ICollection Errors { get; set; } diff --git a/ucalc/Pages/LandlordPage.xaml b/ucalc/Pages/LandlordPage.xaml index b3126cb..8033dea 100644 --- a/ucalc/Pages/LandlordPage.xaml +++ b/ucalc/Pages/LandlordPage.xaml @@ -19,7 +19,9 @@ Width="180" Foreground="{x:Static local:Constants.SubMainColor}" /> - +