private static void SortFilesBeforeFolders(TreeNode root) { foreach (var node in TreeUtils.Flatten(root, (t) => t.Nodes.AsEnumerable()).ToList()) { var nodes = node.Nodes.AsEnumerable().ToList(); var sorted = nodes.OrderBy(n => (ShowSubscriptionsForm.GetPath(n).EndsWith("/") ? "b " : "a ") + n.Name); node.Nodes.Clear(); node.Nodes.AddRange(sorted.ToArray()); } }
private void ShowSubscription(object s, CommandItemEventArgs e) { var connection = e.Context.Application.Connection; if (vaultCom.connection == null) { vaultCom.InitializeFromConnection(application.Connection); } string vaultName = connection.Vault, vaultUri = connection.Server; SynchronizationTree tree = new SynchronizationTree(vaultName, vaultUri); try { tree = SynchronizationTree.ReadTree(vaultName, vaultUri); if (tree.IsEmpty()) { var result = MessageBox.Show("No subscriptions found for this vault. Try harder?", "Try harder?", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { tree = SynchronizationTree.ReadTree(vaultName, vaultUri, tryHarder: true); } } } catch (Exception ex) { var result = MessageBox.Show("[ERROR] " + ex.Message + "\r\nDo you want to continue?", "Error", MessageBoxButtons.OKCancel); if (result == DialogResult.Cancel) { return; } } ShowSubscriptionsForm form = new ShowSubscriptionsForm(tree, StartSyncThread, vaultCom); form.ShowDialog(); }