Beispiel #1
0
        /// <summary>
        /// Retrieves the images that are used to specify the provided modifiers.
        /// </summary>
        /// <param name="modifier">The modifiers to get the images for.</param>
        /// <returns>The images.</returns>
        private static IEnumerable <Image> GetModifierImage(ElementModifier modifier)
        {
            // Access
            if ((modifier & ElementModifier.Public) != 0)
            {
                yield return(Properties.Resources._public);
            }
            if ((modifier & ElementModifier.Internal) != 0)
            {
                yield return(Properties.Resources._internal);
            }
            if ((modifier & ElementModifier.Protected) != 0)
            {
                yield return(Properties.Resources._protected);
            }
            if ((modifier & ElementModifier.Private) != 0)
            {
                yield return(Properties.Resources._private);
            }

            // Other
            if ((modifier & ElementModifier.Partial) != 0)
            {
                yield return(Properties.Resources.partial);
            }
            if ((modifier & ElementModifier.Static) != 0)
            {
                yield return(Properties.Resources._static);
            }
            if ((modifier & ElementModifier.Sealed) != 0)
            {
                yield return(Properties.Resources._sealed);
            }
        }
 public static void Modify(this int[] mass, ElementModifier Modifier)
 {
     for (int i = 0; i < mass.Length; i++)
     {
         mass[i] = Modifier(mass[i]);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Retrieves an image with the specified parameters. The image is retrieved from cache if it was gerneated
        /// before, otherwise it is generated anew.
        /// </summary>
        /// <param name="type">The element type.</param>
        /// <param name="modifiers">The access type.</param>
        /// <param name="static">A value indicating whether the element is static or not.</param>
        /// <returns>The retrieved image.</returns>
        public static BitmapImage GetImage(ElementType type, ElementModifier modifiers = ElementModifier.None)
        {
            var key = $"{type}:{modifiers}";

            if (!imageCache.ContainsKey(key))
            {
                imageCache.Add(key, CreateImage(type, modifiers));
            }

            return(imageCache[key]);
        }
Beispiel #4
0
        /// <summary>
        /// Creates a new image with the specified parameters.
        /// </summary>
        /// <param name="type">The element type.</param>
        /// <param name="modifiers">The element modifiers.</param>
        /// <returns>The generated image.</returns>
        private static BitmapImage CreateImage(ElementType type, ElementModifier modifiers)
        {
            var result = new Bitmap(GetElementImage(type));

            using (var g = Graphics.FromImage(result))
            {
                foreach (var image in GetModifierImage(modifiers))
                {
                    g.DrawImage(image, new Point(0, 0));
                }
            }

            return(result.ToBitmapImage());
        }