Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RenameProfileDialogViewModel"/> class.
        /// </summary>
        /// <param name="currentName">The current profile name.</param>
        /// <param name="profileNames">The list of existing profile names.</param>
        public RenameProfileDialogViewModel(string currentName, IEnumerable <string> profileNames)
        {
            _currentName    = currentName;
            _newProfileName = currentName;
            _profileNames   = profileNames;

            OkCommand = new RelayCommand(OkCommandOnExecute, OkCommandCanExecute);
            OkCommand.Observe(this, nameof(NewProfileName));
            CancelCommand = new RelayCommand(CancelCommandOnExecute);
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SettingsWindowViewModel"/> class.
        /// </summary>
        /// <param name="appSettings">The app settings.</param>
        /// <param name="dialogService">The dialog service.</param>
        /// <param name="viewModels">The view models.</param>
        /// <param name="messageBus">The message bus.</param>
        public SettingsWindowViewModel(IAppSettings appSettings, IDialogService dialogService, IViewModelContainer viewModels, IMessageBus messageBus)
        {
            _appSettings   = appSettings;
            _dialogService = dialogService;
            _messageBus    = messageBus;
            messageBus.Subscribe <EditStartMessage>(EditStartMessageOnPublished);
            ViewModels           = viewModels;
            _selectedProfileName = appSettings.CurrentProfile.Name;
            ProfileNames         = new ObservableCollection <string>(appSettings.Profiles.Select(p => p.Name));

            SelectViewModelCommand = new RelayCommand <ViewModelBase>(SelectViewModelOnExecute);
            DeleteProfileCommand   = new RelayCommand(DeleteProfileCommandOnExecute, DeleteProfileCommandCanExecute);
            DeleteProfileCommand.Observe(ProfileNames);
            AddProfileCommand    = new RelayCommand(AddProfileCommandOnExecute);
            RenameProfileCommand = new RelayCommand(RenameProfileCommandOnExecute);
            SaveCommand          = new RelayCommand(SaveCommandOnExecute, SaveCommandCanExecute);
            SaveCommand.Observe(this, nameof(HasUnsavedChanges));
            CloseCommand          = new RelayCommand(CloseCommandOnExecute);
            ImportProfilesCommand = new RelayCommand(ImportProfilesCommandOnExecute);
            ExportProfilesCommand = new RelayCommand(ExportProfilesCommandOnExecute);
        }