public void TestInvokeWithEventArgsAndNoParameterAndConverterAndConverterParameter()
        {
            var trigger   = new EventToCommandStub();
            var rectangle = new Rectangle();

            ((IAttachedObject)trigger).Attach(rectangle);

            const string prefix = "Test";

            trigger.PassEventArgsToCommand = true;
            trigger.EventArgsConverter     = new TestEventArgsConverter
            {
                TestPrefix = prefix
            };
            trigger.EventArgsConverterParameter = "Suffix";

            var vm      = new CommandViewModel();
            var binding = new Binding
            {
                Source = vm.CommandWithEventArgsConverted
            };

            BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);

            var args = new StringEventArgs("StringEventArgs");

            trigger.InvokeWithEventArgs(args);
            Assert.IsTrue(vm.CommandExecuted);
            Assert.AreEqual(prefix + args.Parameter + trigger.EventArgsConverterParameter, vm.ParameterReceived);
        }
        public void TestInvokeWithEventArgsAndParameterValue()
        {
            var trigger   = new EventToCommandStub();
            var rectangle = new Rectangle();

            ((IAttachedObject)trigger).Attach(rectangle);

            trigger.PassEventArgsToCommand = true;

            var vm      = new CommandViewModel();
            var binding = new Binding
            {
                Source = vm.ParameterCommand
            };

            BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);

            const string CommandParameter = "CommandParameter";

            trigger.CommandParameterValue = CommandParameter;

            var args = new StringEventArgs("StringEventArgs");

            trigger.InvokeWithEventArgs(args);
            Assert.IsTrue(vm.CommandExecuted);
            Assert.AreEqual(CommandParameter, vm.ParameterReceived);
        }
 public SimulatorViewModel()
 {
     this.ShowSimulatorSettingCommandViewModel = new CommandViewModel(
         "Switch to simulator",
         "Switch to simulator",
         () => this.OpenSimulatorSetting());
 }
        public void TestInvokeWithEventArgsAndBoundParameter()
        {
            var trigger   = new EventToCommandStub();
            var rectangle = new Rectangle();

            ((IAttachedObject)trigger).Attach(rectangle);

            trigger.PassEventArgsToCommand = true;

            var vm      = new CommandViewModel();
            var binding = new Binding
            {
                Source = vm.ParameterCommand
            };

            var textBox = new TextBox
            {
                Text = "BoundParameter"
            };

            var bindingParameter = new Binding
            {
                Source = textBox,
                Path   = new PropertyPath("Text")
            };

            BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);
            BindingOperations.SetBinding(trigger, EventToCommand.CommandParameterProperty, bindingParameter);

            var args = new StringEventArgs("StringEventArgs");

            trigger.InvokeWithEventArgs(args);
            Assert.IsTrue(vm.CommandExecuted);
            Assert.AreEqual(textBox.Text, vm.ParameterReceived);
        }
Exemplo n.º 5
0
        public void TestInvokeWithBoundParameter()
        {
            var rectangle = new Rectangle();
            var trigger   = new EventToCommand();

            ((IAttachedObject)trigger).Attach(rectangle);

            const string parameterSent = "Hello world";

            var vm             = new CommandViewModel();
            var bindingCommand = new Binding
            {
                Source = vm.ParameterCommand
            };

            var textBox = new TextBox
            {
                Text = parameterSent
            };

            var bindingParameter = new Binding
            {
                Source = textBox,
                Path   = new PropertyPath("Text")
            };

            BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, bindingCommand);
            BindingOperations.SetBinding(trigger, EventToCommand.CommandParameterProperty, bindingParameter);

            trigger.Invoke();

            Assert.IsTrue(vm.CommandExecuted);
            Assert.AreEqual(parameterSent, vm.ParameterReceived);
        }
Exemplo n.º 6
0
        public void TestEnableAndDisableControlWithValueParameter()
        {
            var trigger = new EventToCommand
            {
                MustToggleIsEnabledValue = true
            };

            var button = new Button();

            ((IAttachedObject)trigger).Attach(button);

            var vm      = new CommandViewModel();
            var binding = new Binding
            {
                Source = vm.ToggledCommandWithParameter
            };

            trigger.CommandParameterValue = "Hel";

            BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);

            Assert.IsFalse(button.IsEnabled);
            trigger.Invoke();
            Assert.IsFalse(vm.CommandExecuted);

            trigger.CommandParameterValue = "Hello world";

            Assert.IsTrue(button.IsEnabled);
            trigger.Invoke();
            Assert.IsTrue(vm.CommandExecuted);
        }
