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
|
||||
{
|
||||
@@ -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<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.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; }
|
||||
|
||||
@@ -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">
|
||||
|
||||
<UserControl.Resources>
|
||||
<local:ErrorsToVisibilityConverter x:Key="ErrorsToVisibilityConverter" />
|
||||
<local:ErrorsToInVisibilityConverter x:Key="ErrorsToInVisibilityConverter" />
|
||||
<controls:ErrorsToVisibilityConverter x:Key="ErrorsToVisibilityConverter" />
|
||||
<controls:ErrorsToInVisibilityConverter x:Key="ErrorsToInVisibilityConverter" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<StackPanel ToolTip="{Binding Path=ErrorsToolTip, RelativeSource={RelativeSource AncestorType=local:ErrorIcon}}">
|
||||
<StackPanel ToolTip="{Binding Path=ErrorsToolTip, RelativeSource={RelativeSource AncestorType=controls:ErrorIcon}}">
|
||||
<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">
|
||||
<Canvas Width="512" Height="512">
|
||||
<Canvas.RenderTransform>
|
||||
@@ -32,7 +32,7 @@
|
||||
</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">
|
||||
<Canvas Width="512" Height="512">
|
||||
<Canvas.RenderTransform>
|
||||
|
||||
@@ -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<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 ICollection<string> Errors { get; set; }
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
Width="180"
|
||||
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 Margin="12, 12, 12, 0">
|
||||
|
||||
Reference in New Issue
Block a user