Implemented salutation combobox for landlord.
This commit is contained in:
+8
-1
@@ -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
|
namespace UCalc
|
||||||
{
|
{
|
||||||
@@ -6,5 +10,8 @@ namespace UCalc
|
|||||||
{
|
{
|
||||||
public static readonly SolidColorBrush MainColor = Brushes.White;
|
public static readonly SolidColorBrush MainColor = Brushes.White;
|
||||||
public static readonly SolidColorBrush SubMainColor = new SolidColorBrush(Color.FromRgb(0x00, 0x7A, 0xCC));
|
public static readonly SolidColorBrush SubMainColor = new SolidColorBrush(Color.FromRgb(0x00, 0x7A, 0xCC));
|
||||||
|
|
||||||
|
public static readonly ImmutableList<string> SalutationStrs =
|
||||||
|
((Salutation[]) Enum.GetValues(typeof(Salutation))).Select(value => value.AsString()).ToImmutableList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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<string>) 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,24 +1,8 @@
|
|||||||
using System;
|
using System.Windows;
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Data;
|
|
||||||
using UCalc.Models;
|
using UCalc.Models;
|
||||||
|
|
||||||
namespace UCalc.Controls
|
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 partial class ErrorCounter
|
||||||
{
|
{
|
||||||
public Model Model { get; set; }
|
public Model Model { get; set; }
|
||||||
|
|||||||
@@ -3,19 +3,19 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:UCalc.Controls"
|
xmlns:controls="clr-namespace:UCalc.Controls"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Width="16"
|
Width="16"
|
||||||
Height="16">
|
Height="16">
|
||||||
|
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<local:ErrorsToVisibilityConverter x:Key="ErrorsToVisibilityConverter" />
|
<controls:ErrorsToVisibilityConverter x:Key="ErrorsToVisibilityConverter" />
|
||||||
<local:ErrorsToInVisibilityConverter x:Key="ErrorsToInVisibilityConverter" />
|
<controls:ErrorsToInVisibilityConverter x:Key="ErrorsToInVisibilityConverter" />
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
|
|
||||||
<StackPanel ToolTip="{Binding Path=ErrorsToolTip, RelativeSource={RelativeSource AncestorType=local:ErrorIcon}}">
|
<StackPanel ToolTip="{Binding Path=ErrorsToolTip, RelativeSource={RelativeSource AncestorType=controls:ErrorIcon}}">
|
||||||
<Viewbox
|
<Viewbox
|
||||||
Visibility="{Binding Path=Errors, RelativeSource={RelativeSource AncestorType=local:ErrorIcon}, Converter={StaticResource ErrorsToInVisibilityConverter}}"
|
Visibility="{Binding Path=Errors, RelativeSource={RelativeSource AncestorType=controls:ErrorIcon}, Converter={StaticResource ErrorsToInVisibilityConverter}}"
|
||||||
Stretch="Uniform">
|
Stretch="Uniform">
|
||||||
<Canvas Width="512" Height="512">
|
<Canvas Width="512" Height="512">
|
||||||
<Canvas.RenderTransform>
|
<Canvas.RenderTransform>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
</Viewbox>
|
</Viewbox>
|
||||||
|
|
||||||
<Viewbox
|
<Viewbox
|
||||||
Visibility="{Binding Path=Errors, RelativeSource={RelativeSource AncestorType=local:ErrorIcon}, Converter={StaticResource ErrorsToVisibilityConverter}}"
|
Visibility="{Binding Path=Errors, RelativeSource={RelativeSource AncestorType=controls:ErrorIcon}, Converter={StaticResource ErrorsToVisibilityConverter}}"
|
||||||
Stretch="Uniform">
|
Stretch="Uniform">
|
||||||
<Canvas Width="512" Height="512">
|
<Canvas Width="512" Height="512">
|
||||||
<Canvas.RenderTransform>
|
<Canvas.RenderTransform>
|
||||||
|
|||||||
@@ -1,44 +1,11 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Data;
|
|
||||||
using UCalc.Annotations;
|
using UCalc.Annotations;
|
||||||
|
|
||||||
namespace UCalc.Controls
|
namespace UCalc.Controls
|
||||||
{
|
{
|
||||||
public class ErrorsToVisibilityConverter : IValueConverter
|
|
||||||
{
|
|
||||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
|
||||||
{
|
|
||||||
return (((ICollection<string>) 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 partial class ErrorIcon : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
public ICollection<string> Errors { get; set; }
|
public ICollection<string> Errors { get; set; }
|
||||||
|
|||||||
@@ -19,7 +19,9 @@
|
|||||||
Width="180"
|
Width="180"
|
||||||
Foreground="{x:Static local:Constants.SubMainColor}" />
|
Foreground="{x:Static local:Constants.SubMainColor}" />
|
||||||
|
|
||||||
<ComboBox Margin="0, 0, 28, 0" /> <!-- TODO -->
|
<ComboBox Margin="0, 0, 28, 0"
|
||||||
|
ItemsSource="{x:Static local:Constants.SalutationStrs}"
|
||||||
|
SelectedIndex="{Binding Path=Model.Salutation.Value, RelativeSource={RelativeSource AncestorType=pages:LandlordPage}}"/>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
|
||||||
<DockPanel Margin="12, 12, 12, 0">
|
<DockPanel Margin="12, 12, 12, 0">
|
||||||
|
|||||||
Reference in New Issue
Block a user