Ejemplo n.º 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;
            }
        }
Ejemplo n.º 2
0
 void newItem_ItemDoubleClicked(ListPageItem listItem, FileSystemItem reference)
 {
     // bubble event to parent (column)
     if (ItemDoubleClicked != null)
     {
         ItemDoubleClicked.Invoke(listItem, reference);
     }
 }
Ejemplo n.º 3
0
 void list_ItemDoubleClicked(ListPageItem listItem, FileSystemItem reference)
 {
     if (reference.Type == ItemTypes.File || reference.Type == ItemTypes.FileShortcut)
     {
         System.Diagnostics.Process.Start(reference.Path);
     }
     else if (reference.Type == ItemTypes.Folder || reference.Type == ItemTypes.FolderShortcut)
     {
         System.Diagnostics.Process.Start(reference.Path);
     }
 }
Ejemplo n.º 4
0
        void newItem_ItemRightClicked(ListPageItem listItem, FileSystemItem reference)
        {
            var menu = new ContextMenu();

            menu.Items.Add(new MenuItem()
            {
                Header = "Rename"
            });

            listItem.ContextMenu = menu;
        }
Ejemplo n.º 5
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();
                }
            }
        }