Exemplo n.º 7
0
        public void TestDisableCommandAndRectangle()
        {
            var trigger = new EventToCommand
            {
                MustToggleIsEnabledValue = true
            };

            var rectangle = new Rectangle();

            ((IAttachedObject)trigger).Attach(rectangle);

            var vm      = new CommandViewModel();
            var binding = new Binding
            {
                Source = vm.ToggledCommand
            };

            vm.EnableToggledCommand = false;

            BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);

#if DOTNET
            Assert.IsFalse(rectangle.IsEnabled);
#endif

            trigger.Invoke();
            Assert.IsFalse(vm.CommandExecuted);
        }
Exemplo n.º 8
0
        public void method_4(GInterface0 ginterface0_0, bool bool_0)
        {
            DateTime       now            = DateTime.Now;
            TreeHeaderNode treeHeaderNode = TreeNode.smethod_0(ginterface0_0, this.CommandById[(int)ginterface0_0.Id], now, bool_0);

            if (bool_0)
            {
                CommandViewModel commandViewModel = this.CommandById[(int)ginterface0_0.Id];
                int num = commandViewModel.CountReceived;
                commandViewModel.CountReceived = num + 1;
            }
            else
            {
                CommandViewModel commandViewModel2 = this.CommandById[(int)ginterface0_0.Id];
                int num = commandViewModel2.CountSent;
                commandViewModel2.CountSent = num + 1;
            }
            if (this.method_3(treeHeaderNode))
            {
                object @lock = this._lock;
                lock (@lock)
                {
                    this.Filtered.Add(treeHeaderNode);
                }
                if (this.JumpToLast)
                {
                    base.Dispatcher.BeginInvoke(new Action(this.method_11), Array.Empty <object>());
                }
            }
        }
Exemplo n.º 9
0
        public RecentAccountViewModel(Action<RecentAccountViewModel> onOpen, Action<RecentAccountViewModel> onRemove)
        {
            OpenCommand = new CommandViewModel(() => onOpen(this));
            RemoveCommand = new CommandViewModel(() => onRemove(this));

            UpdateLocalizedProperties();
        }
Exemplo n.º 10
0
        public void TestDisableCommandOnly()
        {
            var trigger   = new EventToCommand();
            var rectangle = new Rectangle();

            ((IAttachedObject)trigger).Attach(rectangle);

            var vm      = new CommandViewModel();
            var binding = new Binding
            {
                Source = vm.ToggledCommand
            };

            vm.EnableToggledCommand = true;

            BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);

            trigger.Invoke();
            Assert.IsTrue(vm.CommandExecuted);

            vm.CommandExecuted      = false;
            vm.EnableToggledCommand = false;

            trigger.Invoke();
            Assert.IsFalse(vm.CommandExecuted);
        }
        public void InitialState()
        {
            var commandViewModel = new CommandViewModel(Substitute.For <Action>());

            Assert.That(commandViewModel.IsEnabled, Is.True);
            Assert.That(commandViewModel.CanExecute(null), Is.True);
        }
        public void TestCloseAllCustomersWorkspace()
        {
            // Create the MainWindowViewModel, but not the MainWindow.
            MainWindowViewModel target =
                new MainWindowViewModel(Constants.CUSTOMER_DATA_FILE);

            Assert.AreEqual(0, target.Workspaces.Count, "Workspaces isn't empty.");

            // Find the command that opens the "All Customers" workspace.
            CommandViewModel commandVM =
                target.Commands.First(cvm => cvm.DisplayName == Strings.MainWindowViewModel_Command_ViewAllCustomers);

            // Open the "All Customers" workspace.
            commandVM.Command.Execute(null);
            Assert.AreEqual(1, target.Workspaces.Count, "Did not create viewmodel.");

            // Ensure the correct type of workspace was created.
            var allCustomersVM = target.Workspaces[0] as AllCustomersViewModel;

            Assert.IsNotNull(allCustomersVM, "Wrong viewmodel type created.");

            // Tell the "All Customers" workspace to close.
            allCustomersVM.CloseCommand.Execute(null);
            Assert.AreEqual(0, target.Workspaces.Count, "Did not close viewmodel.");
        }
