public SettingsWindowViewmodel(MainWindow main, AppSettings data)
        {
            mainWindow = main;
            Settings   = data;

            ShortcutList = ShortcutManager.ListObservableShortcuts(data);

            AvailableThemes   = App.Themes.GetAllAvailableThemes();
            AvailableModifier = App.Themes.GetAllAvailableModifier().Select(m => new CheckableAlephTheme {
                Theme = m, Owner = this, Checked = data.ThemeModifier.Contains(m.SourceFilename)
            }).ToList();

            _selectedTheme = App.Themes.GetThemeByFilename(Settings.Theme, out _)
                             ?? App.Themes.GetDefault()
                             ?? AvailableThemes.FirstOrDefault()
                             ?? App.Themes.GetFallback();

            _oldTheme     = ThemeManager.Inst.CurrentBaseTheme;
            _oldModifiers = ThemeManager.Inst.CurrentModifers.ToList();

            SnippetList = new ObservableCollectionNoReset <EditableSnippet>(data.Snippets.Data.Select(p => new EditableSnippet {
                PreviewFunc = SnippetPrev, ID = p.Key, Name = p.Value.DisplayName, Value = p.Value.Value
            }));
            NewSnippetID = GetNextSnippetID();
        }
 public OrdersListViewModel(
     IDispatcherHelper dispatcherHelper,
     IQueueProcessor queueProcessor,
     INewOrderViewModelFactory newOrderViewModelFactory,
     ITradeRepository tradeRepository,
     IMarketDataManager marketDataManager)
     : base(dispatcherHelper, queueProcessor)
 {
     _newOrderViewModelFactory = newOrderViewModelFactory;
     _tradeRepository          = tradeRepository;
     _marketDataManager        = marketDataManager;
     PopulateDirectionList();
     Messenger.Default.Register <OrderStatusChangedMessage>(this, OrderStatusChangedMessage.Tokens.Orders, OnOrderStatusChangedMessage);
     Messenger.Default.Register <BarPriceMessage>(this, HandleBarPriceMessage);
     Orders = new ObservableCollectionNoReset <NewOrderViewModel>(dispatcherHelper: DispatcherHelper);
     Orders.CollectionChanged += OnOrdersCollectionChanged;
 }
Example #3
0
        public static ObservableCollectionNoReset <ObservableShortcutConfig> ListObservableShortcuts(AppSettings settings)
        {
            var result = new ObservableCollectionNoReset <ObservableShortcutConfig>();

            foreach (var a in _actions)
            {
                if (settings.Shortcuts.TryGetValue(a.Key, out var def))
                {
                    result.Add(new ObservableShortcutConfig(a.Key, a.Value.Description, def.Key, def.Modifiers, def.Scope));
                }
                else
                {
                    result.Add(new ObservableShortcutConfig(a.Key, a.Value.Description, AlephKey.None, AlephModifierKeys.None, a.Value.DefaultScope));
                }
            }

            return(result);
        }
Example #4
0
        public PositionsViewModel(
            IDispatcherHelper dispatcherHelper,
            IMarketDataManager marketDataManager,
            IAccountManager accountManager,
            IPositionManager positionManager,
            IContractManager contractManager,
            IQueueProcessor queueProcessor,
            ITradeRecordingService tradeRecordingService)
            : base(dispatcherHelper, queueProcessor)
        {
            Positions = new ObservableCollectionNoReset <PositionItem>(dispatcherHelper: DispatcherHelper);

            Messenger.Default.Register <ConnectionChangingMessage>(this, HandleConnectionChangingMessage);
            Messenger.Default.Register <OrderStatusChangedMessage>(this, OrderStatusChangedMessage.Tokens.Positions, OnOrderStatusChangedMessage);
            Messenger.Default.Register <BarPriceMessage>(this, HandleBarPriceMessage);

            _marketDataManager     = marketDataManager;
            _accountManager        = accountManager;
            _positionManager       = positionManager;
            _contractManager       = contractManager;
            _queueProcessor        = queueProcessor;
            _tradeRecordingService = tradeRecordingService;
        }