Exemplo n.º 1
0
        public AccountManagementPageViewModel(ApplicationViewModel application) : base(application)
        {
            _accounts = new ObservableCollection <RecentAccountViewModel>();
            Accounts  = new ReadOnlyObservableCollection <RecentAccountViewModel>(_accounts);
            CreateAccountsEntries();

            NewAccountNameProperty  = new SingleValuedProperty <string>();
            CreateNewAccountCommand = new CommandViewModel(OnCreateNewAccountCommand);
            OpenAccountCommand      = new CommandViewModel(OnOpenAccountCommand);
            SelectFileCommand       = new CommandViewModel(OnSelectFileCommand);

            NewAccountNameProperty.OnValueChanged += UpdateCommandStates;

            UpdateCommandStates();

            Caption = Properties.Resources.AccountManagementPageCaption;
        }
        public AccountManagementPageViewModel(ApplicationViewModel application)
            : base(application)
        {
            _accounts = new ObservableCollection<RecentAccountViewModel>();
            Accounts = new ReadOnlyObservableCollection<RecentAccountViewModel>(_accounts);
            CreateAccountsEntries();

            NewAccountNameProperty = new SingleValuedProperty<string>();
            CreateNewAccountCommand = new CommandViewModel(OnCreateNewAccountCommand);
            OpenAccountCommand = new CommandViewModel(OnOpenAccountCommand);
            SelectFileCommand = new CommandViewModel(OnSelectFileCommand);

            NewAccountNameProperty.OnValueChanged += UpdateCommandStates;

            UpdateCommandStates();

            Caption = Properties.Resources.AccountManagementPageCaption;
        }
        public StandingOrderDetailsViewModel(ApplicationViewModel application, Action <StandingOrderEntityData> onSave, Action <StandingOrderDetailsViewModel> onCancel)
        {
            _application     = application;
            SaveCommand      = new CommandViewModel(() => onSave(CreateStandingOrderEntityData()));
            CancelCommand    = new CommandViewModel(() => onCancel(this));
            PaymentsProperty = new SingleValuedProperty <int> {
                Value = 1
            };
            ValueProperty = new SingleValuedProperty <double>();
            IsEndingTransactionProperty = new SingleValuedProperty <bool>();
            MonthPeriods          = new EnumeratedSingleValuedProperty <MonthPeriod>();
            Categories            = new EnumeratedSingleValuedProperty <CategoryViewModel>();
            FirstBookDateProperty = new SingleValuedProperty <DateTime>();
            DescriptionProperty   = new SingleValuedProperty <string>();
            RequestKind           = new EnumeratedSingleValuedProperty <RequestKind>();

            IsEndingTransactionProperty.OnValueChanged += OnIsEndingTransactionPropertyChanged;
            MonthPeriods.OnValueChanged     += OnMonthPeriodsPropertyChanged;
            PaymentsProperty.OnValueChanged += OnPaymentsPropertyChanged;
            RequestKind.OnValueChanged      += RequestKindOnOnValueChanged;
            ValueProperty.OnIsValidChanged  += ValuePropertyOnOnIsValidChanged;
            ValueProperty.OnValueChanged    += ValuePropertyOnOnValueChanged;
            ValueProperty.Validate           = ValidateValueProperty;

            foreach (MonthPeriod value in Enum.GetValues(typeof(MonthPeriod)))
            {
                MonthPeriods.AddValue(value);
            }

            var allCategoryViewModels = application.Repository.QueryAllCategories().Select(c => new CategoryViewModel(application, c.PersistentId)).ToList();

            allCategoryViewModels.ForEach(a => a.Refresh());
            Categories.SetRange(allCategoryViewModels.OrderBy(c => c.Name));
            FirstBookDateProperty.Value = application.ApplicationContext.Now.Date;

            RequestKind.SetRange(Enum.GetValues(typeof(RequestKind)).Cast <RequestKind>());
            RequestKind.Value = RequestManagement.RequestKind.Expenditure;

            UpdateCommandStates();
            UpdateCaption();
        }
        public StandingOrderManagementViewModel(ApplicationViewModel application, Action onStandingOrderUpdated)
        {
            _application = application;
            _onStandingOrderUpdated = onStandingOrderUpdated;
            StandingOrders = new EnumeratedSingleValuedProperty<StandingOrderEntityViewModel>();
            StandingOrders.OnValueChanged += OnStandingOrdersValueChangd;

            _allStandingOrders =
                application.Repository.QueryAllStandingOrderEntities()
                    .Select(r => new StandingOrderEntityViewModel(application, r.PersistentId)).ToList();

            _allStandingOrders.ForEach(s => s.Refresh());
            CreateStandingOrderCommand = new CommandViewModel(OnCreateStandingOrderCommand);
            DeleteStandingOrderCommand = new CommandViewModel(OnDeleteStandingOrderCommand);
            ShowFinishedProperty = new SingleValuedProperty<bool>();

            ShowFinishedProperty.OnValueChanged += ShowFinishedPropertyOnOnValueChanged;

            UpdateStandingOrdersWithFiltering();
            UpdateCommandStates();
        }
        public StandingOrderManagementViewModel(ApplicationViewModel application, Action onStandingOrderUpdated)
        {
            _application                   = application;
            _onStandingOrderUpdated        = onStandingOrderUpdated;
            StandingOrders                 = new EnumeratedSingleValuedProperty <StandingOrderEntityViewModel>();
            StandingOrders.OnValueChanged += OnStandingOrdersValueChangd;

            _allStandingOrders =
                application.Repository.QueryAllStandingOrderEntities()
                .Select(r => new StandingOrderEntityViewModel(application, r.PersistentId)).ToList();

            _allStandingOrders.ForEach(s => s.Refresh());
            CreateStandingOrderCommand = new CommandViewModel(OnCreateStandingOrderCommand);
            DeleteStandingOrderCommand = new CommandViewModel(OnDeleteStandingOrderCommand);
            ShowFinishedProperty       = new SingleValuedProperty <bool>();

            ShowFinishedProperty.OnValueChanged += ShowFinishedPropertyOnOnValueChanged;

            UpdateStandingOrdersWithFiltering();
            UpdateCommandStates();
        }
        public StandingOrderDetailsViewModel(ApplicationViewModel application, Action<StandingOrderEntityData> onSave, Action<StandingOrderDetailsViewModel> onCancel)
        {
            _application = application;
            SaveCommand = new CommandViewModel(() => onSave(CreateStandingOrderEntityData()));
            CancelCommand = new CommandViewModel(() => onCancel(this));
            PaymentsProperty = new SingleValuedProperty<int> { Value = 1 };
            ValueProperty = new SingleValuedProperty<double>();
            IsEndingTransactionProperty = new SingleValuedProperty<bool>();
            MonthPeriods = new EnumeratedSingleValuedProperty<MonthPeriod>();
            Categories = new EnumeratedSingleValuedProperty<CategoryViewModel>();
            FirstBookDateProperty = new SingleValuedProperty<DateTime>();
            DescriptionProperty = new SingleValuedProperty<string>();
            RequestKind = new EnumeratedSingleValuedProperty<RequestKind>();

            IsEndingTransactionProperty.OnValueChanged += OnIsEndingTransactionPropertyChanged;
            MonthPeriods.OnValueChanged += OnMonthPeriodsPropertyChanged;
            PaymentsProperty.OnValueChanged += OnPaymentsPropertyChanged;
            RequestKind.OnValueChanged += RequestKindOnOnValueChanged;
            ValueProperty.OnIsValidChanged += ValuePropertyOnOnIsValidChanged;
            ValueProperty.OnValueChanged += ValuePropertyOnOnValueChanged;
            ValueProperty.Validate = ValidateValueProperty;

            foreach (MonthPeriod value in Enum.GetValues(typeof(MonthPeriod)))
            {
                MonthPeriods.AddValue(value);
            }

            var allCategoryViewModels = application.Repository.QueryAllCategories().Select(c => new CategoryViewModel(application, c.PersistentId)).ToList();
            allCategoryViewModels.ForEach(a => a.Refresh());
            Categories.SetRange(allCategoryViewModels.OrderBy(c => c.Name));
            FirstBookDateProperty.Value = application.ApplicationContext.Now.Date;

            RequestKind.SetRange(Enum.GetValues(typeof(RequestKind)).Cast<RequestKind>());
            RequestKind.Value = RequestManagement.RequestKind.Expenditure;

            UpdateCommandStates();
            UpdateCaption();
        }
