示例#1
0
        /// <summary>
        /// Refresh the entire list of files/folders
        /// </summary>
        private async Task RefreshListing()
        {
            this.Text        = _titleListing;
            bRefresh.Enabled = false;

            var li = (await Program.Account.Client.ListRecursive(".", false)).ToList();

            foreach (var l in li)
            {
                // convert to relative paths
                l.FullPath = Program.Account.GetCommonPath(l.FullPath, false);
            }

            // get the first level folders
            var folders = li.Where(d => d.Type == ClientItemType.Folder && !d.FullPath.Contains("/"));

            // get the first level files
            var files = li
                        .Where(f => f.Type == ClientItemType.File && folders.All(d => !f.FullPath.StartsWith(d.FullPath)))
                        .Select(x => new TreeNode(x.Name))
                        .ToArray();

            if (!Program.Account.Client.ListingFailed)
            {
                lSelectiveSync.Nodes.Clear();

                // List directories first
                foreach (var d in folders)
                {
                    if (d.Name == "webint")
                    {
                        continue;
                    }

                    var parent = UIHelpers.ConstructNodeFrom(li, d);

                    lSelectiveSync.Nodes.Add(parent);
                }

                lSelectiveSync.Nodes.AddRange(files);

                EditNodeCheckboxes();
            }

            lSelectiveSync.ExpandAll();

            bRefresh.Enabled = true;
            this.Text        = _titleNormal;
        }
示例#2
0
        /// <summary>
        /// Get a remote list inside the current directory
        /// and display the results in tRemoteList.
        /// </summary>
        private async Task PopulateRemoteList()
        {
            tRemoteList.Nodes.Clear();

            Log.Write(l.Info, $"Listing from directory: {Program.Account.Client.WorkingDirectory}");

            var list = (_currentTab == AccountSetupTab.RemoteFolder)
                ? await Program.Account.Client.List(".", false)
                : await Program.Account.Client.ListRecursive(".", false);

            if (_currentTab == AccountSetupTab.RemoteFolder)
            {
                list = list.Where(x => x.Type == ClientItemType.Folder);

                var first   = new TreeNode("/");
                var current = first;

                foreach (var f in Program.Account.HomePath.Split('/'))
                {
                    if (string.IsNullOrWhiteSpace(f))
                    {
                        continue;
                    }

                    current.Nodes.Add(f);
                    current = current.FirstNode;
                }

                tRemoteList.AfterExpand -= tRemoteList_AfterExpand;
                tRemoteList.Nodes.Add(first);
                tRemoteList.ExpandAll();

                foreach (var c in list)
                {
                    var parentNode = new TreeNode(c.Name);
                    current.Nodes.Add(parentNode);

                    var childNode = new TreeNode(c.Name);
                    parentNode.Nodes.Add(childNode);
                }

                current.Expand();
                tFullRemotePath.Text     = Program.Account.HomePath;
                tRemoteList.AfterExpand += tRemoteList_AfterExpand;
            }
            else
            {
                foreach (var l in list)
                {
                    // convert to relative paths
                    l.FullPath = Program.Account.GetCommonPath(l.FullPath, false);
                }
                // get the first level folders
                var folders = list.Where(d => d.Type == ClientItemType.Folder && !d.FullPath.Contains("/"));

                // get the first level files
                var files = list
                            .Where(f => f.Type == ClientItemType.File && folders.All(d => !f.FullPath.StartsWith(d.FullPath)))
                            .Select(x => new TreeNode(x.Name))
                            .ToArray();

                // List directories first
                foreach (var d in folders)
                {
                    if (d.Name == "webint")
                    {
                        continue;
                    }

                    var parent = UIHelpers.ConstructNodeFrom(list.ToList(), d);

                    tRemoteList.Nodes.Add(parent);
                }

                tRemoteList.Nodes.AddRange(files);

                EditNodeCheckboxes();
                tRemoteList.CollapseAll();
            }
        }