样式优化 bug修改 鼠标中键呼出
This commit is contained in:
34
Thread/DispatcherBuild.cs
Normal file
34
Thread/DispatcherBuild.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace GeekDesk.Thread
|
||||
{
|
||||
public class DispatcherBuild
|
||||
{
|
||||
|
||||
//创建一个Dispatcher来单独使用ui线程
|
||||
public static Dispatcher Build()
|
||||
{
|
||||
Dispatcher dispatcher = null;
|
||||
var manualResetEvent = new ManualResetEvent(false);
|
||||
var thread = new System.Threading.Thread(() =>
|
||||
{
|
||||
dispatcher = Dispatcher.CurrentDispatcher;
|
||||
var synchronizationContext = new DispatcherSynchronizationContext(dispatcher);
|
||||
SynchronizationContext.SetSynchronizationContext(synchronizationContext);
|
||||
|
||||
manualResetEvent.Set();
|
||||
Dispatcher.Run();
|
||||
});
|
||||
thread.Start();
|
||||
manualResetEvent.WaitOne();
|
||||
manualResetEvent.Dispose();
|
||||
return dispatcher;
|
||||
}
|
||||
}
|
||||
}
|
||||
58
Thread/MouseHookThread.cs
Normal file
58
Thread/MouseHookThread.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using GeekDesk.Control.UserControls.Config;
|
||||
using GeekDesk.ViewModel;
|
||||
using Gma.System.MouseKeyHook;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace GeekDesk.Thread
|
||||
{
|
||||
public class MouseHookThread
|
||||
{
|
||||
private static AppConfig appConfig = MainWindow.appData.AppConfig;
|
||||
public static IKeyboardMouseEvents m_GlobalHook = Hook.GlobalEvents();
|
||||
|
||||
|
||||
public static void MiddleHook()
|
||||
{
|
||||
//使用dispatcher来单独监听UI线程 防止程序卡顿
|
||||
Dispatcher dispatcher = DispatcherBuild.Build();
|
||||
dispatcher.Invoke((Action)(() =>
|
||||
{
|
||||
m_GlobalHook.MouseDownExt += M_GlobalHook_MouseDownExt;
|
||||
}));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标中键呼出
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private static void M_GlobalHook_MouseDownExt(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
if (appConfig.MouseMiddleShow && e.Button == System.Windows.Forms.MouseButtons.Middle)
|
||||
{
|
||||
if (MotionControl.hotkeyFinished)
|
||||
{
|
||||
MainWindow.mainWindow.Dispatcher.Invoke((Action)(() =>
|
||||
{
|
||||
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed || MainWindow.mainWindow.Opacity == 0)
|
||||
{
|
||||
MainWindow.ShowApp();
|
||||
}
|
||||
else
|
||||
{
|
||||
MainWindow.HideApp();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ namespace GeekDesk.Thread
|
||||
{
|
||||
|
||||
//等待1分钟后再检查更新 有的网络连接过慢
|
||||
System.Threading.Thread.Sleep(60 * 1000);
|
||||
System.Threading.Thread.Sleep(1 * 1000);
|
||||
|
||||
string updateUrl;
|
||||
string nowVersion = ConfigurationManager.AppSettings["Version"];
|
||||
@@ -50,7 +50,7 @@ namespace GeekDesk.Thread
|
||||
{
|
||||
JObject jo = JObject.Parse(updateInfo);
|
||||
string onlineVersion = jo["version"].ToString();
|
||||
if (onlineVersion.CompareTo(nowVersion) > 0)
|
||||
if (onlineVersion.CompareTo(nowVersion) > 0 || true)
|
||||
{
|
||||
App.Current.Dispatcher.Invoke((Action)(() =>
|
||||
{
|
||||
@@ -59,7 +59,9 @@ namespace GeekDesk.Thread
|
||||
}));
|
||||
}
|
||||
}
|
||||
#pragma warning disable CS0168 // 声明了变量“e”,但从未使用过
|
||||
} catch (Exception e)
|
||||
#pragma warning restore CS0168 // 声明了变量“e”,但从未使用过
|
||||
{
|
||||
//不做处理
|
||||
//MessageBox.Show(e.Message);
|
||||
|
||||
Reference in New Issue
Block a user