示例#1
0
        /// <summary>
        /// Tries to find a default png icon in the embedded resources of the assembly
        /// where the icon enum is located.
        /// </summary>
        /// <param name="collectionInfo">Information about the icon collection.</param>
        /// <param name="fileInfo">Information about the icon file.</param>
        private AssemblyResourceLink TryFindSvgIcon(IconCollectionInfo collectionInfo, IconFileInfo fileInfo)
        {
            string resourcePath =
                $"{collectionInfo.IconAssemblyDefaultNamespace}.Assets.Icons.{collectionInfo.IconEnumType.Name}.{fileInfo.ImageName}.svg";
            AssemblyResourceLink resourceLink = new AssemblyResourceLink(
                collectionInfo.IconAssembly,
                resourcePath);

            if (!resourceLink.IsValid())
            {
                return(null);
            }

            return(resourceLink);
        }
示例#2
0
        /// <summary>
        /// Tries to find an svg icon in the embedded resources of the assembly
        /// where the icon enum is located.
        /// </summary>
        /// <param name="collectionInfo">Information about the icon collection.</param>
        /// <param name="fileInfo">Information about the icon file.</param>
        private AssemblyResourceLink TryFindPngIcon(IconCollectionInfo collectionInfo, IconFileInfo fileInfo)
        {
            string resourcePath = string.Empty;
            AssemblyResourceLink resourceLink = null;
            int actIconsize = collectionInfo.IconSideWidthPixel;

            do
            {
                resourcePath =
                    $"{collectionInfo.IconAssemblyDefaultNamespace}.Assets.Icons.{collectionInfo.IconEnumType.Name}.{fileInfo.ImageName}_{actIconsize}x{actIconsize}.png";
                resourceLink = new AssemblyResourceLink(
                    collectionInfo.IconAssembly,
                    resourcePath);
                if (!resourceLink.IsValid())
                {
                    resourcePath = string.Empty;
                    resourceLink = null;

                    bool found = false;
                    for (int loop = 0; loop < PNG_ICON_SIZES.Length; loop++)
                    {
                        if (PNG_ICON_SIZES[loop] < actIconsize)
                        {
                            actIconsize = PNG_ICON_SIZES[loop];
                            found       = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        actIconsize = -1;
                    }
                }
            }while ((resourceLink == null) && (actIconsize > 0));

            return(resourceLink);
        }