Compare commits
53
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d421fdb41f | ||
|
|
6cbff72bc3 | ||
|
|
d81f5b87fc | ||
|
|
fe6f4ffa92 | ||
|
|
7841faafa2 | ||
|
|
89df89db11 | ||
|
|
03867914cb | ||
|
|
52f62c19a4 | ||
|
|
860bda388f | ||
|
|
0b73e2744e | ||
|
|
e5d23a987e | ||
|
|
6ac3eeca2e | ||
|
|
3b73ba25d2 | ||
|
|
34eed73af5 | ||
|
|
2f1f1c007c | ||
|
|
cac4f5da37 | ||
|
|
58dab25b89 | ||
|
|
7d100da9b1 | ||
|
|
c389a47a4a | ||
|
|
d3d069cf17 | ||
|
|
9576122aeb | ||
|
|
a32b40bef6 | ||
|
|
d9f459ccb5 | ||
|
|
18bdeea765 | ||
|
|
87bf9a37cc | ||
|
|
96b6c0fc1d | ||
|
|
0cee53e287 | ||
|
|
db135a36d9 | ||
|
|
bd8dbe0071 | ||
|
|
4f0a01175e | ||
|
|
1f8af68b60 | ||
|
|
5f2a2a7a56 | ||
|
|
6a0e00222c | ||
|
|
c087999c4b | ||
|
|
763f8f006d | ||
|
|
32257f257e | ||
|
|
4903545642 | ||
|
|
6eb3cf5cf6 | ||
|
|
cdcd0d0436 | ||
|
|
e04ac0592b | ||
|
|
0a3cbc8539 | ||
|
|
fb2385041c | ||
|
|
98685e59b3 | ||
|
|
bf9e6a645a | ||
|
|
6d02d9a508 | ||
|
|
2a8a459cdd | ||
|
|
e25d039f3b | ||
|
|
5cdaa60b86 | ||
|
|
ff33d0d735 | ||
|
|
8ba1c7a602 | ||
|
|
8ef5dd56ee | ||
|
|
c3c1a33081 | ||
|
|
4c0461311f |
No files matched your search
@@ -41,7 +41,6 @@ namespace mbts.ui {
|
||||
EditDocumentAltGeometryKey = nameof(EditDocumentAltGeometryKey),
|
||||
EditDocumentGeometryKey = nameof(EditDocumentGeometryKey),
|
||||
GearGeometryKey = nameof(GearGeometryKey),
|
||||
HamburgerMenuGeometryKey = nameof(HamburgerMenuGeometryKey),
|
||||
HornGeometryKey = nameof(HornGeometryKey),
|
||||
KeyGeometryKey = nameof(KeyGeometryKey),
|
||||
LetterAKey = nameof(LetterAKey),
|
||||
@@ -175,7 +174,6 @@ namespace mbts.ui {
|
||||
public static ImageSource FilterActive { get { return load_resource_and_freeze("FilterActive"); } }
|
||||
public static ImageSource FilterError { get { return load_resource_and_freeze("FilterError"); } }
|
||||
public static ImageSource Gear => create_icon(GearGeometryKey);
|
||||
public static ImageSource HamburgerMenu => create_icon(HamburgerMenuGeometryKey);
|
||||
public static ImageSource Horn => create_icon(HornGeometryKey);
|
||||
public static ImageSource Import => load_resource_and_freeze("Import");
|
||||
public static ImageSource Key => create_icon(KeyGeometryKey);
|
||||
|
||||
@@ -13,10 +13,6 @@
|
||||
M19.522852,25.255011L20.920847,25.256994 20.920847,29.729012 19.522852,29.729012z M22.826874,21.952002L25.989905,25.113989 25.001887,26.101996 21.838856,22.941015z M25.269894,19.506992L29.742937,19.509007 29.742937,20.906012 25.269894,20.907995z M10.519729,14.945011C11.300744,14.954991,12.079745,15.103001,12.818766,15.386997L10.878742,17.327C9.6457264,17.200016,8.368704,17.592014,7.4257004,18.532993L3.597655,22.359015C1.9326275,24.025 1.9316508,26.734991 3.597655,28.40299 5.2636887,30.068001 7.9747178,30.066017 9.6397144,28.40299L13.468767,24.575018C14.410794,23.633001,14.800783,22.355993,14.674774,21.122015L16.615807,19.181004C17.523806,21.547003,17.034817,24.325995,15.126776,26.233008L11.298761,30.061012C8.713709,32.644997 4.5236599,32.644997 1.9396465,30.061012 -0.64638097,27.475012 -0.64638097,23.286017 1.9386395,20.702002L5.7666852,16.875004C7.0777046,15.562992,8.8017227,14.922001,10.519729,14.945011z M2.1536381,10.959994L6.6257035,10.959994 6.6266801,12.359988 2.1536381,12.359988z M6.7686803,5.894014L9.9307338,9.0549947 8.9427158,10.044008 5.7806932,6.8819901z M10.976735,2.1390082L12.374761,2.1390082 12.375768,6.6130081 10.975728,6.6130081z M25.382902,0C27.076922,-1.8170738E-08 28.770941,0.6470033 30.063955,1.9389956 32.646992,4.5220043 32.646992,8.7130147 30.061941,11.297L26.234902,15.126011C24.326891,17.032993,21.546862,17.521,19.181845,16.614994L21.121868,14.674015C22.35586,14.798008,23.63389,14.407992,24.575886,13.467013L28.403933,9.6390096C30.067953,7.972994 30.069967,5.2619945 28.403933,3.5960094 26.738905,1.9310002 24.0269,1.9320073 22.361872,3.5960094L18.533827,7.4249893C17.591829,8.3659993,17.201811,9.6440145,17.32782,10.87601L15.385781,12.817996C14.477781,10.453005,14.968784,7.6730062,16.875818,5.7659928L20.702858,1.9379885C21.994864,0.64599622,23.688883,-1.8170738E-08,25.382902,0z
|
||||
</sys:String>
|
||||
|
||||
<sys:String x:Key="{x:Static mbts:Icons.HamburgerMenuGeometryKey}">
|
||||
M2.384186E-06,24L32.000004,24 32.000004,26 2.384186E-06,26z M0,11.999998L32,11.999998 32,13.999998 0,13.999998z M2.384186E-06,0L32.000004,0 32.000004,2 2.384186E-06,2z
|
||||
</sys:String>
|
||||
|
||||
<DrawingImage x:Key="{x:Static mbts:Icons.AddBoxKey}">
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup>
|
||||
|
||||
@@ -76,20 +76,19 @@ namespace mbts.spark {
|
||||
};
|
||||
return ob_settings;
|
||||
}), SparkCommands.window_settings_command(new DialogCommand(() => {
|
||||
var dialog_vm = new ShellSettingsDialogVM<GridSettings, GridSettingsVM>(
|
||||
var vm = new ShellSettingsDialogVM<GridSettings, SimpleGridSettingsVM>(
|
||||
_settings_manager,
|
||||
us => us.synthetic_management_grid,
|
||||
UserSettings.FileExtensions.GRID,
|
||||
s => {
|
||||
var gs_vm = _vm.value.grid_settings_manager.create_vm();
|
||||
s => _vm.value.grid_settings_manager.create_vm(
|
||||
// we need to get the most up to date GridSettings when launching b/c users may
|
||||
// have changed some settings on the grid directly, like column widths.
|
||||
gs_vm.load(s.with(_vm.value.columns.Select(c => c.create())));
|
||||
return gs_vm;
|
||||
});
|
||||
dialog_vm.SubscribeDisposed(literal_title_source.OnDispatcher().Subscribe(t => dialog_vm.title = t));
|
||||
var dialog = new ShellSettingsDialog { DataContext = dialog_vm };
|
||||
dialog_vm.RequestClose += (s, e) => WindowUtilities.force_close(dialog);
|
||||
s.with(_vm.value.columns.Select(c => c.create()))
|
||||
)
|
||||
);
|
||||
vm.SubscribeDisposed(literal_title_source.OnDispatcher().Subscribe(t => vm.title = t));
|
||||
var dialog = new ShellSettingsDialog { Title = "Synthetic Management Grid Settings", DataContext = vm };
|
||||
vm.RequestClose += (s, e) => WindowUtilities.force_close(dialog);
|
||||
return dialog;
|
||||
}))
|
||||
};
|
||||
|
||||
@@ -68,23 +68,19 @@ namespace mbts.spark {
|
||||
Width = width
|
||||
});
|
||||
//
|
||||
grid_settings_manager = new GridSettingsManager(columns);
|
||||
grid_settings_manager = new SimpleGridSettingsManager<Row>(columns, DictionaryHelper.empty<string, GridColumnSettingsFeatureFlags>(), row_vms);
|
||||
// this will initialize the immutable properties that correspond to the col_settings_flags above (e.g. Bid/Ask font_color_override, etc.)
|
||||
grid_settings_manager.load_from(settings_manager.current_settings());
|
||||
|
||||
_resources.AddRange(
|
||||
orders_model.admin_model.all_user_tuples.OnDispatcher().Subscribe(user_filter_items_observer),
|
||||
DataGridFilterHelper.hook_all<SyntheticManagementDialogVM, Row>(this, rows_view),
|
||||
settings_manager.subscribe_current().OnDispatcher().Subscribe(s => {
|
||||
grid_settings_manager.load_from(s);
|
||||
foreach (var r in row_vms)
|
||||
r.raise_invalidated();
|
||||
})
|
||||
settings_manager.subscribe_current().OnDispatcher().Subscribe(grid_settings_manager)
|
||||
);
|
||||
}
|
||||
|
||||
public ObservableCollection<ColumnBase> columns { get; } = new ObservableCollection<ColumnBase>();
|
||||
public GridSettingsManager grid_settings_manager { get; }
|
||||
public SimpleGridSettingsManager<Row> grid_settings_manager { get; }
|
||||
|
||||
public IDataGridColumnPersistentFilter<Row, TimeFilterTuple> create_time_filter { get; } = new TimeFilterVM<Row>(r => r.create_time, nameof(Row.create_time));
|
||||
public IDataGridColumnPersistentFilter<Row, string> name_filter { get; } = new RegexFilterVM<Row>(r => r.name, nameof(Row.name));
|
||||
|
||||
@@ -6,7 +6,6 @@ using mbts.config;
|
||||
using mbts.persist;
|
||||
using mbts.spark;
|
||||
using mbts.ui;
|
||||
using mbts.ui.converters;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.spark;
|
||||
using ProtoBuf;
|
||||
@@ -19,7 +18,6 @@ using System.Reactive.Linq;
|
||||
using System.Reactive.Subjects;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using LadderSettings = mbts.spark.LadderSettings;
|
||||
|
||||
namespace bts.shell {
|
||||
@@ -216,21 +214,7 @@ namespace bts.shell {
|
||||
settings_id);
|
||||
dialog_vm.applied += apply;
|
||||
// dialog
|
||||
var dialog = new ShellSettingsDialog {
|
||||
DataContext = dialog_vm,
|
||||
};
|
||||
dialog.SetBinding(FrameworkElement.MinWidthProperty, new Binding(nameof(Window.SizeToContent)) {
|
||||
Source = dialog,
|
||||
Converter = new WindowMinWidthConverter {
|
||||
SizeToContentThreshold = 657
|
||||
}
|
||||
});
|
||||
dialog.SetBinding(FrameworkElement.MinHeightProperty, new Binding(nameof(Window.SizeToContent)) {
|
||||
Source = dialog,
|
||||
Converter = new WindowMinHeightConverter {
|
||||
SizeToContentThreshold = 331
|
||||
}
|
||||
});
|
||||
var dialog = new ShellSettingsDialog { DataContext = dialog_vm };
|
||||
dialog_vm.SubscribeDisposed(title_source.OnDispatcher().Subscribe(t => dialog_vm.title = t));
|
||||
dialog.Resources[ShellSettingsDialog.SecurityMapKey] = _securities;
|
||||
dialog_vm.RequestClose += on_request_close;
|
||||
|
||||
@@ -12,7 +12,6 @@ using mbts.ui.controls.color_picker;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.spark;
|
||||
using mbts.ui.utility;
|
||||
using mbts.ui.viewmodels;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -106,13 +105,12 @@ namespace mbts.spark {
|
||||
};
|
||||
// update
|
||||
_update = new DeferrableActionWrapper(() => result_changed?.Invoke());
|
||||
mini_ob.result_changed += _update.execute;
|
||||
foreach (var c in _observable_components)
|
||||
c.PropertyChanged += on_prop_changed;
|
||||
favorite_algos_vm.items.CollectionChanged += on_favorite_algo_items_CollectionChanged;
|
||||
_algo_definitions.AddRange(_model.factory.default_algos(security).Values.Select(algo_factory));
|
||||
_dispose = new CompositeDisposable(
|
||||
mini_ob.Observe().Subscribe(_ => _update.execute()),
|
||||
ObservableAutoWrapper.connect_item_hooks(mini_ob.columns, c => c.Observe().Subscribe(_ => _update.execute())),
|
||||
_model.factory.subscribe_accounts().OnDispatcher().Subscribe(acc_map => {
|
||||
_accounts.SyncWithDictionary(MappedDictionary.create(acc_map, account_factory));
|
||||
_try_select_desired_account();
|
||||
@@ -132,6 +130,7 @@ namespace mbts.spark {
|
||||
return Disposable.Create(() => item.PropertyChanged -= on_prop_changed);
|
||||
}
|
||||
void dispose_resources() {
|
||||
mini_ob.result_changed -= _update.execute;
|
||||
mini_ob.Dispose();
|
||||
favorite_algos_vm.items.CollectionChanged -= on_favorite_algo_items_CollectionChanged;
|
||||
favorite_algos_vm.Dispose();
|
||||
@@ -164,7 +163,7 @@ namespace mbts.spark {
|
||||
}
|
||||
|
||||
public MarketSizeDisplayVM size_display { get; } = new MarketSizeDisplayVM();
|
||||
public GridSettingsVM mini_ob { get; } = new MiniOrderBookGridSettingsVM(OrderBookGridSettingsManager.hard_column_flags);
|
||||
public SimpleGridSettingsVM mini_ob { get; } = new SimpleGridSettingsVM(OrderBookGridSettingsManager.hard_column_flags);
|
||||
// price format
|
||||
public LadderSettings.NetChangeTerms price_format { get => _price_format; set => Set(ref _price_format, value); }
|
||||
public IEnumerable<LadderSettings.NetChangeTerms> price_format_options => EnumHelper.get_values<LadderSettings.NetChangeTerms>();
|
||||
@@ -306,7 +305,7 @@ namespace mbts.spark {
|
||||
favorite_algos_vm.load_from(settings.favorite_algos);
|
||||
size_display.load_from(settings.size_display);
|
||||
size_presets.SetItems(settings.calculator_buttons.empty_if_null().Select(s => _create_size_preset_vm((uint)s)));
|
||||
mini_ob.load(settings.mini_ob.value);
|
||||
mini_ob.load_from(settings.mini_ob.value);
|
||||
// columns
|
||||
_orders.assign_from(_current.orders_column);
|
||||
_bid.assign_from(_current.bid_column);
|
||||
@@ -364,14 +363,14 @@ namespace mbts.spark {
|
||||
LadderSettings clone;
|
||||
if (_current == null) {
|
||||
clone = new LadderSettings {
|
||||
mini_ob = new LadderMiniOrderBookSettings(mini_ob.get_result())
|
||||
mini_ob = new LadderMiniOrderBookSettings(mini_ob.create())
|
||||
};
|
||||
} else {
|
||||
clone = SparkUtils.clone_proto(_current);
|
||||
#pragma warning disable CS0612 // Type or member is obsolete
|
||||
clone.mini_ob = new LadderMiniOrderBookSettings(_current.mini_ob.value != null ?
|
||||
mini_ob.get_result().with(sorting_criterion: _current.mini_ob.value.sorting_criterion) :
|
||||
mini_ob.get_result());
|
||||
mini_ob.create().with(sorting_criterion: _current.mini_ob.value.sorting_criterion) :
|
||||
mini_ob.create());
|
||||
#pragma warning restore CS0612 // Type or member is obsolete
|
||||
}
|
||||
clone.badge_style = badge_style;
|
||||
@@ -811,40 +810,4 @@ namespace mbts.spark {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MiniOrderBookGridSettingsVM : GridSettingsVM {
|
||||
public MiniOrderBookGridSettingsVM(IReadOnlyDictionary<string, GridColumnSettingsFeatureFlags> column_flags = null)
|
||||
: base(column_flags) { }
|
||||
|
||||
//public override void sync_params() {
|
||||
// parameters.Clear();
|
||||
// parameters.Add(_font_vm);
|
||||
// parameters.Add(_font_color);
|
||||
// if (_background_enabled)
|
||||
// parameters.Add(_background);
|
||||
// parameters.Add(_selection_highlight);
|
||||
//}
|
||||
}
|
||||
|
||||
//class MiniOrderBookGridSettingsVM : ParameterGroupVM {
|
||||
// public MiniOrderBookGridSettingsVM(GridSettingsVM grid) { }
|
||||
// MiniOrderBookGridSettingsVM(GridSettingsVM grid, ObservableAggregateCollection<object> parameters)
|
||||
// : base("Mini OrderBook", parameters) {
|
||||
// parameters.add_collection(grid.parameters);
|
||||
// }
|
||||
|
||||
// public override void sync_params() {
|
||||
// var fonts_and_colors = HeaderedParameterGroupVM.create("Fonts/Colors", _font_vm, _font_color);
|
||||
// if (_background_enabled)
|
||||
// fonts_and_colors.parameters.Add(_background);
|
||||
// fonts_and_colors.parameters.Add(_selection_highlight);
|
||||
// parameters.SetItems(fonts_and_colors);
|
||||
// }
|
||||
//}
|
||||
|
||||
//class GridSettingsColumnParameterGroupVM : ParameterGroupVM {
|
||||
// public GridSettingsColumnParameterGroupVM(GridSettingsVM grid) : base("Columns") {
|
||||
|
||||
// }
|
||||
//}G
|
||||
}
|
||||
@@ -14,177 +14,255 @@
|
||||
TextElement.FontSize="{x:Static u:FontSizes.Small}"
|
||||
>
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<usp:GridSettingsResources/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<sys:Double x:Key="HorizontalPush">4</sys:Double>
|
||||
<sys:Double x:Key="HorizontalPush2">8</sys:Double>
|
||||
<sys:Double x:Key="HorizontalPush3">12</sys:Double>
|
||||
<sys:Double x:Key="IndentChild">24</sys:Double>
|
||||
<sys:Double x:Key="GroupBoxOffsetLeft">8</sys:Double>
|
||||
<sys:Double x:Key="GroupBoxOffsetRight">2</sys:Double>
|
||||
<sys:Double x:Key="VerticalPush">4</sys:Double>
|
||||
<sys:Double x:Key="VerticalSectionBreak">6</sys:Double>
|
||||
<sys:Double x:Key="VerticalSplit">8</sys:Double>
|
||||
<sys:Double x:Key="CollapsedSizePresetsHeight">24</sys:Double>
|
||||
<!--'Ladder Columns' Column Widths-->
|
||||
<sys:Double x:Key="LadderColumnsShowColumnWidth">57</sys:Double>
|
||||
<sys:Double x:Key="LadderColumnsBackgroundColumnWidth">70</sys:Double>
|
||||
<sys:Double x:Key="LadderColumnsForegroundColumnWidth">81</sys:Double>
|
||||
<sys:Double x:Key="LadderColumnsWidthColumnWidth">50</sys:Double>
|
||||
<sys:Double x:Key="LadderColumnsFontColumnWidth">160</sys:Double>
|
||||
<!--Margins-->
|
||||
<Thickness x:Key="MarginLPush" Left="{StaticResource HorizontalPush}"/>
|
||||
<Thickness x:Key="MarginLPush2" Left="{StaticResource HorizontalPush2}"/>
|
||||
<Thickness x:Key="MarginTPush" Top="{StaticResource HorizontalPush}"/>
|
||||
<Thickness x:Key="MarginTPush2" Top="{StaticResource HorizontalPush2}"/>
|
||||
<Thickness x:Key="MarginIndentChild" Left="{StaticResource IndentChild}"/>
|
||||
<Thickness x:Key="Margin.UP1" Left="{StaticResource HorizontalPush}" Top="{StaticResource VerticalPush}" Right="{StaticResource HorizontalPush}" Bottom="{StaticResource VerticalPush}"/>
|
||||
<!--Colors-->
|
||||
<Color x:Key="LadderColumnDetailsBackgroundColor">LightGray</Color>
|
||||
<Color x:Key="LadderColumnDetailsForegroundColor">Black</Color>
|
||||
<Color x:Key="LadderColumnDetailsBorderColor">Navy</Color>
|
||||
<SolidColorBrush x:Key="LadderColumnDetailsBackgroundBrush" ice:Freeze="True" Color="{StaticResource LadderColumnDetailsBackgroundColor}"/>
|
||||
<SolidColorBrush x:Key="LadderColumnDetailsForegroundBrush" ice:Freeze="True" Color="{StaticResource LadderColumnDetailsForegroundColor}"/>
|
||||
<SolidColorBrush x:Key="LadderColumnDetailsBorderBrush" ice:Freeze="True" Color="{StaticResource LadderColumnDetailsBorderColor}"/>
|
||||
<!--Converters-->
|
||||
<cv:BooleanToVisibilityConverter x:Key="NetChangeGroupBoxIsVisibleVisibilityConverter" VisibilityForTrue="Hidden" VisibilityForFalse="Visible"/>
|
||||
<cv:ValueMap x:Key="ColumnSpanToVisibilityConverter" Default="{u:Visibility Visible}">
|
||||
<cv:KeyValue Key="{u:Int 0}" Value="{u:Visibility Collapsed}"/>
|
||||
</cv:ValueMap>
|
||||
<c:BadgeTextLinesConverter x:Key="BadgeTextLinesConverter"/>
|
||||
<sys:Double x:Key="HorizontalPush">4</sys:Double>
|
||||
<sys:Double x:Key="HorizontalPush2">8</sys:Double>
|
||||
<sys:Double x:Key="HorizontalPush3">12</sys:Double>
|
||||
<sys:Double x:Key="IndentChild">24</sys:Double>
|
||||
<sys:Double x:Key="GroupBoxOffsetLeft">8</sys:Double>
|
||||
<sys:Double x:Key="GroupBoxOffsetRight">2</sys:Double>
|
||||
<sys:Double x:Key="VerticalPush">4</sys:Double>
|
||||
<sys:Double x:Key="VerticalSectionBreak">6</sys:Double>
|
||||
<sys:Double x:Key="VerticalSplit">8</sys:Double>
|
||||
<sys:Double x:Key="CollapsedSizePresetsHeight">24</sys:Double>
|
||||
<!--'Ladder Columns' Column Widths-->
|
||||
<sys:Double x:Key="LadderColumnsShowColumnWidth">57</sys:Double>
|
||||
<sys:Double x:Key="LadderColumnsBackgroundColumnWidth">70</sys:Double>
|
||||
<sys:Double x:Key="LadderColumnsForegroundColumnWidth">81</sys:Double>
|
||||
<sys:Double x:Key="LadderColumnsWidthColumnWidth">50</sys:Double>
|
||||
<sys:Double x:Key="LadderColumnsFontColumnWidth">160</sys:Double>
|
||||
<!--Margins-->
|
||||
<Thickness x:Key="MarginLPush" Left="{StaticResource HorizontalPush}"/>
|
||||
<Thickness x:Key="MarginLPush2" Left="{StaticResource HorizontalPush2}"/>
|
||||
<Thickness x:Key="MarginTPush" Top="{StaticResource HorizontalPush}"/>
|
||||
<Thickness x:Key="MarginTPush2" Top="{StaticResource HorizontalPush2}"/>
|
||||
<Thickness x:Key="MarginIndentChild" Left="{StaticResource IndentChild}"/>
|
||||
<Thickness x:Key="Margin.UP1" Left="{StaticResource HorizontalPush}" Top="{StaticResource VerticalPush}" Right="{StaticResource HorizontalPush}" Bottom="{StaticResource VerticalPush}"/>
|
||||
<!--Colors-->
|
||||
<Color x:Key="LadderColumnDetailsBackgroundColor">LightGray</Color>
|
||||
<Color x:Key="LadderColumnDetailsForegroundColor">Black</Color>
|
||||
<Color x:Key="LadderColumnDetailsBorderColor">Navy</Color>
|
||||
<SolidColorBrush x:Key="LadderColumnDetailsBackgroundBrush" ice:Freeze="True" Color="{StaticResource LadderColumnDetailsBackgroundColor}"/>
|
||||
<SolidColorBrush x:Key="LadderColumnDetailsForegroundBrush" ice:Freeze="True" Color="{StaticResource LadderColumnDetailsForegroundColor}"/>
|
||||
<SolidColorBrush x:Key="LadderColumnDetailsBorderBrush" ice:Freeze="True" Color="{StaticResource LadderColumnDetailsBorderColor}"/>
|
||||
<!--Converters-->
|
||||
<cv:BooleanToVisibilityConverter x:Key="NetChangeGroupBoxIsVisibleVisibilityConverter" VisibilityForTrue="Hidden" VisibilityForFalse="Visible"/>
|
||||
<cv:ValueMap x:Key="ColumnSpanToVisibilityConverter" Default="{u:Visibility Visible}">
|
||||
<cv:KeyValue Key="{u:Int 0}" Value="{u:Visibility Collapsed}"/>
|
||||
</cv:ValueMap>
|
||||
<c:BadgeTextLinesConverter x:Key="BadgeTextLinesConverter"/>
|
||||
|
||||
<Style x:Key="ColumnBackground" TargetType="Rectangle">
|
||||
<Setter Property="Grid.RowSpan" Value="3"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
</Style>
|
||||
<Style x:Key="VolumeComponentRectangle" TargetType="Rectangle">
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="Width">
|
||||
<Setter.Value>
|
||||
<MultiBinding Converter="{x:Static usp:LadderSettingsView.VolumeBarWidthConverter}">
|
||||
<Binding Path="(usp:LadderSettingsView.VolumeComponentValue)" RelativeSource="{RelativeSource Self}"/>
|
||||
<Binding Path="DataContext.volume.max_total_volume" RelativeSource="{RelativeSource AncestorType=usp:LadderSettingsView}"/>
|
||||
<Binding Path="ActualWidth" RelativeSource="{RelativeSource AncestorType=Canvas}"/>
|
||||
</MultiBinding>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style x:Key="ColumnBackground" TargetType="Rectangle">
|
||||
<Setter Property="Grid.RowSpan" Value="3"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
</Style>
|
||||
<Style x:Key="VolumeComponentRectangle" TargetType="Rectangle">
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="Width">
|
||||
<Setter.Value>
|
||||
<MultiBinding Converter="{x:Static usp:LadderSettingsView.VolumeBarWidthConverter}">
|
||||
<Binding Path="(usp:LadderSettingsView.VolumeComponentValue)" RelativeSource="{RelativeSource Self}"/>
|
||||
<Binding Path="DataContext.volume.max_total_volume" RelativeSource="{RelativeSource AncestorType=usp:LadderSettingsView}"/>
|
||||
<Binding Path="ActualWidth" RelativeSource="{RelativeSource AncestorType=Canvas}"/>
|
||||
</MultiBinding>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="LadderColumnDetailsHyperlink" TargetType="Hyperlink" BasedOn="{StaticResource {x:Type Hyperlink}}">
|
||||
<Setter Property="Foreground" Value="{u:BTSColor header_text}"/>
|
||||
<Setter Property="Command" Value="{Binding toggle_show_details_cmd}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="Tan"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style x:Key="LadderColumnDetailsHyperlink" TargetType="Hyperlink" BasedOn="{StaticResource {x:Type Hyperlink}}">
|
||||
<Setter Property="Foreground" Value="{u:BTSColor header_text}"/>
|
||||
<Setter Property="Command" Value="{Binding toggle_show_details_cmd}"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Foreground" Value="Tan"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="LadderColumnLadderColumnDetailsBorder" TargetType="Border">
|
||||
<Setter Property="Background" Value="{StaticResource LadderColumnDetailsBackgroundBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="Navy"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="12,10,12,6"/>
|
||||
<Setter Property="Visibility" Value="{Binding show_details, Converter={StaticResource BooleanToVisibilityConverter}}"/>
|
||||
</Style>
|
||||
<Style x:Key="LadderColumnLadderColumnDetailsBorder" TargetType="Border">
|
||||
<Setter Property="Background" Value="{StaticResource LadderColumnDetailsBackgroundBrush}"/>
|
||||
<Setter Property="BorderBrush" Value="Navy"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Padding" Value="12,10,12,6"/>
|
||||
<Setter Property="Visibility" Value="{Binding show_details, Converter={StaticResource BooleanToVisibilityConverter}}"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="HintText" TargetType="TextBlock">
|
||||
<Setter Property="FontStyle" Value="Italic"/>
|
||||
<Setter Property="Foreground" Value="Gray"/>
|
||||
<Setter Property="TextWrapping" Value="Wrap"/>
|
||||
</Style>
|
||||
<Style x:Key="HintText" TargetType="TextBlock">
|
||||
<Setter Property="FontStyle" Value="Italic"/>
|
||||
<Setter Property="Foreground" Value="Gray"/>
|
||||
<Setter Property="TextWrapping" Value="Wrap"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="LadderColumnShowToggle" TargetType="CheckBox">
|
||||
<Setter Property="Grid.Column" Value="1"/>
|
||||
<Setter Property="ToolTipService.ShowOnDisabled" Value="True"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="IsChecked" Value="{Binding show}"/>
|
||||
<Setter Property="IsEnabled" Value="{Binding can_toggle_show}"/>
|
||||
<Setter Property="ToolTip">
|
||||
<Setter.Value>
|
||||
<MultiBinding Converter="{x:Static usp:LadderSettingsView.LadderColumnToggleShowToolTipConverter}">
|
||||
<Binding Path="can_toggle_show"/>
|
||||
<Binding Path="show"/>
|
||||
<Binding Path="name"/>
|
||||
</MultiBinding>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style x:Key="LadderColumnShowToggle" TargetType="CheckBox">
|
||||
<Setter Property="Grid.Column" Value="1"/>
|
||||
<Setter Property="ToolTipService.ShowOnDisabled" Value="True"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="IsChecked" Value="{Binding show}"/>
|
||||
<Setter Property="IsEnabled" Value="{Binding can_toggle_show}"/>
|
||||
<Setter Property="ToolTip">
|
||||
<Setter.Value>
|
||||
<MultiBinding Converter="{x:Static usp:LadderSettingsView.LadderColumnToggleShowToolTipConverter}">
|
||||
<Binding Path="can_toggle_show"/>
|
||||
<Binding Path="show"/>
|
||||
<Binding Path="name"/>
|
||||
</MultiBinding>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="LadderColumnColorPicker" TargetType="c:ColorPickerPopup">
|
||||
<Setter Property="BorderBrush" Value="Transparent"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="PopupPlacement" Value="Left"/>
|
||||
</Style>
|
||||
<Style x:Key="LadderColumnBackgroundPicker" TargetType="c:ColorPickerPopup" BasedOn="{StaticResource LadderColumnColorPicker}">
|
||||
<Setter Property="Grid.Column" Value="2"/>
|
||||
<Setter Property="Palettes" Value="{Binding background_palettes}"/>
|
||||
<Setter Property="SelectedColor" Value="{Binding background}"/>
|
||||
</Style>
|
||||
<Style x:Key="LadderColumnForegroundPicker" TargetType="c:ColorPickerPopup" BasedOn="{StaticResource LadderColumnColorPicker}">
|
||||
<Setter Property="Grid.Column" Value="3"/>
|
||||
<Setter Property="Palettes" Value="{Binding foreground_palettes}"/>
|
||||
<Setter Property="SelectedColor" Value="{Binding foreground}"/>
|
||||
</Style>
|
||||
<Style x:Key="LadderColumnWidthTickUpDown" TargetType="c:TickUpDownUInt">
|
||||
<Setter Property="Grid.Column" Value="4"/>
|
||||
<Setter Property="Value" Value="{Binding width}"/>
|
||||
</Style>
|
||||
<Style x:Key="LadderColumnColorPicker" TargetType="c:ColorPickerPopup">
|
||||
<Setter Property="BorderBrush" Value="Transparent"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="PopupPlacement" Value="Left"/>
|
||||
</Style>
|
||||
<Style x:Key="LadderColumnBackgroundPicker" TargetType="c:ColorPickerPopup" BasedOn="{StaticResource LadderColumnColorPicker}">
|
||||
<Setter Property="Grid.Column" Value="2"/>
|
||||
<Setter Property="Palettes" Value="{Binding background_palettes}"/>
|
||||
<Setter Property="SelectedColor" Value="{Binding background}"/>
|
||||
</Style>
|
||||
<Style x:Key="LadderColumnForegroundPicker" TargetType="c:ColorPickerPopup" BasedOn="{StaticResource LadderColumnColorPicker}">
|
||||
<Setter Property="Grid.Column" Value="3"/>
|
||||
<Setter Property="Palettes" Value="{Binding foreground_palettes}"/>
|
||||
<Setter Property="SelectedColor" Value="{Binding foreground}"/>
|
||||
</Style>
|
||||
<Style x:Key="LadderColumnWidthTickUpDown" TargetType="c:TickUpDownUInt">
|
||||
<Setter Property="Grid.Column" Value="4"/>
|
||||
<Setter Property="Value" Value="{Binding width}"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="LadderColumnFontPicker" TargetType="c:PopupControl">
|
||||
<Setter Property="Grid.Column" Value="5"/>
|
||||
<Setter Property="BorderBrush" Value="Transparent"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="PopupPlacement" Value="Left"/>
|
||||
<Setter Property="ShowExpanderArrow" Value="False"/>
|
||||
<Setter Property="Content" Value="{Binding}"/>
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<c:FontPicker SelectedFontSize="{Binding font_size}" Typeface="{Binding typeface}"/>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Header" Value="{Binding}"/>
|
||||
<Setter Property="HeaderTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<Style x:Key="LadderColumnFontPicker" TargetType="c:PopupControl">
|
||||
<Setter Property="Grid.Column" Value="5"/>
|
||||
<Setter Property="BorderBrush" Value="Transparent"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="PopupPlacement" Value="Left"/>
|
||||
<Setter Property="ShowExpanderArrow" Value="False"/>
|
||||
<Setter Property="Content" Value="{Binding}"/>
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<c:FontPicker SelectedFontSize="{Binding font_size}" Typeface="{Binding typeface}"/>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Header" Value="{Binding}"/>
|
||||
<Setter Property="HeaderTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<TextBlock
|
||||
FontFamily="{Binding font_family}"
|
||||
FontSize="{Binding font_size}"
|
||||
FontWeight="{Binding font_weight}"
|
||||
Margin="4,0"
|
||||
Text="{Binding font_display_name}"
|
||||
/>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="LadderColumnSample" TargetType="Border">
|
||||
<Setter Property="Grid.Column" Value="6"/>
|
||||
<Setter Property="Background" Value="{Binding background, Converter={StaticResource ColorToBrushConverter}}"/>
|
||||
<Setter Property="BorderBrush" Value="Black"/>
|
||||
<Setter Property="BorderThickness" Value="2,0,0,0"/>
|
||||
<Setter Property="Padding" Value="4,0"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="LadderColumnRowSeparator" TargetType="Rectangle">
|
||||
<Setter Property="Grid.Column" Value="1"/>
|
||||
<Setter Property="Grid.ColumnSpan" Value="6"/>
|
||||
<Setter Property="Fill" Value="DimGray"/>
|
||||
<Setter Property="Height" Value="1"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
</Style>
|
||||
|
||||
<u:KeyedTemplateSelector x:Key="LadderColumnTemplateSelector">
|
||||
<u:KeyedTemplateSelector.Default>
|
||||
<DataTemplate>
|
||||
<Grid Height="{Binding DataContext.row_height, Mode=OneWay, RelativeSource={RelativeSource AncestorType=usp:LadderSettingsView}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="c0"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsShowColumnWidth}}" SharedSizeGroup="c1"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsBackgroundColumnWidth}}" SharedSizeGroup="c2"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsForegroundColumnWidth}}" SharedSizeGroup="c3"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsWidthColumnWidth}}" SharedSizeGroup="c4"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsFontColumnWidth}}" SharedSizeGroup="c5"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.Column="0" Background="{u:BTSColor header}" Padding="6,3">
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding name}" Foreground="{u:BTSColor header_text}"/>
|
||||
</Border>
|
||||
<CheckBox Style="{StaticResource LadderColumnShowToggle}"/>
|
||||
<c:ColorPickerPopup Style="{StaticResource LadderColumnBackgroundPicker}"/>
|
||||
<c:ColorPickerPopup Style="{StaticResource LadderColumnForegroundPicker}"/>
|
||||
<c:TickUpDownUInt Style="{StaticResource LadderColumnWidthTickUpDown}"/>
|
||||
<c:PopupControl Style="{StaticResource LadderColumnFontPicker}"/>
|
||||
<Border Style="{StaticResource LadderColumnSample}">
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="{Binding font_family}"
|
||||
FontSize="{Binding font_size}"
|
||||
FontWeight="{Binding font_weight}"
|
||||
Margin="4,0"
|
||||
Text="{Binding font_display_name}"
|
||||
Foreground="{Binding foreground, Converter={StaticResource ColorToBrushConverter}}"
|
||||
Text="{Binding sample_text}"
|
||||
/>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="LadderColumnSample" TargetType="Border">
|
||||
<Setter Property="Grid.Column" Value="6"/>
|
||||
<Setter Property="Background" Value="{Binding background, Converter={StaticResource ColorToBrushConverter}}"/>
|
||||
<Setter Property="BorderBrush" Value="Black"/>
|
||||
<Setter Property="BorderThickness" Value="2,0,0,0"/>
|
||||
<Setter Property="Padding" Value="4,0"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="LadderColumnRowSeparator" TargetType="Rectangle">
|
||||
<Setter Property="Grid.Column" Value="1"/>
|
||||
<Setter Property="Grid.ColumnSpan" Value="6"/>
|
||||
<Setter Property="Fill" Value="DimGray"/>
|
||||
<Setter Property="Height" Value="1"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
</Style>
|
||||
|
||||
<u:KeyedTemplateSelector x:Key="LadderColumnTemplateSelector">
|
||||
<u:KeyedTemplateSelector.Default>
|
||||
<DataTemplate>
|
||||
</Border>
|
||||
<Rectangle Style="{StaticResource LadderColumnRowSeparator}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</u:KeyedTemplateSelector.Default>
|
||||
<!--Orders-->
|
||||
<u:TemplateSelectorKeyValue Key="{x:Static usp:LadderSettingsView.OrdersColumnTemplateKey}">
|
||||
<DataTemplate>
|
||||
<Grid Height="{Binding DataContext.row_height, Mode=OneWay, RelativeSource={RelativeSource AncestorType=usp:LadderSettingsView}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="c0"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsShowColumnWidth}}" SharedSizeGroup="c1"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsBackgroundColumnWidth}}" SharedSizeGroup="c2"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsForegroundColumnWidth}}" SharedSizeGroup="c3"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsWidthColumnWidth}}" SharedSizeGroup="c4"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsFontColumnWidth}}" SharedSizeGroup="c5"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.Column="0" Background="{u:BTSColor header}" Padding="6,3">
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding name}" Foreground="{u:BTSColor header_text}"/>
|
||||
</Border>
|
||||
<CheckBox Style="{StaticResource LadderColumnShowToggle}"/>
|
||||
<c:ColorPickerPopup Style="{StaticResource LadderColumnBackgroundPicker}"/>
|
||||
<c:ColorPickerPopup Style="{StaticResource LadderColumnForegroundPicker}"/>
|
||||
<c:TickUpDownUInt Style="{StaticResource LadderColumnWidthTickUpDown}"/>
|
||||
<c:PopupControl Style="{StaticResource LadderColumnFontPicker}"/>
|
||||
<Border Style="{StaticResource LadderColumnSample}">
|
||||
<c:Badge
|
||||
Background="{Binding badge_background}"
|
||||
BorderBrush="{Binding badge_border}"
|
||||
FontFamily="{Binding font_family}"
|
||||
FontSize="{Binding font_size}"
|
||||
FontWeight="{Binding font_weight}"
|
||||
Foreground="{Binding foreground, Converter={StaticResource ColorToBrushConverter}}"
|
||||
Width="{x:Static c:Badge.DefaultWidth}"
|
||||
>
|
||||
<c:Badge.TextLines>
|
||||
<MultiBinding Converter="{StaticResource BadgeTextLinesConverter}">
|
||||
<Binding Path="sample_side"/>
|
||||
<Binding Path="sample_quantity"/>
|
||||
<Binding Path="sample_filled"/>
|
||||
<Binding Path="DataContext.badge_style" RelativeSource="{RelativeSource AncestorType=usp:LadderSettingsView}"/>
|
||||
</MultiBinding>
|
||||
</c:Badge.TextLines>
|
||||
</c:Badge>
|
||||
</Border>
|
||||
<Rectangle Style="{StaticResource LadderColumnRowSeparator}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</u:TemplateSelectorKeyValue>
|
||||
<!--Last-->
|
||||
<u:TemplateSelectorKeyValue Key="{x:Static usp:LadderSettingsView.LastColumnTemplateKey}">
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<Grid Height="{Binding DataContext.row_height, Mode=OneWay, RelativeSource={RelativeSource AncestorType=usp:LadderSettingsView}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="c0"/>
|
||||
@@ -193,10 +271,21 @@
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsForegroundColumnWidth}}" SharedSizeGroup="c3"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsWidthColumnWidth}}" SharedSizeGroup="c4"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsFontColumnWidth}}" SharedSizeGroup="c5"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.Column="0" Background="{u:BTSColor header}" Padding="6,3">
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding name}" Foreground="{u:BTSColor header_text}"/>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="name_col"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding name}" Foreground="{u:BTSColor header_text}"/>
|
||||
<TextBlock Grid.Column="1" Margin="4,0,2,0">
|
||||
<Hyperlink Style="{StaticResource LadderColumnDetailsHyperlink}">
|
||||
(Advanced)
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Border>
|
||||
<CheckBox Style="{StaticResource LadderColumnShowToggle}"/>
|
||||
<c:ColorPickerPopup Style="{StaticResource LadderColumnBackgroundPicker}"/>
|
||||
@@ -216,11 +305,21 @@
|
||||
</Border>
|
||||
<Rectangle Style="{StaticResource LadderColumnRowSeparator}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</u:KeyedTemplateSelector.Default>
|
||||
<!--Orders-->
|
||||
<u:TemplateSelectorKeyValue Key="{x:Static usp:LadderSettingsView.OrdersColumnTemplateKey}">
|
||||
<DataTemplate>
|
||||
<Border Style="{StaticResource LadderColumnLadderColumnDetailsBorder}">
|
||||
<CheckBox
|
||||
Content="Show Last on Volume Column"
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType=usp:LadderSettingsView}}"
|
||||
IsChecked="{Binding volume.show_last_trade}"
|
||||
Visibility="{Binding last_column.show_details, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</u:TemplateSelectorKeyValue>
|
||||
<!--Volume-->
|
||||
<u:TemplateSelectorKeyValue Key="{x:Static usp:LadderSettingsView.VolumeColumnTemplateKey}">
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<Grid Height="{Binding DataContext.row_height, Mode=OneWay, RelativeSource={RelativeSource AncestorType=usp:LadderSettingsView}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="c0"/>
|
||||
@@ -232,7 +331,18 @@
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.Column="0" Background="{u:BTSColor header}" Padding="6,3">
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding name}" Foreground="{u:BTSColor header_text}"/>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="name_col"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding name}" Foreground="{u:BTSColor header_text}"/>
|
||||
<TextBlock Grid.Column="1" Margin="4,0,2,0">
|
||||
<Hyperlink Style="{StaticResource LadderColumnDetailsHyperlink}">
|
||||
(Advanced)
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Border>
|
||||
<CheckBox Style="{StaticResource LadderColumnShowToggle}"/>
|
||||
<c:ColorPickerPopup Style="{StaticResource LadderColumnBackgroundPicker}"/>
|
||||
@@ -240,223 +350,114 @@
|
||||
<c:TickUpDownUInt Style="{StaticResource LadderColumnWidthTickUpDown}"/>
|
||||
<c:PopupControl Style="{StaticResource LadderColumnFontPicker}"/>
|
||||
<Border Style="{StaticResource LadderColumnSample}">
|
||||
<c:Badge
|
||||
Background="{Binding badge_background}"
|
||||
BorderBrush="{Binding badge_border}"
|
||||
FontFamily="{Binding font_family}"
|
||||
FontSize="{Binding font_size}"
|
||||
FontWeight="{Binding font_weight}"
|
||||
Foreground="{Binding foreground, Converter={StaticResource ColorToBrushConverter}}"
|
||||
Width="{x:Static c:Badge.DefaultWidth}"
|
||||
>
|
||||
<c:Badge.TextLines>
|
||||
<MultiBinding Converter="{StaticResource BadgeTextLinesConverter}">
|
||||
<Binding Path="sample_side"/>
|
||||
<Binding Path="sample_quantity"/>
|
||||
<Binding Path="sample_filled"/>
|
||||
<Binding Path="DataContext.badge_style" RelativeSource="{RelativeSource AncestorType=usp:LadderSettingsView}"/>
|
||||
</MultiBinding>
|
||||
</c:Badge.TextLines>
|
||||
</c:Badge>
|
||||
<Canvas DataContext="{Binding DataContext.volume, RelativeSource={RelativeSource AncestorType=usp:LadderSettingsView}}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<Grid Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType=Canvas}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle
|
||||
Grid.ColumnSpan="4"
|
||||
usp:LadderSettingsView.VolumeComponentValue="{Binding total.sample_data.total}"
|
||||
Fill="{Binding total.bars.value, Converter={StaticResource ColorToBrushConverter}}"
|
||||
Visibility="{Binding total.bars.enabled, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
Style="{StaticResource VolumeComponentRectangle}"
|
||||
/>
|
||||
<Rectangle
|
||||
usp:LadderSettingsView.VolumeComponentValue="{Binding buy.sample_data.buy}"
|
||||
Fill="{Binding buy.bars.value, Converter={StaticResource ColorToBrushConverter}}"
|
||||
Visibility="{Binding buy.bars.enabled, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
Style="{StaticResource VolumeComponentRectangle}"
|
||||
/>
|
||||
<Rectangle
|
||||
Grid.Column="1"
|
||||
usp:LadderSettingsView.VolumeComponentValue="{Binding sell.sample_data.sell}"
|
||||
Fill="{Binding sell.bars.value, Converter={StaticResource ColorToBrushConverter}}"
|
||||
Visibility="{Binding sell.bars.enabled, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
Style="{StaticResource VolumeComponentRectangle}"
|
||||
/>
|
||||
<Rectangle
|
||||
Grid.Column="2"
|
||||
usp:LadderSettingsView.VolumeComponentValue="{Binding passive.sample_data.passive}"
|
||||
Fill="{Binding passive.bars.value, Converter={StaticResource ColorToBrushConverter}}"
|
||||
Visibility="{Binding passive.bars.enabled, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
Style="{StaticResource VolumeComponentRectangle}"
|
||||
/>
|
||||
</Grid>
|
||||
<Border Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType=Canvas}}" Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType=Canvas}}">
|
||||
<TextBlock
|
||||
Grid.ColumnSpan="4"
|
||||
HorizontalAlignment="Center"
|
||||
Text="{Binding passive.sample_data.numbers_text}"
|
||||
Foreground="{Binding general.foreground, Converter={StaticResource ColorToBrushConverter}}"
|
||||
/>
|
||||
</Border>
|
||||
</Canvas>
|
||||
</Border>
|
||||
<Rectangle Style="{StaticResource LadderColumnRowSeparator}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</u:TemplateSelectorKeyValue>
|
||||
<!--Last-->
|
||||
<u:TemplateSelectorKeyValue Key="{x:Static usp:LadderSettingsView.LastColumnTemplateKey}">
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<Grid Height="{Binding DataContext.row_height, Mode=OneWay, RelativeSource={RelativeSource AncestorType=usp:LadderSettingsView}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="c0"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsShowColumnWidth}}" SharedSizeGroup="c1"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsBackgroundColumnWidth}}" SharedSizeGroup="c2"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsForegroundColumnWidth}}" SharedSizeGroup="c3"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsWidthColumnWidth}}" SharedSizeGroup="c4"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsFontColumnWidth}}" SharedSizeGroup="c5"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.Column="0" Background="{u:BTSColor header}" Padding="6,3">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="name_col"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding name}" Foreground="{u:BTSColor header_text}"/>
|
||||
<TextBlock Grid.Column="1" Margin="4,0,2,0">
|
||||
<Hyperlink Style="{StaticResource LadderColumnDetailsHyperlink}">
|
||||
(Advanced)
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Border>
|
||||
<CheckBox Style="{StaticResource LadderColumnShowToggle}"/>
|
||||
<c:ColorPickerPopup Style="{StaticResource LadderColumnBackgroundPicker}"/>
|
||||
<c:ColorPickerPopup Style="{StaticResource LadderColumnForegroundPicker}"/>
|
||||
<c:TickUpDownUInt Style="{StaticResource LadderColumnWidthTickUpDown}"/>
|
||||
<c:PopupControl Style="{StaticResource LadderColumnFontPicker}"/>
|
||||
<Border Style="{StaticResource LadderColumnSample}">
|
||||
<TextBlock
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="{Binding font_family}"
|
||||
FontSize="{Binding font_size}"
|
||||
FontWeight="{Binding font_weight}"
|
||||
Foreground="{Binding foreground, Converter={StaticResource ColorToBrushConverter}}"
|
||||
Text="{Binding sample_text}"
|
||||
/>
|
||||
</Border>
|
||||
<Rectangle Style="{StaticResource LadderColumnRowSeparator}"/>
|
||||
</Grid>
|
||||
<Border Style="{StaticResource LadderColumnLadderColumnDetailsBorder}">
|
||||
<CheckBox
|
||||
Content="Show Last on Volume Column"
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType=usp:LadderSettingsView}}"
|
||||
IsChecked="{Binding volume.show_last_trade}"
|
||||
Visibility="{Binding last_column.show_details, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</u:TemplateSelectorKeyValue>
|
||||
<!--Volume-->
|
||||
<u:TemplateSelectorKeyValue Key="{x:Static usp:LadderSettingsView.VolumeColumnTemplateKey}">
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<Grid Height="{Binding DataContext.row_height, Mode=OneWay, RelativeSource={RelativeSource AncestorType=usp:LadderSettingsView}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="c0"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsShowColumnWidth}}" SharedSizeGroup="c1"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsBackgroundColumnWidth}}" SharedSizeGroup="c2"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsForegroundColumnWidth}}" SharedSizeGroup="c3"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsWidthColumnWidth}}" SharedSizeGroup="c4"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource LadderColumnsFontColumnWidth}}" SharedSizeGroup="c5"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.Column="0" Background="{u:BTSColor header}" Padding="6,3">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="name_col"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock VerticalAlignment="Center" Text="{Binding name}" Foreground="{u:BTSColor header_text}"/>
|
||||
<TextBlock Grid.Column="1" Margin="4,0,2,0">
|
||||
<Hyperlink Style="{StaticResource LadderColumnDetailsHyperlink}">
|
||||
(Advanced)
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Border>
|
||||
<CheckBox Style="{StaticResource LadderColumnShowToggle}"/>
|
||||
<c:ColorPickerPopup Style="{StaticResource LadderColumnBackgroundPicker}"/>
|
||||
<c:ColorPickerPopup Style="{StaticResource LadderColumnForegroundPicker}"/>
|
||||
<c:TickUpDownUInt Style="{StaticResource LadderColumnWidthTickUpDown}"/>
|
||||
<c:PopupControl Style="{StaticResource LadderColumnFontPicker}"/>
|
||||
<Border Style="{StaticResource LadderColumnSample}">
|
||||
<Canvas DataContext="{Binding DataContext.volume, RelativeSource={RelativeSource AncestorType=usp:LadderSettingsView}}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<Grid Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType=Canvas}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle
|
||||
Grid.ColumnSpan="4"
|
||||
usp:LadderSettingsView.VolumeComponentValue="{Binding total.sample_data.total}"
|
||||
Fill="{Binding total.bars.value, Converter={StaticResource ColorToBrushConverter}}"
|
||||
Visibility="{Binding total.bars.enabled, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
Style="{StaticResource VolumeComponentRectangle}"
|
||||
/>
|
||||
<Rectangle
|
||||
usp:LadderSettingsView.VolumeComponentValue="{Binding buy.sample_data.buy}"
|
||||
Fill="{Binding buy.bars.value, Converter={StaticResource ColorToBrushConverter}}"
|
||||
Visibility="{Binding buy.bars.enabled, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
Style="{StaticResource VolumeComponentRectangle}"
|
||||
/>
|
||||
<Rectangle
|
||||
Grid.Column="1"
|
||||
usp:LadderSettingsView.VolumeComponentValue="{Binding sell.sample_data.sell}"
|
||||
Fill="{Binding sell.bars.value, Converter={StaticResource ColorToBrushConverter}}"
|
||||
Visibility="{Binding sell.bars.enabled, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
Style="{StaticResource VolumeComponentRectangle}"
|
||||
/>
|
||||
<Rectangle
|
||||
Grid.Column="2"
|
||||
usp:LadderSettingsView.VolumeComponentValue="{Binding passive.sample_data.passive}"
|
||||
Fill="{Binding passive.bars.value, Converter={StaticResource ColorToBrushConverter}}"
|
||||
Visibility="{Binding passive.bars.enabled, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
Style="{StaticResource VolumeComponentRectangle}"
|
||||
/>
|
||||
</Grid>
|
||||
<Border Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType=Canvas}}" Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType=Canvas}}">
|
||||
<TextBlock
|
||||
Grid.ColumnSpan="4"
|
||||
HorizontalAlignment="Center"
|
||||
Text="{Binding passive.sample_data.numbers_text}"
|
||||
Foreground="{Binding general.foreground, Converter={StaticResource ColorToBrushConverter}}"
|
||||
/>
|
||||
</Border>
|
||||
</Canvas>
|
||||
</Border>
|
||||
<Rectangle Style="{StaticResource LadderColumnRowSeparator}"/>
|
||||
</Grid>
|
||||
<Border Background="{StaticResource LadderColumnDetailsBackgroundBrush}" BorderBrush="{StaticResource LadderColumnDetailsBorderBrush}" BorderThickness="1" Visibility="{Binding show_details, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="27"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid x:Name="volume_headers" TextElement.Foreground="{StaticResource LadderColumnDetailsForegroundBrush}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition SharedSizeGroup="c0"/>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="c1"/>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="c2"/>
|
||||
<ColumnDefinition SharedSizeGroup="c3"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="1" HorizontalAlignment="Center" Margin="6,0" Text="Show Bar" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="2" HorizontalAlignment="Center" Margin="6,0" Text="Bar Color" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="3" HorizontalAlignment="Center" Margin="6,0" Text="Show Number" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
<ItemsControl x:Name="volume_components_items_source" Grid.Row="1" Margin="0,0,0,8" DataContext="{Binding DataContext.volume, RelativeSource={RelativeSource AncestorType=usp:LadderSettingsView}}" ItemsSource="{Binding volume_components}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Height="{Binding DataContext.row_height, Mode=OneWay, RelativeSource={RelativeSource AncestorType=usp:LadderSettingsView}}" IsEnabled="{Binding show}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="c0"/>
|
||||
<ColumnDefinition SharedSizeGroup="c1"/>
|
||||
<ColumnDefinition SharedSizeGroup="c2"/>
|
||||
<ColumnDefinition SharedSizeGroup="c3"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.Column="1" Grid.ColumnSpan="5" Background="White" BorderBrush="{StaticResource LadderColumnDetailsBorderBrush}" BorderThickness="1" Margin="0,-1" IsHitTestVisible="False"/>
|
||||
<TextBlock Margin="70,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="{StaticResource LadderColumnDetailsForegroundBrush}" Text="{Binding name}"/>
|
||||
<CheckBox Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding bars.enabled}"/>
|
||||
<c:ColorPickerPopup
|
||||
Grid.Column="2"
|
||||
BorderBrush="Transparent"
|
||||
BorderThickness="0"
|
||||
PopupPlacement="Left"
|
||||
Palettes="{Binding palettes}"
|
||||
SelectedColor="{Binding bars.value}"
|
||||
/>
|
||||
<CheckBox Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding show_numbers}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<Border Background="{StaticResource LadderColumnDetailsBackgroundBrush}" BorderBrush="{StaticResource LadderColumnDetailsBorderBrush}" BorderThickness="1" Visibility="{Binding show_details, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="27"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid x:Name="volume_headers" TextElement.Foreground="{StaticResource LadderColumnDetailsForegroundBrush}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition SharedSizeGroup="c0"/>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="c1"/>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="c2"/>
|
||||
<ColumnDefinition SharedSizeGroup="c3"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="1" HorizontalAlignment="Center" Margin="6,0" Text="Show Bar" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="2" HorizontalAlignment="Center" Margin="6,0" Text="Bar Color" VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="3" HorizontalAlignment="Center" Margin="6,0" Text="Show Number" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</u:TemplateSelectorKeyValue>
|
||||
</u:KeyedTemplateSelector>
|
||||
</ResourceDictionary>
|
||||
<ItemsControl x:Name="volume_components_items_source" Grid.Row="1" Margin="0,0,0,8" DataContext="{Binding DataContext.volume, RelativeSource={RelativeSource AncestorType=usp:LadderSettingsView}}" ItemsSource="{Binding volume_components}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Height="{Binding DataContext.row_height, Mode=OneWay, RelativeSource={RelativeSource AncestorType=usp:LadderSettingsView}}" IsEnabled="{Binding show}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="c0"/>
|
||||
<ColumnDefinition SharedSizeGroup="c1"/>
|
||||
<ColumnDefinition SharedSizeGroup="c2"/>
|
||||
<ColumnDefinition SharedSizeGroup="c3"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.Column="1" Grid.ColumnSpan="5" Background="White" BorderBrush="{StaticResource LadderColumnDetailsBorderBrush}" BorderThickness="1" Margin="0,-1" IsHitTestVisible="False"/>
|
||||
<TextBlock Margin="70,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="{StaticResource LadderColumnDetailsForegroundBrush}" Text="{Binding name}"/>
|
||||
<CheckBox Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding bars.enabled}"/>
|
||||
<c:ColorPickerPopup
|
||||
Grid.Column="2"
|
||||
BorderBrush="Transparent"
|
||||
BorderThickness="0"
|
||||
PopupPlacement="Left"
|
||||
Palettes="{Binding palettes}"
|
||||
SelectedColor="{Binding bars.value}"
|
||||
/>
|
||||
<CheckBox Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding show_numbers}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</u:TemplateSelectorKeyValue>
|
||||
</u:KeyedTemplateSelector>
|
||||
</UserControl.Resources>
|
||||
<TabControl BorderThickness="1,1,1,0" ItemContainerStyle="{StaticResource FlatTabItem}" Style="{StaticResource FlatTabControl}">
|
||||
<TabControl>
|
||||
<TabControl.ItemContainerStyle>
|
||||
<Style TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}">
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Top"/>
|
||||
</Style>
|
||||
</TabControl.ItemContainerStyle>
|
||||
<!-- Ladder Columns Tab -->
|
||||
<TabItem Header="Ladder Columns">
|
||||
<Grid Grid.IsSharedSizeScope="True">
|
||||
<TabItem Header="Ladder Columns" VerticalAlignment="Stretch">
|
||||
<Grid Grid.IsSharedSizeScope="True" Margin="8,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="27"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
@@ -503,7 +504,7 @@
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<!-- Market Break Lines Tab -->
|
||||
<TabItem Header="Price Lines">
|
||||
<TabItem Header="Market Break Lines" VerticalAlignment="Stretch">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="27"/>
|
||||
@@ -622,14 +623,14 @@
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<!-- Market Price & Size Tab -->
|
||||
<TabItem Header="Price & Size Display">
|
||||
<TabItem Header="Market Price and Size Display">
|
||||
<Grid Margin="6" Grid.IsSharedSizeScope="True">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalPush3}}"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<GroupBox Header="Size Display" DataContext="{Binding size_display}" Padding="4">
|
||||
<GroupBox Header="Size Display" DataContext="{Binding size_display}" Padding="4">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
@@ -643,7 +644,7 @@
|
||||
ItemsSource="{Binding format_options}"
|
||||
SelectedItem="{Binding selected_format}"
|
||||
/>
|
||||
<StackPanel Grid.Row="1" Grid.ColumnSpan="2" Orientation="Horizontal" VerticalAlignment="Top">
|
||||
<StackPanel Grid.Row="1" Grid.ColumnSpan="2" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="{StaticResource MarginIndentChild}"
|
||||
Text="when implied is > 0"
|
||||
@@ -719,8 +720,8 @@
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<!-- Size Presets Tab-->
|
||||
<TabItem Header="Quantity Buttons">
|
||||
<Grid HorizontalAlignment="Left" Margin="6" VerticalAlignment="Top">
|
||||
<TabItem Header="Order Quantities" VerticalAlignment="Stretch">
|
||||
<Grid HorizontalAlignment="Left" Margin="6">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="{Binding Source={StaticResource VerticalPush}}" MaxHeight="{Binding Source={StaticResource VerticalPush}}"/>
|
||||
@@ -776,7 +777,7 @@
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<!-- Algo Favorites-->
|
||||
<TabItem Header="Algo Favorites">
|
||||
<TabItem Header="Algo Favorites" VerticalAlignment="Stretch">
|
||||
<Grid HorizontalAlignment="Left" Margin="{StaticResource Margin.UP1}" DataContext="{Binding favorite_algos_vm}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
@@ -814,7 +815,7 @@
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<CheckBox Grid.Column="2" VerticalAlignment="Center" VerticalContentAlignment="Center" IsChecked="{Binding is_sticky}">Stay Enabled?</CheckBox>
|
||||
<CheckBox Grid.Column="2" VerticalAlignment="Center" VerticalContentAlignment="Center" IsChecked="{Binding is_sticky}"> Stay Enabled?</CheckBox>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</u:KeyedTemplateSelector.Default>
|
||||
@@ -836,7 +837,7 @@
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<!-- Order Entry Panel Item Control Visbility -->
|
||||
<TabItem Header="Left Panel">
|
||||
<TabItem Header="Left Panel" VerticalAlignment="Stretch">
|
||||
<Grid Margin="6">
|
||||
<Grid.Resources>
|
||||
<sys:Double x:Key="ValueRowHeight">22</sys:Double>
|
||||
@@ -910,8 +911,7 @@
|
||||
<!--Account-->
|
||||
<TextBlock Grid.Row="4" Grid.Column="0" VerticalAlignment="Center">Account</TextBlock>
|
||||
<ComboBox Grid.Row="4" Grid.Column="2" ItemsSource="{Binding accounts_view}" SelectedItem="{Binding default_account, Delay=1}"/>
|
||||
|
||||
<!--Time In Force-->
|
||||
<!--Time In Force-->
|
||||
<TextBlock Grid.Row="6" Grid.Column="0" VerticalAlignment="Center">Time In Force</TextBlock>
|
||||
<ComboBox Grid.Row="6" Grid.Column="2" ItemsSource="{Binding time_in_force_options}" SelectedItem="{Binding default_time_in_force, Delay=1}"/>
|
||||
<!--Algo-->
|
||||
@@ -964,9 +964,30 @@
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</GroupBox>
|
||||
<!--
|
||||
<ItemsControl ItemsSource="{Binding order_entry_panel_items}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<UniformGrid Columns="2" Focusable="False"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="52"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" VerticalAlignment="Center" Text="{Binding name}"/>
|
||||
<CheckBox Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" IsChecked="{Binding show}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
-->
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Safety Checks">
|
||||
<TabItem Header="Safety Checks" VerticalAlignment="Stretch">
|
||||
<Grid HorizontalAlignment="Left" Margin="6">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
@@ -987,28 +1008,8 @@
|
||||
</CheckBox>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Order Popup">
|
||||
<TabControl BorderThickness="0,1,1,1" Margin="0,8,8,8" TabStripPlacement="Right" Style="{StaticResource FlatTabControl}">
|
||||
<TabControl.ItemContainerStyle>
|
||||
<Style TargetType="TabItem" BasedOn="{StaticResource FlatTabItem}">
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="MinWidth" Value="66"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TabControl.ItemContainerStyle>
|
||||
<TabItem Header="Grid">
|
||||
<ItemsControl Grid.IsSharedSizeScope="True" ItemsSource="{Binding mini_ob.parameters}"/>
|
||||
</TabItem>
|
||||
<TabItem
|
||||
Header="Columns"
|
||||
Content="{Binding mini_ob}"
|
||||
ContentTemplate="{StaticResource ColumnsTabContent}"
|
||||
Margin="0,-1,0,0"
|
||||
/>
|
||||
</TabControl>
|
||||
<TabItem Header="Mini Order Book">
|
||||
<usp:GridSettingsView Height="790" Margin="6" DataContext="{Binding mini_ob}" GridSectionContent="{Binding}" GridSectionContentTemplate="{DynamicResource GridSectionCoreContentTemplate}"/>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</UserControl>
|
||||
</UserControl>
|
||||
@@ -83,7 +83,8 @@ namespace bts.shell.orderbook {
|
||||
new[] {
|
||||
OrderRecordTuplePredicate.PredicateTypeOneofCase.FilledEvent,
|
||||
OrderRecordTuplePredicate.PredicateTypeOneofCase.CompletedEvent,
|
||||
OrderRecordTuplePredicate.PredicateTypeOneofCase.CanceledEvent
|
||||
OrderRecordTuplePredicate.PredicateTypeOneofCase.CanceledEvent,
|
||||
OrderRecordTuplePredicate.PredicateTypeOneofCase.SentEvent
|
||||
};
|
||||
|
||||
public OrderRecordTuplePredicateAnimations create() {
|
||||
@@ -107,6 +108,12 @@ namespace bts.shell.orderbook {
|
||||
new SecurityPredicate { is_value = security_criteria } : null
|
||||
};
|
||||
break;
|
||||
case OrderRecordTuplePredicate.PredicateTypeOneofCase.SentEvent:
|
||||
pred.sent_event = new OrderSentEventPredicate {
|
||||
security = security_criteria.is_defined() ?
|
||||
new SecurityPredicate { is_value = security_criteria } : null
|
||||
};
|
||||
break;
|
||||
}
|
||||
return new OrderRecordTuplePredicateAnimations(
|
||||
pred, null, null,
|
||||
|
||||
@@ -17,15 +17,28 @@
|
||||
<UserControl.ContentTemplate>
|
||||
<DataTemplate DataType="{x:Type orderbook:OrderBookSettingsVM}">
|
||||
<Grid>
|
||||
<u:BindingProxy x:Name="ActionMenuItemsViewProxy" Value="{DynamicResource ActionMenuItemsView}"/>
|
||||
<c:ActionMenu ItemsSource="{Binding Path='(u:BindingProxy.Value).(CollectionViewSource.View)', ElementName=ActionMenuItemsViewProxy}">
|
||||
<ItemsControl.GroupStyle>
|
||||
<GroupStyle ContainerStyle="{StaticResource ComboBox.DelineatedGroupContainerStyle.DynamicFill}"/>
|
||||
</ItemsControl.GroupStyle>
|
||||
</c:ActionMenu>
|
||||
<TabControl MinWidth="500" Margin="0,2,0,0" Style="{StaticResource FlatTabControl}">
|
||||
<Grid.Margin>
|
||||
<Thickness Left="{StaticResource HorizontalPush2}" Right="{StaticResource HorizontalPush2}"/>
|
||||
</Grid.Margin>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<c:ActionMenu
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,2,0,0"
|
||||
ItemsSource="{Binding DataContext.action_menu_items, RelativeSource={RelativeSource AncestorType=usp:ShellSettingsDialog}}"
|
||||
Style="{StaticResource SparkToolBarItem}"
|
||||
/>
|
||||
<TabControl x:Name="Tabs" HorizontalAlignment="Stretch" MinHeight="480" MinWidth="500" Margin="0,2,0,0" Padding="6">
|
||||
<TabControl.ItemContainerStyle>
|
||||
<Style TargetType="TabItem">
|
||||
<Setter Property="MinWidth" Value="60"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
</TabControl.ItemContainerStyle>
|
||||
<TabItem Header="Grid">
|
||||
<ItemsControl x:Name="ParameterItemsControl" Grid.IsSharedSizeScope="True">
|
||||
<ItemsControl x:Name="ParameterItemsControl" Grid.IsSharedSizeScope="True" Margin="8,16,0,0">
|
||||
<ItemsControl.ItemsSource>
|
||||
<CompositeCollection>
|
||||
<CollectionContainer Collection="{Binding DataContext.parameters, Source={u:DirectReference ParameterItemsControl}}"/>
|
||||
@@ -134,4 +147,4 @@
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</UserControl.ContentTemplate>
|
||||
</UserControl>
|
||||
</UserControl>
|
||||
@@ -1,379 +1,375 @@
|
||||
using bts.api;
|
||||
using bts.collections;
|
||||
using bts.settings;
|
||||
using bts.shell.pnl;
|
||||
using bts.spark;
|
||||
using bts.utils;
|
||||
using mbts;
|
||||
using mbts.config;
|
||||
using mbts.persist;
|
||||
using mbts.spark;
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.settings;
|
||||
using mbts.ui.spark;
|
||||
using mbts.ui.utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace bts.shell {
|
||||
class PNLWindowFactory : ShellWindowFactory<PNLSaveState> {
|
||||
const string _window_type = "PNL", _window_title = "PNL";
|
||||
readonly IBus _bus;
|
||||
readonly OrdersModel _orders_model;
|
||||
readonly UserSettingsHub _settings_hub;
|
||||
readonly PNLConfig _pnl_conf;
|
||||
readonly IShellWindowThreadIDProvider _thread_id_provider;
|
||||
|
||||
public PNLWindowFactory(IShellModule owner, IBus bus, UserSettingsHub settings_hub, OrdersModel orders_model) : base(owner, _window_type) {
|
||||
_bus = bus;
|
||||
_orders_model = orders_model;
|
||||
_settings_hub = settings_hub;
|
||||
_pnl_conf = new PNLConfig(Configuration.get<bts.config.PNLOptions>());
|
||||
_thread_id_provider = ShellWindowThreadIDFactory.create(_window_type, Configuration.get<bts.config.MultiThreadedWindows>().pnl);
|
||||
_dispose = bus.subscribe(SparkTags.ShowPNLTag).OnDispatcher().Subscribe(_show);
|
||||
}
|
||||
|
||||
public override Task<IShellWindow> load(PNLSaveState state) =>
|
||||
Task.FromResult(_create(state.settings));
|
||||
|
||||
void _show(PNLSettings settings) =>
|
||||
_bus.post(SparkTags.ShowWindow, _create(settings));
|
||||
|
||||
IShellWindow _create(PNLSettings settings) {
|
||||
var settings_manager = _settings_hub.create_pnl_settings_manager(settings);
|
||||
// Need to keep a local copy of the columns, since they are defined in xaml (not the viewmodel), and get_save_state may be called on a non-dispatcher thread.
|
||||
// If that happens, we would be unable to access _grid.Columns, and thus unable to get the current column settings.
|
||||
// Use an ImmutableList to avoid any threading issues when responding to CollectionChanged events on the dispatcher thread.
|
||||
ImmutableList<DIYGrid.ColumnBase> cached_columns = ImmutableList<DIYGrid.ColumnBase>.Empty;
|
||||
SparkWindow<PNLSaveState> main_win = null;
|
||||
main_win = SparkWindow<PNLSaveState>.create(_window_type, _window_title, _bus, this, Icons.Accounting, _thread_id_provider.next_id(), () => {
|
||||
var vm = new PNLVM(_bus, _orders_model, settings ?? PNLSettings.Default);
|
||||
var content = new PNLView {
|
||||
DataContext = vm
|
||||
};
|
||||
vm.sorting_changed += sh => {
|
||||
try {
|
||||
DIYGridSortHelper.set_sort_directions(sh, content._grid.Columns);
|
||||
} catch { }
|
||||
};
|
||||
vm.SubscribeDisposed(
|
||||
DIYGridSortHelper.observe_active_comparers<PNLView.Columns, PNLRowVM>(content._grid, PNLVM.get_column_comparer)
|
||||
.OnDispatcher()
|
||||
.Subscribe(sh => vm.sorting_hierarchy = sh.Select(s => (s.key, s.direction)).ToList()));
|
||||
cached_columns = ImmutableList<DIYGrid.ColumnBase>.Empty.AddRange(content._grid.Columns);
|
||||
|
||||
Func<PNLSaveState> get_save_state = () => {
|
||||
var cols = cached_columns.ToArray(c => c.create());
|
||||
var filters = vm.get_filters_states();
|
||||
var sorting_criterion = vm.sorting_hierarchy.Select(tup => new SortingCriteria(tup.key.ToString(), tup.direction == ListSortDirection.Ascending)).ToArray();
|
||||
var calc_type = vm.calculation_type;
|
||||
var state = settings_manager.instance_settings;
|
||||
if (state == null) {
|
||||
// don't use defaults if the user manipulated the window state outside of the settings dialog (e.g., resized column(s) via drag, or changed sort/filter)
|
||||
var defaults = settings_manager.default_settings;
|
||||
if (calc_type == defaults.calculation_type &&
|
||||
defaults.sorting_criterion.SequenceEqual(sorting_criterion) &&
|
||||
defaults.grid.columns.SequenceEqual(cols) && defaults.filters.safe_equals(filters)) {
|
||||
// the user's current state still matches the defaults (i.e., no outside manipulation was performed); return null so this window will use the latest default settings when restored
|
||||
return new PNLSaveState { use_defaults = true, settings = null };
|
||||
}
|
||||
state = defaults;
|
||||
}
|
||||
// assign latest values, as they may have be modified outside of the settings dialog (in which case the settings manager would be out of date)
|
||||
state = state.with(
|
||||
sorting_criterion,
|
||||
vm.anchors,
|
||||
filters,
|
||||
state.grid.with(columns: cols, background: vm.grid_background_color.rgb_color()),
|
||||
calc_type,
|
||||
vm.header_row_display);
|
||||
return new PNLSaveState { use_defaults = false, settings = state };
|
||||
};
|
||||
IEnumerable<SparkCommand> commands = new[] {
|
||||
new SparkCommandCommand("Collapse All", Icons.RightArrow, new DelegateCommand(() => vm.set_all_expanded(false))),
|
||||
new SparkCommandCommand("Expand All", Icons.DownArrow, new DelegateCommand(() => vm.set_all_expanded(true))),
|
||||
new SparkCommandCommand("Play", Icons.Play, new DelegateCommand(() => vm.is_paused = false)) {
|
||||
show_in_context_menu = _pnl_conf.show_pause_resume,
|
||||
show_in_toolbar = _pnl_conf.show_pause_resume
|
||||
},
|
||||
new SparkCommandCommand("Pause", Icons.Pause, new DelegateCommand(() => vm.is_paused = true)) {
|
||||
show_in_context_menu = _pnl_conf.show_pause_resume,
|
||||
show_in_toolbar = _pnl_conf.show_pause_resume
|
||||
},
|
||||
SparkCommands.window_settings_command(new DialogCommand(() => {
|
||||
settings_manager.instance_settings = get_save_state().settings;
|
||||
var dialog_vm = new ShellSettingsDialogVM<PNLSettings, PNLSettingsVM>(
|
||||
settings_manager,
|
||||
us => us.pnl,
|
||||
UserSettings.FileExtensions.PNL,
|
||||
s => new PNLSettingsVM(s));
|
||||
var dialog = new ShellSettingsDialog { DataContext = dialog_vm };
|
||||
if (main_win != null)
|
||||
dialog_vm.SubscribeDisposed(main_win.literal_title_source.OnDispatcher().Subscribe(t => dialog_vm.title = t));
|
||||
dialog_vm.RequestClose += on_request_close;
|
||||
return dialog;
|
||||
void on_request_close(object sender, EventArgs e) =>
|
||||
WindowUtilities.force_close(dialog);
|
||||
}))
|
||||
};
|
||||
IDisposable dispose = Disposable.Create(
|
||||
settings_manager.subscribe_current().OnDispatcher().Subscribe(s => {
|
||||
vm.load_from(s);
|
||||
var col_setting_map = s.grid.columns.ToDictionary(c => c.id);
|
||||
var fallback_family = new FontFamily(s.grid.font_family);
|
||||
// group
|
||||
var group_col_setting_map = s.group_columns.ToDictionary(c => c.id);
|
||||
var group_appearance = s.group_cell_appearance.to_appearance();
|
||||
// header
|
||||
var header_col_setting_map = s.header_columns.ToDictionary(c => c.id);
|
||||
var header_appearance = s.header_cell_appearance.to_appearance();
|
||||
//
|
||||
foreach (var c in content._grid.Columns.OfType<PNLColumn>()) {
|
||||
if (col_setting_map.TryGetValue(c.id, out var cs)) {
|
||||
c.load_from(cs);
|
||||
}
|
||||
if (group_col_setting_map.TryGetValue(c.id, out var gcs)) {
|
||||
c.load_group_params(
|
||||
group_appearance.font_size,
|
||||
gcs.font_weight_override ?? group_appearance.font_weight,
|
||||
gcs.font_color_override ?? group_appearance.foreground,
|
||||
group_appearance.font_family);
|
||||
}
|
||||
if (header_col_setting_map.TryGetValue(c.id, out var hcs)) {
|
||||
c.load_header_params(
|
||||
header_appearance.font_size,
|
||||
hcs.font_weight_override ?? header_appearance.font_weight,
|
||||
hcs.font_color_override ?? header_appearance.foreground,
|
||||
header_appearance.font_family);
|
||||
}
|
||||
}
|
||||
CollectionHelper.sync_with_never_duplicate(content._grid.Columns, s.grid.columns, cs => {
|
||||
throw new InvalidOperationException();
|
||||
}, c => c.id.ToLower(), cs => cs.id.ToLower());
|
||||
}),
|
||||
content._grid.Columns.Subscribe((s, e) => {
|
||||
switch (e.Action) {
|
||||
case NotifyCollectionChangedAction.Add: add_new(); break;
|
||||
case NotifyCollectionChangedAction.Remove: remove_old(); break;
|
||||
case NotifyCollectionChangedAction.Replace:
|
||||
case NotifyCollectionChangedAction.Move:
|
||||
remove_old();
|
||||
add_new();
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Reset:
|
||||
cached_columns = ImmutableList<DIYGrid.ColumnBase>.Empty.AddRange(content._grid.Columns);
|
||||
break;
|
||||
}
|
||||
void add_new() =>
|
||||
cached_columns = e.NewStartingIndex >= 0 ?
|
||||
cached_columns.InsertRange(e.NewStartingIndex, e.NewItems.OfType<DIYGrid.ColumnBase>()) :
|
||||
cached_columns.AddRange(e.NewItems.OfType<DIYGrid.ColumnBase>());
|
||||
|
||||
void remove_old() =>
|
||||
cached_columns = e.OldStartingIndex >= 0 ?
|
||||
cached_columns.RemoveRange(e.OldStartingIndex, e.OldItems.Count) :
|
||||
cached_columns.RemoveRange(e.OldItems.OfType<DIYGrid.ColumnBase>());
|
||||
}),
|
||||
Disposable.wrap_collection(commands.OfType<IDisposable>()),
|
||||
vm);
|
||||
return (content, commands, get_save_state, dispose);
|
||||
},
|
||||
min_width_offset: SystemParameters.HorizontalScrollBarButtonWidth + 8,
|
||||
min_height_offset: 60);
|
||||
return main_win;
|
||||
}
|
||||
|
||||
readonly struct PNLConfig {
|
||||
public readonly bool
|
||||
enable_animations,
|
||||
show_pause_resume;
|
||||
|
||||
public PNLConfig(bts.config.PNLOptions options) {
|
||||
enable_animations = options.enable_animations;
|
||||
show_pause_resume = options.show_pause_resume;
|
||||
}
|
||||
}
|
||||
|
||||
[Export(typeof(IPNLSettingsMigrationRule))]
|
||||
class AddMissingAnimationsMigrationRule : IPNLSettingsMigrationRule {
|
||||
public bool apply(PNLSettings settings, out PNLSettings new_settings) {
|
||||
if (settings != null && (
|
||||
_apply(ref settings, settings.animations, PNLSettings.default_animations, (s, anims) => s.with(animations: anims)) |
|
||||
_apply(ref settings, settings.group_header_animations, PNLSettings.default_group_header_animations, (s, anims) => s.with(group_header_animations: anims)) |
|
||||
_apply(ref settings, settings.header_row_animations, PNLSettings.default_header_row_animations, (s, anims) => s.with(header_row_animations: anims)))) {
|
||||
//
|
||||
new_settings = settings;
|
||||
return true;
|
||||
}
|
||||
new_settings = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool _apply(ref PNLSettings settings, IEnumerable<PNLAnimationTriggerData> actual_triggers, IEnumerable<PNLAnimationTriggerData> default_triggers, Func<PNLSettings, PNLAnimationTriggerData[], PNLSettings> set_triggers) {
|
||||
if (_apply(actual_triggers, default_triggers, out var result)) {
|
||||
settings = set_triggers(settings, actual_triggers.Concat(result).ToArray());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool _apply(IEnumerable<PNLAnimationTriggerData> actual_triggers, IEnumerable<PNLAnimationTriggerData> default_triggers, out IEnumerable<PNLAnimationTriggerData> result) {
|
||||
var default_trigger_map = default_triggers.ToDictionary(t => t.expression);
|
||||
var actual_trigger_map = actual_triggers.ToImmutableDictionary(t => t.expression);
|
||||
var snapshot = actual_trigger_map;
|
||||
foreach (var kv in snapshot) {
|
||||
if (default_trigger_map.TryGetValue(kv.Key, out var default_anims)) {
|
||||
// assume 1 animation per column
|
||||
var actual_col_anims = kv.Value.animations.ToDictionaryCrushed(a => a.column);
|
||||
var default_col_anims = default_anims.animations.ToDictionaryCrushed(a => a.column);
|
||||
actual_col_anims.Difference(default_col_anims,
|
||||
out var exclusive_actual,
|
||||
out var exclusive_defaults,
|
||||
out var diff);
|
||||
var new_col_anims = exclusive_defaults.ToList();
|
||||
if (new_col_anims.Count > 0) {
|
||||
// add the original col animations to the new ones (combine them)
|
||||
new_col_anims.AddRange(actual_col_anims);
|
||||
actual_trigger_map = actual_trigger_map.SetItem(kv.Key, kv.Value.with(animations: new_col_anims.Select(col_anim => col_anim.Value).ToArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var kv in default_trigger_map) {
|
||||
if (!actual_trigger_map.ContainsKey(kv.Key))
|
||||
actual_trigger_map = actual_trigger_map.Add(kv.Key, kv.Value);
|
||||
}
|
||||
if (actual_trigger_map != snapshot) {
|
||||
result = actual_trigger_map.Values;
|
||||
return true;
|
||||
}
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[Export(typeof(IPNLSettingsMigrationRule))]
|
||||
class AddMissingColumnsMigrationRule : IPNLSettingsMigrationRule {
|
||||
public bool apply(PNLSettings settings, out PNLSettings new_settings) {
|
||||
if (settings != null) {
|
||||
var defaults = PNLSettings.Default;
|
||||
if (_apply(ref settings, settings.grid.columns, defaults.grid.columns, (s, cols) => s.with(grid: s.grid.with(cols))) |
|
||||
_apply(ref settings, settings.group_columns, defaults.group_columns, (s, cols) => s.with(group_columns: cols)) |
|
||||
_apply(ref settings, settings.header_columns, defaults.header_columns, (s, cols) => s.with(header_columns: cols))) {
|
||||
new_settings = settings;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_settings = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool _apply(ref PNLSettings settings, IEnumerable<GridColumnSettings> actual_columns, IEnumerable<GridColumnSettings> default_columns, Func<PNLSettings, IEnumerable<GridColumnSettings>, PNLSettings> set_columns) {
|
||||
if (GridSettingsHelper.add_missing_columns(actual_columns, default_columns, out var new_cols)) {
|
||||
settings = set_columns(settings, new_cols);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[Export(typeof(IPNLSettingsMigrationRule))]
|
||||
class RemoveColumnsMigrationRule : IPNLSettingsMigrationRule {
|
||||
public bool apply(PNLSettings settings, out PNLSettings new_settings) {
|
||||
if (settings != null) {
|
||||
if (_apply(ref settings, settings.grid.columns, (s, cols) => s.with(grid: s.grid.with(cols))) |
|
||||
_apply(ref settings, settings.group_columns, (s, cols) => s.with(group_columns: cols)) |
|
||||
_apply(ref settings, settings.header_columns, (s, cols) => s.with(header_columns: cols))) {
|
||||
new_settings = settings;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_settings = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _apply(ref PNLSettings settings, IEnumerable<GridColumnSettings> columns, Func<PNLSettings, IEnumerable<GridColumnSettings>, PNLSettings> set_columns) {
|
||||
if (_apply(columns, out var new_cols)) {
|
||||
settings = set_columns(settings, new_cols);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _apply(IEnumerable<GridColumnSettings> columns, out IEnumerable<GridColumnSettings> result) {
|
||||
var col_list = columns.ToList();
|
||||
int orig_count = col_list.Count;
|
||||
col_list.RemoveWhere(c => !Enum.TryParse<PNLView.Columns>(c.id, true, out var _));
|
||||
if (col_list.Count < orig_count) {
|
||||
result = col_list;
|
||||
return true;
|
||||
}
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[Export(typeof(IPNLSettingsMigrationRule))]
|
||||
class RemoveColumnAnimationsMigrationRule : IPNLSettingsMigrationRule {
|
||||
public bool apply(PNLSettings settings, out PNLSettings new_settings) {
|
||||
if (settings != null) {
|
||||
if (_apply(ref settings, settings.animations, (s, t) => s.with(animations: t)) |
|
||||
_apply(ref settings, settings.group_header_animations, (s, t) => s.with(group_header_animations: t)) |
|
||||
_apply(ref settings, settings.header_row_animations, (s, t) => s.with(header_row_animations: t))) {
|
||||
new_settings = settings;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_settings = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _apply(ref PNLSettings settings, IEnumerable<PNLAnimationTriggerData> triggers, Func<PNLSettings, IEnumerable<PNLAnimationTriggerData>, PNLSettings> set_triggers) {
|
||||
if (_apply(triggers, out var new_triggers)) {
|
||||
settings = set_triggers(settings, new_triggers);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _apply(IEnumerable<PNLAnimationTriggerData> triggers, out IEnumerable<PNLAnimationTriggerData> result) {
|
||||
var trigger_map = triggers.ToImmutableDictionary(t => t.expression);
|
||||
var snapshot = trigger_map;
|
||||
foreach (var t in trigger_map.Values) {
|
||||
var anims = t.animations.ToList();
|
||||
int orig_count = anims.Count;
|
||||
anims.RemoveWhere(a => !Enum.IsDefined(typeof(PNLView.Columns), a.column));
|
||||
if (anims.Count < orig_count)
|
||||
trigger_map = trigger_map.SetItem(t.expression, t.with(animations: anims.ToArray()));
|
||||
}
|
||||
if (trigger_map != snapshot) {
|
||||
result = trigger_map.Values;
|
||||
return true;
|
||||
}
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[Export(typeof(IPNLSettingsMigrationRule))]
|
||||
class EnableGridBackgroundColorMigrationRule : IPNLSettingsMigrationRule {
|
||||
public bool apply(PNLSettings settings, out PNLSettings new_settings) {
|
||||
if (settings != null && !settings.grid.enable_background_color) {
|
||||
new_settings = settings.with(grid: settings.grid.with(enable_background_color: true));
|
||||
return true;
|
||||
}
|
||||
new_settings = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
using bts.api;
|
||||
using bts.collections;
|
||||
using bts.settings;
|
||||
using bts.shell.pnl;
|
||||
using bts.spark;
|
||||
using bts.utils;
|
||||
using mbts;
|
||||
using mbts.config;
|
||||
using mbts.persist;
|
||||
using mbts.spark;
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.settings;
|
||||
using mbts.ui.spark;
|
||||
using mbts.ui.utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace bts.shell {
|
||||
class PNLWindowFactory : ShellWindowFactory<PNLSaveState> {
|
||||
const string _window_type = "PNL", _window_title = "PNL";
|
||||
readonly IBus _bus;
|
||||
readonly OrdersModel _orders_model;
|
||||
readonly UserSettingsHub _settings_hub;
|
||||
readonly PNLConfig _pnl_conf;
|
||||
readonly IShellWindowThreadIDProvider _thread_id_provider;
|
||||
|
||||
public PNLWindowFactory(IShellModule owner, IBus bus, UserSettingsHub settings_hub, OrdersModel orders_model) : base(owner, _window_type) {
|
||||
_bus = bus;
|
||||
_orders_model = orders_model;
|
||||
_settings_hub = settings_hub;
|
||||
_pnl_conf = new PNLConfig(Configuration.get<bts.config.PNLOptions>());
|
||||
_thread_id_provider = ShellWindowThreadIDFactory.create(_window_type, Configuration.get<bts.config.MultiThreadedWindows>().pnl);
|
||||
_dispose = bus.subscribe(SparkTags.ShowPNLTag).OnDispatcher().Subscribe(_show);
|
||||
}
|
||||
|
||||
public override Task<IShellWindow> load(PNLSaveState state) =>
|
||||
Task.FromResult(_create(state.settings));
|
||||
|
||||
void _show(PNLSettings settings) =>
|
||||
_bus.post(SparkTags.ShowWindow, _create(settings));
|
||||
|
||||
IShellWindow _create(PNLSettings settings) {
|
||||
var settings_manager = _settings_hub.create_pnl_settings_manager(settings);
|
||||
// Need to keep a local copy of the columns, since they are defined in xaml (not the viewmodel), and get_save_state may be called on a non-dispatcher thread.
|
||||
// If that happens, we would be unable to access _grid.Columns, and thus unable to get the current column settings.
|
||||
// Use an ImmutableList to avoid any threading issues when responding to CollectionChanged events on the dispatcher thread.
|
||||
ImmutableList<DIYGrid.ColumnBase> cached_columns = ImmutableList<DIYGrid.ColumnBase>.Empty;
|
||||
return SparkWindow<PNLSaveState>.create(_window_type, _window_title, _bus, this, Icons.Accounting, _thread_id_provider.next_id(), () => {
|
||||
var vm = new PNLVM(_bus, _orders_model, settings ?? PNLSettings.Default);
|
||||
var content = new PNLView {
|
||||
DataContext = vm
|
||||
};
|
||||
vm.sorting_changed += sh => {
|
||||
try {
|
||||
DIYGridSortHelper.set_sort_directions(sh, content._grid.Columns);
|
||||
} catch { }
|
||||
};
|
||||
vm.SubscribeDisposed(
|
||||
DIYGridSortHelper.observe_active_comparers<PNLView.Columns, PNLRowVM>(content._grid, PNLVM.get_column_comparer)
|
||||
.OnDispatcher()
|
||||
.Subscribe(sh => vm.sorting_hierarchy = sh.Select(s => (s.key, s.direction)).ToList()));
|
||||
cached_columns = ImmutableList<DIYGrid.ColumnBase>.Empty.AddRange(content._grid.Columns);
|
||||
|
||||
Func<PNLSaveState> get_save_state = () => {
|
||||
var cols = cached_columns.ToArray(c => c.create());
|
||||
var filters = vm.get_filters_states();
|
||||
var sorting_criterion = vm.sorting_hierarchy.Select(tup => new SortingCriteria(tup.key.ToString(), tup.direction == ListSortDirection.Ascending)).ToArray();
|
||||
var calc_type = vm.calculation_type;
|
||||
var state = settings_manager.instance_settings;
|
||||
if (state == null) {
|
||||
// don't use defaults if the user manipulated the window state outside of the settings dialog (e.g., resized column(s) via drag, or changed sort/filter)
|
||||
var defaults = settings_manager.default_settings;
|
||||
if (calc_type == defaults.calculation_type &&
|
||||
defaults.sorting_criterion.SequenceEqual(sorting_criterion) &&
|
||||
defaults.grid.columns.SequenceEqual(cols) && defaults.filters.safe_equals(filters)) {
|
||||
// the user's current state still matches the defaults (i.e., no outside manipulation was performed); return null so this window will use the latest default settings when restored
|
||||
return new PNLSaveState { use_defaults = true, settings = null };
|
||||
}
|
||||
state = defaults;
|
||||
}
|
||||
// assign latest values, as they may have be modified outside of the settings dialog (in which case the settings manager would be out of date)
|
||||
state = state.with(
|
||||
sorting_criterion,
|
||||
vm.anchors,
|
||||
filters,
|
||||
state.grid.with(columns: cols, background: vm.grid_background_color.rgb_color()),
|
||||
calc_type,
|
||||
vm.header_row_display);
|
||||
return new PNLSaveState { use_defaults = false, settings = state };
|
||||
};
|
||||
IEnumerable<SparkCommand> commands = new[] {
|
||||
new SparkCommandCommand("Collapse All", Icons.RightArrow, new DelegateCommand(() => vm.set_all_expanded(false))),
|
||||
new SparkCommandCommand("Expand All", Icons.DownArrow, new DelegateCommand(() => vm.set_all_expanded(true))),
|
||||
new SparkCommandCommand("Play", Icons.Play, new DelegateCommand(() => vm.is_paused = false)) {
|
||||
show_in_context_menu = _pnl_conf.show_pause_resume,
|
||||
show_in_toolbar = _pnl_conf.show_pause_resume
|
||||
},
|
||||
new SparkCommandCommand("Pause", Icons.Pause, new DelegateCommand(() => vm.is_paused = true)) {
|
||||
show_in_context_menu = _pnl_conf.show_pause_resume,
|
||||
show_in_toolbar = _pnl_conf.show_pause_resume
|
||||
},
|
||||
SparkCommands.window_settings_command(new DialogCommand(() => {
|
||||
settings_manager.instance_settings = get_save_state().settings;
|
||||
var dialog_vm = new ShellSettingsDialogVM<PNLSettings, PNLSettingsVM>(
|
||||
settings_manager,
|
||||
us => us.pnl,
|
||||
UserSettings.FileExtensions.PNL,
|
||||
s => new PNLSettingsVM(s));
|
||||
var dialog = new ShellSettingsDialog { DataContext = dialog_vm };
|
||||
dialog_vm.RequestClose += on_request_close;
|
||||
return dialog;
|
||||
void on_request_close(object sender, EventArgs e) =>
|
||||
WindowUtilities.force_close(dialog);
|
||||
}))
|
||||
};
|
||||
IDisposable dispose = Disposable.Create(
|
||||
settings_manager.subscribe_current().OnDispatcher().Subscribe(s => {
|
||||
vm.load_from(s);
|
||||
var col_setting_map = s.grid.columns.ToDictionary(c => c.id);
|
||||
var fallback_family = new FontFamily(s.grid.font_family);
|
||||
// group
|
||||
var group_col_setting_map = s.group_columns.ToDictionary(c => c.id);
|
||||
var group_appearance = s.group_cell_appearance.to_appearance();
|
||||
// header
|
||||
var header_col_setting_map = s.header_columns.ToDictionary(c => c.id);
|
||||
var header_appearance = s.header_cell_appearance.to_appearance();
|
||||
//
|
||||
foreach (var c in content._grid.Columns.OfType<PNLColumn>()) {
|
||||
if (col_setting_map.TryGetValue(c.id, out var cs)) {
|
||||
c.load_from(cs);
|
||||
}
|
||||
if (group_col_setting_map.TryGetValue(c.id, out var gcs)) {
|
||||
c.load_group_params(
|
||||
group_appearance.font_size,
|
||||
gcs.font_weight_override ?? group_appearance.font_weight,
|
||||
gcs.font_color_override ?? group_appearance.foreground,
|
||||
group_appearance.font_family);
|
||||
}
|
||||
if (header_col_setting_map.TryGetValue(c.id, out var hcs)) {
|
||||
c.load_header_params(
|
||||
header_appearance.font_size,
|
||||
hcs.font_weight_override ?? header_appearance.font_weight,
|
||||
hcs.font_color_override ?? header_appearance.foreground,
|
||||
header_appearance.font_family);
|
||||
}
|
||||
}
|
||||
CollectionHelper.sync_with_never_duplicate(content._grid.Columns, s.grid.columns, cs => {
|
||||
throw new InvalidOperationException();
|
||||
}, c => c.id.ToLower(), cs => cs.id.ToLower());
|
||||
}),
|
||||
content._grid.Columns.Subscribe((s, e) => {
|
||||
switch (e.Action) {
|
||||
case NotifyCollectionChangedAction.Add: add_new(); break;
|
||||
case NotifyCollectionChangedAction.Remove: remove_old(); break;
|
||||
case NotifyCollectionChangedAction.Replace:
|
||||
case NotifyCollectionChangedAction.Move:
|
||||
remove_old();
|
||||
add_new();
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Reset:
|
||||
cached_columns = ImmutableList<DIYGrid.ColumnBase>.Empty.AddRange(content._grid.Columns);
|
||||
break;
|
||||
}
|
||||
void add_new() =>
|
||||
cached_columns = e.NewStartingIndex >= 0 ?
|
||||
cached_columns.InsertRange(e.NewStartingIndex, e.NewItems.OfType<DIYGrid.ColumnBase>()) :
|
||||
cached_columns.AddRange(e.NewItems.OfType<DIYGrid.ColumnBase>());
|
||||
|
||||
void remove_old() =>
|
||||
cached_columns = e.OldStartingIndex >= 0 ?
|
||||
cached_columns.RemoveRange(e.OldStartingIndex, e.OldItems.Count) :
|
||||
cached_columns.RemoveRange(e.OldItems.OfType<DIYGrid.ColumnBase>());
|
||||
}),
|
||||
Disposable.wrap_collection(commands.OfType<IDisposable>()),
|
||||
vm);
|
||||
return (content, commands, get_save_state, dispose);
|
||||
},
|
||||
min_width_offset: SystemParameters.HorizontalScrollBarButtonWidth + 8,
|
||||
min_height_offset: 60);
|
||||
}
|
||||
|
||||
readonly struct PNLConfig {
|
||||
public readonly bool
|
||||
enable_animations,
|
||||
show_pause_resume;
|
||||
|
||||
public PNLConfig(bts.config.PNLOptions options) {
|
||||
enable_animations = options.enable_animations;
|
||||
show_pause_resume = options.show_pause_resume;
|
||||
}
|
||||
}
|
||||
|
||||
[Export(typeof(IPNLSettingsMigrationRule))]
|
||||
class AddMissingAnimationsMigrationRule : IPNLSettingsMigrationRule {
|
||||
public bool apply(PNLSettings settings, out PNLSettings new_settings) {
|
||||
if (settings != null && (
|
||||
_apply(ref settings, settings.animations, PNLSettings.default_animations, (s, anims) => s.with(animations: anims)) |
|
||||
_apply(ref settings, settings.group_header_animations, PNLSettings.default_group_header_animations, (s, anims) => s.with(group_header_animations: anims)) |
|
||||
_apply(ref settings, settings.header_row_animations, PNLSettings.default_header_row_animations, (s, anims) => s.with(header_row_animations: anims)))) {
|
||||
//
|
||||
new_settings = settings;
|
||||
return true;
|
||||
}
|
||||
new_settings = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool _apply(ref PNLSettings settings, IEnumerable<PNLAnimationTriggerData> actual_triggers, IEnumerable<PNLAnimationTriggerData> default_triggers, Func<PNLSettings, PNLAnimationTriggerData[], PNLSettings> set_triggers) {
|
||||
if (_apply(actual_triggers, default_triggers, out var result)) {
|
||||
settings = set_triggers(settings, actual_triggers.Concat(result).ToArray());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool _apply(IEnumerable<PNLAnimationTriggerData> actual_triggers, IEnumerable<PNLAnimationTriggerData> default_triggers, out IEnumerable<PNLAnimationTriggerData> result) {
|
||||
var default_trigger_map = default_triggers.ToDictionary(t => t.expression);
|
||||
var actual_trigger_map = actual_triggers.ToImmutableDictionary(t => t.expression);
|
||||
var snapshot = actual_trigger_map;
|
||||
foreach (var kv in snapshot) {
|
||||
if (default_trigger_map.TryGetValue(kv.Key, out var default_anims)) {
|
||||
// assume 1 animation per column
|
||||
var actual_col_anims = kv.Value.animations.ToDictionaryCrushed(a => a.column);
|
||||
var default_col_anims = default_anims.animations.ToDictionaryCrushed(a => a.column);
|
||||
actual_col_anims.Difference(default_col_anims,
|
||||
out var exclusive_actual,
|
||||
out var exclusive_defaults,
|
||||
out var diff);
|
||||
var new_col_anims = exclusive_defaults.ToList();
|
||||
if (new_col_anims.Count > 0) {
|
||||
// add the original col animations to the new ones (combine them)
|
||||
new_col_anims.AddRange(actual_col_anims);
|
||||
actual_trigger_map = actual_trigger_map.SetItem(kv.Key, kv.Value.with(animations: new_col_anims.Select(col_anim => col_anim.Value).ToArray()));
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var kv in default_trigger_map) {
|
||||
if (!actual_trigger_map.ContainsKey(kv.Key))
|
||||
actual_trigger_map = actual_trigger_map.Add(kv.Key, kv.Value);
|
||||
}
|
||||
if (actual_trigger_map != snapshot) {
|
||||
result = actual_trigger_map.Values;
|
||||
return true;
|
||||
}
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[Export(typeof(IPNLSettingsMigrationRule))]
|
||||
class AddMissingColumnsMigrationRule : IPNLSettingsMigrationRule {
|
||||
public bool apply(PNLSettings settings, out PNLSettings new_settings) {
|
||||
if (settings != null) {
|
||||
var defaults = PNLSettings.Default;
|
||||
if (_apply(ref settings, settings.grid.columns, defaults.grid.columns, (s, cols) => s.with(grid: s.grid.with(cols))) |
|
||||
_apply(ref settings, settings.group_columns, defaults.group_columns, (s, cols) => s.with(group_columns: cols)) |
|
||||
_apply(ref settings, settings.header_columns, defaults.header_columns, (s, cols) => s.with(header_columns: cols))) {
|
||||
new_settings = settings;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_settings = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool _apply(ref PNLSettings settings, IEnumerable<GridColumnSettings> actual_columns, IEnumerable<GridColumnSettings> default_columns, Func<PNLSettings, IEnumerable<GridColumnSettings>, PNLSettings> set_columns) {
|
||||
if (GridSettingsHelper.add_missing_columns(actual_columns, default_columns, out var new_cols)) {
|
||||
settings = set_columns(settings, new_cols);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[Export(typeof(IPNLSettingsMigrationRule))]
|
||||
class RemoveColumnsMigrationRule : IPNLSettingsMigrationRule {
|
||||
public bool apply(PNLSettings settings, out PNLSettings new_settings) {
|
||||
if (settings != null) {
|
||||
if (_apply(ref settings, settings.grid.columns, (s, cols) => s.with(grid: s.grid.with(cols))) |
|
||||
_apply(ref settings, settings.group_columns, (s, cols) => s.with(group_columns: cols)) |
|
||||
_apply(ref settings, settings.header_columns, (s, cols) => s.with(header_columns: cols))) {
|
||||
new_settings = settings;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_settings = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _apply(ref PNLSettings settings, IEnumerable<GridColumnSettings> columns, Func<PNLSettings, IEnumerable<GridColumnSettings>, PNLSettings> set_columns) {
|
||||
if (_apply(columns, out var new_cols)) {
|
||||
settings = set_columns(settings, new_cols);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _apply(IEnumerable<GridColumnSettings> columns, out IEnumerable<GridColumnSettings> result) {
|
||||
var col_list = columns.ToList();
|
||||
int orig_count = col_list.Count;
|
||||
col_list.RemoveWhere(c => !Enum.TryParse<PNLView.Columns>(c.id, true, out var _));
|
||||
if (col_list.Count < orig_count) {
|
||||
result = col_list;
|
||||
return true;
|
||||
}
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[Export(typeof(IPNLSettingsMigrationRule))]
|
||||
class RemoveColumnAnimationsMigrationRule : IPNLSettingsMigrationRule {
|
||||
public bool apply(PNLSettings settings, out PNLSettings new_settings) {
|
||||
if (settings != null) {
|
||||
if (_apply(ref settings, settings.animations, (s, t) => s.with(animations: t)) |
|
||||
_apply(ref settings, settings.group_header_animations, (s, t) => s.with(group_header_animations: t)) |
|
||||
_apply(ref settings, settings.header_row_animations, (s, t) => s.with(header_row_animations: t))) {
|
||||
new_settings = settings;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
new_settings = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _apply(ref PNLSettings settings, IEnumerable<PNLAnimationTriggerData> triggers, Func<PNLSettings, IEnumerable<PNLAnimationTriggerData>, PNLSettings> set_triggers) {
|
||||
if (_apply(triggers, out var new_triggers)) {
|
||||
settings = set_triggers(settings, new_triggers);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool _apply(IEnumerable<PNLAnimationTriggerData> triggers, out IEnumerable<PNLAnimationTriggerData> result) {
|
||||
var trigger_map = triggers.ToImmutableDictionary(t => t.expression);
|
||||
var snapshot = trigger_map;
|
||||
foreach (var t in trigger_map.Values) {
|
||||
var anims = t.animations.ToList();
|
||||
int orig_count = anims.Count;
|
||||
anims.RemoveWhere(a => !Enum.IsDefined(typeof(PNLView.Columns), a.column));
|
||||
if (anims.Count < orig_count)
|
||||
trigger_map = trigger_map.SetItem(t.expression, t.with(animations: anims.ToArray()));
|
||||
}
|
||||
if (trigger_map != snapshot) {
|
||||
result = trigger_map.Values;
|
||||
return true;
|
||||
}
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[Export(typeof(IPNLSettingsMigrationRule))]
|
||||
class EnableGridBackgroundColorMigrationRule : IPNLSettingsMigrationRule {
|
||||
public bool apply(PNLSettings settings, out PNLSettings new_settings) {
|
||||
if (settings != null && !settings.grid.enable_background_color) {
|
||||
new_settings = settings.with(grid: settings.grid.with(enable_background_color: true));
|
||||
return true;
|
||||
}
|
||||
new_settings = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using mbts.ui.viewmodels;
|
||||
|
||||
namespace bts.shell.pnl {
|
||||
class PNLAnchorHierarchyVM : ItemOrderParameterVM<PNLView.Columns> {
|
||||
public PNLAnchorHierarchyVM()
|
||||
: base("", PNLSettings.anchorable_columns) { }
|
||||
}
|
||||
}
|
||||
@@ -1,88 +1,122 @@
|
||||
using bts.collections;
|
||||
using bts.proto;
|
||||
using mbts;
|
||||
using mbts.spark;
|
||||
using bts.proto;
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.settings;
|
||||
using mbts.ui.viewmodels;
|
||||
using System;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.utility.text;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using FontFamily = System.Windows.Media.FontFamily;
|
||||
|
||||
namespace bts.shell.pnl {
|
||||
class PNLCellAppearanceOverrideVM : ParameterGroupVM {
|
||||
public PNLCellAppearanceOverrideVM(string display_name, string rule = null) : base(display_name) {
|
||||
parameters.AddRange(background, font_color, font_weight);
|
||||
background.can_override = true;
|
||||
font_color.can_override = true;
|
||||
font_weight.can_override = true;
|
||||
}
|
||||
class PNLCellAppearanceOverrideVM : ViewModelBase {
|
||||
bool
|
||||
_is_background_overridden,
|
||||
_is_font_color_overridden,
|
||||
_is_font_weight_overridden,
|
||||
_is_font_family_overridden,
|
||||
_is_font_size_overridden;
|
||||
|
||||
public ColorOverrideParameterVM background { get; } = new ColorOverrideParameterVM("Background");
|
||||
public ColorOverrideParameterVM font_color { get; } = new ColorOverrideParameterVM("Font Color");
|
||||
public FontWeightOverrideParameterVM font_weight { get; } = new FontWeightOverrideParameterVM("Font Weight");
|
||||
FontWeight _font_weight_override;
|
||||
FontFamily _font_family_override;
|
||||
double _font_size_override = double.NaN;
|
||||
|
||||
// background
|
||||
public bool is_background_overridden { get => _is_background_overridden; set => Set(ref _is_background_overridden, value); }
|
||||
public ColorPickerPopupVM background_override { get; } = new ColorPickerPopupVM {
|
||||
bind_opacity_to_alpha = true,
|
||||
opacity = 1
|
||||
};
|
||||
// font color
|
||||
public bool is_font_color_overridden { get => _is_font_color_overridden; set => Set(ref _is_font_color_overridden, value); }
|
||||
public ColorPickerPopupVM font_color_override { get; } = new ColorPickerPopupVM();
|
||||
// font weight
|
||||
public bool is_font_weight_overridden { get => _is_font_weight_overridden; set => Set(ref _is_font_weight_overridden, value); }
|
||||
public FontWeight font_weight_override { get => _font_weight_override; set => Set(ref _font_weight_override, value); }
|
||||
// font family
|
||||
public bool is_font_family_overriden { get => _is_font_family_overridden; set => Set(ref _is_font_family_overridden, value); }
|
||||
public FontFamily font_family_override { get => _font_family_override; set => Set(ref _font_family_override, value); }
|
||||
// font size
|
||||
public bool is_font_size_overriden { get => _is_font_size_overridden; set => Set(ref _is_font_size_overridden, value); }
|
||||
public double font_size_override { get => _font_size_override; set => Set(ref _font_size_override, value); }
|
||||
|
||||
public GridColumnSettings apply_to(GridColumnSettings target) =>
|
||||
target.with(
|
||||
font_weight_override: new NullableFontWeightProto(font_weight.effective_is_overridden ? font_weight.override_value : (FontWeight?)null),
|
||||
font_color_override: new NullableColorProto(font_color.effective_is_overridden ? font_color.override_value : (Color?)null),
|
||||
background_color_override: new NullableColorProto(background.effective_is_overridden ? background.override_value : (Color?)null));
|
||||
font_weight_override: new NullableFontWeightProto(is_font_weight_overridden ? font_weight_override : (FontWeight?)null),
|
||||
font_color_override: new NullableColorProto(is_font_color_overridden ? font_color_override.color : (Color?)null),
|
||||
background_color_override: new NullableColorProto(is_background_overridden ? background_override.color : (Color?)null));
|
||||
|
||||
public IDisposable connect_default_values(GridSettingsVM grid_defaults) =>
|
||||
Disposable.Create(
|
||||
grid_defaults.subscribe_font().Subscribe(v => {
|
||||
font_weight.family = v.family;
|
||||
font_weight.default_value = v.weight;
|
||||
font_weight.size = v.size;
|
||||
}),
|
||||
grid_defaults.subscribe_font_color().Subscribe(v => {
|
||||
font_color.default_value = v;
|
||||
}),
|
||||
grid_defaults.subscribe_background().Subscribe(v => {
|
||||
background.default_value = v;
|
||||
}));
|
||||
public void load(GridColumnSettings settings) {
|
||||
if (settings != null)
|
||||
load(settings.font_weight_override, settings.font_color_override, settings.background_color_override);
|
||||
}
|
||||
|
||||
public PNLAnimation create(PNLView.Columns col_key) {
|
||||
var rv = new PNLAnimation {
|
||||
column = col_key
|
||||
public void load(FontParamsProto font_params) {
|
||||
if (font_params == null)
|
||||
return;
|
||||
// font weight
|
||||
is_font_weight_overridden = font_params.font_weight > 0;
|
||||
if (is_font_weight_overridden)
|
||||
font_weight_override = FontWeight.FromOpenTypeWeight(font_params.font_weight);
|
||||
// font color
|
||||
is_font_color_overridden = font_params.font_color > 0;
|
||||
if (is_font_color_overridden)
|
||||
font_color_override.color = font_params.font_color.rgb_color();
|
||||
// font family
|
||||
if (!string.IsNullOrEmpty(font_params.font_family)) {
|
||||
font_family_override = new FontFamily(font_params.font_family);
|
||||
}
|
||||
if (!double.IsNaN(font_params.font_size) && font_params.font_size > 0) {
|
||||
font_size_override = font_params.font_size;
|
||||
} else {
|
||||
font_size_override = double.NaN;
|
||||
}
|
||||
}
|
||||
|
||||
public void load(PNLAnimation animation) {
|
||||
if (animation != null)
|
||||
load(
|
||||
animation.font_weight.HasValue ? FontWeight.FromOpenTypeWeight(animation.font_weight.Value) : (FontWeight?)null,
|
||||
animation.foreground?.argb_color(),
|
||||
animation.background?.argb_color());
|
||||
}
|
||||
|
||||
public void load(FontWeight? font_weight, Color? font_color, Color? background) {
|
||||
// font weight
|
||||
is_font_weight_overridden = font_weight.HasValue;
|
||||
if (is_font_weight_overridden)
|
||||
font_weight_override = font_weight.Value;
|
||||
// font color
|
||||
is_font_color_overridden = font_color.HasValue;
|
||||
if (is_font_color_overridden)
|
||||
font_color_override.color = font_color.Value;
|
||||
// background
|
||||
is_background_overridden = background.HasValue;
|
||||
if (background.HasValue)
|
||||
background_override.color = background.Value;
|
||||
}
|
||||
|
||||
public PNLAnimation to_animation(PNLView.Columns key) =>
|
||||
new PNLAnimation {
|
||||
column = key,
|
||||
foreground = is_font_color_overridden ? font_color_override.color.rgb_color() : (uint?)null,
|
||||
background = is_background_overridden ? background_override.color.rgb_color() : (uint?)null,
|
||||
font_weight = is_font_weight_overridden ? font_weight_override.ToOpenTypeWeight() : (int?)null
|
||||
};
|
||||
if (background.effective_is_overridden)
|
||||
rv.background = background.override_value.rgb_color();
|
||||
if (font_color.effective_is_overridden)
|
||||
rv.foreground = font_color.override_value.rgb_color();
|
||||
if (font_weight.effective_is_overridden)
|
||||
rv.font_weight = font_weight.override_value.ToOpenTypeWeight();
|
||||
return rv;
|
||||
}
|
||||
|
||||
public void load(GridColumnSettings value) {
|
||||
// font weight
|
||||
font_weight.is_overridden = value.font_weight_override.HasValue;
|
||||
if (font_weight.is_overridden)
|
||||
font_weight.override_value = value.font_weight_override.Value;
|
||||
// font color
|
||||
font_color.is_overridden = value.font_color_override.HasValue;
|
||||
if (font_color.is_overridden)
|
||||
font_color.override_value = value.font_color_override.Value;
|
||||
// background
|
||||
background.is_overridden = value.background_color_override.HasValue;
|
||||
if (background.is_overridden)
|
||||
background.override_value = value.background_color_override.Value;
|
||||
}
|
||||
public PNLCellAppearanceProto to_appearance_proto() =>
|
||||
new PNLCellAppearanceProto {
|
||||
background = is_background_overridden ? background_override.color.rgb_color() : (uint?)null,
|
||||
font_params = to_font_params()
|
||||
};
|
||||
|
||||
public void load(PNLAnimation value) {
|
||||
// font weight
|
||||
font_weight.is_overridden = value.font_weight.HasValue && value.font_weight.Value > 0;
|
||||
if (font_weight.is_overridden)
|
||||
font_weight.override_value = FontWeight.FromOpenTypeWeight(value.font_weight.Value);
|
||||
// font color
|
||||
font_color.is_overridden = value.foreground.HasValue;
|
||||
if (font_color.is_overridden)
|
||||
font_color.override_value = value.foreground.Value.argb_color();
|
||||
// background
|
||||
background.is_overridden = value.background.HasValue;
|
||||
if (background.is_overridden)
|
||||
background.override_value = value.background.Value.argb_color();
|
||||
}
|
||||
public FontParamsProto to_font_params() =>
|
||||
new FontParamsProto {
|
||||
typeface = new TypefaceProto(
|
||||
font_family_override?.name(),
|
||||
is_font_weight_overridden ? font_weight_override.ToOpenTypeWeight() : 0),
|
||||
font_color = is_font_color_overridden ? font_color_override.color.rgb_color() : 0,
|
||||
font_size = font_size_override
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,51 +1,34 @@
|
||||
using bts.collections;
|
||||
using mbts.ui.viewmodels;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.shell;
|
||||
using System.Windows;
|
||||
using FontFamily = System.Windows.Media.FontFamily;
|
||||
|
||||
namespace bts.shell.pnl {
|
||||
class PNLHeaderRowCellAppearanceVM : ParameterGroupVM {
|
||||
readonly FontParameterVM _font = new FontParameterVM("Font");
|
||||
readonly ColorParameterVM
|
||||
_background = new ColorParameterVM("Background"),
|
||||
_font_color = new ColorParameterVM("Font Color");
|
||||
readonly BooleanParameterVM
|
||||
_show_totals = new BooleanParameterVM("Show Totals"),
|
||||
_show_selected_totals = new BooleanParameterVM("Show Selected Totals");
|
||||
class PNLCellAppearanceVM : ViewModelBase {
|
||||
FontWeight _font_weight;
|
||||
FontFamily _font_family;
|
||||
double _font_size = double.NaN;
|
||||
|
||||
public PNLHeaderRowCellAppearanceVM() : base("Header Row Display") {
|
||||
parameters.AddRange(
|
||||
HeaderedParameterGroupVM.create("Fonts/Colors", _font, _font_color, _background),
|
||||
HeaderedParameterGroupVM.create("Display", _show_totals, _show_selected_totals));
|
||||
}
|
||||
|
||||
public PNLHeaderRowDisplay display {
|
||||
get {
|
||||
var rv = PNLHeaderRowDisplay.None;
|
||||
if (_show_totals.value)
|
||||
rv |= PNLHeaderRowDisplay.Total;
|
||||
if (_show_selected_totals.value)
|
||||
rv |= PNLHeaderRowDisplay.SelectedTotal;
|
||||
return rv;
|
||||
}
|
||||
set {
|
||||
_show_totals.value = (display & PNLHeaderRowDisplay.Total) != 0;
|
||||
_show_selected_totals.value = (display & PNLHeaderRowDisplay.SelectedTotal) != 0;
|
||||
}
|
||||
}
|
||||
public ColorPickerPopupVM background { get; } = new ColorPickerPopupVM { bind_opacity_to_alpha = true, opacity = 1 };
|
||||
public ColorPickerPopupVM font_color { get; } = new ColorPickerPopupVM();
|
||||
public FontWeight font_weight { get => _font_weight; set => Set(ref _font_weight, value); }
|
||||
public FontFamily font_family { get => _font_family; set => Set(ref _font_family, value); }
|
||||
public double font_size { get => _font_size; set => Set(ref _font_size, value); }
|
||||
|
||||
public PNLCellAppearance to_appearance() =>
|
||||
new PNLCellAppearance(_font_color.value, _background.value, _font.weight, _font.family, _font.size);
|
||||
new PNLCellAppearance(font_color.color, background.color, font_weight, font_family, font_size);
|
||||
|
||||
public void load(PNLCellAppearance appearance) {
|
||||
if (appearance.background.HasValue)
|
||||
_background.value = appearance.background.Value;
|
||||
background.color = appearance.background.Value;
|
||||
if (appearance.foreground.HasValue)
|
||||
_font_color.value = appearance.foreground.Value;
|
||||
font_color.color = appearance.foreground.Value;
|
||||
if (appearance.font_family != null)
|
||||
_font.family = appearance.font_family;
|
||||
font_family = appearance.font_family;
|
||||
if (appearance.font_weight.HasValue)
|
||||
_font.weight = appearance.font_weight.Value;
|
||||
font_weight = appearance.font_weight.Value;
|
||||
if (appearance.font_size > 0)
|
||||
_font.size = appearance.font_size;
|
||||
font_size = appearance.font_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,216 +1,342 @@
|
||||
using bts.collections;
|
||||
using bts.utils;
|
||||
using mbts;
|
||||
using mbts.spark;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.settings;
|
||||
using mbts.ui.utilities;
|
||||
using mbts.ui.utility;
|
||||
using mbts.ui.viewmodels;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
|
||||
namespace bts.shell.pnl {
|
||||
class PNLModularCellAppearanceVM : TabularParameterGroupVM {
|
||||
public static PNLModularCellAppearanceVM create(PNLColumnCellAppearanceVM default_cell_appearance, IReadOnlyObservableCollection<object> rules) {
|
||||
var composite = new ObservableAggregateCollection<object>(new ObservableCollection<object> { default_cell_appearance });
|
||||
composite.add_collection(rules);
|
||||
return new PNLModularCellAppearanceVM(composite) {
|
||||
selected_item = default_cell_appearance
|
||||
};
|
||||
}
|
||||
|
||||
PNLModularCellAppearanceVM(ObservableCollection<object> parameters) : base("", parameters) { }
|
||||
}
|
||||
|
||||
class PNLColumnCellAppearanceVM : ParameterGroupVM {
|
||||
PNLCellAppearanceOverrideVM _selected_cell_mode;
|
||||
|
||||
public static Rule create_rule(string rule) =>
|
||||
new Rule(rule);
|
||||
|
||||
public PNLColumnCellAppearanceVM(string display_name) : base(display_name) {
|
||||
parameters.AddRange(default_vm, group_vm, header_vm);
|
||||
_selected_cell_mode = default_vm;
|
||||
}
|
||||
|
||||
public PNLCellAppearanceOverrideVM selected_cell_mode { get => _selected_cell_mode; set => Set(ref _selected_cell_mode, value); }
|
||||
public PNLCellAppearanceOverrideVM default_vm { get; } = new PNLCellAppearanceOverrideVM("Row") { is_expanded = true };
|
||||
public PNLCellAppearanceOverrideVM group_vm { get; } = new PNLCellAppearanceOverrideVM("Group Row");
|
||||
public PNLCellAppearanceOverrideVM header_vm { get; } = new PNLCellAppearanceOverrideVM("Header Row");
|
||||
|
||||
IEnumerable<PNLCellAppearanceOverrideVM> _cell_modes {
|
||||
get {
|
||||
yield return default_vm;
|
||||
yield return group_vm;
|
||||
yield return header_vm;
|
||||
}
|
||||
}
|
||||
|
||||
public IDisposable connect_default_values(GridSettingsVM grid_defaults) =>
|
||||
new System.Reactive.Disposables.CompositeDisposable(
|
||||
_cell_modes.Select(c => c.connect_default_values(grid_defaults)));
|
||||
|
||||
public class Rule : PNLColumnCellAppearanceVM {
|
||||
public Rule(string rule_text) : base($"When {DisplayNameHelper.expression_snake_to_title_case(rule_text)}") =>
|
||||
this.rule_text = rule_text;
|
||||
|
||||
public string rule_text { get; }
|
||||
}
|
||||
}
|
||||
|
||||
class PNLColumnSettingsVM : GridColumnSettingsVM {
|
||||
readonly ObservableAggregateCollection<object> _cell_appearance_groups = new ObservableAggregateCollection<object>();
|
||||
readonly _AutoRuleTabsWrapperVM _fonts_and_colors;
|
||||
readonly PNLView.Columns _key;
|
||||
|
||||
public PNLColumnSettingsVM(PNLView.Columns key) : base(null) {
|
||||
_key = key;
|
||||
_fonts_and_colors = new _AutoRuleTabsWrapperVM("Fonts/Colors", key);
|
||||
column_layout = new HeaderedParameterGroupVM("Column Layout", new ObservableCollection<object> {
|
||||
header, width, horizontal_alignment
|
||||
});
|
||||
apply_flags(GridColumnSettingsFeatureFlags.None);
|
||||
}
|
||||
|
||||
public HeaderedParameterGroupVM column_layout { get; }
|
||||
public HeaderedParameterGroupVM fonts_and_colors => _fonts_and_colors;
|
||||
public PNLColumnCellAppearanceVM default_cell_appearance => _fonts_and_colors.cell_appearance;
|
||||
|
||||
IEnumerable<PNLCellAppearanceOverrideVM> _all_cell_modes =>
|
||||
_fonts_and_colors.parameters
|
||||
.OfType<PNLColumnCellAppearanceVM>()
|
||||
.SelectMany(c => c.parameters.OfType<PNLCellAppearanceOverrideVM>());
|
||||
|
||||
public void load_from(GridColumnSettings value, IReadOnlyDictionary<string, PNLAnimation> triggers, GridColumnSettings group, IReadOnlyDictionary<string, PNLAnimation> group_triggers, IReadOnlyDictionary<string, PNLAnimation> header_triggers, GridColumnSettings header) {
|
||||
load_from(value);
|
||||
_fonts_and_colors.load_from(value, triggers, group, group_triggers, header_triggers, header);
|
||||
}
|
||||
|
||||
public IEnumerable<(string expression, PNLAnimation row, PNLAnimation group, PNLAnimation header)> get_triggers() =>
|
||||
_fonts_and_colors.create();
|
||||
|
||||
public IDisposable connect_default_values(GridSettingsVM grid_defaults) =>
|
||||
_fonts_and_colors.connect_default_values(grid_defaults);
|
||||
|
||||
public override string ToString() => "Default";
|
||||
|
||||
public override void sync_params() =>
|
||||
parameters.SetItems(column_layout, fonts_and_colors);
|
||||
|
||||
/// <summary>
|
||||
/// This class stores a <see cref="PNLColumnCellAppearanceVM"/> instance in a collection of parameters, and automatically replaces it with a <see cref="PNLModularCellAppearanceVM"/> when rules are loaded.
|
||||
/// Conversely, it replaces the <see cref="PNLModularCellAppearanceVM"/> with the original instance when rules are unloaded.
|
||||
/// The impetus: A special 'TabControl' based DataTemplate is defined in PNLSettingsView.xaml as the default for content of type <see cref="PNLModularCellAppearanceVM"/>.
|
||||
/// </summary>
|
||||
class _AutoRuleTabsWrapperVM : HeaderedParameterGroupVM {
|
||||
public readonly PNLColumnCellAppearanceVM cell_appearance;
|
||||
|
||||
readonly ObservableAggregateCollection<object> _composite_parameters;
|
||||
readonly ObservableCollection<PNLColumnCellAppearanceVM.Rule> _rules = new ObservableCollection<PNLColumnCellAppearanceVM.Rule>();
|
||||
readonly IReadOnlyObservableCollection<object> _wrapped_rules;
|
||||
readonly DeferrableActionWrapper _sync_params;
|
||||
PNLModularCellAppearanceVM _cell_appearance_rules;
|
||||
PNLView.Columns _id;
|
||||
|
||||
public _AutoRuleTabsWrapperVM(string display_name, PNLView.Columns id)
|
||||
: this(display_name, id, new ObservableAggregateCollection<object>()) { }
|
||||
|
||||
_AutoRuleTabsWrapperVM(string display_name, PNLView.Columns id, ObservableAggregateCollection<object> parameters) : base(display_name, parameters) {
|
||||
_id = id;
|
||||
_composite_parameters = parameters;
|
||||
cell_appearance = new PNLColumnCellAppearanceVM("Default");
|
||||
_wrapped_rules = _rules.CastObservable<PNLColumnCellAppearanceVM.Rule, object>();
|
||||
//_wrapped_rules = _rules.SelectObservable<PNLColumnCellAppearanceVM, object>(_ => _, obj => (PNLColumnCellAppearanceVM)obj);
|
||||
// If there are no rules present, the view should display a flat list of font/colors parameters.
|
||||
// If there are rules present, the view should use TabItems to represent each rule its associated font/color parameters,
|
||||
// as well as an additional Tab for the 'defaults.'
|
||||
// It is the responsibility of this class, as the viewmodel, to organize the parameters appropriately.
|
||||
// Listen to rules.CollectionChanged events, and toggle between the 'flat list of default parameters' and the TabItem groups when rules.Count > 0 changes.
|
||||
_composite_parameters.add_collection(cell_appearance.parameters);
|
||||
_composite_parameters.add_collection(_wrapped_rules);
|
||||
bool rules_present = false;
|
||||
_sync_params = new DeferrableActionWrapper(sync_params);
|
||||
_rules.CollectionChanged += (s, e) => _sync_params.execute();
|
||||
void sync_params() {
|
||||
if (rules_present != _rules.Count > 0) {
|
||||
rules_present = !rules_present;
|
||||
_composite_parameters.clear_collections();
|
||||
if (rules_present) {
|
||||
if (_cell_appearance_rules == null) {
|
||||
_cell_appearance_rules = PNLModularCellAppearanceVM.create(cell_appearance, _wrapped_rules);
|
||||
}
|
||||
_composite_parameters.insert_collection(0, new ObservableCollection<object> { _cell_appearance_rules });
|
||||
} else {
|
||||
_composite_parameters.insert_collection(0, new ObservableCollection<object> { cell_appearance });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<(string rule, PNLAnimation row, PNLAnimation group, PNLAnimation header)> create() =>
|
||||
_rules.Select(r => (r.rule_text, r.default_vm.create(_id), r.group_vm.create(_id), r.header_vm.create(_id)));
|
||||
|
||||
public void load_from(GridColumnSettings value, IReadOnlyDictionary<string, PNLAnimation> triggers, GridColumnSettings group, IReadOnlyDictionary<string, PNLAnimation> group_triggers, IReadOnlyDictionary<string, PNLAnimation> header_triggers, GridColumnSettings header) {
|
||||
using (_sync_params.defer_execution()) {
|
||||
_rules.Clear();
|
||||
cell_appearance.default_vm.load(value);
|
||||
cell_appearance.group_vm.load(group);
|
||||
cell_appearance.header_vm.load(header);
|
||||
foreach (var kv in triggers) {
|
||||
var rule_vm = PNLColumnCellAppearanceVM.create_rule(kv.Key);
|
||||
rule_vm.default_vm.load(kv.Value);
|
||||
if (group_triggers.TryGetValue(kv.Key, out var g)) {
|
||||
rule_vm.group_vm.load(g);
|
||||
}
|
||||
if (header_triggers.TryGetValue(kv.Key, out var h))
|
||||
rule_vm.header_vm.load(h);
|
||||
_rules.Add(rule_vm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GridSettingsVM _grid_defaults;
|
||||
|
||||
public IDisposable connect_default_values(GridSettingsVM grid_defaults) {
|
||||
Log.assert(_grid_defaults == null && grid_defaults != null);
|
||||
if (_rules.Count > 0) { }
|
||||
_grid_defaults = grid_defaults;
|
||||
_rules.CollectionChanged += _wtf;
|
||||
_wtf(_rules, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
||||
return Disposable.Create(
|
||||
cell_appearance.connect_default_values(grid_defaults),
|
||||
ObservableAutoWrapper.connect_item_hooks(_rules, r => r.connect_default_values(grid_defaults)),
|
||||
ObservableAutoWrapper.connect_item_hooks(parameters,
|
||||
obj => {
|
||||
if (obj is PNLColumnCellAppearanceVM cell_app) {
|
||||
return cell_app.connect_default_values(grid_defaults);
|
||||
} else if (obj is PNLCellAppearanceOverrideVM cell_app_over) {
|
||||
return cell_app_over.connect_default_values(grid_defaults);
|
||||
}
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
|
||||
private void _wtf(object sender, NotifyCollectionChangedEventArgs e) {
|
||||
if (_rules.Count > 0) {
|
||||
}
|
||||
switch (e.Action) {
|
||||
case NotifyCollectionChangedAction.Reset:
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using bts.collections;
|
||||
using bts.proto;
|
||||
using mbts;
|
||||
using mbts.spark;
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.settings;
|
||||
using mbts.ui.utilities;
|
||||
using mbts.ui.utility;
|
||||
using mbts.ui.viewmodels;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace bts.shell.pnl {
|
||||
class PNLColumnSettingsModeVM : GridColumnSettingsVM {
|
||||
readonly ObservableAggregateCollection<object> _aggregate_parameters = new ObservableAggregateCollection<object>();
|
||||
IDisposable _param_sync;
|
||||
List<(string rule, PNLCellModeVM vm)> _rules = new List<(string rule, PNLCellModeVM vm)>();
|
||||
|
||||
public PNLColumnSettingsModeVM(string mode) {
|
||||
this.mode = mode;
|
||||
show_horizontal_alignment = false;
|
||||
show_width = false;
|
||||
can_edit_header = false;
|
||||
header.can_override = false;
|
||||
parameter_group = new ParameterGroupVM(mode);
|
||||
_param_sync = ObservableAutoWrapper.connect(parameters, parameter_group.parameters);
|
||||
}
|
||||
|
||||
public ParameterGroupVM parameter_group { get; }
|
||||
public string mode { get; }
|
||||
public IEnumerable<(string rule, PNLCellModeVM vm)> rules => _rules;
|
||||
|
||||
public GridColumnSettings apply_to(GridColumnSettings target) {
|
||||
return target.with(
|
||||
font_weight_override: new NullableFontWeightProto(font_weight.effective_is_overridden ? font_weight.override_value : (FontWeight?)null),
|
||||
font_color_override: new NullableColorProto(font_color.effective_is_overridden ? font_color.override_value : (Color?)null),
|
||||
background_color_override: new NullableColorProto(background.effective_is_overridden ? background.override_value : (Color?)null));
|
||||
}
|
||||
|
||||
public void load_rules(IReadOnlyDictionary<string, PNLAnimation> rules) {
|
||||
Disposable.dispose(ref _param_sync);
|
||||
_rules = rules.Select(
|
||||
kv => {
|
||||
var rule_vm = new PNLCellModeVM($"When {DisplayNameHelper.expression_snake_to_title_case(kv.Key)}", kv.Key);
|
||||
rule_vm.load(kv.Value);
|
||||
return (kv.Key, rule_vm);
|
||||
})
|
||||
.ToList();
|
||||
if (_rules.Count > 0) {
|
||||
var row_defaults = new PNLCellModeVM("Default") { is_expanded = true };
|
||||
parameter_group.parameters.SetItems(_rules.Select(r => r.vm).Prepend(row_defaults));
|
||||
} else {
|
||||
sync_params();
|
||||
_param_sync = ObservableAutoWrapper.connect(parameters, parameter_group.parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PNLRulesVM : ParameterGroupVM {
|
||||
PNLCellModeRuleSetVM _selected_cell_mode;
|
||||
|
||||
public PNLRulesVM(string display_name) : base(display_name) {
|
||||
}
|
||||
|
||||
public PNLCellModeRuleSetVM selected_cell_mode { get => _selected_cell_mode; set => Set(ref _selected_cell_mode, value); }
|
||||
|
||||
public void load_from(GridColumnSettings value, IReadOnlyDictionary<string, PNLAnimation> triggers, GridColumnSettings group, IReadOnlyDictionary<string, PNLAnimation> group_triggers, IReadOnlyDictionary<string, PNLAnimation> header_triggers, GridColumnSettings header) {
|
||||
parameters.Clear();
|
||||
var default_mode = new PNLCellModeRuleSetVM("Default");
|
||||
default_mode.default_vm.load(value);
|
||||
default_mode.group_vm.load(group);
|
||||
default_mode.header_vm.load(header);
|
||||
parameters.Add(default_mode);
|
||||
foreach (var kv in triggers) {
|
||||
var rule_vm = new PNLCellModeRuleSetVM($"When {DisplayNameHelper.expression_snake_to_title_case(kv.Key)}", kv.Key);
|
||||
rule_vm.default_vm.load(kv.Value);
|
||||
if (group_triggers.TryGetValue(kv.Key, out var g)) {
|
||||
rule_vm.group_vm.load(g);
|
||||
}
|
||||
if (header_triggers.TryGetValue(kv.Key, out var h))
|
||||
rule_vm.header_vm.load(h);
|
||||
parameters.Add(rule_vm);
|
||||
}
|
||||
if (selected_cell_mode == null)
|
||||
selected_cell_mode = default_mode;
|
||||
}
|
||||
}
|
||||
|
||||
class PNLCellModeRuleSetVM : ParameterGroupVM {
|
||||
PNLCellRuleModeVM _selected_cell_mode;
|
||||
|
||||
public PNLCellModeRuleSetVM(string display_name, string rule = null) : base(display_name) {
|
||||
parameters.AddRange(default_vm, group_vm, header_vm);
|
||||
_selected_cell_mode = default_vm;
|
||||
}
|
||||
|
||||
public PNLCellRuleModeVM selected_cell_mode { get => _selected_cell_mode; set => Set(ref _selected_cell_mode, value); }
|
||||
public PNLCellRuleModeVM default_vm { get; } = new PNLCellRuleModeVM("Row") { is_expanded = true };
|
||||
public PNLCellRuleModeVM group_vm { get; } = new PNLCellRuleModeVM("Group Row");
|
||||
public PNLCellRuleModeVM header_vm { get; } = new PNLCellRuleModeVM("Header Row");
|
||||
}
|
||||
|
||||
class PNLCellRuleModeVM : ParameterGroupVM {
|
||||
public PNLCellRuleModeVM(string display_name, string rule = null) : base(display_name) {
|
||||
parameters.AddRange(background, font_color, font_weight);
|
||||
background.can_override = true;
|
||||
font_color.can_override = true;
|
||||
font_weight.can_override = true;
|
||||
}
|
||||
|
||||
public ColorOverrideParameterVM background { get; } = new ColorOverrideParameterVM("Background");
|
||||
public ColorOverrideParameterVM font_color { get; } = new ColorOverrideParameterVM("Font Color");
|
||||
public FontWeightOverrideParameterVM font_weight { get; } = new FontWeightOverrideParameterVM("Font Weight");
|
||||
|
||||
public GridColumnSettings apply_to(GridColumnSettings target) =>
|
||||
target.with(
|
||||
font_weight_override: new NullableFontWeightProto(font_weight.effective_is_overridden ? font_weight.override_value : (FontWeight?)null),
|
||||
font_color_override: new NullableColorProto(font_color.effective_is_overridden ? font_color.override_value : (Color?)null),
|
||||
background_color_override: new NullableColorProto(background.effective_is_overridden ? background.override_value : (Color?)null));
|
||||
|
||||
|
||||
public PNLAnimation create(PNLView.Columns col_key) {
|
||||
var rv = new PNLAnimation {
|
||||
column = col_key
|
||||
};
|
||||
if (background.effective_is_overridden)
|
||||
rv.background = background.override_value.rgb_color();
|
||||
if (font_color.effective_is_overridden)
|
||||
rv.foreground = font_color.override_value.rgb_color();
|
||||
if (font_weight.effective_is_overridden)
|
||||
rv.font_weight = font_weight.override_value.ToOpenTypeWeight();
|
||||
return rv;
|
||||
}
|
||||
|
||||
public void load(GridColumnSettings value) {
|
||||
// font weight
|
||||
font_weight.is_overridden = value.font_weight_override.HasValue;
|
||||
if (font_weight.is_overridden)
|
||||
font_weight.override_value = value.font_weight_override.Value;
|
||||
// font color
|
||||
font_color.is_overridden = value.font_color_override.HasValue;
|
||||
if (font_color.is_overridden)
|
||||
font_color.override_value = value.font_color_override.Value;
|
||||
// background
|
||||
background.is_overridden = value.background_color_override.HasValue;
|
||||
if (background.is_overridden)
|
||||
background.override_value = value.background_color_override.Value;
|
||||
}
|
||||
|
||||
public void load(PNLAnimation value) {
|
||||
// font weight
|
||||
font_weight.is_overridden = value.font_weight.HasValue && value.font_weight.Value > 0;
|
||||
if (font_weight.is_overridden)
|
||||
font_weight.override_value = FontWeight.FromOpenTypeWeight(value.font_weight.Value);
|
||||
// font color
|
||||
font_color.is_overridden = value.foreground.HasValue;
|
||||
if (font_color.is_overridden)
|
||||
font_color.override_value = value.foreground.Value.argb_color();
|
||||
// background
|
||||
background.is_overridden = value.background.HasValue;
|
||||
if (background.is_overridden)
|
||||
background.override_value = value.background.Value.argb_color();
|
||||
}
|
||||
}
|
||||
|
||||
class PNLCellModeVM : ParameterGroupVM {
|
||||
public PNLCellModeVM(string display_name, string rule = null) : base(display_name) {
|
||||
parameters.AddRange(background, font_color, font_weight);
|
||||
background.can_override = true;
|
||||
font_color.can_override = true;
|
||||
font_weight.can_override = true;
|
||||
}
|
||||
|
||||
public string rule { get; }
|
||||
|
||||
public ColorOverrideParameterVM background { get; } = new ColorOverrideParameterVM("Background");
|
||||
public ColorOverrideParameterVM font_color { get; } = new ColorOverrideParameterVM("Font Color");
|
||||
public FontWeightOverrideParameterVM font_weight { get; } = new FontWeightOverrideParameterVM("Font Weight");
|
||||
|
||||
public GridColumnSettings apply_to(GridColumnSettings target) =>
|
||||
target.with(
|
||||
font_weight_override: new NullableFontWeightProto(font_weight.effective_is_overridden ? font_weight.override_value : (FontWeight?)null),
|
||||
font_color_override: new NullableColorProto(font_color.effective_is_overridden ? font_color.override_value : (Color?)null),
|
||||
background_color_override: new NullableColorProto(background.effective_is_overridden ? background.override_value : (Color?)null));
|
||||
|
||||
|
||||
public PNLAnimation create(PNLView.Columns col_key) {
|
||||
var rv = new PNLAnimation {
|
||||
column = col_key
|
||||
};
|
||||
if (background.effective_is_overridden)
|
||||
rv.background = background.override_value.rgb_color();
|
||||
if (font_color.effective_is_overridden)
|
||||
rv.foreground = font_color.override_value.rgb_color();
|
||||
if (font_weight.effective_is_overridden)
|
||||
rv.font_weight = font_weight.override_value.ToOpenTypeWeight();
|
||||
return rv;
|
||||
}
|
||||
|
||||
public void load(PNLAnimation value) {
|
||||
// font weight
|
||||
font_weight.is_overridden = value.font_weight.HasValue && value.font_weight.Value > 0;
|
||||
if (font_weight.is_overridden)
|
||||
font_weight.override_value = FontWeight.FromOpenTypeWeight(value.font_weight.Value);
|
||||
// font color
|
||||
font_color.is_overridden = value.foreground.HasValue;
|
||||
if (font_color.is_overridden)
|
||||
font_color.override_value = value.foreground.Value.argb_color();
|
||||
// background
|
||||
background.is_overridden = value.background.HasValue;
|
||||
if (background.is_overridden)
|
||||
background.override_value = value.background.Value.argb_color();
|
||||
}
|
||||
}
|
||||
|
||||
class PNLColumnSettingsVM : GridColumnSettingsVM {
|
||||
readonly ObservableCollection<PNLColumnSettingsModeVM> _modes = new ObservableCollection<PNLColumnSettingsModeVM>();
|
||||
readonly ParameterGroupVM _column_params_group = new ParameterGroupVM("Column Layout");
|
||||
readonly ObservableAggregateCollection<object> _cell_appearance_groups = new ObservableAggregateCollection<object>();
|
||||
|
||||
public PNLColumnSettingsVM() : base(null) {
|
||||
_column_params_group.parameters.AddRange(header, width, horizontal_alignment);
|
||||
// hide header/width/align params in group/header vms
|
||||
group_column_vm.can_edit_width = false;
|
||||
group_column_vm.can_edit_header = false;
|
||||
group_column_vm.show_horizontal_alignment = false;
|
||||
group_column_vm.header.can_override = false;
|
||||
group_column_vm.sync_params();
|
||||
// header
|
||||
header_column_vm.show_width = false;
|
||||
header_column_vm.show_horizontal_alignment = false;
|
||||
header_column_vm.header.can_override = false;
|
||||
header_column_vm.sync_params();
|
||||
// header
|
||||
default_vm.show_width = false;
|
||||
default_vm.show_horizontal_alignment = false;
|
||||
default_vm.header.can_override = false;
|
||||
default_vm.sync_params();
|
||||
|
||||
default_vm.parameter_group.is_expanded = true;
|
||||
fonts_and_colors.parameters.Add(default_vm.parameter_group);
|
||||
fonts_and_colors.parameters.Add(group_column_vm.parameter_group);
|
||||
fonts_and_colors.parameters.Add(header_column_vm.parameter_group);
|
||||
|
||||
apply_flags(GridColumnSettingsFeatureFlags.None);
|
||||
sync_params();
|
||||
}
|
||||
|
||||
public ParameterGroupVM column_layout => _column_params_group;
|
||||
public ParameterGroupVM fonts_and_colors { get; } = new ParameterGroupVM("Fonts/Colors");
|
||||
public PNLColumnSettingsModeVM group_column_vm { get; } = new PNLColumnSettingsModeVM("Group Row");
|
||||
public PNLColumnSettingsModeVM header_column_vm { get; } = new PNLColumnSettingsModeVM("Header Row");
|
||||
public PNLColumnSettingsModeVM default_vm { get; } = new PNLColumnSettingsModeVM("Row");
|
||||
|
||||
protected override IEnumerable<object> _visible_parameters {
|
||||
get {
|
||||
yield return header;
|
||||
yield return width;
|
||||
yield return horizontal_alignment;
|
||||
//yield return default_vm.parameter_group;
|
||||
//yield return group_column_vm.parameter_group;
|
||||
//yield return header_column_vm.parameter_group;
|
||||
}
|
||||
}
|
||||
|
||||
public void load_from(GridColumnSettings value, IReadOnlyDictionary<string, PNLAnimation> triggers, GridColumnSettings group, IReadOnlyDictionary<string, PNLAnimation> group_triggers, IReadOnlyDictionary<string, PNLAnimation> header_triggers, GridColumnSettings header) {
|
||||
load_from(value);
|
||||
if (group != null)
|
||||
group_column_vm.load_from(group);
|
||||
if (header != null)
|
||||
header_column_vm.load_from(header);
|
||||
default_vm.load_rules(triggers);
|
||||
group_column_vm.load_rules(triggers);
|
||||
header_column_vm.load_rules(triggers);
|
||||
if (triggers == null || triggers.Count == 0) {
|
||||
fonts_and_colors.parameters.SetItems(new[] { default_vm.parameter_group, group_column_vm.parameter_group, header_column_vm.parameter_group });
|
||||
} else {
|
||||
fonts_and_colors.parameters.Clear();
|
||||
//var default_mode = new PNLCellModeRuleSetVM("Default");
|
||||
//default_mode.default_vm.load(value);
|
||||
//default_mode.group_vm.load(group);
|
||||
//default_mode.header_vm.load(header);
|
||||
//fonts_and_colors.parameters.Add(default_mode);
|
||||
//foreach (var kv in triggers) {
|
||||
// var rule_vm = new PNLCellModeRuleSetVM( $"When {DisplayNameHelper.expression_snake_to_title_case(kv.Key)}", kv.Key);
|
||||
// rule_vm.default_vm.load(kv.Value);
|
||||
// if (group_triggers.TryGetValue(kv.Key, out var g)) {
|
||||
// rule_vm.group_vm.load(g);
|
||||
// }
|
||||
// if (header_triggers.TryGetValue(kv.Key, out var h))
|
||||
// rule_vm.header_vm.load(h);
|
||||
// fonts_and_colors.parameters.Add(rule_vm);
|
||||
//}
|
||||
|
||||
var rule_set = new PNLRulesVM("Rules Poop");
|
||||
rule_set.load_from(value, triggers, group, group_triggers, header_triggers, header);
|
||||
fonts_and_colors.parameters.Add(rule_set);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<(string expression, PNLAnimation row, PNLAnimation group, PNLAnimation header)> get_triggers() {
|
||||
var triggers = new Dictionary<string, (PNLAnimation row, PNLAnimation group, PNLAnimation header)>();
|
||||
if (Enum.TryParse(id, out PNLView.Columns col_key)) {
|
||||
foreach (var (rule, vm) in default_vm.rules)
|
||||
triggers[rule] = (vm.create(col_key), null, null);
|
||||
foreach (var (rule, vm) in group_column_vm.rules)
|
||||
triggers.AddOrUpdate(rule, r => (null, vm.create(col_key), null), (r, tup) => (tup.row, vm.create(col_key), tup.header));
|
||||
foreach (var (rule, vm) in header_column_vm.rules)
|
||||
triggers.AddOrUpdate(rule, r => (null, null, vm.create(col_key)), (r, tup) => (tup.row, tup.group, vm.create(col_key)));
|
||||
}
|
||||
return triggers.Select(kv => (kv.Key, kv.Value.row, kv.Value.group, kv.Value.header));
|
||||
}
|
||||
|
||||
public override string ToString() => "Default";
|
||||
|
||||
static IEnumerable<object> _standard_params() {
|
||||
var header = new StringOverrideParameterVM("Header");
|
||||
var width = new DoubleParameterVM("Width");
|
||||
var horizontal_alignment = new HorizontalAlignmentParameterVM("Horizontal Alignment");
|
||||
yield return header;
|
||||
yield return width;
|
||||
yield return horizontal_alignment;
|
||||
}
|
||||
|
||||
static IEnumerable<object> _cell_appearance_params() {
|
||||
var background = new ColorOverrideParameterVM("Background");
|
||||
var font_color = new ColorOverrideParameterVM("Font Color");
|
||||
var font_weight = new FontWeightOverrideParameterVM();
|
||||
yield return background;
|
||||
yield return font_color;
|
||||
yield return font_weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,60 +1,58 @@
|
||||
using bts.collections;
|
||||
using bts.utils;
|
||||
using mbts.ui.utility;
|
||||
using mbts.ui.viewmodels;
|
||||
using mbts.spark;
|
||||
using mbts.ui;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.shell;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using FontFamily = System.Windows.Media.FontFamily;
|
||||
|
||||
namespace bts.shell.pnl {
|
||||
class PNLGroupRowCellAppearanceVM : ParameterGroupVM {
|
||||
readonly PNLAlternatingRowBackgroundVM _alternating_background_vm = new PNLAlternatingRowBackgroundVM();
|
||||
readonly ColorParameterVM _font_color = new ColorParameterVM("Font Color");
|
||||
readonly FontParameterVM _font = new FontParameterVM("Font");
|
||||
class PNLGroupRowAppearanceVM : ViewModelBase, IValueFactory<(PNLCellAppearance appearance, IReadOnlyList<Color> background_colors)> {
|
||||
FontWeight _font_weight;
|
||||
FontFamily _font_family;
|
||||
double _font_size = double.NaN;
|
||||
|
||||
public PNLGroupRowCellAppearanceVM() : base("Group") {
|
||||
parameters.AddRange(
|
||||
new HeaderedParameterGroupVM("Fonts/Colors", new ObservableCollection<object> { _font, _font_color }),
|
||||
_alternating_background_vm);
|
||||
public PNLGroupRowAppearanceVM() {
|
||||
add_background_cmd = new DelegateCommand(_add_background);
|
||||
// 4 elements is enough to alternate through any reasonable number of groups,
|
||||
// and clicking to add new backgrounds seems awkward
|
||||
for (int i = 0; i < 4; i++)
|
||||
_add_background();
|
||||
}
|
||||
|
||||
ObservableCollection<ColorParameterVM> _alternating_backgrounds => _alternating_background_vm.items;
|
||||
public ObservableCollection<NamedColorPickerPopupVM> background_colors { get; } = new ObservableCollection<NamedColorPickerPopupVM>();
|
||||
public ColorPickerPopupVM font_color { get; } = new ColorPickerPopupVM();
|
||||
public FontWeight font_weight { get => _font_weight; set => Set(ref _font_weight, value); }
|
||||
public FontFamily font_family { get => _font_family; set => Set(ref _font_family, value); }
|
||||
public double font_size { get => _font_size; set => Set(ref _font_size, value); }
|
||||
public ICommand add_background_cmd { get; }
|
||||
|
||||
public (PNLCellAppearance appearance, IReadOnlyList<Color> alternating_backgrounds) create() =>
|
||||
(new PNLCellAppearance(_font_color.value, Colors.Transparent, _font.weight, _font.family, _font.size),
|
||||
_alternating_backgrounds.Cast<ColorParameterVM>().Select(vm => vm.value).ToList());
|
||||
public (PNLCellAppearance appearance, IReadOnlyList<Color> background_colors) create() =>
|
||||
(new PNLCellAppearance(font_color.color, Colors.Transparent, font_weight, font_family, font_size),
|
||||
background_colors.WrapSelectorRO(cp => cp.color));
|
||||
|
||||
public void load((PNLCellAppearance appearance, IReadOnlyList<Color> alternating_backgrounds) value) {
|
||||
var (appearance, alternating_backgrounds) = value;
|
||||
for (int i = 0; i < alternating_backgrounds.Count; i++) {
|
||||
if (_alternating_backgrounds.Count > i) {
|
||||
var vm = _alternating_backgrounds[i];
|
||||
vm.value = alternating_backgrounds[i];
|
||||
}
|
||||
}
|
||||
while (alternating_backgrounds.Count > _alternating_backgrounds.Count)
|
||||
_alternating_backgrounds.Add(new ColorParameterVM($"Background {_alternating_backgrounds.Count}") {
|
||||
value = alternating_backgrounds[_alternating_backgrounds.Count]
|
||||
});
|
||||
while (_alternating_backgrounds.Count > alternating_backgrounds.Count)
|
||||
_alternating_backgrounds.RemoveAt(alternating_backgrounds.Count);
|
||||
CollectionHelper.add_or_update_existing(_alternating_backgrounds, alternating_backgrounds, c => new ColorParameterVM("") { value = c }, (vm, c) => ((ColorParameterVM)vm).value = c);
|
||||
if (appearance.foreground.HasValue)
|
||||
_font_color.value = appearance.foreground.Value;
|
||||
if (appearance.font_family != null)
|
||||
_font.family = appearance.font_family;
|
||||
if (appearance.font_weight.HasValue)
|
||||
_font.weight = appearance.font_weight.Value;
|
||||
if (appearance.font_size > 0)
|
||||
_font.size = appearance.font_size;
|
||||
public void load_from((PNLCellAppearance appearance, IReadOnlyList<Color> background_colors) value) {
|
||||
var (app, bg_colors) = value;
|
||||
// background colors
|
||||
while (background_colors.Count < bg_colors.Count)
|
||||
_add_background();
|
||||
for (int i = 0; i < bg_colors.Count; i++)
|
||||
background_colors[i].color = bg_colors[i];
|
||||
//
|
||||
if (app.foreground.HasValue) font_color.color = app.foreground.Value;
|
||||
if (app.font_family != null) font_family = app.font_family;
|
||||
if (app.font_weight.HasValue) font_weight = app.font_weight.Value;
|
||||
if (app.font_size > 0) font_size = app.font_size;
|
||||
}
|
||||
}
|
||||
|
||||
class PNLAlternatingRowBackgroundVM : HeaderedParameterGroupVM {
|
||||
public PNLAlternatingRowBackgroundVM() : base("Alternating Backgrounds") =>
|
||||
ObservableAutoWrapper.connect(items, parameters, c => c);
|
||||
|
||||
public ObservableCollection<ColorParameterVM> items { get; } = new ObservableCollection<ColorParameterVM>();
|
||||
void _add_background() =>
|
||||
background_colors.Add(new NamedColorPickerPopupVM {
|
||||
bind_opacity_to_alpha = true,
|
||||
name = $"Background {background_colors.Count + 1}"
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using bts.collections;
|
||||
using bts.utils;
|
||||
using mbts;
|
||||
using mbts.collections;
|
||||
using mbts.expression;
|
||||
using mbts.spark;
|
||||
using mbts.ui;
|
||||
@@ -10,30 +12,61 @@ using mbts.ui.utility;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using ColumnKeys = bts.shell.pnl.PNLView.Columns;
|
||||
|
||||
namespace bts.shell.pnl {
|
||||
enum CellTypes {
|
||||
Row,
|
||||
Group,
|
||||
Header
|
||||
}
|
||||
|
||||
class PNLSettingsVM : DisposableViewModelBase, IWindowSettingsVM<PNLSettings>, IValueFactory<PNLSettings>, IObservable<PNLSettings>, ITemplateSelectorKey {
|
||||
readonly IReadOnlyDictionary<ColumnKeys, AnchorItemVM> _anchor_cache;
|
||||
readonly DeferrableActionWrapper _sync_anchors;
|
||||
|
||||
PNLCalculationType _calculation_type;
|
||||
PNLHeaderRowDisplay _header_row_display;
|
||||
PNLSettings _last_loaded;
|
||||
|
||||
public PNLSettingsVM(PNLSettings settings) {
|
||||
// init anchor cache, deferrable resync
|
||||
_anchor_cache = PNLSettings.anchorable_columns.ToDictionary(k => k, k => new AnchorItemVM(this, k));
|
||||
_sync_anchors = new DeferrableActionWrapper(() => {
|
||||
for (int i = 0; i < anchor_items.Count; i++) {
|
||||
anchor_items[i].anchor_index = i + 1;
|
||||
anchor_items[i].refresh();
|
||||
}
|
||||
});
|
||||
core_settings_vm = new GridSettingsVM();
|
||||
columns = core_settings_vm.columns.CastObservable<GridColumnSettingsVM, PNLColumnSettingsVM>();
|
||||
//col_settings => {
|
||||
// var col_vm = new PNLColumnVM(core_settings_vm, EnumHelper.parse<ColumnKeys>(col_settings.id));
|
||||
// col_vm.load_from(col_settings);
|
||||
// return col_vm;
|
||||
// });
|
||||
_dispose = Disposable.Create(
|
||||
anchor_items.Subscribe((s, e) => _sync_anchors.execute()));
|
||||
load(settings);
|
||||
_dispose = ObservableAutoWrapper.connect_item_hooks(columns, col => col.connect_default_values(core_settings_vm));
|
||||
}
|
||||
|
||||
public PNLAnchorHierarchyVM anchor_hierarcy { get; } = new PNLAnchorHierarchyVM();
|
||||
public IEnumerable<AnchorItemVM> anchor_item_headers => _anchor_cache.Values;
|
||||
public ObservableCollection<AnchorItemVM> anchor_items { get; } = new ObservableCollection<AnchorItemVM>();
|
||||
public GridSettingsVM core_settings_vm { get; }
|
||||
public PNLGroupRowCellAppearanceVM group_row_defaults { get; } = new PNLGroupRowCellAppearanceVM();
|
||||
public PNLHeaderRowCellAppearanceVM header_row_defaults { get; } = new PNLHeaderRowCellAppearanceVM();
|
||||
public PNLGroupRowAppearanceVM group_row_defaults { get; } = new PNLGroupRowAppearanceVM();
|
||||
public PNLCellAppearanceVM header_row_defaults { get; } = new PNLCellAppearanceVM();
|
||||
public PNLCalculationType calculation_type { get => _calculation_type; set => Set(ref _calculation_type, value); }
|
||||
public IEnumerable<PNLCalculationType> calculation_types => EnumHelper.get_values_except(PNLCalculationType.None, PNLCalculationType.Same, PNLCalculationType.Opposite);
|
||||
public PNLHeaderRowDisplay header_row_display { get => _header_row_display; set => Set(ref _header_row_display, value); }
|
||||
public IEnumerable<PNLHeaderRowDisplay> header_row_display_options => PNLSettings.header_row_display_options;
|
||||
public IReadOnlyObservableCollection<PNLColumnSettingsVM> columns { get; }
|
||||
string ITemplateSelectorKey.key => GridSettingsTemplateKeys.PNL;
|
||||
|
||||
public ObservableCollection<NamedVM<GridColumnSettingsVM>> cell_types { get; }
|
||||
|
||||
public PNLSettings get_result() {
|
||||
var s = _last_loaded == null ? new PNLSettings() : SparkUtils.clone_proto(_last_loaded);
|
||||
s.calculation_type = _calculation_type;
|
||||
@@ -42,10 +75,13 @@ namespace bts.shell.pnl {
|
||||
var new_cols = new Lazy<List<GridColumnSettings>>(() => s.grid.columns.ToList());
|
||||
for (int i = 0; i < s.grid.columns.Count; i++) {
|
||||
var key = s.grid.columns[i].strong_id<ColumnKeys>();
|
||||
int anchor_index = anchor_hierarcy.value.indexOf(key);
|
||||
if (anchor_index != i && anchor_index >= 0) {
|
||||
new_cols.Value.RemoveAt(i);
|
||||
new_cols.Value.Insert(anchor_index, s.grid.columns[i]);
|
||||
if (_anchor_cache.TryGetValue(key, out var a) && a.anchor_index.HasValue) {
|
||||
// anchor index is 1 based, subtract 1 to get 0 based
|
||||
int anchor_index = a.anchor_index.Value - 1;
|
||||
if (anchor_index != i && anchor_index >= 0 && anchor_index < s.grid.columns.Count) {
|
||||
new_cols.Value.RemoveAt(i);
|
||||
new_cols.Value.Insert(anchor_index, s.grid.columns[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// rule-based animations
|
||||
@@ -62,16 +98,16 @@ namespace bts.shell.pnl {
|
||||
.Where(tup => CoreExpressionEvaluator<PNLNormalizedData>.validate(tup.expression))
|
||||
.ToList();
|
||||
|
||||
s = s.with(anchors: anchor_hierarcy.value,
|
||||
s = s.with(anchors: anchor_items.Select(vm => vm.key),
|
||||
grid: new_cols.IsValueCreated ? s.grid.with(columns: new_cols.Value) : null,
|
||||
group_columns: columns.Select(c => {
|
||||
var col_settings = c.create();
|
||||
col_settings = c.default_cell_appearance.group_vm.apply_to(col_settings);
|
||||
col_settings = c.group_column_vm.apply_to(col_settings);
|
||||
return col_settings;
|
||||
}),
|
||||
header_columns: columns.Select(c => {
|
||||
var col_settings = c.create();
|
||||
col_settings = c.default_cell_appearance.header_vm.apply_to(col_settings);
|
||||
col_settings = c.header_column_vm.apply_to(col_settings);
|
||||
return col_settings;
|
||||
}),
|
||||
animations: trigger_anims.Select(
|
||||
@@ -90,7 +126,7 @@ namespace bts.shell.pnl {
|
||||
expression = ta.expression,
|
||||
animations = Array.ConvertAll(ta.animations, t => t.header)
|
||||
}));
|
||||
s.header_row_display = header_row_defaults.display;
|
||||
s.header_row_display = header_row_display;
|
||||
s.header_cell_appearance = PNLCellAppearanceProto.from_appearance(header_row_defaults.to_appearance());
|
||||
// group
|
||||
var (group_cell_appearance, group_row_background_colors) = group_row_defaults.create();
|
||||
@@ -103,7 +139,7 @@ namespace bts.shell.pnl {
|
||||
public void load(PNLSettings value) {
|
||||
_last_loaded = value;
|
||||
header_row_defaults.load(value.header_cell_appearance.to_appearance());
|
||||
group_row_defaults.load((value.group_cell_appearance.to_appearance(), value.group_background_colors.WrapSelectorRO(c => c.argb_color())));
|
||||
group_row_defaults.load_from((value.group_cell_appearance.to_appearance(), value.group_background_colors.WrapSelectorRO(c => c.argb_color())));
|
||||
var column_map = _map_column_data(value.grid.columns, value.animations);
|
||||
var group_column_map = _map_column_data(value.group_columns, value.group_header_animations);
|
||||
var header_column_map = _map_column_data(value.header_columns, value.header_row_animations);
|
||||
@@ -111,8 +147,8 @@ namespace bts.shell.pnl {
|
||||
core_settings_vm.load(value.grid, false);
|
||||
using (core_settings_vm.begin_change_columns()) {
|
||||
core_settings_vm.columns.SetItems(value.grid.columns.Select(c => {
|
||||
var vm = new PNLColumnSettingsVM();
|
||||
var key = EnumHelper.parse<ColumnKeys>(c.id);
|
||||
var vm = new PNLColumnSettingsVM(key);
|
||||
var (col_settings, trigger_animations) = column_map[key];
|
||||
var group_data = group_column_map.GetNullable(key);
|
||||
var header_data = header_column_map.GetNullable(key);
|
||||
@@ -120,8 +156,9 @@ namespace bts.shell.pnl {
|
||||
return vm;
|
||||
}));
|
||||
}
|
||||
anchor_hierarcy.value = value.anchors.Intersect(PNLSettings.anchorable_columns);
|
||||
header_row_defaults.display = value.header_row_display;
|
||||
using (_sync_anchors.defer_execution())
|
||||
anchor_items.WrapSelector(a => a.key, k => _anchor_cache[k]).sync_with(value.anchors.Intersect(PNLSettings.anchorable_columns));
|
||||
header_row_display = value.header_row_display;
|
||||
calculation_type = value.calculation_type;
|
||||
}
|
||||
|
||||
@@ -141,5 +178,52 @@ namespace bts.shell.pnl {
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
void _append_or_remove_anchor(ColumnKeys key, bool include) {
|
||||
if (!_anchor_cache.TryGetValue(key, out var vm))
|
||||
throw new KeyNotFoundException($"Column key '{key}' is not anchorable (expected one of: {string.Join(", ", PNLSettings.anchorable_columns)}).");
|
||||
if (vm.include == include)
|
||||
return;
|
||||
if (include) {
|
||||
if (anchor_items.Any(a => a.key == key))
|
||||
throw new InvalidOperationException($"{nameof(anchor_items)} already contains an element with key '{key}.'");
|
||||
anchor_items.Add(vm);
|
||||
vm.anchor_index = anchor_items.Count;
|
||||
} else {
|
||||
if (!anchor_items.Remove(vm))
|
||||
throw new InvalidOperationException($"{nameof(anchor_items)} does not contain an element with key '{key}.'");
|
||||
vm.anchor_index = null;
|
||||
}
|
||||
_sync_anchors.execute();
|
||||
}
|
||||
|
||||
public class AnchorItemVM : ViewModelBase, IEquatable<AnchorItemVM> {
|
||||
readonly PNLSettingsVM _owner;
|
||||
int? _anchor_index;
|
||||
|
||||
public AnchorItemVM(PNLSettingsVM owner, ColumnKeys key) {
|
||||
_owner = owner;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public ColumnKeys key { get; }
|
||||
public bool include { get => anchor_index.HasValue; set => _owner._append_or_remove_anchor(key, value); }
|
||||
public int? anchor_index { get => _anchor_index; set => Set(ref _anchor_index, value); }
|
||||
|
||||
public void refresh() =>
|
||||
RaisePropertyChanged(nameof(include), nameof(anchor_index));
|
||||
|
||||
public bool Equals(AnchorItemVM other) =>
|
||||
other != null && key == other.key;
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
Equals(obj as AnchorItemVM);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
key.GetHashCode();
|
||||
|
||||
public override string ToString() =>
|
||||
EnumHelper.get_display_name(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,136 +3,223 @@
|
||||
x:ClassModifier="internal"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:shell="clr-namespace:bts.shell"
|
||||
xmlns:vm="clr-namespace:mbts.ui.viewmodels"
|
||||
xmlns:sp="clr-namespace:mbts.spark"
|
||||
xmlns:pnl="clr-namespace:bts.shell.pnl"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:cv="clr-namespace:mbts.ui.converters"
|
||||
xmlns:usp="clr-namespace:mbts.ui.spark"
|
||||
xmlns:vm="clr-namespace:mbts.ui.viewmodels"
|
||||
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
Content="{Binding}"
|
||||
>
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<usp:GridSettingsResources/>
|
||||
<ResourceDictionary Source="/view/Controls/TabControls/HorizontalTabControl.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<DataTemplate DataType="{x:Type pnl:PNLColumnSettingsVM}">
|
||||
<ItemsControl ItemsSource="{Binding parameters}"/>
|
||||
<sys:Double x:Key="CellTypesTabWidth">183</sys:Double>
|
||||
<DataTemplate x:Key="RowCellTypeTemplate" DataType="{x:Type pnl:PNLColumnSettingsVM}">
|
||||
<TextBlock>Row Cell Appearance</TextBlock>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="GroupCellTypeTemplate" DataType="{x:Type pnl:PNLColumnSettingsVM}">
|
||||
<TextBlock>Group Cell Appearance</TextBlock>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="HeaderCellTypeTemplate" DataType="{x:Type pnl:PNLColumnSettingsVM}">
|
||||
<TextBlock>Header Cell Appearance</TextBlock>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="ParametersListTemplate">
|
||||
<ListBox VerticalAlignment="Top" MinWidth="426" ItemsSource="{Binding parameters}" Style="{StaticResource NakedListBox}">
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem" BasedOn="{StaticResource NakedListBoxItem}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBoxItem">
|
||||
<Border Background="Transparent">
|
||||
<ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
</ListBox>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type vm:OrderedItemParameterVM}">
|
||||
<Style x:Key="ParameterGroupTabItem" TargetType="TabItem" BasedOn="{StaticResource LargeMenuControlBase}">
|
||||
<Setter Property="Padding" Value="14,10,14,10"/>
|
||||
<Setter Property="Background" Value="#FFE8E8E8"/>
|
||||
<Setter Property="Width" Value="{StaticResource CellTypesTabWidth}"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="TabItem">
|
||||
<Border
|
||||
x:Name="Border"
|
||||
CornerRadius="0"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
Background="{TemplateBinding Background}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Height="{TemplateBinding Height}"
|
||||
Width="{TemplateBinding Width}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
>
|
||||
<u:StateManager.Groups>
|
||||
<u:StateGroupsManager AttachToMembers="True">
|
||||
<u:StateDefinitionCollection>
|
||||
<u:MouseStateDefinition MouseSource="{Binding Group.Target.TemplatedParent, RelativeSource={RelativeSource Self}}"/>
|
||||
</u:StateDefinitionCollection>
|
||||
</u:StateGroupsManager>
|
||||
</u:StateManager.Groups>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup Name="MouseStates">
|
||||
<VisualState Name="Normal"/>
|
||||
<VisualState Name="MouseOver" Storyboard="{StaticResource Button.MouseOver.Storyboard}"/>
|
||||
<VisualState Name="Pressed" Storyboard="{StaticResource Button.Pressed.Storyboard}"/>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<ContentPresenter
|
||||
Name="presenter"
|
||||
Grid.Column="1"
|
||||
ContentSource="Header"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
RecognizesAccessKey="True"
|
||||
/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<DataTemplate x:Key="ParameterGroupTabHeaderTemplate">
|
||||
<TextBlock x:Name="text" FontSize="13" Text="{Binding name}"/>
|
||||
<DataTemplate.Triggers>
|
||||
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource AncestorType=TabItem}}" Value="True">
|
||||
<Setter TargetName="text" Property="TextBlock.FontWeight" Value="Bold"/>
|
||||
</DataTrigger>
|
||||
</DataTemplate.Triggers>
|
||||
</DataTemplate>
|
||||
<Style x:Key="ParameterGroupTabControl" TargetType="TabControl">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="TabStripPlacement" Value="Left"/>
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource ParameterGroupTabItem}"/>
|
||||
<Setter Property="ItemTemplate" Value="{StaticResource ParameterGroupTabHeaderTemplate}"/>
|
||||
<Setter Property="ItemsSource" Value="{Binding parameters}"/>
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource ParametersListTemplate}"/>
|
||||
</Style>
|
||||
|
||||
<DataTemplate DataType="{x:Type pnl:PNLRulesVM}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<CheckBox x:Name="IncludeToggle" VerticalAlignment="Top" Margin="0,4,0,0" Width="22" IsChecked="{Binding value}">
|
||||
<CheckBox.Height>
|
||||
<Binding Path="ActualHeight" ElementName="AnchorBorder">
|
||||
<Binding.Converter>
|
||||
<!--Offset Margin.Top-->
|
||||
<cv:DoubleSubtractionConverter Value="4"/>
|
||||
</Binding.Converter>
|
||||
</Binding>
|
||||
</CheckBox.Height>
|
||||
</CheckBox>
|
||||
<Border x:Name="AnchorBorder" Grid.Column="1" BorderBrush="Transparent" BorderThickness="0,4,4,4" MinWidth="120" Padding="6,8" Cursor="{StaticResource {x:Static u:CursorsEx.GrabKey}}">
|
||||
<u:StateManager.Groups>
|
||||
<u:StateGroupsManager AttachToMembers="True">
|
||||
<u:StateDefinitionCollection>
|
||||
<u:MouseStateDefinition MouseSource="{Binding Group.Target, RelativeSource={RelativeSource Self}}"/>
|
||||
<u:CheckedStateDefinition Source="{u:DirectReference IncludeToggle}"/>
|
||||
</u:StateDefinitionCollection>
|
||||
</u:StateGroupsManager>
|
||||
</u:StateManager.Groups>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup Name="MouseStates">
|
||||
<VisualState Name="Normal"/>
|
||||
<VisualState Name="MouseOver"/>
|
||||
<VisualState Name="Pressed">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Cursor">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource {x:Static u:CursorsEx.GrabbingKey}}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ColorAnimation Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Duration="0" To="{x:Static u:BTSColors.header_alternate_color}"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup Name="CheckedStates">
|
||||
<VisualState Name="Unchecked"/>
|
||||
<VisualState Name="Checked">
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetName="KeyIcon" Storyboard.TargetProperty="Opacity" BeginTime="0" Duration="0" To="1"/>
|
||||
<DoubleAnimation Storyboard.TargetName="AnchorIndex" Storyboard.TargetProperty="Opacity" BeginTime="0" Duration="0" To="1"/>
|
||||
<ColorAnimation Storyboard.TargetName="ColumnNameText" Storyboard.TargetProperty="Foreground.Color" BeginTime="0" Duration="0" To="Gold"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Border.Resources>
|
||||
<u:CursorsEx/>
|
||||
</Border.Resources>
|
||||
<Border.Background>
|
||||
<SolidColorBrush Color="{x:Static u:BTSColors.header_color}"/>
|
||||
</Border.Background>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image x:Name="KeyIcon" Height="11" Opacity="0">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Geometry="{Binding Source={StaticResource {x:Static u:Icons.KeyGeometryKey}}}" Brush="Gold"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
<TextBlock x:Name="AnchorIndex" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="16,0,0,-2" FontSize="8.5" Foreground="Gold" Opacity="0">
|
||||
<TextBlock.Text>
|
||||
<Binding Path="checked_index">
|
||||
<Binding.Converter>
|
||||
<cv:IntAdditionConverter Value="1"/>
|
||||
</Binding.Converter>
|
||||
</Binding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
<TextBlock x:Name="ColumnNameText" Grid.Column="1" Margin="6,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" FontWeight="Bold" Text="{Binding}">
|
||||
<TextBlock.Foreground>
|
||||
<SolidColorBrush Color="{x:Static u:BTSColors.header_text_color}"/>
|
||||
</TextBlock.Foreground>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type pnl:PNLAnchorHierarchyVM}">
|
||||
<Grid Margin="12,8">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock FontStyle="Italic">
|
||||
<Run>
|
||||
Check the groups you would like to use.
|
||||
</Run>
|
||||
<LineBreak/>
|
||||
<Run>
|
||||
Drag and drop them to change the grouping order.
|
||||
</Run>
|
||||
</TextBlock>
|
||||
<ItemsControl
|
||||
<!--<Rectangle Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="{StaticResource CellTypesTabWidth}" Fill="#FFE8E8E8"/>-->
|
||||
<c:HorizontalTabControl
|
||||
Grid.Row="1"
|
||||
AllowDrop="True"
|
||||
HorizontalAlignment="Left"
|
||||
ItemsSource="{Binding items}"
|
||||
Margin="0,8,0,0"
|
||||
Loaded="_anchor_items_loaded"
|
||||
Background="Transparent"
|
||||
BorderThickness="0,1,0,0"
|
||||
VerticalAlignment="Stretch"
|
||||
ItemsSource="{Binding parameters}"
|
||||
SelectedItem="{Binding selected_cell_mode}"
|
||||
DisplayMemberPath="name"
|
||||
>
|
||||
</ItemsControl>
|
||||
<TabControl.ItemContainerStyle>
|
||||
<Style TargetType="TabItem" BasedOn="{StaticResource ParameterGroupTabItem}">
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="Transparent"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Padding" Value="4"/>
|
||||
<Setter Property="Width" Value="{x:Static sys:Double.NaN}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<ItemsControl ItemsSource="{Binding parameters}"/>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<!--<Setter Property="BorderBrush" Value=""/>-->
|
||||
<Setter Property="BorderThickness" Value="1,1,1,0"/>
|
||||
<Setter Property="Padding" Value="4,6,4,8"/>
|
||||
<Setter Property="FontWeight" Value="Bold"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TabControl.ItemContainerStyle>
|
||||
</c:HorizontalTabControl>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type pnl:PNLColumnSettingsVM}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<!--<Rectangle Grid.Row="1" HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="{StaticResource CellTypesTabWidth}" Fill="#FFE8E8E8"/>-->
|
||||
<!--<TabControl
|
||||
Grid.Row="1"
|
||||
ItemsSource="{Binding cell_modes}"
|
||||
SelectedItem="{Binding selected_cell_mode}"
|
||||
Style="{StaticResource ParameterGroupTabControl}"
|
||||
/>-->
|
||||
<ContentControl Content="{Binding column_layout}" ContentTemplate="{StaticResource HeaderedParameterGroup}"/>
|
||||
<ContentControl Grid.Row="1" Content="{Binding fonts_and_colors}" ContentTemplate="{StaticResource HeaderedParameterGroup}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type sp:GridColumnSettingsVM}">
|
||||
<ListBox VerticalAlignment="Top" MinWidth="426" ItemsSource="{Binding parameters}" Style="{StaticResource NakedListBox}">
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem" BasedOn="{StaticResource NakedListBoxItem}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBoxItem">
|
||||
<Border Background="Transparent">
|
||||
<ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
</ListBox>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="HeaderedCellAppearanceContent" DataType="{x:Type sp:GridColumnSettingsVM}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="36"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock VerticalAlignment="Center" FontSize="14" FontWeight="SemiBold">
|
||||
Cell Appearance
|
||||
</TextBlock>
|
||||
<ListBox Grid.Row="1" VerticalAlignment="Top" ItemsSource="{Binding parameters}" Style="{StaticResource NakedListBox}">
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem" BasedOn="{StaticResource NakedListBoxItem}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBoxItem">
|
||||
<Border Background="Transparent">
|
||||
<ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
@@ -140,35 +227,133 @@
|
||||
<UserControl.ContentTemplate>
|
||||
<DataTemplate DataType="{x:Type pnl:PNLSettingsVM}">
|
||||
<Grid>
|
||||
<u:BindingProxy x:Name="ActionMenuItemsViewProxy" Value="{DynamicResource ActionMenuItemsView}"/>
|
||||
<c:ActionMenu ItemsSource="{Binding Path='(u:BindingProxy.Value).(CollectionViewSource.View)', ElementName=ActionMenuItemsViewProxy}">
|
||||
<ItemsControl.GroupStyle>
|
||||
<GroupStyle ContainerStyle="{StaticResource ComboBox.DelineatedGroupContainerStyle.DynamicFill}"/>
|
||||
</ItemsControl.GroupStyle>
|
||||
</c:ActionMenu>
|
||||
<TabControl MinWidth="600" Margin="0,2,0,0" Style="{StaticResource FlatTabControl}">
|
||||
<Grid.Margin>
|
||||
<Thickness Left="{StaticResource HorizontalPush2}" Right="{StaticResource HorizontalPush2}"/>
|
||||
</Grid.Margin>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<c:ActionMenu
|
||||
Panel.ZIndex="1"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Margin="0,2,0,0"
|
||||
ItemsSource="{Binding DataContext.action_menu_items, RelativeSource={RelativeSource AncestorType=usp:ShellSettingsDialog}}"
|
||||
Style="{StaticResource SparkToolBarItem}"
|
||||
/>
|
||||
<TabControl x:Name="Tabs" Background="Transparent" HorizontalAlignment="Stretch" MinHeight="480" MinWidth="600" Margin="0,2,0,0" Padding="6">
|
||||
<TabControl.ItemContainerStyle>
|
||||
<Style TargetType="TabItem">
|
||||
<Setter Property="MinWidth" Value="60"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
</TabControl.ItemContainerStyle>
|
||||
<TabItem Header="Grid">
|
||||
<ItemsControl
|
||||
Grid.IsSharedSizeScope="True"
|
||||
ItemsSource="{Binding core_settings_vm.parameters}"
|
||||
/>
|
||||
<ItemsControl x:Name="ParameterItemsControl" Grid.IsSharedSizeScope="True" Margin="8,16,0,0" ItemsSource="{Binding core_settings_vm.parameters}"/>
|
||||
</TabItem>
|
||||
<TabItem Header="Grouping" Content="{Binding anchor_hierarcy}"/>
|
||||
<TabItem Header="Group Row Display">
|
||||
<ItemsControl
|
||||
Grid.IsSharedSizeScope="True"
|
||||
ItemsSource="{Binding group_row_defaults.parameters}"
|
||||
/>
|
||||
<TabItem Header="Grouping">
|
||||
<GroupBox Grid.Column="3" Grid.RowSpan="3" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">
|
||||
<GroupBox.Resources>
|
||||
<u:CursorsEx/>
|
||||
</GroupBox.Resources>
|
||||
<GroupBox.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock>Grouping</TextBlock>
|
||||
<c:HelpButton>
|
||||
<c:HelpButton.Resources>
|
||||
<Style x:Key="HelpButtonToolTipStyleKey" TargetType="ToolTip">
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<TextBlock>
|
||||
<Run>Check the group parameters you would like to use.</Run>
|
||||
<LineBreak/>
|
||||
<Run FontStyle="Italic">Hint: drag/drop the items below to change the grouping hierarchy.</Run>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</c:HelpButton.Resources>
|
||||
</c:HelpButton>
|
||||
<ItemsControl ItemsSource="{Binding anchor_item_headers}" ItemsPanel="{StaticResource HorizontalItemsPanelTemplate}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<CheckBox Margin="4,0,0,0" Content="{Binding key}" ContentTemplate="{StaticResource EnumDescriptionTemplate}" IsChecked="{Binding include}"/>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</GroupBox.Header>
|
||||
<ItemsControl
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
AllowDrop="True"
|
||||
ItemsSource="{Binding anchor_items}"
|
||||
ItemTemplate="{DynamicResource AnchorItemTemplate}"
|
||||
ItemsPanel="{StaticResource HorizontalItemsPanelTemplate}"
|
||||
Loaded="_pnl_anchor_items_loaded"
|
||||
/>
|
||||
</GroupBox>
|
||||
</TabItem>
|
||||
<TabItem Header="Header Row Display">
|
||||
<ItemsControl
|
||||
Grid.IsSharedSizeScope="True"
|
||||
ItemsSource="{Binding header_row_defaults.parameters}"
|
||||
/>
|
||||
<TabItem Header="Columns">
|
||||
<Grid Grid.IsSharedSizeScope="True">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<!--<ColumnDefinition Width="{Binding Source={StaticResource HorizontalPush4}}"/>-->
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<c:DragDropListBox
|
||||
x:Name="ColumnListBox"
|
||||
DataContext="{Binding core_settings_vm}"
|
||||
SelectedItem="{Binding current_column}"
|
||||
SelectItemOnDrop="True"
|
||||
Style="{DynamicResource ColumnsListBox}"
|
||||
/>
|
||||
<!--<ListBox
|
||||
x:Name="CellTypeListBox"
|
||||
Grid.Column="1"
|
||||
Width="165"
|
||||
ItemsSource="{u:EnumBindingSource {x:Type pnl:CellTypes}}"
|
||||
SelectedIndex="0"
|
||||
Style="{StaticResource LargeMenuListBox}"
|
||||
>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding StringFormat='{}{0} Cell Appearance'}"/>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
<ListBox.Background>
|
||||
<SolidColorBrush Color="#FFDDDDDD"/>
|
||||
</ListBox.Background>
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem" BasedOn="{StaticResource LargeMenuListBoxItemBase}">
|
||||
<Setter Property="Padding" Value="8"/>
|
||||
<Setter Property="FontSize" Value="13"/>
|
||||
<Setter Property="FontWeight" Value="{Binding IsSelected, RelativeSource={RelativeSource Self}, Converter={StaticResource BooleanFontWeightConverter}}"/>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
</ListBox>-->
|
||||
<GridSplitter Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="5" Background="Transparent"/>
|
||||
<ScrollViewer Grid.Column="2" VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto" Content="{Binding core_settings_vm.current_column}">
|
||||
<!--<MultiBinding Converter="{x:Static usp:PNLSettingsView.ColumnContentConverter}">
|
||||
<Binding Path="SelectedItem" ElementName="ColumnListBox"/>
|
||||
<Binding Path="SelectedItem" ElementName="CellTypeListBox"/>
|
||||
</MultiBinding>-->
|
||||
<ScrollViewer.MaxHeight>
|
||||
<Binding Path="ActualHeight" RelativeSource="{RelativeSource AncestorType=usp:PNLSettingsView}">
|
||||
<Binding.Converter>
|
||||
<cv:DoubleSubtractionConverter Value="26"/>
|
||||
</Binding.Converter>
|
||||
</Binding>
|
||||
</ScrollViewer.MaxHeight>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Columns" Content="{Binding core_settings_vm}" ContentTemplate="{StaticResource ColumnsTabContent}"/>
|
||||
</TabControl>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</UserControl.ContentTemplate>
|
||||
</UserControl>
|
||||
</UserControl>
|
||||
@@ -1,129 +1,70 @@
|
||||
using bts;
|
||||
using mbts.ui.controls.adorners;
|
||||
using mbts.ui.extensions;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace mbts.ui.spark {
|
||||
/// <summary>
|
||||
/// Interaction logic for PNLSettingsView.xaml
|
||||
/// </summary>
|
||||
partial class PNLSettingsView : UserControl {
|
||||
public PNLSettingsView() =>
|
||||
InitializeComponent();
|
||||
|
||||
IDisposable _anchor_items_drag_drop_behavior;
|
||||
|
||||
void _anchor_items_loaded(object sender, RoutedEventArgs e) {
|
||||
// connecting this drag/drop behavior is idempotent, just in case Loaded happens twice
|
||||
Disposable.dispose(ref _anchor_items_drag_drop_behavior);
|
||||
if (!(sender is ItemsControl ic))
|
||||
return;
|
||||
var root_grid = Window.GetWindow(ic)?.Content as Grid;
|
||||
bool is_dragging = false;
|
||||
IDisposable drag_op = null;
|
||||
var cursor_resources = new Lazy<CursorsEx>();
|
||||
_anchor_items_drag_drop_behavior = Disposable.Create(() => Disposable.dispose(ref drag_op));
|
||||
DragDropHelper.subscribe_drag_start(ic).Subscribe(pt => {
|
||||
if (!is_dragging &&
|
||||
ic.InputHitTest(pt) is DependencyObject d &&
|
||||
ic.ContainerFromElement(d) is FrameworkElement item_view &&
|
||||
ic.ItemContainerGenerator.ItemFromContainer(item_view) is object item &&
|
||||
item != DependencyProperty.UnsetValue) {
|
||||
//
|
||||
item_view.SetCurrentValue(OpacityProperty, 0.5);
|
||||
is_dragging = true;
|
||||
var sz = item_view.RenderSize;
|
||||
var dv = new DrawingVisual();
|
||||
using (var dc = dv.RenderOpen())
|
||||
dc.DrawRoundedRectangle(new VisualBrush(item_view) { Stretch = Stretch.Uniform }, null, new Rect(sz), 0, 0);
|
||||
SetCurrentValue(CursorProperty, Cursors.ScrollWE);
|
||||
SetCurrentValue(AllowDropProperty, true);
|
||||
is_dragging = true;
|
||||
Disposable.replace(ref drag_op, new CompositeDisposable {
|
||||
MouseTraceAdorner.trace_drag(root_grid, dv, sz),
|
||||
DragDropHelper.connect_vertical_insertion_adorner(ic, root_grid),
|
||||
this.SubscribePreviewDrop(on_drop),
|
||||
this.SubscribePreviewMouseUp(on_preview_mouse_up),
|
||||
this.SubscribePreviewDragOver(on_drag),
|
||||
this.SubscribePreviewDragLeave(on_drag),
|
||||
this.SubscribePreviewDragEnter(on_drag),
|
||||
() => {
|
||||
ClearValue(CursorProperty);
|
||||
ClearValue(AllowDropProperty);
|
||||
item_view.ClearValue(OpacityProperty);
|
||||
is_dragging = false;
|
||||
}});
|
||||
DragDrop.DoDragDrop(this, new DataObject(DataFormats.StringFormat, item), DragDropEffects.Move);
|
||||
}
|
||||
});
|
||||
|
||||
void on_drag(object s, DragEventArgs de) =>
|
||||
de.Effects = DragDropEffects.Move;
|
||||
|
||||
void on_drop(object _, DragEventArgs drop_e) {
|
||||
drop_e.Handled = true;
|
||||
if (!is_dragging)
|
||||
return;
|
||||
Disposable.dispose(ref drag_op);
|
||||
if (drop_e.Data.GetDataPresent(DataFormats.StringFormat) &&
|
||||
drop_e.Data.GetData(DataFormats.StringFormat) is object from &&
|
||||
ic.ItemsSource is IList anchor_items &&
|
||||
anchor_items.Count > 1) {
|
||||
//
|
||||
var pt = drop_e.GetPosition(this);
|
||||
if (!(InputHitTest(pt) is DependencyObject hit))
|
||||
return;
|
||||
try {
|
||||
int from_i = anchor_items.IndexOf(from);
|
||||
// Set the container to the first item who's right edge is left of pt.X (or the last item if none satisfy that condition).
|
||||
// The logic presumes that the items are laid out in a single, horizontal line, from left to right
|
||||
// (not the most elegant way to get the drop target, but it's effective).
|
||||
int to_i = -1;
|
||||
if (!(ic.ContainerFromElement(hit) is FrameworkElement drop_target)) {
|
||||
for (to_i = 0; to_i < ic.Items.Count; to_i++) {
|
||||
if (ic.ItemContainerGenerator.ContainerFromIndex(to_i) is FrameworkElement c) {
|
||||
drop_target = c;
|
||||
var tl = c.TranslatePoint(new Point(0, 0), this);
|
||||
var bottom_edge = tl.Y + c.ActualHeight;
|
||||
if (bottom_edge >= pt.Y)
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (drop_target.DataContext is object to) {
|
||||
to_i = anchor_items.IndexOf(to);
|
||||
var drop_target_pt = TranslatePoint(pt, drop_target);
|
||||
if (drop_target_pt.Y > drop_target.ActualHeight / 2) {
|
||||
// target is "Between drop_target and the item below it"
|
||||
if (from_i > to_i)
|
||||
to_i++;
|
||||
} else {
|
||||
// target is "Between drop_target and the item above it"
|
||||
if (from_i < to_i) {
|
||||
to_i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (to_i < 0)
|
||||
return;
|
||||
if (to_i >= anchor_items.Count)
|
||||
to_i = anchor_items.Count - 1;
|
||||
if (from_i >= 0)
|
||||
anchor_items.Move(from_i, to_i);
|
||||
} catch (Exception ex) {
|
||||
Log.Ui.warn($"Error dropping anchor hiearchy item in pnl settings dialog: {ex}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void on_preview_mouse_up(object _, MouseButtonEventArgs __) =>
|
||||
Disposable.dispose(ref drag_op);
|
||||
}
|
||||
}
|
||||
using bts.shell.pnl;
|
||||
using mbts.spark;
|
||||
using mbts.ui.converters;
|
||||
using mbts.ui.viewmodels;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace mbts.ui.spark {
|
||||
/// <summary>
|
||||
/// Interaction logic for PNLSettingsView.xaml
|
||||
/// </summary>
|
||||
partial class PNLSettingsView : UserControl {
|
||||
public static readonly IValueConverter
|
||||
DisplayNameVisualStateConverter = ValueConverter.create<bool, string>(can_override => can_override ? VisualStateNames.DisplayName.Active : VisualStateNames.DisplayName.Inactive),
|
||||
ColumnVisibilityToggleVisualStateConverter = ValueConverter.create<bool, string>(can_override => can_override ? VisualStateNames.ColumnVisibilityToggle.Active : VisualStateNames.ColumnVisibilityToggle.Inactive);
|
||||
|
||||
public static IMultiValueConverter
|
||||
ColumnContentConverter => ValueConverter.create<PNLColumnSettingsVM, CellTypes, GridColumnSettingsVM>((col, cell) => {
|
||||
if (col != null) {
|
||||
switch (cell) {
|
||||
case CellTypes.Row: return col;
|
||||
case CellTypes.Group: return col.group_column_vm;
|
||||
case CellTypes.Header: return col.header_column_vm;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
public PNLSettingsView() =>
|
||||
InitializeComponent();
|
||||
|
||||
private void _pnl_anchor_items_loaded(object sender, System.Windows.RoutedEventArgs e) {
|
||||
|
||||
}
|
||||
|
||||
public static class VisualStateNames {
|
||||
public static class DisplayName {
|
||||
public const string GroupName = nameof(DisplayName);
|
||||
|
||||
public static readonly string
|
||||
Active = $"{GroupName}{VisualStates.Active}",
|
||||
Inactive = $"{GroupName}{VisualStates.Inactive}";
|
||||
}
|
||||
|
||||
public static class ColumnVisibilityToggle {
|
||||
public const string GroupName = nameof(ColumnVisibilityToggle);
|
||||
|
||||
public static readonly string
|
||||
Active = $"{GroupName}{VisualStates.Active}",
|
||||
Inactive = $"{GroupName}{VisualStates.Inactive}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PNLModalColumnSettingsVM {
|
||||
public PNLColumnSettingsVM column { get; }
|
||||
}
|
||||
|
||||
class PNLParameterContentTemplateSelector : DataTemplateSelector {
|
||||
public DataTemplate ParameterList { get; set; }
|
||||
public DataTemplate TabGroups { get; set; }
|
||||
|
||||
public override DataTemplate SelectTemplate(object item, DependencyObject container) {
|
||||
if (item is ParameterGroupVM g && g.enable_tab_display)
|
||||
return TabGroups;
|
||||
return ParameterList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using bts.api;
|
||||
using bts.api.orderman;
|
||||
using bts.shell;
|
||||
using bts.utils;
|
||||
using ProtoBuf;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace mbts {
|
||||
[ProtoContract]
|
||||
class OrderSentEventPredicate : IEquatable<OrderSentEventPredicate> {
|
||||
public enum PredicateTypeOneofCase {
|
||||
[Description("(any order)")]
|
||||
AnyOrder,
|
||||
[Description("choose securities")]
|
||||
SecurityOrder
|
||||
}
|
||||
|
||||
[ProtoMember(1)]
|
||||
public SecurityPredicate security { get; set; }
|
||||
|
||||
public PredicateTypeOneofCase predicate_type_case {
|
||||
get {
|
||||
if (security != null)
|
||||
return PredicateTypeOneofCase.SecurityOrder;
|
||||
return PredicateTypeOneofCase.AnyOrder;
|
||||
}
|
||||
}
|
||||
|
||||
public IPredicate<OrderSecurity> create(object obj) =>
|
||||
create_predicate((INotificationServiceDataCache)obj);
|
||||
|
||||
public IPredicate<OrderSecurity> create_predicate(INotificationServiceDataCache data_cache) =>
|
||||
OrderEventPredicateHelper.create_status_transition_predicate(OrderStatus.Working, security, data_cache);
|
||||
|
||||
public INotificationPredicate<OrderSecurity> create_toast(INotificationServiceDataCache data_cache) =>
|
||||
new MyToaster(security?.create(), data_cache);
|
||||
|
||||
public bool Equals(OrderSentEventPredicate other) => other != null && other.security.safe_equals(other.security);
|
||||
public override bool Equals(object obj) => Equals(obj as OrderSentEventPredicate);
|
||||
public override int GetHashCode() => security == null ? 0 : security.GetHashCode();
|
||||
|
||||
static bool _is_canceled(OrderRecordImmutable o) =>
|
||||
o.HasState && o.State.Status == OrderStatus.Working;
|
||||
|
||||
class MyToaster : INotificationPredicate<OrderSecurity>, IEquatable<MyToaster> {
|
||||
readonly IPredicate<SecurityImmutable> _security_predicate;
|
||||
readonly INotificationServiceDataCache _data_cache;
|
||||
|
||||
public MyToaster(IPredicate<SecurityImmutable> security_predicate, INotificationServiceDataCache data_cache) {
|
||||
_security_predicate = security_predicate;
|
||||
_data_cache = data_cache;
|
||||
}
|
||||
|
||||
public IToastNotification trigger(OrderSecurity order) =>
|
||||
OrderEventPredicateHelper.check_order_transition_trigger(order, _is_canceled, _security_predicate, _data_cache, out var oldval) ?
|
||||
ToastNotifications.order_status_changed(order.order.Key,
|
||||
OrderEventPredicateHelper.get_nullable_status(oldval), OrderStatus.Working, order.security) :
|
||||
ToastNotifications.empty;
|
||||
|
||||
bool IPredicate<OrderSecurity>.trigger(OrderSecurity order) =>
|
||||
OrderEventPredicateHelper.check_order_transition_predicate(order, _is_canceled, _security_predicate, _data_cache);
|
||||
|
||||
public bool Equals(MyToaster other) =>
|
||||
other != null && EqualityComparer.null_check_equals(_security_predicate, other._security_predicate);
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
Equals(obj as MyToaster);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
EqualityComparer.aggregate_hash((int)OrderStatus.Working, _security_predicate == null ? 0 : _security_predicate.GetHashCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ namespace mbts {
|
||||
OrderFilledEventPredicate _filled_event;
|
||||
OrderCompletedEventPredicate _completed_event;
|
||||
OrderCanceledEventPredicate _canceled_event;
|
||||
OrderSentEventPredicate _sent_event;
|
||||
|
||||
public enum PredicateTypeOneofCase {
|
||||
None,
|
||||
@@ -76,6 +77,8 @@ namespace mbts {
|
||||
CompletedEvent,
|
||||
[PredicateCase("Order Canceled", PredicateCategory.Event)]
|
||||
CanceledEvent,
|
||||
[PredicateCase("Order Sent", PredicateCategory.Event)]
|
||||
SentEvent,
|
||||
[PredicateCase(is_toastable:false)]
|
||||
AttachedTargetOrderKey
|
||||
}
|
||||
@@ -126,6 +129,8 @@ namespace mbts {
|
||||
public OrderCompletedEventPredicate completed_event { get => _completed_event; set => _set(ref _completed_event, value); }
|
||||
[ProtoMember(23)]
|
||||
public OrderCanceledEventPredicate canceled_event { get => _canceled_event; set => _set(ref _canceled_event, value); }
|
||||
[ProtoMember(26)]
|
||||
public OrderSentEventPredicate sent_event { get => _sent_event; set => _set(ref _sent_event, value); }
|
||||
[ProtoMember(24)]
|
||||
public bool is_toast_enabled { get; set; }
|
||||
[ProtoMember(25)]
|
||||
@@ -156,6 +161,7 @@ namespace mbts {
|
||||
if (_filled_event != null) return PTOC.FilledEvent;
|
||||
if (_completed_event != null) return PTOC.CompletedEvent;
|
||||
if (_canceled_event != null) return PTOC.CanceledEvent;
|
||||
if (_sent_event != null) return PTOC.SentEvent;
|
||||
if (_attached_target_order_key != null) return PTOC.AttachedTargetOrderKey;
|
||||
return PTOC.None;
|
||||
}
|
||||
@@ -186,6 +192,7 @@ namespace mbts {
|
||||
case PTOC.FilledEvent: return _filled_event.create_predicate(data_cache);
|
||||
case PTOC.CompletedEvent: return _completed_event.create_predicate(data_cache);
|
||||
case PTOC.CanceledEvent: return _canceled_event.create(data_cache);
|
||||
case PTOC.SentEvent: return _sent_event.create(data_cache);
|
||||
case PTOC.AttachedTargetOrderKey: return wrap(_attached_target_order_key.create(), r => r.order.attached_target_order_key());
|
||||
default: return null;
|
||||
}
|
||||
@@ -235,6 +242,7 @@ namespace mbts {
|
||||
case PTOC.FilledEvent: return _filled_event.Equals(other._filled_event);
|
||||
case PTOC.CompletedEvent: return _completed_event.Equals(other._completed_event);
|
||||
case PTOC.CanceledEvent: return _canceled_event.Equals(other._canceled_event);
|
||||
case PTOC.SentEvent: return _sent_event.Equals(other._sent_event);
|
||||
case PTOC.AttachedTargetOrderKey: return _attached_target_order_key.Equals(other._attached_target_order_key);
|
||||
case PTOC.None: return true;
|
||||
default: throw ExceptionHelper.unexpected_oneof_case(ptoc);
|
||||
@@ -270,6 +278,7 @@ namespace mbts {
|
||||
case PTOC.FilledEvent: raw_hash = _filled_event.GetHashCode(); break;
|
||||
case PTOC.CompletedEvent: raw_hash = _completed_event.GetHashCode(); break;
|
||||
case PTOC.CanceledEvent: raw_hash = _canceled_event.GetHashCode(); break;
|
||||
case PTOC.SentEvent: raw_hash = _sent_event.GetHashCode(); break;
|
||||
case PTOC.AttachedTargetOrderKey: raw_hash = _attached_target_order_key.GetHashCode(); break;
|
||||
case PTOC.None: raw_hash = 0; break;
|
||||
default: throw ExceptionHelper.unexpected_oneof_case(ptoc);
|
||||
@@ -305,6 +314,7 @@ namespace mbts {
|
||||
_filled_event = null;
|
||||
_completed_event = null;
|
||||
_canceled_event = null;
|
||||
_sent_event = null;
|
||||
_attached_target_order_key = null;
|
||||
}
|
||||
field = value;
|
||||
@@ -349,4 +359,4 @@ namespace mbts {
|
||||
public IReadOnlyList<SoundNotification> sound_notifications => _sound_animations ?? (_sound_animations = new List<SoundNotification>());
|
||||
public bool is_enabled => _is_enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,6 @@
|
||||
<ResourceDictionary Source="/view/Controls/DataGridEx/Filters/Views/DoubleMinMaxFilterControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/DataGridEx/Filters/Views/DiscreteValuesFilterControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/DataGridEx/Filters/Views/TimeFilterControl.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/ActionMenu/ActionMenu.xaml"/>
|
||||
<ResourceDictionary Source="/Modules/Spreader/ExecutionStrategyEditor.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Order/AlgoContentTemplateSelector.xaml"/>
|
||||
<ResourceDictionary Source="/view/Controls/Order/AlgoPickerNodeView.xaml"/>
|
||||
|
||||
@@ -115,29 +115,20 @@ namespace mbts.ui.controls {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: simplifiy this class to implement IList<IObservableCollection<T>>, or something other than the tuple
|
||||
// it is proving to be more trouble than its worth; the onus should be on callers to wrap/convert their collections if they do not implement IObservableCollection<T>.
|
||||
//internal class Aggregator<T> : IDisposable, IList<(IReadOnlyCollection<T> items, INotifyCollectionChanged notifier)>, IReadOnlyList<(IReadOnlyCollection<T> items, INotifyCollectionChanged notifier)> {
|
||||
internal class Aggregator<T> : IDisposable, IReadOnlyList<(IReadOnlyCollection<T> items, INotifyCollectionChanged notifier)> {
|
||||
internal class Aggregator<T> : IDisposable, IList<(IReadOnlyCollection<T> items, INotifyCollectionChanged notifier)>, IReadOnlyList<(IReadOnlyCollection<T> items, INotifyCollectionChanged notifier)> {
|
||||
readonly ObservableCollection<T> _target;
|
||||
readonly List<NotifierCollectionWrapper> _collections = new List<NotifierCollectionWrapper>();
|
||||
readonly IList<(IReadOnlyCollection<T> items, INotifyCollectionChanged notifier)> _collection_tuples;
|
||||
readonly List<(IReadOnlyCollection<T> items, INotifyCollectionChanged notifier)> _collections = new List<(IReadOnlyCollection<T> items, INotifyCollectionChanged notifier)>();
|
||||
bool _is_disposed;
|
||||
|
||||
public Aggregator(ObservableCollection<T> target, params (IReadOnlyCollection<T> items, INotifyCollectionChanged notifier)[] collections) {
|
||||
_collection_tuples = _collections.WrapSelector(nc => nc.tuple, null);
|
||||
_target = target;
|
||||
foreach (var c in collections)
|
||||
Add(c);
|
||||
}
|
||||
|
||||
public (IReadOnlyCollection<T> items, INotifyCollectionChanged notifier) this[int index] {
|
||||
get => _collections[index].tuple;
|
||||
set {
|
||||
// TODO: optimize with 'Replace' ops instead of Remove/Add
|
||||
RemoveAt(index);
|
||||
Insert(index, value);
|
||||
}
|
||||
get => _collections[index];
|
||||
set => Insert(index, value);
|
||||
}
|
||||
|
||||
public int Count => _collections.Count;
|
||||
@@ -147,24 +138,16 @@ namespace mbts.ui.controls {
|
||||
public void Add((IReadOnlyCollection<T> items, INotifyCollectionChanged notifier) collection) {
|
||||
_check_disposed();
|
||||
_target.AddRange(collection.items);
|
||||
var wrapper = new NotifierCollectionWrapper(collection);
|
||||
_collections.Add(wrapper);
|
||||
wrapper.CollectionChanged += _on_collection_changed;
|
||||
_collections.Add(collection);
|
||||
collection.notifier.CollectionChanged += _on_collection_changed;
|
||||
}
|
||||
|
||||
public bool Remove((IReadOnlyCollection<T> items, INotifyCollectionChanged notifier) collection) {
|
||||
int num_before = _collections.Count;
|
||||
_check_disposed();
|
||||
_remove_collection_items(collection, out int _, out int collection_index, true);
|
||||
_collections.RemoveAt(collection_index);
|
||||
return _collections.Count < num_before;
|
||||
}
|
||||
|
||||
bool _remove(NotifierCollectionWrapper wrapper) {
|
||||
int num_before = _collections.Count;
|
||||
_check_disposed();
|
||||
_remove_collection_items(wrapper, out int _, out int collection_index, true);
|
||||
_remove_collection_items(collection, out int _, out int collection_index);
|
||||
_collections.RemoveAt(collection_index);
|
||||
collection.notifier.CollectionChanged -= _on_collection_changed;
|
||||
return _collections.Count < num_before;
|
||||
}
|
||||
|
||||
@@ -174,47 +157,43 @@ namespace mbts.ui.controls {
|
||||
if (index == _collections.Count)
|
||||
Add(collection);
|
||||
else {
|
||||
var wrapper = new NotifierCollectionWrapper(collection);
|
||||
_collections.Insert(index, wrapper);
|
||||
_on_collection_changed(wrapper, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, wrapper, 0));
|
||||
wrapper.CollectionChanged += _on_collection_changed;
|
||||
_collections.Insert(index, collection);
|
||||
_on_collection_changed(collection, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, collection, 0));
|
||||
collection.notifier.CollectionChanged += _on_collection_changed;
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveAt(int index) {
|
||||
_check_disposed();
|
||||
_remove(_collections[index]);
|
||||
Remove(_collections[index]);
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
_check_disposed();
|
||||
foreach (var c in _collections)
|
||||
c.CollectionChanged -= _on_collection_changed;
|
||||
c.notifier.CollectionChanged -= _on_collection_changed;
|
||||
_collections.Clear();
|
||||
_target.Clear();
|
||||
}
|
||||
|
||||
public bool Contains((IReadOnlyCollection<T> items, INotifyCollectionChanged notifier) item) =>
|
||||
_collection_tuples.Contains(item);
|
||||
_collections.Contains(item);
|
||||
|
||||
public void CopyTo((IReadOnlyCollection<T> items, INotifyCollectionChanged notifier)[] array, int arrayIndex) =>
|
||||
_collection_tuples.CopyTo(array, arrayIndex);
|
||||
_collections.CopyTo(array, arrayIndex);
|
||||
|
||||
public int IndexOf((IReadOnlyCollection<T> items, INotifyCollectionChanged notifier) item) =>
|
||||
_collection_tuples.IndexOf(item);
|
||||
_collections.IndexOf(item);
|
||||
|
||||
public void Dispose() {
|
||||
if (!_is_disposed) {
|
||||
foreach (var c in _collections)
|
||||
c.CollectionChanged -= _on_collection_changed;
|
||||
c.notifier.CollectionChanged -= _on_collection_changed;
|
||||
_is_disposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator<(IReadOnlyCollection<T> items, INotifyCollectionChanged notifier)> GetEnumerator() {
|
||||
for (int i = 0; i < _collections.Count; i++)
|
||||
yield return _collections[i].tuple;
|
||||
}
|
||||
public IEnumerator<(IReadOnlyCollection<T> items, INotifyCollectionChanged notifier)> GetEnumerator() => _collections.GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => _collections.GetEnumerator();
|
||||
|
||||
void _on_collection_changed(object sender, NotifyCollectionChangedEventArgs e) {
|
||||
@@ -229,96 +208,40 @@ namespace mbts.ui.controls {
|
||||
_target.InsertRange(e.NewStartingIndex + offset, e.NewItems);
|
||||
break;
|
||||
case NotifyCollectionChangedAction.Reset:
|
||||
var wrapper = sender as NotifierCollectionWrapper;
|
||||
_remove_collection_items(wrapper, out int starting_index, out int _);
|
||||
_add_items(wrapper.collection, starting_index);
|
||||
foreach (T item in wrapper)
|
||||
_target.Insert(starting_index++, item);
|
||||
var c = (ObservableCollection<T>)sender;
|
||||
_remove_collection_items((c, c), out int starting_index, out int _);
|
||||
_add_items(c, starting_index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void _add_items(IEnumerable items, int index) {
|
||||
void _add_items(IList items, int index) {
|
||||
foreach (T item in items)
|
||||
_target.Insert(index++, item);
|
||||
}
|
||||
|
||||
void _remove_collection_items(NotifierCollectionWrapper wrapper, out int starting_index, out int collection_index, bool disconnect = false) =>
|
||||
_remove_collection_items(wrapper.tuple, out starting_index, out collection_index, disconnect);
|
||||
|
||||
void _remove_collection_items((IReadOnlyCollection<T> items, INotifyCollectionChanged notifier) collection, out int starting_index, out int collection_index, bool disconnect = false) {
|
||||
void _remove_collection_items((IReadOnlyCollection<T> items, INotifyCollectionChanged notifier) collection, out int starting_index, out int collection_index) {
|
||||
int ex_count = 0;
|
||||
int i = 0;
|
||||
for (; i < _collections.Count; i++) {
|
||||
if (_collections[i].collection == collection.items) {
|
||||
if (disconnect)
|
||||
_collections[i].CollectionChanged -= _on_collection_changed;
|
||||
if (_collections[i].items == collection.items)
|
||||
break;
|
||||
} else ex_count += _collections[i].Count;
|
||||
else ex_count += _collections[i].items.Count;
|
||||
}
|
||||
starting_index = ex_count;
|
||||
collection_index = i;
|
||||
for (++i; i < _collections.Count; i++)
|
||||
ex_count += _collections[i].Count;
|
||||
ex_count += _collections[i].items.Count;
|
||||
_target.RemoveRange(starting_index, _target.Count - ex_count);
|
||||
}
|
||||
|
||||
int _get_collection_start(object sender) =>
|
||||
_collections.TakeWhile(c => c != sender).Sum(c => c.Count);
|
||||
_collections.TakeWhile(c => c.items != sender).Sum(c => c.items.Count);
|
||||
|
||||
void _check_disposed() {
|
||||
if (_is_disposed)
|
||||
throw new ObjectDisposedException("ObservableCollectionAggregator");
|
||||
}
|
||||
|
||||
class NotifierCollectionWrapper : IReadOnlyCollection<T>, IList, INotifyCollectionChanged {
|
||||
public NotifierCollectionWrapper((IReadOnlyCollection<T> collection, INotifyCollectionChanged notifier) tuple)
|
||||
: this(tuple.collection, tuple.notifier) { }
|
||||
|
||||
public NotifierCollectionWrapper(IReadOnlyCollection<T> collection, INotifyCollectionChanged notifier) {
|
||||
this.collection = collection;
|
||||
this.notifier = notifier;
|
||||
notifier.CollectionChanged += _on_collection_changed;
|
||||
}
|
||||
|
||||
public object this[int index] {
|
||||
get => throw new NotImplementedException();
|
||||
set => throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public IReadOnlyCollection<T> collection { get; }
|
||||
public INotifyCollectionChanged notifier { get; }
|
||||
|
||||
public (IReadOnlyCollection<T> collection, INotifyCollectionChanged notifier) tuple => (collection, notifier);
|
||||
|
||||
public int Count => collection.Count;
|
||||
|
||||
public bool IsReadOnly => true;
|
||||
public bool IsFixedSize => false;
|
||||
|
||||
public object SyncRoot => null;
|
||||
|
||||
public bool IsSynchronized => false;
|
||||
|
||||
public event NotifyCollectionChangedEventHandler CollectionChanged;
|
||||
|
||||
public int Add(object value) => throw new NotSupportedException();
|
||||
public void Clear() => throw new NotSupportedException();
|
||||
public bool Contains(object value) => collection.Contains((T)value);
|
||||
public void CopyTo(Array array, int index) {
|
||||
foreach (var v in collection)
|
||||
array.SetValue(v, index++);
|
||||
}
|
||||
public IEnumerator<T> GetEnumerator() => collection.GetEnumerator();
|
||||
public int IndexOf(object value) => collection.indexOf((T)value);
|
||||
public void Insert(int index, object value) => throw new NotSupportedException();
|
||||
public void Remove(object value) => throw new NotSupportedException();
|
||||
public void RemoveAt(int index) => throw new NotSupportedException();
|
||||
IEnumerator IEnumerable.GetEnumerator() => collection.GetEnumerator();
|
||||
|
||||
void _on_collection_changed(object sender, NotifyCollectionChangedEventArgs e) =>
|
||||
CollectionChanged?.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,18 @@ namespace mbts.ui.shell {
|
||||
vm.raise_notify_property_changed(target_property_name);
|
||||
}
|
||||
|
||||
//public static IDisposable copy<T>(this IProperty<T> target, IProperty<T> source, string property_name) =>
|
||||
// target.copy(source, property_name, property_name);
|
||||
|
||||
public static IDisposable copy<T>(this IProperty<T> target, IProperty<T> source) {
|
||||
//var target_prop = target.GetType().GetProperty(target_property_name);
|
||||
source.Changed += on_changed;
|
||||
return Disposable.Create(() => source.Changed -= on_changed);
|
||||
void on_changed(T oldval, T newval) {
|
||||
target.Value = newval;
|
||||
}
|
||||
}
|
||||
|
||||
public static void assert(this IValidationViewModel vm, bool condition, string property, string message) {
|
||||
if (condition) vm.clear_error(property);
|
||||
else vm.set_error(property, message);
|
||||
@@ -79,15 +91,6 @@ namespace mbts.ui.shell {
|
||||
// ensure notifications will be in on the same thread as IProperty<T>.Subscribe (don't use .Select extension)
|
||||
Observable.Create<T>(o => property.Subscribe(ch => o.OnNext(ch.newval)));
|
||||
|
||||
public static IObservable<T> SubscribeValue<T>(this IProperty<T> property, bool start_immediately) =>
|
||||
start_immediately ?
|
||||
// ensure notifications will be in on the same thread as IProperty<T>.Subscribe (don't use .Select extension)
|
||||
Observable.Create<T>(o => {
|
||||
o.OnNext(property.Value);
|
||||
return property.Subscribe(ch => o.OnNext(ch.newval));
|
||||
}) :
|
||||
SubscribeValue(property);
|
||||
|
||||
//public static IDisposable S
|
||||
|
||||
public static IProperty<T> block_reentrancy<T>(this IProperty<T> source) =>
|
||||
|
||||
@@ -5,17 +5,13 @@
|
||||
xmlns:ui="clr-namespace:mbts.ui"
|
||||
>
|
||||
<!--Control Base Colors-->
|
||||
<Color x:Key="Control.SuperLightGrayColor">#F6F6F6</Color>
|
||||
<Color x:Key="Control.LightGrayColor">#E5E5E5</Color>
|
||||
<Color x:Key="Control.LightMediumGrayColor">#CFCFCF</Color>
|
||||
<Color x:Key="Control.MediumGrayColor">#B3B3B3</Color>
|
||||
<Color x:Key="Control.MediumDarkGrayColor">#ACACAC</Color>
|
||||
<Color x:Key="Control.AlphaLightGrayColor">#10000000</Color>
|
||||
<Color x:Key="Control.AlphaLightMediumGrayColor">#24000000</Color>
|
||||
<Color x:Key="Control.AlphaMediumGrayColor">#3A000000</Color>
|
||||
<Color x:Key="Control.AlphaMediumGrayColor2">#FF0000</Color>
|
||||
<Color x:Key="Control.DarkMediumGrayColor">#FF959595</Color>
|
||||
<Color x:Key="Control.DarkGrayColor">#707070</Color>
|
||||
<Color x:Key="Text.Prompt.Foreground.Color">#FF999999</Color>
|
||||
|
||||
<SolidColorBrush x:Key="Control.AlphaLightGrayBrush" Color="{StaticResource Control.AlphaLightGrayColor}"/>
|
||||
@@ -144,4 +140,4 @@
|
||||
<SolidColorBrush x:Key="ListBoxItem.Selected.Inactive.Border" Color="{StaticResource ListBoxItem.Selected.Inactive.Border.Color}"/>
|
||||
<SolidColorBrush x:Key="ListBoxItem.MouseOver.Background" Color="{StaticResource ListBoxItem.MouseOver.Background.Color}"/>
|
||||
<SolidColorBrush x:Key="ListBoxItem.MouseOver.Border" Color="{StaticResource ListBoxItem.MouseOver.Border.Color}"/>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary>
|
||||
@@ -1,102 +1,78 @@
|
||||
<ResourceDictionary
|
||||
<c:PopupControl
|
||||
x:Class="mbts.ui.controls.ActionMenu"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
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"
|
||||
Margin="1"
|
||||
Background="Transparent"
|
||||
BorderBrush="Transparent"
|
||||
Padding="2"
|
||||
PopupPlacement="Bottom"
|
||||
ShowExpanderArrow="False"
|
||||
Cursor="Hand"
|
||||
>
|
||||
<SolidColorBrush x:Key="SeparatorFill" Color="{DynamicResource Control.AlphaMediumGrayColor}"/>
|
||||
|
||||
<ControlTemplate x:Key="ActionMenuTemplate" TargetType="c:ActionMenu">
|
||||
<Border
|
||||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalAlignment}"
|
||||
Width="{TemplateBinding Width}"
|
||||
Height="{TemplateBinding Height}"
|
||||
>
|
||||
<u:StateManager.Groups>
|
||||
<u:StateGroupsManager AttachToMembers="True">
|
||||
<u:StateDefinitionCollection>
|
||||
<u:MouseStateDefinition MouseSource="{Binding Group.Target, RelativeSource={RelativeSource Self}}"/>
|
||||
</u:StateDefinitionCollection>
|
||||
</u:StateGroupsManager>
|
||||
</u:StateManager.Groups>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup Name="MouseStates">
|
||||
<VisualState Name="Normal"/>
|
||||
<VisualState Name="MouseOver" Storyboard="{DynamicResource Button.MouseOver.Storyboard}"/>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<c:PopupControl.Resources>
|
||||
<CollectionViewSource x:Key="ItemsSourceView" Source="{Binding ItemsSource, RelativeSource={RelativeSource AncestorType=c:ActionMenu}}">
|
||||
<CollectionViewSource.GroupDescriptions>
|
||||
<PropertyGroupDescription PropertyName="group"/>
|
||||
</CollectionViewSource.GroupDescriptions>
|
||||
</CollectionViewSource>
|
||||
</c:PopupControl.Resources>
|
||||
<c:PopupControl.Header>
|
||||
<Border Width="16">
|
||||
<Grid>
|
||||
<Button
|
||||
x:Name="button"
|
||||
Content="{TemplateBinding Header}"
|
||||
ContentTemplate="{TemplateBinding HeaderTemplate}"
|
||||
ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Padding="2.5,2"
|
||||
Style="{DynamicResource SparkToolBarButton}"
|
||||
>
|
||||
<Button.Background>
|
||||
<SolidColorBrush/>
|
||||
</Button.Background>
|
||||
</Button>
|
||||
<Popup c:PopupViewController.ButtonSource="{Binding ElementName=button}" Placement="Bottom" PlacementTarget="{Binding ElementName=button}" StaysOpen="False">
|
||||
<Border Background="{DynamicResource Control.LightGrayBrush}" BorderThickness="1">
|
||||
<Border.BorderBrush>
|
||||
<SolidColorBrush Color="{DynamicResource Control.DarkMediumGrayColor}"/>
|
||||
</Border.BorderBrush>
|
||||
<ItemsPresenter/>
|
||||
</Border>
|
||||
</Popup>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Rectangle Grid.Row="0" Fill="Black" Height="2" HorizontalAlignment="Stretch"/>
|
||||
<Rectangle Grid.Row="1" Fill="Black" Height="2" Margin="0,4,0,0" HorizontalAlignment="Stretch"/>
|
||||
<Rectangle Grid.Row="2" Fill="Black" Height="2" Margin="0,4,0,0" HorizontalAlignment="Stretch"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
|
||||
<DataTemplate x:Key="HamburgerButtonTemplate">
|
||||
<Image
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Source="{x:Static u:Icons.HamburgerMenu}"
|
||||
/>
|
||||
</DataTemplate>
|
||||
|
||||
<Style x:Key="ActionMenuBase" TargetType="c:ActionMenu">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="BorderBrush">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Template" Value="{StaticResource ActionMenuTemplate}"/>
|
||||
</Style>
|
||||
|
||||
<DataTemplate DataType="{x:Type u:MenuItemVM}">
|
||||
<TextBlock Text="{Binding}" VerticalAlignment="Center"/>
|
||||
</DataTemplate>
|
||||
|
||||
<Style TargetType="c:ActionMenu" BasedOn="{StaticResource ActionMenuBase}">
|
||||
<Setter Property="Panel.ZIndex" Value="1"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Right"/>
|
||||
<Setter Property="VerticalAlignment" Value="Top"/>
|
||||
<Setter Property="Margin" Value="1"/>
|
||||
<Setter Property="HeaderTemplate" Value="{StaticResource HamburgerButtonTemplate}"/>
|
||||
<Setter Property="Width" Value="22"/>
|
||||
<Setter Property="ItemContainerStyle">
|
||||
<Setter.Value>
|
||||
<Style TargetType="MenuItem">
|
||||
<Setter Property="MinWidth" Value="167"/>
|
||||
<Setter Property="CommandParameter" Value="{Binding parameter}"/>
|
||||
<Setter Property="Command" Value="{Binding command}"/>
|
||||
<Setter Property="Header" Value="{Binding name}"/>
|
||||
<Setter Property="Icon" Value="{Binding icon, Converter={x:Static cv:ImageSourceIconConverter.Instance}}"/>
|
||||
</Style>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</c:PopupControl.Header>
|
||||
<Menu ItemsSource="{Binding Source={StaticResource ItemsSourceView}}">
|
||||
<Menu.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Vertical"/>
|
||||
</ItemsPanelTemplate>
|
||||
</Menu.ItemsPanel>
|
||||
<Menu.GroupStyle>
|
||||
<GroupStyle>
|
||||
<GroupStyle.ContainerStyle>
|
||||
<Style TargetType="GroupItem">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="GroupItem">
|
||||
<StackPanel>
|
||||
<ItemsPresenter/>
|
||||
<Rectangle HorizontalAlignment="Stretch" Height="1" Margin="22,0,0,0" Fill="LightGray"/>
|
||||
</StackPanel>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</GroupStyle.ContainerStyle>
|
||||
</GroupStyle>
|
||||
</Menu.GroupStyle>
|
||||
<Menu.ItemContainerStyle>
|
||||
<Style TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}">
|
||||
<!--NOTE: CommandParameter binding must be declared BEFORE Command,
|
||||
otherwise, CanExecuted is called before the parameter value is realized...I know, it sucks...-->
|
||||
<Setter Property="CommandParameter" Value="{Binding parameter}"/>
|
||||
<Setter Property="Command" Value="{Binding command}"/>
|
||||
<Setter Property="Header" Value="{Binding name}"/>
|
||||
<Setter Property="HeaderTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding}" VerticalAlignment="Center"/>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Icon" Value="{Binding icon, Converter={StaticResource IconConverter}}"/>
|
||||
<Setter Property="MinWidth" Value="167"/>
|
||||
</Style>
|
||||
</Menu.ItemContainerStyle>
|
||||
</Menu>
|
||||
</c:PopupControl>
|
||||
@@ -1,15 +1,22 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace mbts.ui.controls {
|
||||
/// <summary>
|
||||
/// Interaction logic for ActionMenu.xaml
|
||||
/// </summary>
|
||||
class ActionMenu : HeaderedItemsControl {
|
||||
static ActionMenu() =>
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(ActionMenu), new FrameworkPropertyMetadata(typeof(ActionMenu)));
|
||||
partial class ActionMenu : PopupControl {
|
||||
public ActionMenu() =>
|
||||
InitializeComponent();
|
||||
|
||||
protected override DependencyObject GetContainerForItemOverride() =>
|
||||
new MenuItem();
|
||||
public static readonly DependencyProperty ItemsSourceProperty =
|
||||
WPFHelper.create_dp<IEnumerable, ActionMenu>(
|
||||
nameof(ItemsSource), Enumerable.Empty<IMenuItemVM>());
|
||||
|
||||
public IEnumerable ItemsSource {
|
||||
get => GetValue(ItemsSourceProperty) as IEnumerable;
|
||||
set => SetValue(ItemsSourceProperty, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ namespace mbts.ui.controls.adorners {
|
||||
move_to(e.GetPosition(target));
|
||||
|
||||
void move_to(Point pt) =>
|
||||
mta.Margin = new Thickness(pt.X, pt.Y, 0, 0);
|
||||
mta.RenderTransform = new TranslateTransform(pt.X, pt.Y);
|
||||
}
|
||||
|
||||
public static IDisposable trace_drag(FrameworkElement target, Visual trace_visual, Size trace_visual_size) {
|
||||
@@ -55,7 +55,7 @@ namespace mbts.ui.controls.adorners {
|
||||
move_to(e.GetPosition(target));
|
||||
|
||||
void move_to(Point pt) =>
|
||||
mta.Margin = new Thickness(pt.X, pt.Y, 0, 0);
|
||||
mta.RenderTransform = new TranslateTransform(pt.X, pt.Y);
|
||||
}
|
||||
|
||||
protected override Visual GetVisualChild(int index) =>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<Setter Property="Padding" Value="3,0,0,0"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="c:ExpanderToggleButton">
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<Border Background="{TemplateBinding Background}">
|
||||
<Grid Background="Transparent">
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -31,15 +31,7 @@
|
||||
Stroke="{StaticResource Path.Static.Brush}"
|
||||
StrokeThickness="2"
|
||||
VerticalAlignment="Center"
|
||||
>
|
||||
<Path.Visibility>
|
||||
<Binding Path="ShowExpanderArrow" RelativeSource="{RelativeSource TemplatedParent}">
|
||||
<Binding.Converter>
|
||||
<cv:BooleanToVisibilityConverter VisibilityForFalse="Hidden" VisibilityForTrue="Visible"/>
|
||||
</Binding.Converter>
|
||||
</Binding>
|
||||
</Path.Visibility>
|
||||
</Path>
|
||||
/>
|
||||
<ContentPresenter
|
||||
Grid.Column="1"
|
||||
ContentSource="{TemplateBinding Content}"
|
||||
|
||||
@@ -16,13 +16,5 @@ namespace mbts.ui.controls {
|
||||
|
||||
static ExpanderToggleButton() =>
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(ExpanderToggleButton), new FrameworkPropertyMetadata(typeof(ExpanderToggleButton)));
|
||||
|
||||
public static readonly DependencyProperty ShowExpanderArrowProperty =
|
||||
WPFHelper.create_dp<bool, ExpanderToggleButton>(nameof(ShowExpanderArrow), true);
|
||||
|
||||
public bool ShowExpanderArrow {
|
||||
get => (bool)GetValue(ShowExpanderArrowProperty);
|
||||
set => SetValue(ShowExpanderArrowProperty, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,14 @@ namespace mbts.ui.controls.color_picker {
|
||||
Model = new ColorModel(this);
|
||||
InitializeComponent();
|
||||
Model.on_palettes(Palettes);
|
||||
Resources["SelectedOpacity"] = Model.opacity;
|
||||
Model.PropertyChanged += (s, e) => {
|
||||
if (e.PropertyName == nameof(Model.opacity))
|
||||
Resources["SelectedOpacity"] = Model.opacity;
|
||||
};
|
||||
//Loaded += on_loaded;
|
||||
//void on_loaded(object sender, RoutedEventArgs e) =>
|
||||
// Model.initialize();
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty SelectedColorProperty =
|
||||
@@ -53,6 +61,7 @@ namespace mbts.ui.controls.color_picker {
|
||||
/// For this reason, TCP must be immune to alpha channel adjustments, made in other controls (<see cref="ColorPickerSuite"/>, and <see cref="ColorPickerControl"/>, both have alpha/opacity sliders).
|
||||
/// To achieve this affect, when
|
||||
|
||||
|
||||
/// To achieve this affect, the latter's Alpha should always be 255 (100% opacity).
|
||||
/// In the <see cref="selected_named_color"/> setter, only the RGB values are forwarded to the 'selected_color' property.
|
||||
/// This 'alpha buffer' works both ways:
|
||||
@@ -116,6 +125,15 @@ namespace mbts.ui.controls.color_picker {
|
||||
|
||||
public ObservableCollection<ColorPaletteVM> palettes { get; } = new ObservableCollection<ColorPaletteVM>();
|
||||
|
||||
bool _is_initialized;
|
||||
public void initialize() {
|
||||
if (_is_initialized)
|
||||
return;
|
||||
_is_initialized = true;
|
||||
_owner.GetBindingExpression(SelectedColorProperty)?.UpdateTarget();
|
||||
_owner._color_picker.SelectedColorChanged += c => selected_color = c;
|
||||
}
|
||||
|
||||
public void on_palettes(ObservableCollection<ColorPaletteVM> new_palettes) {
|
||||
Disposable.dispose(ref _palettes_hook);
|
||||
if (new_palettes != null)
|
||||
|
||||
@@ -34,10 +34,10 @@
|
||||
Height="18"
|
||||
>
|
||||
<Border.BorderBrush>
|
||||
<SolidColorBrush Color="{Binding color}"/>
|
||||
<SolidColorBrush Color="{Binding color}" Opacity="{Binding SelectedOpacity, RelativeSource={RelativeSource AncestorType=c:TabularColorPicker}, Converter={x:Static c:TabularColorPicker.AlphaToOpacityConverter}}"/>
|
||||
</Border.BorderBrush>
|
||||
<Border.Background>
|
||||
<SolidColorBrush Color="{Binding color}"/>
|
||||
<SolidColorBrush Color="{Binding color}" Opacity="{Binding SelectedOpacity, RelativeSource={RelativeSource AncestorType=c:TabularColorPicker}, Converter={x:Static c:TabularColorPicker.AlphaToOpacityConverter}}"/>
|
||||
</Border.Background>
|
||||
</Border>
|
||||
<DataTemplate.Triggers>
|
||||
|
||||
@@ -1,7 +1,25 @@
|
||||
using mbts.ui.converters;
|
||||
using bts.collections;
|
||||
using bts.proto;
|
||||
using bts.utils;
|
||||
using mbts.spark;
|
||||
using mbts.ui.controls.color_picker;
|
||||
using mbts.ui.converters;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.utility;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace mbts.ui.controls {
|
||||
/// <summary>
|
||||
@@ -9,11 +27,24 @@ namespace mbts.ui.controls {
|
||||
/// </summary>
|
||||
class TabularColorPicker : ListBox {
|
||||
public static readonly IValueConverter AlphaToOpacityConverter =
|
||||
ValueConverter.create<byte, double>(alpha => alpha / 255.0);
|
||||
ValueConverter.create<byte, double>(alpha => (double)alpha / 255.0);
|
||||
|
||||
static TabularColorPicker() =>
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(TabularColorPicker), new FrameworkPropertyMetadata(typeof(TabularColorPicker)));
|
||||
|
||||
//public static readonly DependencyProperty SelectedColorProperty =
|
||||
// WPFHelper.create_dp<Color, TabularColorPicker>(
|
||||
// nameof(SelectedColor),
|
||||
// FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
||||
// Colors.Black);
|
||||
|
||||
//public Color SelectedColor {
|
||||
// get => (Color)GetValue(SelectedColorProperty);
|
||||
// set => SetValue(SelectedColorProperty, value);
|
||||
//}
|
||||
//protected override DependencyObject GetContainerForItemOverride() =>
|
||||
// new TabularColorPickerItem();
|
||||
|
||||
public static readonly DependencyProperty SelectedOpacityProperty =
|
||||
WPFHelper.create_dp<byte, TabularColorPicker>(nameof(SelectedOpacity), 255);
|
||||
|
||||
@@ -21,5 +52,29 @@ namespace mbts.ui.controls {
|
||||
get => (byte)GetValue(SelectedOpacityProperty);
|
||||
set => SetValue(SelectedOpacityProperty, value);
|
||||
}
|
||||
|
||||
//protected override DependencyObject GetContainerForItemOverride() =>
|
||||
// new ListBoxItem();
|
||||
}
|
||||
|
||||
class TabularColorPickerItem : ListBoxItem {
|
||||
static TabularColorPickerItem() =>
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(TabularColorPickerItem), new FrameworkPropertyMetadata(typeof(TabularColorPickerItem)));
|
||||
|
||||
public static readonly DependencyProperty ColorProperty =
|
||||
WPFHelper.create_dp<Color, TabularColorPickerItem>(nameof(Color));
|
||||
|
||||
public Color Color {
|
||||
get => (Color)GetValue(ColorProperty);
|
||||
set => SetValue(ColorProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ColorNameProperty =
|
||||
WPFHelper.create_dp<string, TabularColorPickerItem>(nameof(ColorName));
|
||||
|
||||
public string ColorName {
|
||||
get => GetValue(ColorNameProperty) as string;
|
||||
set => SetValue(ColorNameProperty, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,9 +98,10 @@ namespace mbts.ui.settings {
|
||||
|
||||
public GridColumnSettings with(
|
||||
string display_name = null, bool? is_visible = null, bool? is_collapsed = null, NullableFontWeightProto? font_weight_override = null, NullableColorProto? font_color_override = null,
|
||||
double? width = null, HorizontalAlignment? horizontal_alignment = null, double? horizontal_offset = null, NullableColorProto? background_color_override = null) =>
|
||||
double? width = null, HorizontalAlignment? horizontal_alignment = null, double? horizontal_offset = null, NullableColorProto? background_color_override = null,
|
||||
string id = null) =>
|
||||
//
|
||||
new GridColumnSettings(_id,
|
||||
new GridColumnSettings(id ?? _id,
|
||||
display_name ?? this.display_name,
|
||||
is_visible ?? this.is_visible,
|
||||
is_collapsed ?? this.is_collapsed,
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using bts.collections;
|
||||
using bts.proto;
|
||||
using bts.proto;
|
||||
using bts.utils;
|
||||
using mbts.ui;
|
||||
using mbts.ui.settings;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.viewmodels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
|
||||
namespace mbts.spark {
|
||||
@@ -25,14 +27,14 @@ namespace mbts.spark {
|
||||
ImmutableVisibility = 1 << 4
|
||||
}
|
||||
|
||||
class GridColumnSettingsVM : ParameterGroupVM {
|
||||
class GridColumnSettingsVM : DisposableViewModelBase {
|
||||
string _id = string.Empty;
|
||||
GridColumnSettings _settings;
|
||||
|
||||
public GridColumnSettingsVM()
|
||||
: this(GridColumnSettingsFeatureFlags.None) { }
|
||||
|
||||
protected GridColumnSettingsVM(GridColumnSettingsFeatureFlags? init_flags) : base("") {
|
||||
protected GridColumnSettingsVM(GridColumnSettingsFeatureFlags? init_flags) {
|
||||
if (font_color.override_value.A == 0)
|
||||
font_color.set_override(font_color.override_value.with(255));
|
||||
if (init_flags.HasValue)
|
||||
@@ -47,6 +49,31 @@ namespace mbts.spark {
|
||||
public ColorOverrideParameterVM font_color { get; } = new ColorOverrideParameterVM("Font Color");
|
||||
public FontWeightOverrideParameterVM font_weight { get; } = new FontWeightOverrideParameterVM();
|
||||
public HorizontalAlignmentParameterVM horizontal_alignment { get; } = new HorizontalAlignmentParameterVM("Horizontal Alignment");
|
||||
// display name
|
||||
public ObservableCollection<object> parameters { get; } = new ObservableCollection<object>();
|
||||
/// Note: parameter visibility is not automatically re-evaluated (<see cref="sync_params"/>).
|
||||
public bool show_width { get; set; } = true;
|
||||
public bool show_horizontal_alignment { get; set; } = true;
|
||||
public bool can_edit_header { get; set; } = true;
|
||||
public bool can_edit_width { get; set; } = true;
|
||||
public bool can_edit_horizontal_alignment { get; set; } = true;
|
||||
|
||||
protected virtual IEnumerable<object> _visible_parameters {
|
||||
get {
|
||||
if (header.can_override)
|
||||
yield return header;
|
||||
if (show_width)
|
||||
yield return width;
|
||||
if (show_horizontal_alignment)
|
||||
yield return horizontal_alignment;
|
||||
if (background.can_override)
|
||||
yield return background;
|
||||
if (font_color.can_override)
|
||||
yield return font_color;
|
||||
if (font_weight.can_override)
|
||||
yield return font_weight;
|
||||
}
|
||||
}
|
||||
|
||||
public GridColumnSettings create() {
|
||||
return _settings.with(
|
||||
@@ -91,24 +118,11 @@ namespace mbts.spark {
|
||||
font_weight.can_override = (flags & GridColumnSettingsFeatureFlags.ImmutableFontWeight) == 0;
|
||||
font_color.can_override = (flags & GridColumnSettingsFeatureFlags.ImmutableFontColor) == 0;
|
||||
background.can_override = (flags & GridColumnSettingsFeatureFlags.ImmutableBackgroundColor) == 0;
|
||||
sync_params();
|
||||
parameters.sync_with(_visible_parameters);
|
||||
}
|
||||
|
||||
public virtual void sync_params() {
|
||||
var layout = new HeaderedParameterGroupVM("Column Layout");
|
||||
var fonts_and_colors = new HeaderedParameterGroupVM("Fonts/Colors");
|
||||
if (header.can_override)
|
||||
layout.parameters.Add(header);
|
||||
layout.parameters.Add(width);
|
||||
layout.parameters.Add(horizontal_alignment);
|
||||
if (font_weight.can_override)
|
||||
fonts_and_colors.parameters.Add(font_weight);
|
||||
if (font_color.can_override)
|
||||
fonts_and_colors.parameters.Add(font_color);
|
||||
if (background.can_override)
|
||||
fonts_and_colors.parameters.Add(background);
|
||||
parameters.SetItems(layout, fonts_and_colors);
|
||||
}
|
||||
public void sync_params() =>
|
||||
parameters.sync_with(_visible_parameters);
|
||||
|
||||
public override string ToString() =>
|
||||
header.ToString();
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<sys:Double x:Key="ParamOverrideToggleGap">8</sys:Double>
|
||||
<sys:Double x:Key="ParamHeaderContentGap">36</sys:Double>
|
||||
<sys:Double x:Key="ParamContentPaddingRight">24</sys:Double>
|
||||
<sys:Double x:Key="ExpanderOffset">26</sys:Double>
|
||||
<sys:Double x:Key="ExpanderOffset">22</sys:Double>
|
||||
<Thickness x:Key="CellPadding">10,8</Thickness>
|
||||
<Thickness x:Key="ExpanderOffsetMargin" Left="{StaticResource ExpanderOffset}"/>
|
||||
<!--Converters-->
|
||||
@@ -80,6 +80,7 @@
|
||||
</u:StateGroupsManager>
|
||||
|
||||
<!--Styles-->
|
||||
<!--<Style x:Key="ParamHeaderC"-->
|
||||
<Style x:Key="ColorSampleRect" TargetType="Rectangle">
|
||||
<Setter Property="Width" Value="90"/>
|
||||
<Setter Property="Height" Value="20"/>
|
||||
@@ -126,6 +127,7 @@
|
||||
<Setter Property="IsEnabled" Value="{Binding can_override}"/>
|
||||
</Style>
|
||||
|
||||
|
||||
<Style x:Key="HelpControl" TargetType="Control">
|
||||
<Setter Property="Grid.Column" Value="2"/>
|
||||
<Setter Property="Width" Value="14" />
|
||||
@@ -192,7 +194,6 @@
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<DataTemplate x:Key="ExpanderToggleMouseStatesTemplate">
|
||||
<u:StateGroupsManager AttachToMembers="True">
|
||||
<u:StateDefinitionCollection>
|
||||
@@ -201,6 +202,14 @@
|
||||
</u:StateGroupsManager>
|
||||
</DataTemplate>
|
||||
|
||||
<!--<DataTemplate x:Key="ExpanderMouseToggleMouseStatesManagerTemplate">
|
||||
<u:StateGroupsManager>
|
||||
<u:StateDefinitionCollection>
|
||||
<StaticResource ResourceKey="ExpanderToggleMouseStates"/>
|
||||
</u:StateDefinitionCollection>
|
||||
</u:StateGroupsManager>
|
||||
</DataTemplate>-->
|
||||
|
||||
<Style x:Key="ParamRowBase" TargetType="FrameworkElement">
|
||||
<Setter Property="u:StateManager.GroupsTemplate" Value="{StaticResource ExpanderToggleMouseStatesTemplate}"/>
|
||||
<Setter Property="u:StateManager.VisualStateGroupsProxy">
|
||||
@@ -235,6 +244,23 @@
|
||||
</u:GridArchitectureProxy.ColumnDefinitions>
|
||||
</u:GridArchitectureProxy>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="StackedParamRowGridArchitecture">
|
||||
<u:GridArchitectureProxy>
|
||||
<u:GridArchitectureProxy.ColumnDefinitions>
|
||||
<x:Array Type="{x:Type ColumnDefinition}">
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="param_name"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource ParamHeaderContentGap}}" MaxWidth="{Binding Source={StaticResource ParamHeaderContentGap}}"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</x:Array>
|
||||
</u:GridArchitectureProxy.ColumnDefinitions>
|
||||
<u:GridArchitectureProxy.RowDefinitions>
|
||||
<x:Array Type="{x:Type RowDefinition}">
|
||||
<RowDefinition Height="{Binding Source={StaticResource ParamRowHeight}}"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</x:Array>
|
||||
</u:GridArchitectureProxy.RowDefinitions>
|
||||
</u:GridArchitectureProxy>
|
||||
</DataTemplate>
|
||||
|
||||
<!--
|
||||
Layout for the 'value portion' of the param row; should be nested in the 2nd column of the larger ParamRowGridArchitecture
|
||||
@@ -251,7 +277,7 @@
|
||||
</u:GridArchitectureProxy.ColumnDefinitions>
|
||||
</u:GridArchitectureProxy>
|
||||
</DataTemplate>
|
||||
|
||||
|
||||
<Style x:Key="ParamRow" TargetType="FrameworkElement" BasedOn="{StaticResource ParamRowBase}">
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="Height" Value="{StaticResource ParamRowHeight}"/>
|
||||
@@ -268,18 +294,16 @@
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ParamExpanderToggle" TargetType="c:ExpanderToggleButton" BasedOn="{StaticResource ParamRowBase}">
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="ClickMode" Value="Press"/>
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="Transparent"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="ClickMode" Value="Press"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="Padding" Value="7,0,0,0"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="ShowExpanderArrow" Value="False"/>
|
||||
</Style>
|
||||
|
||||
<DataTemplate x:Key="ColumnListBoxItemContentTemplate" DataType="{x:Type sp:GridColumnSettingsVM}">
|
||||
@@ -294,6 +318,14 @@
|
||||
</Binding.Converter>
|
||||
</Binding>
|
||||
</u:StateDefinition>
|
||||
<!--<u:StateDefinition>
|
||||
<Binding Path="Group.Target.Tag.ContextMenu.Items[0].IsChecked">
|
||||
<Binding.Converter>
|
||||
<cv:BooleanToObjectConverter ValueForFalse="HideDisplayName" ValueForTrue="ShowDisplayName"/>
|
||||
</Binding.Converter>
|
||||
</Binding>
|
||||
</u:StateDefinition>-->
|
||||
<!--<u:MouseStateDefinition MouseSource="{u:DirectReference column_item_content_root}"/>-->
|
||||
<u:MouseStateDefinition MouseSource="{Binding Group.Target.TemplatedParent.TemplatedParent, RelativeSource={RelativeSource Self}}" HoverState="VisibilityToggleMouseOver" PressedState="VisibilityTogglePressed" NormalState="VisibilityToggleNormal"/>
|
||||
</u:StateDefinitionCollection>
|
||||
</u:StateGroupsManager>
|
||||
@@ -312,8 +344,10 @@
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<!--<StaticResource ResourceKey="ExpanderToggleMouseStates"/>-->
|
||||
<VisualStateGroup Name="VisibilityToggleMouseStates">
|
||||
<VisualState Name="VisibilityToggleNormal"/>
|
||||
<!--<VisualState Name="VisibilityTogglePressed"/>-->
|
||||
<VisualState Name="VisibilityToggleMouseOver">
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetName="visibility_toggle" Storyboard.TargetProperty="(Control.BorderBrush).(SolidColorBrush.Opacity)" BeginTime="0" Duration="0" To="1"/>
|
||||
@@ -328,6 +362,7 @@
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="display_name_text_block" Storyboard.TargetProperty="(UIElement.Visibility)">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<!--<ThicknessAnimation Storyboard.TargetName="display_name_text_block" Storyboard.TargetProperty="(UIElement.Visibility)" BeginTime="0" Duration="0" To="0"/>-->
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
@@ -365,21 +400,35 @@
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<!--<DataTemplate.Triggers>
|
||||
<DataTrigger Binding="{Binding IsMouseOver, ElementName=column_item_content_root}" Value="True">
|
||||
<Setter TargetName="visibility_toggle" Property="BorderBrush" Value=""/>
|
||||
</DataTrigger>
|
||||
</DataTemplate.Triggers>-->
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="ColumnListBoxItem" DataType="{x:Type sp:GridColumnSettingsVM}">
|
||||
<Grid>
|
||||
<CheckBox x:Name="visibility_toggle" ToolTipService.ShowOnDisabled="True" IsChecked="{Binding show.override_value}" IsEnabled="True" Focusable="False"/>
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal" Focusable="False">
|
||||
<TextBlock Text="{Binding id, Converter={x:Static ut:DisplayNameHelper.CamelCaseSpacesConverter}}" Focusable="False"/>
|
||||
<TextBlock Margin="2,0,0,0" FontStyle="Italic" Text="{Binding header.effective_value, Mode=OneWay, StringFormat='{} ({0})'}" Focusable="False">
|
||||
<TextBlock.Visibility>
|
||||
<MultiBinding Converter="{x:Static usp:GridSettingsResources.ColumnDisplayNameVisibilityConverter}">
|
||||
<Binding Path="id" Converter="{x:Static ut:DisplayNameHelper.CamelCaseSpacesConverter}"/>
|
||||
<Binding Path="header.effective_value"/>
|
||||
</MultiBinding>
|
||||
</TextBlock.Visibility>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<Style x:Key="ColumnsListBox" TargetType="c:DragDropListBox" BasedOn="{StaticResource {x:Type c:DragDropListBox}}">
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="MaxHeight">
|
||||
<Setter.Value>
|
||||
<Binding Path="ActualHeight" RelativeSource="{RelativeSource AncestorType=UserControl}">
|
||||
<Binding.Converter>
|
||||
<cv:DoubleSubtractionConverter Value="34"/>
|
||||
</Binding.Converter>
|
||||
</Binding>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="MinWidth" Value="140"/>
|
||||
<Setter Property="VerticalAlignment" Value="Top"/>
|
||||
<Setter Property="MaxHeight" Value="500"/>
|
||||
<Setter Property="MinWidth" Value="200"/>
|
||||
<Setter Property="ItemsSource" Value="{Binding columns}"/>
|
||||
<Setter Property="SelectedItem" Value="{Binding current_column}"/>
|
||||
<Setter Property="ContextMenu">
|
||||
<Setter.Value>
|
||||
@@ -392,7 +441,7 @@
|
||||
</ContextMenu>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="ItemsSource" Value="{Binding columns}"/>
|
||||
<!--<Setter Property="DisplayMemberPath" Value="id"/>-->
|
||||
<Setter Property="ItemTemplate" Value="{StaticResource ColumnListBoxItemContentTemplate}"/>
|
||||
<Setter Property="ItemContainerStyle">
|
||||
<Setter.Value>
|
||||
@@ -481,8 +530,7 @@
|
||||
<ColumnDefinition Width="14"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border
|
||||
x:Name="drag_region"
|
||||
<Border x:Name="drag_region"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
IsHitTestVisible="True"
|
||||
@@ -505,7 +553,39 @@
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<DataTemplate x:Key="HeaderedParameterGroup" DataType="{x:Type vm:ParameterGroupVM}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="{Binding Source={StaticResource ParamRowHeight}}"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock VerticalAlignment="Center" FontSize="14" FontWeight="SemiBold" Text="{Binding name}"/>
|
||||
<ItemsControl Grid.Row="1" ItemsSource="{Binding parameters}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type vm:ParameterGroupVM}">
|
||||
<!--<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="{Binding Source={StaticResource ParamRowHeight}}"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ListBox VerticalAlignment="Top" MinWidth="426" ItemsSource="{Binding parameters}" Style="{StaticResource NakedListBox}">
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem" BasedOn="{StaticResource NakedListBoxItem}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBoxItem">
|
||||
<Border Background="Transparent">
|
||||
<ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
</ListBox>
|
||||
</Grid>-->
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="{Binding Source={StaticResource ParamRowHeight}}"/>
|
||||
@@ -514,6 +594,7 @@
|
||||
<c:ExpanderToggleButton x:Name="ExpanderToggle" IsChecked="{Binding is_expanded}" Style="{StaticResource ParamExpanderToggle}">
|
||||
<Grid u:GridArchitectureProxy.Template="{StaticResource ParamRowGridArchitecture}">
|
||||
<TextBlock Text="{Binding name}" Style="{StaticResource ParamLabel}"/>
|
||||
<!--<TextBlock Grid.Column="2" Text="{Binding value, Converter={StaticResource EnumDescriptionConverter}}" Style="{StaticResource ParamContent}"/>-->
|
||||
</Grid>
|
||||
</c:ExpanderToggleButton>
|
||||
<ListBox
|
||||
@@ -546,52 +627,11 @@
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type vm:HeaderedParameterGroupVM}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="{Binding Source={StaticResource ParamRowHeight}}"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock VerticalAlignment="Center" Margin="7,0,0,0" FontSize="14" FontWeight="SemiBold" Text="{Binding name}"/>
|
||||
<ItemsControl Grid.Row="1" ItemsSource="{Binding parameters}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type vm:TabularParameterGroupVM}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TabControl
|
||||
Grid.Row="1"
|
||||
Background="Transparent"
|
||||
BorderThickness="0,1,0,0"
|
||||
VerticalAlignment="Stretch"
|
||||
ItemsSource="{Binding parameters}"
|
||||
SelectedItem="{Binding selected_item}"
|
||||
DisplayMemberPath="name"
|
||||
Style="{StaticResource FlatTabControl}"
|
||||
>
|
||||
<TabControl.ItemContainerStyle>
|
||||
<Style TargetType="TabItem" BasedOn="{StaticResource FlatTabItem}">
|
||||
<Setter Property="Header" Value="{Binding name}"/>
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<ItemsControl ItemsSource="{Binding parameters}"/>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</TabControl.ItemContainerStyle>
|
||||
</TabControl>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
|
||||
<DataTemplate DataType="{x:Type vm:BooleanParameterVM}">
|
||||
<Border Grid.ColumnSpan="3" Background="{u:Brush Transparent}" Height="{StaticResource ParamRowHeight}" HorizontalAlignment="Stretch">
|
||||
<Border Grid.ColumnSpan="3" Height="{StaticResource ParamRowHeight}" HorizontalAlignment="Stretch" Padding="6,0,0,0">
|
||||
<Border.Background>
|
||||
<SolidColorBrush Color="Transparent"/>
|
||||
</Border.Background>
|
||||
<u:StateManager.Groups>
|
||||
<u:StateGroupsManager AttachToMembers="True">
|
||||
<u:StateDefinitionCollection>
|
||||
@@ -602,7 +642,7 @@
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<StaticResource ResourceKey="ExpanderToggleMouseStates"/>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<CheckBox HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalContentAlignment="Center" Margin="{StaticResource ExpanderOffsetMargin}" Content="{Binding name}" IsChecked="{Binding value}"/>
|
||||
<CheckBox HorizontalAlignment="Stretch" VerticalAlignment="Stretch" VerticalContentAlignment="Center" Content="{Binding name}" IsChecked="{Binding value}"/>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
||||
@@ -961,7 +1001,7 @@
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="CheckableEnumDescriptionContentTemplate">
|
||||
<DataTemplate x:Key="HorizontalAlignmentItem">
|
||||
<ContentControl ContentTemplate="{StaticResource CheckableListBoxItemContentTemplate}">
|
||||
<ContentControl Content="{Binding}" ContentTemplate="{StaticResource EnumDescriptionTemplate}"/>
|
||||
</ContentControl>
|
||||
@@ -986,7 +1026,7 @@
|
||||
Background="Transparent"
|
||||
BorderThickness="0"
|
||||
ItemsSource="{Binding items}"
|
||||
ItemTemplate="{StaticResource CheckableEnumDescriptionContentTemplate}"
|
||||
ItemTemplate="{StaticResource HorizontalAlignmentItem}"
|
||||
SelectedItem="{Binding value}"
|
||||
Visibility="{Binding IsChecked, ElementName=ExpanderToggle, Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
ItemContainerStyle="{StaticResource LargeMenuListBoxItem}"
|
||||
@@ -1100,30 +1140,35 @@
|
||||
<DataTemplate x:Key="ColumnsTabContent" DataType="{x:Type sp:GridSettingsVM}">
|
||||
<Grid Grid.IsSharedSizeScope="True">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition MinWidth="160" Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalPush4}}"/>
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<c:DragDropListBox
|
||||
x:Name="ColumnListBox"
|
||||
SelectedItem="{Binding current_column}"
|
||||
SelectItemOnDrop="True"
|
||||
Style="{StaticResource ColumnsListBox}"
|
||||
/>
|
||||
<GridSplitter Grid.Column="1" Panel.ZIndex="1" HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="5" Background="Transparent"/>
|
||||
<ScrollViewer Grid.Column="1" VerticalAlignment="Stretch" VerticalScrollBarVisibility="Auto" Content="{Binding current_column}">
|
||||
<ScrollViewer.MaxHeight>
|
||||
<Binding Path="ActualHeight" RelativeSource="{RelativeSource AncestorType=UserControl}">
|
||||
<Binding.Converter>
|
||||
<cv:DoubleSubtractionConverter Value="30"/>
|
||||
</Binding.Converter>
|
||||
</Binding>
|
||||
</ScrollViewer.MaxHeight>
|
||||
<ScrollViewer.ContentTemplate>
|
||||
<DataTemplate DataType="{x:Type sp:GridColumnSettingsVM}">
|
||||
<ItemsControl ItemsSource="{Binding parameters}"/>
|
||||
</DataTemplate>
|
||||
</ScrollViewer.ContentTemplate>
|
||||
</ScrollViewer>
|
||||
<c:DragDropListBox SelectItemOnDrop="True" Style="{StaticResource ColumnsListBox}"/>
|
||||
<Grid Grid.Column="2" MinWidth="280">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="{Binding Source={StaticResource ParamRowHeight}}"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock VerticalAlignment="Center" FontSize="14" FontWeight="SemiBold">
|
||||
Cell Appearance
|
||||
</TextBlock>
|
||||
<ListBox Grid.Row="1" VerticalAlignment="Top" ItemsSource="{Binding current_column.parameters}" Style="{StaticResource NakedListBox}">
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem" BasedOn="{StaticResource NakedListBoxItem}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBoxItem">
|
||||
<Border Background="Transparent">
|
||||
<ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
</ResourceDictionary>
|
||||
@@ -1,4 +1,5 @@
|
||||
using bts.collections;
|
||||
using bts.api;
|
||||
using bts.collections;
|
||||
using bts.proto;
|
||||
using bts.utils;
|
||||
using mbts.ui;
|
||||
@@ -9,11 +10,12 @@ using mbts.ui.utility;
|
||||
using mbts.ui.utility.text;
|
||||
using mbts.ui.viewmodels;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace mbts.spark {
|
||||
@@ -42,7 +44,8 @@ namespace mbts.spark {
|
||||
EqualityComparer.safe_aggregate_hash(predicate_animations_data));
|
||||
}
|
||||
|
||||
class GridSettingsVM : ParameterGroupVM, IRequestViewClose, IWindowSettingsVM<GridSettings>, ITemplateSelectorKey {
|
||||
class GridSettingsVM : DisposableViewModelBase, IRequestViewClose, IWindowSettingsVM<GridSettings>, ITemplateSelectorKey {
|
||||
//
|
||||
readonly FontParameterVM _font_vm = new FontParameterVM("Cell Font");
|
||||
readonly ColorParameterVM
|
||||
_font_color = new ColorParameterVM("Cell Font Color"),
|
||||
@@ -50,32 +53,28 @@ namespace mbts.spark {
|
||||
_background = new ColorParameterVM("Background");
|
||||
readonly Property<GridColumnSettingsVM> _current_column;
|
||||
readonly IReadOnlyDictionary<string, GridColumnSettingsFeatureFlags> _column_flags;
|
||||
readonly ObservableCollection<object> _parameters = new ObservableCollection<object>();
|
||||
bool _background_enabled, _show_column_display_name;
|
||||
IDisposable _dispose;
|
||||
|
||||
protected GridSettingsVM(string name)
|
||||
: base(name) { }
|
||||
|
||||
public GridSettingsVM(IReadOnlyDictionary<string, GridColumnSettingsFeatureFlags> column_flags = null)
|
||||
: this("Grid Settings") {
|
||||
public GridSettingsVM(IReadOnlyDictionary<string, GridColumnSettingsFeatureFlags> column_flags = null) {
|
||||
//
|
||||
_column_flags = column_flags ?? new Dictionary<string, GridColumnSettingsFeatureFlags>();
|
||||
_current_column = backing<GridColumnSettingsVM>(nameof(current_column));
|
||||
sync_params();
|
||||
_parameters.sync_with(_visible_parameters);
|
||||
// font
|
||||
_dispose = Disposable.Create(ObservableAutoWrapper.connect_item_hooks(columns, c => {
|
||||
_font_vm.result_changed += on_result_changed;
|
||||
_background.result_changed += on_result_changed;
|
||||
_dispose = ObservableAutoWrapper.connect_item_hooks(columns, c => {
|
||||
_font_vm.PropertyChanged += on_prop_changed;
|
||||
_background.PropertyChanged += on_prop_changed;
|
||||
_font_color.Changed += on_font_color_changed;
|
||||
on_font_color_changed(default, _font_color.value);
|
||||
on_result_changed();
|
||||
on_prop_changed(null, null);
|
||||
return Disposable.Create(() => {
|
||||
_font_vm.result_changed -= on_result_changed;
|
||||
_background.result_changed -= on_result_changed;
|
||||
_font_vm.PropertyChanged -= on_prop_changed;
|
||||
_font_color.Changed -= on_font_color_changed;
|
||||
});
|
||||
// set the whole state everytime, bc it's simpler and less error prone
|
||||
// than coordinating between specific properties.
|
||||
void on_result_changed() {
|
||||
void on_prop_changed(object sender, PropertyChangedEventArgs e) {
|
||||
c.background.default_value = _background.value;
|
||||
c.font_weight.family = _font_vm.family;
|
||||
c.font_weight.default_value = _font_vm.weight;
|
||||
@@ -83,24 +82,14 @@ namespace mbts.spark {
|
||||
}
|
||||
void on_font_color_changed(Color oldval, Color newval) =>
|
||||
c.font_color.default_value = newval;
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
public event EventHandler RequestClose;
|
||||
public event Action committed;
|
||||
|
||||
public ObservableCollection<GridColumnSettingsVM> columns { get; } = new ObservableCollection<GridColumnSettingsVM>();
|
||||
|
||||
public GridColumnSettingsVM current_column {
|
||||
get => _current_column.Value;
|
||||
set => _current_column.set(value);
|
||||
}
|
||||
|
||||
public bool show_column_display_name {
|
||||
get => _show_column_display_name;
|
||||
set => Set(ref _show_column_display_name, value);
|
||||
}
|
||||
|
||||
public GridColumnSettingsVM current_column { get => _current_column.Value; set => _current_column.set(value); }
|
||||
public IReadOnlyList<DialogSkirtItem> dialog_skirt_items => new[] {
|
||||
new DialogSkirtItem("OK", new DelegateCommand(() => {
|
||||
committed?.Invoke();
|
||||
@@ -109,9 +98,25 @@ namespace mbts.spark {
|
||||
new DialogSkirtItem("Cancel", new DelegateCommand(() => RequestClose?.Invoke(this, new EventArgs()))) { is_cancel = true },
|
||||
new DialogSkirtItem("Apply", new DelegateCommand(() => committed?.Invoke()))
|
||||
};
|
||||
public bool show_column_display_name {
|
||||
get => _show_column_display_name;
|
||||
set => Set(ref _show_column_display_name, value);
|
||||
}
|
||||
|
||||
public string key => ui.spark.GridSettingsTemplateKeys.SimpleGrid;
|
||||
|
||||
public IEnumerable parameters => _parameters;
|
||||
|
||||
IEnumerable<object> _visible_parameters {
|
||||
get {
|
||||
yield return _selection_highlight;
|
||||
if (_background_enabled)
|
||||
yield return _background;
|
||||
yield return _font_vm;
|
||||
yield return _font_color;
|
||||
}
|
||||
}
|
||||
|
||||
public IDisposable begin_change_columns() {
|
||||
var curr_col_id = current_column?.id;
|
||||
return Disposable.Create(() => {
|
||||
@@ -128,7 +133,7 @@ namespace mbts.spark {
|
||||
col_settings.Add(settings);
|
||||
}
|
||||
return new GridSettings(
|
||||
_font_vm.family?.name(),
|
||||
_font_vm.family.name(),
|
||||
_font_vm.size,
|
||||
_font_vm.weight,
|
||||
_font_color.value.rgb_color(),
|
||||
@@ -167,27 +172,7 @@ namespace mbts.spark {
|
||||
}));
|
||||
}
|
||||
}
|
||||
sync_params();
|
||||
_parameters.sync_with(_visible_parameters);
|
||||
}
|
||||
|
||||
public IObservable<Color> subscribe_background() =>
|
||||
_background.SubscribeValue(true);
|
||||
|
||||
public IObservable<Color> subscribe_font_color() =>
|
||||
_font_color.SubscribeValue(true);
|
||||
|
||||
public IObservable<(FontFamily family, FontWeight weight, double size)> subscribe_font() =>
|
||||
_font_vm.SubscribeValue(true);
|
||||
|
||||
public virtual void sync_params() {
|
||||
var fonts_and_colors = HeaderedParameterGroupVM.create("Fonts/Colors", _font_vm, _font_color);
|
||||
if (_background_enabled)
|
||||
fonts_and_colors.parameters.Add(_background);
|
||||
fonts_and_colors.parameters.Add(_selection_highlight);
|
||||
parameters.SetItems(fonts_and_colors);
|
||||
}
|
||||
|
||||
public void Dispose() =>
|
||||
Disposable.dispose(ref _dispose);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sp="clr-namespace:mbts.spark"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:usp="clr-namespace:mbts.ui.spark"
|
||||
Content="{Binding}"
|
||||
@@ -14,24 +13,32 @@
|
||||
<UserControl.ContentTemplate>
|
||||
<DataTemplate DataType="{x:Type sp:GridSettingsVM}">
|
||||
<Grid>
|
||||
<u:BindingProxy x:Name="ActionMenuItemsViewProxy" Value="{DynamicResource ActionMenuItemsView}"/>
|
||||
<Grid.Margin>
|
||||
<Thickness Left="{StaticResource HorizontalPush2}" Right="{StaticResource HorizontalPush2}"/>
|
||||
</Grid.Margin>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<c:ActionMenu
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,2,0,0"
|
||||
ItemsSource="{Binding Path='(u:BindingProxy.Value).(CollectionViewSource.View)', ElementName=ActionMenuItemsViewProxy}"
|
||||
ItemsSource="{Binding DataContext.action_menu_items, RelativeSource={RelativeSource AncestorType=usp:ShellSettingsDialog}}"
|
||||
Style="{StaticResource SparkToolBarItem}"
|
||||
>
|
||||
<ItemsControl.GroupStyle>
|
||||
<GroupStyle ContainerStyle="{StaticResource ComboBox.DelineatedGroupContainerStyle.DynamicFill}"/>
|
||||
</ItemsControl.GroupStyle>
|
||||
</c:ActionMenu>
|
||||
<TabControl MinWidth="500" Margin="0,2,0,0" Style="{StaticResource FlatTabControl}">
|
||||
/>
|
||||
<TabControl x:Name="Tabs" HorizontalAlignment="Stretch" MinHeight="480" MinWidth="500" Margin="0,2,0,0" Padding="6">
|
||||
<TabControl.ItemContainerStyle>
|
||||
<Style TargetType="TabItem">
|
||||
<Setter Property="MinWidth" Value="60"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
</TabControl.ItemContainerStyle>
|
||||
<TabItem Header="Grid">
|
||||
<ItemsControl Grid.IsSharedSizeScope="True" ItemsSource="{Binding parameters}"/>
|
||||
<ItemsControl x:Name="ParameterItemsControl" Grid.IsSharedSizeScope="True" Margin="8,16,0,0" ItemsSource="{Binding parameters}"/>
|
||||
</TabItem>
|
||||
<TabItem Header="Columns" Content="{Binding}" ContentTemplate="{StaticResource ColumnsTabContent}"/>
|
||||
</TabControl>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</UserControl.ContentTemplate>
|
||||
</UserControl>
|
||||
</UserControl>
|
||||
@@ -1,29 +1,9 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace mbts.ui.controls {
|
||||
static class PopupViewController {
|
||||
#region ButtonSource
|
||||
public static readonly DependencyProperty ButtonSourceProperty =
|
||||
DependencyProperty.RegisterAttached("ButtonSource", typeof(ButtonBase), typeof(PopupViewController),
|
||||
new PropertyMetadata(OnButtonSourceChanged));
|
||||
|
||||
static void OnButtonSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
|
||||
if (d is Popup popup)
|
||||
popup.SetValue(ButtonSourceDependencyPropertyKey,
|
||||
e.NewValue is ButtonBase button ? attach(popup, button) : null);
|
||||
}
|
||||
|
||||
public static bool GetButtonSource(DependencyObject d) => (bool)d.GetValue(ButtonSourceProperty);
|
||||
public static void SetButtonSource(DependencyObject d, bool value) => d.SetValue(ButtonSourceProperty, value);
|
||||
|
||||
static readonly DependencyPropertyKey ButtonSourceDependencyPropertyKey =
|
||||
DependencyProperty.RegisterAttachedReadOnly("ButtonSourceDependency", typeof(IDisposable), typeof(PopupViewController),
|
||||
new PropertyMetadata(FrameworkElementLifeDependencyHelper.DisposeOld));
|
||||
#endregion
|
||||
|
||||
public static IDisposable attach(Popup popup, ButtonBase open_cmd_source, bool auto_focus_popup_root_on_open = false) {
|
||||
/// There is a paradoxical corner case handled here that occurs when the user clicks the button to 'close' the popup.
|
||||
/// Conventional logic might dictate that a <see cref="ToggleButton "/> be used to bind <see cref="ToggleButton.IsChecked"/> to <see cref="Popup.IsOpen"/>,
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:usp="clr-namespace:mbts.ui.spark"
|
||||
xmlns:uspcv="clr-namespace:mbts.ui.spark.converters"
|
||||
xmlns:txt="clr-namespace:mbts.ui.utility.text"
|
||||
>
|
||||
<!--Control colors.-->
|
||||
<Color x:Key="WindowColor">#FFE8EDF9</Color>
|
||||
<Color x:Key="ContentAreaColorLight">#FFC5CBF9</Color>
|
||||
<Color x:Key="ContentAreaColorDark">#FF7381F9</Color>
|
||||
|
||||
<Color x:Key="DisabledControlLightColor">#FFE8EDF9</Color>
|
||||
<Color x:Key="DisabledControlDarkColor">#FFC5CBF9</Color>
|
||||
<Color x:Key="DisabledForegroundColor">#FF888888</Color>
|
||||
|
||||
<Color x:Key="SelectedBackgroundColor">#FFC5CBF9</Color>
|
||||
<Color x:Key="SelectedUnfocusedColor">#FFDDDDDD</Color>
|
||||
|
||||
<Color x:Key="ControlLightColor">White</Color>
|
||||
<Color x:Key="ControlMediumColor">#FF7381F9</Color>
|
||||
<Color x:Key="ControlDarkColor">#FF211AA9</Color>
|
||||
|
||||
<Color x:Key="ControlMouseOverColor">#FF3843C4</Color>
|
||||
<Color x:Key="ControlPressedColor">#FF211AA9</Color>
|
||||
|
||||
|
||||
<Color x:Key="GlyphColor">#FF444444</Color>
|
||||
<Color x:Key="GlyphMouseOver">sc#1, 0.004391443, 0.002428215, 0.242281124</Color>
|
||||
|
||||
<!--Border colors-->
|
||||
<Color x:Key="BorderLightColor">#FFCCCCCC</Color>
|
||||
<Color x:Key="BorderMediumColor">#FF888888</Color>
|
||||
<Color x:Key="BorderDarkColor">#FF444444</Color>
|
||||
|
||||
<Color x:Key="PressedBorderLightColor">#FF888888</Color>
|
||||
<Color x:Key="PressedBorderDarkColor">#FF444444</Color>
|
||||
|
||||
<Color x:Key="DisabledBorderLightColor">#FFAAAAAA</Color>
|
||||
<Color x:Key="DisabledBorderDarkColor">#FF888888</Color>
|
||||
|
||||
<Style x:Key="FlatTabItem" TargetType="{x:Type TabItem}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TabItem}">
|
||||
<Grid x:Name="Root">
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="SelectionStates">
|
||||
<VisualState x:Name="Unselected" />
|
||||
<VisualState x:Name="Selected">
|
||||
<Storyboard>
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
|
||||
<EasingColorKeyFrame KeyTime="0" Value="{StaticResource ControlPressedColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
<ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderThickness)" Storyboard.TargetName="Border">
|
||||
<EasingThicknessKeyFrame KeyTime="0" Value="1,1,1,0"/>
|
||||
</ThicknessAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal" />
|
||||
<VisualState x:Name="MouseOver" />
|
||||
<VisualState x:Name="Disabled">
|
||||
<Storyboard>
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
|
||||
<EasingColorKeyFrame KeyTime="0" Value="{StaticResource DisabledControlDarkColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)">
|
||||
<EasingColorKeyFrame KeyTime="0" Value="{StaticResource DisabledBorderLightColor}"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Border
|
||||
x:Name="Border"
|
||||
Margin="0,0,-4,0"
|
||||
BorderThickness="1"
|
||||
>
|
||||
<Border.BorderBrush>
|
||||
<SolidColorBrush Color="{DynamicResource BorderMediumColor}" />
|
||||
</Border.BorderBrush>
|
||||
<Border.Background>
|
||||
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
|
||||
<LinearGradientBrush.GradientStops>
|
||||
<GradientStopCollection>
|
||||
<GradientStop Color="{DynamicResource ControlLightColor}" Offset="0.0"/>
|
||||
<GradientStop Color="{DynamicResource ControlMediumColor}" Offset="1.0"/>
|
||||
</GradientStopCollection>
|
||||
</LinearGradientBrush.GradientStops>
|
||||
</LinearGradientBrush>
|
||||
</Border.Background>
|
||||
<ContentPresenter
|
||||
x:Name="ContentSite"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
ContentSource="Header"
|
||||
Margin="12,2,12,2"
|
||||
RecognizesAccessKey="True"
|
||||
/>
|
||||
</Border>
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Panel.ZIndex" Value="100"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="{x:Type c:HorizontalTabControl}">
|
||||
<Setter Property="OverridesDefaultStyle" Value="True"/>
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource FlatTabItem}"/>
|
||||
<Setter Property="ItemsPanel">
|
||||
<Setter.Value>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal"/>
|
||||
</ItemsPanelTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type c:HorizontalTabControl}">
|
||||
<Grid KeyboardNavigation.TabNavigation="Local">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Disabled">
|
||||
<Storyboard>
|
||||
<ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)">
|
||||
<EasingColorKeyFrame KeyTime="0" Value="#FFAAAAAA"/>
|
||||
</ColorAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<ItemsPresenter
|
||||
x:Name="HeaderPanel"
|
||||
Grid.Row="0"
|
||||
Panel.ZIndex="1"
|
||||
Margin="0,0,4,-1"
|
||||
KeyboardNavigation.TabIndex="1"
|
||||
>
|
||||
</ItemsPresenter>
|
||||
<ContentPresenter
|
||||
x:Name="PART_SelectedContentHost"
|
||||
Grid.Row="1"
|
||||
Grid.ColumnSpan="2"
|
||||
KeyboardNavigation.TabNavigation="Local"
|
||||
KeyboardNavigation.DirectionalNavigation="Contained"
|
||||
KeyboardNavigation.TabIndex="2"
|
||||
Margin="4"
|
||||
ContentSource="SelectedContent"
|
||||
/>
|
||||
<!--<Rectangle Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Top" Height="1" Fill="{TemplateBinding BorderBrush}"/>-->
|
||||
<Rectangle Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="-4,0,0,-1" Height="1" Fill="DarkGray"/>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,24 @@
|
||||
using bts.api;
|
||||
using bts.utils;
|
||||
using mbts.spark;
|
||||
using mbts.ui.controls;
|
||||
using mbts.ui.extensions;
|
||||
using mbts.ui.utilities;
|
||||
using mbts.ui.utility;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace mbts.ui.controls {
|
||||
/// <summary>
|
||||
/// Interaction logic for HorizontalTabControl.xaml
|
||||
/// </summary>
|
||||
class HorizontalTabControl : TabControl {
|
||||
static HorizontalTabControl() =>
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(HorizontalTabControl), new FrameworkPropertyMetadata(typeof(HorizontalTabControl)));
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,6 @@
|
||||
<SolidColorBrush Color="{StaticResource MouseOverBorderLightColor}"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Background" Value="{u:BTSColor UI.Button.mouseover_background}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Opacity" Value="0.5"/>
|
||||
@@ -63,67 +62,6 @@
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SparkToolBarButton" TargetType="Button">
|
||||
<Setter Property="ToolTipService.ShowOnDisabled" Value="True"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="Height" Value="22"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="Padding" Value="2"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="Width" Value="22"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border
|
||||
x:Name="Border"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Height="{TemplateBinding Height}"
|
||||
Width="{TemplateBinding Width}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
Opacity="1"
|
||||
>
|
||||
<Border.BorderBrush>
|
||||
<SolidColorBrush/>
|
||||
</Border.BorderBrush>
|
||||
<Border.Background>
|
||||
<SolidColorBrush/>
|
||||
</Border.Background>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup Name="CommonStates">
|
||||
<VisualState Name="Normal"/>
|
||||
<VisualState Name="MouseOver">
|
||||
<Storyboard>
|
||||
<ColorAnimation Storyboard.TargetProperty="Background.Color" BeginTime="0" Duration="0" To="{DynamicResource Control.AlphaLightMediumGrayColor}"/>
|
||||
<ColorAnimation Storyboard.TargetProperty="BorderBrush.Color" BeginTime="0" Duration="0" To="{DynamicResource Control.DarkGrayColor}"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState u:StateManager.Name="Pressed">
|
||||
<Storyboard>
|
||||
<ColorAnimation Storyboard.TargetProperty="Background.Color" BeginTime="0" Duration="0" To="{DynamicResource Control.AlphaMediumGrayColor}"/>
|
||||
<ColorAnimation Storyboard.TargetProperty="BorderBrush.Color" BeginTime="0" Duration="0" To="{DynamicResource Control.DarkGrayColor}"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState Name="Disabled">
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="Opacity" BeginTime="0" Duration="0" To="0.52"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<ContentPresenter
|
||||
Name="presenter"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
RecognizesAccessKey="True"
|
||||
/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ToolBarThumbStyle" TargetType="{x:Type Thumb}">
|
||||
<Setter Property="OverridesDefaultStyle" Value="True"/>
|
||||
<Setter Property="Cursor" Value="SizeAll"/>
|
||||
@@ -223,7 +161,7 @@
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="SnapsToDevicePixels" Value="True"/>
|
||||
<Setter Property="OverridesDefaultStyle" Value="True"/>
|
||||
<!--<Setter Property="ItemContainerStyle" Value="{StaticResource SparkToolBarItem}"/>-->
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource SparkToolBarItem}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ToolBar}">
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace mbts.ui.converters {
|
||||
class AppendTextConverter : MarkupExtension, IValueConverter {
|
||||
class AppendTextConverter : IValueConverter {
|
||||
public string Prefix { get; set; }
|
||||
public string Suffix { get; set; }
|
||||
|
||||
@@ -19,8 +18,5 @@ namespace mbts.ui.converters {
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) =>
|
||||
throw new NotImplementedException();
|
||||
|
||||
public override object ProvideValue(IServiceProvider serviceProvider) =>
|
||||
this;
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,11 @@ using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace mbts.ui.converters {
|
||||
namespace mbts.ui.converters
|
||||
{
|
||||
[ValueConversion(typeof(ImageSource), typeof(Image))]
|
||||
class ImageSourceIconConverter : IValueConverter {
|
||||
public static ImageSourceIconConverter Instance => new ImageSourceIconConverter();
|
||||
|
||||
internal class ImageSourceIconConverter : IValueConverter
|
||||
{
|
||||
public Thickness Margin { get; set; } = new Thickness(0);
|
||||
public double Width { get; set; } = double.NaN;
|
||||
public double Height { get; set; } = double.NaN;
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace mbts.ui.converters {
|
||||
[ValueConversion(typeof(int), typeof(int))]
|
||||
class IntAdditionConverter : IValueConverter {
|
||||
public int Value { get; set; }
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
if (value is int i)
|
||||
return i + Value;
|
||||
return new ValidationResult(false, "Not an integer.");
|
||||
}
|
||||
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
if (value is int i)
|
||||
return i - Value;
|
||||
return new ValidationResult(false, "Not an integer.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace mbts.ui.converters {
|
||||
[ValueConversion(typeof(SizeToContent), typeof(double))]
|
||||
abstract class WindowSizeThresholdConverter : IValueConverter {
|
||||
readonly SizeToContent _size_to_content_flag;
|
||||
|
||||
protected WindowSizeThresholdConverter(SizeToContent size_to_content_flag) =>
|
||||
_size_to_content_flag = size_to_content_flag;
|
||||
|
||||
public double SizeToContentThreshold { get; set; } = double.NaN;
|
||||
public double Threshold { get; set; }
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
if (value is SizeToContent stc) {
|
||||
if ((stc & _size_to_content_flag) == _size_to_content_flag) {
|
||||
if (double.IsNaN(SizeToContentThreshold)) {
|
||||
if (parameter is double d)
|
||||
return d;
|
||||
} else {
|
||||
return SizeToContentThreshold;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Threshold;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) =>
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
[ValueConversion(typeof(SizeToContent), typeof(double))]
|
||||
sealed class WindowMinWidthConverter : WindowSizeThresholdConverter {
|
||||
public WindowMinWidthConverter() : base(SizeToContent.Width) { }
|
||||
}
|
||||
|
||||
[ValueConversion(typeof(SizeToContent), typeof(double))]
|
||||
sealed class WindowMaxWidthConverter : WindowSizeThresholdConverter {
|
||||
public WindowMaxWidthConverter() : base(SizeToContent.Width) =>
|
||||
Threshold = double.PositiveInfinity;
|
||||
}
|
||||
|
||||
[ValueConversion(typeof(SizeToContent), typeof(double))]
|
||||
sealed class WindowMinHeightConverter : WindowSizeThresholdConverter {
|
||||
public WindowMinHeightConverter() : base(SizeToContent.Height) { }
|
||||
}
|
||||
|
||||
[ValueConversion(typeof(SizeToContent), typeof(double))]
|
||||
sealed class WindowMaxHeightConverter : WindowSizeThresholdConverter {
|
||||
public WindowMaxHeightConverter() : base(SizeToContent.Height) =>
|
||||
Threshold = double.PositiveInfinity;
|
||||
}
|
||||
}
|
||||
@@ -156,62 +156,6 @@ namespace mbts.ui {
|
||||
}
|
||||
}
|
||||
|
||||
public static IDisposable connect_vertical_insertion_adorner(ItemsControl container, FrameworkElement root = null) {
|
||||
VerticalInsertionAdorner insertion_adorner = null;
|
||||
UIElement target = null;
|
||||
VerticalInsertionAdorner.TargetSide target_side = VerticalInsertionAdorner.TargetSide.Top;
|
||||
if (root == null)
|
||||
root = container;
|
||||
return Disposable.Create(
|
||||
root.SubscribePreviewDragEnter(on_drag_enter),
|
||||
root.SubscribePreviewDragLeave((s, e) => remove_adorner()),
|
||||
root.SubscribePreviewDragOver(on_drag_over),
|
||||
root.SubscribePreviewDrop((s, e) => remove_adorner()),
|
||||
Disposable.Create(remove_adorner));
|
||||
void on_drag_over(object sender, DragEventArgs e) {
|
||||
_determine_drop_target(e);
|
||||
_update_insertion_adorner();
|
||||
e.Effects = DragDropEffects.Move;
|
||||
e.Handled = true;
|
||||
}
|
||||
void on_drag_enter(object sender, DragEventArgs e) {
|
||||
_determine_drop_target(e);
|
||||
_update_insertion_adorner();
|
||||
e.Effects = e.AllowedEffects;
|
||||
}
|
||||
// Draw an indicator where the drop will insert the item
|
||||
void _update_insertion_adorner() {
|
||||
if (insertion_adorner == null) {
|
||||
insertion_adorner = new VerticalInsertionAdorner(target, target_side);
|
||||
} else insertion_adorner.Side = target_side;
|
||||
}
|
||||
void _determine_drop_target(DragEventArgs e) {
|
||||
var orig_target = target;
|
||||
var orig_side = target_side;
|
||||
target = null;
|
||||
var pt = e.GetPosition(container);
|
||||
pt.X = MathUtils.within_range(0, container.ActualWidth - 2, pt.X);
|
||||
pt.Y = MathUtils.within_range(0, container.ActualHeight - 2, pt.Y);
|
||||
if (container.InputHitTest(pt) is DependencyObject hit) {
|
||||
target = container.ContainerFromElement(hit) as UIElement;
|
||||
if (target != null) {
|
||||
Point target_position = e.GetPosition(target);
|
||||
target_side = target_position.Y < (target.RenderSize.Height / 2) ?
|
||||
VerticalInsertionAdorner.TargetSide.Top :
|
||||
VerticalInsertionAdorner.TargetSide.Bottom;
|
||||
if (target != orig_target || target_side != orig_side)
|
||||
remove_adorner();
|
||||
}
|
||||
}
|
||||
}
|
||||
void remove_adorner() {
|
||||
if (insertion_adorner != null) {
|
||||
insertion_adorner.Detach();
|
||||
insertion_adorner = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Conditional("DEBUG")]
|
||||
private static void log(string message, params object[] args) {
|
||||
Console.WriteLine(message, args);
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using bts;
|
||||
using mbts.utils;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Data;
|
||||
using CompositeDisposable = System.Reactive.Disposables.CompositeDisposable;
|
||||
|
||||
namespace mbts.ui.extensions {
|
||||
@@ -83,33 +81,6 @@ namespace mbts.ui.extensions {
|
||||
}
|
||||
}
|
||||
|
||||
public static IObservable<bool> ObserveIsSelected(this TabItem tab_item) {
|
||||
int subscription_count = 0;
|
||||
BindingProxy proxy = null;
|
||||
return Observable.Create<bool>(o => {
|
||||
if (subscription_count++ == 0) {
|
||||
Log.assert(proxy == null, "Potential memory leak detected: binding proxy should be null when there are 0 subscriptions.");
|
||||
proxy = new BindingProxy();
|
||||
proxy.SetBinding(BindingProxy.ValueProperty, new Binding(nameof(TabItem.IsSelected)) { Source = tab_item });
|
||||
}
|
||||
bool last_observed = tab_item.IsSelected;
|
||||
o.OnNext(last_observed);
|
||||
proxy.ValueChanged += on_value_changed;
|
||||
return Disposable.CreateDisposeOnce(dispose);
|
||||
void dispose() {
|
||||
proxy.ValueChanged -= on_value_changed;
|
||||
if (--subscription_count == 0) {
|
||||
Log.assert(proxy != null, "Binding proxy should not be null when subscriptions are active.");
|
||||
proxy = null;
|
||||
}
|
||||
}
|
||||
void on_value_changed(object d, DependencyPropertyChangedEventArgs e) {
|
||||
if ((e.NewValue is bool b && b) != last_observed)
|
||||
o.OnNext(last_observed = !last_observed);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static IObservable<bool> ObserveIsChecked(this ToggleButton toggle_button) =>
|
||||
Observable.Create<bool>(o => {
|
||||
toggle_button.Checked += on_checked;
|
||||
|
||||
@@ -2,12 +2,17 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace mbts.ui {
|
||||
namespace mbts.ui
|
||||
{
|
||||
[MarkupExtensionReturnType(typeof(Brush))]
|
||||
class BrushExtension : MarkupExtension {
|
||||
public class BrushExtension : MarkupExtension
|
||||
{
|
||||
public BrushExtension() : this(Colors.Black) { }
|
||||
public BrushExtension(Color Color) : this(Color, 1.0) { }
|
||||
public BrushExtension(Color Color, double Opacity) { this.Color = Color; this.Opacity = Opacity; }
|
||||
@@ -22,70 +27,6 @@ namespace mbts.ui {
|
||||
}
|
||||
}
|
||||
|
||||
[MarkupExtensionReturnType(typeof(Brush))]
|
||||
class FrozenBrush : MarkupExtension {
|
||||
[ThreadStatic]
|
||||
static Dictionary<BrushKey, SolidColorBrush> _brushes;
|
||||
|
||||
double _opacity = 1;
|
||||
|
||||
public FrozenBrush(Color color) =>
|
||||
Color = color;
|
||||
|
||||
public Color Color { get; set; }
|
||||
public double Opacity {
|
||||
get => _opacity;
|
||||
set => _opacity = value < 0 || value > 1 ?
|
||||
throw new ArgumentException("Must be between 0 and 1 (inclusive).", nameof(value)) :
|
||||
value;
|
||||
}
|
||||
|
||||
public static SolidColorBrush get_brush(Color color, double opacity = 1.0) {
|
||||
if (_brushes == null)
|
||||
_brushes = new Dictionary<BrushKey, SolidColorBrush>();
|
||||
unchecked {
|
||||
ushort opac = opacity == 1 ? ushort.MaxValue : (ushort)(opacity * 100_000);
|
||||
// color has a perfect hash (it is 32 bits, so it damn well better).
|
||||
var key = new BrushKey(color.GetHashCode(), opac);
|
||||
if (!_brushes.TryGetValue(key, out var brush)) {
|
||||
_brushes[key] = brush = new SolidColorBrush(color).frozen();
|
||||
}
|
||||
return brush;
|
||||
}
|
||||
}
|
||||
|
||||
public override object ProvideValue(IServiceProvider serviceProvider) =>
|
||||
get_brush(Color, Opacity);
|
||||
|
||||
readonly struct BrushKey : IEquatable<BrushKey> {
|
||||
readonly int _color;
|
||||
// bc opacity does not need more precision than 16 bits; 100,000 discrete values is more than enough
|
||||
// (65,536 should avoid has collisions stemming from opacity; also leaves 16 bits to encode color).
|
||||
readonly ushort _opacity;
|
||||
|
||||
public BrushKey(int color, ushort opacity) {
|
||||
_color = color;
|
||||
_opacity = opacity;
|
||||
}
|
||||
|
||||
public bool Equals(BrushKey other) =>
|
||||
_color == other._color &&
|
||||
_opacity == other._opacity;
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
obj is BrushKey other && Equals(other);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
// ushort.MaxValue indicates opacity of '1.'
|
||||
// The value we have is the actual opacity multiplied by 100,000;
|
||||
// so 1 would actually be a very small opacity: 0.0001.
|
||||
_opacity == ushort.MaxValue ?
|
||||
// the last bit indicates if opacity is zero
|
||||
_color | -1 :
|
||||
((ushort)_color | (_opacity << 16) | -1) ^ -1;
|
||||
}
|
||||
}
|
||||
|
||||
public class ColorTypeConverter : TypeConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { return sourceType == typeof(string); }
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:controls="clr-namespace:mbts.ui.controls"
|
||||
xmlns:cv="clr-namespace:mbts.ui.converters"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
>
|
||||
<SolidColorBrush x:Key="StartMenuMouseOverBorderBrush" Color="#FFFFB700" />
|
||||
<SolidColorBrush x:Key="StartMenuMouseOverBackground" Color="#6ddbff" />
|
||||
@@ -607,7 +606,7 @@
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border
|
||||
<Border
|
||||
x:Name="Border"
|
||||
CornerRadius="0"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
@@ -636,7 +635,7 @@
|
||||
<Setter TargetName="Border" Property="Background" Value="{mbts:BTSColor UI.Button.pressed_background}" />
|
||||
<Setter TargetName="Border" Property="BorderBrush" Value="{mbts:BTSColor UI.Button.pressed_border}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsKeyboardFocused" Value="true">
|
||||
<Trigger Property="IsKeyboardFocused" Value="true">
|
||||
<Setter TargetName="Border" Property="BorderBrush" Value="{mbts:BTSColor UI.Button.focused_border}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
@@ -824,7 +823,7 @@
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<Style x:Key="LargeMenuListBoxItem" TargetType="ListBoxItem">
|
||||
<Style x:Key="LargeMenuListBoxItemBase" TargetType="ListBoxItem">
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
@@ -837,6 +836,9 @@
|
||||
</Setter>
|
||||
<Setter Property="Padding" Value="6"/>
|
||||
<Setter Property="Template" Value="{StaticResource LargeMenuListBoxItemTemplate}"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="LargeMenuListBoxItem" TargetType="ListBoxItem" BasedOn="{StaticResource LargeMenuListBoxItemBase}">
|
||||
<Setter Property="ContentTemplate" Value="{StaticResource CheckableListBoxItemContentTemplate}"/>
|
||||
</Style>
|
||||
|
||||
@@ -1062,255 +1064,4 @@
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<DataTemplate x:Key="CenteredTextTemplate">
|
||||
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding}"/>
|
||||
</DataTemplate>
|
||||
|
||||
<Style x:Key="FlatTabItemBase" TargetType="TabItem" BasedOn="{StaticResource LargeMenuControlBase}">
|
||||
<Setter Property="Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="Transparent"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
<Setter Property="Padding" Value="2"/>
|
||||
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||
<Setter Property="Width" Value="{x:Static sys:Double.NaN}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="TabItem">
|
||||
<Border
|
||||
x:Name="Border"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Height="{TemplateBinding Height}"
|
||||
Width="{TemplateBinding Width}"
|
||||
Margin="{TemplateBinding Margin}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
>
|
||||
<u:StateManager.Groups>
|
||||
<u:StateGroupsManager AttachToMembers="True">
|
||||
<u:StateDefinitionCollection>
|
||||
<u:MouseStateDefinition Mode="Header" MouseSource="{Binding Group.Target, RelativeSource={RelativeSource Self}}"/>
|
||||
<u:SelectedStateDefinition
|
||||
Mode="{Binding Group.Target.TemplatedParent.Parent.TabStripPlacement, RelativeSource={RelativeSource Self}}"
|
||||
Source="{Binding Group.Target.TemplatedParent, RelativeSource={RelativeSource Self}}"
|
||||
/>
|
||||
<u:StateDefinition
|
||||
State="{Binding Group.Target.TemplatedParent.Parent.TabStripPlacement, RelativeSource={RelativeSource Self}, Converter={cv:AppendTextConverter Prefix=Dock}}"
|
||||
/>
|
||||
</u:StateDefinitionCollection>
|
||||
</u:StateGroupsManager>
|
||||
</u:StateManager.Groups>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup Name="HeaderMouseStates">
|
||||
<VisualState Name="HeaderNormal"/>
|
||||
<VisualState Name="HeaderMouseOver">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{u:FrozenBrush {StaticResource Control.AlphaLightMediumGrayColor}}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{u:FrozenBrush {StaticResource Control.DarkGrayColor}}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup Name="TopSelectionStates">
|
||||
<VisualState Name="TopSelected">
|
||||
<Storyboard>
|
||||
<ThicknessAnimation Storyboard.TargetProperty="BorderThickness" BeginTime="0" Duration="0" To="1,1,1,0"/>
|
||||
<ThicknessAnimation Storyboard.TargetProperty="Padding" BeginTime="0" Duration="0" To="2,4,2,6"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState Name="TopUnselected"/>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup Name="RightSelectionStates">
|
||||
<VisualState Name="RightSelected">
|
||||
<Storyboard>
|
||||
<ThicknessAnimation Storyboard.TargetProperty="BorderThickness" BeginTime="0" Duration="0" To="0,1,1,1"/>
|
||||
<ThicknessAnimation Storyboard.TargetProperty="Padding" BeginTime="0" Duration="0" To="6,2,4,2"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState Name="RightUnselected"/>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup Name="DockStates">
|
||||
<VisualState Name="DockLeft">
|
||||
<Storyboard>
|
||||
<ThicknessAnimation Storyboard.TargetProperty="Margin" To="0,0,0,-1"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState Name="DockTop">
|
||||
<Storyboard>
|
||||
<ThicknessAnimation Storyboard.TargetProperty="Margin" To="-1,0,0,0"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState Name="DockRight">
|
||||
<Storyboard>
|
||||
<ThicknessAnimation Storyboard.TargetProperty="Margin" To="0,0,0,-1"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState Name="DockBottom">
|
||||
<Storyboard>
|
||||
<ThicknessAnimation Storyboard.TargetProperty="Margin" To="-1,0,0,0"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<ContentPresenter
|
||||
Name="presenter"
|
||||
Grid.Column="1"
|
||||
ContentSource="Header"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
RecognizesAccessKey="True"
|
||||
/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="FlatTabItem" TargetType="TabItem" BasedOn="{StaticResource FlatTabItemBase}">
|
||||
<Setter Property="MinWidth" Value="60"/>
|
||||
<Setter Property="HeaderTemplate" Value="{StaticResource CenteredTextTemplate}"/>
|
||||
</Style>
|
||||
|
||||
<ControlTemplate x:Key="FlatTabControlTemplate" TargetType="TabControl">
|
||||
<Grid KeyboardNavigation.TabNavigation="Local">
|
||||
<u:StateManager.VisualState>
|
||||
<Binding Path="TabStripPlacement" RelativeSource="{RelativeSource AncestorType=TabControl}">
|
||||
<Binding.Converter>
|
||||
<cv:AppendTextConverter Prefix="TabStrip"/>
|
||||
</Binding.Converter>
|
||||
</Binding>
|
||||
</u:StateManager.VisualState>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup Name="TabStripPlacementStates">
|
||||
<VisualState Name="TabStripLeft">
|
||||
<Storyboard>
|
||||
<!--Tab Strip-->
|
||||
<Int32Animation Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="(Grid.Column)" BeginTime="0" Duration="0" To="0"/>
|
||||
<Int32Animation Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="(Grid.ColumnSpan)" BeginTime="0" Duration="0" To="1"/>
|
||||
<ThicknessAnimation Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="Margin" BeginTime="0" Duration="0" To="0,4,-1,0"/>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="HorizontalAlignment">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static HorizontalAlignment.Right}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="VerticalAlignment">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static VerticalAlignment.Top}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<!--Content-->
|
||||
<Int32Animation Storyboard.TargetName="PART_SelectedContentBorder" Storyboard.TargetProperty="(Grid.Column)" BeginTime="0" Duration="0" To="1"/>
|
||||
<Int32Animation Storyboard.TargetName="PART_SelectedContentBorder" Storyboard.TargetProperty="(Grid.ColumnSpan)" BeginTime="0" Duration="0" To="2"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState Name="TabStripTop">
|
||||
<Storyboard>
|
||||
<!--Tab Strip-->
|
||||
<Int32Animation Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="(Grid.Row)" BeginTime="0" Duration="0" To="0"/>
|
||||
<Int32Animation Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="(Grid.RowSpan)" BeginTime="0" Duration="0" To="1"/>
|
||||
<ThicknessAnimation Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="Margin" BeginTime="0" Duration="0" To="4,0,0,-1"/>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="HorizontalAlignment">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static HorizontalAlignment.Left}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="VerticalAlignment">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static VerticalAlignment.Bottom}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<!--Content-->
|
||||
<Int32Animation Storyboard.TargetName="PART_SelectedContentBorder" Storyboard.TargetProperty="(Grid.Row)" BeginTime="0" Duration="0" To="1"/>
|
||||
<Int32Animation Storyboard.TargetName="PART_SelectedContentBorder" Storyboard.TargetProperty="(Grid.RowSpan)" BeginTime="0" Duration="0" To="2"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState Name="TabStripRight">
|
||||
<Storyboard>
|
||||
<!--Tab Strip-->
|
||||
<Int32Animation Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="(Grid.Column)" BeginTime="0" Duration="0" To="2"/>
|
||||
<Int32Animation Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="(Grid.ColumnSpan)" BeginTime="0" Duration="0" To="1"/>
|
||||
<ThicknessAnimation Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="Margin" BeginTime="0" Duration="0" To="-1,4,0,0"/>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="HorizontalAlignment">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static HorizontalAlignment.Left}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="VerticalAlignment">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static VerticalAlignment.Top}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<!--Content-->
|
||||
<Int32Animation Storyboard.TargetName="PART_SelectedContentBorder" Storyboard.TargetProperty="(Grid.Column)" BeginTime="0" Duration="0" To="0"/>
|
||||
<Int32Animation Storyboard.TargetName="PART_SelectedContentBorder" Storyboard.TargetProperty="(Grid.ColumnSpan)" BeginTime="0" Duration="0" To="2"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState Name="TabStripBottom">
|
||||
<Storyboard>
|
||||
<!--Tab Strip-->
|
||||
<Int32Animation Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="(Grid.Row)" BeginTime="0" Duration="0" To="1"/>
|
||||
<Int32Animation Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="(Grid.RowSpan)" BeginTime="0" Duration="0" To="1"/>
|
||||
<Int32Animation Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="(Grid.ColumnSpan)" BeginTime="0" Duration="0" To="2"/>
|
||||
<ThicknessAnimation Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="Margin" BeginTime="0" Duration="0" To="4,-1,0,0"/>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="HorizontalAlignment">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static HorizontalAlignment.Left}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderPanel" Storyboard.TargetProperty="VerticalAlignment">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static VerticalAlignment.Top}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<!--Content-->
|
||||
<Int32Animation Storyboard.TargetName="PART_SelectedContentBorder" Storyboard.TargetProperty="(Grid.Row)" BeginTime="0" Duration="0" To="0"/>
|
||||
<Int32Animation Storyboard.TargetName="PART_SelectedContentBorder" Storyboard.TargetProperty="(Grid.RowSpan)" BeginTime="0" Duration="0" To="1"/>
|
||||
<Int32Animation Storyboard.TargetName="PART_SelectedContentBorder" Storyboard.TargetProperty="(Grid.ColumnSpan)" BeginTime="0" Duration="0" To="2"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TabPanel
|
||||
x:Name="HeaderPanel"
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="3"
|
||||
Grid.ColumnSpan="3"
|
||||
Panel.ZIndex="1"
|
||||
KeyboardNavigation.TabIndex="1"
|
||||
Background="{u:Brush {StaticResource Control.SuperLightGrayColor}}"
|
||||
IsItemsHost="True"
|
||||
/>
|
||||
<Border
|
||||
x:Name="PART_SelectedContentBorder"
|
||||
Grid.Row="1"
|
||||
Grid.RowSpan="3"
|
||||
Grid.ColumnSpan="3"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
KeyboardNavigation.TabNavigation="Local"
|
||||
KeyboardNavigation.DirectionalNavigation="Contained"
|
||||
KeyboardNavigation.TabIndex="2"
|
||||
>
|
||||
<ContentPresenter
|
||||
x:Name="PART_SelectedContentHost"
|
||||
ContentSource="SelectedContent"
|
||||
/>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="FlatTabControl" TargetType="TabControl">
|
||||
<Setter Property="Background" Value="{u:Brush}"/>
|
||||
<Setter Property="BorderBrush" Value="{u:Brush {StaticResource Control.MediumDarkGrayColor}}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="ItemContainerStyle" Value="{StaticResource FlatTabItem}"/>
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
<Setter Property="TabStripPlacement" Value="Top"/>
|
||||
<Setter Property="Template" Value="{StaticResource FlatTabControlTemplate}"/>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -150,6 +150,8 @@
|
||||
|
||||
<Color x:Key="HeaderBackgroundBorderColor">#FFAAD1FF</Color>
|
||||
<Style x:Key="BTSDialog" TargetType="{x:Type Window}" BasedOn="{StaticResource BTSWindow}">
|
||||
<Setter Property="AllowsTransparency" Value="True"/>
|
||||
<!--<Setter Property="Background" Value="Transparent"/>-->
|
||||
<Setter Property="MinHeight" Value="100" />
|
||||
<Setter Property="MinWidth" Value="100" />
|
||||
<Setter Property="Template">
|
||||
@@ -162,6 +164,11 @@
|
||||
<RowDefinition Height="1" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Rectangle Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<Rectangle.Fill>
|
||||
<SolidColorBrush Color="#01000000"/>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Stretch" Orientation="Horizontal">
|
||||
<Image SnapsToDevicePixels="True" Height="14" Margin="4,2" VerticalAlignment="Center" HorizontalAlignment="Left" Stretch="Uniform" Source="{TemplateBinding Icon}" RenderOptions.BitmapScalingMode="HighQuality" />
|
||||
<TextBlock Text="{TemplateBinding Title}" VerticalAlignment="Center" HorizontalAlignment="Stretch" x:Name="_title" />
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ice="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
|
||||
xmlns:orderbook="clr-namespace:bts.shell.orderbook"
|
||||
xmlns:pnl="clr-namespace:bts.shell.pnl"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:cv="clr-namespace:mbts.ui.converters"
|
||||
@@ -18,20 +19,6 @@
|
||||
Style="{StaticResource BTSDialog}"
|
||||
UseLayoutRounding="True"
|
||||
>
|
||||
<Window.MaxHeight>
|
||||
<Binding Path="SizeToContent" RelativeSource="{RelativeSource Self}">
|
||||
<Binding.Converter>
|
||||
<cv:WindowMaxHeightConverter SizeToContentThreshold="700"/>
|
||||
</Binding.Converter>
|
||||
</Binding>
|
||||
</Window.MaxHeight>
|
||||
<Window.MinHeight>
|
||||
<Binding Path="SizeToContent" RelativeSource="{RelativeSource Self}">
|
||||
<Binding.Converter>
|
||||
<cv:WindowMinHeightConverter SizeToContentThreshold="560"/>
|
||||
</Binding.Converter>
|
||||
</Binding>
|
||||
</Window.MinHeight>
|
||||
<Window.Resources>
|
||||
<!--Primitive Constants-->
|
||||
<sys:Double x:Key="VerticalPush1">4</sys:Double>
|
||||
@@ -47,12 +34,6 @@
|
||||
<cv:ValueMap x:Key="TabHeaderFontWeightConverter" Default="{u:FontWeight Normal}">
|
||||
<cv:KeyValue Key="{u:True}" Value="{u:FontWeight Bold}"/>
|
||||
</cv:ValueMap>
|
||||
<!--Action Menu Items View-->
|
||||
<CollectionViewSource x:Key="ActionMenuItemsView" Source="{Binding DataContext.action_menu_items, RelativeSource={RelativeSource AncestorType=usp:ShellSettingsDialog}}">
|
||||
<CollectionViewSource.GroupDescriptions>
|
||||
<PropertyGroupDescription PropertyName="group"/>
|
||||
</CollectionViewSource.GroupDescriptions>
|
||||
</CollectionViewSource>
|
||||
<!--Styles (Shared/Common)-->
|
||||
<DataTemplate x:Key="FontPickerTemplate">
|
||||
<c:FontPicker SelectedFontFamily="{Binding font_family}" SelectedFontSize="{Binding font_size}" SelectedFontWeight="{Binding font_weight}"/>
|
||||
@@ -112,6 +93,62 @@
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type pnl:PNLCellAppearanceVM}">
|
||||
<Grid VerticalAlignment="Top">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="{Binding Source={StaticResource VerticalPush1}}"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="{Binding Source={StaticResource VerticalPush1}}"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="name_col"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalPush2}}"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock VerticalAlignment="Center">Font</TextBlock>
|
||||
<c:PopupControl Grid.Column="2" Style="{StaticResource FontPickerPopupControl}"/>
|
||||
<TextBlock Grid.Row="2" VerticalAlignment="Center">Font Color (default)</TextBlock>
|
||||
<c:ColorPickerPopupWithOpacitySlider Grid.Row="2" Grid.Column="2" HorizontalAlignment="Stretch" SelectedColor="{Binding font_color.color}" Palettes="{Binding font_color.palettes}" CanUserEditOpacity="False"/>
|
||||
<TextBlock Grid.Row="4" VerticalAlignment="Center">Background</TextBlock>
|
||||
<c:ColorPickerPopupWithOpacitySlider Grid.Row="4" Grid.Column="2" HorizontalAlignment="Stretch" SelectedColor="{Binding background.color}" SelectedOpacity="{Binding background.opacity}" Palettes="{Binding background.palettes}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type pnl:PNLGroupRowAppearanceVM}">
|
||||
<Grid VerticalAlignment="Top">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="{Binding Source={StaticResource VerticalPush1}}"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="{Binding Source={StaticResource VerticalPush1}}"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="name_col"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalPush2}}"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock VerticalAlignment="Center">Font</TextBlock>
|
||||
<c:PopupControl Grid.Column="2" Style="{StaticResource FontPickerPopupControl}"/>
|
||||
<TextBlock Grid.Row="2" VerticalAlignment="Center">Font Color (default)</TextBlock>
|
||||
<c:ColorPickerPopupWithOpacitySlider Grid.Row="2" Grid.Column="2" HorizontalAlignment="Stretch" SelectedColor="{Binding font_color.color}" Palettes="{Binding font_color.palettes}" CanUserEditOpacity="False"/>
|
||||
<TabControl Grid.Row="4" Grid.ColumnSpan="3" ItemsSource="{Binding background_colors}">
|
||||
<TabControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding name}"/>
|
||||
</DataTemplate>
|
||||
</TabControl.ItemTemplate>
|
||||
<TabControl.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<c:ColorPickerPopupWithOpacitySlider Margin="4" HorizontalAlignment="Stretch" SelectedColor="{Binding color}" SelectedOpacity="{Binding opacity}" Palettes="{Binding palettes}"/>
|
||||
</DataTemplate>
|
||||
</TabControl.ContentTemplate>
|
||||
</TabControl>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<Style x:Key="CopyProfileTargetButton" TargetType="Button">
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Height" Value="22"/>
|
||||
@@ -210,10 +247,103 @@
|
||||
</u:StyleSelectorKeyValue>
|
||||
</u:KeyedStyleSelector>
|
||||
|
||||
<DataTemplate x:Key="AnchorItemContentTemplate">
|
||||
<Border Padding="4">
|
||||
<Grid>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup Name="IsComboBoxItemStates">
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Height="11">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Geometry="{Binding Source={StaticResource {x:Static u:Icons.KeyGeometryKey}}}" Brush="Gold"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="16,0,0,4" FontSize="8.5" Text="{Binding DataContext.anchor_index, RelativeSource={RelativeSource AncestorType=ComboBox}}">
|
||||
<TextBlock.Foreground>
|
||||
<SolidColorBrush Color="{x:Static anchor_color, MemberType={u:Nested u:BTSColors.PNL}}"/>
|
||||
</TextBlock.Foreground>
|
||||
<TextBlock.Visibility>
|
||||
<Binding RelativeSource="{RelativeSource AncestorType=ComboBoxItem}">
|
||||
<Binding.Converter>
|
||||
<cv:ValueConverterPipe>
|
||||
<StaticResource ResourceKey="IsNullConverter"/>
|
||||
<cv:BooleanToVisibilityConverter/>
|
||||
</cv:ValueConverterPipe>
|
||||
</Binding.Converter>
|
||||
</Binding>
|
||||
</TextBlock.Visibility>
|
||||
</TextBlock>
|
||||
<TextBlock Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Normal" Foreground="Gold" Text="{Binding}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="AnchorItemTemplate">
|
||||
<Border BorderBrush="Transparent" BorderThickness="4" Padding="6,8" Cursor="{StaticResource {x:Static u:CursorsEx.GrabKey}}">
|
||||
<u:StateManager.Groups>
|
||||
<u:StateGroupsManager AttachToMembers="True">
|
||||
<u:StateDefinitionCollection>
|
||||
<u:MouseStateDefinition MouseSource="{Binding Group.Target, RelativeSource={RelativeSource Self}}"/>
|
||||
</u:StateDefinitionCollection>
|
||||
</u:StateGroupsManager>
|
||||
</u:StateManager.Groups>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup Name="MouseStates">
|
||||
<VisualState Name="Normal"/>
|
||||
<VisualState Name="MouseOver"/>
|
||||
<VisualState Name="Pressed">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Cursor">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource {x:Static u:CursorsEx.GrabbingKey}}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ColorAnimation Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Duration="0" To="{x:Static u:BTSColors.header_alternate_color}"/>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<Border.Resources>
|
||||
<u:CursorsEx/>
|
||||
</Border.Resources>
|
||||
<Border.Background>
|
||||
<SolidColorBrush Color="{x:Static u:BTSColors.header_color}"/>
|
||||
</Border.Background>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Height="11">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing Geometry="{Binding Source={StaticResource {x:Static u:Icons.KeyGeometryKey}}}" Brush="Gold"/>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
</Image.Source>
|
||||
</Image>
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="16,0,0,-2" FontSize="8.5" Foreground="Gold" Text="{Binding anchor_index}"/>
|
||||
<TextBlock Grid.Column="1" Margin="6,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" FontWeight="Bold" Foreground="Gold" Text="{Binding}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
||||
<u:KeyedTemplateSelector x:Key="GridSettingsTemplateSelector">
|
||||
<u:TemplateSelectorKeyValue Key="{x:Static usp:GridSettingsTemplateKeys.SimpleGrid}">
|
||||
<DataTemplate>
|
||||
<usp:GridSettingsView/>
|
||||
<usp:GridSettingsView
|
||||
GridSectionContent="{Binding}"
|
||||
GridSectionContentTemplate="{StaticResource GridSectionCoreContentTemplate}"
|
||||
CellContentTemplate="{DynamicResource DefaultCellContentTemplate}"
|
||||
/>
|
||||
</DataTemplate>
|
||||
</u:TemplateSelectorKeyValue>
|
||||
<u:TemplateSelectorKeyValue Key="{x:Static usp:GridSettingsTemplateKeys.Ladder}">
|
||||
@@ -230,27 +360,27 @@
|
||||
<scm:SortDescription PropertyName="id"/>
|
||||
</CollectionViewSource.SortDescriptions>
|
||||
</CollectionViewSource>
|
||||
<SolidColorBrush x:Key="SeparatorFill" Color="Black"/>
|
||||
</Grid.Resources>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<!--Padding.Left-->
|
||||
<ColumnDefinition Width="8"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border Grid.ColumnSpan="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{StaticResource HeaderBackgroundBrush}" BorderBrush="{StaticResource HeaderBackgroundBorderBrush}" BorderThickness="1,0,1,1"/>
|
||||
<TextBlock Margin="8,0,0,0" VerticalAlignment="Center">Profile:</TextBlock>
|
||||
<ComboBox Grid.Column="1" Margin="8,4" ItemsSource="{Binding Source={StaticResource ProfilesViewSource}}" SelectedItem="{Binding selected_profile}" ItemTemplateSelector="{StaticResource ProfileItemTemplateSelector}">
|
||||
<Border Grid.ColumnSpan="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="{StaticResource HeaderBackgroundBrush}" BorderBrush="{StaticResource HeaderBackgroundBorderBrush}" BorderThickness="1,0,1,1"/>
|
||||
<TextBlock Grid.Column="1" VerticalAlignment="Center">Profile:</TextBlock>
|
||||
<ComboBox Grid.Column="2" Margin="8,4" ItemsSource="{Binding Source={StaticResource ProfilesViewSource}}" SelectedItem="{Binding selected_profile}" ItemTemplateSelector="{StaticResource ProfileItemTemplateSelector}">
|
||||
<ComboBox.GroupStyle>
|
||||
<GroupStyle ContainerStyle="{StaticResource ComboBox.DelineatedGroupContainerStyle.DynamicFill}"/>
|
||||
</ComboBox.GroupStyle>
|
||||
</ComboBox>
|
||||
<ToolBar Grid.Column="2" Background="Transparent" BorderThickness="0" Style="{StaticResource SparkToolBar}">
|
||||
<ToolBar.Resources>
|
||||
<Style x:Key="{x:Static ToolBar.ButtonStyleKey}" TargetType="Button" BasedOn="{StaticResource SparkToolBarButton}"/>
|
||||
</ToolBar.Resources>
|
||||
<ToolBar Grid.Column="3" Background="Transparent" BorderThickness="0" Style="{StaticResource SparkToolBar}">
|
||||
<u:StateManager.VisualState>
|
||||
<Binding Path="selected_profile.is_global">
|
||||
<Binding.Converter>
|
||||
@@ -279,48 +409,46 @@
|
||||
<VisualState Name="Global"/>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<!--<Menu>-->
|
||||
<Button Command="{Binding add_profile_cmd}" ToolTip="New Profile">
|
||||
<Button.Content>
|
||||
<MenuItem Command="{Binding add_profile_cmd}" ToolTip="New Profile">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{x:Static u:Icons.AddBoxes}"/>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator VerticalAlignment="Stretch" Width="1" Margin="2,2,1,2" Background="Gray"/>
|
||||
<Button x:Name="save_profile" Command="{Binding save_profile_cmd}" CommandParameter="{Binding selected_profile}">
|
||||
<Button.Content>
|
||||
<MenuItem x:Name="save_profile" Command="{Binding save_profile_cmd}" CommandParameter="{Binding selected_profile}">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{x:Static u:Icons.Disk}" HorizontalAlignment="Left" Margin="-1,0,0,0"/>
|
||||
</Button.Content>
|
||||
<Button.ToolTip>
|
||||
</MenuItem.Icon>
|
||||
<MenuItem.ToolTip>
|
||||
<TextBlock Text="{Binding selected_profile.name, StringFormat='Save \'{0}\''}"/>
|
||||
</Button.ToolTip>
|
||||
</Button>
|
||||
<Button Command="{Binding save_all_cmd}" ToolTip="Save All Profiles">
|
||||
<Button.Content>
|
||||
</MenuItem.ToolTip>
|
||||
</MenuItem>
|
||||
<MenuItem Command="{Binding save_all_cmd}" ToolTip="Save All Profiles">
|
||||
<MenuItem.Icon>
|
||||
<Grid>
|
||||
<Image Source="{x:Static u:Icons.Disk}" HorizontalAlignment="Left" VerticalAlignment="Bottom" Height="10"/>
|
||||
<Image Source="{x:Static u:Icons.Disk}" HorizontalAlignment="Right" VerticalAlignment="Top" Height="10"/>
|
||||
</Grid>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
<Button x:Name="rename_profile" Width="10" Command="{Binding save_profile_as_cmd}" CommandParameter="{Binding selected_profile}">
|
||||
<Button.Content>
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem x:Name="rename_profile" Width="10" Command="{Binding save_profile_as_cmd}" CommandParameter="{Binding selected_profile}">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{x:Static u:Icons.Pencil}" HorizontalAlignment="Left" Margin="-1,0,0,0"/>
|
||||
</Button.Content>
|
||||
<Button.ToolTip>
|
||||
</MenuItem.Icon>
|
||||
<MenuItem.ToolTip>
|
||||
<TextBlock Text="{Binding selected_profile.name, StringFormat='Rename \'{0}\''}"/>
|
||||
</Button.ToolTip>
|
||||
</Button>
|
||||
<Button x:Name="revert_profile" Command="{Binding revert_profile_cmd}" CommandParameter="{Binding selected_profile}">
|
||||
<Button.Content>
|
||||
</MenuItem.ToolTip>
|
||||
</MenuItem>
|
||||
<MenuItem x:Name="revert_profile" Command="{Binding revert_profile_cmd}" CommandParameter="{Binding selected_profile}">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{x:Static u:Icons.UndoCircular}"/>
|
||||
</Button.Content>
|
||||
<Button.ToolTip>
|
||||
</MenuItem.Icon>
|
||||
<MenuItem.ToolTip>
|
||||
<TextBlock Text="{Binding selected_profile.name, StringFormat='Undo Changes To \'{0}\''}"/>
|
||||
</Button.ToolTip>
|
||||
</Button>
|
||||
<!--</Menu>-->
|
||||
</MenuItem.ToolTip>
|
||||
</MenuItem>
|
||||
<Separator VerticalAlignment="Stretch" Width="1" Margin="2,2,1,2" Background="Gray"/>
|
||||
<c:PopupControl ShowExpanderArrow="False" IsOpen="{Binding is_copy_menu_open, Mode=TwoWay}" ButtonStyle="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
|
||||
<c:PopupControl ShowExpanderArrow="False" IsOpen="{Binding is_copy_menu_open, Mode=TwoWay}">
|
||||
<c:PopupControl.Header>
|
||||
<Image Source="{x:Static u:Icons.CopyWF}"/>
|
||||
</c:PopupControl.Header>
|
||||
@@ -398,7 +526,6 @@
|
||||
ShowDialogSkirt="True"
|
||||
Style="{StaticResource SparkToolBarItem}"
|
||||
OKClick="{x:Static c:ContractPickerPopup.FlushSelectedCriteriaHandler}"
|
||||
ButtonStyle="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
|
||||
>
|
||||
<c:ContractPickerPopup.Header>
|
||||
<Image Source="{x:Static u:Icons.HandPointingOverDocument}"/>
|
||||
@@ -411,39 +538,193 @@
|
||||
</TextBlock>
|
||||
</c:ContractPickerPopup.ToolTip>
|
||||
</c:ContractPickerPopup>
|
||||
<Button x:Name="delete_profile" Command="{Binding delete_profile_cmd}" CommandParameter="{Binding selected_profile}">
|
||||
<Image Source="{x:Static u:Icons.Trash}"/>
|
||||
<Button.ToolTip>
|
||||
<MenuItem x:Name="delete_profile" Command="{Binding delete_profile_cmd}" CommandParameter="{Binding selected_profile}">
|
||||
<MenuItem.Icon>
|
||||
<Image Source="{x:Static u:Icons.Trash}"/>
|
||||
</MenuItem.Icon>
|
||||
<MenuItem.ToolTip>
|
||||
<TextBlock Text="{Binding selected_profile.name, StringFormat='Delete \'{0}\''}"/>
|
||||
</Button.ToolTip>
|
||||
</Button>
|
||||
</MenuItem.ToolTip>
|
||||
</MenuItem>
|
||||
<Separator VerticalAlignment="Stretch" Width="1" Margin="2,2,1,2" Background="Gray"/>
|
||||
<c:ActionMenu
|
||||
Grid.Column="2"
|
||||
VerticalAlignment="Stretch"
|
||||
Margin="0,0,4,0"
|
||||
ItemsSource="{Binding Source={StaticResource ActionMenuItemsView}}"
|
||||
Style="{StaticResource SparkToolBarItem}"
|
||||
>
|
||||
<c:ActionMenu.GroupStyle>
|
||||
<GroupStyle ContainerStyle="{StaticResource ComboBox.DelineatedGroupContainerStyle.DynamicFill}"/>
|
||||
</c:ActionMenu.GroupStyle>
|
||||
</c:ActionMenu>
|
||||
<c:ActionMenu Grid.Column="4" HorizontalAlignment="Right" Margin="0,0,4,0" ItemsSource="{Binding action_menu_items}" Style="{StaticResource SparkToolBarItem}"/>
|
||||
</ToolBar>
|
||||
<usp:LadderSettingsView Grid.Row="1" Grid.ColumnSpan="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" DataContext="{Binding selected_profile.value}"/>
|
||||
<usp:LadderSettingsView Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" HorizontalAlignment="Left" Width="758" MinHeight="234" Margin="0,10,8,0" DataContext="{Binding selected_profile.value}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</u:TemplateSelectorKeyValue>
|
||||
<u:TemplateSelectorKeyValue Key="{x:Static usp:GridSettingsTemplateKeys.OrderBook}">
|
||||
<DataTemplate DataType="{x:Type orderbook:OrderBookSettingsVM}">
|
||||
<usp:OrderBookSettingsView/>
|
||||
</DataTemplate>
|
||||
<DataTemplate DataType="{x:Type orderbook:OrderBookSettingsVM}">
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
|
||||
<usp:OrderBookSettingsView/>
|
||||
</ScrollViewer>
|
||||
</DataTemplate>
|
||||
</u:TemplateSelectorKeyValue>
|
||||
<u:TemplateSelectorKeyValue Key="{x:Static usp:GridSettingsTemplateKeys.PNL}">
|
||||
<DataTemplate>
|
||||
<usp:PNLSettingsView/>
|
||||
</DataTemplate>
|
||||
</u:TemplateSelectorKeyValue>
|
||||
<u:TemplateSelectorKeyValue Key="BahBahBlackSheep">
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<c:ActionMenu HorizontalAlignment="Right" Margin="0,2,0,0" ItemsSource="{Binding DataContext.action_menu_items, RelativeSource={RelativeSource AncestorType=usp:ShellSettingsDialog}}"/>
|
||||
<usp:GridSettingsView
|
||||
Grid.Row="1"
|
||||
DataContext="{Binding core_settings_vm}"
|
||||
GridSectionContent="{Binding DataContext.instance_vm, RelativeSource={RelativeSource AncestorType=usp:ShellSettingsDialog}}"
|
||||
CellContentTemplate="{DynamicResource PNLCellContentTemplate}"
|
||||
>
|
||||
<usp:GridSettingsView.GridSectionContentTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalPush3}}"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TabControl Grid.IsSharedSizeScope="True" VerticalAlignment="Top" Height="150" Padding="10">
|
||||
<TabItem Header="Grouping" Content="{Binding}">
|
||||
<TabItem.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<GroupBox Grid.Column="3" Grid.RowSpan="3" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">
|
||||
<GroupBox.Resources>
|
||||
<u:CursorsEx/>
|
||||
</GroupBox.Resources>
|
||||
<GroupBox.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock>Grouping</TextBlock>
|
||||
<c:HelpButton>
|
||||
<c:HelpButton.Resources>
|
||||
<Style x:Key="HelpButtonToolTipStyleKey" TargetType="ToolTip">
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<TextBlock>
|
||||
<Run>Check the group parameters you would like to use.</Run>
|
||||
<LineBreak/>
|
||||
<Run FontStyle="Italic">Hint: drag/drop the items below to change the grouping hierarchy.</Run>
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</c:HelpButton.Resources>
|
||||
</c:HelpButton>
|
||||
<ItemsControl ItemsSource="{Binding anchor_item_headers}" ItemsPanel="{StaticResource HorizontalItemsPanelTemplate}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<CheckBox Margin="4,0,0,0" Content="{Binding key}" ContentTemplate="{StaticResource EnumDescriptionTemplate}" IsChecked="{Binding include}"/>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</GroupBox.Header>
|
||||
<ItemsControl
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
AllowDrop="True"
|
||||
ItemsSource="{Binding anchor_items}"
|
||||
ItemTemplate="{StaticResource AnchorItemTemplate}"
|
||||
ItemsPanel="{StaticResource HorizontalItemsPanelTemplate}"
|
||||
Loaded="_pnl_anchor_items_loaded"
|
||||
/>
|
||||
</GroupBox>
|
||||
</DataTemplate>
|
||||
</TabItem.ContentTemplate>
|
||||
</TabItem>
|
||||
<TabItem Header="Grid" Content="{Binding core_settings_vm}">
|
||||
<TabItem.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<Grid VerticalAlignment="Top">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="{Binding Source={StaticResource VerticalPush1}}"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="{Binding Source={StaticResource VerticalPush1}}"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="{Binding Source={StaticResource VerticalPush1}}"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="name_col"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalPush2}}"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock VerticalAlignment="Center">Font</TextBlock>
|
||||
<c:PopupControl Grid.Column="2" HorizontalAlignment="Stretch" Style="{StaticResource FontPickerPopupControl}"/>
|
||||
<TextBlock Grid.Row="2" VerticalAlignment="Center">Font Color (default)</TextBlock>
|
||||
<c:ColorPickerPopupWithOpacitySlider Grid.Row="2" Grid.Column="2" HorizontalAlignment="Stretch" DataContext="{Binding font_color}" CanUserEditOpacity="False"/>
|
||||
<TextBlock Grid.Row="4" VerticalAlignment="Center">Selection Highlight</TextBlock>
|
||||
<c:ColorPickerPopupWithOpacitySlider Grid.Row="4" Grid.Column="2" HorizontalAlignment="Stretch" DataContext="{Binding selection_highlight}"/>
|
||||
<TextBlock Grid.Row="6" VerticalAlignment="Center">Background</TextBlock>
|
||||
<c:ColorPickerPopupWithOpacitySlider
|
||||
Grid.Row="6"
|
||||
Grid.Column="2"
|
||||
HorizontalAlignment="Stretch"
|
||||
SelectedColor="{Binding background.color}"
|
||||
SelectedOpacity="{Binding background.opacity}"
|
||||
Palettes="{Binding background.palettes}"
|
||||
/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</TabItem.ContentTemplate>
|
||||
</TabItem>
|
||||
<TabItem Header="Group Row Defaults" Content="{Binding group_row_defaults}"/>
|
||||
<TabItem Header="Header Row Display" Content="{Binding}">
|
||||
<TabItem.ContentTemplate>
|
||||
<DataTemplate DataType="{x:Type pnl:PNLSettingsVM}">
|
||||
<Grid VerticalAlignment="Top">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="{Binding Source={StaticResource VerticalPush1}}"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="name_col"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalPush2}}" MaxWidth="{Binding Source={StaticResource HorizontalPush2}}"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ContentControl Grid.ColumnSpan="3" Content="{Binding header_row_defaults}"/>
|
||||
<TextBlock Grid.Row="2" VerticalAlignment="Center">Display</TextBlock>
|
||||
<ComboBox Grid.Row="2" Grid.Column="2" HorizontalAlignment="Stretch" ItemsSource="{Binding header_row_display_options}" ItemTemplate="{StaticResource EnumFlagsDescriptionTemplate}" SelectedItem="{Binding header_row_display}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</TabItem.ContentTemplate>
|
||||
</TabItem>
|
||||
<TabItem Header="Calculation" Content="{Binding}">
|
||||
<TabItem.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<Grid VerticalAlignment="Top">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="name_col"/>
|
||||
<ColumnDefinition Width="{Binding Source={StaticResource HorizontalPush2}}"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock VerticalAlignment="Center">Calculation</TextBlock>
|
||||
<ComboBox
|
||||
Grid.Column="2"
|
||||
HorizontalAlignment="Stretch"
|
||||
ItemsSource="{Binding calculation_types}"
|
||||
SelectedItem="{Binding calculation_type}"
|
||||
ItemTemplate="{StaticResource EnumDescriptionTemplate}"
|
||||
/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</TabItem.ContentTemplate>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</usp:GridSettingsView.GridSectionContentTemplate>
|
||||
</usp:GridSettingsView>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</u:TemplateSelectorKeyValue>
|
||||
</u:KeyedTemplateSelector>
|
||||
</Window.Resources>
|
||||
<Grid x:Name="root_grid">
|
||||
@@ -452,7 +733,7 @@
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ContentControl
|
||||
VerticalAlignment="Stretch"
|
||||
VerticalAlignment="Top"
|
||||
HorizontalAlignment="Stretch"
|
||||
Content="{Binding instance_vm}"
|
||||
ContentTemplateSelector="{StaticResource GridSettingsTemplateSelector}"
|
||||
@@ -463,6 +744,15 @@
|
||||
LeftItemContainerStyleSelector="{StaticResource LeftButtonStyleSelector}"
|
||||
RightItems="{Binding right_skirt_items}"
|
||||
BorderThickness="0"
|
||||
/>
|
||||
>
|
||||
<!--<c:DialogSkirt.Background>
|
||||
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
|
||||
<LinearGradientBrush.GradientStops>
|
||||
<GradientStop Color="Transparent"/>
|
||||
<GradientStop Color="{x:Static u:BTSColors.dialog_skirt}" Offset="1"/>
|
||||
</LinearGradientBrush.GradientStops>
|
||||
</LinearGradientBrush>
|
||||
</c:DialogSkirt.Background>-->
|
||||
</c:DialogSkirt>
|
||||
</Grid>
|
||||
</Window>
|
||||
</Window>
|
||||
@@ -1,4 +1,14 @@
|
||||
using System.Windows;
|
||||
using bts.shell.pnl;
|
||||
using mbts.utils;
|
||||
using mbts.ui.extensions;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using mbts.ui.controls.adorners;
|
||||
|
||||
namespace mbts.ui.spark {
|
||||
/// <summary>
|
||||
@@ -14,6 +24,102 @@ namespace mbts.ui.spark {
|
||||
LocalProfileItemTemplateKey = "LocalProfileItemTemplate",
|
||||
SaveAsStyleKey = "SaveAsStyle",
|
||||
SecurityMapKey = "SecurityMap";
|
||||
|
||||
#region PNL
|
||||
// TODO: need to break up ShellSettingsDialog components into smaller parts, so the various settings dialogs can be more easily customized.
|
||||
// Until then, certain esoteric behaviors for specific dialogs (e.g., pnl anchor items drag/drop behavior) will reside in this class.
|
||||
IDisposable _pnl_anchor_items_drag_drop_behavior;
|
||||
|
||||
void _pnl_anchor_items_loaded(object sender, RoutedEventArgs e) {
|
||||
// connecting this drag/drop behavior is idempotent, just in case Loaded happens twice
|
||||
Disposable.dispose(ref _pnl_anchor_items_drag_drop_behavior);
|
||||
if (!(sender is ItemsControl ic))
|
||||
return;
|
||||
bool is_dragging = false;
|
||||
IDisposable drag_op = null;
|
||||
var cursor_resources = new Lazy<CursorsEx>();
|
||||
_pnl_anchor_items_drag_drop_behavior = Disposable.Create(() => Disposable.dispose(ref drag_op));
|
||||
DragDropHelper.subscribe_drag_start(ic).Subscribe(pt => {
|
||||
if (!is_dragging &&
|
||||
ic.InputHitTest(pt) is DependencyObject d &&
|
||||
ic.ContainerFromElement(d) is FrameworkElement item_view &&
|
||||
ic.ItemContainerGenerator.ItemFromContainer(item_view) is object item &&
|
||||
item != DependencyProperty.UnsetValue) {
|
||||
//
|
||||
item_view.SetCurrentValue(OpacityProperty, 0.5);
|
||||
is_dragging = true;
|
||||
var sz = item_view.RenderSize;
|
||||
var dv = new DrawingVisual();
|
||||
using (var dc = dv.RenderOpen())
|
||||
dc.DrawRoundedRectangle(new VisualBrush(item_view) { Stretch = Stretch.Uniform }, null, new Rect(sz), 0, 0);
|
||||
SetCurrentValue(CursorProperty, Cursors.ScrollWE);
|
||||
SetCurrentValue(AllowDropProperty, true);
|
||||
is_dragging = true;
|
||||
Disposable.replace(ref drag_op, new CompositeDisposable {
|
||||
MouseTraceAdorner.trace_drag(root_grid, dv, sz),
|
||||
DragDropHelper.connect_horizontal_insertion_adorner(ic, root_grid),
|
||||
this.SubscribePreviewDrop(on_drop),
|
||||
this.SubscribePreviewMouseUp(on_preview_mouse_up),
|
||||
this.SubscribePreviewDragOver(on_drag),
|
||||
this.SubscribePreviewDragLeave(on_drag),
|
||||
this.SubscribePreviewDragEnter(on_drag),
|
||||
() => {
|
||||
ClearValue(CursorProperty);
|
||||
ClearValue(AllowDropProperty);
|
||||
item_view.ClearValue(OpacityProperty);
|
||||
is_dragging = false;
|
||||
}});
|
||||
DragDrop.DoDragDrop(this, new DataObject(DataFormats.StringFormat, item), DragDropEffects.Move);
|
||||
}
|
||||
});
|
||||
|
||||
void on_drag(object s, DragEventArgs de) =>
|
||||
de.Effects = DragDropEffects.Move;
|
||||
|
||||
void on_drop(object _, DragEventArgs drop_e) {
|
||||
drop_e.Handled = true;
|
||||
if (!is_dragging)
|
||||
return;
|
||||
Disposable.dispose(ref drag_op);
|
||||
if (drop_e.Data.GetDataPresent(DataFormats.StringFormat) &&
|
||||
drop_e.Data.GetData(DataFormats.StringFormat) is PNLSettingsVM.AnchorItemVM from &&
|
||||
ic.ItemsSource is ObservableCollection<PNLSettingsVM.AnchorItemVM> anchor_items &&
|
||||
anchor_items.Count > 1) {
|
||||
//
|
||||
var pt = drop_e.GetPosition(this);
|
||||
if (!(InputHitTest(pt) is DependencyObject hit))
|
||||
return;
|
||||
int from_i = anchor_items.IndexOf(from);
|
||||
// Set the container to the first item who's right edge is left of pt.X (or the last item if none satisfy that condition).
|
||||
// The logic presumes that the items are laid out in a single, horizontal line, from left to right
|
||||
// (not the most elegant way to get the drop target, but it's effective).
|
||||
int to_i = -1;
|
||||
if (!(ic.ContainerFromElement(hit) is FrameworkElement drop_target)) {
|
||||
for (to_i = 0; to_i < ic.Items.Count; to_i++) {
|
||||
if (ic.ItemContainerGenerator.ContainerFromIndex(to_i) is FrameworkElement c) {
|
||||
drop_target = c;
|
||||
var tl = c.TranslatePoint(new Point(0, 0), this);
|
||||
var right_edge = tl.X + c.ActualWidth;
|
||||
if (right_edge >= pt.X)
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (drop_target.DataContext is PNLSettingsVM.AnchorItemVM to) {
|
||||
to_i = anchor_items.IndexOf(to);
|
||||
}
|
||||
if (to_i < 0)
|
||||
return;
|
||||
if (to_i >= anchor_items.Count)
|
||||
to_i = anchor_items.Count - 1;
|
||||
if (from_i >= 0)
|
||||
anchor_items.Move(from_i, to_i);
|
||||
}
|
||||
}
|
||||
|
||||
void on_preview_mouse_up(object _, MouseButtonEventArgs __) =>
|
||||
Disposable.dispose(ref drag_op);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
static class GridSettingsTemplateKeys {
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace bts.spark {
|
||||
public virtual double MinWidth => 400;
|
||||
public virtual double MinHeight => Math.Max(ABSOLUTE_MIN_HEIGHT, TITLE_PANEL_HEIGHT + COLUMN_HEADER_HEIGHT + GRID_FOOTER_HEIGHT + Commands.Count() * SPARK_MENU_ITEM_HEIGHT);
|
||||
|
||||
public IObservable<string> literal_title_source {
|
||||
protected IObservable<string> literal_title_source {
|
||||
get {
|
||||
if (_literal_title_source == null) {
|
||||
if (_shell_window_vm != null)
|
||||
|
||||
@@ -3,12 +3,7 @@
|
||||
namespace mbts.ui {
|
||||
class BindingProxy : FrameworkElement {
|
||||
public static readonly DependencyProperty ValueProperty =
|
||||
DependencyProperty.Register(nameof(Value), typeof(object), typeof(BindingProxy), new PropertyMetadata(OnValueChanged));
|
||||
|
||||
static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) =>
|
||||
((BindingProxy)d).ValueChanged?.Invoke(d, e);
|
||||
|
||||
public event DependencyPropertyChangedEventHandler ValueChanged;
|
||||
DependencyProperty.Register(nameof(Value), typeof(object), typeof(BindingProxy));
|
||||
|
||||
public object Value {
|
||||
get => GetValue(ValueProperty);
|
||||
|
||||
@@ -24,19 +24,6 @@ namespace mbts.ui.utility {
|
||||
return Enum.GetValues(t);
|
||||
}
|
||||
|
||||
// TODO: avoid boxing
|
||||
public static T add_flags<T>(T value, T flags) where T : struct {
|
||||
var v = (long)(object)value;
|
||||
var f = (long)(object)flags;
|
||||
return (T)(object)(v | f);
|
||||
}
|
||||
|
||||
public static T remove_flags<T>(T value, T flags) where T : struct {
|
||||
var v = (long)(object)value;
|
||||
var f = (long)(object)flags;
|
||||
return (T)(object)((v ^ f) & v);
|
||||
}
|
||||
|
||||
public static T parse<T>(string name) where T : struct /*(Enum, more specifically)*/ {
|
||||
if (!typeof(T).IsEnum) throw new InvalidOperationException($"{typeof(T)} is not an enum type.");
|
||||
if (!Enum.TryParse(name, true, out T result)) throw new ArgumentException(nameof(name), "Does not match any of the values");
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using mbts.utils;
|
||||
using mbts.ui.shell;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -37,6 +38,126 @@ namespace bts.utils {
|
||||
name;
|
||||
}
|
||||
|
||||
class NamedVM : ViewModelBase, IEquatable<NamedVM> {
|
||||
string _name;
|
||||
|
||||
public NamedVM() { }
|
||||
|
||||
public NamedVM(string name) =>
|
||||
this.name = name;
|
||||
|
||||
public NamedVM(string name, bool is_read_only) {
|
||||
this.name = name;
|
||||
this.is_read_only = is_read_only;
|
||||
}
|
||||
|
||||
public bool is_read_only { get; }
|
||||
|
||||
public string name {
|
||||
get => _name;
|
||||
set {
|
||||
_assert_can_write();
|
||||
Set(ref _name, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Equals(NamedVM other) =>
|
||||
other != null &&
|
||||
name == other.name;
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
is_read_only ?
|
||||
Equals(obj as NamedVM) :
|
||||
base.Equals(obj);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
is_read_only ?
|
||||
_name == null ? 0 : _name.GetHashCode() :
|
||||
base.GetHashCode();
|
||||
|
||||
void _assert_can_write() {
|
||||
if (is_read_only)
|
||||
throw new InvalidOperationException("NamedVM is read only.");
|
||||
}
|
||||
}
|
||||
|
||||
class NamedVM<T> : ViewModelBase, IEquatable<NamedVM<T>> {
|
||||
string _name;
|
||||
T _value;
|
||||
|
||||
public NamedVM() { }
|
||||
|
||||
public NamedVM(string name) =>
|
||||
_name = name;
|
||||
|
||||
public NamedVM(string name, T value)
|
||||
: this(name) => _value = value;
|
||||
|
||||
public NamedVM(string name, T value, bool is_name_read_only, bool is_value_read_only)
|
||||
: this(name, value) {
|
||||
this.is_name_read_only = is_name_read_only;
|
||||
this.is_value_read_only = is_value_read_only;
|
||||
}
|
||||
|
||||
public bool is_name_read_only { get; }
|
||||
public bool is_value_read_only { get; }
|
||||
|
||||
public string name {
|
||||
get => _name;
|
||||
set {
|
||||
if (is_name_read_only)
|
||||
throw ExceptionBuilder.InvalidOperation.is_read_only();
|
||||
Set(ref _name, value);
|
||||
}
|
||||
}
|
||||
|
||||
public T value {
|
||||
get => _value;
|
||||
set {
|
||||
if (is_value_read_only)
|
||||
throw ExceptionBuilder.InvalidOperation.is_read_only();
|
||||
Set(ref _value, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Equals(NamedVM<T> other) =>
|
||||
other != null &&
|
||||
name == other.name &&
|
||||
EqualityComparer<T>.Default.Equals(value, other.value);
|
||||
|
||||
public override bool Equals(object obj) {
|
||||
if (obj == this)
|
||||
return true;
|
||||
/// 'this' and 'obj' must be entirely non-mutable (<see cref="is_name_read_only"/>, <see cref="is_value_read_only"/>)
|
||||
/// to be considered equivalent, in addition to having equal <see cref="value"/> and <see cref="name"/> members.
|
||||
if (!(obj is NamedVM<T> other))
|
||||
return false;
|
||||
return is_value_read_only && is_name_read_only &&
|
||||
other.is_name_read_only && other.is_value_read_only &&
|
||||
name == other.name && EqualityComparer<T>.Default.Equals(value, other.value);
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
// There are 2 main components to hash: name and value.
|
||||
// Each shall use 16 bits of the 32 available to create the hash code.
|
||||
// Both components also have a corresponding 'is_read_only' property,
|
||||
// which shall be represented as a flag in the first bit of the 16 appropriated to each component.
|
||||
// If a component is not read only, it must not be included in the hash code (technically, it will be represented as a constant: 0).
|
||||
int hash = 0;
|
||||
if (is_name_read_only) {
|
||||
hash |= 1;
|
||||
if (name != null)
|
||||
hash |= ((name.GetHashCode() % (1 << 14)) << 1);
|
||||
}
|
||||
if (is_value_read_only) {
|
||||
hash |= (1 << 16);
|
||||
if (value != null)
|
||||
hash |= ((value.GetHashCode() % (1 << 14)) << 17);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
readonly struct Overridable<T> : IEquatable<Overridable<T>> {
|
||||
public readonly T value, default_value;
|
||||
public readonly bool is_overridden, can_override;
|
||||
|
||||
@@ -115,26 +115,26 @@ namespace mbts.ui {
|
||||
}
|
||||
}
|
||||
|
||||
class BooleanStateDefinition : StateDefinition {
|
||||
class CheckedStateDefinition : StateDefinition {
|
||||
public static readonly Func<FrameworkElement, FrameworkElement> FindMenuItemAncestor =
|
||||
target => target?.find_ancestor_of_type<MenuItem>();
|
||||
|
||||
IDisposable _source_hook;
|
||||
bool _value;
|
||||
IDisposable _checkable_source_hook;
|
||||
bool _is_checked;
|
||||
|
||||
static BooleanStateDefinition() {
|
||||
StateProperty.OverrideMetadata(typeof(BooleanStateDefinition), StateProperty.DefaultMetadata.with(coerce_state));
|
||||
static CheckedStateDefinition() {
|
||||
StateProperty.OverrideMetadata(typeof(CheckedStateDefinition), StateProperty.DefaultMetadata.with(coerce_state));
|
||||
object coerce_state(DependencyObject d, object baseValue) {
|
||||
var csd = (BooleanStateDefinition)d;
|
||||
var csd = (CheckedStateDefinition)d;
|
||||
return new StringBuilderEx(
|
||||
csd.Mode?.ToString() ?? string.Empty,
|
||||
csd._value ? csd.TrueState : csd.FalseState).ToString();
|
||||
csd._is_checked ? csd.CheckedState : csd.UncheckedState).ToString();
|
||||
}
|
||||
}
|
||||
|
||||
#region Mode
|
||||
public static readonly DependencyProperty ModeProperty =
|
||||
WPFHelper.create_dp<object, BooleanStateDefinition>(nameof(Mode), new PropertyMetadata(null, OnModeChanged));
|
||||
WPFHelper.create_dp<object, CheckedStateDefinition>(nameof(Mode), new PropertyMetadata(null, OnModeChanged));
|
||||
|
||||
static void OnModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => d.CoerceValue(StateProperty);
|
||||
|
||||
@@ -144,83 +144,44 @@ namespace mbts.ui {
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Source
|
||||
public static readonly DependencyProperty SourceProperty =
|
||||
WPFHelper.create_dp<FrameworkElement, BooleanStateDefinition>(
|
||||
nameof(Source),
|
||||
(o, v) => o._on_source_changed(v));
|
||||
#region CheckableSource
|
||||
public static readonly DependencyProperty CheckableSourceProperty =
|
||||
WPFHelper.create_dp<FrameworkElement, CheckedStateDefinition>(
|
||||
nameof(CheckableSource),
|
||||
(o, v) => o._on_checkable_source_changed(v));
|
||||
|
||||
public FrameworkElement Source {
|
||||
get => GetValue(SourceProperty) as FrameworkElement;
|
||||
set => SetValue(SourceProperty, value);
|
||||
public FrameworkElement CheckableSource {
|
||||
get => GetValue(CheckableSourceProperty) as FrameworkElement;
|
||||
set => SetValue(CheckableSourceProperty, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public string TrueState { get; set; } = "True";
|
||||
public string FalseState { get; set; } = "False";
|
||||
public string CheckedState { get; set; } = "Checked";
|
||||
public string UncheckedState { get; set; } = "Unchecked";
|
||||
|
||||
void _on_source_changed(FrameworkElement source) {
|
||||
Disposable.replace(ref _source_hook,
|
||||
OneOf.infer<IObservable<bool>, ToggleButton, MenuItem, TabItem>(
|
||||
source, subscribe_toggle_button, subscribe_menu_item, susbcribe_tab_item)
|
||||
?.Subscribe(on_value_changed));
|
||||
|
||||
IObservable<bool> susbcribe_tab_item(TabItem ti) {
|
||||
on_value_changed(ti.IsSelected);
|
||||
return ti.ObserveIsSelected();
|
||||
}
|
||||
void _on_checkable_source_changed(FrameworkElement checkable_source) {
|
||||
Disposable.replace(ref _checkable_source_hook,
|
||||
OneOf.infer<IObservable<bool>, ToggleButton, MenuItem>(
|
||||
checkable_source, subscribe_toggle_button, subscribe_menu_item)
|
||||
?.Subscribe(on_checked_changed));
|
||||
|
||||
IObservable<bool> subscribe_toggle_button(ToggleButton tb) {
|
||||
on_value_changed(tb.IsChecked ?? false);
|
||||
on_checked_changed(tb.IsChecked ?? false);
|
||||
return tb.ObserveIsChecked();
|
||||
}
|
||||
|
||||
IObservable<bool> subscribe_menu_item(MenuItem mi) {
|
||||
on_value_changed(mi.IsChecked);
|
||||
on_checked_changed(mi.IsChecked);
|
||||
return mi.ObserveIsChecked();
|
||||
}
|
||||
|
||||
void on_value_changed(bool value) {
|
||||
_value = value;
|
||||
void on_checked_changed(bool is_checked) {
|
||||
_is_checked = is_checked;
|
||||
CoerceValue(StateProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CheckedStateDefinition : BooleanStateDefinition {
|
||||
public CheckedStateDefinition() {
|
||||
CheckedState = "Checked";
|
||||
UncheckedState = "Unchecked";
|
||||
}
|
||||
|
||||
public string CheckedState {
|
||||
get => TrueState;
|
||||
set => TrueState = value;
|
||||
}
|
||||
|
||||
public string UncheckedState {
|
||||
get => FalseState;
|
||||
set => FalseState = value;
|
||||
}
|
||||
}
|
||||
|
||||
class SelectedStateDefinition : BooleanStateDefinition {
|
||||
public SelectedStateDefinition() {
|
||||
SelectedState = "Selected";
|
||||
UnselectedState = "Unselected";
|
||||
}
|
||||
|
||||
public string SelectedState {
|
||||
get => TrueState;
|
||||
set => TrueState = value;
|
||||
}
|
||||
|
||||
public string UnselectedState {
|
||||
get => FalseState;
|
||||
set => FalseState = value;
|
||||
}
|
||||
}
|
||||
|
||||
class ModalStateDefinition : StateDefinition {
|
||||
StateDefinition _source;
|
||||
|
||||
|
||||
@@ -23,6 +23,10 @@ namespace mbts.ui.viewmodels {
|
||||
public ColorOverrideParameterVM(string name)
|
||||
: base(name) { }
|
||||
|
||||
public override Color override_value {
|
||||
get => base.override_value;
|
||||
set => base.override_value = value;
|
||||
}
|
||||
public ObservableCollection<ColorPaletteVM> palettes =>
|
||||
_palettes ?? (_palettes = new ObservableCollection<ColorPaletteVM>(ColorPalette.all_presets().Select(p => new ColorPaletteVM(p))));
|
||||
}
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
using bts.collections;
|
||||
using bts.utils;
|
||||
using mbts.collections;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
|
||||
namespace mbts.ui.viewmodels {
|
||||
class OrderedItemParameterVM : BooleanParameterVM {
|
||||
int _index, _checked_index;
|
||||
|
||||
public OrderedItemParameterVM(string name) : base(name) { }
|
||||
|
||||
public int index {
|
||||
get => _index;
|
||||
set => Set(ref _index, value);
|
||||
}
|
||||
|
||||
public int checked_index {
|
||||
get => _checked_index;
|
||||
set => Set(ref _checked_index, value);
|
||||
}
|
||||
}
|
||||
|
||||
class ItemOrderParameterVM<T> : ParameterVM<IEnumerable<T>>, IDisposable {
|
||||
readonly ObservableList<Item> _items = new ObservableList<Item>();
|
||||
//readonly IReadOnlyObservableCollection<Item> _checked_items;
|
||||
readonly IList<T> _wrapped_keys;
|
||||
readonly DeferrableActionWrapper _refresh_indices, _refresh_value, _load_value;
|
||||
IDisposable _dispose;
|
||||
|
||||
public ItemOrderParameterVM(string name)
|
||||
: base(name) { }
|
||||
|
||||
public ItemOrderParameterVM(string name, IEnumerable<T> items)
|
||||
: this(name, items, EqualityComparer<T>.Default) { }
|
||||
|
||||
public ItemOrderParameterVM(string name, IEnumerable<T> available_items, IEqualityComparer<T> comparer)
|
||||
: base(name) {
|
||||
_wrapped_keys = _items.WrapSelector(item => item.key, k => new Item(k));
|
||||
_wrapped_keys.AddRange(available_items);
|
||||
//_checked_items = ObservableFilterCollection.create(_items, item => item.value);
|
||||
_refresh_indices = new DeferrableActionWrapper(refresh_indices);
|
||||
_refresh_value = new DeferrableActionWrapper(refresh_value);
|
||||
_load_value = new DeferrableActionWrapper(load_value);
|
||||
// If this class is ever used with large collections,
|
||||
// the 'refresh_indices' method may need to be optimized.
|
||||
// It is naturally an O(n) op, but execution could be throttled.
|
||||
refresh_indices();
|
||||
_dispose = Disposable.Create(
|
||||
ObservableAutoWrapper.connect_item_hooks(items,
|
||||
item => item.SubscribeValue().Subscribe(_ => _refresh_indices.execute())),
|
||||
items.Subscribe((s, e) => _refresh_indices.execute()));
|
||||
//
|
||||
void refresh_indices() {
|
||||
int checked_index = 0;
|
||||
for (int i = 0; i < items.Count; i++) {
|
||||
items[i].index = i;
|
||||
items[i].checked_index = checked_index;
|
||||
if (items[i].value)
|
||||
checked_index++;
|
||||
}
|
||||
}
|
||||
|
||||
void refresh_value() {
|
||||
using (_refresh_value.supress_execution())
|
||||
value = _checked_keys.ToList();
|
||||
}
|
||||
|
||||
void load_value() {
|
||||
using (_load_value.supress_execution())
|
||||
using (_refresh_indices.defer_execution()) {
|
||||
foreach (var v in _items)
|
||||
v.value = false;
|
||||
int i = 0;
|
||||
foreach (var v in value) {
|
||||
int curr_pos = _wrapped_keys.IndexOf(v);
|
||||
if (curr_pos >= 0) {
|
||||
_items[curr_pos].value = true;
|
||||
if (curr_pos != i)
|
||||
_items.Move(curr_pos, i++);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IReadOnlyObservableCollection<OrderedItemParameterVM> items => _items;
|
||||
|
||||
IEnumerable<T> _checked_keys =>
|
||||
_items.Where(i => i.value).Select(i => i.key);
|
||||
|
||||
public void Dispose() =>
|
||||
Disposable.dispose(ref _dispose);
|
||||
|
||||
protected override void on_changed_end(IEnumerable<T> oldval, IEnumerable<T> newval) =>
|
||||
_load_value.execute();
|
||||
|
||||
public class Item : OrderedItemParameterVM, IEquatable<Item> {
|
||||
public Item(T key) : base(EnumHelper.get_display_name(key)) =>
|
||||
this.key = key;
|
||||
|
||||
public T key { get; }
|
||||
|
||||
public bool Equals(Item other) =>
|
||||
other != null &&
|
||||
EqualityComparer<T>.Default.Equals(key, other.key);
|
||||
|
||||
public override bool Equals(object obj) =>
|
||||
Equals(obj as Item);
|
||||
|
||||
public override int GetHashCode() =>
|
||||
key.GetHashCode();
|
||||
|
||||
public override string ToString() =>
|
||||
EnumHelper.get_display_name(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,325 +1,246 @@
|
||||
using bts.utils;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.utility;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
|
||||
namespace mbts.ui.viewmodels {
|
||||
// as parameters are frequently grouped together,
|
||||
// a non-generic 'result_changed' delegate is useful for responding to changes from any PropertyVM<T>.
|
||||
interface IResultChanged {
|
||||
event Action result_changed;
|
||||
}
|
||||
|
||||
interface IReadOnlyParameterVM<T> : IReadOnlyProperty<T> { }
|
||||
interface IParameterVM<T> : IReadOnlyParameterVM<T> {
|
||||
new T value { get; set; }
|
||||
}
|
||||
|
||||
class PropertyVM<T> : ViewModelBase, IProperty<T>, IResultChanged, INotifyPropertyChanged, IRaiseNotifyPropertyChanged {
|
||||
readonly IEqualityComparer<T> _comparer;
|
||||
T _value;
|
||||
|
||||
public PropertyVM()
|
||||
: this(EqualityComparer<T>.Default) { }
|
||||
|
||||
public PropertyVM(IEqualityComparer<T> comparer) =>
|
||||
_comparer = comparer;
|
||||
|
||||
public event PropertyChange<T> Changing;
|
||||
public event PropertyChange<T> Changed;
|
||||
public event Action result_changed;
|
||||
|
||||
public virtual T value {
|
||||
get => _value;
|
||||
set {
|
||||
if (!_comparer.Equals(_value, value)) {
|
||||
// changing
|
||||
on_changing_begin(_value, value);
|
||||
Changing?.Invoke(_value, value);
|
||||
on_changing_end(_value, value);
|
||||
var oldval = _value;
|
||||
_value = value;
|
||||
// changed
|
||||
on_changed_begin(oldval, value);
|
||||
Changed?.Invoke(oldval, _value);
|
||||
result_changed?.Invoke();
|
||||
on_changed_end(oldval, value);
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
T IProperty<T>.Value {
|
||||
get => value;
|
||||
set => this.value = value;
|
||||
}
|
||||
|
||||
public IDisposable Subscribe(IObserver<(T oldval, T newval)> observer) =>
|
||||
this.subscribe_changed(observer);
|
||||
|
||||
protected virtual void on_changing_begin(T oldval, T newval) { }
|
||||
protected virtual void on_changing_end(T oldval, T newval) { }
|
||||
protected virtual void on_changed_begin(T oldval, T newval) { }
|
||||
protected virtual void on_changed_end(T oldval, T newval) { }
|
||||
}
|
||||
|
||||
class ParameterVM<T> : PropertyVM<T>, IParameterVM<T>, IResultChanged {
|
||||
string _name;
|
||||
PropertyChangedDemuxer _demuxer_backing;
|
||||
PropertyChangedDemuxer _demuxer =>
|
||||
_demuxer_backing ?? (_demuxer_backing = new PropertyChangedDemuxer(this));
|
||||
|
||||
public ParameterVM() { }
|
||||
|
||||
public ParameterVM(string name)
|
||||
: this(name, EqualityComparer<T>.Default) { }
|
||||
|
||||
public ParameterVM(string name, IEqualityComparer<T> comparer)
|
||||
: base(comparer) {
|
||||
_name = name;
|
||||
}
|
||||
|
||||
public string name {
|
||||
get => _name;
|
||||
set {
|
||||
if (_name != value) {
|
||||
_name = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected IDisposable add_dependency<TValue>(string prop_name, Func<T, TValue> src_getter, Action<TValue> vm_setter, Func<T, TValue, T> update) {
|
||||
//
|
||||
bool is_busy = false;
|
||||
Changed += on_changed;
|
||||
_demuxer.subscribe<TValue>(prop_name).Subscribe(on_vm_changed);
|
||||
return Disposable.Create(() => Changed -= on_changed);
|
||||
void on_changed(T oldval, T newval) {
|
||||
if (is_busy)
|
||||
return;
|
||||
is_busy = true;
|
||||
var v = src_getter(newval);
|
||||
vm_setter(v);
|
||||
is_busy = false;
|
||||
}
|
||||
void on_vm_changed(TValue v) {
|
||||
if (is_busy)
|
||||
return;
|
||||
is_busy = true;
|
||||
value = update(value, v);
|
||||
is_busy = false;
|
||||
}
|
||||
}
|
||||
|
||||
public class Dependency<TValue> {
|
||||
readonly Func<T, TValue> _get;
|
||||
readonly Func<T, TValue, T> _set;
|
||||
readonly Action<TValue> _assign;
|
||||
readonly ParameterVM<T> _owner;
|
||||
|
||||
public Dependency(
|
||||
Func<T, TValue> get,
|
||||
Func<T, TValue, T> set,
|
||||
Action<TValue> assign,
|
||||
ParameterVM<T> owner) {
|
||||
_get = get;
|
||||
_set = set;
|
||||
_assign = assign;
|
||||
_owner = owner;
|
||||
}
|
||||
|
||||
public void on_source(T src) =>
|
||||
_assign(_get(src));
|
||||
|
||||
public void on_value(TValue value) =>
|
||||
_owner.value = _set(_owner.value, value);
|
||||
}
|
||||
}
|
||||
|
||||
class ParameterOverrideVM<T> : ViewModelBase {
|
||||
static readonly IPropertyChangedDetector<ParameterOverrideVM<T>> _update =
|
||||
ObjectSnapshot.build_detector_except<ParameterOverrideVM<T>>(nameof(name), nameof(is_expanded));
|
||||
|
||||
readonly IEqualityComparer<T> _comparer;
|
||||
|
||||
bool
|
||||
_can_override,
|
||||
_is_overridden,
|
||||
_is_expanded;
|
||||
T _override_value, _default_value;
|
||||
|
||||
public ParameterOverrideVM(string name)
|
||||
: this(name, EqualityComparer<T>.Default) { }
|
||||
|
||||
public ParameterOverrideVM(string name, IEqualityComparer<T> comparer) {
|
||||
this.name = name;
|
||||
_comparer = comparer;
|
||||
}
|
||||
|
||||
public string name { get; }
|
||||
|
||||
public bool is_expanded {
|
||||
get => _is_expanded;
|
||||
set => Set(ref _is_expanded, value);
|
||||
}
|
||||
|
||||
public bool can_override {
|
||||
get => _can_override;
|
||||
set {
|
||||
using (detect_property_changes())
|
||||
_can_override = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// indicates whether both <see cref="can_override"/> and <see cref="is_overridden"/> are true.
|
||||
public bool effective_is_overridden =>
|
||||
can_override && is_overridden;
|
||||
|
||||
public T effective_value =>
|
||||
effective_is_overridden ? override_value : default_value;
|
||||
|
||||
/// <see cref="is_overridden"/> is orthogonal to <see cref="can_override"/>
|
||||
public bool is_overridden {
|
||||
get => _is_overridden;
|
||||
set {
|
||||
using (_update.detect_changes(this))
|
||||
_is_overridden = value;
|
||||
}
|
||||
}
|
||||
public virtual T default_value {
|
||||
get => _default_value;
|
||||
set {
|
||||
using (_update.detect_changes(this))
|
||||
_default_value = value;
|
||||
}
|
||||
}
|
||||
public virtual T override_value {
|
||||
get => _override_value;
|
||||
set {
|
||||
if (!_comparer.Equals(value, _override_value)) {
|
||||
using (_update.detect_changes(this)) {
|
||||
is_overridden = true;
|
||||
_override_value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// unlike the override_value setter, this method does not set is_override to true.
|
||||
public void set_override(T value) {
|
||||
using (_update.detect_changes(this))
|
||||
_override_value = value;
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
effective_is_overridden ? $"{override_value} ({default_value})" : default_value?.ToString();
|
||||
}
|
||||
|
||||
class ParameterGroupVM : ViewModelBase, IResultChanged {
|
||||
bool _is_expanded;
|
||||
IDisposable _parameters_changed_hook;
|
||||
|
||||
public ParameterGroupVM(string name)
|
||||
: this(name, null) { }
|
||||
|
||||
public ParameterGroupVM(string name, ObservableCollection<object> parameters) {
|
||||
this.name = name;
|
||||
this.parameters = parameters ?? new ObservableCollection<object>();
|
||||
}
|
||||
|
||||
public event Action result_changed {
|
||||
add {
|
||||
_result_changed += value;
|
||||
if (_parameters_changed_hook == null) {
|
||||
_parameters_changed_hook = ObservableAutoWrapper.connect_item_hooks(parameters,
|
||||
obj => {
|
||||
if (obj is IResultChanged rc) {
|
||||
rc.result_changed += _raise_result_changed;
|
||||
return Disposable.Create(() => rc.result_changed -= _raise_result_changed);
|
||||
}
|
||||
return Disposable.empty;
|
||||
});
|
||||
}
|
||||
}
|
||||
remove {
|
||||
_result_changed -= value;
|
||||
if (_result_changed == null)
|
||||
Disposable.dispose(ref _parameters_changed_hook);
|
||||
}
|
||||
}
|
||||
|
||||
event Action _result_changed;
|
||||
|
||||
public string name { get; }
|
||||
public ObservableCollection<object> parameters { get; }
|
||||
public bool is_expanded { get => _is_expanded; set => Set(ref _is_expanded, value); }
|
||||
|
||||
public static ParameterGroupVM create(string name, params object[] parameters) =>
|
||||
new ParameterGroupVM(name, new ObservableCollection<object>(parameters));
|
||||
|
||||
void _raise_result_changed() =>
|
||||
_result_changed?.Invoke();
|
||||
}
|
||||
|
||||
class TabularParameterGroupVM : ParameterGroupVM {
|
||||
object _selected_item;
|
||||
|
||||
public TabularParameterGroupVM(string name)
|
||||
: base(name) { }
|
||||
|
||||
public TabularParameterGroupVM(string name, ObservableCollection<object> parameters)
|
||||
: base(name, parameters) { }
|
||||
|
||||
public object selected_item { get => _selected_item; set => Set(ref _selected_item, value); }
|
||||
|
||||
public new static TabularParameterGroupVM create(string name, params object[] parameters) =>
|
||||
new TabularParameterGroupVM(name, new ObservableCollection<object>(parameters));
|
||||
}
|
||||
|
||||
class HeaderedParameterGroupVM : ParameterGroupVM {
|
||||
public HeaderedParameterGroupVM(string name)
|
||||
: base(name) { }
|
||||
|
||||
public HeaderedParameterGroupVM(string name, ObservableCollection<object> parameters)
|
||||
: base(name, parameters) { }
|
||||
|
||||
public new static HeaderedParameterGroupVM create(string name, params object[] parameters) =>
|
||||
new HeaderedParameterGroupVM(name, new ObservableCollection<object>(parameters));
|
||||
}
|
||||
|
||||
static class ParameterVMExtensions {
|
||||
public static IObservable<Unit> Observe(this ParameterGroupVM parameter_group_vm) {
|
||||
return Observable.Create<Unit>(o => {
|
||||
var notify_throttle = new DeferrableActionWrapper(notify_impl);
|
||||
parameter_group_vm.PropertyChanged += on_prop_changed;
|
||||
return Disposable.Create(ObservableAutoWrapper.connect_item_hooks(parameter_group_vm.parameters, obj => {
|
||||
var hook = new System.Reactive.Disposables.CompositeDisposable();
|
||||
if (obj is IResultChanged rop) {
|
||||
rop.result_changed += notify;
|
||||
hook.Add(Disposable.Create(() => rop.result_changed -= notify));
|
||||
} else if (obj is INotifyPropertyChanged npc) {
|
||||
npc.PropertyChanged += on_prop_changed;
|
||||
hook.Add(Disposable.Create(() => npc.PropertyChanged -= on_prop_changed));
|
||||
}
|
||||
return hook;
|
||||
}),
|
||||
Disposable.Create(() => parameter_group_vm.PropertyChanged -= on_prop_changed));
|
||||
void notify() {
|
||||
using (notify_throttle.defer_execution())
|
||||
notify_throttle.execute();
|
||||
}
|
||||
void notify_impl() =>
|
||||
o.OnNext(Unit.Default);
|
||||
void on_prop_changed(object sender, PropertyChangedEventArgs e) =>
|
||||
notify();
|
||||
});
|
||||
}
|
||||
}
|
||||
using bts.utils;
|
||||
using mbts.ui.shell;
|
||||
using mbts.ui.utility;
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace mbts.ui.viewmodels {
|
||||
interface IReadOnlyParameterVM<T> : IReadOnlyProperty<T> { }
|
||||
interface IParameterVM<T> : IReadOnlyParameterVM<T> {
|
||||
new T value { get; set; }
|
||||
}
|
||||
|
||||
class PropertyVM<T> : ViewModelBase, IProperty<T>, INotifyPropertyChanged, IRaiseNotifyPropertyChanged {
|
||||
readonly IEqualityComparer<T> _comparer;
|
||||
T _value;
|
||||
|
||||
public PropertyVM()
|
||||
: this(EqualityComparer<T>.Default) { }
|
||||
|
||||
public PropertyVM(IEqualityComparer<T> comparer) =>
|
||||
_comparer = comparer;
|
||||
|
||||
public event PropertyChange<T> Changing;
|
||||
public event PropertyChange<T> Changed;
|
||||
|
||||
public virtual T value {
|
||||
get => _value;
|
||||
set {
|
||||
if (!_comparer.Equals(_value, value)) {
|
||||
// changing
|
||||
on_changing_begin(_value, value);
|
||||
Changing?.Invoke(_value, value);
|
||||
on_changing_end(_value, value);
|
||||
var oldval = _value;
|
||||
_value = value;
|
||||
// changed
|
||||
on_changed_begin(oldval, value);
|
||||
Changed?.Invoke(oldval, _value);
|
||||
on_changed_end(oldval, value);
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
T IProperty<T>.Value {
|
||||
get => value;
|
||||
set => this.value = value;
|
||||
}
|
||||
|
||||
public IDisposable Subscribe(IObserver<(T oldval, T newval)> observer) =>
|
||||
this.subscribe_changed(observer);
|
||||
|
||||
protected virtual void on_changing_begin(T oldval, T newval) { }
|
||||
protected virtual void on_changing_end(T oldval, T newval) { }
|
||||
protected virtual void on_changed_begin(T oldval, T newval) { }
|
||||
protected virtual void on_changed_end(T oldval, T newval) { }
|
||||
}
|
||||
|
||||
class ParameterVM<T> : PropertyVM<T>, IParameterVM<T> {
|
||||
string _name;
|
||||
PropertyChangedDemuxer _demuxer_backing;
|
||||
PropertyChangedDemuxer _demuxer =>
|
||||
_demuxer_backing ?? (_demuxer_backing = new PropertyChangedDemuxer(this));
|
||||
|
||||
public ParameterVM() { }
|
||||
|
||||
public ParameterVM(string name)
|
||||
: this(name, EqualityComparer<T>.Default) { }
|
||||
|
||||
public ParameterVM(string name, IEqualityComparer<T> comparer)
|
||||
: base(comparer) {
|
||||
_name = name;
|
||||
}
|
||||
|
||||
public string name {
|
||||
get => _name;
|
||||
set {
|
||||
if (_name != value) {
|
||||
_name = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected IDisposable add_dependency<TValue>(string prop_name, Func<T, TValue> src_getter, Action<TValue> vm_setter, Func<T, TValue, T> update) {
|
||||
//
|
||||
bool is_busy = false;
|
||||
Changed += on_changed;
|
||||
_demuxer.subscribe<TValue>(prop_name).Subscribe(on_vm_changed);
|
||||
return Disposable.Create(() => Changed -= on_changed);
|
||||
void on_changed(T oldval, T newval) {
|
||||
if (is_busy)
|
||||
return;
|
||||
is_busy = true;
|
||||
var v = src_getter(newval);
|
||||
vm_setter(v);
|
||||
is_busy = false;
|
||||
}
|
||||
void on_vm_changed(TValue v) {
|
||||
if (is_busy)
|
||||
return;
|
||||
is_busy = true;
|
||||
value = update(value, v);
|
||||
is_busy = false;
|
||||
}
|
||||
}
|
||||
|
||||
public class Dependency<TValue> {
|
||||
readonly Func<T, TValue> _get;
|
||||
readonly Func<T, TValue, T> _set;
|
||||
readonly Action<TValue> _assign;
|
||||
readonly ParameterVM<T> _owner;
|
||||
|
||||
public Dependency(
|
||||
Func<T, TValue> get,
|
||||
Func<T, TValue, T> set,
|
||||
Action<TValue> assign,
|
||||
ParameterVM<T> owner) {
|
||||
_get = get;
|
||||
_set = set;
|
||||
_assign = assign;
|
||||
_owner = owner;
|
||||
}
|
||||
|
||||
public void on_source(T src) =>
|
||||
_assign(_get(src));
|
||||
|
||||
public void on_value(TValue value) =>
|
||||
_owner.value = _set(_owner.value, value);
|
||||
}
|
||||
}
|
||||
|
||||
class ParameterOverrideVM<T> : ViewModelBase {
|
||||
static readonly IPropertyChangedDetector<ParameterOverrideVM<T>> _update =
|
||||
ObjectSnapshot.build_detector_except<ParameterOverrideVM<T>>(nameof(name), nameof(is_enabled), nameof(is_visible));
|
||||
|
||||
readonly IEqualityComparer<T> _comparer;
|
||||
|
||||
bool
|
||||
_can_override,
|
||||
_is_overridden,
|
||||
_is_enabled,
|
||||
_is_expanded,
|
||||
_is_visible;
|
||||
T _override_value, _default_value;
|
||||
|
||||
public ParameterOverrideVM(string name)
|
||||
: this(name, EqualityComparer<T>.Default) { }
|
||||
|
||||
public ParameterOverrideVM(string name, IEqualityComparer<T> comparer) {
|
||||
this.name = name;
|
||||
_comparer = comparer;
|
||||
}
|
||||
|
||||
public string name { get; }
|
||||
public bool is_enabled {
|
||||
get => _is_enabled;
|
||||
set => Set(ref _is_enabled, value);
|
||||
}
|
||||
|
||||
public bool is_expanded {
|
||||
get => _is_expanded;
|
||||
set => Set(ref _is_expanded, value);
|
||||
}
|
||||
|
||||
public bool is_visible {
|
||||
get => _is_visible;
|
||||
set => Set(ref _is_visible, value);
|
||||
}
|
||||
|
||||
public bool can_override {
|
||||
get => _can_override;
|
||||
set {
|
||||
using (detect_property_changes())
|
||||
_can_override = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// indicates whether both <see cref="can_override"/> and <see cref="is_overridden"/> are true.
|
||||
public bool effective_is_overridden =>
|
||||
can_override && is_overridden;
|
||||
|
||||
public T effective_value =>
|
||||
effective_is_overridden ? override_value : default_value;
|
||||
|
||||
/// <see cref="is_overridden"/> is orthogonal to <see cref="can_override"/>
|
||||
public bool is_overridden {
|
||||
get => _is_overridden;
|
||||
set {
|
||||
using (_update.detect_changes(this))
|
||||
_is_overridden = value;
|
||||
}
|
||||
}
|
||||
public virtual T default_value {
|
||||
get => _default_value;
|
||||
set {
|
||||
using (_update.detect_changes(this))
|
||||
_default_value = value;
|
||||
}
|
||||
}
|
||||
public virtual T override_value {
|
||||
get => _override_value;
|
||||
set {
|
||||
if (!_comparer.Equals(value, _override_value)) {
|
||||
using (_update.detect_changes(this)) {
|
||||
is_overridden = true;
|
||||
_override_value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// unlike the override_value setter, this method does not set is_override to true.
|
||||
public void set_override(T value) {
|
||||
using (_update.detect_changes(this))
|
||||
_override_value = value;
|
||||
}
|
||||
|
||||
public override string ToString() =>
|
||||
effective_is_overridden ? $"{override_value} ({default_value})" : default_value?.ToString();
|
||||
}
|
||||
|
||||
class ParameterGroupVM : ViewModelBase {
|
||||
bool _is_enabled, _is_expanded, _is_visible;
|
||||
|
||||
public ParameterGroupVM(string name)
|
||||
: this(name, null) { }
|
||||
|
||||
public ParameterGroupVM(string name, ObservableCollection<object> parameters) {
|
||||
this.name = name;
|
||||
this.parameters = parameters ?? new ObservableCollection<object>();
|
||||
}
|
||||
|
||||
public string name { get; }
|
||||
public ObservableCollection<object> parameters { get; }
|
||||
public bool enable_tab_display { get; set; }
|
||||
public IEnumerable parameters_view => parameters;
|
||||
public bool is_enabled { get => _is_enabled; set => Set(ref _is_enabled, value); }
|
||||
public bool is_expanded { get => _is_expanded; set => Set(ref _is_expanded, value); }
|
||||
public bool is_visible { get => _is_visible; set => Set(ref _is_visible, value); }
|
||||
}
|
||||
}
|
||||
@@ -20,13 +20,6 @@ namespace bts.collections {
|
||||
collection.AddRange(items);
|
||||
}
|
||||
|
||||
public static void SetItems<T>(this ICollection<T> collection, params T[] items) {
|
||||
if (collection.Count > 0)
|
||||
collection.Clear();
|
||||
for (int i = 0; i < items.Length; i++)
|
||||
collection.Add(items[i]);
|
||||
}
|
||||
|
||||
public static bool within_range<T>(this ICollection<T> collection, int index) =>
|
||||
index >= 0 && index < collection.Count;
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace bts.collections {
|
||||
/// <summary>
|
||||
/// An <see cref="ObservableCollection{T}"/> that implements <see cref="IObservableCollection{T}"/>.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">
|
||||
/// The type of elements in the collection.
|
||||
/// </typeparam>
|
||||
class ObservableList<T> : ObservableCollection<T>, IObservableCollection<T>, IReadOnlyObservableCollection<T> { }
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace mbts.utils {
|
||||
static class ExceptionBuilder {
|
||||
@@ -47,6 +48,11 @@ namespace mbts.utils {
|
||||
new ArgumentOutOfRangeException(name, "Value is greater than or equal to the number of elements.");
|
||||
}
|
||||
|
||||
public static class InvalidOperation {
|
||||
public static InvalidOperationException is_read_only([CallerMemberName]string name = "This value") =>
|
||||
new InvalidOperationException($"{name} is read only.");
|
||||
}
|
||||
|
||||
public static class Format {
|
||||
public static string LessThan(int value) => $"{Messages.LessThan} {value}.";
|
||||
public static string LessThanOrEqualTo(int value) => $"{Messages.LessThanOrEqualTo} {value}.";
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
# source: tools/cpp_helper/generate-cpps.ps1
|
||||
#
|
||||
|
||||
CppConfig
|
||||
{
|
||||
value
|
||||
CppConfig
|
||||
{
|
||||
value
|
||||
{
|
||||
cpp_entry { key: "098" value: 2000 }
|
||||
cpp_entry { key: "0A" value: 100 }
|
||||
cpp_entry { key: "0B" value: 100 }
|
||||
cpp_entry { key: "0C" value: 100 }
|
||||
@@ -458,9 +459,9 @@ CppConfig
|
||||
cpp_entry { key: "DDE" value: 1000 }
|
||||
cpp_entry { key: "DDI" value: 1000 }
|
||||
cpp_entry { key: "DDO" value: 1000 }
|
||||
cpp_entry { key: "DEB" value: 745 }
|
||||
cpp_entry { key: "DEB" value: 720 }
|
||||
cpp_entry { key: "DEN" value: 250 }
|
||||
cpp_entry { key: "DEP" value: 276 }
|
||||
cpp_entry { key: "DEP" value: 252 }
|
||||
cpp_entry { key: "DFL" value: 100 }
|
||||
cpp_entry { key: "DFN" value: 100 }
|
||||
cpp_entry { key: "DG2" value: 100 }
|
||||
@@ -729,8 +730,8 @@ CppConfig
|
||||
cpp_entry { key: "IPO" value: 10 }
|
||||
cpp_entry { key: "IPT" value: 10 }
|
||||
cpp_entry { key: "IS" value: 50 }
|
||||
cpp_entry { key: "ITB" value: 745 }
|
||||
cpp_entry { key: "ITP" value: 276 }
|
||||
cpp_entry { key: "ITB" value: 720 }
|
||||
cpp_entry { key: "ITP" value: 252 }
|
||||
cpp_entry { key: "IW" value: 50 }
|
||||
cpp_entry { key: "J4L" value: 80 }
|
||||
cpp_entry { key: "J7" value: 6250000 }
|
||||
@@ -772,6 +773,7 @@ CppConfig
|
||||
cpp_entry { key: "K5" value: 20 }
|
||||
cpp_entry { key: "K5K" value: 20 }
|
||||
cpp_entry { key: "K5N" value: 20 }
|
||||
cpp_entry { key: "KC" value: 375 }
|
||||
cpp_entry { key: "KE" value: 50 }
|
||||
cpp_entry { key: "KET" value: 50 }
|
||||
cpp_entry { key: "KQ" value: 20 }
|
||||
@@ -807,7 +809,6 @@ CppConfig
|
||||
cpp_entry { key: "LIY" value: 1000 }
|
||||
cpp_entry { key: "LL" value: 42000 }
|
||||
cpp_entry { key: "LLR" value: 1000 }
|
||||
cpp_entry { key: "LNG" value: 10000 }
|
||||
cpp_entry { key: "LPE" value: 47000 }
|
||||
cpp_entry { key: "LPS" value: 1000 }
|
||||
cpp_entry { key: "LSF" value: 1 }
|
||||
@@ -1002,6 +1003,7 @@ CppConfig
|
||||
cpp_entry { key: "OAD" value: 1 }
|
||||
cpp_entry { key: "ODO" value: 1000 }
|
||||
cpp_entry { key: "OFF" value: 5 }
|
||||
cpp_entry { key: "OJ" value: 150 }
|
||||
cpp_entry { key: "OML" value: 5 }
|
||||
cpp_entry { key: "OMM" value: 80 }
|
||||
cpp_entry { key: "OOD" value: 5 }
|
||||
@@ -1144,7 +1146,7 @@ CppConfig
|
||||
cpp_entry { key: "SBT" value: 50 }
|
||||
cpp_entry { key: "SD" value: 1000 }
|
||||
cpp_entry { key: "SDA" value: 250 }
|
||||
cpp_entry { key: "SDD" value: 1840 }
|
||||
cpp_entry { key: "SDD" value: 1600 }
|
||||
cpp_entry { key: "SDG" value: 250 }
|
||||
cpp_entry { key: "SDI" value: 1000 }
|
||||
cpp_entry { key: "SDM" value: 100 }
|
||||
@@ -1161,12 +1163,10 @@ CppConfig
|
||||
cpp_entry { key: "SFR" value: 250 }
|
||||
cpp_entry { key: "SG" value: 250 }
|
||||
cpp_entry { key: "SGB" value: 1000 }
|
||||
cpp_entry { key: "SGC" value: 1000 }
|
||||
cpp_entry { key: "SGE" value: 42000 }
|
||||
cpp_entry { key: "SGF" value: 1000 }
|
||||
cpp_entry { key: "SGG" value: 1000 }
|
||||
cpp_entry { key: "SGT" value: 250 }
|
||||
cpp_entry { key: "SGU" value: 32.15 }
|
||||
cpp_entry { key: "SI" value: 5000 }
|
||||
cpp_entry { key: "SIL" value: 1000 }
|
||||
cpp_entry { key: "SIR" value: 500 }
|
||||
@@ -1185,7 +1185,7 @@ CppConfig
|
||||
cpp_entry { key: "SR3" value: 2500 }
|
||||
cpp_entry { key: "SR5" value: 1000 }
|
||||
cpp_entry { key: "SRB" value: 1000 }
|
||||
cpp_entry { key: "SRT" value: 1840 }
|
||||
cpp_entry { key: "SRT" value: 1600 }
|
||||
cpp_entry { key: "SSI" value: 1000 }
|
||||
cpp_entry { key: "SSP" value: 5000 }
|
||||
cpp_entry { key: "SSW" value: 1000 }
|
||||
@@ -1197,31 +1197,31 @@ CppConfig
|
||||
cpp_entry { key: "SU" value: 250 }
|
||||
cpp_entry { key: "SUT" value: 250 }
|
||||
cpp_entry { key: "T01" value: 800 }
|
||||
cpp_entry { key: "T02" value: 800 }
|
||||
cpp_entry { key: "T03" value: 800 }
|
||||
cpp_entry { key: "T04" value: 800 }
|
||||
cpp_entry { key: "T05" value: 800 }
|
||||
cpp_entry { key: "T06" value: 800 }
|
||||
cpp_entry { key: "T07" value: 800 }
|
||||
cpp_entry { key: "T08" value: 800 }
|
||||
cpp_entry { key: "T09" value: 800 }
|
||||
cpp_entry { key: "T10" value: 800 }
|
||||
cpp_entry { key: "T11" value: 800 }
|
||||
cpp_entry { key: "T12" value: 800 }
|
||||
cpp_entry { key: "T13" value: 800 }
|
||||
cpp_entry { key: "T15" value: 800 }
|
||||
cpp_entry { key: "T16" value: 800 }
|
||||
cpp_entry { key: "T17" value: 800 }
|
||||
cpp_entry { key: "T18" value: 800 }
|
||||
cpp_entry { key: "T19" value: 800 }
|
||||
cpp_entry { key: "T1U" value: 1000 }
|
||||
cpp_entry { key: "T21" value: 800 }
|
||||
cpp_entry { key: "T22" value: 800 }
|
||||
cpp_entry { key: "T20" value: 800 }
|
||||
cpp_entry { key: "T23" value: 800 }
|
||||
cpp_entry { key: "T24" value: 800 }
|
||||
cpp_entry { key: "T25" value: 800 }
|
||||
cpp_entry { key: "T28" value: 800 }
|
||||
cpp_entry { key: "T29" value: 800 }
|
||||
cpp_entry { key: "T26" value: 800 }
|
||||
cpp_entry { key: "T27" value: 800 }
|
||||
cpp_entry { key: "T2B" value: 1000 }
|
||||
cpp_entry { key: "T2D" value: 1000 }
|
||||
cpp_entry { key: "T2M" value: 100 }
|
||||
cpp_entry { key: "T30" value: 800 }
|
||||
cpp_entry { key: "T31" value: 800 }
|
||||
cpp_entry { key: "T3B" value: 1000 }
|
||||
cpp_entry { key: "T3L" value: 80 }
|
||||
cpp_entry { key: "T4B" value: 1000 }
|
||||
@@ -1276,7 +1276,7 @@ CppConfig
|
||||
cpp_entry { key: "TT" value: 50000 }
|
||||
cpp_entry { key: "TTD" value: 24 }
|
||||
cpp_entry { key: "TTE" value: 10000 }
|
||||
cpp_entry { key: "TTF" value: 745 }
|
||||
cpp_entry { key: "TTF" value: 720 }
|
||||
cpp_entry { key: "TUB" value: 1000 }
|
||||
cpp_entry { key: "TUF" value: 1000 }
|
||||
cpp_entry { key: "TUL" value: 1000 }
|
||||
@@ -1299,7 +1299,7 @@ CppConfig
|
||||
cpp_entry { key: "UFU" value: 100 }
|
||||
cpp_entry { key: "UFV" value: 100 }
|
||||
cpp_entry { key: "UGG" value: 42000 }
|
||||
cpp_entry { key: "UKG" value: 310 }
|
||||
cpp_entry { key: "UKG" value: 300 }
|
||||
cpp_entry { key: "ULB" value: 42000 }
|
||||
cpp_entry { key: "UMB" value: 1000 }
|
||||
cpp_entry { key: "UMD" value: 1000 }
|
||||
@@ -1457,13 +1457,14 @@ CppConfig
|
||||
cpp_entry { key: "ZT" value: 2000 }
|
||||
cpp_entry { key: "ZW" value: 50 }
|
||||
cpp_entry { key: "ZWT" value: 50 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CmeSymbolMics
|
||||
{
|
||||
value
|
||||
CmeSymbolMics
|
||||
{
|
||||
value
|
||||
{
|
||||
cme_mic { key: "098" value: CBT }
|
||||
cme_mic { key: "0A" value: NYMEX }
|
||||
cme_mic { key: "0B" value: NYMEX }
|
||||
cme_mic { key: "0C" value: NYMEX }
|
||||
@@ -2264,7 +2265,6 @@ CmeSymbolMics
|
||||
cme_mic { key: "LIY" value: CBT }
|
||||
cme_mic { key: "LL" value: NYMEX }
|
||||
cme_mic { key: "LLR" value: NYMEX }
|
||||
cme_mic { key: "LNG" value: NYMEX }
|
||||
cme_mic { key: "LPE" value: NYMEX }
|
||||
cme_mic { key: "LPS" value: NYMEX }
|
||||
cme_mic { key: "LSF" value: COMEX }
|
||||
@@ -2618,12 +2618,10 @@ CmeSymbolMics
|
||||
cme_mic { key: "SFR" value: CME }
|
||||
cme_mic { key: "SG" value: CME }
|
||||
cme_mic { key: "SGB" value: NYMEX }
|
||||
cme_mic { key: "SGC" value: COMEX }
|
||||
cme_mic { key: "SGE" value: NYMEX }
|
||||
cme_mic { key: "SGF" value: NYMEX }
|
||||
cme_mic { key: "SGG" value: NYMEX }
|
||||
cme_mic { key: "SGT" value: CME }
|
||||
cme_mic { key: "SGU" value: COMEX }
|
||||
cme_mic { key: "SI" value: COMEX }
|
||||
cme_mic { key: "SIL" value: COMEX }
|
||||
cme_mic { key: "SIR" value: CME }
|
||||
@@ -2654,31 +2652,31 @@ CmeSymbolMics
|
||||
cme_mic { key: "SU" value: CME }
|
||||
cme_mic { key: "SUT" value: CME }
|
||||
cme_mic { key: "T01" value: NYMEX }
|
||||
cme_mic { key: "T02" value: NYMEX }
|
||||
cme_mic { key: "T03" value: NYMEX }
|
||||
cme_mic { key: "T04" value: NYMEX }
|
||||
cme_mic { key: "T05" value: NYMEX }
|
||||
cme_mic { key: "T06" value: NYMEX }
|
||||
cme_mic { key: "T07" value: NYMEX }
|
||||
cme_mic { key: "T08" value: NYMEX }
|
||||
cme_mic { key: "T09" value: NYMEX }
|
||||
cme_mic { key: "T10" value: NYMEX }
|
||||
cme_mic { key: "T11" value: NYMEX }
|
||||
cme_mic { key: "T12" value: NYMEX }
|
||||
cme_mic { key: "T13" value: NYMEX }
|
||||
cme_mic { key: "T15" value: NYMEX }
|
||||
cme_mic { key: "T16" value: NYMEX }
|
||||
cme_mic { key: "T17" value: NYMEX }
|
||||
cme_mic { key: "T18" value: NYMEX }
|
||||
cme_mic { key: "T19" value: NYMEX }
|
||||
cme_mic { key: "T1U" value: CBT }
|
||||
cme_mic { key: "T21" value: NYMEX }
|
||||
cme_mic { key: "T22" value: NYMEX }
|
||||
cme_mic { key: "T20" value: NYMEX }
|
||||
cme_mic { key: "T23" value: NYMEX }
|
||||
cme_mic { key: "T24" value: NYMEX }
|
||||
cme_mic { key: "T25" value: NYMEX }
|
||||
cme_mic { key: "T28" value: NYMEX }
|
||||
cme_mic { key: "T29" value: NYMEX }
|
||||
cme_mic { key: "T26" value: NYMEX }
|
||||
cme_mic { key: "T27" value: NYMEX }
|
||||
cme_mic { key: "T2B" value: NYMEX }
|
||||
cme_mic { key: "T2D" value: NYMEX }
|
||||
cme_mic { key: "T2M" value: NYMEX }
|
||||
cme_mic { key: "T30" value: NYMEX }
|
||||
cme_mic { key: "T31" value: NYMEX }
|
||||
cme_mic { key: "T3B" value: NYMEX }
|
||||
cme_mic { key: "T3L" value: NYMEX }
|
||||
cme_mic { key: "T4B" value: NYMEX }
|
||||
@@ -2914,5 +2912,5 @@ CmeSymbolMics
|
||||
cme_mic { key: "ZT" value: CBT }
|
||||
cme_mic { key: "ZW" value: CBT }
|
||||
cme_mic { key: "ZWT" value: CBT }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,3 +29,5 @@ Sym,Mult,Exch
|
||||
"BUB",1000,CBT
|
||||
"FNU",1000,CBT
|
||||
"SOM",500,CBT
|
||||
"OJ",150,IFU
|
||||
"KC",375,IFU
|
||||
|
Reference in new issue
Block a user