Exemplo n.º 13
0
 private void Start()
 {
     _localInventory  = GetComponent <Inventory>();
     _selector        = GetComponentInChildren <Selector>();
     _transferCommand = new CommandViewModel("Transfer", OnTransferCommand);
     CoreContainerViewModel.Instance.CommandUi.Register(_transferCommand);
 }
Exemplo n.º 14
0
        public void TestDisableCommandAndControl()
        {
            var trigger = new EventToCommand
            {
                MustToggleIsEnabledValue = true
            };

            var button = new Button();

            ((IAttachedObject)trigger).Attach(button);

            var vm      = new CommandViewModel();
            var binding = new Binding
            {
                Source = vm.ToggledCommand
            };

            vm.EnableToggledCommand = false;

            BindingOperations.SetBinding(trigger, EventToCommand.CommandProperty, binding);

            Assert.IsFalse(button.IsEnabled);
            trigger.Invoke();
            Assert.IsFalse(vm.CommandExecuted);
        }
Exemplo n.º 15
0
        public void InitialState()
        {
            var commandViewModel = new CommandViewModel(Substitute.For<Action>());

            Assert.That(commandViewModel.IsEnabled, Is.True);
            Assert.That(commandViewModel.CanExecute(null), Is.True);
        }
Exemplo n.º 16
0
        private void CreateCommands()
        {
            List <CommandViewModel> list = new List <CommandViewModel>();

            RelayCommand clearRelay =
                new RelayCommand(
                    param => logSystem.ClearMessages(),
                    param => logSystem.Messages.Count > 0);
            CommandViewModel clearCvm =
                new CommandViewModel("Clear log", clearRelay);

            list.Add(clearCvm);

            RelayCommand copyClipBoardRelay =
                new RelayCommand(
                    param => logSystem.CopyToClipboard(),
                    param => logSystem.Messages.Count > 0);
            CommandViewModel copyClipboardCvm =
                new CommandViewModel("Copy to clipboard", copyClipBoardRelay);

            list.Add(copyClipboardCvm);

            List <CommandGroupViewModel> commandGroupsList = new List <CommandGroupViewModel>();
            CommandGroupViewModel        group             = new CommandGroupViewModel("Actions");

            foreach (CommandViewModel item in list)
            {
                group.Commands.Add(item);
            }
            commandGroupsList.Add(group);

            CommandGroups = new ReadOnlyCollection <CommandGroupViewModel>(commandGroupsList);
        }
        public void InvokeCommandCallsAction()
        {
            var action           = Substitute.For <Action>();
            var commandViewModel = new CommandViewModel(action);

            commandViewModel.Execute(null);
            action.Received(1).Invoke();
        }
Exemplo n.º 18
0
 public Registrar()
 {
     InitializeComponent();
     BindingContext = new CommandViewModel(Navigation, this);
     ubicacion      = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), this.baseDatos);
     this.dbPersona = new PersonaDBContext(ubicacion);
     this.dbUsuario = new UsuarioDBContext(ubicacion);
 }
Exemplo n.º 19
0
 public CommandsSample()
 {
     InitializeComponent();
     DataContext = new CommandViewModel();
     if (chkCommandEnabled.IsChecked == true)
     {
     }
 }
Exemplo n.º 20
0
 public MoficarRegistro()
 {
     InitializeComponent();
     BindingContext = new CommandViewModel(Navigation);
     ubicacion      = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), this.baseDatosUser);
     dbPersona      = new PersonaDBContext(ubicacion);
     CargarRegistros();
 }
Exemplo n.º 21
0
        public void CommandViewModel_Return_ToString_Correctly()
        {
            CommandModel     cm  = new GenericCommandModel("Test", new SimpleCommand());
            CommandViewModel cvm = new CommandViewModel(cm);

            Assert.AreNotEqual(cvm.ToString(), typeof(CommandViewModel).ToString());
            Console.WriteLine(cvm.ToString());
        }
 private void DeleteCommand(CommandViewModel command)
 {
     if (Config.Remove(command.Config))
     {
         Commands.Remove(command);
         Options.Save(Config);
     }
 }
