🩹 修复关闭后仍有后台窗口, 优化主窗口动画

This commit is contained in:
liufei
2022-06-13 20:35:48 +08:00
parent c7ef24a5b1
commit da7588273e
11 changed files with 165 additions and 43 deletions

View File

@@ -77,8 +77,7 @@ namespace GeekDesk.Util
#region
private static void HideWindow(object o, EventArgs e)
{
if (window.Visibility != Visibility.Visible
|| RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW
if (RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW
|| RunTimeStatus.LOCK_APP_PANEL) return;
double screenLeft = SystemParameters.VirtualScreenLeft;
@@ -98,7 +97,7 @@ namespace GeekDesk.Util
//鼠标不在窗口上
if ((mouseX < windowLeft || mouseX > windowLeft + windowWidth
|| mouseY < windowTop || mouseY > windowTop + windowHeight) && !IS_HIDE)
|| mouseY < windowTop || mouseY > windowTop + windowHeight) && !IS_HIDE && window.Visibility == Visibility.Visible)
{
//上方隐藏条件
if (windowTop <= screenTop)
@@ -126,8 +125,9 @@ namespace GeekDesk.Util
}
}
else if (mouseX >= windowLeft && mouseX <= windowLeft + windowWidth
&& mouseY >= windowTop && mouseY <= windowTop + windowHeight && IS_HIDE)
&& mouseY >= windowTop && mouseY <= windowTop + windowHeight && IS_HIDE && window.Visibility != Visibility.Visible)
{
window.Visibility = Visibility.Visible;
//上方显示
if (windowTop <= screenTop - showMarginWidth)
{
@@ -189,6 +189,7 @@ namespace GeekDesk.Util
double windowTop = window.Top;
double windowLeft = window.Left;
window.Visibility = Visibility.Visible;
//左侧显示
if (windowLeft <= screenLeft - showMarginWidth)
{
@@ -286,6 +287,11 @@ namespace GeekDesk.Util
window.Top = to - 20;
break;
}
if (hideType > HideType.RIGHT_SHOW)
{
window.Visibility = Visibility.Collapsed;
}
//double toTemp = to;
//double leftT = 0;
//double topT = 0;

37
Util/RelayCommand.cs Normal file
View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace GeekDesk.Util
{
public class RelayCommand : ICommand
{
private readonly Predicate<object> _canExecute;
private readonly Action<object> _execute;
public RelayCommand(Predicate<object> canExecute, Action<object> execute)
{
_canExecute = canExecute;
_execute = execute;
}
public event EventHandler CanExecuteChanged
{
add => CommandManager.RequerySuggested += value;
remove => CommandManager.RequerySuggested -= value;
}
public bool CanExecute(object parameter)
{
return _canExecute(parameter);
}
public void Execute(object parameter)
{
_execute(parameter);
}
}
}

View File

@@ -21,7 +21,7 @@ namespace GeekDesk.Util
/// <summary>
/// 随鼠标位置显示面板
/// </summary>
public static void Show(Window window, MousePosition position, double widthOffset = 0, double heightOffset = 0, bool visibility = true)
public static void Show(Window window, MousePosition position, double widthOffset = 0, double heightOffset = 0)
{
//获取鼠标位置
System.Windows.Point p = MouseUtil.GetMousePosition();
@@ -101,11 +101,6 @@ namespace GeekDesk.Util
{
window.Top = p.Y - afterHeight;
}
if (visibility)
{
window.Opacity = 0;
window.Visibility = Visibility.Visible;
}
}
}