From d5e2f903044680b7869297b1aba7d5160843521d Mon Sep 17 00:00:00 2001
From: SQc04 <2327412600@qq.com>
Date: Mon, 8 Jul 2024 23:00:19 +0800
Subject: [PATCH] Optimize software startup speed, add multi-line support for
the text sending box, fix bugs, and optimize layout.
---
FSGaryityTool_Win11.csproj | 3 +-
MainWindow.xaml | 2 +-
MainWindow.xaml.cs | 530 ++++++++++++++++--------------
Package.appxmanifest | 2 +-
Page1.xaml | 576 +++++++++++++++++----------------
Page1.xaml.cs | 59 +++-
Page5.xaml | 148 ++++++---
Page5.xaml.cs | 60 ++++
Reliance/ClevoEcInfoWrapper.cs | 7 +-
SettingsPage.xaml.cs | 1 +
10 files changed, 798 insertions(+), 590 deletions(-)
diff --git a/FSGaryityTool_Win11.csproj b/FSGaryityTool_Win11.csproj
index bc70101..33af3eb 100644
--- a/FSGaryityTool_Win11.csproj
+++ b/FSGaryityTool_Win11.csproj
@@ -101,6 +101,7 @@
+
@@ -257,7 +258,7 @@
- 0.2.35
+ 0.2.37
diff --git a/MainWindow.xaml b/MainWindow.xaml
index fa8d664..91e14b6 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -86,7 +86,7 @@
-
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 3e26577..7ee0161 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -61,11 +61,12 @@ namespace FSGaryityTool_Win11
public sealed partial class MainWindow : Window
{
- public static string FSSoftVersion = "0.2.35";
+ public static string FSSoftVersion = "0.2.37";
public static int FsPage = 0;
public static bool defWindowBackGround = true;
public static TomlTable settingstomlSp;
+
private Dictionary pageTypeMap = new Dictionary
{
{"MainPage1", typeof(MainPage1)},
@@ -79,9 +80,17 @@ public sealed partial class MainWindow : Window
private Dictionary backRequestedMap = new Dictionary
{
{0, () => Debug.WriteLine("SerialPortPage")},
- {4, () => { if (FSPage.fSPage.MyWebView2.CanGoBack) FSPage.fSPage.MyWebView2.GoBack(); }},
+ {5, () => { if (FSPage.fSPage.MyWebView2.CanGoBack) FSPage.fSPage.MyWebView2.GoBack(); }},
};
+ void CanvasControl_Draw(
+ Microsoft.Graphics.Canvas.UI.Xaml.CanvasControl sender,
+ Microsoft.Graphics.Canvas.UI.Xaml.CanvasDrawEventArgs args)
+ {
+ args.DrawingSession.DrawEllipse(155, 115, 80, 30, Microsoft.UI.Colors.Black, 3);
+ args.DrawingSession.DrawText("Hello, Win2D World!", 100, 100, Microsoft.UI.Colors.Yellow);
+ }
+
private void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
{
var selectedItem = (NavigationViewItem)args.SelectedItem;
@@ -146,27 +155,38 @@ private static IntPtr WndProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lPar
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
//*/
- public async void DelayedInitialize(UIElement mainContent)
+ public void DelayedInitialize(UIElement mainContent)
{
- await Task.Delay(TimeSpan.FromMilliseconds(500)); // 延时改为0.5秒
-
- // 创建淡出动画
- Storyboard storyboard = new Storyboard();
- DoubleAnimation fadeOutAnimation = new DoubleAnimation()
+ Task.Run(() =>
{
- From = 1.0,
- To = 0.0,
- Duration = new Duration(TimeSpan.FromMilliseconds(100))
- };
- Storyboard.SetTarget(fadeOutAnimation, (ExtendedSplash)App.m_window.Content);
- Storyboard.SetTargetProperty(fadeOutAnimation, "Opacity");
- storyboard.Children.Add(fadeOutAnimation);
-
- // 播放淡出动画
- storyboard.Begin();
- await Task.Delay(TimeSpan.FromMilliseconds(1)); // 等待淡出动画完成
- // 移除 ExtendedSplash
- ((App)Application.Current).RemoveExtendedSplash(mainContent);
+ Thread.Sleep(500); // 延时改为0.5秒
+
+ // 创建淡出动画
+ DispatcherQueue.TryEnqueue(() =>
+ {
+ Storyboard storyboard = new Storyboard();
+ DoubleAnimation fadeOutAnimation = new DoubleAnimation()
+ {
+ From = 1.0,
+ To = 0.0,
+ Duration = new Duration(TimeSpan.FromMilliseconds(50))
+ };
+ Storyboard.SetTarget(fadeOutAnimation, (ExtendedSplash)App.m_window.Content);
+ Storyboard.SetTargetProperty(fadeOutAnimation, "Opacity");
+ storyboard.Children.Add(fadeOutAnimation);
+
+ // 播放淡出动画
+ storyboard.Begin();
+ });
+
+ Thread.Sleep(1); // 等待淡出动画完成
+
+ // 移除 ExtendedSplash
+ DispatcherQueue.TryEnqueue(() =>
+ {
+ ((App)Application.Current).RemoveExtendedSplash(mainContent);
+ });
+ });
}
@@ -177,7 +197,6 @@ public MainWindow()
bool isFirstActivation = true;
UIElement mainContent = this.Content;
-
///*
var app = (Application.Current as App); // 尝试将当前应用程序实例转换为App类型
if (app != null) // 检查转换是否成功
@@ -188,7 +207,6 @@ public MainWindow()
}
//*/
-
// 将窗口的标题栏设置为自定义标题栏
this.ExtendsContentIntoTitleBar = true; // enable custom titlebar
@@ -212,85 +230,88 @@ public MainWindow()
}
};
- string SYSAPLOCAL = Environment.GetFolderPath(folder: Environment.SpecialFolder.LocalApplicationData);
- string FSFolder = Path.Combine(SYSAPLOCAL, "FAIRINGSTUDIO");
- string FSGravif = Path.Combine(FSFolder, "FSGravityTool");
- string FSSetJson = Path.Combine(FSGravif, "Settings.json");
- string FSSetToml = Path.Combine(FSGravif, "Settings.toml");
+ Task.Run(() =>
+ {
- //Debug.WriteLine("开始搜索文件夹");
- Debug.WriteLine("开始搜索文件夹 " + FSFolder); //新建FS文件夹
+ string SYSAPLOCAL = Environment.GetFolderPath(folder: Environment.SpecialFolder.LocalApplicationData);
+ string FSFolder = Path.Combine(SYSAPLOCAL, "FAIRINGSTUDIO");
+ string FSGravif = Path.Combine(FSFolder, "FSGravityTool");
+ string FSSetJson = Path.Combine(FSGravif, "Settings.json");
+ string FSSetToml = Path.Combine(FSGravif, "Settings.toml");
-
- if (Directory.Exists(FSFolder))
- {
- //Debug.WriteLine("找到文件夹,跳过新建文件夹");
- }
- else
- {
- //Debug.WriteLine("没有找到文件夹");
- Directory.CreateDirectory(FSFolder);
- //Debug.WriteLine("新建文件夹");
- }
+ //Debug.WriteLine("开始搜索文件夹");
+ Debug.WriteLine("开始搜索文件夹 " + FSFolder); //新建FS文件夹
- if (Directory.Exists(FSGravif))
- {
- //Debug.WriteLine("找到文件夹,跳过新建文件夹");
- }
- else
- {
- //Debug.WriteLine("没有找到文件夹");
- Directory.CreateDirectory(FSGravif);
- //Debug.WriteLine("新建文件夹");
- }
-
+ if (Directory.Exists(FSFolder))
+ {
+ //Debug.WriteLine("找到文件夹,跳过新建文件夹");
+ }
+ else
+ {
+ //Debug.WriteLine("没有找到文件夹");
+ Directory.CreateDirectory(FSFolder);
+ //Debug.WriteLine("新建文件夹");
+ }
- /*
- if (File.Exists(FSSetJson))
- {
- Debug.WriteLine("找到JSON文件,跳过新建文件");
- }
- else
- {
- Debug.WriteLine("没有找到JSON文件");
- var SettJson = new //创建对象
+
+ if (Directory.Exists(FSGravif))
{
- FSGravity = "Tool",
- SerialSettings = "1",
- DefaultBAUD = "115200",
- DefaultParity = "None",
- DefaultSTOP = "One",
- DefaultDATA = "8",
- DefaultRXHEX = "0",
- DefaultTXHEX = "0",
- DefaultDTR = "1",
- DefaultRTS = "0",
- DefaultSTime = "0",
- DefaultAUTOSco = "1",
- };
- var jsonstring1 = JsonConvert.SerializeObject(SettJson); //序列化Json
- using (StreamWriter file = File.CreateText(FSSetJson)) //创建json
+ //Debug.WriteLine("找到文件夹,跳过新建文件夹");
+ }
+ else
{
- file.WriteLine(jsonstring1);
+ //Debug.WriteLine("没有找到文件夹");
+ Directory.CreateDirectory(FSGravif);
+ //Debug.WriteLine("新建文件夹");
}
- Debug.WriteLine("新建JSON");
- }
- */
- if (File.Exists(FSSetToml)) //生成TOML
- {
- Debug.WriteLine("找到TOML文件,跳过新建文件");
- }
- else
- {
- Debug.WriteLine("没有找到TOML文件");
- string[] cOMSaveDeviceinf = { "0" };
- TomlTable settingstoml = new TomlTable
+
+ /*
+ if (File.Exists(FSSetJson))
{
- ["Version"] = FSSoftVersion,
+ Debug.WriteLine("找到JSON文件,跳过新建文件");
+ }
+ else
+ {
+ Debug.WriteLine("没有找到JSON文件");
+ var SettJson = new //创建对象
+ {
+ FSGravity = "Tool",
+ SerialSettings = "1",
+ DefaultBAUD = "115200",
+ DefaultParity = "None",
+ DefaultSTOP = "One",
+ DefaultDATA = "8",
+ DefaultRXHEX = "0",
+ DefaultTXHEX = "0",
+ DefaultDTR = "1",
+ DefaultRTS = "0",
+ DefaultSTime = "0",
+ DefaultAUTOSco = "1",
+ };
+ var jsonstring1 = JsonConvert.SerializeObject(SettJson); //序列化Json
+ using (StreamWriter file = File.CreateText(FSSetJson)) //创建json
+ {
+ file.WriteLine(jsonstring1);
+ }
+ Debug.WriteLine("新建JSON");
+ }
+ */
- ["FSGravitySettings"] =
+ if (File.Exists(FSSetToml)) //生成TOML
+ {
+ Debug.WriteLine("找到TOML文件,跳过新建文件");
+ }
+ else
+ {
+ Debug.WriteLine("没有找到TOML文件");
+ string[] cOMSaveDeviceinf = { "0" };
+ TomlTable settingstoml = new TomlTable
+ {
+ ["Version"] = FSSoftVersion,
+
+ ["FSGravitySettings"] =
{
Comment =
"FSGaryityTool Settings:",
@@ -299,9 +320,9 @@ public MainWindow()
["SoftDefLanguage"] = "zh-CN",
},
- ["SerialPortSettings"] =
+ ["SerialPortSettings"] =
{
- Comment =
+ Comment =
"FSGaryityTool SerialPort Settings:\r\n" +
"Parity:None,Odd,Even,Mark,Space\r\n" +
"STOPbits:None,One,OnePointFive,Two\r\n" +
@@ -323,17 +344,17 @@ public MainWindow()
["DefaultTXNewLine"] = "1"
},
- ["SerialPortCOMData"] =
+ ["SerialPortCOMData"] =
{
Comment =
- "This is a cache of information for all serial devices.\r\n" +
+ "This is a cache of information for all serial devices.\r\n" +
"",
["CheckTime"] = "2024-04-12 19:48:55", //串口设备信息更新的时间
["CheckCounter"] = "0", //串口设备信息更新次数
["COMSaveDeviceinf"] = String.Join(",", cOMSaveDeviceinf),//已保存串口设备的映射表
},
- ["COMData"] =
+ ["COMData"] =
{
Comment =
"This is an example of cached serial device information.\r\n",
@@ -350,107 +371,107 @@ public MainWindow()
},
- };
+ };
- using (StreamWriter writer = File.CreateText(FSSetToml))
- {
- settingstoml.WriteTo(writer);
- Debug.WriteLine("写入Toml");
- // Remember to flush the data if needed!
- writer.Flush();
+ using (StreamWriter writer = File.CreateText(FSSetToml))
+ {
+ settingstoml.WriteTo(writer);
+ Debug.WriteLine("写入Toml");
+ // Remember to flush the data if needed!
+ writer.Flush();
+ }
+ Debug.WriteLine("新建TOML");
}
- Debug.WriteLine("新建TOML");
- }
- string TomlfsVersion; //版本号比较
+ string TomlfsVersion; //版本号比较
- using (StreamReader reader = File.OpenText(FSSetToml))
- {
- TomlTable settingstomlr = TOML.Parse(reader);
- TomlfsVersion = settingstomlr["Version"];
- }
+ using (StreamReader reader = File.OpenText(FSSetToml))
+ {
+ TomlTable settingstomlr = TOML.Parse(reader);
+ TomlfsVersion = settingstomlr["Version"];
+ }
- Version TomlVersion = new Version(TomlfsVersion);
- Version FSGrVersion = new Version(FSSoftVersion);
+ Version TomlVersion = new Version(TomlfsVersion);
+ Version FSGrVersion = new Version(FSSoftVersion);
- if (FSGrVersion > TomlVersion) //Settings.Toml版本管理
- {
- Debug.WriteLine(">");
+ if (FSGrVersion > TomlVersion) //Settings.Toml版本管理
+ {
+ Debug.WriteLine(">");
- //缓存设置
- string defpage,defPageBackground,defLaunage;
- string baud, party, stop, data, rxhex, txhex, dtr, rts, shtime, autosco, autosavrset, autosercom, autoconnect, txnewline;
- string checkTime, checkCounter;
+ //缓存设置
+ string defpage, defPageBackground, defLaunage;
+ string baud, party, stop, data, rxhex, txhex, dtr, rts, shtime, autosco, autosavrset, autosercom, autoconnect, txnewline;
+ string checkTime, checkCounter;
- string[] cOMSaveDeviceinf = {"0","1"};
- string cOMDeviceinf;
+ string[] cOMSaveDeviceinf = { "0", "1" };
+ string cOMDeviceinf;
- string serialPortSettings = "SerialPortSettings";
+ string serialPortSettings = "SerialPortSettings";
- string TomlCheckNulls(string Mode, string Menu , string Name)
- {
- string data = "0";
- using (StreamReader reader = File.OpenText(Page1.FSSetToml))
+ string TomlCheckNulls(string Mode, string Menu, string Name)
{
- TomlTable SPsettingstomlr = TOML.Parse(reader); //读取TOML
-
- if (SPsettingstomlr[Menu][Name] != "Tommy.TomlLazy") data = SPsettingstomlr[Menu][Name];
- else
+ string data = "0";
+ using (StreamReader reader = File.OpenText(Page1.FSSetToml))
{
- data = Mode;
+ TomlTable SPsettingstomlr = TOML.Parse(reader); //读取TOML
+
+ if (SPsettingstomlr[Menu][Name] != "Tommy.TomlLazy") data = SPsettingstomlr[Menu][Name];
+ else
+ {
+ data = Mode;
+ }
}
+ return data;
}
- return data;
- }
-
- using (StreamReader reader = File.OpenText(Page1.FSSetToml)) //打开TOML文件
- {
- settingstomlSp = TOML.Parse(reader);
- if ((string)settingstomlSp["FSGravitySettings"]["DefaultNvPage"] != "Tommy.TomlLazy") defpage = settingstomlSp["FSGravitySettings"]["DefaultNvPage"];
- else defpage = "0";
- if ((string)settingstomlSp["FSGravitySettings"]["SoftBackground"] != "Tommy.TomlLazy") defPageBackground = settingstomlSp["FSGravitySettings"]["SoftBackground"];
- else defPageBackground = "0";
-
- var culture = System.Globalization.CultureInfo.CurrentUICulture;
- string lang = culture.Name;
-
- if ((string)settingstomlSp["FSGravitySettings"]["SoftDefLanguage"] != "Tommy.TomlLazy") defLaunage = settingstomlSp["FSGravitySettings"]["SoftDefLanguage"];
- else defLaunage = lang;
-
- baud = TomlCheckNulls("115200", serialPortSettings, "DefaultBAUD");
- party = TomlCheckNulls("None", serialPortSettings, "DefaultParity");
- stop = TomlCheckNulls("One", serialPortSettings, "DefaultSTOP");
- data = TomlCheckNulls("8", serialPortSettings, "DefaultDATA");
-
- rxhex = TomlCheckNulls("0", serialPortSettings, "DefaultRXHEX");
- txhex = TomlCheckNulls("0", serialPortSettings, "DefaultTXHEX");
- dtr = TomlCheckNulls("1", serialPortSettings, "DefaultDTR");
- rts = TomlCheckNulls("0", serialPortSettings, "DefaultRTS");
- shtime = TomlCheckNulls("0", serialPortSettings, "DefaultSTime");
- autosco = TomlCheckNulls("1", serialPortSettings, "DefaultAUTOSco");
- autosavrset = TomlCheckNulls("1", serialPortSettings, "AutoDaveSet");
- autosercom = TomlCheckNulls("1", serialPortSettings, "AutoSerichCom");
- autoconnect = TomlCheckNulls("1", serialPortSettings, "AutoConnect");
- txnewline = TomlCheckNulls("1", serialPortSettings, "DefaultTXNewLine");
-
- //if (settingstomlSp["SerialPortSettings"] != null) = ;
-
- if ((string)settingstomlSp["SerialPortCOMData"]["CheckTime"] != "Tommy.TomlLazy") checkTime = settingstomlSp["SerialPortCOMData"]["CheckTime"];
- else checkTime = "2024-04-12 19:48:55";
- if ((string)settingstomlSp["SerialPortCOMData"]["CheckCounter"] != "Tommy.TomlLazy") checkCounter = settingstomlSp["SerialPortCOMData"]["CheckCounter"];
- else checkCounter = "0";
- if ((string)settingstomlSp["SerialPortCOMData"]["COMSaveDeviceinf"] != "Tommy.TomlLazy") cOMDeviceinf = settingstomlSp["SerialPortCOMData"]["COMSaveDeviceinf"];
- else cOMDeviceinf = "0";
-
-
- settingstomlSp = new TomlTable
+ using (StreamReader reader = File.OpenText(Page1.FSSetToml)) //打开TOML文件
{
- ["Version"] = FSSoftVersion,
+ settingstomlSp = TOML.Parse(reader);
+
+ if ((string)settingstomlSp["FSGravitySettings"]["DefaultNvPage"] != "Tommy.TomlLazy") defpage = settingstomlSp["FSGravitySettings"]["DefaultNvPage"];
+ else defpage = "0";
+ if ((string)settingstomlSp["FSGravitySettings"]["SoftBackground"] != "Tommy.TomlLazy") defPageBackground = settingstomlSp["FSGravitySettings"]["SoftBackground"];
+ else defPageBackground = "0";
+
+ var culture = System.Globalization.CultureInfo.CurrentUICulture;
+ string lang = culture.Name;
+
+ if ((string)settingstomlSp["FSGravitySettings"]["SoftDefLanguage"] != "Tommy.TomlLazy") defLaunage = settingstomlSp["FSGravitySettings"]["SoftDefLanguage"];
+ else defLaunage = lang;
+
+ baud = TomlCheckNulls("115200", serialPortSettings, "DefaultBAUD");
+ party = TomlCheckNulls("None", serialPortSettings, "DefaultParity");
+ stop = TomlCheckNulls("One", serialPortSettings, "DefaultSTOP");
+ data = TomlCheckNulls("8", serialPortSettings, "DefaultDATA");
+
+ rxhex = TomlCheckNulls("0", serialPortSettings, "DefaultRXHEX");
+ txhex = TomlCheckNulls("0", serialPortSettings, "DefaultTXHEX");
+ dtr = TomlCheckNulls("1", serialPortSettings, "DefaultDTR");
+ rts = TomlCheckNulls("0", serialPortSettings, "DefaultRTS");
+ shtime = TomlCheckNulls("0", serialPortSettings, "DefaultSTime");
+ autosco = TomlCheckNulls("1", serialPortSettings, "DefaultAUTOSco");
+ autosavrset = TomlCheckNulls("1", serialPortSettings, "AutoDaveSet");
+ autosercom = TomlCheckNulls("1", serialPortSettings, "AutoSerichCom");
+ autoconnect = TomlCheckNulls("1", serialPortSettings, "AutoConnect");
+ txnewline = TomlCheckNulls("1", serialPortSettings, "DefaultTXNewLine");
+
+ //if (settingstomlSp["SerialPortSettings"] != null) = ;
+
+ if ((string)settingstomlSp["SerialPortCOMData"]["CheckTime"] != "Tommy.TomlLazy") checkTime = settingstomlSp["SerialPortCOMData"]["CheckTime"];
+ else checkTime = "2024-04-12 19:48:55";
+ if ((string)settingstomlSp["SerialPortCOMData"]["CheckCounter"] != "Tommy.TomlLazy") checkCounter = settingstomlSp["SerialPortCOMData"]["CheckCounter"];
+ else checkCounter = "0";
+ if ((string)settingstomlSp["SerialPortCOMData"]["COMSaveDeviceinf"] != "Tommy.TomlLazy") cOMDeviceinf = settingstomlSp["SerialPortCOMData"]["COMSaveDeviceinf"];
+ else cOMDeviceinf = "0";
+
+
+ settingstomlSp = new TomlTable
+ {
+ ["Version"] = FSSoftVersion,
- ["FSGravitySettings"] =
+ ["FSGravitySettings"] =
{
Comment =
"FSGaryityTool Settings:",
@@ -459,7 +480,7 @@ string TomlCheckNulls(string Mode, string Menu , string Name)
["SoftDefLanguage"] = defLaunage,
},
- ["SerialPortSettings"] =
+ ["SerialPortSettings"] =
{
Comment =
"FSGaryityTool SerialPort Settings:\r\n" +
@@ -483,7 +504,7 @@ string TomlCheckNulls(string Mode, string Menu , string Name)
["DefaultTXNewLine"] = txnewline,
},
- ["SerialPortCOMData"] =
+ ["SerialPortCOMData"] =
{
Comment =
"This is a cache of information for all serial devices.\r\n",
@@ -492,7 +513,7 @@ string TomlCheckNulls(string Mode, string Menu , string Name)
["CheckCounter"] = "0",
["COMSaveDeviceinf"] = cOMDeviceinf//String.Join(",", cOMSaveDeviceinf)
},
- ["COMData"] =
+ ["COMData"] =
{
Comment =
"This is an example of cached serial device information.\r\n",
@@ -508,56 +529,85 @@ string TomlCheckNulls(string Mode, string Menu , string Name)
},
},
- };
+ };
+ }
+ //更新Toml
+ using (StreamWriter writer = File.CreateText(Page1.FSSetToml)) //将设置写入TOML文件
+ {
+ settingstomlSp.WriteTo(writer);
+ //Debug.WriteLine("写入Toml" + settingstomlSp["FSGravitySettings"]["DefaultNvPage"]);
+ // Remember to flush the data if needed!
+ writer.Flush();
+ }
}
- //更新Toml
- using (StreamWriter writer = File.CreateText(Page1.FSSetToml)) //将设置写入TOML文件
+ else
{
- settingstomlSp.WriteTo(writer);
- //Debug.WriteLine("写入Toml" + settingstomlSp["FSGravitySettings"]["DefaultNvPage"]);
- // Remember to flush the data if needed!
- writer.Flush();
+ Debug.WriteLine("<=");
+
}
- }
- else
- {
- Debug.WriteLine("<=");
- }
+
+ // 在初始化完成后,回到 UI 线程移除 ExtendedSplash
+ this.DispatcherQueue.TryEnqueue(() =>
+ {
+ SerialPortI.Content = Page1.LanguageText("serialPort");
+ DownFlashI.Content = Page1.LanguageText("download Flash");
+ KeyboardI.Content = Page1.LanguageText("keyboard");
+ MouseI.Content = Page1.LanguageText("mouse");
- SerialPortI.Content = Page1.LanguageText("serialPort");
- DownFlashI.Content = Page1.LanguageText("download Flash");
- KeyboardI.Content = Page1.LanguageText("keyboard");
- MouseI.Content = Page1.LanguageText("mouse");
+ //设置默认页面
+ using (StreamReader reader = File.OpenText(FSSetToml))
+ {
+ TomlTable settingstomlr = TOML.Parse(reader);
+ Debug.WriteLine("Print:" + settingstomlr["FSGravitySettings"]["DefaultNvPage"]);
+ int NvPage = int.Parse(settingstomlr["FSGravitySettings"]["DefaultNvPage"]);
+ FSnv.SelectedItem = FSnv.MenuItems[NvPage]; //设置默认页面
+ FsPage = NvPage;
+ }
+ using (StreamReader reader = File.OpenText(FSSetToml))
+ {
+ TomlTable settingstomlr = TOML.Parse(reader);
+ Debug.WriteLine("Print:" + settingstomlr["FSGravitySettings"]["SoftBackground"]);
+ int defPageBackground = int.Parse(settingstomlr["FSGravitySettings"]["SoftBackground"]);
+ if (defPageBackground == 0) defWindowBackGround = true;
+ else if (defPageBackground == 1) defWindowBackGround = false;
+ lastdefWindowBackGround = defPageBackground;
+ }
+ TitleBarTextBlock.Text = "FSGravityTool";
+ //SystemBackdrop = new MicaBackdrop()
+ //{ Kind = MicaKind.BaseAlt };
- this.Activated += (sender, e) =>
- {
- if (isFirstActivation)
- {
- DelayedInitialize(mainContent);
- isFirstActivation = false;
- }
- };
+ //SystemBackdrop = new DesktopAcrylicBackdrop();
- //设置默认页面
- using (StreamReader reader = File.OpenText(FSSetToml))
- {
- TomlTable settingstomlr = TOML.Parse(reader);
- Debug.WriteLine("Print:" + settingstomlr["FSGravitySettings"]["DefaultNvPage"]);
- int NvPage = int.Parse(settingstomlr["FSGravitySettings"]["DefaultNvPage"]);
- FSnv.SelectedItem = FSnv.MenuItems[NvPage]; //设置默认页面
- FsPage = NvPage;
- }
- using (StreamReader reader = File.OpenText(FSSetToml))
- {
- TomlTable settingstomlr = TOML.Parse(reader);
- Debug.WriteLine("Print:" + settingstomlr["FSGravitySettings"]["SoftBackground"]);
- int defPageBackground = int.Parse(settingstomlr["FSGravitySettings"]["SoftBackground"]);
- if (defPageBackground == 0) defWindowBackGround = true;
- else if (defPageBackground == 1) defWindowBackGround = false;
- lastdefWindowBackGround = defPageBackground;
- }
+ if (Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicController.IsSupported())
+ {
+ // 连接策略对象。
+ m_configurationSource = new Microsoft.UI.Composition.SystemBackdrops.SystemBackdropConfiguration();
+ this.Activated += Window_Activated; // 当窗口被激活时的事件处理。
+ this.Closed += Window_Closed; // 当窗口被关闭时的事件处理。
+ ((FrameworkElement)this.Content).ActualThemeChanged += Window_ThemeChanged; // 当窗口主题改变时的事件处理。
+
+ // 初始配置状态。
+ m_configurationSource.IsInputActive = true; // 设置输入活动状态为真。
+ SetConfigurationSourceTheme(); // 设置配置源主题。
+
+ m_acrylicController = new Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicController(); // 创建一个新的亚克力控制器。
+
+ // 根据defWindowBackGround的值选择亚克力效果的类型。
+ m_acrylicController.Kind = defWindowBackGround ? Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicKind.Thin : Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicKind.Base;
+
+ // 启用系统背景。
+ // 注意:确保使用了"using WinRT;"以支持Window.As<...>()调用。
+ m_acrylicController.AddSystemBackdropTarget(this.As()); // 添加系统背景目标。
+ m_acrylicController.SetSystemBackdropConfiguration(m_configurationSource); // 设置系统背景配置。
+ }
+
+
+ });
+
+
+ });
/*
if (AppWindowTitleBar.IsCustomizationSupported())
@@ -587,36 +637,16 @@ string TomlCheckNulls(string Mode, string Menu , string Name)
}*/
- TitleBarTextBlock.Text = "FSGravityTool";
- //SystemBackdrop = new MicaBackdrop()
- //{ Kind = MicaKind.BaseAlt };
-
- //SystemBackdrop = new DesktopAcrylicBackdrop();
- if (Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicController.IsSupported())
+ this.Activated += (sender, e) =>
{
- // 连接策略对象。
- m_configurationSource = new Microsoft.UI.Composition.SystemBackdrops.SystemBackdropConfiguration();
- this.Activated += Window_Activated; // 当窗口被激活时的事件处理。
- this.Closed += Window_Closed; // 当窗口被关闭时的事件处理。
- ((FrameworkElement)this.Content).ActualThemeChanged += Window_ThemeChanged; // 当窗口主题改变时的事件处理。
-
- // 初始配置状态。
- m_configurationSource.IsInputActive = true; // 设置输入活动状态为真。
- SetConfigurationSourceTheme(); // 设置配置源主题。
-
- m_acrylicController = new Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicController(); // 创建一个新的亚克力控制器。
-
- // 根据defWindowBackGround的值选择亚克力效果的类型。
- m_acrylicController.Kind = defWindowBackGround ? Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicKind.Thin : Microsoft.UI.Composition.SystemBackdrops.DesktopAcrylicKind.Base;
-
- // 启用系统背景。
- // 注意:确保使用了"using WinRT;"以支持Window.As<...>()调用。
- m_acrylicController.AddSystemBackdropTarget(this.As()); // 添加系统背景目标。
- m_acrylicController.SetSystemBackdropConfiguration(m_configurationSource); // 设置系统背景配置。
- }
-
+ if (isFirstActivation)
+ {
+ DelayedInitialize(mainContent);
+ isFirstActivation = false;
+ }
+ };
}
int lastdefWindowBackGround = 0;
public void WindowBackSetting()
diff --git a/Package.appxmanifest b/Package.appxmanifest
index e65fe4c..86fd189 100644
--- a/Package.appxmanifest
+++ b/Package.appxmanifest
@@ -9,7 +9,7 @@
+ Version="0.2.37.0" />
FSGaryityTool
diff --git a/Page1.xaml b/Page1.xaml
index 6740f63..d111581 100644
--- a/Page1.xaml
+++ b/Page1.xaml
@@ -23,309 +23,343 @@
-
+
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- BAUDRATE
-
-
-
-
-
-
-
-
-
-
-
- Parity
-
-
-
-
-
-
-
-
-
-
-
- STOP Bits
-
-
-
-
-
-
-
-
-
-
-
- DATA Bits
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
- RX HEX
- TX HEX
-
-
-
-
-
-
-
- TXNewLine
- DTR
- RTS
-
-
-
-
-
-
-
- AutoSaveSet
- AUTOScroll
-
-
-
-
-
-
-
- AutoSerichCom
- Auto Connect
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ BAUDRATE
+
+
+
+
+
+
+
+
+
+
+
+ Parity
+
+
+
+
+
+
+
+
+
+
+
+ STOP Bits
+
+
+
+
+
+
+
+
+
+
+
+ DATA Bits
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ RX HEX
+ TX HEX
+
+
+
+
+
+
+
+ TXNewLine
+ DTR
+ RTS
+
+
+
+
+
+
+
+ AutoSaveSet
+ AUTOScroll
+
+
+
+
+
+
+
+ AutoSerichCom
+ Auto Connect
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Showtimestamp
+
+
-
-
-
-
- Showtimestamp
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
diff --git a/Page1.xaml.cs b/Page1.xaml.cs
index 36875d4..0d1c1b0 100644
--- a/Page1.xaml.cs
+++ b/Page1.xaml.cs
@@ -56,6 +56,8 @@
using FSGaryityTool_Win11.McuToolpage;
using System.Timers;
using System.Text.RegularExpressions;
+using Windows.System;
+using Microsoft.UI.Input;
// To learn more about WinUI, the WinUI project structure,
@@ -1185,10 +1187,11 @@ private void UpdateItemsRepeater(LinkedList items)
private DateTime lastReceivedTime = DateTime.Now; // 添加这一行来声明lastReceivedTime变量
StringBuilder buffer = new StringBuilder();
- private async void _serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
+ private void _serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
// 在另一个线程中处理串口数据
- await Task.Run(() =>
+
+ Task.Run(() =>
{
string Timesr = current_time.ToString("yyyy-MM-dd HH:mm:ss:ff "); //显示时间
@@ -1250,12 +1253,12 @@ await Task.Run(() =>
lastReceivedTime = DateTime.Now; // 更新最后接收数据的时间
}
-
DispatcherQueue.TryEnqueue(() =>
{
UpdateItemsRepeater(tempDataList);
});
});
+
}
private void UpdateItemsRepeater(LinkedList items)
@@ -1455,7 +1458,7 @@ private void SendStringData()
// 如果需要在每条消息后添加换行符
AppendNewLineIfRequired();
// 更新接收文本框的内容
- RXTextBox.Text += $"TX: {str}\r\n";
+ RXTextBox.Text += $"TX: {str}" + "\r\n";
}
catch
{
@@ -1473,14 +1476,23 @@ private void SendHexData()
{
// 获取要发送的十六进制字符串,并进行必要的预处理
string input = PrepareHexString();
- // 将十六进制字符串转换为字节数组
- byte[] bytes = ConvertHexStringToByteArray(input);
- // 通过串口发送字节数组
- CommonRes._serialPort.Write(bytes, 0, bytes.Length);
- // 如果需要在每条消息后添加换行符
- AppendNewLineIfRequired();
- // 更新接收文本框的内容
- RXTextBox.Text += $"TX: 0x {string.Join(" ", bytes.Select(b => b.ToString("X2")))}\r\n";
+ Task.Run(() =>
+ {
+ // 将十六进制字符串转换为字节数组
+ byte[] bytes = ConvertHexStringToByteArray(input);
+ // 通过串口发送字节数组
+ CommonRes._serialPort.Write(bytes, 0, bytes.Length);
+ // 如果需要在每条消息后添加换行符
+ AppendNewLineIfRequired();
+
+ DispatcherQueue.TryEnqueue(() =>
+ {
+ // 更新接收文本框的内容
+ RXTextBox.Text += $"TX: 0x {string.Join(" ", bytes.Select(b => b.ToString("X2")))}\r\n";
+ });
+ input = "";
+ });
+
}
catch (FormatException)
{
@@ -1496,6 +1508,7 @@ private string PrepareHexString()
{
// 获取要发送的十六进制字符串,并去除所有空格
string input = TXTextBox.Text.Trim().Replace(" ", "");
+ input = input.Replace("\r", "").Replace("\t", "");
// 如果长度为奇数,前面添加一个 '0'
if (input.Length % 2 != 0)
{
@@ -1504,6 +1517,7 @@ private string PrepareHexString()
return input;
}
+
// 将十六进制字符串转换为字节数组
private byte[] ConvertHexStringToByteArray(string input)
{
@@ -1765,9 +1779,9 @@ private void DTRButton_Click(object sender, RoutedEventArgs e) //DTR信号
}
}
- public static async void RSTButtonRes()
+ public static void RSTButtonRes()
{
- await Task.Run(() =>
+ Task.Run(() =>
{
CommonRes._serialPort.BaudRate = 74880;// BANDComboBox.SelectedItem = "74880";//ESP12F
@@ -1925,14 +1939,29 @@ private Task RXDATA_ClickAsync(object sender, RoutedEventArgs e)
return Task.CompletedTask;
}
+ public bool isCtrlDown = false;
+ private void TXTextBox_KeyDown(object sender, KeyRoutedEventArgs e)
+ {
+ if (e.Key == Windows.System.VirtualKey.Control)
+ {
+ isCtrlDown = true;
+ }
+ }
+
private void TXTextBox_KeyUp(object sender, KeyRoutedEventArgs e)
{
- if (e.Key == Windows.System.VirtualKey.Enter)
+ if (e.Key == Windows.System.VirtualKey.Enter && isCtrlDown)
{
TXButton_Click(this, new RoutedEventArgs());
}
+ if (e.Key == Windows.System.VirtualKey.Control)
+ {
+ isCtrlDown = false;
+ }
}
+
+
private void SaveSetButton_Click(object sender, RoutedEventArgs e)
{
if (autosaveset == 0)
diff --git a/Page5.xaml b/Page5.xaml
index 378da54..11c7be5 100644
--- a/Page5.xaml
+++ b/Page5.xaml
@@ -8,56 +8,114 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:Toolkit="using:CommunityToolkit.WinUI.Controls"
+ xmlns:win2d="using:Microsoft.Graphics.Canvas.UI.Xaml"
NavigationCacheMode="Enabled">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
diff --git a/Page5.xaml.cs b/Page5.xaml.cs
index a4ef78e..6af8de4 100644
--- a/Page5.xaml.cs
+++ b/Page5.xaml.cs
@@ -20,6 +20,15 @@
using System.ComponentModel;
using Microsoft.UI.Xaml.Media.Animation;
+using Microsoft.Graphics.Canvas.UI.Xaml;
+using Microsoft.Graphics.Canvas.Geometry;
+using System.Numerics;
+
+using Microsoft.UI;
+using Windows.UI;
+
+
+
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
@@ -206,6 +215,29 @@ private void CPUFanRadialGauge_ValueChanged(object sender, RangeBaseValueChanged
// ǷValueԷ˱仯
cpuDelayTimer.Change(200, Timeout.Infinite);
}
+
+ private void WatchDogStart_Click(object sender, RoutedEventArgs e)
+ {
+ bool isStart = ClevoEcControl.IsWatchDogStarted();
+ Debug.WriteLine($"isStart: " + isStart.ToString());
+ if (!isStart)
+ {
+ ClevoEcControl.SetWatchDogStarted();
+ }
+ Debug.WriteLine("WatchDogserver is Start");
+ }
+
+ private void WatchDogClose_Click(object sender, RoutedEventArgs e)
+ {
+ bool isStart = ClevoEcControl.IsWatchDogStarted();
+ Debug.WriteLine($"isStart: " + isStart.ToString());
+ if (isStart)
+ {
+ ClevoEcControl.SetWatchDogClosed();
+ }
+ Debug.WriteLine("WatchDogserver is Close");
+ }
+
private void GPUFanRadialGauge_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
{
// ǷValueԷ˱仯
@@ -243,5 +275,33 @@ private void GpuOnTimer(object state)
oldGpuDutySet = gpuDutySet;
}
}
+ private void OnDraw(CanvasControl sender, CanvasDrawEventArgs args)
+ {
+ Vector2 point1 = new Vector2(0, 200); //
+ Vector2 controlPoint1 = new Vector2(100, 100); // Ƶ1
+ Vector2 controlPoint2 = new Vector2(200, 150); // Ƶ2
+ Vector2 point2 = new Vector2(300, 0); // յ
+
+ var pathBuilder = new CanvasPathBuilder(sender);
+ pathBuilder.BeginFigure(point1);
+ pathBuilder.AddCubicBezier(controlPoint1, controlPoint2, point2);
+ pathBuilder.EndFigure(CanvasFigureLoop.Open);
+
+ var path = CanvasGeometry.CreatePath(pathBuilder);
+
+ Color color;
+ if (Application.Current.RequestedTheme == ApplicationTheme.Dark)
+ {
+ color = (Color)Application.Current.Resources["SystemAccentColorLight2"];
+ }
+ else
+ {
+ color = (Color)Application.Current.Resources["SystemAccentColorDark1"];
+ }
+
+ args.DrawingSession.DrawGeometry(path, color, 3);
+ }
+
+
}
}
diff --git a/Reliance/ClevoEcInfoWrapper.cs b/Reliance/ClevoEcInfoWrapper.cs
index 6c14a99..a8ba311 100644
--- a/Reliance/ClevoEcInfoWrapper.cs
+++ b/Reliance/ClevoEcInfoWrapper.cs
@@ -1,9 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
+using System.Runtime.InteropServices;
namespace FSGaryityTool_Win11.Reliance
{
diff --git a/SettingsPage.xaml.cs b/SettingsPage.xaml.cs
index 01f37c0..7f73853 100644
--- a/SettingsPage.xaml.cs
+++ b/SettingsPage.xaml.cs
@@ -23,6 +23,7 @@
using System.Reflection.PortableExecutable;
using static System.Net.Mime.MediaTypeNames;
using Windows.ApplicationModel;
+using System.Threading.Tasks;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.