示例#1
0
        private static DataSet <T> GetDirectoryItems <T>(string path, CancellationToken ct)
            where T : DirectoryItem, new()
        {
            var result = DataSet <T> .Create();

            if (string.IsNullOrEmpty(path))
            {
                return(result);
            }

            foreach (var folder in DirectoryTreeItem.GetSubDirectories(path))
            {
                DirectoryInfo directoryInfo = new DirectoryInfo(folder);
                result.AddRow((_, x) => _.Initialize(x, directoryInfo));
                ct.ThrowIfCancellationRequested();
            }

            foreach (var file in GetFiles(path))
            {
                FileInfo fileInfo = new FileInfo(file);
                result.AddRow((_, x) => _.Initialize(x, fileInfo));
                ct.ThrowIfCancellationRequested();
            }

            return(result);
        }
示例#2
0
 public MainWindow()
 {
     InitializeComponent();
     CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, ExecuteCloseCommand));
     _directoryTreePresenter.Show(_directoryTreeView, DirectoryTreeItem.GetLogicalDrives());
     _currentDirectoryPresenter = new CurrentDirectoryPresenter(_currentDirectoryBarView, _directoryTreePresenter);
     DirectoryListMode          = DirectoryListMode.LargeIcon;
 }
示例#3
0
        private static string GetDisplayText(DirectoryTreeItem _, RowPresenter p)
        {
            var result = p.GetValue(_.Path);
            var depth  = p.Depth;

            if (depth > 0)
            {
                result = Path.GetFileName(result);
            }
            return(result);
        }
示例#4
0
        private static void Refresh(DirectoryTreeItemView v, DirectoryTreeItem _, RowPresenter p)
        {
            var depth = p.Depth;

            v.Refresh(depth, depth == 0 ? Icons.DiskDrive : Icons.Folder, GetDisplayText(_, p));
        }
示例#5
0
 public static RowBinding <DirectoryTreeItemView> BindToDirectoryTreeItemView(this DirectoryTreeItem _)
 {
     return(new RowBinding <DirectoryTreeItemView>((e, r) => Refresh(e, _, r)));
 }