コード例 #1
0
 private void PopulateCategory(JumpListCustomCategory category, PostInfo[] postInfo)
 {
     foreach (PostInfo post in postInfo)
     {
         if (!category.AddJumpListItem(new JumpListItem(post.Id)))
         {
             return;
         }
     }
 }
コード例 #2
0
        protected WriterJumpList(string appId, IntPtr ownerWindow)
            : base(appId, ownerWindow)
        {
            PostInfo[] drafts = PostListCache.Drafts;
            PostInfo[] posts  = PostListCache.RecentPosts;

            int       numPostsToUse;
            int       numDraftsToUse;
            const int MAX_POSTS_IF_CONSTRAINED = 3;

            Debug.Assert(MAX_POSTS_IF_CONSTRAINED < MAX_ITEMS);

            if (posts.Length <= MAX_POSTS_IF_CONSTRAINED)
            {
                // We can fit all of the posts.  Fill in the rest with drafts.
                numPostsToUse  = posts.Length;
                numDraftsToUse = Math.Min(drafts.Length, MAX_ITEMS - numPostsToUse);
            }
            else
            {
                if (MAX_POSTS_IF_CONSTRAINED + drafts.Length <= MAX_ITEMS)
                {
                    // There's room for all the drafts.  Fill in the rest with posts.
                    numDraftsToUse = drafts.Length;
                    numPostsToUse  = MAX_ITEMS - numDraftsToUse;
                }
                else
                {
                    // Limit the number of posts.  Fill in the rest with drafts.
                    numDraftsToUse = MAX_ITEMS - MAX_POSTS_IF_CONSTRAINED;
                    numPostsToUse  = MAX_POSTS_IF_CONSTRAINED;
                }
            }

            // Don't show the "Recent" or "Frequent" categories.
            KnownCategoryToDisplay = JumpListKnownCategoryType.Neither;

            // Show custom categories instead.
            _recentDrafts = new JumpListCustomCategory(Res.Get(StringId.RecentDrafts), numDraftsToUse);
            PopulateCategory(_recentDrafts, drafts);
            _recentPosts = new JumpListCustomCategory(Res.Get(StringId.RecentPosts), numPostsToUse);
            PopulateCategory(_recentPosts, posts);
            AddCustomCategories(_recentDrafts, _recentPosts);
        }
コード例 #3
0
        protected WriterJumpList(string appId, IntPtr ownerWindow)
            : base(appId, ownerWindow)
        {
            PostInfo[] drafts = PostListCache.Drafts;
            PostInfo[] posts = PostListCache.RecentPosts;

            int numPostsToUse;
            int numDraftsToUse;
            const int MAX_POSTS_IF_CONSTRAINED = 3;
            Debug.Assert(MAX_POSTS_IF_CONSTRAINED < MAX_ITEMS);

            if (posts.Length <= MAX_POSTS_IF_CONSTRAINED)
            {
                // We can fit all of the posts.  Fill in the rest with drafts.
                numPostsToUse = posts.Length;
                numDraftsToUse = Math.Min(drafts.Length, MAX_ITEMS - numPostsToUse);
            }
            else
            {
                if (MAX_POSTS_IF_CONSTRAINED + drafts.Length <= MAX_ITEMS)
                {
                    // There's room for all the drafts.  Fill in the rest with posts.
                    numDraftsToUse = drafts.Length;
                    numPostsToUse = MAX_ITEMS - numDraftsToUse;
                }
                else
                {
                    // Limit the number of posts.  Fill in the rest with drafts.
                    numDraftsToUse = MAX_ITEMS - MAX_POSTS_IF_CONSTRAINED;
                    numPostsToUse = MAX_POSTS_IF_CONSTRAINED;
                }
            }

            // Don't show the "Recent" or "Frequent" categories.
            KnownCategoryToDisplay = JumpListKnownCategoryType.Neither;

            // Show custom categories instead.
            _recentDrafts = new JumpListCustomCategory(Res.Get(StringId.RecentDrafts), numDraftsToUse);
            PopulateCategory(_recentDrafts, drafts);
            _recentPosts = new JumpListCustomCategory(Res.Get(StringId.RecentPosts), numPostsToUse);
            PopulateCategory(_recentPosts, posts);
            AddCustomCategories(_recentDrafts, _recentPosts);

        }
