Пример #1
0
 private void OpenArchive(string path)
 {
     if (Directory.Exists(path))
     {
         previousFileIndex = FileList.SelectedIndex;
         SelectFolder(path);
     }
     else if (_type != ArchiveTypes.None)
     {
         FileList.Items.Clear();
         var archive = ArchiveFactory.Open(path);
         _archivePath = path;
         archive.Entries.ToList().ForEach(delegate(IArchiveEntry values)
         {
             var extension = "." + values.Key.Split('.').Last();
             var isDir     = values.IsDirectory;
             var exePath   = IconManager.FindIconForFilename(extension, false);
             FileList.Items.Add(new FileItem(exePath)
             {
                 Name = values.Key, Entry = values, IsDir = isDir
             });
         });
         ArchiveMode = true;
     }
     else
     {
         Process.Start(path);
     }
 }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            switch (value)
            {
            case IFilesystemEntry filesystemEntry:

                if (filesystemEntry.IsDirectory)
                {
                    return(IconManager.FindIconForFolder(parameter as string == "large", false));
                }

                var isDDS = FileTypeChecker.IsExtensionDDS(filesystemEntry);
                if (isDDS)
                {
                    return(IconManager.FindIconForFilename("file.dds", parameter as string == "large"));
                }

                //todo known types
                //menuItem.File.Filename

                // fallback
                return(IconManager.FindIconForFilename(filesystemEntry.Name, parameter as string == "large"));

            default:
                return(IconManager.FindIconForFilename("empty_file", parameter as string == "large"));    // return empty file
            }
        }
Пример #3
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var fileName = value as string;

            var icon = IconManager.FindIconForFilename(fileName, true);

            if (icon == null)
            {
                // TODO: get default icon if no icon found for file type
            }

            return(icon);
        }
Пример #4
0
        private void AddNodes(Func <string, string> removeFunc, string path, TreeNode parent)
        {
            foreach (var dir in Directory.GetDirectories(path))
            {
                TreeNode tn = new FileNode(removeFunc(dir), dir, true)
                {
                    ImageKey         = removeFunc(dir) == "_ide" ? "idedir" : "dir",
                    SelectedImageKey = removeFunc(dir) == "_ide" ? "idedir" : "dir"
                };

                parent.Nodes.Add(tn);

                AddNodes(removeFunc, dir, tn);
            }

            foreach (var file in Directory.GetFiles(path))
            {
                var ext = System.IO.Path.GetExtension(file);
                if (!string.IsNullOrEmpty(ext))
                {
                    if (!il.Images.Keys.Contains(ext))
                    {
                        il.Images.Add(ext, IconManager.FindIconForFilename(file, true));
                    }

                    parent.Nodes.Add(new FileNode(removeFunc(file), file, false)
                    {
                        ImageKey         = ext,
                        SelectedImageKey = ext
                    });
                }
                else
                {
                    parent.Nodes.Add(new FileNode(removeFunc(file), file, false));
                }

                if (file.EndsWith(".hasm", true, CultureInfo.CurrentCulture))
                {
                    SourceFiles.Add(new SourceFile(Formatter.MakeRelative(file, Path + "\\"), file));
                }
            }
        }
Пример #5
0
        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string fileName = (string)value;

            return(IconManager.FindIconForFilename(fileName, true));
        }
Пример #6
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(null);
            }

            if (!(value is Blob blob))
            {
                return(null);
            }

            if (FolderResource.IsLoadingBlob(blob))
            {
                return(null);
            }

            if (targetType == typeof(ImageSource))
            {
                if (blob.Kind == BlobItemKind.Folder)
                {
                    if (blob.Properties.ContainsKey("IsLogsContainer"))
                    {
                        return("azure/metrics".GetImageSource());
                    }

                    if (blob.Properties.ContainsKey("IsSecret"))
                    {
                        return("account/azure.keyvault.secret".GetImageSource());
                    }

                    if (blob.Properties.ContainsKey("IsContainer"))
                    {
                        return("account/azure.blob.container".GetImageSource());
                    }

                    if (blob.Properties.ContainsKey("IsFilesystem"))
                    {
                        return("account/azure.datalake.gen2".GetImageSource());
                    }

                    if (blob.Properties.ContainsKey("IsShare"))
                    {
                        return("account/azure.file".GetImageSource());
                    }


                    return(_folderImageSource);
                }

                return(WindowsNative.HasAssociatedProgram(blob.Name) ? IconManager.FindIconForFilename(blob.Name, false) : null);
            }
            else if (targetType == typeof(Visibility))
            {
                if (blob.IsFile && WindowsNative.HasAssociatedProgram(blob.Name))
                {
                    return(Visibility.Visible);
                }

                return(Visibility.Collapsed);
            }

            return(null);
        }