Exemplo n.º 23
0
 public MainPage()
 {
     InitializeComponent();
     BindingContext = new CommandViewModel(Navigation, ref txtPassword, ref iconoOjo, this);
     ubicacion      = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), this.baseDatosUser);
     dbUsuario      = new UsuarioDBContext(ubicacion);
     dbPersona      = new PersonaDBContext(ubicacion);
 }
Exemplo n.º 24
0
        public LoginPage()
        {
            InitializeComponent();
            CommandViewModel command = new CommandViewModel();

            this.DataContext        = command;                //手动设置前台的DataContext
            command.GoToPsyTstPage += Command_goToPsyTstPage; //订阅跳转页面事件
        }
Exemplo n.º 25
0
 public CommandView(CommandViewModel viewModel)
 {
     InitializeComponent();
     if (!DesignerProperties.GetIsInDesignMode(this))
     {
         DataContext = viewModel;
     }
 }
Exemplo n.º 26
0
        public void InvokeCommandCallsAction()
        {
            var action = Substitute.For<Action>();
            var commandViewModel = new CommandViewModel(action);

            commandViewModel.Execute(null);
            action.Received(1).Invoke();
        }
        public void CommandViewModelNotThrowsException()
        {
            var command           = new RelayCommand(o => { });
            var commandVievMaodel = new CommandViewModel(null, command);

            Assert.NotNull(commandVievMaodel);
            Assert.AreEqual(command, commandVievMaodel.Command);
        }
Exemplo n.º 28
0
        public CommandView(CommandViewModel viewModel)
        {
            InitializeComponent();

            this.Loaded += (s, e) =>
            {
                this.DataContext = viewModel;
            };
        }
Exemplo n.º 29
0
        private static void SaveCommand(CommandViewModel command)
        {
            if (CommandsInProgress.Any() && CommandsInProgress.FirstOrDefault(f => f.JCommand == command.JCommand) != null)
            {
                return;
            }

            NewCommands.Add(command);
        }
Exemplo n.º 30
0
        public HttpResponseMessage Disconnect([FromBody] CommandViewModel commandViewModel)
        {
            try
            {
                var response = new CommandResponseViewModel();
                _logger.WriteLogEntry(_tenantId.ToString(), null, string.Format(MethodBase.GetCurrentMethod().Name + " in ProvisioningAPI was called."), LogLevelType.Info);

                if (commandViewModel == null)
                {
                    throw new Exception("Did not receive any json message in the post body.");
                }

                if (commandViewModel.EquipmentId < 1)
                {
                    throw new Exception("EquipmentId is a required parameter.");
                }

                var connectionInfo = Setup(commandViewModel.EquipmentId, commandViewModel.SessionId);
                if (connectionInfo == null)
                {
                    throw new Exception("Could not find any connection settings for the equipmentId.");
                }

                //Now lock the thread so it cannot be used by any other thread.
                using (var tlh = new ThreadLockHelper())
                {
                    tlh.Lock(connectionInfo.LockObj, commandViewModel.Timeout);
                    // Do thread safe work here
                    if (connectionInfo.ConnectionManagerService.IsConnected)
                    {
                        var sr = connectionInfo.ConnectionManagerService.Disconnect();
                        response = new CommandResponseViewModel
                        {
                            Data            = sr.Data,
                            SessionId       = connectionInfo.SessionId,
                            TimeoutOccurred = sr.TimeoutOccurred
                        };
                    }
                }

                //Clear Cache Service in memory
                var memoryCachingService = new MemoryCacheProvider();
                memoryCachingService.ClearCache(connectionInfo.SessionId);

                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
            catch (Exception ex)
            {
                _logger.WriteLogEntry(_tenantId.ToString(), new List <object> {
                    ex.RetrieveEntityExceptionDataAsObjectList()
                },
                                      string.Format(MethodBase.GetCurrentMethod().Name + " in " + _name), LogLevelType.Error, ex.GetInnerMostException());

                throw;
            }
        }
 public void RemoveCommand(CommandViewModel command)
 {
     foreach (CommandGroupViewModel group in commandGroupsList)
     {
         if (group.Commands.Contains(command))
         {
             group.Commands.Remove(command);
         }
     }
 }
Exemplo n.º 32
0
 public TreeHeaderNode(CommandViewModel commandViewModel_0, DateTime dateTime_0, bool bool_0)
 {
     Class13.NP5bWyNzLwONS();
     this.PropertyChanged = new PropertyChangedEventHandler(TreeHeaderNode.< > c.< > 9.method_0);
     base..ctor();
     this.Command   = commandViewModel_0;
     this.Timestamp = dateTime_0;
     this.Received  = bool_0;
     commandViewModel_0.PropertyChanged += this.method_0;
 }
Exemplo n.º 33
0
 private CommandViewModelBase CreateAlertCommand(bool capture)
 => CommandViewModel.Create(async() =>
 {
     Log("Begin CreateAlertCommand ({0})", capture);
     await Task.Delay(250).ConfigureAwait(capture);
     Log("Calling {0}", nameof(AlertAsync));
     await AlertAsync("Alert", title: nameof(CreateAlertCommand), buttonText: "I got it").ConfigureAwait(capture);
     Log("Called {0}", nameof(AlertAsync));
     Log("End CreateAlertCommand ({0})", capture);
 }, title: $"AlertAsync ({capture})");
        public CardRenderWindow(CmdCards launcherCommand, CommandViewModel vm)
        {
            Command = launcherCommand;
            Game = new CardGame(this);

            InitializeComponent();

            stopwatch = new Stopwatch();

            renderTick = new DispatcherTimer();
            renderTick.Interval = TimeSpan.FromMilliseconds(10);
            renderTick.Tick += MainLoop;
        }
        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();
        }
