private static int GetNumberOfIcons(IconSetType iconSetType)
 {
     IconSetType[] fourIcons =
     {
         IconSetType.Item4Arrows,
         IconSetType.Item4ArrowsGray,
         IconSetType.Item4RedToBlack,
         IconSetType.Item4Rating,
         IconSetType.Item4TrafficLights
     };
     IconSetType[] fiveIcons =
     {
         IconSetType.Item5Arrows,
         IconSetType.Item5ArrowsGray,
         IconSetType.Item5Rating,
         IconSetType.Item5Quarters
     };
     if (fourIcons.Contains(iconSetType))
     {
         return(4);
     }
     if (fiveIcons.Contains(iconSetType))
     {
         return(5);
     }
     return(3);
 }
Exemple #2
0
        internal static Stream GetResource(IconSetType iconType, int iconIndex)
        {
            int    num = (int)iconType;
            string str = _cachedImageSources[num, iconIndex];

            if (str == null)
            {
                str = _cachedIconNames[num, iconIndex];
                _cachedImageSources[num, iconIndex] = str;
            }
            if (_cachedResource.ContainsKey(str))
            {
                return(_cachedResource[str]);
            }
            Assembly assembly = IntrospectionExtensions.GetTypeInfo((Type)typeof(FormatIconsHelper)).Assembly;

            string[] manifestResourceNames  = assembly.GetManifestResourceNames();
            Stream   manifestResourceStream = null;
            string   str2 = null;

            foreach (string str3 in manifestResourceNames)
            {
                if (!string.IsNullOrEmpty(str3) && str3.Contains(str))
                {
                    str2 = str3;
                    break;
                }
            }
            if (!string.IsNullOrEmpty(str2))
            {
                manifestResourceStream = assembly.GetManifestResourceStream(str2);
            }
            _cachedResource.Add(str, manifestResourceStream);
            return(manifestResourceStream);
        }
        /// <summary>
        /// Add default icon set.
        /// </summary>
        /// <param name="iconSetType"></param>
        /// <param name="showValue"></param>
        /// <returns></returns>
        public CFRule AddDefaultIconSet(IconSetType iconSetType = IconSetType.Item3Arrows, bool showValue = true)
        {
            CFRule rule = new CFRule(CFType.IconSet);

            rule.IconSet = IconSet.CreateDefaultIconSet(iconSetType, showValue);
            AddRule(rule);
            return(rule);
        }
        public static IconSet CreateDefaultIconSet(IconSetType iconSetType = IconSetType.Item3Arrows, bool showValue = true)
        {
            IconSet iconSet = new IconSet();

            iconSet.IconSetType = iconSetType;
            iconSet.CFVOList    = GenerateCFVOs(iconSetType);
            iconSet.ShowValue   = showValue;
            return(iconSet);
        }
        private static List <CFVO> GenerateCFVOs(IconSetType iconSetType)
        {
            int         numberOfIcons = GetNumberOfIcons(iconSetType);
            decimal     step          = 100.0m / numberOfIcons;
            List <CFVO> list          = new List <CFVO>();

            for (int i = 0; i < numberOfIcons; i++)
            {
                int  percent = (int)Math.Round(i * step);
                CFVO cfvo    = new CFVO
                {
                    Type  = CFVOType.Percent,
                    Value = percent.ToString()
                };
                list.Add(cfvo);
            }
            return(list);
        }
Exemple #6
0
            public static async Task <ImageSource> GetIconSource(IconSetType iconType, int iconIndex)
            {
                int         num    = (int)iconType;
                ImageSource source = CachedImageSources[num, iconIndex];

                if (source == null)
                {
                    BitmapImage bmp = new BitmapImage();
                    using (var stream = typeof(SR).Assembly.GetManifestResourceStream("Dt.Cells.Icons.ConditionalFormats." + CachedIconNames[num, iconIndex]))
                    {
#if UWP
                        await bmp.SetSourceAsync(stream.AsRandomAccessStream());
#else
                        await bmp.SetSourceAsync(stream);
#endif
                    }
                    source = bmp;
                    CachedImageSources[num, iconIndex] = bmp;
                }
                return(source);
            }