Esempio n. 1
0
        /// <summary>
        /// Occurs when the <see cref="E:System.Windows.Forms.TreeView.NodeMouseClick"></see> event is fired
        /// -- that is, when a node in the tree view is clicked.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.TreeNodeMouseClickEventArgs"></see> that contains the event data.</param>
        protected override void OnNodeMouseClick(TreeNodeMouseClickEventArgs e)
        {
            // Are we dealing with a dropdown node?
            if (e.Node is OpenFOAMDropDownTreeNode <dynamic> )
            {
                m_CurrentOFDropDownNode = (OpenFOAMDropDownTreeNode <dynamic>)e.Node;

                // Need to add the node's ComboBox to the TreeView's list of controls for it to work
                Controls.Add(m_CurrentOFDropDownNode.ComboBox);

                // Set the bounds of the ComboBox, with a little adjustment to make it look right
                m_CurrentOFDropDownNode.ComboBox.SetBounds(
                    m_CurrentOFDropDownNode.Bounds.X - 1,
                    m_CurrentOFDropDownNode.Bounds.Y - 2,
                    m_CurrentOFDropDownNode.Bounds.Width + 25,
                    m_CurrentOFDropDownNode.Bounds.Height);

                // Listen to the SelectedValueChanged event of the node's ComboBox
                m_CurrentOFDropDownNode.ComboBox.SelectedValueChanged += new EventHandler(ComboBox_SelectedValueChanged);
                m_CurrentOFDropDownNode.ComboBox.DropDownClosed       += new EventHandler(ComboBox_DropDownClosed);

                // Now show the ComboBox
                m_CurrentOFDropDownNode.ComboBox.Show();
                m_CurrentOFDropDownNode.ComboBox.DroppedDown = true;
            }
            else if (e.Node is OpenFOAMTextBoxTreeNode <dynamic> )
            {
                if (m_CurrentOFTxtBoxTreeNode != (OpenFOAMTextBoxTreeNode <dynamic>)e.Node)
                {
                    HideTextBox();
                }

                m_CurrentOFTxtBoxTreeNode = (OpenFOAMTextBoxTreeNode <dynamic>)e.Node;

                Controls.Add(m_CurrentOFTxtBoxTreeNode.TxtBox);

                //Set location of the TextBox.
                m_CurrentOFTxtBoxTreeNode.TxtBox.SetBounds(
                    m_CurrentOFTxtBoxTreeNode.Bounds.X - 1,
                    m_CurrentOFTxtBoxTreeNode.Bounds.Y - 2,
                    m_CurrentOFTxtBoxTreeNode.Bounds.Width + 25,
                    m_CurrentOFTxtBoxTreeNode.Bounds.Height);

                //Listen to Click/Leave and TextChanged Event of the TextBox.
                m_CurrentOFTxtBoxTreeNode.TxtBox.TextChanged += new EventHandler(TextBox_TextChanged);
                m_CurrentOFTxtBoxTreeNode.TxtBox.Click       += new EventHandler(TextBox_Click);
                m_CurrentOFTxtBoxTreeNode.TxtBox.MouseLeave  += new EventHandler(TextBox_Leave);

                m_CurrentOFTxtBoxTreeNode.TxtBox.Show();
            }
            else
            {
                HideTextBox();
                HideComboBox();
            }
            base.OnNodeMouseClick(e);
        }
Esempio n. 2
0
 /// <summary>
 /// Method to hide the currently-selected node TextBox
 /// </summary>
 private void HideTextBox()
 {
     if (m_CurrentOFTxtBoxTreeNode != null)
     {
         TextBox_ChangeValue();
         m_ChangeValue = false;
         m_CurrentOFTxtBoxTreeNode.TxtBox.TextChanged -= TextBox_TextChanged;
         m_CurrentOFTxtBoxTreeNode.Text = m_CurrentOFTxtBoxTreeNode.TxtBox.Text;
         m_CurrentOFTxtBoxTreeNode.TxtBox.Hide();
         Controls.Remove(m_CurrentOFTxtBoxTreeNode.TxtBox);
         m_CurrentOFTxtBoxTreeNode = null;
     }
 }