Esempio n. 1
0
        private void TreeViewTables_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            if (!GetMainHome().GetUserControl <Editor>().GetQueryExecutor().IsAlive())
            {
                switch ((e.Node as MyTreeNode).Type)
                {
                case NodeType.Table:
                {
                    List <string>     fields     = DbDataHelper.getTableFields(GetSqlConnection(), e.Node.Text);
                    List <string>     fieldsInfo = DbDataHelper.getTableInfo(GetSqlConnection(), e.Node.Text);
                    List <MyTreeNode> nodes      = new List <MyTreeNode>();
                    foreach (string f in fields)
                    {
                        nodes.Add(new MyTreeNode()
                            {
                                Text = f, ImageIndex = 1, SelectedImageIndex = 1
                            });
                    }
                    foreach (string f in fieldsInfo)
                    {
                        nodes.Add(new MyTreeNode()
                            {
                                Text = f, ImageIndex = 2, SelectedImageIndex = 2
                            });
                    }
                    var triggerParentNode = new MyTreeNode()
                    {
                        Text = "Triggers", ImageIndex = 3, SelectedImageIndex = 3, Type = NodeType.ParentTrigger
                    };
                    triggerParentNode.Nodes.Add(getDummy());
                    nodes.Add(triggerParentNode);
                    this.setTableFields(nodes, e.Node as MyTreeNode);
                }
                break;

                case NodeType.ParentTrigger:
                {
                    List <string>     triggers = DbDataHelper.getTableTriggers(GetSqlConnection(), e.Node.Parent.Text);
                    List <MyTreeNode> nodes    = new List <MyTreeNode>();
                    foreach (string t in triggers)
                    {
                        nodes.Add(new MyTreeNode()
                            {
                                Text = t, Type = NodeType.Trigger, ImageIndex = 3, SelectedImageIndex = 3
                            });
                    }
                    this.setTableFields(nodes, e.Node as MyTreeNode);
                }
                break;
                }
            }
        }
Esempio n. 2
0
        private void treeViewTables_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                Point      p    = new Point(e.X, e.Y);
                MyTreeNode node = treeViewTables.GetNodeAt(p) as MyTreeNode;
                if (node != null)
                {
                    switch (node.Type)
                    {
                    case NodeType.Table:
                    {
                        treeViewTables.SelectedNode = node;
                        TableTableMenu.Show(this, this.PointToClient(treeViewTables.PointToScreen(p)));
                    }
                    break;

                    case NodeType.Trigger:
                    {
                        treeViewTables.SelectedNode = node;
                        TableTriggersMenu.Show(this, this.PointToClient(treeViewTables.PointToScreen(p)));
                    }
                    break;
                    }
                }
            }
            else if (e.Button == MouseButtons.Left && !GetMainHome().GetUserControl <Editor>().GetQueryExecutor().IsAlive())
            {
                MyTreeNode node = treeViewTables.GetNodeAt(new Point(e.X, e.Y)) as MyTreeNode;
                if (node != null && node.Type == NodeType.Table && e.X > node.Bounds.Left - 15)
                {
                    GetMainHome().GetUserControl <TableView>().setTableInfo(node.Text, DbDataHelper.getTableFields(GetSqlConnection(), node.Text)
                                                                            , DbDataHelper.getTableInfo(GetSqlConnection(), node.Text));
                }
            }
        }