private void TreeTables_DragDrop(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.Copy;
            TreeNode NewNode;

            if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false))
            {
                Point    pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y));
                TreeNode DestinationNode = ((TreeView)sender).GetNodeAt(pt);
                if (DestinationNode == null)
                {
                    MessageBox.Show("Please drag to a node!");
                    return;
                }
                NewNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");
                if (DestinationNode.TreeView != NewNode.TreeView && NewNode.Tag != null)
                {
                    DragDropFromTemplateToTableTree(NewNode, DestinationNode);
                }
                else if (DestinationNode.TreeView == NewNode.TreeView)
                {
                    DragDropFromTableToTableTree(NewNode, DestinationNode);
                }
            }
            TreeTables.ExpandAll();
        }
 private void LoadProjectFile()
 {
     //Laod it
     mnuProject.ToolTipText = _projPath;
     this._rgProject        = RgProject.Load(_projPath);
     if (this._rgProject != null && _rgProject.Alltables != null)
     {
         LoadTablesToTree(_rgProject.Alltables.Tables);
         //add templates
         foreach (RgMapping rgMaps in _rgProject.RgMappings)
         {
             TreeNode tn = TreeTables.Nodes.Find(rgMaps.TableName, false).FirstOrDefault();
             if (tn != null)
             {
                 foreach (String template in rgMaps.TemplateRelativePaths)
                 {
                     var templateName = FileHelper.GetTemplateName(template);
                     AddTemplateNode(tn, new Template {
                         TemplatePath = template, TemplateName = templateName
                     });
                 }
             }
         }
         TreeTables.ExpandAll();
     }
     mnuOutput.ToolTipText = _rgProject.SolutionRootFolder;
 }
        private void TreeTemplates_DragDrop(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.Copy;

            if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false))
            {
                Point pt      = ((TreeView)sender).PointToClient(new Point(e.X, e.Y));
                var   newNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");
                RemoveTemplateNode(newNode);
            }
            TreeTables.ExpandAll();
        }
        private void LoadTablesToTree(List <Table> tables)
        {
            TreeNode tn;

            TreeTables.Nodes.Clear();
            foreach (var table in tables)
            {
                TreeNode tnn = TreeTables.Nodes.Add(table.Name, table.Name);
                tnn.Tag         = table;
                tnn.ToolTipText = table.Name;
            }
            TreeTables.ExpandAll();
        }