示例#1
0
        /// <summary>
        ///   Handles the <see cref="ConfigWallpaperVM.UnhandledCommandException" /> event of a <see cref="ConfigWallpaperVM" />
        ///   instance and handles the thrown exception if possible.
        /// </summary>
        /// <commondoc select='All/Methods/EventHandlers[@Params="Object,+EventArgs"]/*' />
        private void ConfigWallpaperVM_UnhandledCommandException(object sender, CommandExceptionEventArgs e)
        {
            if (e.IsHandled)
            {
                return;
            }

            ConfigWallpaperVM configWallpaperVM = (ConfigWallpaperVM)sender;

            if (e.Command == configWallpaperVM.ApplySettingsCommand)
            {
                if (e.Exception is InvalidOperationException)
                {
                    DialogManager.ShowWallpapers_MultiscreenWallpaperOnDisabledScreens(null);
                }

                e.IsHandled = true;
            }
        }
示例#2
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="ConfigWallpaperWindow" /> class.
        /// </summary>
        /// <param name="configWallpaperVM">
        ///   The <see cref="WallpaperManager.ViewModels.ConfigWallpaperVM" /> instance used as interface to communicate
        ///   with the application.
        /// </param>
        /// <param name="screensSettings">
        ///   The collection of <see cref="ScreenSettings" /> objects defining configuration values related to single screens.
        /// </param>
        /// <seealso cref="WallpaperManager.ViewModels.ConfigWallpaperVM">ConfigWallpaperVM Class</seealso>
        /// <seealso cref="ScreenSettingsCollection">ScreenSettingsCollection Class</seealso>
        /// <seealso cref="ScreenSettings">ScreensSettings Class</seealso>
        public ConfigWallpaperWindow(ConfigWallpaperVM configWallpaperVM, ScreenSettingsCollection screensSettings)
        {
            this.ConfigWallpaperVM = configWallpaperVM;
            this.ConfigWallpaperVM.RequestClose += delegate(object sender, RequestCloseEventArgs e) {
                this.DialogResult = e.Result;
                this.Close();
            };

            this.ScreensSettings  = screensSettings;
            this.WallpaperPreview = null;

            this.InitializeComponent();

            switch (configWallpaperVM.ConfigurationMode)
            {
            case ConfigWallpaperMode.ConfigureDefaultSettings:
                this.Title = LocalizationManager.GetLocalizedString("ConfigDefaultSettings.Title");
                this.lblGeneral_ImagePath.Visibility       = Visibility.Collapsed;
                this.pnlGeneral_ImagePath.Visibility       = Visibility.Collapsed;
                this.rdbPlacement_AutoDetermine.Visibility = Visibility.Visible;
                this.ctlMultiscreenSetting.Content         = this.ctlMultiscreenSetting.Resources["ConfigureDefaultSettingsContent"];

                break;

            case ConfigWallpaperMode.ConfigureStaticWallpaper:
                this.Title = LocalizationManager.GetLocalizedString("ConfigStaticWallpaper.Title");
                this.slbPreview.Visibility            = Visibility.Collapsed;
                this.ctlMultiscreenSetting.Content    = null;
                this.ctlMultiscreenSetting.Visibility = Visibility.Collapsed;

                break;

            default:
                this.Title = LocalizationManager.GetLocalizedString("ConfigWallpaper.Title");
                this.ctlMultiscreenSetting.Content = this.ctlMultiscreenSetting.Resources["ConfigureWallpapersContent"];

                break;
            }

            this.UpdatePreviewImage(null, null);
        }
示例#3
0
        /// <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();
            }
        }
示例#4
0
        /// <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;
            }
        }