Example #1
0
        private void DeleteUnmappedIcons()
        {
            List <string> usedIcons = new List <string>();

            usedIcons.Add("unknown.ico");

            List <IconMapItem> mappedIcons = IconMapperUtil.GetMappedIcons();

            foreach (IconMapItem item in mappedIcons)
            {
                usedIcons.Add(item.Icon);
            }

            WriteLine("Removing Unmapped Icons");

            string[] iconsInFolder = System.IO.Directory.GetFiles(AppConfig.IconFolder, "*.ico");
            for (int i = iconsInFolder.Length - 1; i > 0; i--)
            {
                string iconPath = iconsInFolder[i];
                string iconName = System.IO.Path.GetFileName(iconPath);
                if (!usedIcons.Contains(iconName))
                {
                    WriteLine("Deleting: " + iconName);
                    System.IO.File.Delete(iconPath);
                }
            }
        }
Example #2
0
        /// <summary>
        /// <para>Created By    : YUKUANG</para>
        /// <para>Created Date  : 30 Oct 2009</para>
        /// <para>Modified By   : -</para>
        /// <para>Modified Date : -</para>
        /// <para>---------------------------------------------------------------</para>
        /// <para></para>
        /// <para>Changes</para>
        /// <para>---------------------------------------------------------------</para>
        /// <para></para>
        /// <para>Description</para>
        /// <para>---------------------------------------------------------------</para>
        /// Clean unused icons
        /// </summary>
        private void DeletedUnusedIcons()
        {
            List <string> usedIcons = new List <string>();

            usedIcons.Add("unknown.ico");

            List <IconMapItem> mappedIcons = IconMapperUtil.GetMappedIcons();

            foreach (IconMapItem item in mappedIcons)
            {
                usedIcons.Add(item.Icon);
            }


            List <string> groupNames = ShortcutUtil.GetShortcutGroupNames();

            foreach (string groupName in groupNames)
            {
                List <ShortcutItem> shortcuts = ShortcutUtil.GetShortcuts(groupName);
                foreach (ShortcutItem item in shortcuts)
                {
                    if (!string.IsNullOrEmpty(item.IconPath))
                    {
                        if (!usedIcons.Contains(item.IconPath))
                        {
                            usedIcons.Add(item.IconPath);
                        }
                    }
                }
            }

            string[] iconsInFolder = System.IO.Directory.GetFiles(AppConfig.IconFolder, "*.ico");
            for (int i = iconsInFolder.Length - 1; i > 0; i--)
            {
                string iconPath = iconsInFolder[i];
                string iconName = System.IO.Path.GetFileName(iconPath);
                if (!usedIcons.Contains(iconName))
                {
                    WriteLine("Deleting: " + iconName);
                    System.IO.File.Delete(iconPath);
                }
            }
        }