diff --git a/Control/UserControls/Config/MotionControl.xaml.cs b/Control/UserControls/Config/MotionControl.xaml.cs
index ce775ac..a3907de 100644
--- a/Control/UserControls/Config/MotionControl.xaml.cs
+++ b/Control/UserControls/Config/MotionControl.xaml.cs
@@ -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;
}
diff --git a/Control/Windows/IconfontWindow.xaml.cs b/Control/Windows/IconfontWindow.xaml.cs
index 22000cf..67df36a 100644
--- a/Control/Windows/IconfontWindow.xaml.cs
+++ b/Control/Windows/IconfontWindow.xaml.cs
@@ -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)
diff --git a/Control/Windows/SystemItemWindow.xaml.cs b/Control/Windows/SystemItemWindow.xaml.cs
index 0f79d65..ec8b6c1 100644
--- a/Control/Windows/SystemItemWindow.xaml.cs
+++ b/Control/Windows/SystemItemWindow.xaml.cs
@@ -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);
}
diff --git a/Converts/ReverseBoolConvert.cs b/Converts/ReverseBoolConvert.cs
new file mode 100644
index 0000000..dfb9c6b
--- /dev/null
+++ b/Converts/ReverseBoolConvert.cs
@@ -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();
+ }
+ }
+}
diff --git a/GeekDesk.csproj b/GeekDesk.csproj
index 6fb53bd..0f743f1 100644
--- a/GeekDesk.csproj
+++ b/GeekDesk.csproj
@@ -256,6 +256,7 @@
+
@@ -285,6 +286,7 @@
+
diff --git a/MainWindow.xaml b/MainWindow.xaml
index 851bb32..c3db11f 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -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"
>
@@ -38,6 +37,7 @@
+
@@ -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"
>
+
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index f943eaf..4b690e9 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -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();
+ //}
}
///
@@ -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;
+ }
+ }
+
+
+
}
}
diff --git a/Util/MarginHide.cs b/Util/MarginHide.cs
index ca73440..a16bbdd 100644
--- a/Util/MarginHide.cs
+++ b/Util/MarginHide.cs
@@ -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;
diff --git a/Util/RelayCommand.cs b/Util/RelayCommand.cs
new file mode 100644
index 0000000..383b0ae
--- /dev/null
+++ b/Util/RelayCommand.cs
@@ -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