Exemplo n.º 1
0
 public MainViewModel(IFileDialogService fileDialogService)
 {
     ShowFirstDetailsCommand  = new SimpleRelayCommand(ExecuteShowFirstDetails, CanShowFirstDetails);
     ShowSecondDetailsCommand = new SimpleRelayCommand(ExecuteShowSecondDetails, CanShowSecondDetails);
     _firstDetails            = new FirstDetailsViewModel(fileDialogService);
     _secondDetails           = new SecondDetailsViewModel();
 }
        public void CanExecuteChanged_RemoveHandler_HandlerIsNotCalled()
        {
            SynchronizationContext.SetSynchronizationContext(new TestSynchronizationContext());

            var commandExecuted = false;

            _canExecuteChangedRaised = false;

            var command = new SimpleRelayCommand(() =>
            {
                // ReSharper disable once AccessToModifiedClosure
                Assert.False(commandExecuted);
                commandExecuted = true;
            });

            command.CanExecuteChanged += CommandOnCanExecuteChanged;

            command.Execute(null);

            Assert.True(commandExecuted);
            Assert.True(_canExecuteChangedRaised);

            _canExecuteChangedRaised = false;
            commandExecuted          = false;

            command.CanExecuteChanged -= CommandOnCanExecuteChanged;

            command.Execute(null);

            Assert.True(commandExecuted);
            Assert.False(_canExecuteChangedRaised);
        }
        public AddCcuViewModel(IWindowManager windowManager)
        {
            OkCommand = new SimpleRelayCommand(() => windowManager.CloseDialog(this, true),
                                               () => !string.IsNullOrWhiteSpace(Address));
            CancelCommand = new SimpleRelayCommand(() => windowManager.CloseDialog(this, false));

            MruAddresses = new ExtendedObservableCollection <string>();
        }
        public TextEditDialogViewModel(string text, string caption, string title, Func<string, bool> validate)
        {
            _caption = caption;
            _title = title;
            _validate = validate;
            _text = text;

            OkCommand = new SimpleRelayCommand(Ok, CanOk);
        }
Exemplo n.º 5
0
        public RedViewModel(SimpleViewModel blueViewModel)
        {
            _blueViewModel   = blueViewModel;
            _yellowViewModel = new YellowViewModel(this);

            GotoBackCommand   = new SimpleRelayCommand(GotoBack);
            GotoBlueCommand   = new SimpleRelayCommand(GotoBlue);
            GotoYellowCommand = new SimpleRelayCommand(GotoYellow);
        }
Exemplo n.º 6
0
        public TextEditDialogViewModel(string text, string caption, string title, Func <string, bool> validate)
        {
            _caption  = caption;
            _title    = title;
            _validate = validate;
            _text     = text;

            OkCommand = new SimpleRelayCommand(Ok, CanOk);
        }
Exemplo n.º 7
0
        public MainViewModel(IFileDialogService fileDialogService)
        {
            if (fileDialogService == null)
            {
                throw new ArgumentNullException(nameof(fileDialogService));
            }
            _fileDialogService = fileDialogService;

            OpenFileCommand = new SimpleRelayCommand(OpenFile);
            SaveFileCommand = new SimpleRelayCommand(SaveFile);
        }
Exemplo n.º 8
0
        public MainViewModel(ITextEditService textEditService)
        {
            if (textEditService == null)
            {
                throw new ArgumentNullException(nameof(textEditService));
            }

            _textEditService = textEditService;

            EditTextCommand = new SimpleRelayCommand(EditText);
        }
Exemplo n.º 9
0
        public MainViewModel(IViewService viewService)
        {
            if (viewService == null)
            {
                throw new ArgumentNullException(nameof(viewService));
            }

            _viewService = viewService;

            EditTextCommand    = new SimpleRelayCommand(EditText);
            DisplayTextCommand = new SimpleRelayCommand(DisplayText);
        }
Exemplo n.º 10
0
        public MainViewModel(IMessageBoxService messageBoxService)
        {
            if (messageBoxService == null)
            {
                throw new ArgumentNullException(nameof(messageBoxService));
            }

            _messageBoxService = messageBoxService;

            ShowMessageBoxCommand = new SimpleRelayCommand(ShowMessageBox);
            AskYesNoCommand       = new SimpleRelayCommand(AskYesNo);
        }
Exemplo n.º 11
0
 public MainViewModel()
 {
     SelectFirstName = new SimpleRelayCommand(() =>
     {
         IsLastNameFocused  = false;
         IsFirstNameFocused = true;
     });
     SelectLastName = new SimpleRelayCommand(() =>
     {
         IsFirstNameFocused = false;
         IsLastNameFocused  = true;
     });
 }
        public void Execute_CanExecuteIsFalse_ActionIsNotExecuted()
        {
            var commandExecuted = false;

            var command = new SimpleRelayCommand(() =>
            {
                Assert.False(commandExecuted);
                commandExecuted = true;
            }, () => false);

            command.Execute(null);

            Assert.False(commandExecuted);
        }
        public void Execute_Wait_ActionIsExecuted()
        {
            SynchronizationContext.SetSynchronizationContext(new TestSynchronizationContext());

            var commandExecuted         = false;
            var canExecuteChangedRaised = false;

            var command = new SimpleRelayCommand(() =>
            {
                Assert.False(commandExecuted);
                commandExecuted = true;
            });

            command.CanExecuteChanged += (_, _) =>
            {
                Assert.False(canExecuteChangedRaised);
                canExecuteChangedRaised = true;
            };

            command.Execute(null);

            Assert.True(commandExecuted);
            Assert.True(canExecuteChangedRaised);
        }
Exemplo n.º 14
0
 public RedViewModel()
 {
     _blueVM         = new BlueViewModel();
     GotoBlueCommand = new SimpleRelayCommand(GotoBlue);
 }
Exemplo n.º 15
0
 public BlueViewModel()
 {
     GotoRedCommand    = new SimpleRelayCommand(GotoRed);
     GetMessageCommand = new SimpleRelayCommand(GetMessage);
 }
Exemplo n.º 16
0
 public EditTextViewModel()
 {
     OkCommand = new SimpleRelayCommand(Ok);
 }
Exemplo n.º 17
0
 public AddNoteViewModel()
 {
     SaveCommand   = new SimpleRelayCommand(x => Save(this, new EventArgs()));
     CancelCommand = new SimpleRelayCommand(x => Cancel(this, new EventArgs()));
 }
Exemplo n.º 18
0
 public MainViewModel()
 {
     OkCommand     = new SimpleRelayCommand(Ok);
     CancelCommand = new SimpleRelayCommand(Cancel);
 }
Exemplo n.º 19
0
 public AppViewModel()
 {
     HomeCommand = new SimpleRelayCommand(NavigateToHome);
 }
Exemplo n.º 20
0
 public FirstDetailsViewModel(IFileDialogService fileDialogService)
 {
     OpenFileDialogCommand = new SimpleRelayCommand(() => ExecuteOpenFileDialog(fileDialogService));
 }
Exemplo n.º 21
0
 public YellowViewModel(SimpleViewModel redViewModel)
 {
     _redViewModel  = redViewModel;
     GotoRedCommand = new SimpleRelayCommand(GotoRed);
     NavCommand     = new SimpleRelayCommand <Type>(Nav);
 }