Ejemplo n.º 1
0
        /// <summary>
        /// Convert MMDevice to IconPath(string)
        /// </summary>
        /// <param name="value">Enum value</param>
        /// <param name="targetType">target type</param>
        /// <param name="parameter">parameter</param>
        /// <param name="language">language</param>
        /// <returns>bool</returns>
        public override object Convert(object value, Type targetType, object parameter,
                                       System.Globalization.CultureInfo culture)
        {
            var device = value as MMDevice;

            if (device == null)
            {
                return(null);
            }

            try
            {
                if (device?.State != EDeviceState.Active)
                {
                    return(null);
                }
                var isLarge = false;
                if (parameter != null)
                {
                    isLarge = ((string)parameter).ToUpper().Equals("LARGE");
                }

                ImageSource img = WindowsUtil.GetIconFromEXEDLL2(device.IconPath, isLarge).ToImageSource();

                return(img);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.StackTrace);

                return(null);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="iconpath"></param>
 public void SetDeviceIcon(string iconpath)
 {
     System.Drawing.Icon ico = WindowsUtil.GetIconFromEXEDLL2(iconpath, false);
     this.Icon = ico;
 }