diff --git a/FSGaryityTool_Win11.csproj b/FSGaryityTool_Win11.csproj
index 1842b15..bc70101 100644
--- a/FSGaryityTool_Win11.csproj
+++ b/FSGaryityTool_Win11.csproj
@@ -257,7 +257,7 @@
- 0.2.34
+ 0.2.35
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 9e8248d..3e26577 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -61,7 +61,7 @@ namespace FSGaryityTool_Win11
public sealed partial class MainWindow : Window
{
- public static string FSSoftVersion = "0.2.34";
+ public static string FSSoftVersion = "0.2.35";
public static int FsPage = 0;
public static bool defWindowBackGround = true;
public static TomlTable settingstomlSp;
diff --git a/Package.appxmanifest b/Package.appxmanifest
index 30ee7e6..e65fe4c 100644
--- a/Package.appxmanifest
+++ b/Package.appxmanifest
@@ -9,7 +9,7 @@
+ Version="0.2.35.0" />
FSGaryityTool
diff --git a/Page1.xaml b/Page1.xaml
index b468a53..6740f63 100644
--- a/Page1.xaml
+++ b/Page1.xaml
@@ -80,7 +80,7 @@
BAUDRATE
-
+
diff --git a/Page1.xaml.cs b/Page1.xaml.cs
index 5057913..36875d4 100644
--- a/Page1.xaml.cs
+++ b/Page1.xaml.cs
@@ -55,6 +55,7 @@
using Microsoft.Windows.ApplicationModel.Resources;
using FSGaryityTool_Win11.McuToolpage;
using System.Timers;
+using System.Text.RegularExpressions;
// To learn more about WinUI, the WinUI project structure,
@@ -927,18 +928,37 @@ private void COMButtonIcon_Rotation(object name)
}
- private void Settings_ColorValuesChanged(Windows.UI.ViewManagement.UISettings sender, object args)
+ private void OnThemeChanged(DependencyObject sender, DependencyProperty dp)
{
- var color = sender.GetColorValue(Windows.UI.ViewManagement.UIColorType.Accent);
- CONTButton.Background = new SolidColorBrush(color);
+ var darkaccentColor = (Windows.UI.Color)Application.Current.Resources["SystemAccentColorLight2"];
+ var ligtaccentColor = (Windows.UI.Color)Application.Current.Resources["SystemAccentColorDark1"];
+ // 当主题改变时,此函数会被调用
+ var theme = Application.Current.RequestedTheme;
+
+ if (Con == 1)
+ {
+ if (theme == ApplicationTheme.Dark) //设置连接按钮背景颜色
+ {
+ // 当前处于深色模式
+ CONTButton.Background = new SolidColorBrush(darkaccentColor);
+ CONTButton.Foreground = new SolidColorBrush(Colors.Black);
+ }
+ else if (theme == ApplicationTheme.Light)
+ {
+ // 当前处于浅色模式
+ CONTButton.Background = new SolidColorBrush(ligtaccentColor);
+ CONTButton.Foreground = new SolidColorBrush(Colors.White);
+ }
+ }
}
+
+
private void CONTButton_Click(object sender, RoutedEventArgs e)
{
var settings = new Windows.UI.ViewManagement.UISettings();
var color = settings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Accent);
-
var foregroundColor = COMButton.Foreground as SolidColorBrush;
var backgroundColor = COMButton.Background as SolidColorBrush;
var darkaccentColor = (Windows.UI.Color)Application.Current.Resources["SystemAccentColorLight2"];
@@ -946,8 +966,6 @@ private void CONTButton_Click(object sender, RoutedEventArgs e)
var theme = Application.Current.RequestedTheme;
- settings.ColorValuesChanged += Settings_ColorValuesChanged;
-
// 获取当前窗口的句柄
if (Con == 0)
@@ -1525,28 +1543,42 @@ private void RXTextBox_TextChanged(object sender, TextChangedEventArgs e)
}
private void BANDComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
- if (autosaveset == 1)
+ // 检查输入的是否为数字
+ if (!int.TryParse((string)BANDComboBox.SelectedItem, out int baudRate) || baudRate == 0)
{
+ // 如果输入的不是数字,使用设置文件中的数字覆盖它
using (StreamReader reader = File.OpenText(FSSetToml)) //打开TOML文件
{
settingstomlr = TOML.Parse(reader);
-
- settingstomlr["SerialPortSettings"]["DefaultBAUD"] = (string)BANDComboBox.SelectedItem;
+ BANDComboBox.SelectedItem = ((Tommy.TomlString)settingstomlr["SerialPortSettings"]["DefaultBAUD"]).Value;
}
+ }
+ else
+ {
+ if (autosaveset == 1)
+ {
+ using (StreamReader reader = File.OpenText(FSSetToml)) //打开TOML文件
+ {
+ settingstomlr = TOML.Parse(reader);
- using (StreamWriter writer = File.CreateText(FSSetToml)) //将设置写入TOML文件
+ settingstomlr["SerialPortSettings"]["DefaultBAUD"] = (string)BANDComboBox.SelectedItem;
+ }
+
+ using (StreamWriter writer = File.CreateText(FSSetToml)) //将设置写入TOML文件
+ {
+ settingstomlr.WriteTo(writer);
+ writer.Flush();
+ }
+ }
+ if (Con == 1)
{
- settingstomlr.WriteTo(writer);
- writer.Flush();
+ CommonRes._serialPort.BaudRate = Convert.ToInt32(BANDComboBox.SelectedItem);
+ RXTextBox.Text = RXTextBox.Text + "BaudRate = " + Convert.ToInt32(BANDComboBox.SelectedItem) + "\r\n";
}
+ baudrate = Convert.ToInt32(BANDComboBox.SelectedItem);
}
- if (Con == 1)
- {
- CommonRes._serialPort.BaudRate = Convert.ToInt32(BANDComboBox.SelectedItem);
- RXTextBox.Text = RXTextBox.Text + "BaudRate = " + Convert.ToInt32(BANDComboBox.SelectedItem) + "\r\n";
- }
- baudrate = Convert.ToInt32(BANDComboBox.SelectedItem);
}
+
private void PARComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (autosaveset == 1)
diff --git a/Resources/zh_CN/Resource.Designer.cs b/Resources/zh_CN/Resource.Designer.cs
index 5c6f9f6..f461a8c 100644
--- a/Resources/zh_CN/Resource.Designer.cs
+++ b/Resources/zh_CN/Resource.Designer.cs
@@ -61,7 +61,7 @@ internal Resource() {
}
///
- /// 查找类似 基础亚克力 的本地化字符串。
+ /// 查找类似 亚克力 的本地化字符串。
///
internal static string _base {
get {
diff --git a/Resources/zh_CN/Resource.resx b/Resources/zh_CN/Resource.resx
index 06b9197..9e5b11c 100644
--- a/Resources/zh_CN/Resource.resx
+++ b/Resources/zh_CN/Resource.resx
@@ -142,7 +142,7 @@
Settings Page text
- 基础亚克力
+ 亚克力
Settings Page text