コード例 #1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string path = (string)value;

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

            //by default we presume an image
            string image = "Images/file.png";

            string name = DirectoryStructure.GetFileFolderName(path);

            if (string.IsNullOrEmpty(name))
            {
                image = "Images/drive.png";
            }
            else if ((new FileInfo(path)).Attributes.HasFlag(FileAttributes.Directory))
            {
                image = "Images/folder-closed.png";
            }
            else
            {
            }

            return(new BitmapImage(new Uri($"pack://application:,,,/{image}")));
        }
コード例 #2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // Get the full path
            var path = (string)value;

            // If the path is null, ignore
            if (path == null)
            {
                return(null);
            }

            // Get the name of the item: file/folder
            var name = DirectoryStructure.GetFileFolderName(path);

            // Let's assume it is a file just in case
            var image = "Images/file.png";

            // If the name is blank, we presume it's a drive as we cannot have blank file or folder name
            if (string.IsNullOrEmpty(name))
            {
                image = "Images/drive.png";
            }
            else if (new FileInfo(path).Attributes.HasFlag(FileAttributes.Directory))
            {
                image = "Images/folder-closed.png";
            }


            return(new BitmapImage(new Uri($"pack://application:,,,/{image}")));
        }
コード例 #3
0
        /// <summary>
        /// Convert a full path to a specific image type of a drive folder or file
        /// </summary>

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var name = DirectoryStructure.GetFileFolderName(path);


            //by default, we presume an image
            var image = "Images/download.jpg";

            switch ((DirectoryItemType)value)
            {
            case DirectoryItemType.Drive:
                image = "Image/drive.png";
                break;

            case DirectoryItemType.Folder:
                image = "Image/download.jpg";
                break;
            }

            // if the name is blank we presume it's  a drive as we cannot have a blank file or folder name
            if (string.IsNullOrEmpty(name))
            {
                image = "Images/download.jpg";
            }
            else if (new FileInfo(path).Attributes.HasFlag(FileAttributes.Directory))
            {
                image = "Images/afv_icon.png";
            }

            return(new BitmapImage(new Uri($"pack://application:,,,/{image}")));
        }
コード例 #4
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            //get the full path
            var path = (string)value;

            //if the path is null, ignore
            if (path == null)
            {
                return(null);
            }

            //get the name of the file/folder
            var name = DirectoryStructure.GetFileFolderName(path);

            //by default we presume an image
            var image = "Images/C.jpg";

            //if the name is blank, we presume it's a drive (we cannot have a blank file/image name)
            if (string.IsNullOrEmpty(name))
            {
                image = "Images/A.jpg";
            }
            else if (new FileInfo(path).Attributes.HasFlag(FileAttributes.Directory))
            {
                image = "Images/B.jpg";
            }

            return(new BitmapImage(new Uri($"pack://application:,,,/{image}")));
        }
コード例 #5
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var path = (string)value;

            //if the path is null, ignore
            if (path == null)
                return null;


            var name = DirectoryStructure.GetFileFolderName(path);

            

            var image = "Images/file.png";
            if (string.IsNullOrEmpty(name))
                image = "Images/drive.png";
            else if (new FileInfo(path).Attributes.HasFlag(FileAttributes.Directory))
                image = "Images/folder-closed.png";




            return new BitmapImage(new Uri($"pack://application:,,,/{image}"));
        }