Пример #1
0
        protected override void OnMouseMoved(MouseMovedEventArgs args)
        {
            base.OnMouseMoved(args);
            if (State.HasFlag(DockBoxState.InProcess))
            {
                if (State.HasFlag(DockBoxState.SizeLR))
                {
                    stateSize.Location = new Point(args.Position.X, stateSize.Y);
                }
                else if (State.HasFlag(DockBoxState.SizeUD))
                {
                    stateSize.Location = new Point(stateSize.X, args.Position.Y);
                }
                else if (State.HasFlag(DockBoxState.Move))
                {
                    var htest = DockHitTest(args.X, args.Y, 50);
                    if (htest.Item != null)
                    {
                        stateMove = Rectangle.Zero;
                        if (htest.Align == LayoutAlignType.None)
                        {
                            stateMove = htest.Item.Bound.Inflate(-40, -40);
                        }
                        else
                        {
                            stateMove = new Rectangle(htest.AlignBound.X + 10, htest.AlignBound.Y + 10, htest.AlignBound.Width - 20, htest.AlignBound.Height - 20);
                        }
                    }
                }
                QueueDraw();
            }
            else
            {
                var test = DockHitTest(args.X, args.Y, 1);
                if (test.Item == null)
                {
                    hitLeft   = DockHitTest(args.X - 10, args.Y);
                    hitRight  = DockHitTest(args.X + 10, args.Y);
                    hitTop    = DockHitTest(args.X, args.Y - 10);
                    hitBottom = DockHitTest(args.X, args.Y + 10);

                    if (hitLeft.Item != null && hitRight.Item != null && hitLeft.Item != hitRight.Item)
                    {
                        State = DockBoxState.SizeLR;
                    }
                    else if (hitTop.Item != null && hitBottom.Item != null && hitTop.Item != hitBottom.Item)
                    {
                        State = DockBoxState.SizeUD;
                    }
                    else
                    {
                        State = DockBoxState.Default;
                    }
                }
                else
                {
                    State = DockBoxState.Default;
                }
            }
        }
Пример #2
0
        public DockBoxHitTest DockHitTest(double x, double y, double size)
        {
            var htest = new DockBoxHitTest();

            foreach (DockItem item in items.GetVisibleItems())
            {
                if (item.Bound.Contains(x, y))
                {
                    htest.Item  = item;
                    htest.Bound = item.Bound;
                    break;
                }
            }
            if (htest.Item != null)
            {
                var rect = Rectangle.Zero;
                htest.Align      = GuiService.GetAlignRect(htest.Item.Bound, size, x, y, ref rect);
                htest.AlignBound = rect;
            }
            return(htest);
        }