Exemplo n.º 1
0
        public MainViewModel()
        {
            AccountsVM   = new AccountsViewModel();
            SettingsVM   = new SettingsViewModel();
            AddAccountVM = new AddAccountViewModel();

            CurrentView = AccountsVM;

            AccountsViewCommand = new RelayCommand(o =>
            {
                CurrentView = AccountsVM;
            });

            SettingsViewCommand = new RelayCommand(o =>
            {
                CurrentView = SettingsVM;
            });

            AddAccountViewCommand = new RelayCommand(o =>
            {
                CurrentView = AddAccountVM;
            });

            EditAccountViewCommand = new RelayCommand(o =>
            {
                EditAccountV = new EditAccountView((int)o);
                CurrentView  = EditAccountV;
            });

            ExitCommand = new RelayCommand(o =>
            {
                try
                {
                    Application.Current.Shutdown();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            });

            MinimizeCommand = new RelayCommand(o =>
            {
                try
                {
                    CurWindowState = WindowState.Minimized;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            });
        }
Exemplo n.º 2
0
        public void NewAccount(Guid? parentAccountId)
        {
            var parent = parentAccountId.HasValue ? this.book.Accounts.Where(a => a.AccountId == parentAccountId.Value).Single() : null;
            var newAccount = new Account(
                Guid.NewGuid(),
                AccountType.Balance,
                parent == null ? null : parent.Security,
                parent,
                "New Account",
                parent == null ? null : parent.SmallestFraction);

            using (var editor = new EditAccountView(this, newAccount))
            {
                var result = editor.ShowDialog();
                if (result == DialogResult.Cancel)
                {
                    return;
                }

                this.book.AddAccount(editor.NewAccount);
            }
        }