不开启贴边隐藏不再占用后台资源
This commit is contained in:
@@ -1,15 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
using System.Windows.Media;
|
using GeekDesk.Constant;
|
||||||
|
|
||||||
namespace GeekDesk.Util
|
namespace GeekDesk.Util
|
||||||
{
|
{
|
||||||
@@ -24,6 +18,7 @@ namespace GeekDesk.Util
|
|||||||
RIGHT_HIDE = 6
|
RIGHT_HIDE = 6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public class MarginHide
|
public class MarginHide
|
||||||
{
|
{
|
||||||
private static Window window;//定义使用该方法的窗体
|
private static Window window;//定义使用该方法的窗体
|
||||||
@@ -33,9 +28,11 @@ namespace GeekDesk.Util
|
|||||||
private static readonly int fadeShowTime = 200;
|
private static readonly int fadeShowTime = 200;
|
||||||
private static readonly int taskTime = 250;
|
private static readonly int taskTime = 250;
|
||||||
|
|
||||||
|
public static readonly int shadowWidth = 20;
|
||||||
|
|
||||||
|
|
||||||
private static double showMarginWidth = 1;
|
private static double showMarginWidth = 1;
|
||||||
|
|
||||||
public static bool IS_RUN = false;
|
|
||||||
public static bool IS_HIDE = false;
|
public static bool IS_HIDE = false;
|
||||||
|
|
||||||
private static Timer timer = null;
|
private static Timer timer = null;
|
||||||
@@ -43,11 +40,6 @@ namespace GeekDesk.Util
|
|||||||
public static void ReadyHide(Window window)
|
public static void ReadyHide(Window window)
|
||||||
{
|
{
|
||||||
MarginHide.window = window;
|
MarginHide.window = window;
|
||||||
if (timer != null) return;
|
|
||||||
timer = new Timer();//添加timer计时器,隐藏功能
|
|
||||||
timer.Interval = taskTime;
|
|
||||||
timer.Tick += HideWindow;
|
|
||||||
timer.Start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -77,7 +69,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 || !IS_RUN) return;
|
if (window.Visibility != Visibility.Visible) return;
|
||||||
|
|
||||||
double screenLeft = SystemParameters.VirtualScreenLeft;
|
double screenLeft = SystemParameters.VirtualScreenLeft;
|
||||||
double screenTop = SystemParameters.VirtualScreenTop;
|
double screenTop = SystemParameters.VirtualScreenTop;
|
||||||
@@ -158,12 +150,21 @@ namespace GeekDesk.Util
|
|||||||
|
|
||||||
public static void StartHide()
|
public static void StartHide()
|
||||||
{
|
{
|
||||||
IS_RUN = true;
|
if (timer != null) return;
|
||||||
|
timer = new Timer
|
||||||
|
{
|
||||||
|
Interval = taskTime
|
||||||
|
};//添加timer计时器,隐藏功能
|
||||||
|
timer.Tick += HideWindow;
|
||||||
|
timer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void StopHide()
|
public static void StopHide()
|
||||||
{
|
{
|
||||||
IS_RUN = false;
|
if (timer == null) return;
|
||||||
|
timer.Stop();
|
||||||
|
timer.Dispose();
|
||||||
|
timer = null;
|
||||||
//功能关闭 如果界面是隐藏状态 那么要显示界面 ↓
|
//功能关闭 如果界面是隐藏状态 那么要显示界面 ↓
|
||||||
if (IS_HIDE)
|
if (IS_HIDE)
|
||||||
{
|
{
|
||||||
@@ -239,15 +240,26 @@ namespace GeekDesk.Util
|
|||||||
To = to,
|
To = to,
|
||||||
Duration = new Duration(TimeSpan.FromMilliseconds(hideTime))
|
Duration = new Duration(TimeSpan.FromMilliseconds(hideTime))
|
||||||
};
|
};
|
||||||
|
// 如果是显示 则贴屏幕侧不显示阴影
|
||||||
|
bool isShow = false;
|
||||||
|
int shadowWidthTemp = Constants.SHADOW_WIDTH;
|
||||||
|
if (hideType <= HideType.RIGHT_SHOW)
|
||||||
|
{
|
||||||
|
isShow = true;
|
||||||
|
if (hideType == HideType.RIGHT_SHOW)
|
||||||
|
{
|
||||||
|
shadowWidthTemp = -shadowWidthTemp;
|
||||||
|
}
|
||||||
|
}
|
||||||
da.Completed += (s, e) =>
|
da.Completed += (s, e) =>
|
||||||
{
|
{
|
||||||
if ("Top".Equals(property.Name))
|
if ("Top".Equals(property.Name))
|
||||||
{
|
{
|
||||||
window.Top = toTemp;
|
window.Top = isShow ? toTemp - shadowWidthTemp : toTemp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
window.Left = toTemp;
|
window.Left = isShow ? toTemp - shadowWidthTemp : toTemp;
|
||||||
}
|
}
|
||||||
window.BeginAnimation(property, null);
|
window.BeginAnimation(property, null);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user