Esempio 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);
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio n. 8
0
        public MainViewModel(ITextEditService textEditService)
        {
            if (textEditService == null)
            {
                throw new ArgumentNullException(nameof(textEditService));
            }

            _textEditService = textEditService;

            EditTextCommand = new SimpleRelayCommand(EditText);
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio 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);
        }
Esempio n. 14
0
 public RedViewModel()
 {
     _blueVM         = new BlueViewModel();
     GotoBlueCommand = new SimpleRelayCommand(GotoBlue);
 }
Esempio n. 15
0
 public BlueViewModel()
 {
     GotoRedCommand    = new SimpleRelayCommand(GotoRed);
     GetMessageCommand = new SimpleRelayCommand(GetMessage);
 }
Esempio n. 16
0
 public EditTextViewModel()
 {
     OkCommand = new SimpleRelayCommand(Ok);
 }
Esempio n. 17
0
 public AddNoteViewModel()
 {
     SaveCommand   = new SimpleRelayCommand(x => Save(this, new EventArgs()));
     CancelCommand = new SimpleRelayCommand(x => Cancel(this, new EventArgs()));
 }
Esempio n. 18
0
 public MainViewModel()
 {
     OkCommand     = new SimpleRelayCommand(Ok);
     CancelCommand = new SimpleRelayCommand(Cancel);
 }
Esempio n. 19
0
 public AppViewModel()
 {
     HomeCommand = new SimpleRelayCommand(NavigateToHome);
 }
Esempio n. 20
0
 public FirstDetailsViewModel(IFileDialogService fileDialogService)
 {
     OpenFileDialogCommand = new SimpleRelayCommand(() => ExecuteOpenFileDialog(fileDialogService));
 }
Esempio n. 21
0
 public YellowViewModel(SimpleViewModel redViewModel)
 {
     _redViewModel  = redViewModel;
     GotoRedCommand = new SimpleRelayCommand(GotoRed);
     NavCommand     = new SimpleRelayCommand <Type>(Nav);
 }