コード例 #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;
            }
        }
コード例 #2
0
        public WindowAttacher(IntPtr windowHandle, Window overlayWindow)
        {
            if (windowHandle.Equals(IntPtr.Zero))
            {
                Debug.WriteLine("could not pinvoke!");
                System.Windows.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);
                App.exit();
            }
            else
            {
                this.windowHandle  = windowHandle;
                this.overlayWindow = overlayWindow;
                windowEventHook    = new WindowObserver(windowHandle, observedWindowEvent);
                SetForegroundWindow(windowHandle);

                updateOverlay();
                overlayWindow.Topmost = true;

                ToasterThread.toaster.popToast("Info", "Welcome to BDMT v" + App.version);
            }
        }