private void uncheckAllLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { updateLocked = true; var nodes = new List <TreeNodeData>(); Action <TreeNode> helper = null; helper = n => { if (n.Checked) { nodes.Add(n.Tag as TreeNodeData); n.Checked = false; } foreach (TreeNode c in n.Nodes) { helper(c); } }; foreach (TreeNode c in treeView.Nodes) { helper(c); } evts.OnNodesChecked(nodes.Where(n => n != null), false); updateLocked = false; }
public override void AwakeFromNib() { base.AwakeFromNib(); Window.owner = this; collapseAllLinkLabel.StringValue = "collapse all"; collapseAllLinkLabel.LinkClicked = (s, e) => { foreach (var item in dataSource.Items) { treeView.CollapseItem(item, collapseChildren: true); } }; uncheckAllLinkLabel.StringValue = "uncheck all"; uncheckAllLinkLabel.LinkClicked = (s, e) => { var checkedNodes = dataSource.Items .SelectMany(i => i.Traverse()) .Where(n => n.Data.Checkable) .Where(n => evts.IsNodeChecked(n.Data)) .ToArray(); evts.OnNodesChecked(checkedNodes.Select(n => n.Data).ToArray(), false); foreach (var item in checkedNodes) { treeView.ReloadItem(item, reloadChildren: false); } }; treeView.Delegate = new TreeDelegate() { owner = this }; treeView.DataSource = dataSource; }