public void UpdatePosition()
        {
            if (!User32.IsForegroundWindow("Hearthstone") && !_needToRefresh)
            {
                _needToRefresh = true;
            }
            else if (_needToRefresh && User32.IsForegroundWindow("Hearthstone"))
            {
                _needToRefresh = false;
                Update(true);
            }

            //hide the overlay depenting on options
            ShowOverlay(!(
                            (_config.HideInBackground && !User32.IsForegroundWindow("Hearthstone")) ||
                            (_config.HideInMenu && _hearthstone.IsInMenu) ||
                            _config.HideOverlay));

            var hsRect = new User32.Rect();

            User32.GetWindowRect(User32.FindWindow(null, "Hearthstone"), ref hsRect);

            //hs window has height 0 if it just launched, screwing things up if the tracker is started before hs is.
            //this prevents that from happening.
            if (hsRect.bottom - hsRect.top == 0)
            {
                return;
            }

            SetRect(hsRect.top, hsRect.left, hsRect.right - hsRect.left, hsRect.bottom - hsRect.top);
            ReSizePosLists();
        }
Ejemplo n.º 2
0
        public static Bitmap CaptureWindow(IntPtr wndHandle, Point point, int width, int height)
        {
            User32.Rect windowRect;
            User32.GetWindowRect(wndHandle, out windowRect);
            var windowWidth  = windowRect.right - windowRect.left;
            var windowHeight = windowRect.bottom - windowRect.top;
            var bmp          = new Bitmap(windowWidth, windowHeight, PixelFormat.Format32bppArgb);

            using (var graphics = Graphics.FromImage(bmp))
            {
                var hdc = graphics.GetHdc();

                try
                {
                    User32.PrintWindow(wndHandle, hdc, 0);
                }
                finally
                {
                    graphics.ReleaseHdc(hdc);
                }
            }
            var cRect = new User32.Rect();

            User32.GetClientRect(wndHandle, ref cRect);
            var cWidth        = cRect.right - cRect.left;
            var cHeight       = cRect.bottom - cRect.top;
            var captionHeight = windowHeight - cHeight > 0 ? SystemInformation.CaptionHeight : 0;

            return(bmp.Clone(new Rectangle((windowWidth - cWidth) / 2 + point.X,
                                           (windowHeight - cHeight - captionHeight) / 2 + captionHeight + point.Y,
                                           width, height), PixelFormat.Format32bppArgb));
        }
Ejemplo n.º 3
0
        public void UpdatePosition()
        {
            //hide the overlay depenting on options
            EnableCanvas(!(
                             (_config.HideInBackground && !User32.IsForegroundWindow("Hearthstone")) ||
                             (_config.HideInMenu && _hearthstone.IsInMenu) ||
                             _config.HideOverlay));

            var hsRect = new User32.Rect();

            User32.GetWindowRect(User32.FindWindow(null, "Hearthstone"), ref hsRect);
            SetRect(hsRect.top, hsRect.left, hsRect.right - hsRect.left, hsRect.bottom - hsRect.top);
            ReSizePosLists();
        }
Ejemplo n.º 4
0
        public void Export(Deck deck)
        {
            if (deck == null)
            {
                return;
            }

            var hsHandle = User32.FindWindow(null, "Hearthstone");

            if (!User32.IsForegroundWindow("Hearthstone"))
            {
                //restore window and bring to foreground
                User32.ShowWindow(hsHandle, SwRestore);
                User32.SetForegroundWindow(hsHandle);
                //wait it to actually be in foreground, else the rect might be wrong
                Thread.Sleep(500);
            }
            if (!User32.IsForegroundWindow("Hearthstone"))
            {
                MessageBox.Show("Can't find Heartstone window.");
                return;
            }

            User32.Rect hsWindowRect = new User32.Rect();
            User32.GetWindowRect(hsHandle, ref hsWindowRect);

            var height = (hsWindowRect.bottom - hsWindowRect.top);
            var width  = (hsWindowRect.right - hsWindowRect.left);

            var  bounds       = Screen.FromHandle(hsHandle).Bounds;
            bool isFullscreen = bounds.Width == width && bounds.Height == height;

            foreach (var card in deck.Cards)
            {
                AddCardToDeck(card, width, height, hsHandle, isFullscreen);
            }
        }
        public void UpdatePosition()
        {
            //hide the overlay depenting on options
            EnableCanvas(!(
                (_config.HideInBackground && !User32.IsForegroundWindow("Hearthstone"))
                || (_config.HideInMenu && _hearthstone.IsInMenu)
                || _config.HideOverlay));

            var hsRect = new User32.Rect();
            User32.GetWindowRect(User32.FindWindow(null, "Hearthstone"), ref hsRect);
            SetRect(hsRect.top, hsRect.left, hsRect.right - hsRect.left, hsRect.bottom - hsRect.top);
            ReSizePosLists();
        }
        public void UpdatePosition()
        {
            if (!User32.IsForegroundWindow("Hearthstone") && !_needToRefresh)
            {
                _needToRefresh = true;

            } else if (_needToRefresh && User32.IsForegroundWindow("Hearthstone"))
            {
                _needToRefresh = false;
                Update(true);
            }

            //hide the overlay depenting on options
            EnableCanvas(!(
                (_config.HideInBackground && !User32.IsForegroundWindow("Hearthstone"))
                || (_config.HideInMenu && _hearthstone.IsInMenu)
                || _config.HideOverlay));

            var hsRect = new User32.Rect();
            User32.GetWindowRect(User32.FindWindow(null, "Hearthstone"), ref hsRect);

            //hs window has height 0 if it just launched, screwing things up if the tracker is started before hs is.
            //this prevents that from happening.
            if (hsRect.bottom - hsRect.top == 0)
            {
                return;
            }

            SetRect(hsRect.top, hsRect.left, hsRect.right - hsRect.left, hsRect.bottom - hsRect.top);
            ReSizePosLists();
        }