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;
}