Esempio n. 1
0
        /// <summary>
        /// Repopulates the application's jump list.
        /// Use this method after all current changes to
        /// the application's jump list have been introduced,
        /// and you want the list to be refreshed.
        /// </summary>
        /// <returns><b>true</b> if the list was refreshed; <b>false</b>
        /// if the operation was cancelled.  The operation might have
        /// been cancelled if the <see cref="UserRemovedItems"/> event
        /// handler instructed us to cancel the operation.</returns>
        /// <remarks>
        /// If the user removed items from the jump list between the
        /// last refresh operation and this one, then the
        /// <see cref="UserRemovedItems"/> event will be invoked.
        /// If the event handler for this event instructed us to cancel
        /// the operation, then the current transaction is aborted,
        /// no items are added, and this method returns <b>false</b>.
        /// Check the return value to determine whether the jump list
        /// needs to be changed and the operation attempted again.
        /// </remarks>
        public bool Refresh()
        {
            if (!BeginList())
            {
                return(false);   //Operation was cancelled
            }
            _tasks.RefreshTasks(_customDestinationList);
            _destinations.RefreshDestinations(_customDestinationList);

            switch (EnabledAutoDestinationType)
            {
            case ApplicationDestinationType.Frequent:
                HResult appendKnownCategoryFrequentResult = _customDestinationList.AppendKnownCategory(KnownDestCategory.FREQUENT);
                appendKnownCategoryFrequentResult.ThrowIf();
                break;

            case ApplicationDestinationType.Recent:
                HResult appendKnownCategoryRecentResult = _customDestinationList.AppendKnownCategory(KnownDestCategory.RECENT);
                appendKnownCategoryRecentResult.ThrowIf();
                break;
            }

            CommitList();
            return(true);
        }