order ticket - fix cancel, close after action, add input-dirty borders
This commit is contained in:
1 parent
53f88e4c60
commit
56ee3679ee
14 files changed
+441
-223
No files matched your search
@@ -309,6 +309,8 @@ namespace mbts.ui
|
||||
public static BTSColor input_invalid_border { get { return new BTSColor(0x7E, 0xB4, 0xEA); } }
|
||||
public static BTSColor input_invalid_background { get { return new BTSColor(0xAB, 0xAD, 0xB3); } }
|
||||
|
||||
public static BTSColor input_dirty_border => warning;
|
||||
|
||||
public static class ComboBox
|
||||
{
|
||||
// Normal
|
||||
@@ -407,6 +409,7 @@ namespace mbts.ui
|
||||
public static BTSColor uneditable_button_border { get { return UI.transparent; } }
|
||||
public static BTSColor uneditable_button_background { get { return UI.transparent; } }
|
||||
|
||||
//public static BTSColor uncommitted_edit_background => new BTSColor
|
||||
}
|
||||
|
||||
public static class Button
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:mbts="clr-namespace:mbts.ui"
|
||||
xmlns:ui="clr-namespace:mbts.ui"
|
||||
>
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mbts="clr-namespace:mbts.ui"
|
||||
xmlns:ui="clr-namespace:mbts.ui"
|
||||
>
|
||||
<Color x:Key="Text.Prompt.Foreground.Color">#FF999999</Color>
|
||||
|
||||
<SolidColorBrush x:Key="CommonBackground" Color="{ui:BTSColor common_background}" />
|
||||
@@ -22,10 +21,16 @@
|
||||
<SolidColorBrush x:Key="bid_foreground" Color="{mbts:BTSColor Name=Quoteset.bid_text}" />
|
||||
<SolidColorBrush x:Key="ask_background" Color="{mbts:BTSColor Name=Quoteset.default_background}" />
|
||||
<SolidColorBrush x:Key="ask_foreground" Color="{mbts:BTSColor Name=Quoteset.ask_text}" />
|
||||
<SolidColorBrush x:Key="uncommitted_border" Color="{mbts:BTSColor Name=UI.warning}" />
|
||||
<SolidColorBrush x:Key="override_color" Color="{mbts:BTSColor Name=Quoteset.quoteset_override}" />
|
||||
<SolidColorBrush x:Key="dialog_skirt" Color="{mbts:BTSColor Name=UI.dialog_skirt}" />
|
||||
|
||||
<!---TextBox-->
|
||||
<Color x:Key="TextBox.Static.Background.Color">#FFFFFFFF</Color>
|
||||
<Color x:Key="TextBox.Static.Border.Color">#FFABADB3</Color>
|
||||
|
||||
<SolidColorBrush x:Key="TextBox.Static.Border.Brush" Color="{StaticResource TextBox.Static.Border.Color}"/>
|
||||
<SolidColorBrush x:Key="TextBox.Static.Background.Brush" Color="{StaticResource TextBox.Static.Background.Color}"/>
|
||||
|
||||
<!--ComboBox-->
|
||||
<LinearGradientBrush x:Key="ComboBox.Static.Background" EndPoint="0,1" StartPoint="0,0">
|
||||
<GradientStop Color="#FFF0F0F0" Offset="0.0"/>
|
||||
|
||||
@@ -19,16 +19,29 @@
|
||||
<ResourceDictionary Source="/view/Controls/Popup/PopupControl.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<Style TargetType="uag:OrderDetailsPopupControl">
|
||||
<Setter Property="Background" Value="{StaticResource ComboBox.Static.Background}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource ComboBox.Static.Border}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="uag:OrderDetailsPopupControl">
|
||||
<Grid x:Name="Root">
|
||||
<Grid x:Name="Root" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="0"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ComboBox x:Name="PART_OrderTypeComboBox" ItemsSource="{TemplateBinding ItemsView}" SelectedItem="{Binding SelectedItem, RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Stretch">
|
||||
<ComboBox
|
||||
x:Name="PART_OrderTypeComboBox"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
HorizontalAlignment="Stretch"
|
||||
ItemsSource="{TemplateBinding ItemsView}"
|
||||
SelectedItem="{Binding SelectedItem, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
>
|
||||
<ComboBox.GroupStyle>
|
||||
<GroupStyle>
|
||||
<GroupStyle.ContainerStyle>
|
||||
@@ -53,9 +66,14 @@
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<c:PopupControl x:Name="PART_OrderDetailsPopup" Grid.Column="2"
|
||||
Content="{Binding SelectedItem, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Visibility="{TemplateBinding HasEditableProperties, Converter={StaticResource BoolToVisibility}}">
|
||||
<c:PopupControl
|
||||
x:Name="PART_OrderDetailsPopup" Grid.Column="2"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Content="{Binding SelectedItem, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Visibility="{TemplateBinding HasEditableProperties, Converter={StaticResource BoolToVisibility}}"
|
||||
>
|
||||
<c:PopupControl.PopupContainerStyle>
|
||||
<Style TargetType="Border" BasedOn="{StaticResource PopupContainerStyleBase}">
|
||||
<Setter Property="Padding" Value="4"/>
|
||||
|
||||
@@ -3,17 +3,31 @@
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:usp="clr-namespace:mbts.ui.spark"
|
||||
xmlns:uspcv="clr-namespace:mbts.ui.spark.converters">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/view/Colors.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<uspcv:TickDisplayTwoWayConverter x:Key="TickDisplayTwoWayConverter" x:Shared="False"/>
|
||||
<ControlTemplate x:Key="PriceEntryTemplate" TargetType="usp:PriceEntryControl">
|
||||
<c:TickUpDown BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Background="{TemplateBinding Background}"
|
||||
TickUpCommand="{TemplateBinding TickUpCommand}"
|
||||
TickDownCommand="{TemplateBinding TickDownCommand}">
|
||||
<TextBox x:Name="_text" Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TickDisplayTwoWayConverter}, Mode=TwoWay}"/>
|
||||
<c:TickUpDown
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Background="{TemplateBinding Background}"
|
||||
TickUpCommand="{TemplateBinding TickUpCommand}"
|
||||
TickDownCommand="{TemplateBinding TickDownCommand}"
|
||||
>
|
||||
<TextBox
|
||||
x:Name="_text"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TickDisplayTwoWayConverter}, Mode=TwoWay}"
|
||||
/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
<Style TargetType="usp:PriceEntryControl">
|
||||
<Setter Property="Background" Value="{StaticResource TextBox.Static.Background.Brush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource TextBox.Static.Border.Brush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Template" Value="{StaticResource PriceEntryTemplate}"/>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -3,152 +3,160 @@
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/view/Resources/Converters.xaml" />
|
||||
<ResourceDictionary Source="/view/Colors.xaml" />
|
||||
<ResourceDictionary Source="/view/Resources/Converters.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<Style TargetType="{x:Type c:TickUpDown}">
|
||||
<Setter Property="Height" Value="20" />
|
||||
<Setter Property="MinWidth" Value="14" />
|
||||
<Setter Property="Focusable" Value="false" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDown">
|
||||
<Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="14" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<ContentPresenter Grid.RowSpan="2" Grid.Column="0" VerticalAlignment="Center" Margin="{TemplateBinding Padding}" />
|
||||
<RepeatButton Command="{TemplateBinding TickUpCommand}" CommandParameter="{TemplateBinding TickUpParameter}" Grid.Row="0" Grid.Column="1" BorderThickness="0" Focusable="False">
|
||||
<Path Data="F1 M 0,0 L 2.667,2.66665 L 5.3334,0 L 5.3334,-1.78168 L 2.6667,0.88501 L0,-1.78168 L0,0 Z"
|
||||
<Setter Property="Height" Value="20" />
|
||||
<Setter Property="MinWidth" Value="14" />
|
||||
<Setter Property="Focusable" Value="false" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDown">
|
||||
<Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="14" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<ContentPresenter Grid.RowSpan="2" Grid.Column="0" VerticalAlignment="Center" Margin="{TemplateBinding Padding}" />
|
||||
<RepeatButton Command="{TemplateBinding TickUpCommand}" CommandParameter="{TemplateBinding TickUpParameter}" Grid.Row="0" Grid.Column="1" BorderThickness="0" Focusable="False">
|
||||
<Path Data="F1 M 0,0 L 2.667,2.66665 L 5.3334,0 L 5.3334,-1.78168 L 2.6667,0.88501 L0,-1.78168 L0,0 Z"
|
||||
Fill="#FF606060" HorizontalAlignment="Right" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
|
||||
<Path.RenderTransform>
|
||||
<RotateTransform Angle="180" />
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
</RepeatButton>
|
||||
<RepeatButton Command="{TemplateBinding TickDownCommand}" CommandParameter="{TemplateBinding TickDownParameter}" Grid.Row="1" Grid.Column="1" BorderThickness="0" Focusable="False">
|
||||
<Path Data="F1 M 0,0 L 2.667,2.66665 L 5.3334,0 L 5.3334,-1.78168 L 2.6667,0.88501 L0,-1.78168 L0,0 Z"
|
||||
<Path.RenderTransform>
|
||||
<RotateTransform Angle="180" />
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
</RepeatButton>
|
||||
<RepeatButton Command="{TemplateBinding TickDownCommand}" CommandParameter="{TemplateBinding TickDownParameter}" Grid.Row="1" Grid.Column="1" BorderThickness="0" Focusable="False">
|
||||
<Path Data="F1 M 0,0 L 2.667,2.66665 L 5.3334,0 L 5.3334,-1.78168 L 2.6667,0.88501 L0,-1.78168 L0,0 Z"
|
||||
Fill="#FF606060" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</RepeatButton>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</RepeatButton>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style TargetType="{x:Type c:TickUpDownDouble}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownDouble">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource DoubleTextConverter}}"
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownDouble">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource DoubleTextConverter}}"
|
||||
u:DoubleDisplay.Multiplier="{TemplateBinding Multiplier}"
|
||||
u:DoubleDisplay.Format="{TemplateBinding Format}" />
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style TargetType="{x:Type c:TickUpDownInt}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownInt">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource IntTextConverter}}"/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownInt">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource IntTextConverter}}"/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style TargetType="{x:Type c:TickUpDownUInt}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownUInt">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource UIntTextConverter}}"/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownUInt">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource UIntTextConverter}}"/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style TargetType="{x:Type c:TickUpDownUShort}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownUShort">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource UShortTextConverter}}"/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownUShort">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource UShortTextConverter}}"/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style TargetType="{x:Type c:TickUpDownULong}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownULong">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource ULongTextConverter}}"/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownULong">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource ULongTextConverter}}"/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style TargetType="{x:Type c:TickUpDownByte}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownByte">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource ByteTextConverter}}"/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownByte">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource ByteTextConverter}}"/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style TargetType="{x:Type c:TickUpDownNullableInt}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownNullableInt">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource NullableIntTextConverter}}"/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownNullableInt">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource NullableIntTextConverter}}"/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style TargetType="{x:Type c:TickUpDownNullableUInt}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownNullableUInt">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource NullableUIntTextConverter}}"/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Background" Value="{StaticResource TextBox.Static.Background.Brush}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource TextBox.Static.Border.Brush}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownNullableUInt">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
Background="{TemplateBinding Background}"
|
||||
Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource NullableUIntTextConverter}}"
|
||||
/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style TargetType="{x:Type c:TickUpDownNullableUShort}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownNullableUShort">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource NullableUShortTextConverter}}"/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownNullableUShort">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource NullableUShortTextConverter}}"/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style TargetType="{x:Type c:TickUpDownNullableULong}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownNullableULong">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource NullableULongTextConverter}}"/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:TickUpDownNullableULong">
|
||||
<c:TickUpDown x:Name="PART_tick_up_down">
|
||||
<TextBox Text="{Binding Value, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Converter={StaticResource NullableULongTextConverter}}"/>
|
||||
</c:TickUpDown>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -110,10 +110,13 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
public async Task send_order((double price, Side? side) args) {
|
||||
if (args.side.HasValue && !HasErrors) {
|
||||
var sec_order = selected_order_type as ISecurityOrderTypeDefVM;
|
||||
if (!size_calculator.value.HasValue || size_calculator.value.Value == 0) {
|
||||
await size_calculator.flash_value_error();
|
||||
if (args.side.HasValue) {
|
||||
_validate_selected_account();
|
||||
_validate_selected_time_in_force();
|
||||
_validate_selected_order_type();
|
||||
if (HasErrors) return;
|
||||
else if (!size_calculator.value.HasValue || size_calculator.value.Value == 0) {
|
||||
size_calculator.flash_error();
|
||||
} else {
|
||||
var order = create(args.side.Value);
|
||||
uint size = (uint)Math.Abs(size_calculator.value.Value);
|
||||
|
||||
@@ -1,30 +1,45 @@
|
||||
using bts.api.orderman;
|
||||
using mbts.ui;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace mbts.spark {
|
||||
class ExistingOrderTicketVM : OrderPropertiesEditorVM {
|
||||
class ExistingOrderTicketVM : OrderPropertiesEditorVM, IRequestViewClose {
|
||||
readonly Property<double> _current_price;
|
||||
readonly Property<uint> _current_size;
|
||||
readonly Property<string> _current_account;
|
||||
readonly Property<TimeInForce> _current_time_in_force;
|
||||
readonly Property<CustomOrderDefinition.CustomOneofCase> _current_order_type;
|
||||
readonly DelegateProperty<bool> _price_dirty, _size_dirty, _account_dirty, _time_in_force_dirty, _order_type_dirty;
|
||||
|
||||
public ExistingOrderTicketVM(OrdersModel model, IObservable<OrderRecordTuple> order_source, IObservable<int[]> calculator_buttons)
|
||||
: base(model, order_source.Where(ot => ot.security_md.HasValue).Select(ot => ot.security_md.Value.security),
|
||||
order_source.Select(ot => new InlineOrderProperties(
|
||||
new InlineUserProperty<double>(ot.order.State.Price),
|
||||
new InlineUserProperty<uint>(ot.order.State.Quantity),
|
||||
new InlineUserProperty<string>(ot.order.Def.Account),
|
||||
new InlineUserProperty<TimeInForce>(ot.order.Def.TimeInForce),
|
||||
new InlineUserProperty<CustomOrderDefinition>(ot.order.Def.CustomDef.CloneToMutable())
|
||||
order_source.Take(1).Select(ot => new InlineOrderProperties(
|
||||
new InlineUserProperty<double>(ot.order.State.Price, true),
|
||||
new InlineUserProperty<uint>(ot.order.State.Quantity, true),
|
||||
new InlineUserProperty<string>(ot.order.Def.Account, true),
|
||||
new InlineUserProperty<TimeInForce>(ot.order.Def.TimeInForce, true),
|
||||
new InlineUserProperty<CustomOrderDefinition>(ot.order.Def.CustomDef.CloneToMutable(), true)
|
||||
)), calculator_buttons) {
|
||||
uint? key = null;
|
||||
_current_price = backing(nameof(current_price), order_source.Select(ort => ort.order.State.Price));
|
||||
_current_size = backing(nameof(current_size), order_source.Select(ort => ort.order.State.Quantity));
|
||||
_current_account = backing(nameof(current_account), order_source.Select(ort => ort.order.Def.Account));
|
||||
_current_time_in_force = backing(nameof(current_time_in_force), order_source.Select(ort => ort.order.Def.TimeInForce));
|
||||
_current_order_type = backing(nameof(current_order_type), order_source.Select(ort => ort.order.Def.CustomDef.CustomCase));
|
||||
_price_dirty = backing(nameof(price_dirty), () => !double.IsNaN(price) && price != current_price);
|
||||
_size_dirty = backing(nameof(size_dirty), () => size_calculator.value.HasValue && size_calculator.value.Value != current_size);
|
||||
_account_dirty = backing(nameof(account_dirty), () => selected_account != current_account);
|
||||
_time_in_force_dirty = backing(nameof(time_in_force_dirty), () => selected_time_in_force != current_time_in_force);
|
||||
_order_type_dirty = backing(nameof(order_type_dirty), () => selected_order_type == null || selected_order_type.order_type != current_order_type);
|
||||
_dispose = Disposable.Create(
|
||||
order_source.Select(ort => ort.order.Key).ObserveOnDispatcher().Subscribe(k => key = k),
|
||||
bbo = new BBOVM(order_source.Where(ort => ort.security_md.HasValue).Select(ort => ort.security_md.Value))
|
||||
bbo = new BBOVM(order_source.Where(ort => ort.security_md.HasValue).Select(ort => ort.security_md.Value)),
|
||||
Observable.Merge(_price_dirty, _size_dirty, _account_dirty, _time_in_force_dirty, _order_type_dirty)
|
||||
.ObserveOnDispatcher().Subscribe(_ => RaisePropertyChanged(nameof(dirty_items_text)))
|
||||
);
|
||||
modify_order = new DelegateCommand(() => {
|
||||
if (key.HasValue) {
|
||||
@@ -37,23 +52,54 @@ namespace mbts.spark {
|
||||
}
|
||||
} else if (size_valid) {
|
||||
model.update_order_size(key.Value, size_calculator.value.Value).ignore();
|
||||
} else return;
|
||||
} else {
|
||||
size_calculator.flash_error();
|
||||
flash_error(nameof(price)).ignore();
|
||||
return;
|
||||
}
|
||||
RequestClose?.Invoke(this, new EventArgs());
|
||||
}
|
||||
});
|
||||
cancel_order = new DelegateCommand(() => {
|
||||
if (key.HasValue) {
|
||||
model.cancel_order(key.Value).ignore();
|
||||
RequestClose?.Invoke(this, new EventArgs());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public double current_price => _current_price.Value;
|
||||
public uint current_size => _current_size.Value;
|
||||
public event EventHandler RequestClose;
|
||||
|
||||
public override double? current_price => _current_price.Value;
|
||||
public override uint? current_size => _current_size.Value;
|
||||
public string current_account => _current_account.Value;
|
||||
public TimeInForce current_time_in_force => _current_time_in_force.Value;
|
||||
public CustomOrderDefinition.CustomOneofCase current_order_type => _current_order_type.Value;
|
||||
public override bool? price_dirty => _price_dirty.Value;
|
||||
public override bool? size_dirty => _size_dirty.Value;
|
||||
public override bool? account_dirty => _account_dirty.Value;
|
||||
public override bool? time_in_force_dirty => _time_in_force_dirty.Value;
|
||||
public override bool? order_type_dirty => _order_type_dirty.Value;
|
||||
public string dirty_items_text => string.Join(", ", _dirty_items());
|
||||
public BBOVM bbo { get; }
|
||||
public ICommand modify_order { get; }
|
||||
public ICommand cancel_order { get; }
|
||||
|
||||
(bool price_valid, bool size_valid) _validate_input() {
|
||||
bool pv = _price_valid(), sv = _size_valid();
|
||||
if (!pv) flash_error(nameof(price)).ignore();
|
||||
if (!sv) size_calculator.flash_value_error().ignore();
|
||||
return (pv, sv);
|
||||
IEnumerable<string> _dirty_items() {
|
||||
if (_price_dirty.Value) yield return "price";
|
||||
if (_size_dirty.Value) yield return "size";
|
||||
if (_account_dirty.Value) yield return "account";
|
||||
if (_time_in_force_dirty.Value) yield return "tif";
|
||||
if (_order_type_dirty.Value) yield return "type";
|
||||
}
|
||||
protected override void _on_price_changed(double value) => _price_dirty.refresh();
|
||||
protected override void _on_size_changed(uint? value) => _size_dirty.refresh();
|
||||
protected override void _on_selected_account_changed(string value) => _account_dirty.refresh();
|
||||
protected override void _on_selected_time_in_force_changed(TimeInForce value) => _time_in_force_dirty.refresh();
|
||||
protected override void _on_selected_order_type_changed(IOrderTypeDefVM value) => _order_type_dirty.refresh();
|
||||
|
||||
(bool price_valid, bool size_valid) _validate_input() =>
|
||||
(_price_valid(), _size_valid());
|
||||
|
||||
bool _price_valid() =>
|
||||
!double.IsNaN(price) && price != 0;
|
||||
@@ -61,4 +107,4 @@ namespace mbts.spark {
|
||||
bool _size_valid() =>
|
||||
size_calculator.value.HasValue && size_calculator.value.Value != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,17 +5,31 @@ using System.Reactive.Linq;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace mbts.spark {
|
||||
class NewOrderTicketVM : OrderPropertiesEditorVM {
|
||||
class NewOrderTicketVM : OrderPropertiesEditorVM, IRequestViewClose {
|
||||
public NewOrderTicketVM(OrdersModel model, SecurityMD security_md, IObservable<LadderSettings> settings)
|
||||
: base(model, Observable.Return(security_md.security), settings) {
|
||||
bbo = new BBOVM(Observable.Return(security_md));
|
||||
send_order = new DelegateCommand<Side>(side => {
|
||||
if (DoubleHelper.IsNaNOrInfinityOr(price, 0)) flash_error(nameof(price)).ignore();
|
||||
else if (!HasErrors) model.send_order(create(side), price, size_calculator.value.Value).ignore();
|
||||
_validate_selected_account();
|
||||
_validate_selected_time_in_force();
|
||||
_validate_selected_order_type();
|
||||
_validate_price();
|
||||
size_calculator.validate();
|
||||
if (!HasErrors && !size_calculator.HasErrors) {
|
||||
model.send_order(create(side), price, size_calculator.value.Value).ignore();
|
||||
RequestClose?.Invoke(this, new EventArgs());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public event EventHandler RequestClose;
|
||||
|
||||
public BBOVM bbo { get; }
|
||||
public ICommand send_order { get; }
|
||||
|
||||
void _validate_price() {
|
||||
using (validation(nameof(price)))
|
||||
validation_assert(!DoubleHelper.IsNaNOrInfinityOr(price, 0), string.Empty, nameof(price));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<UserControl x:Class="mbts.ui.spark.OrderModificationControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:uc="clr-namespace:mbts.ui"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:usp="clr-namespace:mbts.ui.spark"
|
||||
xmlns:uag="clr-namespace:mbts.ui.spark.algo"
|
||||
@@ -20,9 +20,6 @@
|
||||
<Setter Property="Height" Value="{StaticResource ButtonHeight}"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
</Style>
|
||||
<Style TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
|
||||
<Setter Property="Height" Value="{StaticResource ButtonHeight}"/>
|
||||
</Style>
|
||||
<Style x:Key="TextPromptStyle" TargetType="TextBlock">
|
||||
<Setter Property="HorizontalAlignment" Value="Right"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
@@ -31,6 +28,28 @@
|
||||
<Setter Property="FontStyle" Value="Italic"/>
|
||||
<Setter Property="IsHitTestVisible" Value="False"/>
|
||||
</Style>
|
||||
<Style TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
|
||||
<Setter Property="Height" Value="{StaticResource ButtonHeight}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="usp:OrderModificationControl.IsDirty" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{u:BTSColor UI.input_dirty_border}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style TargetType="usp:PriceEntryControl" BasedOn="{StaticResource {x:Type usp:PriceEntryControl}}">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="usp:OrderModificationControl.IsDirty" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{u:BTSColor UI.input_dirty_border}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style TargetType="c:TickUpDownNullableUInt" BasedOn="{StaticResource {x:Type c:TickUpDownNullableUInt}}">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="usp:OrderModificationControl.IsDirty" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{u:BTSColor UI.input_dirty_border}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
@@ -58,9 +77,15 @@
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<usp:PriceEntryControl Grid.ColumnSpan="2" ContractSpec="{Binding security.ContractSpec}" Value="{Binding price}" TickDefaultValue="{Binding working_price, Converter={StaticResource NullableDoubleZeroConverter}}"/>
|
||||
<usp:PriceEntryControl
|
||||
Grid.ColumnSpan="2" ContractSpec="{Binding security.ContractSpec}" Value="{Binding price}"
|
||||
usp:OrderModificationControl.IsDirty="{Binding price_dirty, FallbackValue={x:Null}}"
|
||||
/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding current_price, Converter={StaticResource NullableDoubleTextConverter}}" Style="{StaticResource TextPromptStyle}"/>
|
||||
<c:TickUpDownNullableUInt Grid.Row="2" Grid.ColumnSpan="2" Value="{Binding size_calculator.value}" TickDefaultValue="{Binding working_size, Converter={StaticResource NullableIntConverter}}"/>
|
||||
<c:TickUpDownNullableUInt
|
||||
Grid.Row="2" Grid.ColumnSpan="2" Value="{Binding size_calculator.value}"
|
||||
usp:OrderModificationControl.IsDirty="{Binding size_dirty, FallbackValue={x:Null}}"
|
||||
/>
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding current_size, Converter={StaticResource NullableUIntTextConverter}}" Style="{StaticResource TextPromptStyle}"/>
|
||||
</Grid>
|
||||
<Grid Grid.Column="2">
|
||||
@@ -69,13 +94,13 @@
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalSpacing}}"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Command="{Binding set_price_command}" CommandParameter="{Binding bbo.bid}" Foreground="{uc:BTSColor MarketData.bid}" FontWeight="Bold">
|
||||
<Button Command="{Binding set_price_command}" CommandParameter="{Binding bbo.bid}" Foreground="{u:BTSColor MarketData.bid}" FontWeight="Bold">
|
||||
<MultiBinding Converter="{StaticResource TickDisplayConverter}">
|
||||
<Binding Path="bbo.bid"/>
|
||||
<Binding Path="security.ContractSpec"/>
|
||||
</MultiBinding>
|
||||
</Button>
|
||||
<Button Grid.Column="2" Command="{Binding set_price_command}" CommandParameter="{Binding bbo.ask}" Foreground="{uc:BTSColor MarketData.ask}" FontWeight="Bold">
|
||||
<Button Grid.Column="2" Command="{Binding set_price_command}" CommandParameter="{Binding bbo.ask}" Foreground="{u:BTSColor MarketData.ask}" FontWeight="Bold">
|
||||
<MultiBinding Converter="{StaticResource TickDisplayConverter}">
|
||||
<Binding Path="bbo.ask"/>
|
||||
<Binding Path="security.ContractSpec"/>
|
||||
@@ -88,8 +113,16 @@
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalSpacing}}"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Content="{Binding bbo.bid_size}" Command="{Binding size_calculator.set_value_command}" CommandParameter="{Binding bbo.bid_size}" Foreground="{uc:BTSColor MarketData.bid}"/>
|
||||
<Button Grid.Column="2" Content="{Binding bbo.ask_size}" Command="{Binding size_calculator.set_value_command}" CommandParameter="{Binding bbo.ask_size}" Foreground="{uc:BTSColor MarketData.ask}"/>
|
||||
<Button
|
||||
Content="{Binding bbo.bid_size}" Command="{Binding size_calculator.set_value_command}"
|
||||
CommandParameter="{Binding bbo.bid_size}" Foreground="{u:BTSColor MarketData.bid}"
|
||||
/>
|
||||
<Button
|
||||
Grid.Column="2"
|
||||
Content="{Binding bbo.ask_size}" Command="{Binding size_calculator.set_value_command}"
|
||||
CommandParameter="{Binding bbo.ask_size}"
|
||||
Foreground="{u:BTSColor MarketData.ask}"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="4" Grid.RowSpan="3">
|
||||
<Grid.RowDefinitions>
|
||||
@@ -105,7 +138,10 @@
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Button Margin="2,4,2,0" Command="{Binding Path=DataContext.click, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding}" Content="{Binding}" Focusable="False"/>
|
||||
<Button
|
||||
Margin="2,4,2,0" Content="{Binding}" Focusable="False" CommandParameter="{Binding}"
|
||||
Command="{Binding Path=DataContext.click, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
|
||||
/>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
@@ -118,9 +154,27 @@
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<ComboBox Grid.ColumnSpan="2" Margin="0,2" ItemsSource="{Binding accounts}" SelectedItem="{Binding selected_account}"/>
|
||||
<ComboBox Grid.Row="1" Grid.ColumnSpan="2" Margin="0,2" ItemsSource="{Binding time_in_forces}" SelectedItem="{Binding selected_time_in_force}"/>
|
||||
<uag:OrderDetailsPopupControl Grid.Row="2" Margin="0,2" ItemsSource="{Binding order_types}" SelectedItem="{Binding selected_order_type}"/>
|
||||
<ComboBox
|
||||
Grid.ColumnSpan="2" Margin="0,2" ItemsSource="{Binding accounts}" SelectedItem="{Binding selected_account}"
|
||||
usp:OrderModificationControl.IsDirty="{Binding account_dirty, FallbackValue={x:Null}}"
|
||||
/>
|
||||
<ComboBox
|
||||
Grid.Row="1" Grid.ColumnSpan="2" Margin="0,2" ItemsSource="{Binding time_in_forces}" SelectedItem="{Binding selected_time_in_force}"
|
||||
usp:OrderModificationControl.IsDirty="{Binding time_in_force_dirty, FallbackValue={x:Null}}"
|
||||
/>
|
||||
<uag:OrderDetailsPopupControl
|
||||
Grid.Row="2" Margin="0,2" ItemsSource="{Binding order_types}" SelectedItem="{Binding selected_order_type}"
|
||||
usp:OrderModificationControl.IsDirty="{Binding order_type_dirty, FallbackValue={x:Null}}">
|
||||
<uag:OrderDetailsPopupControl.Style>
|
||||
<Style TargetType="uag:OrderDetailsPopupControl" BasedOn="{StaticResource {x:Type uag:OrderDetailsPopupControl}}">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="usp:OrderModificationControl.IsDirty" Value="True">
|
||||
<Setter Property="BorderBrush" Value="{u:BTSColor UI.input_dirty_border}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</uag:OrderDetailsPopupControl.Style>
|
||||
</uag:OrderDetailsPopupControl>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1,22 +1,21 @@
|
||||
using bts.spark;
|
||||
using mbts.spark;
|
||||
using mbts.spark;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace mbts.ui.spark
|
||||
{
|
||||
namespace mbts.ui.spark {
|
||||
/// <summary>
|
||||
/// Interaction logic for OrderModificationControl.xaml
|
||||
/// </summary>
|
||||
public partial class OrderModificationControl : UserControl
|
||||
{
|
||||
public OrderModificationControl() {
|
||||
public partial class OrderModificationControl : UserControl {
|
||||
public static readonly DependencyProperty IsDirtyProperty = DependencyProperty.RegisterAttached("IsDirty", typeof(bool?), typeof(OrderModificationControl), new PropertyMetadata(null));
|
||||
public static bool? GetIsDirty(DependencyObject d) => d.GetValue(IsDirtyProperty) as bool?;
|
||||
public static void SetIsDirty(DependencyObject d, bool? value) => d.SetValue(IsDirtyProperty, value);
|
||||
|
||||
public OrderModificationControl() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
|
||||
internal class OrderModificationTemplateSelector : DataTemplateSelector
|
||||
{
|
||||
class OrderModificationTemplateSelector : DataTemplateSelector {
|
||||
public DataTemplate StopLimitOrderTemplate { get; set; }
|
||||
public DataTemplate StopMarketOrderTemplate { get; set; }
|
||||
public DataTemplate IcebergOrderTemplate { get; set; }
|
||||
@@ -36,4 +35,4 @@ namespace mbts.ui.spark
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
<Window x:Class="mbts.ui.spark.OrderModificationDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:cv="clr-namespace:mbts.ui.converters"
|
||||
xmlns:usp="clr-namespace:mbts.ui.spark"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
u:WindowStyle.SizeToContent="WidthAndHeight"
|
||||
u:WindowStyle.TitleContent="{Binding bbo, Mode=OneWay}"
|
||||
u:WindowStyle.CloseOnEscape="True"
|
||||
@@ -16,6 +17,9 @@
|
||||
<sys:Double x:Key="HorizontalSpacing">8.0</sys:Double>
|
||||
<sys:Double x:Key="VerticalSpacing">4.0</sys:Double>
|
||||
<sys:Double x:Key="ButtonHeight">22.0</sys:Double>
|
||||
<cv:ValueMap x:Key="DirtyItemsVisibilityConverter" Default="{u:Visibility Visible}">
|
||||
<cv:KeyValue Key="{x:Static sys:String.Empty}" Value="{u:Visibility Collapsed}"/>
|
||||
</cv:ValueMap>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
<Grid Margin="10">
|
||||
@@ -29,11 +33,30 @@
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalSpacing}}"/>
|
||||
<ColumnDefinition MinWidth="120"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<usp:OrderModificationControl Grid.ColumnSpan="3" />
|
||||
<Button Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MinHeight="40" Foreground="Red" FontWeight="Bold" Command="{Binding cancel_order}">
|
||||
<usp:OrderModificationControl Grid.ColumnSpan="3"/>
|
||||
<Button
|
||||
Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||
MinHeight="40" Foreground="Red" FontWeight="Bold" Command="{Binding cancel_order}"
|
||||
>
|
||||
<TextBlock TextWrapping="Wrap">Cancel Order</TextBlock>
|
||||
</Button>
|
||||
<Button Grid.Row="2" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MinHeight="40" FontWeight="Bold" Command="{Binding modify_order}">Modify</Button>
|
||||
<Button
|
||||
Grid.Row="2" Grid.Column="2" MinHeight="40"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||
Command="{Binding modify_order}"
|
||||
>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock HorizontalAlignment="Center" FontWeight="Bold">Modify</TextBlock>
|
||||
<TextBlock
|
||||
Grid.Row="1" Margin="0,4,0,0" FontSize="9" Text="{Binding dirty_items_text}"
|
||||
Visibility="{Binding dirty_items_text, Converter={StaticResource DirtyItemsVisibilityConverter}}"
|
||||
/>
|
||||
</Grid>
|
||||
</Button>
|
||||
</Grid>
|
||||
<u:WindowStyle.TitleContentTemplate>
|
||||
<DataTemplate>
|
||||
|
||||
@@ -32,19 +32,21 @@ namespace mbts.spark {
|
||||
readonly OrdersModel _model;
|
||||
readonly ObservableCollection<CustomOrderDefinition.CustomOneofCase> _order_types_model =
|
||||
new ObservableCollection<CustomOrderDefinition.CustomOneofCase>(EnumHelper.get_values_except(CustomOrderDefinition.CustomOneofCase.None));
|
||||
double _price = double.NaN;
|
||||
string _selected_account;
|
||||
TimeInForce _selected_time_in_force = TimeInForce.Undefined;
|
||||
IOrderTypeDefVM _selected_order_type;
|
||||
TimeInForce _selected_time_in_force;
|
||||
|
||||
protected OrderPropertiesEditorVM(OrdersModel model, IObservable<SecurityImmutable> security_source, IObservable<LadderSettings> settings)
|
||||
: this(model, security_source, settings.Select(s => new InlineOrderProperties(
|
||||
time_in_force:new InlineUserProperty<TimeInForce>(s.default_time_in_force, true),
|
||||
order_type_def:new InlineUserProperty<CustomOrderDefinition>(model.factory.custom_order(s.default_order_type), true))
|
||||
), settings.Select(s => s.calculator_buttons)) { }
|
||||
order_type_def:new InlineUserProperty<CustomOrderDefinition>(model.factory.custom_order(s.default_order_type), true),
|
||||
account:new InlineUserProperty<string>(model.factory.default_account)
|
||||
)), settings.Select(s => s.calculator_buttons)) { }
|
||||
|
||||
protected OrderPropertiesEditorVM(OrdersModel model, IObservable<SecurityImmutable> security_source, IObservable<InlineOrderProperties> order_properties, IObservable<int[]> calcuator_buttons) {
|
||||
_model = model;
|
||||
accounts = model.factory.accounts;
|
||||
selected_account = accounts[0];
|
||||
order_types = OrderTypeDefVMFactory.get_collection(model, _order_types_model, _on_order_type_is_ready_changed);
|
||||
set_price_command = new DelegateCommand<double>(p => {
|
||||
price = p;
|
||||
@@ -53,6 +55,7 @@ namespace mbts.spark {
|
||||
InlineOrderProperties props = new InlineOrderProperties();
|
||||
_dispose = Disposable.Create(
|
||||
size_calculator = new CalculatorLogic(0, calcuator_buttons),
|
||||
size_calculator.value_observable.ObserveOnDispatcher().Subscribe(_on_size_changed),
|
||||
security_source.ObserveOnDispatcher().Subscribe(s => {
|
||||
using (detect_property_changes()) {
|
||||
security = s;
|
||||
@@ -116,23 +119,32 @@ namespace mbts.spark {
|
||||
public event Action<SecurityImmutable> security_changed;
|
||||
|
||||
public SecurityImmutable security { get; private set; } = SecurityDataHelper.Defaults.SecurityImmutable;
|
||||
public double price { get; set; } = double.NaN;
|
||||
public double price { get => _price; set { _on_price_changed(_price = value); } }
|
||||
public CalculatorLogic size_calculator { get; }
|
||||
public string[] accounts { get; }
|
||||
public string selected_account { get; set; }
|
||||
public string selected_account { get => _selected_account; set => _on_selected_account_changed(_selected_account = value); }
|
||||
public ObservableCollection<TimeInForce> time_in_forces { get; } = new ObservableCollection<TimeInForce>();
|
||||
public TimeInForce selected_time_in_force { get => _selected_time_in_force; set { _selected_time_in_force = value; _validate_selected_time_in_force(); } }
|
||||
public TimeInForce selected_time_in_force { get => _selected_time_in_force; set { _on_selected_time_in_force_changed(_selected_time_in_force = value); _validate_selected_time_in_force(); } }
|
||||
public ObservableAutoWrapper<IOrderTypeDefVM, CustomOrderDefinition.CustomOneofCase> order_types { get; }
|
||||
public IOrderTypeDefVM selected_order_type {
|
||||
get => _selected_order_type;
|
||||
set {
|
||||
if ((value is ILazyOrderTypeDefVM lvm) && !lvm.is_initialized)
|
||||
lvm.initialize();
|
||||
_selected_order_type = value;
|
||||
_on_selected_order_type_changed(_selected_order_type = value);
|
||||
_validate_selected_order_type();
|
||||
}
|
||||
}
|
||||
public ICommand set_price_command { get; }
|
||||
// these virtual properties avoid binding errors for properties that only apply to the modify ticket.
|
||||
// writing different templates for each ticket, while a better solution in theory, would be way more code/work than it's worth.
|
||||
public virtual double? current_price => null;
|
||||
public virtual uint? current_size => null;
|
||||
public virtual bool? price_dirty => null;
|
||||
public virtual bool? size_dirty => null;
|
||||
public virtual bool? account_dirty => null;
|
||||
public virtual bool? time_in_force_dirty => null;
|
||||
public virtual bool? order_type_dirty => null;
|
||||
|
||||
protected OrderDefinition create(Side side) {
|
||||
if (HasErrors) throw new InvalidOperationException("Cannot create order when errors are present.");
|
||||
@@ -144,12 +156,23 @@ namespace mbts.spark {
|
||||
return order;
|
||||
}
|
||||
|
||||
void _validate_selected_time_in_force() {
|
||||
protected virtual void _on_price_changed(double value) { }
|
||||
protected virtual void _on_size_changed(uint? value) { }
|
||||
protected virtual void _on_selected_account_changed(string value) { }
|
||||
protected virtual void _on_selected_time_in_force_changed(TimeInForce value) { }
|
||||
protected virtual void _on_selected_order_type_changed(IOrderTypeDefVM value) { }
|
||||
|
||||
protected void _validate_selected_account() {
|
||||
using (validation(nameof(selected_account)))
|
||||
validation_assert(selected_account != null && accounts.Contains(selected_account), string.Empty, nameof(selected_account));
|
||||
}
|
||||
|
||||
protected void _validate_selected_time_in_force() {
|
||||
using (validation(nameof(selected_time_in_force)))
|
||||
validation_assert(time_in_forces.Contains(selected_time_in_force), string.Empty, nameof(selected_time_in_force));
|
||||
}
|
||||
|
||||
void _validate_selected_order_type() {
|
||||
protected void _validate_selected_order_type() {
|
||||
using (validation(nameof(selected_order_type))) {
|
||||
var svm = _selected_order_type as ISecurityOrderTypeDefVM;
|
||||
validation_assert(
|
||||
@@ -163,5 +186,5 @@ namespace mbts.spark {
|
||||
if (sender == _selected_order_type)
|
||||
_validate_selected_order_type();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +1,52 @@
|
||||
using mbts.ui;
|
||||
using mbts.ui.shell;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace mbts.spark {
|
||||
public class CalculatorLogic : DisposableViewModelBase {
|
||||
readonly Property<uint?> _value;
|
||||
readonly Property<int[]> _buttons;
|
||||
|
||||
public CalculatorLogic(uint? initial_size, IObservable<int[]> buttons_source) {
|
||||
_size = backing(nameof(value), initial_size);
|
||||
_value = backing(nameof(value), initial_size);
|
||||
_buttons = backing(nameof(buttons), buttons_source);
|
||||
}
|
||||
|
||||
Property<uint?> _size;
|
||||
public uint? value { get => _size.Value; set => _size.set(value); }
|
||||
Property<int[]> _buttons;
|
||||
public uint? value { get => _value.Value; set => _value.set(value); }
|
||||
public IObservable<uint?> value_observable => _value.Select(vals => vals.newval);
|
||||
public int[] buttons { get => _buttons.Value; set => _buttons.set(value); }
|
||||
public ICommand click => new DelegateCommand<uint>(handle_calculator_click);
|
||||
public ICommand set_value_command => new DelegateCommand<uint>(v => _size.Value = v);
|
||||
public ICommand clear => new DelegateCommand(() => _size.Value = null);
|
||||
public ICommand set_value_command => new DelegateCommand<uint>(v => _value.Value = v);
|
||||
public ICommand clear => new DelegateCommand(() => _value.Value = null);
|
||||
|
||||
public async Task flash_value_error() =>
|
||||
await flash_error(nameof(value));
|
||||
public void validate() {
|
||||
using (validation(nameof(value)))
|
||||
validation_assert(value.HasValue && value.Value != 0, string.Empty, nameof(value));
|
||||
}
|
||||
|
||||
private void handle_calculator_click(uint value) {
|
||||
public void flash_error() =>
|
||||
flash_error(nameof(value)).ignore();
|
||||
|
||||
void handle_calculator_click(uint value) {
|
||||
if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift) || value == 0) {
|
||||
_size.Value = value;
|
||||
_value.Value = value;
|
||||
} else if (KeyboardExtensions.IsCtrlDown()) {
|
||||
if (!_size.Value.HasValue)
|
||||
_size.Value = 0;
|
||||
if (!_value.Value.HasValue)
|
||||
_value.Value = 0;
|
||||
else {
|
||||
if (value > _size.Value)
|
||||
_size.Value = 0;
|
||||
if (value > _value.Value)
|
||||
_value.Value = 0;
|
||||
else
|
||||
_size.Value -= value;
|
||||
_value.Value -= value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!_size.Value.HasValue)
|
||||
_size.Value = value;
|
||||
if (!_value.Value.HasValue)
|
||||
_value.Value = value;
|
||||
else
|
||||
_size.Value += value;
|
||||
_value.Value += value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,10 +36,11 @@ namespace mbts.spark.utilities {
|
||||
users = new HashSet<string>(accounts) { _login }.Ordered().ToLArray();
|
||||
}
|
||||
|
||||
#region Defaults
|
||||
public string default_account => accounts[0];
|
||||
public string[] accounts { get; } = new[] { "BTS1", "BTS2", "BTS3", "BTS4" };
|
||||
public string[] users { get; }
|
||||
|
||||
#region Defaults
|
||||
public CustomOrderDefinition.CustomOneofCase default_order_type() =>
|
||||
CustomOrderDefinition.CustomOneofCase.Limit;
|
||||
|
||||
|
||||
Reference in new issue
Block a user