Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ThemesWindowViewModel" /> class.
        /// </summary>
        public ThemesWindowViewModel(ThemeEditorViewModel themeEditorViewModel, ThemeManager themeManager)
        {
            ThemeEditorViewModel = themeEditorViewModel;
            _themeManager = themeManager;

            Items = new ViewModelCollectionWrapper<ThemeViewModel, Theme>(_themeManager.Themes);

            // select the current theme
            if (themeManager.ActiveTheme != null) {
                SelectedItem = Items.First(t => t.Model == themeManager.ActiveTheme);
            }

            // connect the commands to methods
            DuplicateCommand = new RelayCommand(param => Duplicate());
            ExportCommand = new RelayCommand(param => Export());
            // delete command is only available if the ActiveTheme is editable
            DeleteCommand = new RelayCommand(param => Delete(),
                param => _themeManager.ActiveTheme != null && _themeManager.ActiveTheme.Editable);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ThemesWindowViewModel" /> class.
        /// </summary>
        public ThemesWindowViewModel(ThemeEditorViewModel themeEditorViewModel, ThemeManager themeManager,
            ThemeViewModel.Factory themeViewModelFactory, Func<ThemesWindowViewModel, ThemeEditDialogViewModel> themeEditDialogViewModelFactory,
            IDialogService dialogService)
        {
            ThemeEditorViewModel = themeEditorViewModel;
            ThemeManager = themeManager;
            EditDialogViewModel = themeEditDialogViewModelFactory(this);
            _dialogService = dialogService;

            Items = new ViewModelCollectionWrapper<ThemeViewModel, Theme>(ThemeManager.Themes,
                model => themeViewModelFactory(model, this));

            OnLoadedCommand = () =>
            {
                // select the current theme
                if (themeManager.ActiveTheme != null) {
                    SelectItemByModel(themeManager.ActiveTheme);
                }
            };
            CreateThemeCommand = new RelayCommand(o => ShowEditDialog());
        }
Exemple #3
0
 private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
 {
     ViewModel = DataContext as ThemeEditorViewModel;
     SetupEditBehaviour();
 }