コード例 #1
0
 public MainViewModel(IFileDialogService fileDialogService)
 {
     ShowFirstDetailsCommand  = new SimpleRelayCommand(ExecuteShowFirstDetails, CanShowFirstDetails);
     ShowSecondDetailsCommand = new SimpleRelayCommand(ExecuteShowSecondDetails, CanShowSecondDetails);
     _firstDetails            = new FirstDetailsViewModel(fileDialogService);
     _secondDetails           = new SecondDetailsViewModel();
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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>();
        }
コード例 #4
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);
        }
コード例 #5
0
ファイル: RedViewModel.cs プロジェクト: Tosker/SimpleWPF
        public RedViewModel(SimpleViewModel blueViewModel)
        {
            _blueViewModel   = blueViewModel;
            _yellowViewModel = new YellowViewModel(this);

            GotoBackCommand   = new SimpleRelayCommand(GotoBack);
            GotoBlueCommand   = new SimpleRelayCommand(GotoBlue);
            GotoYellowCommand = new SimpleRelayCommand(GotoYellow);
        }
コード例 #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);
        }
コード例 #7
0
        public MainViewModel(IFileDialogService fileDialogService)
        {
            if (fileDialogService == null)
            {
                throw new ArgumentNullException(nameof(fileDialogService));
            }
            _fileDialogService = fileDialogService;

            OpenFileCommand = new SimpleRelayCommand(OpenFile);
            SaveFileCommand = new SimpleRelayCommand(SaveFile);
        }
コード例 #8
0
ファイル: MainViewModel.cs プロジェクト: sk8tz/Cas.Common.WPF
        public MainViewModel(ITextEditService textEditService)
        {
            if (textEditService == null)
            {
                throw new ArgumentNullException(nameof(textEditService));
            }

            _textEditService = textEditService;

            EditTextCommand = new SimpleRelayCommand(EditText);
        }
コード例 #9
0
ファイル: MainViewModel.cs プロジェクト: sk8tz/Cas.Common.WPF
        public MainViewModel(IViewService viewService)
        {
            if (viewService == null)
            {
                throw new ArgumentNullException(nameof(viewService));
            }

            _viewService = viewService;

            EditTextCommand    = new SimpleRelayCommand(EditText);
            DisplayTextCommand = new SimpleRelayCommand(DisplayText);
        }
コード例 #10
0
        public MainViewModel(IMessageBoxService messageBoxService)
        {
            if (messageBoxService == null)
            {
                throw new ArgumentNullException(nameof(messageBoxService));
            }

            _messageBoxService = messageBoxService;

            ShowMessageBoxCommand = new SimpleRelayCommand(ShowMessageBox);
            AskYesNoCommand       = new SimpleRelayCommand(AskYesNo);
        }
コード例 #11
0
ファイル: MainViewModel.cs プロジェクト: sk8tz/Cas.Common.WPF
 public MainViewModel()
 {
     SelectFirstName = new SimpleRelayCommand(() =>
     {
         IsLastNameFocused  = false;
         IsFirstNameFocused = true;
     });
     SelectLastName = new SimpleRelayCommand(() =>
     {
         IsFirstNameFocused = false;
         IsLastNameFocused  = true;
     });
 }
コード例 #12
0
        public void Execute_CanExecuteIsFalse_ActionIsNotExecuted()
        {
            var commandExecuted = false;

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

            command.Execute(null);

            Assert.False(commandExecuted);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
 public RedViewModel()
 {
     _blueVM         = new BlueViewModel();
     GotoBlueCommand = new SimpleRelayCommand(GotoBlue);
 }
コード例 #15
0
 public BlueViewModel()
 {
     GotoRedCommand    = new SimpleRelayCommand(GotoRed);
     GetMessageCommand = new SimpleRelayCommand(GetMessage);
 }
コード例 #16
0
 public EditTextViewModel()
 {
     OkCommand = new SimpleRelayCommand(Ok);
 }
コード例 #17
0
 public AddNoteViewModel()
 {
     SaveCommand   = new SimpleRelayCommand(x => Save(this, new EventArgs()));
     CancelCommand = new SimpleRelayCommand(x => Cancel(this, new EventArgs()));
 }
コード例 #18
0
ファイル: MainViewModel.cs プロジェクト: sk8tz/Cas.Common.WPF
 public MainViewModel()
 {
     OkCommand     = new SimpleRelayCommand(Ok);
     CancelCommand = new SimpleRelayCommand(Cancel);
 }
コード例 #19
0
ファイル: AppViewModel.cs プロジェクト: Tosker/SimpleWPF
 public AppViewModel()
 {
     HomeCommand = new SimpleRelayCommand(NavigateToHome);
 }
コード例 #20
0
 public FirstDetailsViewModel(IFileDialogService fileDialogService)
 {
     OpenFileDialogCommand = new SimpleRelayCommand(() => ExecuteOpenFileDialog(fileDialogService));
 }
コード例 #21
0
ファイル: YellowViewModel.cs プロジェクト: Tosker/SimpleWPF
 public YellowViewModel(SimpleViewModel redViewModel)
 {
     _redViewModel  = redViewModel;
     GotoRedCommand = new SimpleRelayCommand(GotoRed);
     NavCommand     = new SimpleRelayCommand <Type>(Nav);
 }