merge from edge
This commit is contained in:
1 parent
647a4bc55a
commit
071909e4c9
22 files changed
+217
-100
No files matched your search
@@ -235,8 +235,8 @@ namespace mbts.spark {
|
||||
ProtoBuf.Serializer.SerializeWithLengthPrefix(output, header, ProtoBuf.PrefixStyle.Fixed32);
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
base.Dispose();
|
||||
protected override void Dispose(bool disposing) {
|
||||
base.Dispose(disposing);
|
||||
_timer.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/bts_mspark;component/Utilities/Converters/Converters.xaml"/>
|
||||
<ResourceDictionary Source="/bts_mspark;component/Themes/generic.xaml"/>
|
||||
<ResourceDictionary Source="/mspark/Utilities/Converters/Converters.xaml"/>
|
||||
<ResourceDictionary Source="/mspark/Themes/generic.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<Style x:Key="LastPriceElement" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{uc:BTSColor MarketData.last}"/>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/bts_mspark;component/Utilities/Converters/Converters.xaml"/>
|
||||
<ResourceDictionary Source="/mspark/Utilities/Converters/Converters.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<sys:Double x:Key="HorizontalSpacing">8.0</sys:Double>
|
||||
<sys:Double x:Key="VerticalSpacing">4.0</sys:Double>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/bts_mspark;component/Utilities/Converters/Converters.xaml"/>
|
||||
<ResourceDictionary Source="/mspark/Utilities/Converters/Converters.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<sys:Double x:Key="HorizontalSpacing">8.0</sys:Double>
|
||||
<sys:Double x:Key="VerticalSpacing">4.0</sys:Double>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/bts_mspark;component/Utilities/Converters/Converters.xaml"/>
|
||||
<ResourceDictionary Source="/mspark/Utilities/Converters/Converters.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<sys:Double x:Key="HorizontalSpacing">8.0</sys:Double>
|
||||
<sys:Double x:Key="VerticalSpacing">4.0</sys:Double>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/bts_mspark;component/Controls/SecuritySelectorControl/SecuritySelectorControl.xaml"/>
|
||||
<ResourceDictionary Source="/mspark/Controls/SecuritySelectorControl/SecuritySelectorControl.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<cv:BTSColorConverter x:Key="BTSColorConverter"/>
|
||||
<SolidColorBrush x:Key="LightBlueGray" Color="{Binding Source={x:Static uc:BTSCoreColors.blue_grey_lightest}, Converter={StaticResource BTSColorConverter}, Mode=OneTime}"/>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/bts_mspark;component/Controls/SecuritySelectorControl/SecuritySelectorControl.xaml" />
|
||||
<ResourceDictionary Source="/mspark/Controls/SecuritySelectorControl/SecuritySelectorControl.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/bts_mspark;component/Controls/SecuritySelectorControl/SecuritySelectorControl.xaml"/>
|
||||
<ResourceDictionary Source="/mspark/Controls/SecuritySelectorControl/SecuritySelectorControl.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<ControlTemplate x:Key="GroupItemTemplate" TargetType="GroupItem">
|
||||
<Border x:Name="bd" BorderBrush="Black" BorderThickness="0,0,0,1">
|
||||
@@ -143,4 +143,4 @@
|
||||
</Menu.ItemsPanel>
|
||||
</Menu>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
</UserControl>
|
||||
@@ -1,16 +0,0 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:uc="clr-namespace:mbts.ui"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:c="clr-namespace:mbts.ui.controls"
|
||||
xmlns:cv="clr-namespace:mbts.ui.converters"
|
||||
xmlns:usp="clr-namespace:mbts.ui.spark"
|
||||
xmlns:uspcv="clr-namespace:mbts.ui.spark.converters"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib">
|
||||
<sys:Int32 x:Key="IntZero">0</sys:Int32>
|
||||
<sys:Double x:Key="DoubleZero">0</sys:Double>
|
||||
<uspcv:TickDisplayConverter x:Key="TickDisplayConverter" HideNaN="True"/>
|
||||
<uspcv:ImageSourceIconConverter x:Key="IconConverter"/>
|
||||
<cv:NumericSignBrushConverter x:Key="PositionSignBrushConverter" Zero="{StaticResource IntZero}"/>
|
||||
<cv:NumericSignBrushConverter x:Key="DayChangeSignBrushConverter" Zero="{StaticResource DoubleZero}"/>
|
||||
</ResourceDictionary>
|
||||
@@ -76,10 +76,13 @@ namespace mbts.ui
|
||||
public static ImageSource Crucible { get { return (DrawingImage)_resources["Crucible"]; } }
|
||||
|
||||
public static ImageSource Accounting { get { return (DrawingImage)_resources["Accounting"]; } }
|
||||
public static ImageSource Book { get { return (DrawingImage)_resources["Book"]; } }
|
||||
public static ImageSource CancelOrders { get { return (DrawingImage)_resources["CancelOrders"]; } }
|
||||
public static ImageSource Clock { get { return (DrawingImage)_resources["Clock"]; } }
|
||||
public static ImageSource Defrag { get { return (DrawingImage)_resources["Defrag"]; } }
|
||||
public static ImageSource Display { get { return (DrawingImage)_resources["Display"]; } }
|
||||
public static ImageSource Payment { get { return (DrawingImage)_resources["Payment"]; } }
|
||||
public static ImageSource Spawn { get { return (DrawingImage)_resources["Spawn"]; } }
|
||||
public static ImageSource Target { get { return (DrawingImage)_resources["Target"]; } }
|
||||
public static ImageSource Wrench { get { return (DrawingImage)_resources["Wrench"]; } }
|
||||
}
|
||||
|
||||
@@ -324,6 +324,40 @@ M0,0L63.999001,0 63.999001,48.792999 0,48.792999z">
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
|
||||
<DrawingImage x:Key="Book">
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup>
|
||||
<DrawingGroup.Children>
|
||||
<GeometryDrawing Brush="White" Geometry="M16.378574,2.0941912E-05C17.053625,-0.0029775997,17.669592,0.31702943,17.669592,0.31702964L27.747614,10.181254C30.078613,11.977292,28.301632,12.163302,28.301632,12.163302L14.005584,15.500376C11.924586,18.496447,15.130586,19.519465,15.130586,19.519465L30.870606,16.081391C32.66065,16.035383,31.786623,17.428421,31.786623,17.428421L15.130586,21.214503C12.353603,22.20553,10.869592,20.092476,10.869592,20.092476L0.76355401,8.8182232C-1.4574583,4.6071207,1.8735417,3.616101,1.8735417,3.616101L16.08762,0.023016395C16.184605,0.0080166093,16.282566,2.082104E-05,16.378574,2.0941912E-05z">
|
||||
<GeometryDrawing.Pen>
|
||||
<Pen Brush="Black" Thickness="2"/>
|
||||
</GeometryDrawing.Pen>
|
||||
</GeometryDrawing>
|
||||
</DrawingGroup.Children>
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
|
||||
<DrawingImage x:Key="Defrag">
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup>
|
||||
<DrawingGroup.Children>
|
||||
<GeometryDrawing Brush="Black" Geometry="M26.84801,26.411987L31.841998,26.411987 31.841998,31.915009 26.84801,31.915009z M10.497003,26.411987L18.709003,26.411987 18.709003,31.915009 10.497003,31.915009z M20.052005,18.708984L25.386005,18.708984 25.386005,31.915009 20.052005,31.915009z M10.497003,14.221985L18.709003,14.221985 18.709003,25.057983 10.497003,25.057983z M20.052005,9.5660095L25.386005,9.5660095 25.386005,17.18399 20.052005,17.18399z M26.84801,7.07901L31.841998,7.07901 31.841998,25.057983 26.84801,25.057983z M10.497003,1.9949951L18.709003,1.9949951 18.709003,12.686005 10.497003,12.686005z M0,0L9.2280055,0 9.2280055,32 0,32z"/>
|
||||
</DrawingGroup.Children>
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
|
||||
<DrawingImage x:Key="Spawn">
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup>
|
||||
<DrawingGroup.Children>
|
||||
<GeometryDrawing Brush="Black" Geometry="M27,22.000013C25.346001,22.000013 24,23.345991 24,25.000013 24,26.654005 25.346001,28.000013 27,28.000013 28.653999,28.000013 30,26.654005 30,25.000013 30,23.345991 28.653999,22.000013 27,22.000013z M5,22C3.3460007,22 2,23.346 2,25 2,26.654 3.3460007,28 5,28 6.6540003,28 8,26.654 8,25 8,23.346 6.6540003,22 5,22z M16,2C14.346,2 13,3.3460007 13,5 13,6.6540003 14.346,8 16,8 17.654,8 19,6.6540003 19,5 19,3.3460007 17.654,2 16,2z M16,0C18.757,0 21,2.243 21,5 21,6.2061872 20.570676,7.3139925 19.856814,8.178627L19.749571,8.3023939 26.702677,20.009615 26.74309,20.006532C26.828189,20.002204 26.913844,20.000013 27,20.000013 29.757004,20.000013 32,22.242994 32,25.000013 32,27.757002 29.757004,30.000013 27,30.000013 24.242996,30.000013 22,27.757002 22,25.000013 22,23.104563 23.060166,21.452075 24.618662,20.604373L24.703606,20.560808 18.143555,9.5162544 17.944359,9.6064529C17.346375,9.8598127 16.68925,10 16,10 15.224594,10 14.489846,9.8225756 13.834221,9.5061913L13.749143,9.4625559 7.9581623,20.972196 7.9896793,20.994624C9.2092552,21.907268 10,23.363032 10,25 10,27.757 7.757,30 5,30 2.243,30 0,27.757 0,25 0,22.243 2.243,20 5,20 5.3446255,20 5.6812191,20.035047 6.0064049,20.101764L6.1420031,20.133139 12.151809,8.1885796 12.143186,8.178627C11.429324,7.3139925 11,6.2061872 11,5 11,2.243 13.243,0 16,0z"/>
|
||||
</DrawingGroup.Children>
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
|
||||
<DrawingImage x:Key="CancelIcon">
|
||||
<DrawingImage.Drawing>
|
||||
<GeometryDrawing>
|
||||
|
||||
@@ -8,12 +8,16 @@ using System.Linq;
|
||||
|
||||
namespace mbts.collections
|
||||
{
|
||||
public interface IObservableCollectionEx : IList, ICollection, IEnumerable, INotifyCollectionChanged
|
||||
public interface IReadOnlyObservableCollectionEx : ICollection, IEnumerable, INotifyPropertyChanged { }
|
||||
|
||||
public interface IReadOnlyObservableCollectionEx<T> : IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, INotifyCollectionChanged { }
|
||||
|
||||
public interface IObservableCollectionEx : IList, ICollection, IEnumerable, INotifyCollectionChanged, IReadOnlyObservableCollectionEx
|
||||
{
|
||||
void SetItems(IEnumerable items);
|
||||
}
|
||||
|
||||
public interface IObservableCollectionEx<T> : IList<T>, ICollection<T>, IList, ICollection, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, INotifyCollectionChanged
|
||||
public interface IObservableCollectionEx<T> : IList<T>, ICollection<T>, IList, ICollection, IReadOnlyObservableCollectionEx<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, INotifyCollectionChanged
|
||||
{
|
||||
void SetItems(IEnumerable<T> items);
|
||||
void AddRange(IEnumerable<T> items);
|
||||
|
||||
@@ -130,47 +130,21 @@ namespace mbts.ui.shell
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public abstract class DisposableViewModelBase : ViewModelBase, IDisposable
|
||||
{
|
||||
protected IDisposable _dispose = null;
|
||||
private List<IDisposable> _observable_properties;
|
||||
|
||||
protected Property<T> backing<T>(string name, IObservable<T> source, T default_value=default(T)) {
|
||||
if (_observable_properties == null) _observable_properties = new List<IDisposable>();
|
||||
var prop = new ObservablePropertySink<T>(this, name, default_value);
|
||||
_observable_properties.Add(source.Subscribe(prop));
|
||||
return prop;
|
||||
}
|
||||
|
||||
class ObservablePropertySink<T> : Property<T>, IObserver<T> {
|
||||
protected class ObservablePropertySink<T> : Property<T>, IObserver<T>
|
||||
{
|
||||
public ObservablePropertySink(ViewModelBase owner, string name, T default_val) : base(owner, name, default_val) { }
|
||||
public void OnCompleted() { }
|
||||
public void OnError(Exception error) { }
|
||||
|
||||
public void OnNext(T value) { set(value); }
|
||||
}
|
||||
|
||||
protected void set_dispose(IDisposable disposable) {
|
||||
if (_dispose != null) throw new InvalidOperationException("Cannot set disposable twice");
|
||||
_dispose = disposable;
|
||||
}
|
||||
protected void set_dispose(params IDisposable[] garbage) {
|
||||
set_dispose(Disposable.Create(garbage));
|
||||
}
|
||||
|
||||
public virtual void Dispose() {
|
||||
Disposable.dispose(ref _dispose);
|
||||
Disposable.dispose(_observable_properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class RequestViewCloseViewModelBase : ViewModelBase, IRequestViewClose
|
||||
{
|
||||
public void TryClose() {
|
||||
if (RequestClose != null)
|
||||
RequestClose(this, new EventArgs());
|
||||
RequestClose?.Invoke(this, new EventArgs());
|
||||
}
|
||||
|
||||
public event EventHandler RequestClose;
|
||||
@@ -227,9 +201,7 @@ namespace mbts.ui.shell
|
||||
}
|
||||
|
||||
private void FireErrorsChanged(string property) {
|
||||
if (ErrorsChanged != null) {
|
||||
ErrorsChanged(this, new DataErrorsChangedEventArgs(property));
|
||||
}
|
||||
ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(property));
|
||||
}
|
||||
|
||||
#region INotifyDataErrorInfo
|
||||
@@ -249,4 +221,34 @@ namespace mbts.ui.shell
|
||||
public IEnumerable<string> AllErrors { get { return _errors.Values; } }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class DisposableViewModelBase : ViewModelBaseWithValidation, IDisposable
|
||||
{
|
||||
protected IDisposable _dispose = null;
|
||||
private List<IDisposable> _observable_properties;
|
||||
|
||||
protected Property<T> backing<T>(string name, IObservable<T> source, T default_value = default(T)) {
|
||||
if (_observable_properties == null) _observable_properties = new List<IDisposable>();
|
||||
var prop = new ObservablePropertySink<T>(this, name, default_value);
|
||||
_observable_properties.Add(source.Subscribe(prop));
|
||||
return prop;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void set_dispose(IDisposable disposable) {
|
||||
if (_dispose != null) throw new InvalidOperationException("Cannot set disposable twice");
|
||||
_dispose = disposable;
|
||||
}
|
||||
protected void set_dispose(params IDisposable[] garbage) {
|
||||
set_dispose(Disposable.Create(garbage));
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing) { }
|
||||
public void Dispose() {
|
||||
Disposable.dispose(ref _dispose);
|
||||
Disposable.dispose(_observable_properties);
|
||||
Dispose(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,35 @@
|
||||
using mbts.ui.shell;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace mbts.ui.controls
|
||||
{
|
||||
public abstract class RXDataCellBase<T> : ViewModelBaseWithValidation, IDisposable
|
||||
public class RXReadOnlyDataGridCell<T> : SelectableViewModelBase, IDisposable
|
||||
{
|
||||
protected RXDataCellBase(IObservable<T> data_stream) {
|
||||
_sub = data_stream.ObserveOnDispatcher().Subscribe(t => { _output = t; RaisePropertyChanged("output"); });
|
||||
public RXReadOnlyDataGridCell(IObservable<T> data) : this(data, default(T)) { }
|
||||
public RXReadOnlyDataGridCell(IObservable<T> data, T initial_output) : this(data, initial_output, SynchronizationContext.Current) { }
|
||||
public RXReadOnlyDataGridCell(IObservable<T> data, T initial_output, SynchronizationContext context) {
|
||||
_output = new ObservablePropertySink<T>(this, nameof(output), initial_output);
|
||||
_sub = (context != null ? data.ObserveOn(context) : data).Subscribe(_output);
|
||||
}
|
||||
private readonly IDisposable _sub;
|
||||
private readonly ObservablePropertySink<T> _output;
|
||||
public T output => _output.Value;
|
||||
public void Dispose() { _sub.Dispose(); }
|
||||
}
|
||||
|
||||
private IDisposable _sub;
|
||||
|
||||
private T _output;
|
||||
public T output { get { return _output; } }
|
||||
public abstract class RXDataCellBase<T> : RXReadOnlyDataGridCell<T>
|
||||
{
|
||||
protected RXDataCellBase(IObservable<T> data_stream) : base(data_stream) { }
|
||||
|
||||
public T input {
|
||||
get { return _output; }
|
||||
get => output;
|
||||
set {
|
||||
bool valid = validate_input(value);
|
||||
using (validation())
|
||||
validation_assert(valid, "", "input");
|
||||
if (valid && confirm_input(value))
|
||||
_persist_input(value);
|
||||
using (validation()) validation_assert(valid, string.Empty, "input");
|
||||
if (valid && confirm_input(value)) _persist_input(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,12 +53,12 @@ namespace mbts.ui.controls
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
protected virtual bool confirm_input(T input) { return true; }
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously persists input.
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns>persistence Task</returns>
|
||||
protected abstract Task persist_input(T input);
|
||||
|
||||
public virtual void Dispose() {
|
||||
Disposable.dispose(ref _sub);
|
||||
}
|
||||
}
|
||||
|
||||
public class RXDataCell<T> : RXDataCellBase<T>
|
||||
@@ -69,16 +73,8 @@ namespace mbts.ui.controls
|
||||
private readonly Func<T, bool> _validate, _confirm;
|
||||
private readonly Func<T, Task> _persist;
|
||||
|
||||
protected override bool confirm_input(T input) {
|
||||
return _confirm(input);
|
||||
}
|
||||
|
||||
protected override bool validate_input(T input) {
|
||||
return _validate(input);
|
||||
}
|
||||
|
||||
protected override Task persist_input(T input) {
|
||||
return _persist(input);
|
||||
}
|
||||
protected override bool confirm_input(T input) { return _confirm(input); }
|
||||
protected override bool validate_input(T input) { return _validate(input); }
|
||||
protected override Task persist_input(T input) { return _persist(input); }
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -21,4 +21,13 @@ namespace mbts.ui.converters
|
||||
|
||||
public object[] ConvertBack(object values, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
//internal class SelectedExpsStringConverter : SelectedItemsStringConverter
|
||||
//{
|
||||
// protected override string GetItemString(object item) {
|
||||
// var exp = item as SecurityExpiration;
|
||||
// if (exp == null) return string.Empty;
|
||||
// return SecurityDisplay.format_expiration(exp);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
@@ -162,10 +162,19 @@ namespace mbts.ui
|
||||
window.ensure_onscreen();
|
||||
}
|
||||
|
||||
public static void Show(this Window window, int off_x, int off_y, bool dispose_vm_on_close=false) {
|
||||
public static IDisposable Show(this Window window, int off_x=int.MinValue, int off_y=int.MinValue, bool dispose_vm_on_close=false) {
|
||||
window.move_to_mouse(off_x, off_y);
|
||||
if (dispose_vm_on_close) window.Closed += (s, e) => (window.DataContext as IDisposable)?.Dispose();
|
||||
if (off_x != int.MinValue && off_y != int.MinValue) window.move_to_mouse(off_x, off_y);
|
||||
else window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
window.Show();
|
||||
return Disposable.Create(() => {
|
||||
// not very elegant, but safe and effective
|
||||
if (window != null) {
|
||||
try { window.Close(); }
|
||||
catch { }
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,4 +60,16 @@
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- Removed ExpirationLabel
|
||||
<Style x:Key="ExpirationFilter" TargetType="control:MultiSelectDropDown" BasedOn="{StaticResource {x:Type control:MultiSelectDropDown}}">
|
||||
<Setter Property="ItemTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<control:ExpirationLabel Security="{Binding security}" ExpDate="{Binding expiration}" />
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>-->
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -2,7 +2,10 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:uc="clr-namespace:mbts.ui"
|
||||
xmlns:u="clr-namespace:mbts.ui"
|
||||
xmlns:cv="clr-namespace:mbts.ui.converters">
|
||||
xmlns:cv="clr-namespace:mbts.ui.converters"
|
||||
xmlns:usp="clr-namespace:mbts.ui.spark"
|
||||
xmlns:uspcv="clr-namespace:mbts.ui.spark.converters"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib">
|
||||
<cv:BooleanOrConverter x:Key="OrConverter" />
|
||||
<cv:BooleanAndConverter x:Key="AndConverter" />
|
||||
<cv:NotConverter x:Key="NotConverter" />
|
||||
@@ -47,4 +50,10 @@
|
||||
<cv:ValueMap x:Key="IsEnabledOpacityConverter" Default="{u:Double 1}">
|
||||
<cv:KeyValue Key="{u:False}" Value="{u:Double 0.56}" />
|
||||
</cv:ValueMap>
|
||||
<uspcv:TickDisplayConverter x:Key="TickDisplayConverter" HideNaN="True"/>
|
||||
<uspcv:ImageSourceIconConverter x:Key="IconConverter"/>
|
||||
<cv:NumericSignBrushConverter x:Key="PositionSignBrushConverter" Zero="{StaticResource IntZero}"/>
|
||||
<cv:NumericSignBrushConverter x:Key="DayChangeSignBrushConverter" Zero="{StaticResource DoubleZero}"/>
|
||||
<sys:Int32 x:Key="IntZero">0</sys:Int32>
|
||||
<sys:Double x:Key="DoubleZero">0</sys:Double>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Reactive.Linq;
|
||||
using System.Reactive.Subjects;
|
||||
|
||||
namespace mbts.ui.utilities
|
||||
{
|
||||
public class ColdObseravbleProperty<T> : IObservable<T>, IDisposable {
|
||||
private readonly Subject<T> _subject = new Subject<T>();
|
||||
private T _value;
|
||||
public T Value { get => _value; set => set(value); }
|
||||
public void set(T value) { _subject.OnNext(_value = value); }
|
||||
public IDisposable Subscribe(IObserver<T> observer) {
|
||||
return (_value != null ? _subject.StartWith(_value) : _subject.AsObservable()).Subscribe(observer);
|
||||
}
|
||||
public void Dispose() { _subject.Dispose(); }
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@ namespace mbts.ui.utility
|
||||
{
|
||||
public static readonly ICommand Empty = new DelegateCommand(() => { });
|
||||
|
||||
public static readonly ICommand Disabled = new DelegateCommand(() => { }, () => false);
|
||||
|
||||
public static ICommand AddShellWindow(IWindowManager wm, Func<IShellWindow> factory) { return new DelegateCommand(() => wm.Windows.Add(factory())); }
|
||||
|
||||
public static ICommand ExportToCSV(Func<IEnumerable<string>> csv_rows) { return ExportToCSV<object>(_ => csv_rows()); }
|
||||
|
||||
@@ -8,9 +8,9 @@ namespace mbts.ui.utility
|
||||
{
|
||||
public class RXObservableCollection<T> : ObservableCollection<T>, IObserver<IEnumerable<T>>, IDisposable
|
||||
{
|
||||
public RXObservableCollection(IObservable<IEnumerable<T>> data_stream) : this(data_stream, SynchronizationContext.Current) { }
|
||||
public RXObservableCollection(IObservable<IEnumerable<T>> data_stream, SynchronizationContext context) {
|
||||
_sub = data_stream.ObserveOn(context).Subscribe(this);
|
||||
public RXObservableCollection(IObservable<IEnumerable<T>> data) : this(data, SynchronizationContext.Current) { }
|
||||
public RXObservableCollection(IObservable<IEnumerable<T>> data, SynchronizationContext context) {
|
||||
_sub = (context != null ? data.ObserveOn(context) : data).Subscribe(this);
|
||||
}
|
||||
|
||||
private IDisposable _sub;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using mbts.utils;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reactive.Linq;
|
||||
|
||||
namespace mbts.ui.shell
|
||||
{
|
||||
public abstract class SelectableViewModelBase : ViewModelBaseWithValidation, ISelectable
|
||||
{
|
||||
protected SelectableViewModelBase() {
|
||||
_is_selected = backing(nameof(is_selected), false);
|
||||
}
|
||||
private readonly Property<bool> _is_selected;
|
||||
public bool is_selected { get => _is_selected.Value; set => _is_selected.set(value); }
|
||||
public IObservable<bool> observe_is_selected() { return _is_selected.Select(vals => vals.newval); }
|
||||
}
|
||||
|
||||
public class SelectableViewModelBase<T> : SelectableViewModelBase, IComparable<SelectableViewModelBase<T>>, IComparable
|
||||
{
|
||||
public SelectableViewModelBase(T initial_value = default(T)) {
|
||||
_value = backing(nameof(value), initial_value);
|
||||
}
|
||||
private readonly Property<T> _value;
|
||||
public T value { get => _value.Value; set => _value.set(value); }
|
||||
|
||||
public int CompareTo(SelectableViewModelBase<T> other) {
|
||||
if (other == null) return -1;
|
||||
if (other.value == null) return value == null ? 0 : -1;
|
||||
var comp = Comparer<T>.Default;
|
||||
return comp == null ? 0 : comp.Compare(value, other.value);
|
||||
}
|
||||
|
||||
public int CompareTo(object obj) { return CompareTo(obj as SelectableViewModelBase<T>); }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user