diff --git a/App.config b/App.config
index 4a166e8..faec5df 100644
--- a/App.config
+++ b/App.config
@@ -61,15 +61,16 @@
-
+
-
+
+
diff --git a/App.xaml.cs b/App.xaml.cs
index 1701231..4a63eea 100644
--- a/App.xaml.cs
+++ b/App.xaml.cs
@@ -1,8 +1,14 @@
using GeekDesk.Constant;
+using GeekDesk.MyThread;
using GeekDesk.Util;
+using GeekDesk.ViewModel;
+using Microsoft.Win32;
using System;
+using System.Diagnostics;
using System.Windows;
using System.Windows.Input;
+using System.Windows.Interop;
+using System.Windows.Media;
using System.Windows.Threading;
namespace GeekDesk
@@ -20,10 +26,13 @@ namespace GeekDesk
this.Startup += new StartupEventHandler(App_Startup);
Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
+ SystemEvents.PowerModeChanged += OnPowerModeChanged;
}
+
private void App_Startup(object sender, StartupEventArgs e)
{
+ //RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly; //禁用硬件加速
mutex = new System.Threading.Mutex(true, Constants.MY_NAME, out bool ret);
if (!ret)
{
@@ -40,6 +49,25 @@ namespace GeekDesk
}
}
+
+ //电源监听
+ private void OnPowerModeChanged(object sender, PowerModeChangedEventArgs e)
+ {
+ switch (e.Mode)
+ {
+ case PowerModes.Resume:
+ // 系统从休眠状态唤醒
+ LogUtil.WriteLog("System resumed from sleep.");
+ ProcessUtil.ReStartApp();
+ break;
+ case PowerModes.Suspend:
+ // 系统进入休眠状态
+ LogUtil.WriteLog("System is going to sleep.");
+ break;
+ }
+ }
+
+
void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
e.Handled = true;//使用这一行代码告诉运行时,该异常被处理了,不再作为UnhandledException抛出了。
diff --git a/Constant/Constants.cs b/Constant/Constants.cs
index 95e22be..513ddd5 100644
--- a/Constant/Constants.cs
+++ b/Constant/Constants.cs
@@ -22,11 +22,15 @@ namespace GeekDesk.Constant
///
/// 备份文件路径
///
- public static string DATA_FILE_BAK_PATH = APP_DIR + "bak\\Data.bak"; //app备份数据文件路径
+ public static string DATA_FILE_BAK_DIR_PATH = APP_DIR + "bak"; //app备份数据文件路径
+ public static string DATA_FILE_TEMP_DIR_PATH = APP_DIR + "temp"; //app临时缓存文件路径
+
+ //public static string DATA_FILE_BAK_PATH = DATA_FILE_BAK_DIR_PATH + "\\Data.bak"; //app备份数据文件路径
+
public static string PW_FILE_BAK_PATH = APP_DIR + "bak\\pw.txt"; //密码文件路径
-
- public static string UUID_FILE_BAK_PATH = APP_DIR + "bak\\uuid.txt"; //密码文件路径
+
+ public static string UUID_FILE_BAK_PATH = APP_DIR + "bak\\uuid.txt"; //uuid文件路径
public static string LOG_FILE_PATH = APP_DIR + "logs\\log.log"; //日志文件
diff --git a/Constant/DictConst.cs b/Constant/DictConst.cs
new file mode 100644
index 0000000..221600e
--- /dev/null
+++ b/Constant/DictConst.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GeekDesk.Constant
+{
+ public class DictConst
+ {
+ public static readonly Dictionary batchMenuHeaderDict = new Dictionary();
+ static DictConst() {
+ batchMenuHeaderDict.Add(true, "取消批量操作");
+ batchMenuHeaderDict.Add(false, "批量操作");
+ }
+ }
+}
diff --git a/Control/Other/BGNmaeDialog.xaml b/Control/Other/BGNmaeDialog.xaml
new file mode 100644
index 0000000..772ea71
--- /dev/null
+++ b/Control/Other/BGNmaeDialog.xaml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Control/Other/BGNmaeDialog.xaml.cs b/Control/Other/BGNmaeDialog.xaml.cs
new file mode 100644
index 0000000..c78fce8
--- /dev/null
+++ b/Control/Other/BGNmaeDialog.xaml.cs
@@ -0,0 +1,42 @@
+using GeekDesk.Constant;
+using GeekDesk.Util;
+using GeekDesk.ViewModel;
+using Microsoft.Win32;
+using System;
+using System.Windows;
+using System.Windows.Media.Imaging;
+
+
+namespace GeekDesk.Control.Other
+{
+ ///
+ /// TextDialog.xaml 的交互逻辑
+ ///
+ public partial class BGNmaeDialog
+ {
+ public HandyControl.Controls.Dialog dialog;
+
+ public BGNmaeDialog()
+ {
+ InitializeComponent();
+ }
+
+ ///
+ /// 保存
+ ///
+ ///
+ ///
+ private void Save(object sender, RoutedEventArgs e)
+ {
+ GradientBGParam bg = new GradientBGParam();
+ bg.Id = Guid.NewGuid().ToString();
+ bg.Name = BGName.Text;
+ bg.Color1 = MainWindow.appData.AppConfig.GradientBGParam.Color1;
+ bg.Color2 = MainWindow.appData.AppConfig.GradientBGParam.Color2;
+ MainWindow.appData.AppConfig.CustomBGParams.Add(bg);
+ MainWindow.appData.AppConfig.CustomBGParams = DeepCopyUtil.DeepCopy(MainWindow.appData.AppConfig.CustomBGParams);
+ dialog.Close();
+ }
+
+ }
+}
diff --git a/Control/Other/GradientBGDialog.xaml b/Control/Other/GradientBGDialog.xaml
index 3f2bd22..c072381 100644
--- a/Control/Other/GradientBGDialog.xaml
+++ b/Control/Other/GradientBGDialog.xaml
@@ -20,19 +20,27 @@
Width="600"
Height="400"
Margin="0,-620,0,0">
+
+
+
+ ItemsSource="{Binding}"
+ Background="Transparent"
+ Margin="20,20,20,50"
+ BorderThickness="0"
+ >
+
+
+
+
+
@@ -40,6 +48,7 @@
+
bgArr = DeepCopyUtil.DeepCopy(GradientBGParamList.GradientBGParams);
+ foreach(var bg in MainWindow.appData.AppConfig.CustomBGParams)
+ {
+ bgArr.Add(bg);
+ }
+
+ this.DataContext = DeepCopyUtil.DeepCopy(bgArr);
InitializeComponent();
}
@@ -45,8 +53,38 @@ namespace GeekDesk.Control.Other
}
}
-
-
-
+ private void Delete(object sender, RoutedEventArgs e)
+ {
+ HandyControl.Controls.Growl.Ask("确认删除吗?", isConfirmed =>
+ {
+ if (isConfirmed)
+ {
+ GradientBGParam bg = (GradientBGParam)(((MenuItem)sender).Tag);
+ ObservableCollection bgArr = (ObservableCollection)this.DataContext;
+ bgArr.Remove(bg);
+ MainWindow.appData.AppConfig.CustomBGParams.Remove(bg);
+ for (int i = MainWindow.appData.AppConfig.CustomBGParams.Count - 1; i >= 0; i--)
+ {
+ var cbg = MainWindow.appData.AppConfig.CustomBGParams[i];
+ if (cbg.Id == null)
+ {
+ if (cbg.Color1.Equals(bg.Color1) && cbg.Color2.Equals(bg.Color2))
+ {
+ MainWindow.appData.AppConfig.CustomBGParams.RemoveAt(i);
+ }
+ } else
+ {
+ if (cbg.Id.Equals(bg.Id))
+ {
+ MainWindow.appData.AppConfig.CustomBGParams.RemoveAt(i);
+ }
+ }
+
+ }
+ MainWindow.appData.AppConfig.CustomBGParams = DeepCopyUtil.DeepCopy(MainWindow.appData.AppConfig.CustomBGParams);
+ }
+ return true;
+ }, "ConfigWindowAskGrowl");
+ }
}
}
diff --git a/Control/UserControls/Config/ThemeControl.xaml b/Control/UserControls/Config/ThemeControl.xaml
index 2ac84e5..5f021f6 100644
--- a/Control/UserControls/Config/ThemeControl.xaml
+++ b/Control/UserControls/Config/ThemeControl.xaml
@@ -16,6 +16,7 @@
+
@@ -70,7 +71,8 @@
-
+
-
+
-
+
+
+
@@ -133,6 +142,10 @@
+
+
+
+
@@ -216,6 +229,7 @@
+
diff --git a/Control/UserControls/Config/ThemeControl.xaml.cs b/Control/UserControls/Config/ThemeControl.xaml.cs
index 64c3f66..509a292 100644
--- a/Control/UserControls/Config/ThemeControl.xaml.cs
+++ b/Control/UserControls/Config/ThemeControl.xaml.cs
@@ -167,6 +167,16 @@ namespace GeekDesk.Control.UserControls.Config
}
appConfig.IsShow = null;
}
-
+
+ ///
+ /// 保存当前颜色到系统预设
+ ///
+ ///
+ ///
+ private void NewBGBtn_Click(object sender, RoutedEventArgs e)
+ {
+ BGNmaeDialog dialog = new BGNmaeDialog();
+ dialog.dialog = HandyControl.Controls.Dialog.Show(dialog, "ConfigWindowDialog");
+ }
}
}
diff --git a/Control/UserControls/PannelCard/LeftCardControl.xaml.cs b/Control/UserControls/PannelCard/LeftCardControl.xaml.cs
index 555a25e..d60fed5 100644
--- a/Control/UserControls/PannelCard/LeftCardControl.xaml.cs
+++ b/Control/UserControls/PannelCard/LeftCardControl.xaml.cs
@@ -463,6 +463,10 @@ namespace GeekDesk.Control.UserControls.PannelCard
{
int index = MenuListBox.ItemContainerGenerator.IndexFromContainer(lbi);
MenuListBox.SelectedIndex = index;
+ if (appData.AppConfig.IconBatch_NoWrite)
+ {
+ appData.AppConfig.IconBatch_NoWrite = false;
+ }
}
});
});
@@ -487,6 +491,12 @@ namespace GeekDesk.Control.UserControls.PannelCard
MenuInfo mi = lbi.DataContext as MenuInfo;
int index = MenuListBox.Items.IndexOf(mi);
MenuListBox.SelectedIndex = index;
+
+ if (appData.AppConfig.IconBatch_NoWrite)
+ {
+ appData.AppConfig.IconBatch_NoWrite = false;
+ MainWindow.mainWindow.RightCard.IconListBox.SelectionMode = SelectionMode.Extended;
+ }
}
diff --git a/Control/UserControls/PannelCard/RightCardControl.xaml b/Control/UserControls/PannelCard/RightCardControl.xaml
index 724e696..fde22ec 100644
--- a/Control/UserControls/PannelCard/RightCardControl.xaml
+++ b/Control/UserControls/PannelCard/RightCardControl.xaml
@@ -111,6 +111,10 @@
+
+
+
+
@@ -148,6 +152,8 @@
+
+
@@ -169,6 +175,7 @@
ItemsSource="{Binding AppConfig.SelectedMenuIcons, Mode=OneWay}"
BorderThickness="0"
Padding="0,10,0,0"
+ SelectionChanged="IconListBox_SelectionChanged"
ScrollViewer.CanContentScroll ="True"
VirtualizingPanel.VirtualizationMode="Recycling"
VirtualizingPanel.IsVirtualizing="True"
@@ -223,7 +230,12 @@
-
+
+
@@ -247,12 +259,16 @@
MouseLeftButtonDown="Icon_MouseLeftButtonDown"
MouseLeftButtonUp="Icon_MouseLeftButtonUp"
>
+
+
diff --git a/Control/UserControls/PannelCard/RightCardControl.xaml.cs b/Control/UserControls/PannelCard/RightCardControl.xaml.cs
index 9aa39e2..c57b56d 100644
--- a/Control/UserControls/PannelCard/RightCardControl.xaml.cs
+++ b/Control/UserControls/PannelCard/RightCardControl.xaml.cs
@@ -7,10 +7,12 @@ using GeekDesk.Util;
using GeekDesk.ViewModel;
using GeekDesk.ViewModel.Temp;
using HandyControl.Controls;
+using Newtonsoft.Json.Linq;
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
+using System.Linq;
using System.Reflection;
using System.Threading;
using System.Windows;
@@ -105,6 +107,11 @@ namespace GeekDesk.Control.UserControls.PannelCard
private void Icon_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
+ if (appData.AppConfig.IconBatch_NoWrite)
+ {
+
+ return;
+ }
if (appData.AppConfig.DoubleOpen)
{
IconClick(sender, e);
@@ -113,6 +120,18 @@ namespace GeekDesk.Control.UserControls.PannelCard
private void Icon_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
+ //Console.WriteLine("选中:" + IconListBox.SelectedItems.Count);
+ if (appData.AppConfig.IconBatch_NoWrite)
+ {
+ //查找checkbox更改选中状态
+ Panel p = sender as Panel;
+ var ens = p.Children.OfType();
+ foreach (CheckBox cb in ens)
+ {
+ cb.IsChecked = !cb.IsChecked;
+ }
+ return;
+ }
if (!appData.AppConfig.DoubleOpen)
{
IconClick(sender, e);
@@ -352,9 +371,14 @@ namespace GeekDesk.Control.UserControls.PannelCard
Panel sp = sender as Panel;
DependencyObject dos = sp.Parent;
+ Image img = null;
- Image img = sp.Children[0] as Image;
+ foreach (var imgBak in sp.Children.OfType())
+ {
+ img = (Image)imgBak;
+ }
+ if (img == null) return;
double afterHeight = img.Height;
double afterWidth = img.Width;
@@ -683,6 +707,39 @@ namespace GeekDesk.Control.UserControls.PannelCard
MyPoptip.VerticalOffset = 30;
}
+ ///
+ /// 控制图标标题显示及隐藏
+ ///
+ ///
+ ///
+ private void ShowTitle_Click(object sender, RoutedEventArgs e)
+ {
+ appData.AppConfig.ShowIconTitle = !appData.AppConfig.ShowIconTitle;
+ }
+ ///
+ /// 批量操作
+ ///
+ ///
+ ///
+ private void BatchHandle(object sender, RoutedEventArgs e)
+ {
+ if (!appData.AppConfig.IconBatch_NoWrite)
+ {
+ //开启批量操作时把所有的状态更改为未选中
+ foreach(var ic in IconListBox.Items)
+ {
+ IconInfo info = ic as IconInfo;
+ info.IsChecked_NoWrite = false;
+ }
+ }
+ appData.AppConfig.IconBatch_NoWrite = !appData.AppConfig.IconBatch_NoWrite;
+ IconListBox.SelectionMode = SelectionMode.Multiple;
+ }
+
+ private void IconListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ //Console.WriteLine(sender.ToString());
+ }
}
}
diff --git a/Control/Windows/ConfigWindow.xaml b/Control/Windows/ConfigWindow.xaml
index 788f2d5..e01c625 100644
--- a/Control/Windows/ConfigWindow.xaml
+++ b/Control/Windows/ConfigWindow.xaml
@@ -21,10 +21,13 @@
>
+
+
+
@@ -36,6 +39,7 @@
+
diff --git a/Control/Windows/PixelColorPickerWindow.xaml b/Control/Windows/PixelColorPickerWindow.xaml
index f9bb3e2..d0bd8c9 100644
--- a/Control/Windows/PixelColorPickerWindow.xaml
+++ b/Control/Windows/PixelColorPickerWindow.xaml
@@ -11,6 +11,7 @@
MouseLeftButtonDown="Window_MouseLeftButtonDown"
MouseRightButtonDown="Window_MouseRightButtonDown"
MouseWheel="Window_MouseWheel"
+ Loaded="Window_Loaded"
>