示例#1
0
        NcHitTest HandleNcHitTest(Point screenPoint)
        {
            var windowPoint = _contentWindow.PointFromScreen(screenPoint);
            var capH        = (double)WindowCaptionHeightConverter.Instance.Convert(Chrome.GetCaptionHeight(_contentWindow), typeof(Double), null, CultureInfo.CurrentCulture);
            //double capH = (windowCapH > -1 ? windowCapH : _contentWindow.ActualHeight);

            NcHitTest location = NcHitTest.HTCLIENT;
            var       hitTest  = _contentWindow.InputHitTest(windowPoint);

            if (hitTest != null && (windowPoint.Y <= capH || Chrome.GetIsCaption(hitTest)) &&
                !Chrome.GetIsHitTestVisible(hitTest))
            {
                location = NcHitTest.HTCAPTION;
                if (windowPoint.Y <= 40)
                {
                    // TODO: check for sysmenu style
                    if (_contentWindow.FlowDirection == System.Windows.FlowDirection.LeftToRight)
                    {
                        if (windowPoint.X <= 40)
                        {
                            location = NcHitTest.HTSYSMENU;
                        }
                    }
                    else if (windowPoint.X >= (_contentWindow.ActualWidth - 40))
                    {
                        location = NcHitTest.HTSYSMENU;
                    }
                }
            }

            if (_resizeGrip != null && _resizeGrip.Visibility == System.Windows.Visibility.Visible &&
                VisualTreeHelper.HitTest(_resizeGrip, _resizeGrip.PointFromScreen(screenPoint)) != null)
            {
                location = _resizeGrip.FlowDirection == System.Windows.FlowDirection.LeftToRight ?
                           NcHitTest.HTBOTTOMRIGHT : NcHitTest.HTBOTTOMLEFT;
            }

            //Debug.WriteLine(location);
            return(location);
        }
示例#2
0
        private NcHitTest HandleNcHitTest(IntPtr hWnd, IntPtr lParam)
        {
            Point screenPoint = lParam.ToPoint();
            Point windowPoint = ContentWindow.PointFromScreen(screenPoint);
            var   capH        = (double)WindowCaptionHeightConverter.Instance.Convert(Chrome.GetCaptionHeight(ContentWindow), typeof(Double), null, CultureInfo.CurrentCulture);
            //double capH = (windowCapH > -1 ? windowCapH : ContentWindow.ActualHeight);

            NcHitTest location = NcHitTest.HTCLIENT;
            var       hitTest  = ContentWindow.InputHitTest(windowPoint);

            if (hitTest != null && (windowPoint.Y <= capH || Chrome.GetIsCaption(hitTest)) &&
                !Chrome.GetIsHitTestVisible(hitTest))
            {
                location = NcHitTest.HTCAPTION;
                if (windowPoint.Y <= 40)
                {
                    // check for sysmenu style
                    if (((WindowStyles)User32.GetWindowLong(hWndContent, CommonWin32.WindowClasses.WindowLong.GWL_STYLE)).HasFlag(WindowStyles.WS_SYSMENU))
                    {
                        if (ContentWindow.FlowDirection == System.Windows.FlowDirection.LeftToRight)
                        {
                            if (windowPoint.X <= 40)
                            {
                                location = NcHitTest.HTSYSMENU;
                            }
                        }
                        else if (windowPoint.X >= (ContentWindow.ActualWidth - 40))
                        {
                            location = NcHitTest.HTSYSMENU;
                        }
                    }
                }
            }

            if (_resizeGrip != null && _resizeGrip.Visibility == System.Windows.Visibility.Visible &&
                VisualTreeHelper.HitTest(_resizeGrip, _resizeGrip.PointFromScreen(screenPoint)) != null)
            {
                location = _resizeGrip.FlowDirection == System.Windows.FlowDirection.LeftToRight ?
                           NcHitTest.HTBOTTOMRIGHT : NcHitTest.HTBOTTOMLEFT;
            }

            //Debug.WriteLine(location);
            return(location);
        }