コード例 #1
0
ファイル: DropDownBox.cs プロジェクト: zcf7822/monodevelop
        void PositionListWindow()
        {
            if (window == null)
            {
                return;
            }
            int ox, oy;

            ParentWindow.GetOrigin(out ox, out oy);
            int dx = ox + this.Allocation.X;
            int dy = oy + this.Allocation.Bottom;

            window.WidthRequest = Allocation.Width;
            int width, height;

            window.GetSizeRequest(out width, out height);
            Xwt.Rectangle geometry = DesktopService.GetUsableMonitorGeometry(Screen.Number, Screen.GetMonitorAtPoint(dx, dy));

            if (dy + height > geometry.Bottom)
            {
                dy = oy + this.Allocation.Y - height;
            }
            if (dx + width > geometry.Right)
            {
                dx = (int)geometry.Right - width;
            }

            window.Move(dx, dy);
            window.GetSizeRequest(out width, out height);
            window.GrabFocus();
            window.FocusOutEvent += delegate {
                DestroyWindow();
            };
            window.ShowAll();
        }