优化贴边交互

This commit is contained in:
liufei
2022-04-20 16:38:55 +08:00
parent 125cc72499
commit be9dcdb923
5 changed files with 99 additions and 11 deletions

View File

@@ -222,5 +222,34 @@ namespace GeekDesk.Util
}
}
/// <summary>
/// 判断鼠标是否在窗口内
/// </summary>
/// <param name="window"></param>
/// <returns></returns>
public static bool MouseInWindow(Window window)
{
double windowHeight = window.Height;
double windowWidth = window.Width;
double windowTop = window.Top;
double windowLeft = window.Left;
//获取鼠标位置
System.Windows.Point p = MouseUtil.GetMousePosition();
double mouseX = p.X;
double mouseY = p.Y;
//鼠标不在窗口上
if (mouseX < windowLeft || mouseX > windowLeft + windowWidth
|| mouseY < windowTop || mouseY > windowTop + windowHeight)
{
return false;
}
return true;
}
}
}

View File

@@ -30,6 +30,8 @@ namespace GeekDesk.Util
public static readonly int shadowWidth = 20;
public static bool ON_HIDE = false;
private static double showMarginWidth = 1;
@@ -69,7 +71,8 @@ namespace GeekDesk.Util
#region
private static void HideWindow(object o, EventArgs e)
{
if (window.Visibility != Visibility.Visible) return;
if (window.Visibility != Visibility.Visible
|| RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW) return;
double screenLeft = SystemParameters.VirtualScreenLeft;
double screenTop = SystemParameters.VirtualScreenTop;
@@ -150,6 +153,7 @@ namespace GeekDesk.Util
public static void StartHide()
{
ON_HIDE = true;
if (timer != null) return;
timer = new Timer
{
@@ -161,6 +165,7 @@ namespace GeekDesk.Util
public static void StopHide()
{
ON_HIDE = false;
if (timer == null) return;
timer.Stop();
timer.Dispose();
@@ -295,6 +300,20 @@ namespace GeekDesk.Util
}
public static void WaitHide(int waitTime)
{
new System.Threading.Thread(()=>
{
System.Threading.Thread.Sleep(waitTime);
//修改状态为false 继续执行贴边隐藏
RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW = false;
}).Start();
}
}
}