コード例 #4
0
        private static void DumpFileRegistration(JumpListCustomCategory category)
        {
            try
            {
                Trace.WriteLine("Dumping file registration for category " + category.Name + " in response to jumplist error:");

                Dictionary<string, bool> fileTypes = new Dictionary<string, bool>();
                foreach (IJumpListItem link in category.JumpListItems)
                {
                    bool error = false;
                    string extension = Path.GetExtension(link.Path);
                    if (link is JumpListItem)
                    {
                        JumpListItem item = (JumpListItem)link;
                        Trace.WriteLine("JumpListItem: " + item.ParsingName + " with path: " + item.Path);

                        // Verify the file registration for this file type.
                        if (!fileTypes.ContainsKey(extension))
                        {
                            Trace.WriteLine("Dumping file registration for extension: " + extension);
                            RegistryHelper.DumpKey(Registry.LocalMachine, @"SOFTWARE\Classes\" + extension);

                            Trace.WriteLine("Dumping ProgId for extension: " + extension);
                            string progId = FileHelper.GetProgIDFromExtension(extension);
                            if (String.IsNullOrEmpty(progId))
                            {
                                error = true;
                                Trace.Fail("ERROR: ProgId missing for extension: " + extension);
                            }
                            else
                            {
                                RegistryHelper.DumpKey(Registry.LocalMachine, @"SOFTWARE\Classes\" + progId);

                                // Detect the UserAppModelId
                                string appUserModelID = RegistryHelper.GetAppUserModelID(progId);
                                if (String.IsNullOrEmpty(appUserModelID))
                                {
                                    error = true;
                                    Trace.Fail("ERROR: Missing AppUserModelID for " + progId);
                                }
                                else if (!appUserModelID.Equals(TaskbarManager.Instance.ApplicationId, StringComparison.Ordinal))
                                {
                                    error = true;
                                    Trace.Fail("ERROR: Incorrect AppUserModelID for " + progId + ": " + appUserModelID);
                                }
                            }
                        }
                        // else already verified/dumped
                    }
                    else
                    {
                        error = true;
                        Trace.WriteLine("ERROR: Adding something that is not a JumpListItem: " + link.Path);
                    }

                    if (!fileTypes.ContainsKey(extension))
                        fileTypes.Add(extension, error);
                }

            }
            catch (Exception ex)
            {
                Trace.WriteLine("Exception thrown while trying to dump file registration: " + ex);
                throw;
            }
        }
コード例 #5
0
        private static void DumpFileRegistration(JumpListCustomCategory category)
        {
            try
            {
                Trace.WriteLine("Dumping file registration for category " + category.Name + " in response to jumplist error:");

                Dictionary <string, bool> fileTypes = new Dictionary <string, bool>();
                foreach (IJumpListItem link in category.JumpListItems)
                {
                    bool   error     = false;
                    string extension = Path.GetExtension(link.Path);
                    if (link is JumpListItem)
                    {
                        JumpListItem item = (JumpListItem)link;
                        Trace.WriteLine("JumpListItem: " + item.ParsingName + " with path: " + item.Path);

                        // Verify the file registration for this file type.
                        if (!fileTypes.ContainsKey(extension))
                        {
                            Trace.WriteLine("Dumping file registration for extension: " + extension);
                            RegistryHelper.DumpKey(Registry.LocalMachine, @"SOFTWARE\Classes\" + extension);

                            Trace.WriteLine("Dumping ProgId for extension: " + extension);
                            string progId = FileHelper.GetProgIDFromExtension(extension);
                            if (String.IsNullOrEmpty(progId))
                            {
                                error = true;
                                Trace.Fail("ERROR: ProgId missing for extension: " + extension);
                            }
                            else
                            {
                                RegistryHelper.DumpKey(Registry.LocalMachine, @"SOFTWARE\Classes\" + progId);

                                // Detect the UserAppModelId
                                string appUserModelID = RegistryHelper.GetAppUserModelID(progId);
                                if (String.IsNullOrEmpty(appUserModelID))
                                {
                                    error = true;
                                    Trace.Fail("ERROR: Missing AppUserModelID for " + progId);
                                }
                                else if (!appUserModelID.Equals(TaskbarManager.Instance.ApplicationId, StringComparison.Ordinal))
                                {
                                    error = true;
                                    Trace.Fail("ERROR: Incorrect AppUserModelID for " + progId + ": " + appUserModelID);
                                }
                            }
                        }
                        // else already verified/dumped
                    }
                    else
                    {
                        error = true;
                        Trace.WriteLine("ERROR: Adding something that is not a JumpListItem: " + link.Path);
                    }

                    if (!fileTypes.ContainsKey(extension))
                    {
                        fileTypes.Add(extension, error);
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Exception thrown while trying to dump file registration: " + ex);
                throw;
            }
        }
コード例 #6
0
 private void PopulateCategory(JumpListCustomCategory category, PostInfo[] postInfo)
 {
     foreach (PostInfo post in postInfo)
     {
         if (!category.AddJumpListItem(new JumpListItem(post.Id)))
             return;
     }
 }