diff --git a/App.xaml.cs b/App.xaml.cs
index 4c7ba9a..9446f2b 100644
--- a/App.xaml.cs
+++ b/App.xaml.cs
@@ -1,4 +1,5 @@
-using Microsoft.Win32;
+using GeekDesk.Constant;
+using Microsoft.Win32;
using System;
using System.IO;
using System.Windows;
@@ -23,96 +24,17 @@ namespace GeekDesk
{
bool ret;
- mutex = new System.Threading.Mutex(true, "GeekDesk", out ret);
+ mutex = new System.Threading.Mutex(true, Constants.MY_NAME, out ret);
if (!ret)
{
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;
diff --git a/Constant/Constants.cs b/Constant/Constants.cs
index 17cf5c1..895b1f7 100644
--- a/Constant/Constants.cs
+++ b/Constant/Constants.cs
@@ -9,6 +9,9 @@ namespace GeekDesk.Constant
public class Constants
{
public static string APP_DIR = AppDomain.CurrentDomain.BaseDirectory.Trim();
+
+ public static string MY_NAME = "GeekDesk";
+
///
/// app数据文件路径
///
diff --git a/Control/UserControls/Config/AboutControl.xaml b/Control/UserControls/Config/AboutControl.xaml
index 83d2329..e05472d 100644
--- a/Control/UserControls/Config/AboutControl.xaml
+++ b/Control/UserControls/Config/AboutControl.xaml
@@ -25,7 +25,7 @@
Command="hc:ControlCommands.OpenLink"
CommandParameter="https://github.com/Demo-Liu/GeekDesk"
Margin="0,0,10,0" Color="#24292F"/>
-
@@ -63,7 +63,7 @@
-
+
diff --git a/Control/UserControls/Config/OtherControl.xaml b/Control/UserControls/Config/OtherControl.xaml
new file mode 100644
index 0000000..55c80b1
--- /dev/null
+++ b/Control/UserControls/Config/OtherControl.xaml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Control/UserControls/Config/OtherControl.xaml.cs b/Control/UserControls/Config/OtherControl.xaml.cs
new file mode 100644
index 0000000..ed293c0
--- /dev/null
+++ b/Control/UserControls/Config/OtherControl.xaml.cs
@@ -0,0 +1,37 @@
+using GeekDesk.Constant;
+using GeekDesk.Util;
+using GeekDesk.ViewModel;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace GeekDesk.Control.UserControls.Config
+{
+ ///
+ /// OtherControl.xaml 的交互逻辑
+ ///
+ public partial class OtherControl : UserControl
+ {
+ public OtherControl()
+ {
+ InitializeComponent();
+ }
+
+ private void SelfStartUpBox_Click(object sender, RoutedEventArgs e)
+ {
+ AppConfig appConfig = MainWindow.appData.AppConfig;
+ RegisterUtil.SetSelfStarting(appConfig.SelfStartUp, Constants.MY_NAME);
+ }
+ }
+}
diff --git a/Control/Windows/ConfigWindow.xaml b/Control/Windows/ConfigWindow.xaml
index 2d0aadf..18a4478 100644
--- a/Control/Windows/ConfigWindow.xaml
+++ b/Control/Windows/ConfigWindow.xaml
@@ -103,6 +103,21 @@
/>
+
+
+
+
+
diff --git a/Control/Windows/ConfigWindow.xaml.cs b/Control/Windows/ConfigWindow.xaml.cs
index 2e63ac8..7e634ad 100644
--- a/Control/Windows/ConfigWindow.xaml.cs
+++ b/Control/Windows/ConfigWindow.xaml.cs
@@ -18,6 +18,7 @@ namespace GeekDesk.Control.Windows
private static AboutControl about = new AboutControl();
private static ThemeControl theme = new ThemeControl();
private static MotionControl motion = new MotionControl();
+ private static OtherControl other = new OtherControl();
public MainWindow mainWindow;
private ConfigWindow(AppConfig appConfig, MainWindow mainWindow)
@@ -64,6 +65,9 @@ namespace GeekDesk.Control.Windows
case "Theme":
RightCard.Content = theme;
break;
+ case "Other":
+ RightCard.Content = other;
+ break;
default:
RightCard.Content = about;
break;
diff --git a/GeekDesk.csproj b/GeekDesk.csproj
index 6b0d30d..5c40dfc 100644
--- a/GeekDesk.csproj
+++ b/GeekDesk.csproj
@@ -102,6 +102,9 @@
CustomIconUrlDialog.xaml
+
+ OtherControl.xaml
+
TodoControl.xaml
@@ -165,6 +168,7 @@
+
@@ -182,6 +186,10 @@
MSBuild:Compile
Designer
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index bec1707..b140da9 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -69,6 +69,11 @@ namespace GeekDesk
}
RegisterHotKey(true);
//RegisterCreateToDoHotKey(true);
+
+ if (!appData.AppConfig.SelfStartUped)
+ {
+ RegisterUtil.SetSelfStarting(appData.AppConfig.SelfStartUp, Constants.MY_NAME);
+ }
UpdateThread.Update();
}
diff --git a/Resource/Dictionary/Geometry.xaml b/Resource/Dictionary/Geometry.xaml
index 801b280..98e8bac 100644
--- a/Resource/Dictionary/Geometry.xaml
+++ b/Resource/Dictionary/Geometry.xaml
@@ -33,5 +33,17 @@
M760.844227 482.947384l227.272092-215.929406a116.216042 116.216042 0 0 0 0-164.329483l-56.713429-56.713429a116.216042 116.216042 0 0 0-162.144622-2.068645l-221.995883 210.792657-215.673731-230.363439-1.766484-1.836213A75.958805 75.958805 0 0 0 222.392061 22.057805L60.526358 183.923508a75.912319 75.912319 0 0 0-1.30162 105.593896l212.442925 226.946687-200.867807 190.803497a116.216042 116.216042 0 0 0-33.098329 57.73613L3.7432 909.971609a76.888533 76.888533 0 0 0 96.529044 91.276079l139.738169-41.163722a116.843609 116.843609 0 0 0 47.2302-27.217797l198.032135-188.153772 238.521805 254.838537 1.766484 1.836213a75.958805 75.958805 0 0 0 107.430109 0.441621l161.865703-161.865703a75.912319 75.912319 0 0 0 1.30162-105.593896zM283.475213 833.129562L177.90456 727.558909a36.886972 36.886972 0 0 0-11.482145-7.600529L690.74271 221.833181l110.428483 110.428483a34.399948 34.399948 0 0 0 5.578371 3.718913z m537.452708-734.95025a41.233452 41.233452 0 0 1 57.550184 0.743783l56.713428 56.713428a41.419397 41.419397 0 0 1-0.743783 59.03775l-75.610156 71.658811a35.492379 35.492379 0 0 0-4.648642-7.158908l-109.196593-109.057134zM247.169321 380.630781a37.189133 37.189133 0 0 0 25.892934-10.877822l56.225322-56.225321a37.491295 37.491295 0 0 0-52.994516-52.994515l-56.225321 56.225321a37.189133 37.189133 0 0 0-10.459443 23.731316l-95.62256-102.270117c-0.604323-0.604323-0.604323-1.208647-0.418378-1.348106l161.865704-161.91219c0.139459-0.139459 0.790269-0.139459 1.464322 0.488107l215.999136 230.758573-166.862994 158.518682zM79.074438 929.309958a1.8827 1.8827 0 0 1-2.324321-2.324321l33.958328-144.96789a41.558857 41.558857 0 0 1 6.22918-13.457818 37.189133 37.189133 0 0 0 7.902691 11.877279l103.432277 103.432278a41.070749 41.070749 0 0 1-9.297283 4.160534l-139.784656 41.186965z m700.922193 19.524295c-0.139459 0.139459-0.790269 0.139459-1.464322-0.488107l-147.12951-157.170575a36.58481 36.58481 0 0 0 16.502678-9.041608l56.225321-56.225322a37.491295 37.491295 0 1 0-52.994515-52.994515l-56.225321 56.225321a37.189133 37.189133 0 0 0-8.553501 13.945925l-46.742092-49.972898L706.478362 534.593793 941.443956 785.620444c0.557837 0.604323 0.557837 1.208647 0.418378 1.348106l-161.819217 161.865703z
+
+ M512 0c282.775704 0 512 229.224296 512 512S794.775704 1024 512 1024 0 794.775704 0 512 229.224296 0 512 0zM303.407407 455.111111a56.888889 56.888889 0 1 0 0 113.777778 56.888889 56.888889 0 0 0 0-113.777778z m208.592593 0a56.888889 56.888889 0 1 0 0 113.777778 56.888889 56.888889 0 0 0 0-113.777778z m208.592593 0a56.888889 56.888889 0 1 0 0 113.777778 56.888889 56.888889 0 0 0 0-113.777778z
+
+
+
+ M512 0C230.4 0 0 230.4 0 512s230.4 512 512 512 512-230.4 512-512S793.6 0 512 0z m284.8 313.6c0 12.8-12.8 25.6-25.6 25.6H416c-41.6 0-76.8 35.2-76.8 76.8v243.2c0 12.8 12.8 25.6 25.6 25.6h240c41.6 0 76.8-35.2 76.8-76.8v-12.8c0-12.8-12.8-25.6-25.6-25.6H480c-12.8 0-25.6-12.8-25.6-25.6v-64c0-12.8 12.8-25.6 25.6-25.6h291.2c12.8 0 25.6 12.8 25.6 25.6v144c0 92.8-76.8 169.6-169.6 169.6H252.8c-12.8 0-25.6-12.8-25.6-25.6V412.8C227.2 310.4 310.4 224 416 224h355.2c12.8 0 25.6 12.8 25.6 25.6v64z
+
+
+
+ M1021.72444445 512a495.16088889 495.16088889 0 0 1-97.57582223 299.64515555 500.62222222 500.62222222 0 0 1-250.85724444 184.22897778 30.58346667 30.58346667 0 0 1-26.2144-4.73315555 25.85031111 25.85031111 0 0 1-8.00995556-20.02488889v-139.81013334a119.05706667 119.05706667 0 0 0-34.58844444-94.29902222 473.31555555 473.31555555 0 0 0 67.72053333-11.65084444 248.30862222 248.30862222 0 0 0 62.2592-26.2144 187.50577778 187.50577778 0 0 0 53.52106667-43.69066667 209.35111111 209.35111111 0 0 0 36.40888889-69.90506667 334.2336 334.2336 0 0 0 13.83537778-100.12444444 191.87484445 191.87484445 0 0 0-52.7928889-136.53333333 176.21902222 176.21902222 0 0 0-5.09724444-135.44106667 87.01724445 87.01724445 0 0 0-53.52106666 7.28177778 341.87946667 341.87946667 0 0 0-61.16693334 29.12711111l-25.12213333 15.65582222a473.31555555 473.31555555 0 0 0-254.86222223 0c-7.28177778-5.09724445-16.384-10.55857778-28.03484444-17.84035555A371.00657778 371.00657778 0 0 0 300.82844445 220.72888889a94.29902222 94.29902222 0 0 0-57.16195556-9.10222222 178.40355555 178.40355555 0 0 0-4.73315556 136.53333333 197.70026667 197.70026667 0 0 0-52.4288 137.26151111A327.68 327.68 0 0 0 200.33991111 584.81777778a223.55057778 223.55057778 0 0 0 36.40888889 69.90506667 172.94222222 172.94222222 0 0 0 53.52106667 44.41884444 304.7424 304.7424 0 0 0 62.2592 26.2144 471.13102222 471.13102222 0 0 0 68.08462222 11.65084444 105.22168889 105.22168889 0 0 0-32.768 68.44871112 112.86755555 112.86755555 0 0 1-30.21937778 9.4663111 190.41848889 190.41848889 0 0 1-36.40888889 3.2768A78.6432 78.6432 0 0 1 274.61404445 803.27111111a124.5184 124.5184 0 0 1-36.4088889-41.50613333 109.22666667 109.22666667 0 0 0-32.03982222-34.58844445 91.7504 91.7504 0 0 0-32.768-16.01991111h-13.1072a47.33155555 47.33155555 0 0 0-19.29671111 2.91271111q-5.46133333 3.2768-3.2768 7.64586667a50.24426667 50.24426667 0 0 0 6.18951111 9.10222222 62.98737778 62.98737778 0 0 0 8.73813334 8.37404445l4.73315555 2.91271111a88.83768889 88.83768889 0 0 1 29.12711111 25.12213333 179.49582222 179.49582222 0 0 1 20.75306667 33.49617778l6.5536 15.29173333a82.28408889 82.28408889 0 0 0 29.12711111 41.14204445 109.22666667 109.22666667 0 0 0 44.05475556 18.93262222 223.18648889 223.18648889 0 0 0 45.8752 4.73315556 207.16657778 207.16657778 0 0 0 36.40888888-2.54862223l15.29173334-2.54862222v95.39128889a26.2144 26.2144 0 0 1-8.73813334 20.02488889 31.67573333 31.67573333 0 0 1-26.57848888 4.73315555 498.43768889 498.43768889 0 0 1-249.40088889-185.32124444A486.78684445 486.78684445 0 0 1 2.27555555 512a497.70951111 497.70951111 0 0 1 68.44871112-254.86222222A504.6272 504.6272 0 0 1 257.13777778 70.72426667 497.70951111 497.70951111 0 0 1 512 2.27555555a497.70951111 497.70951111 0 0 1 254.86222222 68.44871112A504.6272 504.6272 0 0 1 953.27573333 257.13777778 496.98133333 496.98133333 0 0 1 1021.72444445 512z
+
+
\ No newline at end of file
diff --git a/Util/RegisterUtil.cs b/Util/RegisterUtil.cs
new file mode 100644
index 0000000..99c5abb
--- /dev/null
+++ b/Util/RegisterUtil.cs
@@ -0,0 +1,82 @@
+using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GeekDesk.Util
+{
+ class RegisterUtil
+ {
+
+ #region 注册表开机自启动
+ ///
+ /// 开机自动启动
+ ///
+ /// 设置开机启动,或取消开机启动
+ /// 注册表中的名称
+ /// 开启或停用是否成功
+ public static 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
+ }
+}
diff --git a/ViewModel/AppConfig.cs b/ViewModel/AppConfig.cs
index 20a4663..0eb178d 100644
--- a/ViewModel/AppConfig.cs
+++ b/ViewModel/AppConfig.cs
@@ -54,9 +54,39 @@ namespace GeekDesk.ViewModel
private UpdateType updateType = UpdateType.Gitee; //更新源 默认gitee源
+ private bool selfStartUp = true; //开机自启动设置
+ private bool selfStartUped = false; //是否已设置
+
#region GetSet
+ public bool SelfStartUped
+ {
+ get
+ {
+ return selfStartUped;
+ }
+ set
+ {
+ selfStartUped = value;
+ OnPropertyChanged("SelfStartUped");
+ }
+ }
+
+ public bool SelfStartUp
+ {
+ get
+ {
+ return selfStartUp;
+ }
+ set
+ {
+ selfStartUp = value;
+ selfStartUped = true;
+ OnPropertyChanged("SelfStartUp");
+ }
+ }
+
public Key ToDoHotkey
{
get