2021-04-13 15:26:19 +08:00
|
|
|
|
using DraggAnimatedPanelExample;
|
2021-05-14 16:48:26 +08:00
|
|
|
|
using GeekDesk.Constant;
|
|
|
|
|
|
using GeekDesk.Control;
|
2021-07-15 17:27:23 +08:00
|
|
|
|
using GeekDesk.Control.UserControls.Config;
|
2021-06-17 17:28:04 +08:00
|
|
|
|
using GeekDesk.Control.Windows;
|
2021-12-20 09:39:27 +08:00
|
|
|
|
using GeekDesk.Interface;
|
2021-06-17 23:06:46 +08:00
|
|
|
|
using GeekDesk.Task;
|
2021-07-20 13:37:11 +08:00
|
|
|
|
using GeekDesk.Thread;
|
2021-04-13 15:26:19 +08:00
|
|
|
|
using GeekDesk.Util;
|
|
|
|
|
|
using GeekDesk.ViewModel;
|
2021-12-10 17:58:23 +08:00
|
|
|
|
using Gma.System.MouseKeyHook;
|
2021-06-02 17:34:02 +08:00
|
|
|
|
using HandyControl.Data;
|
2021-12-10 17:58:23 +08:00
|
|
|
|
|
2021-04-13 15:26:19 +08:00
|
|
|
|
using System;
|
2021-05-08 17:27:41 +08:00
|
|
|
|
using System.Collections.ObjectModel;
|
2021-05-14 16:48:26 +08:00
|
|
|
|
using System.Diagnostics;
|
2021-05-26 17:19:04 +08:00
|
|
|
|
using System.Drawing;
|
2021-04-13 15:26:19 +08:00
|
|
|
|
using System.IO;
|
2021-04-12 13:46:05 +08:00
|
|
|
|
using System.Windows;
|
2021-04-13 15:26:19 +08:00
|
|
|
|
using System.Windows.Controls;
|
2021-04-12 13:46:05 +08:00
|
|
|
|
using System.Windows.Input;
|
2021-05-28 18:01:19 +08:00
|
|
|
|
using System.Windows.Interop;
|
2021-05-26 17:19:04 +08:00
|
|
|
|
using System.Windows.Media;
|
2021-08-19 13:59:47 +08:00
|
|
|
|
using System.Windows.Media.Animation;
|
2021-07-29 17:04:36 +08:00
|
|
|
|
using static GeekDesk.Util.ShowWindowFollowMouse;
|
2021-04-12 13:46:05 +08:00
|
|
|
|
|
|
|
|
|
|
namespace GeekDesk
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// MainWindow.xaml 的交互逻辑
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
///
|
2021-12-20 09:39:27 +08:00
|
|
|
|
public partial class MainWindow : Window, IWindowCommon
|
2021-04-12 13:46:05 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
2021-05-14 16:48:26 +08:00
|
|
|
|
public static AppData appData = CommonCode.GetAppDataByFile();
|
2021-07-19 17:30:34 +08:00
|
|
|
|
public static ToDoInfoWindow toDoInfoWindow;
|
2021-07-15 17:27:23 +08:00
|
|
|
|
public static int hotKeyId = -1;
|
2021-07-18 20:10:19 +08:00
|
|
|
|
public static int toDoHotKeyId = -1;
|
2021-07-15 17:27:23 +08:00
|
|
|
|
public static MainWindow mainWindow;
|
2021-04-12 13:46:05 +08:00
|
|
|
|
public MainWindow()
|
|
|
|
|
|
{
|
2021-05-20 17:33:49 +08:00
|
|
|
|
LoadData();
|
2021-05-31 17:31:16 +08:00
|
|
|
|
InitializeComponent();
|
2021-07-15 17:27:23 +08:00
|
|
|
|
mainWindow = this;
|
2021-05-20 17:33:49 +08:00
|
|
|
|
this.Topmost = true;
|
2021-04-12 13:46:05 +08:00
|
|
|
|
this.Loaded += Window_Loaded;
|
|
|
|
|
|
this.SizeChanged += MainWindow_Resize;
|
2021-07-18 20:10:19 +08:00
|
|
|
|
ToDoTask.BackLogCheck();
|
2021-08-19 13:59:47 +08:00
|
|
|
|
|
|
|
|
|
|
////实例化隐藏 Hide类,进行时间timer设置
|
2022-01-09 16:00:47 +08:00
|
|
|
|
MarginHide.ReadyHide(this);
|
2021-08-19 13:59:47 +08:00
|
|
|
|
if (appData.AppConfig.MarginHide)
|
|
|
|
|
|
{
|
2022-01-09 16:00:47 +08:00
|
|
|
|
MarginHide.StartHide();
|
2021-08-19 13:59:47 +08:00
|
|
|
|
}
|
2021-04-12 13:46:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-10 17:58:23 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 加载缓存数据
|
|
|
|
|
|
/// </summary>
|
2021-05-20 17:33:49 +08:00
|
|
|
|
private void LoadData()
|
2021-04-13 15:26:19 +08:00
|
|
|
|
{
|
2022-01-09 17:37:25 +08:00
|
|
|
|
GC.KeepAlive(appData); // 持活
|
2021-04-13 15:26:19 +08:00
|
|
|
|
this.DataContext = appData;
|
2021-05-12 10:00:12 +08:00
|
|
|
|
if (appData.MenuList.Count == 0)
|
2021-04-13 15:26:19 +08:00
|
|
|
|
{
|
2022-01-09 16:00:47 +08:00
|
|
|
|
appData.MenuList.Add(new MenuInfo() { MenuName = "NewMenu", MenuId = System.Guid.NewGuid().ToString(), MenuEdit = Visibility.Collapsed });
|
2021-04-13 15:26:19 +08:00
|
|
|
|
}
|
2021-05-28 18:01:19 +08:00
|
|
|
|
|
2021-05-12 10:00:12 +08:00
|
|
|
|
this.Width = appData.AppConfig.WindowWidth;
|
2022-01-09 16:00:47 +08:00
|
|
|
|
this.Height = appData.AppConfig.WindowHeight;
|
2021-04-12 13:46:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-10 17:58:23 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 窗口加载完毕 执行方法
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
2021-04-12 13:46:05 +08:00
|
|
|
|
void Window_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
2021-05-20 17:33:49 +08:00
|
|
|
|
if (!appData.AppConfig.StartedShowPanel)
|
|
|
|
|
|
{
|
2021-08-19 13:59:47 +08:00
|
|
|
|
if (appData.AppConfig.AppAnimation)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Opacity = 0;
|
2022-01-09 16:00:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2021-08-19 13:59:47 +08:00
|
|
|
|
{
|
|
|
|
|
|
this.Visibility = Visibility.Collapsed;
|
|
|
|
|
|
}
|
2022-01-09 16:00:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2021-07-15 17:27:23 +08:00
|
|
|
|
{
|
|
|
|
|
|
ShowApp();
|
2021-05-20 17:33:49 +08:00
|
|
|
|
}
|
2021-12-10 17:58:23 +08:00
|
|
|
|
|
2021-12-20 09:39:27 +08:00
|
|
|
|
//给任务栏图标一个名字
|
2021-12-13 10:53:55 +08:00
|
|
|
|
BarIcon.Text = Constants.MY_NAME;
|
|
|
|
|
|
|
2021-12-10 17:58:23 +08:00
|
|
|
|
//注册热键
|
2021-07-18 20:10:19 +08:00
|
|
|
|
RegisterHotKey(true);
|
2021-08-19 13:59:47 +08:00
|
|
|
|
RegisterCreateToDoHotKey(true);
|
2021-07-21 11:15:51 +08:00
|
|
|
|
|
2021-12-10 17:58:23 +08:00
|
|
|
|
//注册自启动
|
2021-12-13 10:04:15 +08:00
|
|
|
|
if (!appData.AppConfig.SelfStartUped && !Constants.DEV)
|
2021-07-21 11:15:51 +08:00
|
|
|
|
{
|
|
|
|
|
|
RegisterUtil.SetSelfStarting(appData.AppConfig.SelfStartUp, Constants.MY_NAME);
|
|
|
|
|
|
}
|
2021-07-20 17:30:12 +08:00
|
|
|
|
|
2021-12-10 17:58:23 +08:00
|
|
|
|
//注册鼠标中键监听事件
|
2021-12-20 09:56:43 +08:00
|
|
|
|
if (appData.AppConfig.MouseMiddleShow)
|
|
|
|
|
|
{
|
|
|
|
|
|
MouseHookThread.MiddleHook();
|
|
|
|
|
|
}
|
2021-12-10 17:58:23 +08:00
|
|
|
|
|
|
|
|
|
|
//更新线程开启 检测更新
|
|
|
|
|
|
UpdateThread.Update();
|
2021-07-15 17:27:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 注册当前窗口的热键
|
|
|
|
|
|
/// </summary>
|
2021-07-18 20:10:19 +08:00
|
|
|
|
public static void RegisterHotKey(bool first)
|
2021-07-15 17:27:23 +08:00
|
|
|
|
{
|
2021-06-02 17:34:02 +08:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2021-07-18 20:10:19 +08:00
|
|
|
|
if (appData.AppConfig.HotkeyModifiers != 0)
|
2021-07-15 17:27:23 +08:00
|
|
|
|
{
|
2021-08-19 13:59:47 +08:00
|
|
|
|
|
|
|
|
|
|
hotKeyId = GlobalHotKey.RegisterHotKey(appData.AppConfig.HotkeyModifiers, appData.AppConfig.Hotkey, () =>
|
2021-07-15 17:27:23 +08:00
|
|
|
|
{
|
2021-07-18 20:10:19 +08:00
|
|
|
|
if (MotionControl.hotkeyFinished)
|
2021-07-15 17:27:23 +08:00
|
|
|
|
{
|
2022-01-09 16:00:47 +08:00
|
|
|
|
if (mainWindow.Visibility == Visibility.Collapsed || mainWindow.Opacity == 0 || MarginHide.IS_HIDE)
|
2021-07-18 20:10:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
ShowApp();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2021-08-19 13:59:47 +08:00
|
|
|
|
HideApp();
|
2021-07-18 20:10:19 +08:00
|
|
|
|
}
|
2021-07-15 17:27:23 +08:00
|
|
|
|
}
|
2021-07-18 20:10:19 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!first)
|
|
|
|
|
|
{
|
|
|
|
|
|
HandyControl.Controls.Growl.Success("GeekDesk快捷键注册成功(" + appData.AppConfig.HotkeyStr + ")!", "HotKeyGrowl");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (first)
|
|
|
|
|
|
{
|
|
|
|
|
|
HandyControl.Controls.Growl.WarningGlobal("GeekDesk启动快捷键已被其它程序占用(" + appData.AppConfig.HotkeyStr + ")!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
HandyControl.Controls.Growl.Warning("GeekDesk启动快捷键已被其它程序占用(" + appData.AppConfig.HotkeyStr + ")!", "HotKeyGrowl");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-19 13:59:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
2021-07-18 20:10:19 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 注册新建待办的热键
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static void RegisterCreateToDoHotKey(bool first)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2021-08-19 13:59:47 +08:00
|
|
|
|
|
2022-01-09 16:00:47 +08:00
|
|
|
|
if (appData.AppConfig.ToDoHotkeyModifiers != 0)
|
2021-07-18 20:10:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
//加载完毕注册热键
|
2021-08-19 13:59:47 +08:00
|
|
|
|
toDoHotKeyId = GlobalHotKey.RegisterHotKey(appData.AppConfig.ToDoHotkeyModifiers, appData.AppConfig.ToDoHotkey, () =>
|
2021-07-18 20:10:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (MotionControl.hotkeyFinished)
|
2021-07-15 17:27:23 +08:00
|
|
|
|
{
|
2021-08-19 13:59:47 +08:00
|
|
|
|
ToDoInfoWindow.ShowOrHide();
|
2021-07-15 17:27:23 +08:00
|
|
|
|
}
|
2021-07-18 20:10:19 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!first)
|
|
|
|
|
|
{
|
|
|
|
|
|
HandyControl.Controls.Growl.Success("新建待办任务快捷键注册成功(" + appData.AppConfig.ToDoHotkeyStr + ")!", "HotKeyGrowl");
|
|
|
|
|
|
}
|
2021-07-15 17:27:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
2021-06-02 17:34:02 +08:00
|
|
|
|
{
|
2021-07-18 20:10:19 +08:00
|
|
|
|
if (first)
|
|
|
|
|
|
{
|
|
|
|
|
|
HandyControl.Controls.Growl.WarningGlobal("新建待办任务快捷键已被其它程序占用(" + appData.AppConfig.ToDoHotkeyStr + ")!");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
HandyControl.Controls.Growl.Warning("新建待办任务快捷键已被其它程序占用(" + appData.AppConfig.ToDoHotkeyStr + ")!", "HotKeyGrowl");
|
|
|
|
|
|
}
|
2021-06-02 17:34:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-12 13:46:05 +08:00
|
|
|
|
|
2021-12-10 17:58:23 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 重置窗体大小 写入缓存
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
2021-04-12 13:46:05 +08:00
|
|
|
|
void MainWindow_Resize(object sender, System.EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.DataContext != null)
|
|
|
|
|
|
{
|
2021-04-13 15:26:19 +08:00
|
|
|
|
AppData appData = this.DataContext as AppData;
|
|
|
|
|
|
appData.AppConfig.WindowWidth = this.Width;
|
|
|
|
|
|
appData.AppConfig.WindowHeight = this.Height;
|
2021-04-12 13:46:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-09 16:00:47 +08:00
|
|
|
|
|
2021-12-10 17:58:23 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 程序窗体拖动
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
2021-05-12 10:00:12 +08:00
|
|
|
|
private void DragMove(object sender, MouseEventArgs e)
|
2021-04-12 13:46:05 +08:00
|
|
|
|
{
|
2021-05-19 17:31:28 +08:00
|
|
|
|
|
2021-05-12 10:00:12 +08:00
|
|
|
|
if (e.LeftButton == MouseButtonState.Pressed)
|
|
|
|
|
|
{
|
2021-05-19 17:31:28 +08:00
|
|
|
|
var windowMode = this.ResizeMode;
|
|
|
|
|
|
if (this.ResizeMode != ResizeMode.NoResize)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ResizeMode = ResizeMode.NoResize;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.UpdateLayout();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 当点击拖拽区域的时候,让窗口跟着移动
|
|
|
|
|
|
(When clicking the drag area, make the window follow) */
|
|
|
|
|
|
DragMove();
|
|
|
|
|
|
|
|
|
|
|
|
if (this.ResizeMode != windowMode)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ResizeMode = windowMode;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.UpdateLayout();
|
2021-05-12 10:00:12 +08:00
|
|
|
|
}
|
2021-05-08 17:27:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-04-12 13:46:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
2021-05-12 10:00:12 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关闭按钮单击事件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void CloseButtonClick(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
2021-08-19 13:59:47 +08:00
|
|
|
|
if (appData.AppConfig.AppAnimation)
|
|
|
|
|
|
{
|
|
|
|
|
|
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
2022-01-09 16:00:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2021-08-19 13:59:47 +08:00
|
|
|
|
{
|
|
|
|
|
|
this.Visibility = Visibility.Collapsed;
|
|
|
|
|
|
}
|
2021-05-12 10:00:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-09 16:00:47 +08:00
|
|
|
|
|
2021-05-19 17:31:28 +08:00
|
|
|
|
|
2021-05-28 18:01:19 +08:00
|
|
|
|
///// <summary>
|
|
|
|
|
|
///// 左侧栏宽度改变 持久化
|
|
|
|
|
|
///// </summary>
|
|
|
|
|
|
///// <param name="sender"></param>
|
|
|
|
|
|
///// <param name="e"></param>
|
|
|
|
|
|
//private void LeftCardResize(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// appData.AppConfig.MenuCardWidth = LeftColumn.Width.Value;
|
|
|
|
|
|
//}
|
2021-05-19 17:31:28 +08:00
|
|
|
|
|
2022-01-09 16:00:47 +08:00
|
|
|
|
|
2021-06-01 21:49:50 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 右键任务栏图标 显示主面板
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void ShowApp(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
ShowApp();
|
|
|
|
|
|
}
|
2021-07-15 17:27:23 +08:00
|
|
|
|
public static void ShowApp()
|
2021-06-01 21:49:50 +08:00
|
|
|
|
{
|
2021-12-10 17:58:23 +08:00
|
|
|
|
//有全屏化应用则不显示
|
|
|
|
|
|
//if (CommonCode.IsPrimaryFullScreen())
|
|
|
|
|
|
//{
|
|
|
|
|
|
// return;
|
|
|
|
|
|
//}
|
2022-01-09 16:00:47 +08:00
|
|
|
|
//修改贴边隐藏状态为未隐藏
|
|
|
|
|
|
MarginHide.IS_HIDE = false;
|
2021-06-01 21:49:50 +08:00
|
|
|
|
if (appData.AppConfig.FollowMouse)
|
|
|
|
|
|
{
|
2021-08-19 13:59:47 +08:00
|
|
|
|
ShowWindowFollowMouse.Show(mainWindow, MousePosition.CENTER, 0, 0, false);
|
2021-06-01 21:49:50 +08:00
|
|
|
|
}
|
2021-08-19 13:59:47 +08:00
|
|
|
|
FadeStoryBoard(1, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Visible);
|
2021-07-15 17:27:23 +08:00
|
|
|
|
Keyboard.Focus(mainWindow);
|
2021-06-01 21:49:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-19 13:59:47 +08:00
|
|
|
|
public static void HideApp()
|
|
|
|
|
|
{
|
|
|
|
|
|
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-09 16:00:47 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 淡入淡出效果
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="opacity"></param>
|
|
|
|
|
|
/// <param name="milliseconds"></param>
|
|
|
|
|
|
/// <param name="visibility"></param>
|
|
|
|
|
|
public static void FadeStoryBoard(int opacity, int milliseconds, Visibility visibility)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (appData.AppConfig.AppAnimation)
|
|
|
|
|
|
{
|
|
|
|
|
|
DoubleAnimation opacityAnimation = new DoubleAnimation
|
|
|
|
|
|
{
|
|
|
|
|
|
From = mainWindow.Opacity,
|
|
|
|
|
|
To = opacity,
|
|
|
|
|
|
Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds))
|
|
|
|
|
|
};
|
|
|
|
|
|
opacityAnimation.Completed += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
mainWindow.BeginAnimation(OpacityProperty, null);
|
|
|
|
|
|
if (visibility == Visibility.Visible)
|
|
|
|
|
|
{
|
|
|
|
|
|
mainWindow.Opacity = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
mainWindow.Opacity = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
Timeline.SetDesiredFrameRate(opacityAnimation, 60);
|
|
|
|
|
|
mainWindow.BeginAnimation(OpacityProperty, opacityAnimation);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
//防止关闭动画后 窗体仍是0透明度
|
|
|
|
|
|
mainWindow.Opacity = 1;
|
|
|
|
|
|
mainWindow.Visibility = visibility;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-19 13:59:47 +08:00
|
|
|
|
|
2021-05-19 17:31:28 +08:00
|
|
|
|
|
|
|
|
|
|
|
2021-05-12 10:00:12 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 图片图标单击事件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void NotifyIcon_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
2021-08-19 13:59:47 +08:00
|
|
|
|
if (this.Visibility == Visibility.Collapsed || this.Opacity == 0)
|
2021-05-12 10:00:12 +08:00
|
|
|
|
{
|
2021-05-19 17:31:28 +08:00
|
|
|
|
ShowApp();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2021-05-12 10:00:12 +08:00
|
|
|
|
{
|
2021-08-19 13:59:47 +08:00
|
|
|
|
HideApp();
|
2021-05-12 10:00:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-05-14 16:48:26 +08:00
|
|
|
|
/// <summary>
|
2021-05-19 17:31:28 +08:00
|
|
|
|
/// 右键任务栏图标 设置
|
2021-05-14 16:48:26 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
2021-05-19 17:31:28 +08:00
|
|
|
|
private void ConfigApp(object sender, RoutedEventArgs e)
|
2021-05-14 16:48:26 +08:00
|
|
|
|
{
|
2021-06-17 17:28:04 +08:00
|
|
|
|
ConfigWindow.Show(appData.AppConfig, this);
|
2021-05-14 16:48:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-19 13:59:47 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 右键任务栏图标打开程序目录
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void OpenThisDir(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Process p = new Process();
|
|
|
|
|
|
p.StartInfo.FileName = "Explorer.exe";
|
|
|
|
|
|
p.StartInfo.Arguments = "/e,/select," + Constants.APP_DIR + Constants.MY_NAME + ".exe";
|
|
|
|
|
|
p.Start();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-05-19 17:31:28 +08:00
|
|
|
|
|
2021-06-17 17:28:04 +08:00
|
|
|
|
|
2021-05-28 18:01:19 +08:00
|
|
|
|
|
2021-05-14 16:48:26 +08:00
|
|
|
|
/// <summary>
|
2021-06-17 17:28:04 +08:00
|
|
|
|
/// 设置图标
|
2021-05-14 16:48:26 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
2021-05-19 17:31:28 +08:00
|
|
|
|
private void ConfigButtonClick(object sender, RoutedEventArgs e)
|
2021-05-14 16:48:26 +08:00
|
|
|
|
{
|
2021-06-17 17:28:04 +08:00
|
|
|
|
SettingMenus.IsOpen = true;
|
2021-05-19 17:31:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-06-17 17:28:04 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置菜单点击
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void ConfigMenuClick(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
ConfigWindow.Show(appData.AppConfig, this);
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 待办任务
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void BacklogMenuClick(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
2021-07-18 20:10:19 +08:00
|
|
|
|
ToDoWindow.Show();
|
2021-06-17 17:28:04 +08:00
|
|
|
|
}
|
2021-05-19 17:31:28 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 禁用设置按钮右键菜单
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void SettingButton_Initialized(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
SettingButton.ContextMenu = null;
|
2021-05-14 16:48:26 +08:00
|
|
|
|
}
|
2021-05-20 17:33:49 +08:00
|
|
|
|
|
|
|
|
|
|
private void App_LostFocus(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (appData.AppConfig.AppHideType == AppHideType.LOST_FOCUS)
|
|
|
|
|
|
{
|
2021-08-19 13:59:47 +08:00
|
|
|
|
//如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
|
2022-01-09 16:00:47 +08:00
|
|
|
|
if (appData.AppConfig.MarginHide && !MarginHide.IS_HIDE)
|
2021-08-19 13:59:47 +08:00
|
|
|
|
{
|
|
|
|
|
|
this.Visibility = Visibility.Collapsed;
|
|
|
|
|
|
}
|
2021-05-20 17:33:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-05-21 17:19:46 +08:00
|
|
|
|
|
2021-08-19 13:59:47 +08:00
|
|
|
|
private void Window_Deactivated(object sender, EventArgs e)
|
2021-05-21 17:19:46 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (appData.AppConfig.AppHideType == AppHideType.LOST_FOCUS)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Visibility = Visibility.Collapsed;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-06-17 17:28:04 +08:00
|
|
|
|
|
2021-08-19 13:59:47 +08:00
|
|
|
|
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
|
2021-07-07 17:28:29 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (this.DataContext != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
AppData appData = this.DataContext as AppData;
|
|
|
|
|
|
appData.AppConfig.WindowWidth = this.Width;
|
|
|
|
|
|
appData.AppConfig.WindowHeight = this.Height;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-08-19 13:59:47 +08:00
|
|
|
|
|
2022-01-09 16:00:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 右键任务栏图标退出
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void ExitApp(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (appData.AppConfig.MouseMiddleShow)
|
|
|
|
|
|
{
|
|
|
|
|
|
MouseHookThread.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
Application.Current.Shutdown();
|
|
|
|
|
|
}
|
2021-08-19 13:59:47 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 重启
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void ReStartApp(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
2022-01-09 16:00:47 +08:00
|
|
|
|
if (appData.AppConfig.MouseMiddleShow)
|
|
|
|
|
|
{
|
|
|
|
|
|
MouseHookThread.Dispose();
|
|
|
|
|
|
}
|
2021-12-13 13:03:50 +08:00
|
|
|
|
|
2021-08-19 13:59:47 +08:00
|
|
|
|
Process p = new Process();
|
2022-01-09 16:00:47 +08:00
|
|
|
|
p.StartInfo.FileName = Constants.APP_DIR + "GeekDesk.exe";
|
2021-08-19 13:59:47 +08:00
|
|
|
|
p.StartInfo.WorkingDirectory = Constants.APP_DIR;
|
|
|
|
|
|
p.Start();
|
2021-12-13 13:03:50 +08:00
|
|
|
|
|
2021-08-19 13:59:47 +08:00
|
|
|
|
Application.Current.Shutdown();
|
|
|
|
|
|
}
|
2021-12-13 10:53:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关闭托盘图标
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
|
private void CloseBarIcon(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
appData.AppConfig.ShowBarIcon = false;
|
|
|
|
|
|
}
|
2021-12-20 09:39:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void OnKeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.Key == Key.Escape)
|
|
|
|
|
|
{
|
|
|
|
|
|
HideApp();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-04-12 13:46:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|