Revit.SDK.Samples.NewHostedSweep.CS.EdgeFetchForm.treeViewHost_MouseDown C# (CSharp) Method

treeViewHost_MouseDown() private method

Select or un-select the key-node if down the left mouse button in the area of check-box or label.
private treeViewHost_MouseDown ( object sender, MouseEventArgs e ) : void
sender object
e MouseEventArgs
return void
        private void treeViewHost_MouseDown(object sender, MouseEventArgs e)
        {
            TreeViewHitTestInfo hitInfo = treeViewHost.HitTest(e.Location);

            if(e.Button == MouseButtons.Left &&
                (hitInfo.Location == TreeViewHitTestLocations.StateImage ||
                hitInfo.Location == TreeViewHitTestLocations.Label))
            {
                // mouse down in area of state image or label.
                TreeNode node = hitInfo.Node;
                if(node.Nodes.Count > 0)
                    // cancel the expand or collapse of node which has children.
                    m_cancelExpandOrCollapse = true;

                // active the node.
                ActiveNode(node);

                // select or un-select the node.
                CheckState checkState = (CheckState)((node.StateImageIndex + 1) % 2);
                UpdateNodeCheckStatus(node, checkState);

                pictureBoxPreview.Refresh();
            }
        }