/// <summary> /// Handles the <see cref="CommandBinding.Executed" /> event of a <see cref="CommandBinding" />. /// This method shows the <see cref="ConfigWallpaperWindow" /> to configure the static /// <see cref="Wallpaper" /> of the current screen. /// </summary> /// <param name="sender"> /// The source of the event. /// </param> /// <param name="e"> /// The <see cref="ExecutedRoutedEventArgs" /> instance containing the event data. /// </param> /// <seealso cref="ConfigureStaticWallpaperCommand" /> protected virtual void ConfigureStaticWallpaperCommand_Executed(object sender, ExecutedRoutedEventArgs e) { ConfigWallpaperWindow configWallpaperWindow = new ConfigWallpaperWindow( new ConfigWallpaperVM(this.DataContext.SelectedScreenSettings.StaticWallpaper), this.DataContext.Configuration.ScreensSettings); configWallpaperWindow.Owner = this.GetClosestParentOfType <Window>(); configWallpaperWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner; configWallpaperWindow.ShowDialog(); }
/// <summary> /// Shows the <see cref="ConfigWallpaperWindow" /> to configure the <see cref="WallpaperDefaultSettings" /> of the /// given <see cref="WallpaperCategoryVM" />. /// </summary> /// <param name="categoryVM"> /// The <see cref="WallpaperCategoryVM" /> to configure the <see cref="WallpaperDefaultSettings" /> for. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="categoryVM" /> is <c>null</c>. /// </exception> /// <seealso cref="WallpaperCategoryVM">WallpaperCategoryVM Class</seealso> private void WallpaperCategoryVM_RequestConfigureDefaultSettings(WallpaperCategoryVM categoryVM) { if (categoryVM == null) { throw new ArgumentNullException(); } ConfigWallpaperVM configWallpaperVM = new ConfigWallpaperVM(categoryVM.Category.WallpaperDefaultSettings); configWallpaperVM.UnhandledCommandException += this.ConfigWallpaperVM_UnhandledCommandException; ConfigWallpaperWindow configWallpaperWindow = new ConfigWallpaperWindow(configWallpaperVM, this.Configuration.General.ScreensSettings); configWallpaperWindow.Owner = this.MainWindow; bool?result = configWallpaperWindow.ShowDialog(); // If the settings have been confirmed by the user. if ((result != null) && result.Value) { this.WriteConfigFile(); } }
/// <summary> /// Shows the <see cref="ConfigWallpaperWindow" /> to configure the selected <see cref="Wallpaper" /> instances of the /// given <see cref="WallpaperCategoryVM" />. /// </summary> /// <param name="categoryVM"> /// The <see cref="WallpaperCategoryVM" /> to configure the selected <see cref="Wallpaper" /> instances for. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="categoryVM" /> is <c>null</c>. /// </exception> /// <seealso cref="WallpaperCategoryVM">WallpaperCategoryVM Class</seealso> private void WallpaperCategoryVM_RequestConfigureSelected(WallpaperCategoryVM categoryVM) { if (categoryVM == null) { throw new ArgumentNullException(); } var wallpapersToConfigure = new Wallpaper[categoryVM.SelectedWallpaperVMs.Count]; for (int i = 0; i < categoryVM.SelectedWallpaperVMs.Count; i++) { wallpapersToConfigure[i] = categoryVM.SelectedWallpaperVMs[i].Wallpaper; } ConfigWallpaperVM configWallpaperVM = new ConfigWallpaperVM(this.Configuration.General, wallpapersToConfigure, categoryVM.IsSynchronizedCategory); configWallpaperVM.UnhandledCommandException += this.ConfigWallpaperVM_UnhandledCommandException; ConfigWallpaperWindow configWallpaperWindow = new ConfigWallpaperWindow(configWallpaperVM, this.Configuration.General.ScreensSettings); configWallpaperWindow.Owner = this.MainWindow; bool?result = configWallpaperWindow.ShowDialog(); // If the settings have been confirmed by the user. if ((result != null) && result.Value) { this.WriteConfigFile(); } // It could be possible that the ImagePath of a wallpaper has been changed, so we clear the thumbnails which will // then be recreated when the GUI requests them. for (int i = 0; i < categoryVM.SelectedWallpaperVMs.Count; i++) { categoryVM.SelectedWallpaperVMs[i].Thumbnail = null; } }