Ejemplo n.º 1
0
        public static ManagedFileChooserNavigationItem[] DefaultGetFileSystemRoots()
        {
            return(MountedVolumes
                   .Select(x =>
            {
                var displayName = x.VolumeLabel;

                if (displayName == null & x.VolumeSizeBytes > 0)
                {
                    displayName = $"{ByteSizeHelper.ToString(x.VolumeSizeBytes)} Volume";
                }
                ;

                try
                {
                    Directory.GetFiles(x.VolumePath);
                }
                catch (Exception)
                {
                    return null;
                }

                return new ManagedFileChooserNavigationItem
                {
                    ItemType = ManagedFileChooserItemType.Volume,
                    DisplayName = displayName,
                    Path = x.VolumePath
                };
            })
                   .Where(x => x != null)
                   .ToArray());
        }
Ejemplo n.º 2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is long size && size > 0)
            {
                return(ByteSizeHelper.ToString((ulong)size));
            }

            return("");
        }