Beispiel #1
0
        private void loadDirectory(Directory directory, FileSystemItem selection = null)
        {
            listMain.Items.Clear();

            // add items, directories first
            var allItems = new List <FileSystemItem>();

            try { allItems.AddRange(FileSystemQuerier.Search(directory.Path)); }
            catch (UnauthorizedAccessException) { throw; }

            if (allItems.Count > 0)
            {
                foreach (var item in allItems)
                {
                    var newItem = new ListPageItem(item);
                    newItem.ItemDoubleClicked += newItem_ItemDoubleClicked;
                    newItem.ItemRightClicked  += newItem_ItemRightClicked;

                    listMain.Items.Add(newItem);

                    if (selection != null && FileSystemItem.IsSamePath(selection, item.Path))
                    {
                        ignoreSelectionChanges.Start();
                        listMain.SelectedIndex = listMain.Items.IndexOf(newItem);
                        ignoreSelectionChanges.Stop();
                        break;
                    }
                }
            }
            else
            {
                // show message that directory is empty
                textEmpty.Visibility = System.Windows.Visibility.Visible;
            }
        }
Beispiel #2
0
        private void loadRoot(FileSystemItem selection = null)
        {
            listMain.Items.Clear();

            // add all drives
            foreach (var drive in System.IO.DriveInfo.GetDrives())
            {
                var newItem = new ListPageItem(new Directory(drive.RootDirectory));

                newItem.ItemDoubleClicked += newItem_ItemDoubleClicked;
                newItem.ItemRightClicked  += newItem_ItemRightClicked;

                listMain.Items.Add(newItem);
                if (selection != null && FileSystemItem.IsSamePath(selection, drive.RootDirectory.FullName))
                {
                    ignoreSelectionChanges.Start();
                    listMain.SelectedIndex = listMain.Items.IndexOf(newItem);
                    ignoreSelectionChanges.Stop();
                }
            }
        }