Example #1
0
        private void TemplateTree_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
        {
            Point point = TemplateTree.PointToClient(new Point(e.X, e.Y));

            DragHelper.ImageList_DragEnter(TemplateTree.Handle, point.X, point.Y);
            e.Effect = DragDropEffects.Move;
        }
Example #2
0
        void TemplateTree_DragOver(object sender, DragEventArgs e)
        {
            Point point = TemplateTree.PointToClient(new Point(e.X, e.Y));

            DragHelper.ImageList_DragMove(point.X, point.Y);
            e.Effect = DragDropEffects.Move;
        }
Example #3
0
        private void TemplateTree_MouseUp(object sender, MouseEventArgs e)
        {
            if (Yqun.Common.ContextCache.ApplicationContext.Current.IsAdministrator)
            {
                if (e.Button == MouseButtons.Right)
                {
                    Point    pt   = TemplateTree.PointToClient(Cursor.Position);
                    TreeNode Node = TemplateTree.HitTest(pt).Node;
                    TemplateTree.SelectedNode = Node;

                    ModelContextMenu.Show(TemplateTree, pt);
                }
            }
        }
Example #4
0
        void TemplateTree_ItemDrag(object sender, ItemDragEventArgs e)
        {
            TreeNode Node     = e.Item as TreeNode;
            Boolean  IsModule = Convert.ToBoolean(Node.Tag);

            if (IsModule)
            {
                dragNode = e.Item as TreeNode;
                TemplateTree.SelectedNode = dragNode;

                int imageWidth = dragNode.Bounds.Size.Width + TemplateTree.Indent;

                imageListDrag.Images.Clear();
                imageListDrag.ImageSize = new Size(imageWidth > 255 ? 255 : imageWidth, dragNode.Bounds.Height);

                Bitmap   bmp = new Bitmap(dragNode.Bounds.Width + TemplateTree.Indent, dragNode.Bounds.Height);
                Graphics gfx = Graphics.FromImage(bmp);
                gfx.DrawImage(imageList1.Images[dragNode.ImageIndex], 0, 0);
                gfx.DrawString(dragNode.Text, TemplateTree.Font,
                               new SolidBrush(TemplateTree.ForeColor),
                               (float)TemplateTree.Indent, 1.0f);

                imageListDrag.Images.Add(bmp);

                Point p = TemplateTree.PointToClient(Control.MousePosition);

                int dx = p.X + TemplateTree.Indent - dragNode.Bounds.Left;
                int dy = p.Y - dragNode.Bounds.Top;

                if (DragHelper.ImageList_BeginDrag(imageListDrag.Handle, 0, dx, dy))
                {
                    TemplateTree.DoDragDrop(bmp, DragDropEffects.Move);
                    DragHelper.ImageList_EndDrag();
                }
            }
            else
            {
                return;
            }
        }