/// <summary>
 ///     The domain tree view_ before select.
 /// </summary>
 /// <param name="sender">
 ///     The sender.
 /// </param>
 /// <param name="e">
 ///     The e.
 /// </param>
 private void DomainTreeView_BeforeSelect(object sender, TreeViewCancelEventArgs e)
 {
     if (CurrentlySelectedControl != null && CurrentlySelectedControl.Validate().Count > 0)
     {
         e.Cancel = true;
     }
 }
        private void DomainTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (CurrentlySelectedControl == null ||
                (CurrentlySelectedControl != null && CurrentlySelectedControl.Validate().Count == 0))
            {
                if (e.Node.Tag is Table)
                {
                    var table = e.Node.Tag as Table;
                    modelControl.DataSource  = table;
                    CurrentlySelectedControl = modelControl;
                    modelControl.BringToFront();
                }
                else if (e.Node.Tag is Column)
                {
                    var column = e.Node.Tag as Column;
                    fieldControl.DataSource  = column;
                    CurrentlySelectedControl = fieldControl;
                    fieldControl.BringToFront();
                }
                else if (e.Node.Tag is Relationship)
                {
                    var relationship = e.Node.Tag as Relationship;
                    relationshipControl.Domain     = DataSource;
                    relationshipControl.DataSource = relationship;
                    CurrentlySelectedControl       = relationshipControl;
                    relationshipControl.BringToFront();
                }
                else if (e.Node.Tag is Index)
                {
                    var index = e.Node.Tag as Index;
                    indexUserControl.DataSource = index;
                    CurrentlySelectedControl    = indexUserControl;
                    indexUserControl.BringToFront();
                }
                else if (e.Node.Tag == null)
                {
                    defaultModelControl.BringToFront();

                    if (e.Node.Text.ToLower() == "indexes" && ScaffoldConfig.ReturnSourceType(DataSource.SourceTypeId).GetType().Name == "EdmxSourceType")
                    {
                        SelectedTable = e.Node.Parent.Tag as Table;
                        btnAddIndex.BringToFront();
                        lblAddIndex.BringToFront();
                    }
                    else
                    {
                        SelectedTable = null;
                        btnAddIndex.SendToBack();
                        lblAddIndex.SendToBack();
                    }
                }
            }
        }