ui: Refine combo win
* make call/put toggle a spark menu item (in the toolbar) * dock account/risk terms to the left * hide account/risk terms labels (show them as tooltips instead)
This commit is contained in:
1 parent
cc0380d8f1
commit
a53dfd14b1
6 files changed
+82
-25
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using bts;
|
||||
using bts.collections;
|
||||
using bts.utils;
|
||||
|
||||
using mbts.ui.dpi;
|
||||
@@ -28,6 +29,7 @@ namespace mbts.ui {
|
||||
AddFileThinGeometryKey = nameof(AddFileThinGeometryKey),
|
||||
ArrowGeometryKey = nameof(ArrowGeometryKey),
|
||||
AttachAlgosKey = nameof(AttachAlgosKey),
|
||||
CallPutGeometryKey = nameof(CallPutGeometryKey),
|
||||
CheckMarkGeometryKey = nameof(CheckMarkGeometryKey),
|
||||
CopyWFGeometryKey = nameof(CopyWFGeometryKey),
|
||||
CopyBoxesGeometryKey = nameof(CopyBoxesGeometryKey),
|
||||
@@ -167,6 +169,21 @@ namespace mbts.ui {
|
||||
|
||||
public static ImageSource analytics => Math;
|
||||
public static ImageSource ModifyOrder { get { return load_resource_and_freeze("ModifyOrder"); } }
|
||||
|
||||
public static ImageSource call_put_checked =>
|
||||
create_checked_icon(
|
||||
CallPutGeometryKey,
|
||||
brush: Brushes.Black,
|
||||
check_brush: Brushes.Black,
|
||||
check_off_x_pct: 0.9);
|
||||
|
||||
public static ImageSource call_put_unchecked =>
|
||||
create_checked_icon(
|
||||
CallPutGeometryKey,
|
||||
brush: Brushes.Black,
|
||||
check_brush: Brushes.Transparent,
|
||||
check_off_x_pct: 0.9);
|
||||
|
||||
public static ImageSource CheckMark => create_icon(CheckMarkGeometryKey);
|
||||
public static ImageSource ChevronRight => new DrawingImage(create_chevron_right_drawing());
|
||||
public static ImageSource ChevronDown => new DrawingImage(create_chevron_down_drawing());
|
||||
|
||||
@@ -423,6 +423,12 @@
|
||||
M15.999513,0C16.50052,-3.8678991E-07,17.001274,0.21826346,17.288297,0.65479128L31.74151,22.585975C32.057495,23.064982 32.084472,23.677966 31.812494,24.184989 31.541494,24.687009 31.02049,24.999999 30.450475,24.999999L1.5480773,24.999999C0.97903845,24.999999 0.45705819,24.687009 0.18703459,24.184989 -0.085979476,23.677966 -0.057963934,23.064982 0.25704309,22.585975L14.709219,0.65479128C14.997247,0.21826346,15.498506,-3.8678991E-07,15.999513,0z
|
||||
</sys:String>
|
||||
|
||||
<x:Array x:Key="{x:Static mbts:Icons.CallPutGeometryKey}" Type="sys:String">
|
||||
<sys:String>
|
||||
M 11.736 2.328 L 11.04 4.248 Q 10.296 3.888 9.516 3.672 Q 8.846 3.486 7.972 3.46 A 9.769 9.769 0 0 0 7.68 3.456 A 5.081 5.081 0 0 0 5.783 3.805 A 4.795 4.795 0 0 0 4.932 4.248 A 5.08 5.08 0 0 0 3.404 5.827 A 6.475 6.475 0 0 0 3.024 6.528 Q 2.383 7.9 2.332 9.802 A 12.382 12.382 0 0 0 2.328 10.128 A 10.047 10.047 0 0 0 2.476 11.893 A 7.423 7.423 0 0 0 3.012 13.656 A 6.163 6.163 0 0 0 3.873 15.055 A 5.142 5.142 0 0 0 4.908 16.008 A 4.729 4.729 0 0 0 7.583 16.847 A 5.734 5.734 0 0 0 7.68 16.848 A 8.092 8.092 0 0 0 8.633 16.795 Q 9.227 16.724 9.72 16.56 Q 10.584 16.272 11.4 15.816 L 12.096 17.712 A 9.015 9.015 0 0 1 11.017 18.203 A 11.495 11.495 0 0 1 10.068 18.516 Q 9.002 18.819 7.61 18.839 A 13.78 13.78 0 0 1 7.416 18.84 Q 5.232 18.84 3.552 17.796 A 6.864 6.864 0 0 1 1.182 15.289 A 8.38 8.38 0 0 1 0.936 14.82 A 9.027 9.027 0 0 1 0.192 12.488 Q 0.006 11.464 0 10.299 A 15.082 15.082 0 0 1 0 10.224 Q 0 7.656 0.948 5.676 Q 1.896 3.696 3.636 2.58 A 7.049 7.049 0 0 1 6.679 1.521 A 8.95 8.95 0 0 1 7.704 1.464 A 10.953 10.953 0 0 1 8.918 1.528 A 8.448 8.448 0 0 1 9.888 1.692 A 9.174 9.174 0 0 1 11.682 2.303 A 8.552 8.552 0 0 1 11.736 2.328 Z M 28.296 18.552 L 26.016 18.552 L 26.016 1.8 Q 27 1.68 28.188 1.62 A 48.193 48.193 0 0 1 30.331 1.561 A 53.263 53.263 0 0 1 30.648 1.56 Q 32.736 1.56 34.2 2.22 A 5.906 5.906 0 0 1 35.42 2.947 A 4.65 4.65 0 0 1 36.432 4.032 Q 37.2 5.184 37.2 6.672 A 6.062 6.062 0 0 1 37.03 8.141 A 4.624 4.624 0 0 1 36.312 9.72 A 5.355 5.355 0 0 1 34.5 11.311 A 6.736 6.736 0 0 1 33.84 11.628 A 8.346 8.346 0 0 1 31.899 12.162 A 11.327 11.327 0 0 1 30.168 12.288 A 24.966 24.966 0 0 1 29.08 12.265 A 19.903 19.903 0 0 1 28.296 12.216 L 28.296 18.552 Z M 22.728 0.6 L 15.96 20.256 L 14.184 19.656 L 20.952 0 L 22.728 0.6 Z M 28.296 3.576 L 28.296 10.272 A 11.512 11.512 0 0 0 28.608 10.306 Q 28.747 10.32 28.904 10.332 A 23.1 23.1 0 0 0 29.232 10.356 Q 29.784 10.392 30.456 10.392 Q 32.592 10.392 33.768 9.432 A 3.095 3.095 0 0 0 34.933 7.166 A 4.157 4.157 0 0 0 34.944 6.864 A 3.468 3.468 0 0 0 34.762 5.714 A 2.913 2.913 0 0 0 33.816 4.392 A 3.711 3.711 0 0 0 32.597 3.753 Q 31.742 3.48 30.6 3.48 Q 29.952 3.48 29.376 3.504 Q 28.8 3.528 28.296 3.576 Z
|
||||
</sys:String>
|
||||
</x:Array>
|
||||
|
||||
<!--
|
||||
'y' for equilateral triangle of side length x:
|
||||
(x/2)^2 + Y^2 = x^2
|
||||
|
||||
@@ -14,7 +14,8 @@ namespace mbts.analytics {
|
||||
|
||||
public static ComboReportSettings Default(int id = -1) =>
|
||||
new() {
|
||||
id = id
|
||||
id = id,
|
||||
show_upper_status_bar = true
|
||||
};
|
||||
|
||||
[ProtoMember(1)]
|
||||
@@ -23,6 +24,8 @@ namespace mbts.analytics {
|
||||
public ComboViewFormat view_format { get; set; }
|
||||
[ProtoMember(3)]
|
||||
public bool show_call_put { get; set; }
|
||||
[ProtoMember(5)]
|
||||
public bool show_upper_status_bar { get; set; }
|
||||
|
||||
[ProtoMember(4)]
|
||||
public SparkMenuDisplaySettings menu_display { get; set; } = SparkMenuDisplaySettings.Default;
|
||||
@@ -35,6 +38,7 @@ namespace mbts.analytics {
|
||||
id == other.id &&
|
||||
view_format == other.view_format &&
|
||||
show_call_put == other.show_call_put &&
|
||||
show_upper_status_bar == other.show_upper_status_bar &&
|
||||
menu_display.Equals(other.menu_display);
|
||||
|
||||
public override bool Equals(object? obj) =>
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace mbts.analytics {
|
||||
using mbts.ui;
|
||||
using mbts.ui.shell;
|
||||
|
||||
using Spark.ViewModel.Commands;
|
||||
|
||||
using System;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows;
|
||||
@@ -12,19 +14,21 @@ namespace mbts.analytics {
|
||||
readonly ComboDataModel _model;
|
||||
readonly DelegateProperty<string> _status_bar_text;
|
||||
readonly Property<ComboViewFormat> _view_format;
|
||||
readonly Property<bool> _show_call_put;
|
||||
|
||||
ComboFullData _data = ComboFullData.Empty;
|
||||
string? _internal_account;
|
||||
string? _risk_terms_name;
|
||||
bool _show_call_put;
|
||||
|
||||
public ComboReportVM(ComboDataModel model, ComboReportSettings settings) {
|
||||
_model = model;
|
||||
_show_call_put = settings.show_call_put;
|
||||
_show_call_put = backing(nameof(show_call_put), settings.show_call_put);
|
||||
_view_format = backing(nameof(view_format), settings.view_format);
|
||||
show_upper_status_bar = settings.show_upper_status_bar;
|
||||
_status_bar_text = backing(nameof(status_bar_text), get_status_bar_text);
|
||||
launch_settings_editor_cmd = new DialogCommand(mk_settings_win, () => _data is not null);
|
||||
_dispose = Disposable.Create(
|
||||
toggle_show_upper_status_bar_cmd.bind(this, nameof(show_upper_status_bar)),
|
||||
model.data_source.OnDispatcher().Subscribe(on_data),
|
||||
_view_format.observe_current(true).Subscribe(on_view_format),
|
||||
launch_settings_editor_cmd);
|
||||
@@ -80,22 +84,30 @@ namespace mbts.analytics {
|
||||
_view_format.observe_current(true);
|
||||
|
||||
public bool show_call_put {
|
||||
get => _show_call_put;
|
||||
set => Set(ref _show_call_put, value);
|
||||
get => _show_call_put.Value;
|
||||
set => _show_call_put.set(value);
|
||||
}
|
||||
public IObservable<bool> show_call_put_observable =>
|
||||
_show_call_put.observe_current(true);
|
||||
|
||||
public bool show_upper_status_bar {
|
||||
get => toggle_show_upper_status_bar_cmd.is_selected;
|
||||
set => toggle_show_upper_status_bar_cmd.is_selected = value;
|
||||
}
|
||||
public string status_bar_text => _status_bar_text.Value;
|
||||
|
||||
public ComboFuturesGrid futures_grid { get; } = new();
|
||||
public ComboOptionsGrid options_grid { get; } = new();
|
||||
|
||||
public IToggleCommand toggle_show_upper_status_bar_cmd { get; } = new ToggleCommand();
|
||||
public IDialogCommand launch_settings_editor_cmd { get; }
|
||||
|
||||
public ComboReportSettings get_state(int report_id) =>
|
||||
new() {
|
||||
id = report_id,
|
||||
view_format = view_format,
|
||||
show_call_put = show_call_put
|
||||
show_call_put = show_call_put,
|
||||
show_upper_status_bar = show_upper_status_bar
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:cv="clr-namespace:mbts.ui.converters"
|
||||
xmlns:analytics="clr-namespace:mbts.analytics"
|
||||
Background="{StaticResource CommonBackground}"
|
||||
TextElement.FontSize="11"
|
||||
@@ -58,26 +59,26 @@
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="8">
|
||||
<GroupBox Header="View" Padding="4">
|
||||
<c:RadioButtonsControl ItemsSource="{u:EnumBindingSource {u:Nested analytics:ComboViewFormat}}" SelectedItem="{Binding view_format}" />
|
||||
</GroupBox>
|
||||
<CheckBox Margin="12,7,0,0" Content="Show Call/Put" IsChecked="{Binding show_call_put}" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="8">
|
||||
<TextBlock Margin="8,0,0,0" VerticalAlignment="Center">
|
||||
<TextBlock.Inlines>
|
||||
<Run Text="Internal Account: "/>
|
||||
<Run Text="{Binding internal_account, Mode=OneWay}" FontWeight="Bold"/>
|
||||
</TextBlock.Inlines>
|
||||
</TextBlock>
|
||||
<TextBlock Margin="8,0,0,0" VerticalAlignment="Center">
|
||||
<TextBlock.Inlines>
|
||||
<Run Text="Risk Terms: "/>
|
||||
<Run Text="{Binding risk_terms_name, Mode=OneWay}" FontWeight="Bold"/>
|
||||
</TextBlock.Inlines>
|
||||
</TextBlock>
|
||||
|
||||
<StackPanel
|
||||
Margin="8"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{Binding show_upper_status_bar, Converter={x:Static cv:BooleanToVisibilityConverter.Instance}}">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontWeight="Bold"
|
||||
Text="{Binding internal_account, Mode=OneWay}"
|
||||
ToolTip="Internal Account" />
|
||||
|
||||
<TextBlock VerticalAlignment="Center" Margin="4,0" Text="|" />
|
||||
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontWeight="Bold"
|
||||
Text="{Binding risk_terms_name, Mode=OneWay}"
|
||||
ToolTip="Risk Terms" />
|
||||
</StackPanel>
|
||||
|
||||
<AdornerDecorator Grid.Row="1" Height="Auto" VerticalAlignment="Top">
|
||||
<c:DataGridEx
|
||||
DataContext="{Binding futures_grid, Mode=OneWay}"
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace mbts.analytics {
|
||||
|
||||
using mbts.ui;
|
||||
|
||||
using Spark.Model;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
@@ -60,6 +62,12 @@ namespace mbts.analytics {
|
||||
};
|
||||
_commands.AddRange(
|
||||
mk_toggle_expanded_cmd(),
|
||||
mk_toggle_show_call_put_cmd(),
|
||||
new SparkMenuItemToggleModel(
|
||||
"Show Account & Risk Terms", cmd: _vm.toggle_show_upper_status_bar_cmd) {
|
||||
show_in_context_menu = true,
|
||||
show_in_toolbar = false
|
||||
},
|
||||
new SparkCommandCommand("Settings", Icons.Gear, _vm.launch_settings_editor_cmd),
|
||||
_menu_display_vm.spark_cmd);
|
||||
|
||||
@@ -73,6 +81,15 @@ namespace mbts.analytics {
|
||||
}));
|
||||
return spark_cmd;
|
||||
}
|
||||
|
||||
SparkCommandCommand mk_toggle_show_call_put_cmd() {
|
||||
var cmd = new Command(() => _vm.show_call_put = !_vm.show_call_put);
|
||||
var spark_cmd = new SparkCommandCommand("Show Call/Put", null, cmd);
|
||||
|
||||
_vm.SubscribeDisposed(_vm.show_call_put_observable.Subscribe(
|
||||
show => spark_cmd.icon = show ? Icons.call_put_checked : Icons.call_put_unchecked));
|
||||
return spark_cmd;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnParentViewCreated(SparkWindowView parent_view) =>
|
||||
|
||||
Reference in new issue
Block a user