Example #1
0
        public DepositsViewModel(KeeperDb db, RateExtractor rateExtractor,
                                 DepositCalculationAggregator depositCalculatorAggregator,
                                 OldRatesDiagramDataExtractor oldRatesDiagramDataExtractor)
        {
            var sw = new Stopwatch();

            Console.WriteLine("DepositViewModel ctor starts {0}", sw.Elapsed);
            sw.Start();

            _db            = db;
            _rateExtractor = rateExtractor;
            _depositCalculatorAggregator  = depositCalculatorAggregator;
            _oldRatesDiagramDataExtractor = oldRatesDiagramDataExtractor;

            MyTitleStyle = new Style();

            DepositList = new List <Deposit>();
            foreach (var account in _db.FlattenAccounts())
            {
                if (!account.Is("Депозиты") || account.Children.Count != 0 || !account.IsDeposit())
                {
                    continue;
                }
                _depositCalculatorAggregator.FillinFieldsForOneDepositReport(account.Deposit);
                DepositList.Add(account.Deposit);
            }
            SelectedDeposit = DepositList[0];

            UpperRow    = new GridLength(1, GridUnitType.Star);
            LowerRow    = new GridLength(1, GridUnitType.Star);
            LeftColumn  = new GridLength(1, GridUnitType.Star);
            RightColumn = new GridLength(1, GridUnitType.Star);

            DepoCurrenciesProportionChartCtor();
            Console.WriteLine("DepositViewModel ctor 1 {0}", sw.Elapsed);
            YearsProfitCtor();
            Console.WriteLine("DepositViewModel ctor 2 {0}", sw.Elapsed);
            TotalBalancesCtor();
            Console.WriteLine("DepositViewModel ctor 3 {0}", sw.Elapsed);
//            CashDepoProportionChartCtor();

            sw.Stop();
            Console.WriteLine("DepositViewModel ctor takes {0}", sw.Elapsed);
        }
        public void ShowDepositReport()
        {
            if (!MyForestModel.SelectedAccount.IsDeposit() || MyForestModel.SelectedAccount.Children.Count != 0)
            {
                return;
            }

            foreach (var launchedForm in _launchedForms)
            {
                if (launchedForm is DepositViewModel && launchedForm.IsActive &&
                    ((DepositViewModel)launchedForm).Deposit.ParentAccount == MyForestModel.SelectedAccount)
                {
                    launchedForm.TryClose();
                }
            }

            var depositForm = IoC.Get <DepositViewModel>();

            _depositCalculationAggregator.FillinFieldsForOneDepositReport(MyForestModel.SelectedAccount.Deposit);
            depositForm.SetAccount(MyForestModel.SelectedAccount);
            _launchedForms.Add(depositForm);
            depositForm.RenewPressed += DepositViewModelRenewed; // подписываемся на переофрмление депозита, если оно произойдет надо сменить селекшен
            WindowManager.ShowWindow(depositForm);
        }