public DirectoryDiffControl() { this.InitializeComponent(); this.activeTree = this.TreeA; this.TreeA.ImageList = this.Images; this.TreeB.ImageList = this.Images; this.UpdateButtons(); this.UpdateColors(); DiffOptions.OptionsChanged += this.DiffOptionsChanged; }
private void TreeNode_SelectChanged(object sender, TreeViewEventArgs e) { DirectoryDiffEntry?entry = DirectoryDiffTreeView.GetEntryForNode(e.Node); if (entry != null) { GetNodes(entry, out TreeNode? nodeA, out TreeNode? nodeB); if (nodeA != null && nodeB != null) { this.TreeA.SelectedNode = nodeA; this.TreeB.SelectedNode = nodeB; } } this.UpdateButtons(); }
private void SyncTreeViewScrollPositions(DirectoryDiffTreeView source) { DirectoryDiffEntry?entry = DirectoryDiffTreeView.GetEntryForNode(source.TopNode); if (entry != null) { GetNodes(entry, out TreeNode? nodeA, out TreeNode? nodeB); if (nodeA != null && nodeB != null) { this.TreeA.TopNode = nodeA; this.TreeB.TopNode = nodeB; } } // An alternate but VERY flickery way to do this is: // int sourcePos = Windows.GetScrollPos(source, false); // target.BeginUpdate(); // Windows.SetScrollPos(target, false, sourcePos); // target.EndUpdate(); }
private void TreeNode_StateChange(object sender, TreeViewEventArgs e) { DirectoryDiffEntry?entry = DirectoryDiffTreeView.GetEntryForNode(e.Node); if (entry != null) { GetNodes(entry, out TreeNode? nodeA, out TreeNode? nodeB); if (nodeA != null && nodeB != null) { if (e.Action == TreeViewAction.Collapse) { // Although the Docs say that Collapse() isn't recursive, // it actually is. Since clicking the +/- isn't recursive // we have to simulate that by calling Collapse even on the // node that fired the event. if (nodeA.IsExpanded || e.Node == nodeA) { nodeA.Collapse(); } if (nodeB.IsExpanded || e.Node == nodeB) { nodeB.Collapse(); } } else if (e.Action == TreeViewAction.Expand) { if (!nodeA.IsExpanded || e.Node == nodeA) { nodeA.Expand(); } if (!nodeB.IsExpanded || e.Node == nodeB) { nodeB.Expand(); } } } } }
private void TreeView_Enter(object?sender, EventArgs e) { this.activeTree = (DirectoryDiffTreeView)sender !; this.UpdateButtons(); }