Ejemplo n.º 1
0
        public TaskbarIconViewModel(ViewManager manager, ProgramSettings settings, IDialogService dialogService)
        {
            _manager       = manager;
            _dialogService = dialogService;
            _settings      = settings;

            ExitCommand = new DelegateCommand(() => Application.Current.Shutdown());

            SettingsCommand = new DelegateCommand(() =>
            {
                var dialog = _dialogService.CreateDialog <SettingsViewModel, SettingsView>(_manager.Settings);
                if (dialog.ShowDialog() == true)
                {
                    manager.ApplySettings(dialog);
                }
            });

            AboutCommand = new DelegateCommand(() =>
            {
                var dialog = _dialogService.CreateDialog <AboutViewModel, AboutView>();
                dialog.ShowDialog();
            });

            StartStopCommand = new DelegateCommand(() =>
            {
                if (manager.IsWindowVisible)
                {
                    manager.Stop();
                }
                else
                {
                    manager.Start();
                }
                RaisePropertyChanged(nameof(MenuItemStartStopText));
                RaisePropertyChanged(nameof(MenuItemStartStopIcon));
            });

            AutoStartCommand = new DelegateCommand(() =>
            {
                if (StartUpManager.IsInStartup())
                {
                    StartUpManager.RemoveFromStartup();
                }
                else
                {
                    StartUpManager.AddToStartup();
                }
                RaisePropertyChanged(nameof(AutoStart));
            });
        }
Ejemplo n.º 2
0
        public TaskbarIconViewModel(ViewManager manager, ProgramSettings settings, IDialogService dialogService)
        {
            _manager       = manager;
            _dialogService = dialogService;
            _settings      = settings;

            RefreshCommand = new DelegateCommand(() => _manager.Refresh());
            ExitCommand    = new DelegateCommand(() => Application.Current.Shutdown());

            SettingsCommand = new DelegateCommand(() =>
            {
                var dialog = _dialogService.CreateDialog <SettingsViewModel, SettingsView>(_manager.Settings);
                dialog.SelectedTabIndex = _manager.Settings.WallpaperType == WallpaperType.SystemInformation ? 1 : _manager.Settings.WallpaperType == WallpaperType.Image ? 2 : _manager.Settings.WallpaperType == WallpaperType.Gallery ? 3 : _manager.Settings.WallpaperType == WallpaperType.Video ? 4 : 0;
                if (dialog.ShowDialog() == true)
                {
                    manager.ApplySettings(dialog);
                }
            });

            PlayCommand = new DelegateCommand(() => {
                if (_settings.WallpaperType == WallpaperType.Video)
                {
                    _manager.VideoPlay();
                }
                if (_settings.WallpaperType == WallpaperType.Gallery)
                {
                    _manager.GalleryPlay();
                }
            });

            PauseCommand = new DelegateCommand(() => {
                if (_settings.WallpaperType == WallpaperType.Video)
                {
                    _manager.VideoPause();
                }
                if (_settings.WallpaperType == WallpaperType.Gallery)
                {
                    _manager.GalleryPause();
                }
            });

            StopCommand = new DelegateCommand(() => {
                if (_settings.WallpaperType == WallpaperType.Video)
                {
                    _manager.VideoStop();
                }
                if (_settings.WallpaperType == WallpaperType.Gallery)
                {
                    _manager.GalleryStop();
                }
            });

            AboutCommand = new DelegateCommand(() =>
            {
                var dialog = _dialogService.CreateDialog <AboutViewModel, AboutView>();
                dialog.ShowDialog();
            });

            ShowHideCommand = new DelegateCommand(() =>
            {
                manager.ShowWindow(!manager.IsWindowVisible);
                RaisePropertyChanged(nameof(MenuItemShowHideText));
            });

            AutoStartCommand = new DelegateCommand(() =>
            {
                if (StartUpManager.IsInStartup())
                {
                    StartUpManager.RemoveFromStartup();
                }
                else
                {
                    StartUpManager.AddToStartup();
                }
                RaisePropertyChanged(nameof(AutoStart));
            });

            EnableInteractiveModeCommand = new DelegateCommand(() =>
            {
                _settings.InteractiveMode = !_settings.InteractiveMode;
                manager.EnableInteractive(_settings.InteractiveMode);
                manager.Update();
                RaisePropertyChanged(nameof(MenuItemInteractiveModeText));
            });
        }