Skip to content

Commit 13fbacb

Browse files
authored
Merge pull request #32 from Demo-Liu/2.4.11
2.4.11
2 parents dee1caa + a03fb71 commit 13fbacb

55 files changed

Lines changed: 1762 additions & 389 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

App.config

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3+
<configSections>
4+
<section name="SystemIcons" type="System.Configuration.DictionarySectionHandler" />
5+
</configSections>
6+
<SystemIcons>
7+
<add key="Calculator" value="计算器" />
8+
<add key="Computer" value="此电脑" />
9+
<add key="GroupPolicy" value="组策略" />
10+
<add key="Network" value="网络连接" />
11+
<add key="RecycleBin" value="回收站" />
12+
<add key="Registry" value="注册表编辑器" />
13+
<add key="Notepad" value="记事本" />
14+
<add key="Mstsc" value="远程桌面连接" />
15+
<add key="Control" value="控制面板" />
16+
<add key="CMD" value="命令行" />
17+
<add key="Services" value="服务" />
18+
</SystemIcons>
319
<startup>
420
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
521
</startup>
@@ -28,12 +44,13 @@
2844
</assemblyBinding>
2945
</runtime>
3046
<appSettings>
31-
<add key="Version" value="2.3.21" />
47+
<add key="Version" value="2.4.11" />
3248
<add key="GitHubUrl" value="https://github.com/Demo-Liu/GeekDesk" />
3349
<add key="GiteeUrl" value="https://gitee.com/demo_liu/GeekDesk/tree/master" />
3450
<add key="GitHubUpdateUrl" value="https://demo-liu.github.io/GeekDesk/Update.json" />
3551
<add key="GiteeUpdateUrl" value="https://demo-liu.github.io/GeekDesk/Update.json" />
3652
<add key="ClientSettingsProvider.ServiceUri" value="" />
53+
<add key="CustomIconTeachUrl" value="https://mp.weixin.qq.com/s/LxoHAekho9HBVl4FRw_Law" />
3754
</appSettings>
3855
<system.web>
3956
<membership defaultProvider="ClientAuthenticationMembershipProvider">

App.xaml.cs

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using GeekDesk.Constant;
2+
using GeekDesk.Util;
23
using Microsoft.Win32;
34
using System;
45
using System.IO;
6+
using System.Text;
57
using System.Windows;
68
using System.Windows.Media.Animation;
79
using System.Windows.Threading;
@@ -19,6 +21,8 @@ public partial class App : Application
1921
public App()
2022
{
2123
this.Startup += new StartupEventHandler(App_Startup);
24+
Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
25+
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
2226
}
2327

2428
private void App_Startup(object sender, StartupEventArgs e)
@@ -35,47 +39,24 @@ private void App_Startup(object sender, StartupEventArgs e)
3539
}
3640
}
3741
}
38-
}
39-
40-
41-
42-
43-
// private void WriteLog(object exception)
44-
// {
45-
// Exception ex = exception as Exception;
46-
47-
// using (FileStream fs = File.Open(".//ErrorLog.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite))
48-
// {
49-
// fs.Seek(0, SeekOrigin.End);
50-
// byte[] buffer = Encoding.Default.GetBytes("-------------------------------------------------------\r\n");
51-
// fs.Write(buffer, 0, buffer.Length);
52-
53-
// buffer = Encoding.Default.GetBytes(DateTime.Now.ToString() + "\r\n");
54-
// fs.Write(buffer, 0, buffer.Length);
55-
56-
// if (ex != null)
57-
// {
58-
// buffer = Encoding.Default.GetBytes("成员名: " + ex.TargetSite + "\r\n");
59-
// fs.Write(buffer, 0, buffer.Length);
6042

61-
// buffer = Encoding.Default.GetBytes("引发异常的类: " + ex.TargetSite.DeclaringType + "\r\n");
62-
// fs.Write(buffer, 0, buffer.Length);
43+
void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
44+
{
45+
e.Handled = true;//使用这一行代码告诉运行时,该异常被处理了,不再作为UnhandledException抛出了。
46+
LogUtil.WriteErrorLog(e, "未捕获异常!");
47+
if (Constants.DEV)
48+
{
49+
MessageBox.Show("GeekDesk遇到一个问题, 不用担心, 这不影响其它操作!");
50+
}
51+
}
6352

64-
// buffer = Encoding.Default.GetBytes("异常信息: " + ex.Message + "\r\n");
65-
// fs.Write(buffer, 0, buffer.Length);
53+
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
54+
{
55+
LogUtil.WriteErrorLog(e, "严重异常!");
56+
MessageBox.Show("GeekDesk遇到未知问题崩溃!");
57+
}
6658

67-
// buffer = Encoding.Default.GetBytes("引发异常的程序集或对象: " + ex.Source + "\r\n");
68-
// fs.Write(buffer, 0, buffer.Length);
6959

