private void ReceiveResoources() { foreach (TreeNode treeNode in _resourceTreeView.Nodes) { NodeCheckState currState = _resourceTreeView.GetNodeCheckState(treeNode); if (currState == NodeCheckState.Checked) { ResourceUnpack resourceUnpack = (ResourceUnpack)treeNode.Tag; resourceUnpack.AcceptReceiving(); _mail.AddLink("ResourceAttachment", resourceUnpack.Resource); foreach (TreeNode linkTreeNode in treeNode.Nodes) { foreach (TreeNode linkedResourceNode in linkTreeNode.Nodes) { currState = _resourceTreeView.GetNodeCheckState(linkedResourceNode); if (currState == NodeCheckState.Checked) { resourceUnpack = (ResourceUnpack)linkedResourceNode.Tag; resourceUnpack.AcceptReceiving(); } } } } } }
private void SetNodeCheckState(TreeNode treeNode, NodeCheckState checkState) { SerializableTag linkedResourceNodeTag = (SerializableTag)treeNode.Tag; linkedResourceNodeTag.AcceptSending = (checkState != NodeCheckState.Unchecked); _resourceTreeView.SetNodeCheckState(treeNode, checkState); }
public void SetNodeCheckStateFromCollection(TreeNode node) { IResource resourceTag = (IResource)node.Tag; if (resourceTag != null) { HashMap.Entry checkEntry = _checkStates.GetEntry(resourceTag.Id); NodeCheckState check = NodeCheckState.Checked; if (checkEntry != null) { check = (NodeCheckState)checkEntry.Value; } else { if (!Folder.IsIgnoreImport(resourceTag)) { check = NodeCheckState.Checked; } else { check = NodeCheckState.Unchecked; } } SetNodeCheckState(node, check); } }
/** * Changes the checked state of a node and fires the AfterThreeStateCheck event. */ private void ChangeNodeCheckState(TreeNode node, NodeCheckState state) { SetNodeCheckState(node, state); if (AfterThreeStateCheck != null) { AfterThreeStateCheck(this, new ThreeStateCheckEventArgs(node, state)); } }
private void SetCheckStateRecursively(TreeNodeCollection nodes, NodeCheckState parentCheckState) { foreach (TreeNode node in nodes) { NodeCheckState checkState = GetNodeCheckState(node); if (checkState == NodeCheckState.Unchecked || checkState == NodeCheckState.Checked) { SetNodeCheckState(node, parentCheckState); } SetCheckStateRecursively(node.Nodes, parentCheckState); } }
private List <TreeNode> CheckedNodes(TreeNodeCollection nodes) { List <TreeNode> checks = new List <TreeNode>(); foreach (TreeNode node in nodes) { NodeCheckState checkState = _categoryTree.GetNodeCheckState(node); if (checkState == NodeCheckState.Checked) { checks.Add(node); } } return(checks); }
public void SetNodeCheckState(TreeNode node, NodeCheckState checkState) { if (node.TreeView != this) { return; } TVITEM item = new TVITEM(); item.mask = TreeViewItemFlags.STATE | TreeViewItemFlags.HANDLE; item.stateMask = 0xF000; item.state = (int)checkState << 12; item.hItem = node.Handle; Win32Declarations.SendMessage(Handle, TreeViewMessage.TVM_SETITEMA, 0, ref item); }
private void AfterThreeStateCheck(object sender, JetBrains.UI.Components.CustomTreeView.ThreeStateCheckEventArgs e) { SerializableTag nodeTag = (SerializableTag)e.Node.Tag; if (nodeTag.TreeNodeType == SerializableTag.Type.Link) { NodeCheckState curState = _resourceTreeView.GetNodeCheckState(e.Node); nodeTag.AcceptSending = (curState == NodeCheckState.Checked); foreach (TreeNode treeNode in e.Node.Nodes) { SetNodeCheckState(treeNode, curState); } } else if (nodeTag.TreeNodeType == SerializableTag.Type.LinkedResource) { nodeTag.AcceptSending = (_resourceTreeView.GetNodeCheckState(e.Node)) == NodeCheckState.Checked; TreeNode parentNode = e.Node.Parent; bool thereChecked = false; bool thereUnchecked = false; foreach (TreeNode treeNode in parentNode.Nodes) { NodeCheckState curState = _resourceTreeView.GetNodeCheckState(treeNode); if (curState == NodeCheckState.Checked) { thereChecked = true; } else if (curState == NodeCheckState.Unchecked) { thereUnchecked = true; } if (thereChecked && thereUnchecked) { SetNodeCheckState(parentNode, NodeCheckState.Grayed); break; } } if (thereChecked && !thereUnchecked) { SetNodeCheckState(parentNode, NodeCheckState.Checked); } if (!thereChecked && thereUnchecked) { SetNodeCheckState(parentNode, NodeCheckState.Unchecked); } } _fileLength.Text = _resourceSerializer.GenerateXML(ResourceSerializer.ResourceTransferFileName).ToString(); }
private void CollectCheckStates(TreeNodeCollection nodes) { foreach (TreeNode node in nodes) { IResource resource = (IResource)node.Tag; if (resource != null) { NodeCheckState checkState = GetNodeCheckState(node); if (resource.Id != -1 && (checkState == NodeCheckState.Checked || checkState == NodeCheckState.Unchecked)) { _checkStates.Add(resource.Id, checkState); } } CollectCheckStates(node.Nodes); } }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (myThreeStateCheckboxes) { bool doubleClick = false; if (myLastMouseUpPoint.X != -1) { if (Math.Abs(e.X - myLastMouseUpPoint.X) <= SystemInformation.DoubleClickSize.Width && Math.Abs(e.Y - myLastMouseUpPoint.Y) <= SystemInformation.DoubleClickSize.Height) { TimeSpan ts = DateTime.Now - myLastMouseUpTime; if (ts.TotalMilliseconds <= SystemInformation.DoubleClickTime) { doubleClick = true; } } } myLastMouseUpPoint = new Point(e.X, e.Y); myLastMouseUpTime = DateTime.Now; if (doubleClick) { return; } TVHITTESTINFO hti = new TVHITTESTINFO(); hti.pt = new POINT(e.X, e.Y); Win32Declarations.SendMessage(Handle, TreeViewMessage.TVM_HITTEST, 0, ref hti); if ((hti.flags & TreeViewHitTestFlags.ONITEMSTATEICON) != 0) { TreeNode node = TreeNode.FromHandle(this, hti.hItem); NodeCheckState state = GetNodeCheckState(node); if (state == NodeCheckState.Checked || state == NodeCheckState.Grayed) { state = NodeCheckState.Unchecked; } else { state = NodeCheckState.Checked; } ChangeNodeCheckState(node, state); } } }
public ThreeStateCheckEventArgs(TreeNode node, NodeCheckState checkState) { myNode = node; myCheckState = checkState; }
private void _treeView_AfterThreeStateCheck(object sender, ThreeStateCheckEventArgs e) { NodeCheckState checkState = GetNodeCheckState(e.Node); SetCheckStateRecursively(e.Node.Nodes, checkState); }