Exemplo n.º 36
0
        public void IsEnabledChangedInvokesPropertyChanged()
        {
            var propertyChangedHandler = Substitute.For<PropertyChangedEventHandler>();
            var commandViewModel = new CommandViewModel(Substitute.For<Action>());
            commandViewModel.PropertyChanged += propertyChangedHandler;

            commandViewModel.IsEnabled = false;
            propertyChangedHandler.Received(1).Invoke(commandViewModel, Arg.Is<PropertyChangedEventArgs>(e => e.PropertyName == "IsEnabled"));
            propertyChangedHandler.ClearReceivedCalls();

            commandViewModel.IsEnabled = true;
            propertyChangedHandler.Received(1).Invoke(commandViewModel, Arg.Is<PropertyChangedEventArgs>(e => e.PropertyName == "IsEnabled"));
            propertyChangedHandler.ClearReceivedCalls();

            commandViewModel.IsEnabled = true;
            propertyChangedHandler.DidNotReceiveWithAnyArgs().Invoke(Arg.Any<object>(), Arg.Any<PropertyChangedEventArgs>());
        }
Exemplo n.º 37
0
        public void IsEnabledChangedInvokesCanExecuteChanged()
        {
            var canExecuteChangedHandler = Substitute.For<EventHandler>();
            var commandViewModel = new CommandViewModel(Substitute.For<Action>());
            commandViewModel.CanExecuteChanged += canExecuteChangedHandler;

            commandViewModel.IsEnabled = false;
            canExecuteChangedHandler.Received(1).Invoke(commandViewModel, EventArgs.Empty);
            canExecuteChangedHandler.ClearReceivedCalls();

            commandViewModel.IsEnabled = true;
            canExecuteChangedHandler.Received(1).Invoke(commandViewModel, EventArgs.Empty);
            canExecuteChangedHandler.ClearReceivedCalls();

            commandViewModel.IsEnabled = true;
            canExecuteChangedHandler.DidNotReceiveWithAnyArgs().Invoke(Arg.Any<object>(), Arg.Any<EventArgs>());
        }
        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 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 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.º 42
0
 void ViewModel_Executed(CommandViewModel obj)
 {
     UpdateStates(true);
 }
Exemplo n.º 43
0
 void ViewModel_Faulted(CommandViewModel arg1, Exception arg2, bool arg3)
 {
     UpdateStates(true);
 }
Exemplo n.º 44
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.º 45
0
 public CategoryEditViewModel(string name, Action<CategoryEditViewModel> onDelete)
 {
     Name = name;
     EntityId = null;
     DeleteCommand = new CommandViewModel(() => onDelete(this));
 }