コード例 #1
0
        public LibraryCards()
        {
            InitializeComponent();

            ItemsAdded.BeginBulkOperation();
            ItemsAdded.Add(new LibraryCardItem
            {
                Text = "SidebarDesktop".GetLocalized(),
                Path = AppSettings.DesktopPath,
            });
            ItemsAdded.Add(new LibraryCardItem
            {
                Text = "SidebarDownloads".GetLocalized(),
                Path = AppSettings.DownloadsPath,
            });
            foreach (var item in ItemsAdded)
            {
                item.Icon                 = GlyphHelper.GetIconUri(item.Path);
                item.SelectCommand        = LibraryCardClicked;
                item.AutomationProperties = item.Text;
            }
            ItemsAdded.EndBulkOperation();

            Loaded   += LibraryCards_Loaded;
            Unloaded += LibraryCards_Unloaded;
        }
コード例 #2
0
        /// <summary>
        /// Adds the item do the navigation sidebar
        /// </summary>
        /// <param name="path">The path which to save</param>
        /// <returns>Task</returns>
        public async Task AddItemToSidebarAsync(string path)
        {
            var item = await FilesystemTasks.Wrap(() => DrivesManager.GetRootFromPathAsync(path));

            var res = await FilesystemTasks.Wrap(() => StorageFileExtensions.DangerousGetFolderFromPathAsync(path, item));

            if (res || (FilesystemResult)FolderHelpers.CheckFolderAccessWithWin32(path))
            {
                var lastItem    = favoriteSection.ChildItems.LastOrDefault(x => x.ItemType == NavigationControlItemType.Location && !x.Path.Equals(App.AppSettings.RecycleBinPath));
                int insertIndex = lastItem != null?favoriteSection.ChildItems.IndexOf(lastItem) + 1 : 0;

                var locationItem = new LocationItem
                {
                    Font              = InteractionViewModel.FontName,
                    Path              = path,
                    Section           = SectionType.Favorites,
                    Icon              = GlyphHelper.GetIconUri(path),
                    IsDefaultLocation = false,
                    Text              = res.Result?.DisplayName ?? Path.GetFileName(path.TrimEnd('\\'))
                };

                if (!favoriteSection.ChildItems.Contains(locationItem))
                {
                    favoriteSection.ChildItems.Insert(insertIndex, locationItem);
                }
            }
            else
            {
                Debug.WriteLine($"Pinned item was invalid and will be removed from the file lines list soon: {res.ErrorCode}");
                RemoveItem(path);
            }
        }
コード例 #3
0
ファイル: WindowsFontsTest.cs プロジェクト: xposure/TrueType
        public void ShouldGetGlyph()
        {
            var font = TrueTypeFont.FromFile(@"C:\Windows\Fonts\arial.ttf");

            var glyphIndex = GlyphHelper.GetGlyphIndex('A', font);

            Assert.NotEqual((uint)0, glyphIndex);
        }
コード例 #4
0
ファイル: FontImage.cs プロジェクト: pdxmholmes/shibang
        private ImageSource CreateGlyph()
        {
            if (Glyph != null && FontFamily != null && Brush != null)
            {
                return(GlyphHelper.CreateGlyph(Glyph, FontFamily, FontStyle, FontWeight, FontStretch, IsEnabled ? Brush : DisabledBrush));
            }

            return(null);
        }
コード例 #5
0
 public LibraryLocationItem(ShellLibraryItem shellLibrary)
 {
     Section           = SectionType.Library;
     Text              = shellLibrary.DisplayName;
     Path              = shellLibrary.FullPath;
     Icon              = GlyphHelper.GetIconUri(shellLibrary.DefaultSaveFolder);
     DefaultSaveFolder = shellLibrary.DefaultSaveFolder;
     Folders           = shellLibrary.Folders == null ? null : new ReadOnlyCollection <string>(shellLibrary.Folders);
     IsDefaultLocation = shellLibrary.IsPinned;
 }
