Example #1
0
        /// <summary>
        ///   Called when <see cref="AddCategoryCommand" /> is executed and adds the given <see cref="WallpaperCategory" /> object.
        /// </summary>
        /// <param name="wallpaperCategory">
        ///   The <see cref="WallpaperCategory" /> object to add.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///   <paramref name="wallpaperCategory" /> is <c>null</c>.
        /// </exception>
        /// <seealso cref="AddCategoryCommand" />
        protected void AddCategoryCommand_Execute(WallpaperCategory wallpaperCategory)
        {
            if (wallpaperCategory == null)
            {
                throw new ArgumentNullException();
            }

            try {
                this.Add(this.RequestWallpaperCategoryVM(wallpaperCategory));
            } catch (Exception exception) {
                this.OnUnhandledCommandException(new CommandExceptionEventArgs(this.AddCategoryCommand, exception));
            }
        }
Example #2
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="WallpaperCategoryVM" /> class.
        /// </summary>
        /// <param name="category">
        ///   The <see cref="WallpaperManager.Models.Wallpaper" /> which should be wrapped by this View Model.
        /// </param>
        /// <param name="wallpaperChangerVM">
        ///   The <see cref="ViewModels.WallpaperChangerVM" /> instance used to control cycle operations
        ///   performed by this View Model.
        /// </param>
        /// <param name="requestConfigureSelected">
        ///   The delegate invoked to request the configuration of the selected <see cref="WallpaperVM" /> instances.
        /// </param>
        /// <param name="requestConfigureDefaultSettings">
        ///   The delegate invoked to request the configuration of the <see cref="WallpaperDefaultSettings" />.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///   <paramref name="category" /> or <paramref name="wallpaperChangerVM" /> or
        ///   <paramref name="requestConfigureSelected" /> or <paramref name="requestConfigureDefaultSettings" /> is <c>null</c>.
        /// </exception>
        /// <commondoc select='ViewModels/General/seealso' />
        public WallpaperCategoryVM(
            WallpaperCategory category,
            WallpaperChangerVM wallpaperChangerVM,
            Action <WallpaperCategoryVM> requestConfigureSelected,
            Action <WallpaperCategoryVM> requestConfigureDefaultSettings)
        {
            this.Category                        = category;
            this.WallpaperChangerVM              = wallpaperChangerVM;
            this.RequestConfigureSelected        = requestConfigureSelected;
            this.RequestConfigureDefaultSettings = requestConfigureDefaultSettings;

            CollectionChangedEventManager.AddListener(category, this);

            // Simulate adding of all wallpapers to the category so that a WallpaperVM is created for any Wallpaper instance.
            this.handleCategoryCollectionChanged = true;
            this.Category_CollectionChanged(
                this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, category));

            this.selectedWallpaperVMs = new ReadOnlyCollection <WallpaperVM>(new List <WallpaperVM>());

            PropertyChangedEventManager.AddListener(wallpaperChangerVM, this, string.Empty);
            this.WallpaperChangerVM_PropertyChanged(this, new PropertyChangedEventArgs("ActiveWallpapers"));
        }
Example #3
0
        /// <summary>
        ///   Creates a new <see cref="WallpaperCategoryVM" /> from a given <see cref="WallpaperCategory" />.
        /// </summary>
        /// <param name="category">
        ///   The <see cref="WallpaperCategory" /> instance to be wrapped by a new <see cref="WallpaperCategoryVM" />.
        /// </param>
        /// <returns>
        ///   The new <see cref="WallpaperCategoryVM" /> instance.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        ///   <paramref name="category" /> is <c>null</c>.
        /// </exception>
        /// <seealso cref="WallpaperCategory">WallpaperCategory Class</seealso>
        /// <seealso cref="WallpaperCategoryVM">WallpaperCategoryVM Class</seealso>
        private WallpaperCategoryVM WallpaperCategoryCollectionVM_RequestWallpaperCategoryVM(WallpaperCategory category)
        {
            if (category == null)
            {
                throw new ArgumentNullException();
            }

            // Provide the View Model with a new WallpaperCategoryVM object.
            return(new WallpaperCategoryVM(
                       category,
                       this.WallpaperChangerVM,
                       this.WallpaperCategoryVM_RequestConfigureSelected,
                       this.WallpaperCategoryVM_RequestConfigureDefaultSettings));
        }
Example #4
0
 /// <summary>
 ///   Determines if <see cref="AddCategoryCommand" /> can be executed.
 /// </summary>
 /// <param name="wallpaperCategory">
 ///   The <see cref="WallpaperCategory" /> object to add.
 /// </param>
 /// <returns>
 ///   A <see cref="bool" /> indicating whether the command can be executed or not.
 /// </returns>
 /// <seealso cref="AddCategoryCommand" />
 protected bool AddCategoryCommand_CanExecute(WallpaperCategory wallpaperCategory)
 {
     return(true);
 }