70-
// buffer = Encoding.Default.GetBytes("栈:" + ex.StackTrace + "\r\n");
71-
// fs.Write(buffer, 0, buffer.Length);
72-
// }
73-
// else
74-
// {
75-
// buffer = Encoding.Default.GetBytes("应用程序错误: " + exception.ToString() + "\r\n");
76-
// fs.Write(buffer, 0, buffer.Length);
77-
// }
78-
// }
60+
}
7961

80-
//}
8162
}

Constant/Constants.cs

Lines changed: 14 additions & 0 deletions
Large diffs are not rendered by default.

Control/Other/BacklogNotificatin.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<Image Source="/Resource/Image/BacklogImg.png" Margin="22,35,22,361" />
1717

18-
18+
1919
<hc:Card MaxWidth="250" Height="200" BorderThickness="0" Effect="{DynamicResource EffectShadow2}" Margin="8">
2020
<!--Card 的内容部分-->
2121
<Border CornerRadius="4,4,0,0" Width="160" Height="160">

Control/Other/BacklogNotificatin.xaml.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ private void BacklogDone_Click(object sender, RoutedEventArgs e)
4040
if (info.ExecType == TodoTaskExecType.CRON)
4141
{
4242
CronExpression exp = new CronExpression(info.Cron);
43-
DateTime dtNow = DateTime.Now;
44-
DateTimeOffset ddo = DateTime.SpecifyKind(dtNow, DateTimeKind.Local);
45-
string nextExecTime = ddo.LocalDateTime.ToString("yyyy-MM-dd HH:mm:ss");
46-
info.ExeTime = nextExecTime;
43+
DateTime nowTime = DateTime.Now;
4744

48-
DateTime nextTime = ddo.LocalDateTime;
49-
TimeSpan ts = nextTime.Subtract(dtNow);
45+
//计算下次执行时间
46+
DateTime nextTime = DateTime.SpecifyKind(exp.GetNextValidTimeAfter(nowTime).Value.LocalDateTime, DateTimeKind.Local);
47+
48+
string nextTimeStr = nextTime.ToString("yyyy-MM-dd HH:mm:ss");
49+
info.ExeTime = nextTimeStr;
50+
51+
TimeSpan ts = nextTime.Subtract(nowTime);
5052
int minutes = (int)Math.Ceiling(ts.TotalMinutes);
5153
if (minutes < 0)
5254
{
@@ -62,7 +64,8 @@ private void BacklogDone_Click(object sender, RoutedEventArgs e)
6264
{
6365
Growl.SuccessGlobal("下次任务将在 " + minutes + " 分钟后提醒您!");
6466
}
65-
} else
67+
}
68+
else
6669
{
6770
appData.ToDoList.Remove(info); //执行任务删除
6871
appData.HiToDoList.Add(info); //添加历史任务
@@ -120,7 +123,7 @@ private void DelayButton_Click(object sender, RoutedEventArgs e)
120123
ToDoInfo info = this.DataContext as ToDoInfo;
121124
int time = int.Parse(DelayTime.Text);
122125
string type = DelayType.Text;
123-
switch(type)
126+
switch (type)
124127
{
125128
case "分":
126129
info.ExeTime = DateTime.Now.AddMinutes(time).ToString("yyyy-MM-dd HH:mm:ss");

Control/Other/CustomIconUrlDialog.xaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</Border.Resources>
1818
<StackPanel Margin="10">
1919
<Grid Margin="8,20,8,20">
20-
20+
2121
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,-10">
2222
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Center">
2323
<TextBlock Text="SVG 图标地址:" Style="{StaticResource LeftTB}"/>
@@ -35,9 +35,11 @@
3535
</hc:UniformSpacingPanel>
3636
<TextBlock Text="注: 需配置正确的url方可加载远程图标!" Foreground="Red" Margin="10,95,-10,-92" />
3737

38-
<hc:UniformSpacingPanel Spacing="10" Margin="246.206,124.551,-246.206,-124.551">
39-
<Button Content="取消" Command="hc:ControlCommands.Close"
38+
<hc:UniformSpacingPanel Spacing="10" Margin="203,125,-203,-125">
39+
<Button Content="取消" Command="hc:ControlCommands.Close" HorizontalAlignment="Stretch" Margin="-1,1,1,1" VerticalAlignment="Stretch"
4040
/>
41+
<Button Content="教程" Click="Teach_Click"
42+
Style="{StaticResource Btn1}"/>
4143
<Button Content="保存" Click="Confirm_Click"
4244
Command="hc:ControlCommands.Close"
4345
Style="{StaticResource Btn1}"/>

Control/Other/CustomIconUrlDialog.xaml.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
using GeekDesk.ViewModel;
44
using Microsoft.Win32;
55
using System;
6+
using System.Configuration;
7+
using System.Diagnostics;
68
using System.Windows;
79
using System.Windows.Controls;
810
using System.Windows.Media.Imaging;
@@ -32,13 +34,21 @@ private void Confirm_Click(object sender, RoutedEventArgs e)
3234
AppConfig appConfig = this.DataContext as AppConfig;
3335
appConfig.CustomIconJsonUrl = JsonUrl.Text.Trim();
3436
appConfig.CustomIconUrl = IconUrl.Text.Trim();
35-
if (!StringUtil.IsEmpty(IconUrl.Text) && !StringUtil.IsEmpty(JsonUrl.Text))
37+
if (!StringUtil.IsEmpty(IconUrl.Text) && !StringUtil.IsEmpty(JsonUrl.Text))
3638
{
3739
IconfontWindow.vm.IsSettingUrl = "true";
38-
} else
40+
}
41+
else
3942
{
4043
IconfontWindow.vm.IsSettingUrl = "false";
4144
}
4245
}
46+
47+
48+
private void Teach_Click(object sender, RoutedEventArgs e)
49+
{
50+
string url = ConfigurationManager.AppSettings["CustomIconTeachUrl"];
51+
Process.Start(url);
52+
}
4353
}
4454
}

