示例#1
0
        public override void DragAndDrop_Hover(Package p, int x, int y)
        {
            Point localPos = CanvasPosToLocal(new Point(x, y));

            ControlBase droppedOn = GetControlAt(localPos.X, localPos.Y);

            if (droppedOn != null && droppedOn != this)
            {
                Point dropPos = droppedOn.CanvasPosToLocal(new Point(x, y));
                m_TabDragControl.SetBounds(new Rectangle(0, 0, 3, Height));
                m_TabDragControl.BringToFront();
                m_TabDragControl.SetPosition(droppedOn.X - 1, 0);

                if (dropPos.X > droppedOn.Width / 2)
                {
                    m_TabDragControl.MoveBy(droppedOn.Width - 1, 0);
                }
                m_TabDragControl.Dock = Dock.None;
            }
            else
            {
                m_TabDragControl.Dock = Dock.Left;
                m_TabDragControl.BringToFront();
            }
        }
        public override bool DragAndDrop_HandleDrop(Package p, int x, int y)
        {
            Point LocalPos = CanvasPosToLocal(new Point(x, y));

            TabButton  button     = DragAndDrop.SourceControl as TabButton;
            TabControl tabControl = Parent as TabControl;

            if (tabControl != null && button != null)
            {
                if (button.TabControl != tabControl)
                {
                    // We've moved tab controls!
                    tabControl.AddPage(button);
                }
            }

            ControlBase droppedOn = GetControlAt(LocalPos.X, LocalPos.Y);

            if (droppedOn != null)
            {
                Point dropPos = droppedOn.CanvasPosToLocal(new Point(x, y));
                DragAndDrop.SourceControl.BringNextToControl(droppedOn, dropPos.X > droppedOn.Width / 2);
            }
            else
            {
                DragAndDrop.SourceControl.BringToFront();
            }
            return(true);
        }
示例#3
0
        /// <summary>
        /// Converts canvas coordinates to local coordinates.
        /// </summary>
        /// <param name="pnt">Canvas coordinates.</param>
        /// <returns>Local coordinates.</returns>
        public virtual Point CanvasPosToLocal(Point pnt)
        {
            if (m_Parent != null)
            {
                int x = pnt.X - X;
                int y = pnt.Y - Y;

                // If our parent is a container and we're a child of it
                // add its offset onto us.
                //
                var container = m_Parent as Container;
                if (container != null && container.Children.Contains(this))
                {
                    x -= container.PanelBounds.X;
                    y -= container.PanelBounds.Y;
                }


                return(m_Parent.CanvasPosToLocal(new Point(x, y)));
            }

            return(pnt);
        }