public void RemoveValue(int[] available, int selected, int deleted, int expectedNewSelected) { var property = new EnumeratedSingleValuedProperty<int>(); foreach (var i in available) { property.AddValue(i); } property.Value = selected; property.RemoveValue(deleted); Assert.That(property.Value, Is.EqualTo(expectedNewSelected)); Assert.That(property.SelectableValues.Count, Is.EqualTo(available.Length-1)); }
public void RemoveValue(int[] available, int selected, int deleted, int expectedNewSelected) { var property = new EnumeratedSingleValuedProperty <int>(); foreach (var i in available) { property.AddValue(i); } property.Value = selected; property.RemoveValue(deleted); Assert.That(property.Value, Is.EqualTo(expectedNewSelected)); Assert.That(property.SelectableValues.Count, Is.EqualTo(available.Length - 1)); }
public CategoryManagementDialogViewModel(ApplicationViewModel application, Action<CategoryManagementDialogViewModel> ok) { CategoriesToDelete = new List<CategoryEditViewModel>(); Categories = new EnumeratedSingleValuedProperty<CategoryEditViewModel>(); Categories.PropertyChanged += CategoriesOnPropertyChanged; foreach (var categoryViewModel in application.Repository.QueryAllCategories().Select(c => new CategoryEditViewModel(c.PersistentId, c.Name, OnDeleteCategory))) { Categories.AddValue(categoryViewModel); } OkCommand = new CommandViewModel(() => ok(this)); NewCategoryCommand = new CommandViewModel(OnNewCategoryCommand); UpdateCommandStates(); }
public CategoryManagementDialogViewModel(ApplicationViewModel application, Action <CategoryManagementDialogViewModel> ok) { CategoriesToDelete = new List <CategoryEditViewModel>(); Categories = new EnumeratedSingleValuedProperty <CategoryEditViewModel>(); Categories.PropertyChanged += CategoriesOnPropertyChanged; foreach (var categoryViewModel in application.Repository.QueryAllCategories().Select(c => new CategoryEditViewModel(c.PersistentId, c.Name, OnDeleteCategory))) { Categories.AddValue(categoryViewModel); } OkCommand = new CommandViewModel(() => ok(this)); NewCategoryCommand = new CommandViewModel(OnNewCategoryCommand); UpdateCommandStates(); }
public RequestManagementPageViewModel(ApplicationViewModel application, int year, int month) : base(application) { Months = new EnumeratedSingleValuedProperty<MonthNameViewModel>(); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameJanuary, 1)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameFebuary, 2)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameMarch, 3)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameApril, 4)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameMay, 5)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameJune, 6)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameJuly, 7)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameAugust, 8)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameSeptember, 9)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameOctober, 10)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameNovember, 11)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameDecember, 12)); Requests = new EnumeratedSingleValuedProperty<RequestViewModel>(); _year = year; Months.Value = Months.SelectableValues.Single(m => m.Index == month); AddRequestCommand = new CommandViewModel(OnAddRequestCommand); DeleteRequestCommand = new CommandViewModel(OnDeleteRequestCommand); PreviousMonthCommand = new CommandViewModel(OnPreviousMonthCommand); NextMonthCommand = new CommandViewModel(OnNextMonthCommand); EditRequestCommand = new CommandViewModel(OnEditRequestCommand); SwitchAccountCommand = new CommandViewModel(OnSwitchAccountCommand); EditCategoriesCommand = new CommandViewModel(OnEditCategoriesCommand); GotoCurrentMonthCommand = new CommandViewModel(OnGotoCurrentMonthCommand); EditStandingOrdersCommand = new CommandViewModel(OnEditStandingOrdersCommand); Months.PropertyChanged += OnMonthsPropertyChanged; Requests.PropertyChanged += OnSelectedRequestChanged; UpdateCurrentMonth(); UpdateCommandStates(); UpdateSaldoAsString(); UpdateMonthsIsEnabled(); Caption = string.Format(Properties.Resources.RequestManagementPageCaptionFormat, Application.Repository.Name); }
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 RequestManagementPageViewModel(ApplicationViewModel application, int year, int month) : base(application) { Months = new EnumeratedSingleValuedProperty <MonthNameViewModel>(); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameJanuary, 1)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameFebuary, 2)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameMarch, 3)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameApril, 4)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameMay, 5)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameJune, 6)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameJuly, 7)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameAugust, 8)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameSeptember, 9)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameOctober, 10)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameNovember, 11)); Months.AddValue(new MonthNameViewModel(Properties.Resources.MonthNameDecember, 12)); Requests = new EnumeratedSingleValuedProperty <RequestViewModel>(); _year = year; Months.Value = Months.SelectableValues.Single(m => m.Index == month); AddRequestCommand = new CommandViewModel(OnAddRequestCommand); DeleteRequestCommand = new CommandViewModel(OnDeleteRequestCommand); PreviousMonthCommand = new CommandViewModel(OnPreviousMonthCommand); NextMonthCommand = new CommandViewModel(OnNextMonthCommand); EditRequestCommand = new CommandViewModel(OnEditRequestCommand); SwitchAccountCommand = new CommandViewModel(OnSwitchAccountCommand); EditCategoriesCommand = new CommandViewModel(OnEditCategoriesCommand); GotoCurrentMonthCommand = new CommandViewModel(OnGotoCurrentMonthCommand); EditStandingOrdersCommand = new CommandViewModel(OnEditStandingOrdersCommand); Months.PropertyChanged += OnMonthsPropertyChanged; Requests.PropertyChanged += OnSelectedRequestChanged; UpdateCurrentMonth(); UpdateCommandStates(); UpdateSaldoAsString(); Caption = string.Format(Properties.Resources.RequestManagementPageCaptionFormat, Application.Repository.Name); }
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(); }
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(); }
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(); }