Control/Other/IconInfoDialog.xaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:hc="https://handyorg.github.io/handycontrol"
55
CornerRadius="4"
6-
Width="300"
7-
Height="340"
6+
Width="350"
7+
Height="450"
88
Style="{StaticResource BorderBG}"
99
>
1010
<Border.Resources>
1111
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
12-
<Setter Property="Width" Value="40"/>
12+
<Setter Property="Width" Value="75"/>
1313
<Setter Property="TextAlignment" Value="Center"/>
1414
<Setter Property="HorizontalAlignment" Value="Left"/>
1515
<Setter Property="VerticalAlignment" Value="Center"/>
@@ -22,7 +22,7 @@
2222
<Button Width="22" Height="22" Command="hc:ControlCommands.Close" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top"/>
2323
<hc:UniformSpacingPanel Spacing="10">
2424
<TextBlock Text="名称:" Style="{StaticResource LeftTB}"/>
25-
<TextBox x:Name="IconName" Text="{Binding Name, Mode=OneWay}" Width="180" FontSize="14"/>
25+
<TextBox x:Name="IconName" Text="{Binding Name, Mode=OneWay}" Width="230" FontSize="14"/>
2626
</hc:UniformSpacingPanel>
2727
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black"/>
2828
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
@@ -42,8 +42,12 @@
4242
</CheckBox>
4343
</hc:UniformSpacingPanel>
4444
<hc:Divider LineStrokeDashArray="3,3" LineStroke="Black" Grid.ColumnSpan="4"/>
45+
<hc:UniformSpacingPanel Spacing="10">
46+
<TextBlock Text="启动参数:" Style="{StaticResource LeftTB}"/>
47+
<TextBox x:Name="StartArg" Text="{Binding StartArg, Mode=OneWay}" Width="230" Height="100" TextWrapping="Wrap" FontSize="14"/>
48+
</hc:UniformSpacingPanel>
4549
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
46-
<Button Content="保存" Style="{StaticResource Btn1}" Click="SaveProperty" Margin="208,0,0,0"/>
50+
<Button Content="保存" Style="{StaticResource Btn1}" Click="SaveProperty" Margin="265,10,0,0"/>
4751
</hc:UniformSpacingPanel>
4852
</StackPanel>
4953
</hc:SimplePanel>

Control/Other/IconInfoDialog.xaml.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ private void SaveProperty(object sender, RoutedEventArgs e)
3838
info.BitmapImage = IconImg.Source as BitmapImage;
3939
info.Name = IconName.Text;
4040
info.AdminStartUp = IconIsAdmin.IsChecked.Value;
41+
info.StartArg = StartArg.Text;
4142
CommonCode.SaveAppData(MainWindow.appData);
4243
dialog.Close();
4344
}
@@ -74,11 +75,13 @@ private void EditImage(object sender, RoutedEventArgs e)
7475
info.BitmapImage = ImageUtil.GetBitmapIconByPath(ofd.FileName);
7576
CommonCode.SaveAppData(MainWindow.appData);
7677
}
77-
} catch (Exception)
78+
}
79+
catch (Exception e1)
7880
{
7981
HandyControl.Controls.Growl.WarningGlobal("修改图标失败,已重置为默认图标!");
82+
LogUtil.WriteErrorLog(e1, "修改图标失败!");
8083
}
81-
84+
8285
}
8386
}
8487
}

Control/Other/IconInfoUrlDialog.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ private void EditImage(object sender, RoutedEventArgs e)
8989
info.BitmapImage = ImageUtil.GetBitmapIconByPath(ofd.FileName);
9090
CommonCode.SaveAppData(MainWindow.appData);
9191
}
92-
} catch (Exception)
92+
} catch (Exception ex)
9393
{
9494
HandyControl.Controls.Growl.WarningGlobal("修改图标失败,已重置为默认图标!");
95+
LogUtil.WriteErrorLog(ex, "修改图标失败!");
9596
}
9697

9798
}

0 commit comments

Comments
 (0)