Пример #1
0
        public PortfolioValueTimeSeriesViewModel(
            PortfolioTrackerContext dbContext,
            IMarketProvider provider)
        {
            DbContext = dbContext;
            Provider  = provider;

            LoadPortfolioValueTimeSeriesDataCommand = new DelegateCommand <int>(LoadPortfolioValueTimeSeriesData, CanLoadPortfolioValueTimeSeriesData);

            LoadPortfolioValueTimeSeriesDataCommand.Execute(30);

            XAxisFormatter = value =>
            {
                var days = (DateTime.Today - MinDate).Days;
                var date = new DateTime((long)(value * TimeSpan.FromHours(1).Ticks));

                if (days < 365)
                {
                    return(value < 0 ? "" : date.ToString("MMM dd"));
                }
                else
                {
                    return(value < 0 ? "" : date.ToString("MMM `yy"));
                }
            };
        }
Пример #2
0
        public RootViewModel(
            ViewModelFactory viewModelFactory,
            PortfolioTrackerContext portfolioTrackerContext)
        {
            ViewModelFactory        = viewModelFactory;
            PortfolioTrackerContext = portfolioTrackerContext;
            ChangeViewModelCommand  = new DelegateCommand <string>(x =>
            {
                if (ChildViewModel != null)
                {
                    ChildViewModel.IsBusyChanged -= ChildIsBusyChangedEventHandler;
                    if (ChildViewModel.IsBusy)
                    {
                        DecrementBusyCounter();
                    }
                }
                switch (x)
                {
                case nameof(AccountSummaryViewModel):
                    ChildViewModel = ViewModelFactory.GetInstance <AccountSummaryViewModel>();
                    break;

                case nameof(HistoryViewModel):
                    ChildViewModel = ViewModelFactory.GetInstance <HistoryViewModel>();
                    break;

                default:
                    throw new InvalidOperationException("Unknown view model.");
                }
                if (ChildViewModel != null)
                {
                    if (ChildViewModel.IsBusy)
                    {
                        IncrementBusyCounter();
                    }
                    ChildViewModel.IsBusyChanged += ChildIsBusyChangedEventHandler;
                }
                ChildViewModel.AccountId = AccountId;
            });
            //Test();
            ChangeViewModelCommand.Execute(nameof(AccountSummaryViewModel));
        }
Пример #3
0
 public HistoryViewModel(PortfolioTrackerContext dbContext)
 {
     DbContext = dbContext;
 }