コード例 #6
0
        List <CommandViewModel> CreateToolbarCommands()
        {
            var newProjectRelayCommand = DelegateCommandFactory.Create <object>(OnNewFileExecuted);
            var addNewItemRelayCommand = DelegateCommandFactory.Create <object>(OnNewFileExecuted);
            var openRelayCommand       = DelegateCommandFactory.Create <object>(OnNewFileExecuted);

            CommandViewModel newProject = new CommandViewModel("New Project", newProjectRelayCommand)
            {
                Glyph = GlyphHelper.GetGlyph("/Images/VS2010Docking/NewProject_16x16.png"), KeyGesture = KeyGestureHelper.GetKeyGesure(Key.N, ModifierKeys.Control | ModifierKeys.Shift)
            };
            CommandViewModel newFile = new CommandViewModel("Add New Item", addNewItemRelayCommand)
            {
                Glyph = GlyphHelper.GetGlyph("/Images/VS2010Docking/File_16x16.png"), KeyGesture = KeyGestureHelper.GetKeyGesure(Key.N, ModifierKeys.Control)
            };
            CommandViewModel openFile = new CommandViewModel("Open File", openRelayCommand)
            {
                Glyph = GlyphHelper.GetGlyph("/Images/VS2010Docking/OpenFile_16x16.png"), KeyGesture = KeyGestureHelper.GetKeyGesure(Key.O, ModifierKeys.Control)
            };

            CommandViewModel save = new CommandViewModel("Save")
            {
                Glyph = GlyphHelper.GetGlyph("/Images/VS2010Docking/Save_16x16.png"), KeyGesture = KeyGestureHelper.GetKeyGesure(Key.S, ModifierKeys.Control)
            };
            CommandViewModel saveAll = new CommandViewModel("Save All")
            {
                Glyph = GlyphHelper.GetGlyph("/Images/VS2010Docking/SaveAll_16x16.png"), KeyGesture = KeyGestureHelper.GetKeyGesure(Key.S, ModifierKeys.Control | ModifierKeys.Shift)
            };

            CommandViewModel cut = new CommandViewModel("Cut")
            {
                Glyph = GlyphHelper.GetGlyph("/Images/VS2010Docking/Cut_16x16.png"), KeyGesture = KeyGestureHelper.GetKeyGesure(Key.S, ModifierKeys.Control | ModifierKeys.Shift)
            };
            CommandViewModel copy = new CommandViewModel("Copy")
            {
                Glyph = GlyphHelper.GetGlyph("/Images/VS2010Docking/Copy_16x16.png"), KeyGesture = KeyGestureHelper.GetKeyGesure(Key.S, ModifierKeys.Control | ModifierKeys.Shift)
            };
            CommandViewModel paste = new CommandViewModel("Paste")
            {
                Glyph = GlyphHelper.GetGlyph("/Images/VS2010Docking/Paste_16x16.png"), KeyGesture = KeyGestureHelper.GetKeyGesure(Key.S, ModifierKeys.Control | ModifierKeys.Shift)
            };

            CommandViewModel undo = new CommandViewModel("Undo")
            {
                Glyph = GlyphHelper.GetGlyph("/Images/VS2010Docking/Undo_16x16.png"), KeyGesture = KeyGestureHelper.GetKeyGesure(Key.S, ModifierKeys.Control | ModifierKeys.Shift)
            };
            CommandViewModel redo = new CommandViewModel("Redo")
            {
                Glyph = GlyphHelper.GetGlyph("/Images/VS2010Docking/Redo_16x16.png"), KeyGesture = KeyGestureHelper.GetKeyGesure(Key.S, ModifierKeys.Control | ModifierKeys.Shift)
            };

            return(new List <CommandViewModel>()
            {
                newProject, newFile, openFile, save, saveAll, GetSeparator(), cut, copy, paste, GetSeparator(), undo, redo
            });
        }
コード例 #7
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;
 }
コード例 #8
0
        protected virtual List <CommandViewModel> CreateFileCommands()
        {
            var openDocumentRelayCommand  = DelegateCommandFactory.Create <object>(OnOpenDocument);
            CommandViewModel openDocument = new CommandViewModel("Open...", openDocumentRelayCommand)
            {
                Glyph = GlyphHelper.GetGlyph("/Images/Open_16x16.png"), IsEnabled = true
            };

            return(new List <CommandViewModel>()
            {
                openDocument
            });
        }
コード例 #9
0
        private void ReloadLibraryItems()
        {
            ItemsAdded.BeginBulkOperation();
            var toRemove = ItemsAdded.Where(i => i.IsLibrary).ToList();

            foreach (var item in toRemove)
            {
                ItemsAdded.Remove(item);
            }
            foreach (var lib in App.LibraryManager.Libraries)
            {
                ItemsAdded.Add(new LibraryCardItem
                {
                    Icon                 = GlyphHelper.GetIconUri(lib.DefaultSaveFolder),
                    Text                 = lib.Text,
                    Path                 = lib.Path,
                    SelectCommand        = LibraryCardClicked,
                    AutomationProperties = lib.Text,
                    Library              = lib,
                });
            }
            ItemsAdded.EndBulkOperation();
        }