Exemplo n.º 7
0
        private void InitializeViewModel(ApplicationViewModel application, int year, int month, string selectedCategoryId, Action <RequestDialogViewModel> onOk)
        {
            _onOk                = onOk;
            Categories           = new EnumeratedSingleValuedProperty <CategoryViewModel>();
            DescriptionProperty  = new SingleValuedProperty <string>();
            ValueProperty        = new SingleValuedProperty <double>();
            DateProperty         = new SingleValuedProperty <DateTime>();
            CreateRequestCommand = new CommandViewModel(OnCreateRequestCommand);
            RequestKind          = new EnumeratedSingleValuedProperty <RequestKind>();

            DateProperty.OnValueChanged    += DatePropertyOnOnValueChanged;
            RequestKind.OnValueChanged     += RequestKindOnOnValueChanged;
            ValueProperty.Validate          = ValidateValueProperty;
            ValueProperty.OnIsValidChanged += ValuePropertyOnOnIsValidChanged;
            ValueProperty.OnValueChanged   += ValuePropertyOnOnValueChanged;

            FirstPossibleDate = new DateTime(year, month, 1);
            LastPossibleDate  = new DateTime(year, month, DateTime.DaysInMonth(year, month));
            RequestKind.SetRange(Enum.GetValues(typeof(RequestKind)).Cast <RequestKind>());
            RequestKind.Value = RequestManagement.RequestKind.Expenditure;

            var categories = application.Repository.QueryAllCategories()
                             .Select(c => new CategoryViewModel(application, c.PersistentId))
                             .ToList();

            categories.ForEach(c => c.Refresh());
            Categories.SetRange(categories.OrderBy(c => c.Name));

            if (!string.IsNullOrEmpty(selectedCategoryId))
            {
                Categories.Value = Categories.SelectableValues.Single(c => c.EntityId == selectedCategoryId);
            }

            UpdateLocalizedProperties();
            UpdateCommandStates();
        }
