public TreeViewController(MultiselectTreeView treeView) { this.treeView = treeView; treeView.BeforeExpand += (s, e) => { if (updating) { return; } e.Cancel = true; OnExpand?.Invoke(Map(e.Node)); }; treeView.BeforeCollapse += (s, e) => { if (updating) { return; } e.Cancel = true; OnCollapse?.Invoke(Map(e.Node)); }; treeView.BeforeMultiSelect += (s, e) => { if (updating) { return; } e.Cancel = true; OnSelect?.Invoke(e.Nodes.OfType <ViewNode>().Select(n => n.Node).ToArray()); }; }
public void MultiselectTreeViewRegular() { using (var treeView = new MultiselectTreeView()) { treeView.HTMLStyle = UnitTestInitializeWin.HTMLStyle; Assert.AreEqual(0, treeView.SelectedTreeNode.Count); var treeNode = new TreeNode("Test") { Tag = "test" }; treeView.Nodes.Add(treeNode); var treeNode2 = new TreeNode("Test2") { Tag = "test2" }; treeNode.Nodes.Add(treeNode2); var treeNode3 = new TreeNode("Test3") { Tag = "test3" }; treeNode.Nodes.Add(treeNode3); var treeNode3a = new TreeNode("Test3a") { Tag = "test3" }; treeNode3.Nodes.Add(treeNode3a); var treeNode3b = new TreeNode("Test3b") { Tag = "test3" }; treeNode3.Nodes.Add(treeNode3b); var firedAfter = false; var firedBefore = false; treeView.AfterSelect += (s, args) => { firedAfter = true; }; treeView.BeforeSelect += (s, args) => { firedBefore = true; }; UnitTestWinFormHelper.ShowControl(treeView, .2, (control, form) => { if (!(control is MultiselectTreeView text)) { return; } text.PressKey(Keys.Control | Keys.A); text.PressKey(Keys.Control | Keys.C); Application.DoEvents(); treeView.SelectedNode = treeNode2; treeView.SelectAll(); Application.DoEvents(); var result = treeView.SelectedToClipboard(); Assert.IsTrue(result.Contains(treeNode.Text)); Assert.IsTrue(result.Contains(treeNode2.Text)); Assert.IsTrue(result.Contains(treeNode3.Text)); });
Windows.Reactive.ITreeViewController <Node> Windows.Reactive.IReactive.CreateTreeViewController <Node>(MultiselectTreeView treeView) { return(new Windows.Reactive.TreeViewController <Node>(treeView)); }