void OnPopupLoaded(object sender, RoutedEventArgs e)
        {
            if (_alreadyLoaded)
            {
                return;
            }

            _alreadyLoaded = true;

            if (Child != null)
            {
                Child.AddHandler(PreviewMouseLeftButtonDownEvent,
                                 new MouseButtonEventHandler(OnChildPreviewMouseLeftButtonDown), true);
            }

            _parentWindow = Window.GetWindow(this);

            if (_parentWindow == null)
            {
                return;
            }

            _parentWindow.Activated   += OnParentWindowActivated;
            _parentWindow.Deactivated += OnParentWindowDeactivated;
        }
Beispiel #2
0
        /// <summary>
        /// popup加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnPopupLoaded(object sender, RoutedEventArgs e)
        {
            if (_alreadyLoaded)
            {
                return;
            }

            _alreadyLoaded = true;

            if (Child != null)
            {
                Child.AddHandler(PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(OnChildPreviewMouseLeftButtonDown), true);
            }

            _parentWindow = Window.GetWindow(this);
            if (IsMove)
            {
                _parentWindow.LocationChanged += delegate
                {
                    var offset = HorizontalOffset;
                    HorizontalOffset = offset + 1;
                    HorizontalOffset = offset;
                }
            }
            ;

            if (_parentWindow == null)
            {
                return;
            }

            _parentWindow.Activated   += OnParentWindowActivated;
            _parentWindow.Deactivated += OnParentWindowDeactivated;
        }
Beispiel #3
0
        void OnPopupLoaded(object sender, RoutedEventArgs e)
        {
            if (_alreadyLoaded)
            {
                return;
            }

            _alreadyLoaded = true;

            if (Child != null)
            {
                Child.AddHandler(PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(OnChildPreviewMouseLeftButtonDown), true);
            }

            _parentWindow = Window.GetWindow(this);

            if (_parentWindow == null)
            {
                return;
            }

            _parentWindow.Activated   += OnParentWindowActivated;
            _parentWindow.Deactivated += OnParentWindowDeactivated;
            _parentWindow.Loaded      += _parentWindow_Loaded;

            FullScreenManager.OnFullScreen.Subscribe(x =>
            {
                isForcedHide = x;

                if (x)
                {
                    var hwndSource = (PresentationSource.FromVisual(Child)) as HwndSource;

                    if (hwndSource == null)
                    {
                        return;
                    }
                    var hwnd = hwndSource.Handle;

                    RECT rect;

                    if (!GetWindowRect(hwnd, out rect))
                    {
                        return;
                    }

                    SetWindowPos(hwnd, HWND_BOTTOM, rect.Left, rect.Top, (int)Width, (int)Height, TOPMOST_FLAGS);
                }
            });
        }