diff --git a/App.config b/App.config
index 881791c..2d4d451 100644
--- a/App.config
+++ b/App.config
@@ -1,21 +1,23 @@
-
+
-
+
-
-
+
+
-
+
+
-
-
+
+
+
diff --git a/App.xaml.cs b/App.xaml.cs
index 42e0140..323a35b 100644
--- a/App.xaml.cs
+++ b/App.xaml.cs
@@ -1,4 +1,8 @@
-using System.Windows;
+using Microsoft.Win32;
+using System;
+using System.IO;
+using System.Windows;
+using System.Windows.Threading;
namespace GeekDesk
{
@@ -7,5 +11,138 @@ namespace GeekDesk
///
public partial class App : Application
{
+ System.Threading.Mutex mutex;
+ private void App_Startup(object sender, StartupEventArgs e)
+ {
+ bool ret;
+ mutex = new System.Threading.Mutex(true, "GeekDesk", out ret);
+
+ if (!ret)
+ {
+ MessageBox.Show("已有一个客户端正在运行,请先结束原来客户端!");
+ Environment.Exit(0);
+ }
+ #region 设置程序开机自动运行(+注册表项)
+ try
+ {
+ //SetSelfStarting(true, "GeekDesk.exe");
+ }
+ catch (Exception ex)
+ {
+ }
+
+ #endregion
+ }
+
+
+
+ #region 注册表开机自启动
+
+
+ ///
+ /// 开机自动启动
+ ///
+ /// 设置开机启动,或取消开机启动
+ /// 注册表中的名称
+ /// 开启或停用是否成功
+ public bool SetSelfStarting(bool started, string exeName)
+ {
+ RegistryKey key = null;
+ try
+ {
+ string exeDir = System.Windows.Forms.Application.ExecutablePath;
+ //RegistryKey HKLM = Registry.CurrentUser;
+ //key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);//打开注册表子项
+ key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);//打开注册表子项
+
+ if (key == null)//如果该项不存在的话,则创建该子项
+ {
+ key = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
+ }
+ if (started)
+ {
+ try
+ {
+ object ob = key.GetValue(exeName, -1);
+
+ if (!ob.ToString().Equals(exeDir))
+ {
+ if (!ob.ToString().Equals("-1"))
+ {
+ key.DeleteValue(exeName);//取消开机启动
+ }
+ key.SetValue(exeName, exeDir);//设置为开机启动
+ }
+ key.Close();
+
+ }
+ catch (Exception ex)
+ {
+ return false;
+ }
+ }
+ else
+ {
+ try
+ {
+ key.DeleteValue(exeName);//取消开机启动
+ key.Close();
+ }
+ catch (Exception ex)
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ catch (Exception ex)
+ {
+ if (key != null)
+ {
+ key.Close();
+ }
+ return false;
+ }
+ }
+
+ #endregion
}
+ // private void WriteLog(object exception)
+ // {
+ // Exception ex = exception as Exception;
+
+ // using (FileStream fs = File.Open(".//ErrorLog.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite))
+ // {
+ // fs.Seek(0, SeekOrigin.End);
+ // byte[] buffer = Encoding.Default.GetBytes("-------------------------------------------------------\r\n");
+ // fs.Write(buffer, 0, buffer.Length);
+
+ // buffer = Encoding.Default.GetBytes(DateTime.Now.ToString() + "\r\n");
+ // fs.Write(buffer, 0, buffer.Length);
+
+ // if (ex != null)
+ // {
+ // buffer = Encoding.Default.GetBytes("成员名: " + ex.TargetSite + "\r\n");
+ // fs.Write(buffer, 0, buffer.Length);
+
+ // buffer = Encoding.Default.GetBytes("引发异常的类: " + ex.TargetSite.DeclaringType + "\r\n");
+ // fs.Write(buffer, 0, buffer.Length);
+
+ // buffer = Encoding.Default.GetBytes("异常信息: " + ex.Message + "\r\n");
+ // fs.Write(buffer, 0, buffer.Length);
+
+ // buffer = Encoding.Default.GetBytes("引发异常的程序集或对象: " + ex.Source + "\r\n");
+ // fs.Write(buffer, 0, buffer.Length);
+
+ // buffer = Encoding.Default.GetBytes("栈:" + ex.StackTrace + "\r\n");
+ // fs.Write(buffer, 0, buffer.Length);
+ // }
+ // else
+ // {
+ // buffer = Encoding.Default.GetBytes("应用程序错误: " + exception.ToString() + "\r\n");
+ // fs.Write(buffer, 0, buffer.Length);
+ // }
+ // }
+
+ //}
}
diff --git a/Control/UserControls/Config/MotionControl.xaml.cs b/Control/UserControls/Config/MotionControl.xaml.cs
index 2666be3..12fca53 100644
--- a/Control/UserControls/Config/MotionControl.xaml.cs
+++ b/Control/UserControls/Config/MotionControl.xaml.cs
@@ -1,7 +1,6 @@
using GeekDesk.Control.Windows;
using GeekDesk.Util;
using GeekDesk.ViewModel;
-using GlobalHotKey;
using HandyControl.Data;
using Microsoft.Win32;
using System;
diff --git a/Control/UserControls/PannelCard/RightCardControl.xaml.cs b/Control/UserControls/PannelCard/RightCardControl.xaml.cs
index 1d9892f..3513d31 100644
--- a/Control/UserControls/PannelCard/RightCardControl.xaml.cs
+++ b/Control/UserControls/PannelCard/RightCardControl.xaml.cs
@@ -173,7 +173,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
{
string path = (string)obj;
- string base64 = ImageUtil.FileImageToBase64(path, ImageFormat.Jpeg);
+ //string base64 = ImageUtil.FileImageToBase64(path, ImageFormat.Jpeg);
IconInfo iconInfo = new IconInfo
{
diff --git a/Control/Windows/ConfigWindow.xaml.cs b/Control/Windows/ConfigWindow.xaml.cs
index cbf4a88..2e63ac8 100644
--- a/Control/Windows/ConfigWindow.xaml.cs
+++ b/Control/Windows/ConfigWindow.xaml.cs
@@ -1,5 +1,4 @@
-using GalaSoft.MvvmLight.Command;
using GeekDesk.Control.UserControls;
using GeekDesk.Control.UserControls.Config;
using GeekDesk.ViewModel;
diff --git a/Control/Windows/UpdateWindow.xaml b/Control/Windows/UpdateWindow.xaml
index 48fe6b7..975f8f2 100644
--- a/Control/Windows/UpdateWindow.xaml
+++ b/Control/Windows/UpdateWindow.xaml
@@ -4,13 +4,41 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GeekDesk.Control.Windows"
+ xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
- Title="UpdateWindow" Height="450" Width="800"
+ Title="UpdateWindow" Height="300" Width="450"
WindowStyle="None"
AllowsTransparency="True"
Background="Transparent" ShowInTaskbar="False">
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Control/Windows/UpdateWindow.xaml.cs b/Control/Windows/UpdateWindow.xaml.cs
index 985ebb7..5d8dc42 100644
--- a/Control/Windows/UpdateWindow.xaml.cs
+++ b/Control/Windows/UpdateWindow.xaml.cs
@@ -1,5 +1,11 @@
-using System;
+using GeekDesk.Constant;
+using GeekDesk.Util;
+using GeekDesk.ViewModel;
+using Newtonsoft.Json.Linq;
+using System;
using System.Collections.Generic;
+using System.Configuration;
+using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -19,9 +25,83 @@ namespace GeekDesk.Control.Windows
///
public partial class UpdateWindow : Window
{
- public UpdateWindow()
+ private static AppConfig appConfig = MainWindow.appData.AppConfig;
+ private static string githubUrl = "";
+ private static string giteeUrl = "";
+ private UpdateWindow(JObject jo)
{
- InitializeComponent();
+ try
+ {
+ WindowStartupLocation = WindowStartupLocation.CenterScreen;
+ InitializeComponent();
+ DataHandle(jo);
+ }
+ catch (Exception)
+ {
+
+ }
+
+ }
+
+ ///
+ /// 移动窗口
+ ///
+ ///
+ ///
+ private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ if (e.LeftButton == MouseButtonState.Pressed)
+ {
+ DragMove();
+ }
+ }
+
+
+ private void DataHandle(JObject jo)
+ {
+ Title.Text = StringUtil.IsEmpty(jo["title"]) ? "" : jo["title"].ToString();
+ SubTitle.Text = StringUtil.IsEmpty(jo["subTitle"]) ? "" : jo["subTitle"].ToString();
+ MsgTitle.Text = StringUtil.IsEmpty(jo["msgTitle"]) ? "" : jo["msgTitle"].ToString();
+ JArray ja = JArray.Parse(StringUtil.IsEmpty(jo["msg"]) ? "[]" : jo["msg"].ToString());
+ githubUrl = StringUtil.IsEmpty(jo["githubUrl"]) ? ConfigurationManager.AppSettings["GitHubUrl"] : jo["githubUrl"].ToString();
+ giteeUrl = StringUtil.IsEmpty(jo["giteeUrl"]) ? ConfigurationManager.AppSettings["GiteeUrl"] : jo["giteeUrl"].ToString();
+ string msg = "";
+ for (int i=0; i
Taskbar.ico
+
+ LocalIntranet
+
+
+ false
+
-
- packages\SharpShellTools.2.2.0.0\lib\Apex.WinForms.dll
-
packages\CommonServiceLocator.2.0.6\lib\net45\CommonServiceLocator.dll
-
- packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.dll
-
-
- packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Extras.dll
-
-
- packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll
-
-
- packages\GlobalHotKey.1.1.0\lib\GlobalHotKey.dll
-
packages\HandyControl.3.1.0\lib\net472\HandyControl.dll
packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll
-
- packages\SharpShellTools.2.2.0.0\lib\ServerManager.exe
-
-
- packages\SharpShellTools.2.2.0.0\lib\SharpShell.dll
-
-
- packages\SharpShellTools.2.2.0.0\lib\srm.exe
- True
-
@@ -89,9 +70,6 @@
packages\System.Drawing.Common.6.0.0-preview.3.21201.4\lib\net461\System.Drawing.Common.dll
-
- packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll
-
@@ -187,7 +165,6 @@
-
@@ -297,6 +274,7 @@
Resources.Designer.cs
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 01c9971..bec1707 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -7,9 +7,7 @@ using GeekDesk.Task;
using GeekDesk.Thread;
using GeekDesk.Util;
using GeekDesk.ViewModel;
-using GlobalHotKey;
using HandyControl.Data;
-using SharpShell.SharpContextMenu;
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
@@ -36,7 +34,6 @@ namespace GeekDesk
public static int hotKeyId = -1;
public static int toDoHotKeyId = -1;
public static MainWindow mainWindow;
- public HotKeyManager hkm = new HotKeyManager();
public MainWindow()
{
LoadData();
@@ -46,7 +43,6 @@ namespace GeekDesk
this.Loaded += Window_Loaded;
this.SizeChanged += MainWindow_Resize;
ToDoTask.BackLogCheck();
- UpdateThread.Update();
}
private void LoadData()
@@ -73,6 +69,8 @@ namespace GeekDesk
}
RegisterHotKey(true);
//RegisterCreateToDoHotKey(true);
+ UpdateThread.Update();
+
}
///
@@ -155,21 +153,21 @@ namespace GeekDesk
}
}
- private void DisplayWindowHotKeyPress(object sender, KeyPressedEventArgs e)
- {
- if (e.HotKey.Key == Key.Y)
- {
- if (this.Visibility == Visibility.Collapsed)
- {
- ShowApp();
- }
- else
- {
- this.Visibility = Visibility.Collapsed;
- }
- }
+ //private void DisplayWindowHotKeyPress(object sender, KeyPressedEventArgs e)
+ //{
+ // if (e.HotKey.Key == Key.Y)
+ // {
+ // if (this.Visibility == Visibility.Collapsed)
+ // {
+ // ShowApp();
+ // }
+ // else
+ // {
+ // this.Visibility = Visibility.Collapsed;
+ // }
+ // }
- }
+ //}
void MainWindow_Resize(object sender, System.EventArgs e)
diff --git a/Properties/app.manifest b/Properties/app.manifest
new file mode 100644
index 0000000..897adce
--- /dev/null
+++ b/Properties/app.manifest
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Thread/UpdateThread.cs b/Thread/UpdateThread.cs
index 7190959..dc6f972 100644
--- a/Thread/UpdateThread.cs
+++ b/Thread/UpdateThread.cs
@@ -1,4 +1,5 @@
using GeekDesk.Constant;
+using GeekDesk.Control.Windows;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using Newtonsoft.Json.Linq;
@@ -9,6 +10,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using System.Windows;
namespace GeekDesk.Thread
{
@@ -46,15 +48,17 @@ namespace GeekDesk.Thread
string onlineVersion = jo["version"].ToString();
if (onlineVersion.CompareTo(nowVersion) > 0)
{
- //检测到版本更新
+ App.Current.Dispatcher.Invoke((Action)(() =>
+ {
+ //检测到版本更新
+ UpdateWindow.Show(jo);
+ }));
}
}
- } catch (Exception)
+ } catch (Exception e)
{
-
+ MessageBox.Show(e.Message);
}
-
-
}
}
}
diff --git a/Update.json b/Update.json
index 5ce2ae6..9e476e9 100644
--- a/Update.json
+++ b/Update.json
@@ -1,5 +1,9 @@
{
- "version" : "1.0-beta",
- "msg" : "",
- "log" : ""
+ "title" : "",
+ "subTitle" : "",
+ "msgTitle" : "",
+ "msg" : [],
+ "githubUrl" : "",
+ "giteeUrl" : "",
+ "version": ""
}
\ No newline at end of file
diff --git a/Util/FileIcon.cs b/Util/FileIcon.cs
index 2816f5c..c85d515 100644
--- a/Util/FileIcon.cs
+++ b/Util/FileIcon.cs
@@ -47,7 +47,7 @@ namespace GeekDesk.Util
public static IntPtr GetJumboIcon(int iImage)
{
IImageList spiml = null;
- Guid guil = new Guid(IID_IImageList2);//or IID_IImageList
+ Guid guil = new Guid(IID_IImageList);//or IID_IImageList
Shell32.SHGetImageList(Shell32.SHIL_JUMBO, ref guil, ref spiml);
IntPtr hIcon = IntPtr.Zero;
diff --git a/Util/HttpUtil.cs b/Util/HttpUtil.cs
index 6b29485..9a96fa2 100644
--- a/Util/HttpUtil.cs
+++ b/Util/HttpUtil.cs
@@ -13,6 +13,8 @@ namespace GeekDesk.Util
#region Get请求
public static string Get(string url)
{
+ ServicePointManager.Expect100Continue = true;
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
//创建Web访问对 象
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
//通过Web访问对象获取响应内容
diff --git a/Util/ShellContextMenu.cs b/Util/ShellContextMenu.cs
deleted file mode 100644
index d4067f6..0000000
--- a/Util/ShellContextMenu.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using SharpShell.SharpContextMenu;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace GeekDesk.Util
-{
- class ShellContextMenu : SharpContextMenu
- {
- protected override bool CanShowMenu()
- {
- throw new NotImplementedException();
- }
-
- protected override ContextMenuStrip CreateMenu()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/Util/StringUtil.cs b/Util/StringUtil.cs
index 5e281d6..33c54c2 100644
--- a/Util/StringUtil.cs
+++ b/Util/StringUtil.cs
@@ -10,9 +10,9 @@ namespace GeekDesk.Util
{
- public static bool IsEmpty(string str)
+ public static bool IsEmpty(object str)
{
- if (str == null || str.Length == 0 || str.Trim().Length == 0)
+ if (str == null || str.ToString().Length == 0 || str.ToString().Trim().Length == 0)
{
return true;
}
diff --git a/packages.config b/packages.config
index d53a471..f79c0b0 100644
--- a/packages.config
+++ b/packages.config
@@ -1,11 +1,7 @@
-
-
-
-
\ No newline at end of file