🩹 修复关闭后仍有后台窗口, 优化主窗口动画
This commit is contained in:
@@ -310,10 +310,9 @@ namespace GeekDesk.Control.UserControls.Config
|
|||||||
{
|
{
|
||||||
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed)
|
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed)
|
||||||
{
|
{
|
||||||
MainWindow.mainWindow.Visibility = Visibility.Visible;
|
appConfig.IsShow = true;
|
||||||
// 执行一下动画 防止太过突兀
|
|
||||||
MainWindow.FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
|
||||||
}
|
}
|
||||||
|
appConfig.IsShow = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ namespace GeekDesk.Control.Windows
|
|||||||
}
|
}
|
||||||
window.Show();
|
window.Show();
|
||||||
Keyboard.Focus(window);
|
Keyboard.Focus(window);
|
||||||
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0, false);
|
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CustomButton_Click(object sender, RoutedEventArgs e)
|
private void CustomButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ namespace GeekDesk.Control.Windows
|
|||||||
}
|
}
|
||||||
window.Show();
|
window.Show();
|
||||||
Keyboard.Focus(window);
|
Keyboard.Focus(window);
|
||||||
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0, false);
|
ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
22
Converts/ReverseBoolConvert.cs
Normal file
22
Converts/ReverseBoolConvert.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Data;
|
||||||
|
|
||||||
|
namespace GeekDesk.Converts
|
||||||
|
{
|
||||||
|
internal class ReverseBoolConvert : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
if (value == null) return null;
|
||||||
|
bool val = (bool)value;
|
||||||
|
return !val;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -256,6 +256,7 @@
|
|||||||
<Compile Include="Converts\OpcityConvert.cs" />
|
<Compile Include="Converts\OpcityConvert.cs" />
|
||||||
<Compile Include="Converts\BGStyleConvert.cs" />
|
<Compile Include="Converts\BGStyleConvert.cs" />
|
||||||
<Compile Include="Converts\UpdateTypeConvert.cs" />
|
<Compile Include="Converts\UpdateTypeConvert.cs" />
|
||||||
|
<Compile Include="Converts\ReverseBoolConvert.cs" />
|
||||||
<Compile Include="Converts\Visibility2BooleanConverter.cs" />
|
<Compile Include="Converts\Visibility2BooleanConverter.cs" />
|
||||||
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.cs" />
|
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.cs" />
|
||||||
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.Drag.cs" />
|
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.Drag.cs" />
|
||||||
@@ -285,6 +286,7 @@
|
|||||||
<Compile Include="Util\MD5Util.cs" />
|
<Compile Include="Util\MD5Util.cs" />
|
||||||
<Compile Include="Util\MouseUtil.cs" />
|
<Compile Include="Util\MouseUtil.cs" />
|
||||||
<Compile Include="Util\RegisterUtil.cs" />
|
<Compile Include="Util\RegisterUtil.cs" />
|
||||||
|
<Compile Include="Util\RelayCommand.cs" />
|
||||||
<Compile Include="Util\ShellContextMenu.cs" />
|
<Compile Include="Util\ShellContextMenu.cs" />
|
||||||
<Compile Include="Util\ShowWindowFollowMouse.cs" />
|
<Compile Include="Util\ShowWindowFollowMouse.cs" />
|
||||||
<Compile Include="Util\StringUtil.cs" />
|
<Compile Include="Util\StringUtil.cs" />
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
AllowsTransparency="True"
|
AllowsTransparency="True"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
ShowInTaskbar="False"
|
ShowInTaskbar="False"
|
||||||
Opacity="0"
|
Opacity="1"
|
||||||
Deactivated="AppWindow_Deactivated"
|
Deactivated="AppWindow_Deactivated"
|
||||||
SizeChanged="Window_SizeChanged"
|
SizeChanged="Window_SizeChanged"
|
||||||
PreviewKeyDown="OnKeyDown"
|
PreviewKeyDown="OnKeyDown"
|
||||||
@@ -27,8 +27,7 @@
|
|||||||
MouseDown="MainWindow_MouseDown"
|
MouseDown="MainWindow_MouseDown"
|
||||||
MouseEnter="MainWindow_MouseEnter"
|
MouseEnter="MainWindow_MouseEnter"
|
||||||
GotFocus="Window_GotFocus"
|
GotFocus="Window_GotFocus"
|
||||||
Loaded="Window_Loaded"
|
Loaded="Window_Loaded"
|
||||||
xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeInAndGrowHorizontally}, Event=Visibility}"
|
|
||||||
>
|
>
|
||||||
|
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
@@ -38,6 +37,7 @@
|
|||||||
<cvt:OpcityConvert x:Key="OpcityConvert"/>
|
<cvt:OpcityConvert x:Key="OpcityConvert"/>
|
||||||
<cvt:IntToCornerRadius x:Key="IntToCornerRadius"/>
|
<cvt:IntToCornerRadius x:Key="IntToCornerRadius"/>
|
||||||
<cvt:DoubleToGridLength x:Key="DoubleToGridLength"/>
|
<cvt:DoubleToGridLength x:Key="DoubleToGridLength"/>
|
||||||
|
<cvt:ReverseBoolConvert x:Key="ReverseBoolConvert"/>
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
|
|
||||||
<WindowChrome.WindowChrome>
|
<WindowChrome.WindowChrome>
|
||||||
@@ -57,6 +57,12 @@
|
|||||||
Focusable="True"
|
Focusable="True"
|
||||||
x:Name="BGBorder"
|
x:Name="BGBorder"
|
||||||
hc:Dialog.Token="MainWindowDialog"
|
hc:Dialog.Token="MainWindowDialog"
|
||||||
|
xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeInAndGrowHorizontally}, Event=None}"
|
||||||
|
xf:Animations.PrimaryBinding="{Binding AppConfig.IsShow, Mode=OneWay}"
|
||||||
|
xf:Animations.Secondary="{xf:Animate BasedOn={StaticResource FadeOut}, Event=None}"
|
||||||
|
xf:Animations.SecondaryBinding="{Binding AppConfig.IsShow, Mode=OneWay, Converter={StaticResource ReverseBoolConvert}}"
|
||||||
|
xf:Animations.SecondaryCompletionCommand="{Binding HideCommand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
|
||||||
|
xf:Animations.AllowOpacityReset="False"
|
||||||
>
|
>
|
||||||
<Border.Effect>
|
<Border.Effect>
|
||||||
<DropShadowEffect BlurRadius="30" Direction="-90" Color="Gray"
|
<DropShadowEffect BlurRadius="30" Direction="-90" Color="Gray"
|
||||||
@@ -73,6 +79,8 @@
|
|||||||
<ColumnDefinition x:Name="RightColumn" Width="*"></ColumnDefinition>
|
<ColumnDefinition x:Name="RightColumn" Width="*"></ColumnDefinition>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<CheckBox x:Name="ShowBox" Visibility="Hidden" Panel.ZIndex="2"/>
|
||||||
|
<CheckBox x:Name="HideBox" Visibility="Hidden" Panel.ZIndex="2"/>
|
||||||
|
|
||||||
<StackPanel HorizontalAlignment="Right" Panel.ZIndex="99" hc:Growl.GrowlParent="False" hc:Growl.Token="MainWindowGrowl" Grid.Column="1" Grid.Row="1"/>
|
<StackPanel HorizontalAlignment="Right" Panel.ZIndex="99" hc:Growl.GrowlParent="False" hc:Growl.Token="MainWindowGrowl" Grid.Column="1" Grid.Row="1"/>
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ namespace GeekDesk
|
|||||||
{
|
{
|
||||||
//加载数据
|
//加载数据
|
||||||
LoadData();
|
LoadData();
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
//用于其他类访问
|
//用于其他类访问
|
||||||
@@ -180,14 +179,7 @@ namespace GeekDesk
|
|||||||
BGSettingUtil.BGSetting();
|
BGSettingUtil.BGSetting();
|
||||||
if (!appData.AppConfig.StartedShowPanel)
|
if (!appData.AppConfig.StartedShowPanel)
|
||||||
{
|
{
|
||||||
if (appData.AppConfig.AppAnimation)
|
this.Visibility = Visibility.Collapsed;
|
||||||
{
|
|
||||||
this.Opacity = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.Visibility = Visibility.Collapsed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -435,7 +427,15 @@ namespace GeekDesk
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
MainWindow.mainWindow.Activate();
|
MainWindow.mainWindow.Activate();
|
||||||
mainWindow.Visibility = Visibility.Visible;
|
mainWindow.Show();
|
||||||
|
//mainWindow.Visibility = Visibility.Visible;
|
||||||
|
if (appData.AppConfig.AppAnimation)
|
||||||
|
{
|
||||||
|
appData.AppConfig.IsShow = true;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
appData.AppConfig.IsShow = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (MarginHide.ON_HIDE)
|
if (MarginHide.ON_HIDE)
|
||||||
{
|
{
|
||||||
@@ -450,10 +450,12 @@ namespace GeekDesk
|
|||||||
|
|
||||||
if (appData.AppConfig.FollowMouse)
|
if (appData.AppConfig.FollowMouse)
|
||||||
{
|
{
|
||||||
ShowWindowFollowMouse.Show(mainWindow, MousePosition.CENTER, 0, 0, false);
|
ShowWindowFollowMouse.Show(mainWindow, MousePosition.CENTER, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//FadeStoryBoard(1, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Visible);
|
||||||
|
|
||||||
FadeStoryBoard(1, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Visible);
|
|
||||||
Keyboard.Focus(mainWindow);
|
Keyboard.Focus(mainWindow);
|
||||||
if (RunTimeStatus.SHOW_MENU_PASSWORDBOX)
|
if (RunTimeStatus.SHOW_MENU_PASSWORDBOX)
|
||||||
{
|
{
|
||||||
@@ -466,25 +468,35 @@ namespace GeekDesk
|
|||||||
|
|
||||||
public static void HideApp()
|
public static void HideApp()
|
||||||
{
|
{
|
||||||
if (!MarginHide.IS_HIDE)
|
if (appData.AppConfig.AppAnimation)
|
||||||
{
|
{
|
||||||
//关闭锁定
|
appData.AppConfig.IsShow = false;
|
||||||
RunTimeStatus.LOCK_APP_PANEL = false;
|
|
||||||
if (RunTimeStatus.SEARCH_BOX_SHOW)
|
|
||||||
{
|
|
||||||
mainWindow.HidedSearchBox();
|
|
||||||
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ShowApp();
|
appData.AppConfig.IsShow = null;
|
||||||
|
HideAppVis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void HideAppVis()
|
||||||
|
{
|
||||||
|
//关闭锁定
|
||||||
|
RunTimeStatus.LOCK_APP_PANEL = false;
|
||||||
|
if (RunTimeStatus.SEARCH_BOX_SHOW)
|
||||||
|
{
|
||||||
|
mainWindow.HidedSearchBox();
|
||||||
|
}
|
||||||
|
mainWindow.Visibility = Visibility.Collapsed;
|
||||||
|
//if (!MarginHide.IS_HIDE)
|
||||||
|
//{
|
||||||
|
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// ShowApp();
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -802,5 +814,30 @@ namespace GeekDesk
|
|||||||
RunTimeStatus.APP_BTN_IS_DOWN = false;
|
RunTimeStatus.APP_BTN_IS_DOWN = false;
|
||||||
}).Start();
|
}).Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ICommand _hideCommand;
|
||||||
|
public ICommand HideCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_hideCommand == null)
|
||||||
|
{
|
||||||
|
_hideCommand = new RelayCommand(
|
||||||
|
p =>
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
p =>
|
||||||
|
{
|
||||||
|
HideAppVis();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return _hideCommand;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,8 +77,7 @@ namespace GeekDesk.Util
|
|||||||
#region 窗体贴边隐藏功能
|
#region 窗体贴边隐藏功能
|
||||||
private static void HideWindow(object o, EventArgs e)
|
private static void HideWindow(object o, EventArgs e)
|
||||||
{
|
{
|
||||||
if (window.Visibility != Visibility.Visible
|
if (RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW
|
||||||
|| RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW
|
|
||||||
|| RunTimeStatus.LOCK_APP_PANEL) return;
|
|| RunTimeStatus.LOCK_APP_PANEL) return;
|
||||||
|
|
||||||
double screenLeft = SystemParameters.VirtualScreenLeft;
|
double screenLeft = SystemParameters.VirtualScreenLeft;
|
||||||
@@ -98,7 +97,7 @@ namespace GeekDesk.Util
|
|||||||
|
|
||||||
//鼠标不在窗口上
|
//鼠标不在窗口上
|
||||||
if ((mouseX < windowLeft || mouseX > windowLeft + windowWidth
|
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)
|
if (windowTop <= screenTop)
|
||||||
@@ -126,8 +125,9 @@ namespace GeekDesk.Util
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mouseX >= windowLeft && mouseX <= windowLeft + windowWidth
|
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)
|
if (windowTop <= screenTop - showMarginWidth)
|
||||||
{
|
{
|
||||||
@@ -189,6 +189,7 @@ namespace GeekDesk.Util
|
|||||||
double windowTop = window.Top;
|
double windowTop = window.Top;
|
||||||
double windowLeft = window.Left;
|
double windowLeft = window.Left;
|
||||||
|
|
||||||
|
window.Visibility = Visibility.Visible;
|
||||||
//左侧显示
|
//左侧显示
|
||||||
if (windowLeft <= screenLeft - showMarginWidth)
|
if (windowLeft <= screenLeft - showMarginWidth)
|
||||||
{
|
{
|
||||||
@@ -286,6 +287,11 @@ namespace GeekDesk.Util
|
|||||||
window.Top = to - 20;
|
window.Top = to - 20;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (hideType > HideType.RIGHT_SHOW)
|
||||||
|
{
|
||||||
|
window.Visibility = Visibility.Collapsed;
|
||||||
|
}
|
||||||
|
|
||||||
//double toTemp = to;
|
//double toTemp = to;
|
||||||
//double leftT = 0;
|
//double leftT = 0;
|
||||||
//double topT = 0;
|
//double topT = 0;
|
||||||
|
|||||||
37
Util/RelayCommand.cs
Normal file
37
Util/RelayCommand.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,7 +21,7 @@ namespace GeekDesk.Util
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 随鼠标位置显示面板
|
/// 随鼠标位置显示面板
|
||||||
/// </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();
|
System.Windows.Point p = MouseUtil.GetMousePosition();
|
||||||
@@ -101,11 +101,6 @@ namespace GeekDesk.Util
|
|||||||
{
|
{
|
||||||
window.Top = p.Y - afterHeight;
|
window.Top = p.Y - afterHeight;
|
||||||
}
|
}
|
||||||
if (visibility)
|
|
||||||
{
|
|
||||||
window.Opacity = 0;
|
|
||||||
window.Visibility = Visibility.Visible;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,23 @@ namespace GeekDesk.ViewModel
|
|||||||
|
|
||||||
private string passwordHint; //密码提示
|
private string passwordHint; //密码提示
|
||||||
|
|
||||||
|
private bool? isShow;
|
||||||
|
|
||||||
|
|
||||||
#region GetSet
|
#region GetSet
|
||||||
|
public bool? IsShow
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return isShow;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
isShow = value;
|
||||||
|
OnPropertyChanged("IsShow");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string PasswordHint
|
public string PasswordHint
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|||||||
Reference in New Issue
Block a user