Example #1
0
        public void Attach(IntPtr windowHandle)
        {
            if (windowHandle.Equals(IntPtr.Zero))
            {
                //_logger.Error("Make sure BDO isn't initially minimized and this application is running as admin.");
                //Debug.WriteLine("could not pinvoke!");
                MessageBox.Show("Make sure BDO isn't initially minimized and this application is running as admin.", "Could not attach to BDO", MessageBoxButton.OK, MessageBoxImage.Error);
                MyApp.exit();
            }
            else
            {
                WindowHandle = windowHandle;
                var r = GetWindowArea();
                Size = new Size
                {
                    Width  = r.Width,
                    Height = r.Height
                };

                Config = ScreenConfig.LoadFromFile($"{Size.Width}x{Size.Height}");

                _overlay = new Overlay(_notifier, _container);

                _windowEventHook = new WindowObserver(windowHandle, ObservedWindowEvent);
                User32.SetForegroundWindow(windowHandle);

                _overlay.Update(r);
                _overlay.Topmost = true;
            }
        }
Example #2
0
        private void ObservedWindowEvent(User32.WindowEventTypes windowEvent)
        {
            switch (windowEvent)
            {
            case User32.WindowEventTypes.EVENT_OBJECT_FOCUS: {
                _overlay.Update(GetWindowArea());
                _overlay.Show();
                MyApp.minimized = false;
            }
            break;

            case User32.WindowEventTypes.EVENT_OBJECT_HIDE: {
                MyApp.minimized = true;
                _overlay.Hide();
                _notifier.Notify("Info", "BDMT has been minimized!");
            }
            break;

            case User32.WindowEventTypes.EVENT_OBJECT_LOCATIONCHANGE: {
                _overlay.Update(GetWindowArea());
            }
            break;

            case User32.WindowEventTypes.EVENT_OBJECT_SHOW: {
            }
            break;

            case User32.WindowEventTypes.EVENT_SYSTEM_FOREGROUND: {
            }
            break;

            case 0: {
                _overlay.Hide();
            }
            break;

            default:
                break;
            }
        }