Exemplo n.º 8
0
        private void InitializeViewModel(ApplicationViewModel application, int year, int month, string selectedCategoryId, Action<RequestDialogViewModel> onOk)
        {
            _onOk = onOk;
            Categories = new EnumeratedSingleValuedProperty<CategoryViewModel>();
            DescriptionProperty = new SingleValuedProperty<string>();
            ValueProperty = new SingleValuedProperty<double>();
            DateProperty = new SingleValuedProperty<DateTime>();
            CreateRequestCommand = new CommandViewModel(OnCreateRequestCommand);
            RequestKind = new EnumeratedSingleValuedProperty<RequestKind>();

            DateProperty.OnValueChanged += DatePropertyOnOnValueChanged;
            RequestKind.OnValueChanged += RequestKindOnOnValueChanged;
            ValueProperty.Validate = ValidateValueProperty;
            ValueProperty.OnIsValidChanged += ValuePropertyOnOnIsValidChanged;
            ValueProperty.OnValueChanged += ValuePropertyOnOnValueChanged;

            FirstPossibleDate = new DateTime(year, month, 1);
            LastPossibleDate = new DateTime(year, month, DateTime.DaysInMonth(year, month));
            RequestKind.SetRange(Enum.GetValues(typeof(RequestKind)).Cast<RequestKind>());
            RequestKind.Value = RequestManagement.RequestKind.Expenditure;

            var categories = application.Repository.QueryAllCategories()
                                                   .Select(c => new CategoryViewModel(application, c.PersistentId))
                                                   .ToList();
            categories.ForEach(c => c.Refresh());
            Categories.SetRange(categories.OrderBy(c => c.Name));

            if (!string.IsNullOrEmpty(selectedCategoryId))
            {
                Categories.Value = Categories.SelectableValues.Single(c => c.EntityId == selectedCategoryId);
            }

            UpdateLocalizedProperties();
            UpdateCommandStates();
        }