Esempio n. 1
0
 public LibraryLocationItem(ShellLibraryItem shellLibrary)
 {
     Section           = SectionType.Library;
     Text              = shellLibrary.DisplayName;
     Path              = shellLibrary.FullPath;
     DefaultSaveFolder = shellLibrary.DefaultSaveFolder;
     Folders           = shellLibrary.Folders == null ? null : new ReadOnlyCollection <string>(shellLibrary.Folders);
     IsDefaultLocation = shellLibrary.IsPinned;
 }
Esempio n. 2
0
 public LibraryLocationItem(ShellLibraryItem shellLibrary)
 {
     Section           = SectionType.Library;
     Text              = shellLibrary.DisplayName;
     Path              = shellLibrary.FullPath;
     Icon              = new Windows.UI.Xaml.Media.Imaging.SvgImageSource(GlyphHelper.GetIconUri(shellLibrary.DefaultSaveFolder));
     IconSource        = GlyphHelper.GetIconUri(shellLibrary.DefaultSaveFolder);
     DefaultSaveFolder = shellLibrary.DefaultSaveFolder;
     Folders           = shellLibrary.Folders == null ? null : new ReadOnlyCollection <string>(shellLibrary.Folders);
     IsDefaultLocation = shellLibrary.IsPinned;
 }
Esempio n. 3
0
 public LibraryLocationItem(ShellLibraryItem shellLibrary)
 {
     Section     = SectionType.Library;
     MenuOptions = new ContextMenuOptions
     {
         IsLocationItem = true,
         ShowProperties = true,
         ShowShellItems = true,
         ShowUnpinItem  = !shellLibrary.IsPinned,
     };
     Text = shellLibrary.DisplayName;
     Path = shellLibrary.FullPath;
     DefaultSaveFolder = shellLibrary.DefaultSaveFolder;
     Folders           = shellLibrary.Folders is null ? null : new ReadOnlyCollection <string>(shellLibrary.Folders);
     IsDefaultLocation = shellLibrary.IsPinned;
 }
Esempio n. 4
0
        public static ShellLibraryItem GetShellLibraryItem(ShellLibrary2 library, string filePath)
        {
            var libraryItem = new ShellLibraryItem
            {
                FullPath     = filePath,
                AbsolutePath = library.GetDisplayName(ShellItemDisplayString.DesktopAbsoluteParsing),
                RelativePath = library.GetDisplayName(ShellItemDisplayString.ParentRelativeParsing),
                DisplayName  = library.GetDisplayName(ShellItemDisplayString.NormalDisplay),
                IsPinned     = library.PinnedToNavigationPane,
            };
            var folders = library.Folders;

            if (folders.Count > 0)
            {
                libraryItem.DefaultSaveFolder = SafetyExtensions.IgnoreExceptions(() => library.DefaultSaveFolder.FileSystemPath);
                libraryItem.Folders           = folders.Select(f => f.FileSystemPath).ToArray();
            }
            return(libraryItem);
        }
Esempio n. 5
0
        public async Task HandleWin32LibraryEvent(ShellLibraryItem library, string oldPath)
        {
            string path = oldPath;

            if (string.IsNullOrEmpty(oldPath))
            {
                path = library?.FullPath;
            }
            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var changedLibrary = Libraries.FirstOrDefault(l => string.Equals(l.Path, path, StringComparison.OrdinalIgnoreCase));
                if (changedLibrary != null)
                {
                    Libraries.Remove(changedLibrary);
                }
                // library is null in case it was deleted
                if (library != null)
                {
                    Libraries.AddSorted(new LibraryLocationItem(library));
                }
            });
        }