Beispiel #1
0
        internal PointF ConvertWidgetCenterToWin32Coord(Region widget)
        {
            var ret = new PointF();
            var gameFullScreenFrame = UIObject.GetUIObjectByName <Frame>(this, "GlueParent") ??
                                      UIObject.GetUIObjectByName <Frame>(this, "UIParent");

            if (gameFullScreenFrame == null)
            {
                return(ret);
            }
            var gameFullScreenFrameRect = gameFullScreenFrame.Rect;
            var widgetCenter            = widget.Center;
            var windowInfo        = Utility.GetWindowInfo(GameProcess.MainWindowHandle);
            var leftBorderWidth   = windowInfo.rcClient.Left - windowInfo.rcWindow.Left;
            var bottomBorderWidth = windowInfo.rcWindow.Bottom - windowInfo.rcClient.Bottom;
            var winClientWidth    = windowInfo.rcClient.Right - windowInfo.rcClient.Left;
            var winClientHeight   = windowInfo.rcClient.Bottom - windowInfo.rcClient.Top;

            // gameFullScreenFrameRect sometimes doesn't fill entire screen.
            // When that happens, it's centered on the screen, and we need to add the gaps that it doesn't occupy.
            // Left gap is simply gameFullScreenFrameRect.Left, and we assume the right side gap is same width because frame is centered, so we just multiply left gap by 2.

            var xCo = winClientWidth / (gameFullScreenFrameRect.Width + gameFullScreenFrameRect.Left * 2);
            var yCo = winClientHeight / gameFullScreenFrameRect.Height + gameFullScreenFrameRect.Top * 2;

            ret.X = widgetCenter.X * xCo + leftBorderWidth;
            ret.Y = widgetCenter.Y * yCo + bottomBorderWidth;
            // flip the Y coord around because in WoW's UI coord space the Y goes up where as in windows it goes down.
            ret.Y = windowInfo.rcWindow.Bottom - windowInfo.rcWindow.Top - ret.Y;
            return(ret);
        }
Beispiel #2
0
        internal PointF ConvertWidgetCenterToWin32Coord(Region widget)
        {
            var ret = new PointF();
            var gameFullScreenFrame = UIObject.GetUIObjectByName <Frame>(this, "GlueParent") ?? UIObject.GetUIObjectByName <Frame>(this, "UIParent");

            if (gameFullScreenFrame == null)
            {
                return(ret);
            }
            var gameFullScreenFrameRect = gameFullScreenFrame.Rect;
            var widgetCenter            = widget.Center;
            var windowInfo        = Utility.GetWindowInfo(GameProcess.MainWindowHandle);
            var leftBorderWidth   = windowInfo.rcClient.Left - windowInfo.rcWindow.Left;
            var bottomBorderWidth = windowInfo.rcWindow.Bottom - windowInfo.rcClient.Bottom;
            var winClientWidth    = windowInfo.rcClient.Right - windowInfo.rcClient.Left;
            var winClientHeight   = windowInfo.rcClient.Bottom - windowInfo.rcClient.Top;
            var xCo = winClientWidth / gameFullScreenFrameRect.Width;
            var yCo = winClientHeight / gameFullScreenFrameRect.Height;

            ret.X = widgetCenter.X * xCo + leftBorderWidth;
            ret.Y = widgetCenter.Y * yCo + bottomBorderWidth;
            // flip the Y coord around because in WoW's UI coord space the Y goes up where as in windows it goes down.
            ret.Y = windowInfo.rcWindow.Bottom - windowInfo.rcWindow.Top - ret.Y;
            return(ret);
        }
Beispiel #3
0
        internal PointF ConvertWidgetCenterToWin32Coord(Region widget)
        {
            var ret = new PointF();
            var gameFullScreenFrame = UIObject.GetUIObjectByName<Frame>(this, "GlueParent") ?? UIObject.GetUIObjectByName<Frame>(this, "UIParent");
            if (gameFullScreenFrame == null)
                return ret;
            var gameFullScreenFrameRect = gameFullScreenFrame.Rect;
            var widgetCenter = widget.Center;
            var windowInfo = Utility.GetWindowInfo(GameProcess.MainWindowHandle);
            var leftBorderWidth = windowInfo.rcClient.Left - windowInfo.rcWindow.Left;
            var bottomBorderWidth = windowInfo.rcWindow.Bottom - windowInfo.rcClient.Bottom;
            var winClientWidth = windowInfo.rcClient.Right - windowInfo.rcClient.Left;
            var winClientHeight = windowInfo.rcClient.Bottom - windowInfo.rcClient.Top;
            var xCo = winClientWidth / gameFullScreenFrameRect.Width;
            var yCo = winClientHeight / gameFullScreenFrameRect.Height;

            ret.X = widgetCenter.X * xCo + leftBorderWidth;
            ret.Y = widgetCenter.Y * yCo + bottomBorderWidth;
            // flip the Y coord around because in WoW's UI coord space the Y goes up where as in windows it goes down.
            ret.Y = windowInfo.rcWindow.Bottom - windowInfo.rcWindow.Top - ret.Y;
            return ret;
        }