🩹 修复关闭后仍有后台窗口, 优化主窗口动画
This commit is contained in:
@@ -310,10 +310,9 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
{
|
||||
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed)
|
||||
{
|
||||
MainWindow.mainWindow.Visibility = Visibility.Visible;
|
||||
// 执行一下动画 防止太过突兀
|
||||
MainWindow.FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
||||
appConfig.IsShow = true;
|
||||
}
|
||||
appConfig.IsShow = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace GeekDesk.Control.Windows
|
||||
}
|
||||
window.Show();
|
||||
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)
|
||||
|
||||
@@ -280,7 +280,7 @@ namespace GeekDesk.Control.Windows
|
||||
}
|
||||
window.Show();
|
||||
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\BGStyleConvert.cs" />
|
||||
<Compile Include="Converts\UpdateTypeConvert.cs" />
|
||||
<Compile Include="Converts\ReverseBoolConvert.cs" />
|
||||
<Compile Include="Converts\Visibility2BooleanConverter.cs" />
|
||||
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.cs" />
|
||||
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.Drag.cs" />
|
||||
@@ -285,6 +286,7 @@
|
||||
<Compile Include="Util\MD5Util.cs" />
|
||||
<Compile Include="Util\MouseUtil.cs" />
|
||||
<Compile Include="Util\RegisterUtil.cs" />
|
||||
<Compile Include="Util\RelayCommand.cs" />
|
||||
<Compile Include="Util\ShellContextMenu.cs" />
|
||||
<Compile Include="Util\ShowWindowFollowMouse.cs" />
|
||||
<Compile Include="Util\StringUtil.cs" />
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
ShowInTaskbar="False"
|
||||
Opacity="0"
|
||||
Opacity="1"
|
||||
Deactivated="AppWindow_Deactivated"
|
||||
SizeChanged="Window_SizeChanged"
|
||||
PreviewKeyDown="OnKeyDown"
|
||||
@@ -27,8 +27,7 @@
|
||||
MouseDown="MainWindow_MouseDown"
|
||||
MouseEnter="MainWindow_MouseEnter"
|
||||
GotFocus="Window_GotFocus"
|
||||
Loaded="Window_Loaded"
|
||||
xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeInAndGrowHorizontally}, Event=Visibility}"
|
||||
Loaded="Window_Loaded"
|
||||
>
|
||||
|
||||
<Window.Resources>
|
||||
@@ -38,6 +37,7 @@
|
||||
<cvt:OpcityConvert x:Key="OpcityConvert"/>
|
||||
<cvt:IntToCornerRadius x:Key="IntToCornerRadius"/>
|
||||
<cvt:DoubleToGridLength x:Key="DoubleToGridLength"/>
|
||||
<cvt:ReverseBoolConvert x:Key="ReverseBoolConvert"/>
|
||||
</Window.Resources>
|
||||
|
||||
<WindowChrome.WindowChrome>
|
||||
@@ -57,6 +57,12 @@
|
||||
Focusable="True"
|
||||
x:Name="BGBorder"
|
||||
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>
|
||||
<DropShadowEffect BlurRadius="30" Direction="-90" Color="Gray"
|
||||
@@ -73,6 +79,8 @@
|
||||
<ColumnDefinition x:Name="RightColumn" Width="*"></ColumnDefinition>
|
||||
</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"/>
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ namespace GeekDesk
|
||||
{
|
||||
//加载数据
|
||||
LoadData();
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
//用于其他类访问
|
||||
@@ -180,14 +179,7 @@ namespace GeekDesk
|
||||
BGSettingUtil.BGSetting();
|
||||
if (!appData.AppConfig.StartedShowPanel)
|
||||
{
|
||||
if (appData.AppConfig.AppAnimation)
|
||||
{
|
||||
this.Opacity = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -435,7 +427,15 @@ namespace GeekDesk
|
||||
//}
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -450,10 +450,12 @@ namespace GeekDesk
|
||||
|
||||
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);
|
||||
if (RunTimeStatus.SHOW_MENU_PASSWORDBOX)
|
||||
{
|
||||
@@ -466,25 +468,35 @@ namespace GeekDesk
|
||||
|
||||
public static void HideApp()
|
||||
{
|
||||
if (!MarginHide.IS_HIDE)
|
||||
if (appData.AppConfig.AppAnimation)
|
||||
{
|
||||
//关闭锁定
|
||||
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);
|
||||
}
|
||||
appData.AppConfig.IsShow = false;
|
||||
}
|
||||
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>
|
||||
@@ -802,5 +814,30 @@ namespace GeekDesk
|
||||
RunTimeStatus.APP_BTN_IS_DOWN = false;
|
||||
}).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 窗体贴边隐藏功能
|
||||
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
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>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -99,7 +99,23 @@ namespace GeekDesk.ViewModel
|
||||
|
||||
private string passwordHint; //密码提示
|
||||
|
||||
private bool? isShow;
|
||||
|
||||
|
||||
#region GetSet
|
||||
public bool? IsShow
|
||||
{
|
||||
get
|
||||
{
|
||||
return isShow;
|
||||
}
|
||||
set
|
||||
{
|
||||
isShow = value;
|
||||
OnPropertyChanged("IsShow");
|
||||
}
|
||||
}
|
||||
|
||||
public string PasswordHint
|
||||
{
|
||||
get
|
||||
|
||||
Reference in New Issue
Block a user