From 10241782879a18e7325c90b7cbc9b27e0379cb50 Mon Sep 17 00:00:00 2001
From: SeaLoong <984391132@qq.com>
Date: Wed, 30 Sep 2020 13:08:42 +0800
Subject: [PATCH] v1.1.0.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
禁止重复运行
优化启动逻辑
---
drcom4scutGUI/MainWindow.xaml.cs | 36 ++++++++++++++++++++----
drcom4scutGUI/Properties/AssemblyInfo.cs | 4 +--
drcom4scutGUI/drcom4scutGUI.csproj | 22 +++++++++++++++
3 files changed, 54 insertions(+), 8 deletions(-)
diff --git a/drcom4scutGUI/MainWindow.xaml.cs b/drcom4scutGUI/MainWindow.xaml.cs
index f5b781d..5fc6845 100644
--- a/drcom4scutGUI/MainWindow.xaml.cs
+++ b/drcom4scutGUI/MainWindow.xaml.cs
@@ -89,6 +89,10 @@ private void InitNetworkInterface()
}
}
}
+ if (this.mac != null && this.comboBox_MAC.SelectedIndex < 0)
+ {
+ this.comboBox_MAC.SelectedIndex = this.comboBox_MAC.Items.Add(this.mac);
+ }
}
private void InitUI()
@@ -181,21 +185,29 @@ private void GetCoreVersion()
private void Window_Loaded(object sender, RoutedEventArgs e)
{
- LoadConfig();
- InitTray();
- InitUI();
+ if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
+ {
+ this.IsEnabled = false;
+ MessageBox.Show("程序已在运行!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ System.Windows.Application.Current.Shutdown(0);
+ return;
+ }
GetCoreVersion();
QuitPreviousCore();
if (this.core == null)
{
this.IsEnabled = false;
MessageBox.Show("未找到核心程序 drcom4scut.exe,无法使用!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
- label.Content = "未找到核心程序 drcom4scut.exe,无法使用!";
+ System.Windows.Application.Current.Shutdown(0);
+ return;
}
else
{
this.Title = "drcom4scutGUI - core: " + this.core;
}
+ LoadConfig();
+ InitTray();
+ InitUI();
if (this.autoLogin)
{
StartCoreProcess();
@@ -204,7 +216,10 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
- this.notifyIcon.Visible = false;
+ if (this.notifyIcon != null)
+ {
+ this.notifyIcon.Visible = false;
+ }
try
{
if (process != null) process.Kill();
@@ -317,9 +332,18 @@ private void StartCoreProcess()
string s = match.Groups[1].Value;
if (this.success)
{
+ if (s.Contains("ignore"))
+ {
+ return;
+ }
+ string text = "出现错误,但是保持核心程序运行。";
+ if (s.Contains("Will try reconnect at the next"))
+ {
+ text = s;
+ }
this.Dispatcher.BeginInvoke(new NoArgDelegate(() =>
{
- label.Content = "出现错误,但是保持连接。";
+ label.Content = text;
this.notifyIcon.ShowBalloonTip(5000, "错误", s, ToolTipIcon.Error);
}));
return;
diff --git a/drcom4scutGUI/Properties/AssemblyInfo.cs b/drcom4scutGUI/Properties/AssemblyInfo.cs
index 15999b6..674be74 100644
--- a/drcom4scutGUI/Properties/AssemblyInfo.cs
+++ b/drcom4scutGUI/Properties/AssemblyInfo.cs
@@ -51,5 +51,5 @@
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.1.0.0")]
+[assembly: AssemblyFileVersion("1.1.0.0")]
diff --git a/drcom4scutGUI/drcom4scutGUI.csproj b/drcom4scutGUI/drcom4scutGUI.csproj
index 061f616..cb67a13 100644
--- a/drcom4scutGUI/drcom4scutGUI.csproj
+++ b/drcom4scutGUI/drcom4scutGUI.csproj
@@ -14,6 +14,21 @@
4
true
+ false
+ publish\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ 0
+ 1.0.0.%2a
+ false
+ true
AnyCPU
@@ -122,5 +137,12 @@
+
+
+ False
+ .NET Framework 3.5 SP1
+ false
+
+
\ No newline at end of file