Ejemplo n.º 1
0
        private IconData[] CreateIconData(IIcon icon, bool highRes)
        {
            if (icon == null)
            {
                throw new ArgumentNullException(nameof(icon));
            }

            IEnumerable <IconSizeInfo> sizes = null;

            if (highRes)
            {
                sizes = icon.GetHighResolutionIconSizes();
            }
            else
            {
                sizes = icon.GetIconSizes();
            }

            if (sizes == null || !sizes.Any())
            {
                throw new NullReferenceException($"Specified icon '{icon.GetType().FullName}' doesn't provide any sizes");
            }

            var iconsData = sizes.Select(s => new IconData(m_IconsDir, s.SourceImage, s.TargetSize, s.Name)).ToArray();

            return(iconsData);
        }
Ejemplo n.º 2
0
        private IconData[] CreateIconData(IIcon icon, bool highRes)
        {
            if (icon == null)
            {
                throw new ArgumentException("Icons are not specified");
            }

            IconData[] iconsData;

            if (icon is HighResIcon)
            {
                var highResIcons = icon as HighResIcon;

                if (highRes)
                {
                    iconsData = new IconData[]
                    {
                        new IconData(m_IconsDir, highResIcons.Size20x20, new Size(20, 20)),
                        new IconData(m_IconsDir, highResIcons.Size32x32, new Size(32, 32)),
                        new IconData(m_IconsDir, highResIcons.Size40x40, new Size(40, 40)),
                        new IconData(m_IconsDir, highResIcons.Size64x64, new Size(64, 64)),
                        new IconData(m_IconsDir, highResIcons.Size96x96, new Size(96, 96)),
                        new IconData(m_IconsDir, highResIcons.Size128x128, new Size(128, 128))
                    };
                }
                else
                {
                    iconsData = new IconData[]
                    {
                        new IconData(m_IconsDir, highResIcons.Size20x20, new Size(16, 16)),
                        new IconData(m_IconsDir, highResIcons.Size32x32, new Size(24, 24)),
                    };
                }
            }
            else if (icon is BasicIcon)
            {
                var basicIcons = icon as BasicIcon;

                if (highRes)
                {
                    iconsData = new IconData[]
                    {
                        new IconData(m_IconsDir, basicIcons.Size16x16, new Size(20, 20)),
                        new IconData(m_IconsDir, basicIcons.Size24x24, new Size(32, 32)),
                        new IconData(m_IconsDir, basicIcons.Size24x24, new Size(40, 40)),
                        new IconData(m_IconsDir, basicIcons.Size24x24, new Size(64, 64)),
                        new IconData(m_IconsDir, basicIcons.Size24x24, new Size(96, 96)),
                        new IconData(m_IconsDir, basicIcons.Size24x24, new Size(128, 128))
                    };
                }
                else
                {
                    iconsData = new IconData[]
                    {
                        new IconData(m_IconsDir, basicIcons.Size16x16, new Size(16, 16)),
                        new IconData(m_IconsDir, basicIcons.Size24x24, new Size(24, 24)),
                    };
                }
            }
            else if (icon is MasterIcon)
            {
                var masterIcons = icon as MasterIcon;

                if (highRes)
                {
                    iconsData = new IconData[]
                    {
                        new IconData(m_IconsDir, masterIcons.Icon, new Size(20, 20)),
                        new IconData(m_IconsDir, masterIcons.Icon, new Size(32, 32)),
                        new IconData(m_IconsDir, masterIcons.Icon, new Size(40, 40)),
                        new IconData(m_IconsDir, masterIcons.Icon, new Size(64, 64)),
                        new IconData(m_IconsDir, masterIcons.Icon, new Size(96, 96)),
                        new IconData(m_IconsDir, masterIcons.Icon, new Size(128, 128))
                    };
                }
                else
                {
                    iconsData = new IconData[]
                    {
                        new IconData(m_IconsDir, masterIcons.Icon, new Size(16, 16)),
                        new IconData(m_IconsDir, masterIcons.Icon, new Size(24, 24)),
                    };
                }
            }
            else
            {
                throw new NotSupportedException($"Specified icon '{icon.GetType().FullName}' is not supported");
            }

            return(iconsData);
        }