コード例 #10
0
ファイル: LibraryManager.cs プロジェクト: linsui/Files
        private async Task SyncLibrarySideBarItemsUI()
        {
            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                await SidebarControl.SideBarItemsSemaphore.WaitAsync();
                try
                {
                    SidebarControl.SideBarItems.BeginBulkOperation();

                    try
                    {
                        if (App.AppSettings.ShowLibrarySection && !SidebarControl.SideBarItems.Contains(librarySection))
                        {
                            librarySection = new LocationItem()
                            {
                                Text             = "SidebarLibraries".GetLocalized(),
                                Section          = SectionType.Library,
                                Font             = App.Current.Resources["OldFluentUIGlyphs"] as FontFamily,
                                Glyph            = "\uEC13",
                                SelectsOnInvoked = false,
                                ChildItems       = new ObservableCollection <INavigationControlItem>()
                            };
                            SidebarControl.SideBarItems.Insert(1, librarySection);

                            libraryItems.Clear();
                            libraryItems.Add(AppSettings.DocumentsPath);
                            libraryItems.Add(AppSettings.PicturesPath);
                            libraryItems.Add(AppSettings.MusicPath);
                            libraryItems.Add(AppSettings.VideosPath);

                            for (int i = 0; i < libraryItems.Count(); i++)
                            {
                                string path = libraryItems[i];

                                var item = await FilesystemTasks.Wrap(() => DrivesManager.GetRootFromPathAsync(path));
                                var res  = await FilesystemTasks.Wrap(() => StorageFileExtensions.DangerousGetFolderFromPathAsync(path, item));

                                if (res || (FilesystemResult)FolderHelpers.CheckFolderAccessWithWin32(path))
                                {
                                    var locationItem = new LocationItem
                                    {
                                        Path              = path,
                                        Section           = SectionType.Library,
                                        Glyph             = GlyphHelper.GetItemIcon(path),
                                        Font              = InteractionViewModel.FontName,
                                        IsDefaultLocation = true,
                                        Text              = res.Result?.DisplayName ?? Path.GetFileName(path.TrimEnd('\\'))
                                    };

                                    librarySection.ChildItems.Insert(i, locationItem);
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }

                    SidebarControl.SideBarItems.EndBulkOperation();
                }
                finally
                {
                    SidebarControl.SideBarItemsSemaphore.Release();
                }
            });
        }
コード例 #11
0
        protected override List <CommandViewModel> CreateFileCommands()
        {
            var projectRelayCommand   = DelegateCommandFactory.Create <object>(OnNewFileExecuted);
            var fileRelayCommand      = DelegateCommandFactory.Create <object>(OnNewFileExecuted);
            var fileOpenRelayCommand  = DelegateCommandFactory.Create <object>(OnNewFileExecuted);
            var closeFileRelayCommand = DelegateCommandFactory.Create <object>(OnCloseFileExecuted);

            CommandViewModel newCommand = new CommandViewModel("New")
            {
                IsSubItem = true
            };
            CommandViewModel newProject = new CommandViewModel("Project...", projectRelayCommand)
            {
                Glyph = GlyphHelper.GetGlyph("/Images/VS2010Docking/NewProject_16x16.png"), KeyGesture = KeyGestureHelper.GetKeyGesure(Key.N, ModifierKeys.Control | ModifierKeys.Shift)
            };
            CommandViewModel newFile = new CommandViewModel("File...", fileRelayCommand)
            {
                Glyph = GlyphHelper.GetGlyph("/Images/VS2010Docking/File_16x16.png"), KeyGesture = KeyGestureHelper.GetKeyGesure(Key.N, ModifierKeys.Control)
            };

            newCommand.Commands = new List <CommandViewModel>()
            {
                newProject, newFile
            };

            CommandViewModel openCommand = new CommandViewModel("Open")
            {
                IsSubItem = true,
            };
            CommandViewModel openProject = new CommandViewModel("Project/Solution...")
            {
                Glyph = GlyphHelper.GetGlyph("/Images/VS2010Docking/OpenSolution_16x16.png"), KeyGesture = KeyGestureHelper.GetKeyGesure(Key.O, ModifierKeys.Control | ModifierKeys.Shift), IsEnabled = false
            };
            CommandViewModel openFile = new CommandViewModel("File...", fileOpenRelayCommand)
            {
                Glyph = GlyphHelper.GetGlyph("/Images/VS2010Docking/OpenFile_16x16.png"), KeyGesture = KeyGestureHelper.GetKeyGesure(Key.O, ModifierKeys.Control)
            };

            openCommand.Commands = new List <CommandViewModel>()
            {
                openProject, openFile
            };

            CommandViewModel closeFile     = new CommandViewModel("Close", closeFileRelayCommand);
            CommandViewModel closeSolution = new CommandViewModel("Close Solution")
            {
                Glyph = GlyphHelper.GetGlyph("/Images/VS2010Docking/CloseSolution_16x16.png")
            };
            CommandViewModel save = new CommandViewModel("Save")
            {
                Glyph = GlyphHelper.GetGlyph("/Images/VS2010Docking/Save_16x16.png"), KeyGesture = KeyGestureHelper.GetKeyGesure(Key.S, ModifierKeys.Control)
            };
            CommandViewModel saveAll = new CommandViewModel("Save All")
            {
                Glyph = GlyphHelper.GetGlyph("/Images/VS2010Docking/SaveAll_16x16.png"), KeyGesture = KeyGestureHelper.GetKeyGesure(Key.S, ModifierKeys.Control | ModifierKeys.Shift)
            };

            CommandViewModel recentFilesCommand = new CommandViewModel("Recent files")
            {
                IsSubItem = true,
            };
            CommandViewModel recentProjectsCommand = new CommandViewModel("Recent projects and solutions")
            {
                IsSubItem = true,
            };

            return(new List <CommandViewModel>()
            {
                newCommand, openCommand, GetSeparator(), closeFile, closeSolution, GetSeparator(), save,
                saveAll, GetSeparator(), recentFilesCommand, recentProjectsCommand
            });
        }