コード例 #1
0
        public FileInfo GetIconPath(FileEntityViewModel viewModel)
        {
            if (viewModel is FileViewModel fileViewModel)
            {
                var extension = new FileInfo(fileViewModel.FullName).Extension;

                var imagePath = _converter.GetImagePath(string.IsNullOrEmpty(extension) ? "" : extension.Substring(1));

                return(imagePath);
            }

            if (viewModel is LogicalDriveViewModel logicalDriveViewModel)
            {
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    if (logicalDriveViewModel.FullName == "C:\\")
                    {
                        return(_converter.GetImagePath(IconName.SystemDrive));
                    }
                }

                return(_converter.GetImagePath(IconName.LogicalDrive));
            }

            if (viewModel is DirectoryViewModel)
            {
                return(_converter.GetImagePath(IconName.Folder));
            }

            throw new NotImplementedException();
        }
コード例 #2
0
        private void DefinitionPathToVm(MenuItemViewModel vm, string path, DirectoryInfo iconsDirectory)
        {
            vm.Command = BookmarkClickCommand;

            var attr = File.GetAttributes(path);

            if (attr.HasFlag(FileAttributes.Directory))
            {
                vm.Header   = new DirectoryInfo(path).Name;
                vm.IconPath = Path.Combine(iconsDirectory.FullName, IconName.Folder + ".svg");
            }
            else
            {
                var extension = new FileInfo(path).Extension;

                vm.Header   = new FileInfo(path).Name;
                vm.IconPath =
                    _converter.GetImagePath(string.IsNullOrEmpty(extension) ? "" : extension.Substring(1))
                    .FullName;
            }
        }