Esempio n. 1
0
        public MainViewModel(XtbWrapper xtbWrapper)
        {
            RxApp.MainThreadScheduler = new DispatcherScheduler(Application.Current.Dispatcher);

            _xtbWrapper = xtbWrapper;

            Symbols = new ObservableCollection <SymbolViewModel>();

            SearchSymbolCommand = ReactiveCommand.CreateAsyncTask(ExecuteSearchSymbol, RxApp.MainThreadScheduler);

            this.ObservableForProperty(x => x.SelectedSymbol)
            .Throttle(TimeSpan.FromSeconds(0.1), RxApp.MainThreadScheduler)
            .Subscribe(ExecuteLoadTickData);

            this.ObservableForProperty(x => x.SearchText)
            .Throttle(TimeSpan.FromSeconds(0.2), RxApp.MainThreadScheduler)
            .Subscribe(SearchSymbolCommand.Execute);

            if (IsInDesignMode)
            {
                IsLoggedIn = true;
            }

            LoginCommand  = ReactiveCommand.CreateAsyncTask(CreateCanExecutePasswordObservable(), ExecuteLoginAsync, RxApp.MainThreadScheduler);
            LogoutCommand = ReactiveCommand.CreateAsyncTask(ExecuteLogoutAsync, RxApp.MainThreadScheduler);

            RememberLoginData = Settings.Default.RememberLoginData;
            Login             = Settings.Default.Login;
            Password          = Settings.Default.Password.Decrypt().ToSecureString();
            IsDemoAccount     = Settings.Default.IsDemoAccount;
        }
Esempio n. 2
0
        public SymbolViewModel(XtbWrapper xtbWrapper, string name, string description)
        {
            _xtbWrapper = xtbWrapper;
            StatusText  = "Ready";

            Name        = name;
            Description = description;

            if (IsInDesignMode)
            {
                IsBusy = true;
            }

            Plots        = new ObservableCollection <PlotViewModel>();
            Ticks        = new ObservableCollection <TickData>();
            LoadTickData = ReactiveCommand.CreateAsyncTask(this.WhenAny(x => x.IsBusy, x => !x.Value && !string.IsNullOrEmpty(Name)),
                                                           ExecuteLoadTickDataAsync, RxApp.MainThreadScheduler);

            UpdatePlot(_lastLoadedDuration);
        }