/// <summary>
        ///     Get or create icon.
        /// </summary>
        /// <param name="fontFamily">The icon's font family</param>
        /// <param name="icon">Icon to generate</param>
        /// <param name="size">Bitmap size in pixels</param>
        /// <param name="fore">Foreground color</param>
        /// <param name="back">Background color</param>
        /// <returns></returns>
        public Bitmap Get(FontFamily fontFamily, TEnum icon, int size, Color fore, Color back, bool useGdi = false)
        {
            var key = new IconKey(icon, size, fore, back);

            if (_cache.TryGetValue(key, out var bitmap))
            {
                return(bitmap);
            }
            bitmap = useGdi
                ? fontFamily.ToBitmapGdi(icon, size, fore, back)
                : fontFamily.ToBitmap(icon, size, fore);
            _cache[key] = bitmap;
            return(bitmap);
        }
 public void RestoreBinding()
 {
     if (!string.IsNullOrWhiteSpace(textMeshComponent.text))
     {
         foreach (var item in IconsMap)
         {
             if (textMeshComponent.text == item.Value.IconCharacter)
             {
                 Icon = item.Key;
                 break;
             }
         }
     }
 }
        /// <summary>
        ///     Extract the Icon out of an AudioDevice
        /// </summary>
        /// <param name="audioDevice"></param>
        /// <param name="largeIcon"></param>
        /// <returns></returns>
        public static Icon ExtractIconFromAudioDevice(MMDevice audioDevice, bool largeIcon)
        {
            Icon ico;
            var  iconKey = new IconKey(audioDevice.IconPath, largeIcon);

            if (IconCache.TryGetValue(iconKey, out ico))
            {
                return(ico);
            }
            try
            {
                if (audioDevice.IconPath.EndsWith(".ico"))
                {
                    ico = Icon.ExtractAssociatedIcon(audioDevice.IconPath);
                }
                else
                {
                    var iconInfo  = audioDevice.IconPath.Split(',');
                    var dllPath   = iconInfo[0];
                    var iconIndex = int.Parse(iconInfo[1]);
                    ico = IconExtractor.Extract(dllPath, iconIndex, largeIcon);
                }
            }
            catch (Exception e)
            {
                AppLogger.Log.Error($"Can't extract icon from {audioDevice.IconPath}\n Ex: ", e);
                switch (audioDevice.DataFlow)
                {
                case DataFlow.Capture:
                    ico = Resources.defaultSpeakers;
                    break;

                case DataFlow.Render:
                    ico = Resources.defaultMicrophone;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            IconCache.Add(iconKey, ico);
            return(ico);
        }
Exemple #4
0
 public void ShowLogMessage(string message, int step, IconKey iconKey)
 {
     ShowLogMessage(message, step, iconKey.ToString());
 }
Exemple #5
0
 public void ShowLogMessage(string message, IconKey iconKey)
 {
     ShowLogMessage(message, 10, iconKey.ToString());
 }