Ejemplo n.º 1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            ItemType type;

            if (!Enum.TryParse <ItemType>(value.GetType().Name, out type))
            {
                return(null);
            }

            IconSize size;

            if (!Enum.TryParse <IconSize>((string)parameter, out size))
            {
                size = IconSize.Small;
            }

            if (type == ItemType.File)
            {
                Icon icon = IconReader.GetFileIcon(((File)value).Extension.ToLower(), size, false);
                return(icon.ToImageSource());
            }
            else
            {
                if ((type == ItemType.DriveModel) && !Enum.TryParse <ItemType>(((DriveModel)value).DriveType.ToString(), out type))
                {
                    return(null);
                }
                string key = type.ToString() + size.ToString();
                if (!_folderIconCache.ContainsKey(key))
                {
                    _folderIconCache.Add(key, IconReader.GetIcon(type, size).ToImageSource());
                }
                return(_folderIconCache[key]);
            }
        }
Ejemplo n.º 2
0
 private void UpdateImage()
 {
     Image = IconReader.GetIcon(_model.Path, _model.IsDirectory);
 }