diff --git a/.gitignore b/.gitignore
index 0d6c45d..d2508e6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,211 +1,41 @@
-## Ignore Visual Studio temporary files, build results, and
-## files generated by popular Visual Studio add-ons.
-
-# User-specific files
-*.suo
+# Visual Studio
+.vs/
*.user
-*.userosscache
-*.sln.docstates
-
-# User-specific files (MonoDevelop/Xamarin Studio)
-*.userprefs
+*.suo
# Build results
-[Dd]ebugPublic/
-[Rr]elease/
-[Rr]eleases/
-x64/
-x86/
-build/
-bld/
-[Bb]in/
-[Oo]bj/
-
-# Visual Studio 2015 cache/options directory
-.vs/
-
-# MSTest test Results
-[Tt]est[Rr]esult*/
-[Bb]uild[Ll]og.*
-
-# NUNIT
-*.VisualState.xml
-TestResult.xml
-
-# Build Results of an ATL Project
-[Dd]ebugPS/
-[Rr]eleasePS/
-dlldata.c
-
-# DNX
-project.lock.json
-artifacts/
-
-*_i.c
-*_p.c
-*_i.h
-*.ilk
-*.meta
-*.obj
-*.pch
-*.pdb
-*.pgc
-*.pgd
-*.rsp
-*.sbr
-*.tlb
-*.tli
-*.tlh
-*.tmp
-*.tmp_proj
-*.log
-*.vspscc
-*.vssscc
-.builds
-*.pidb
-*.svclog
-*.scc
-
-# Chutzpah Test files
-_Chutzpah*
-
-# Visual C++ cache files
-ipch/
-*.aps
-*.ncb
-*.opensdf
-*.sdf
-*.cachefile
-
-# Visual Studio profiler
-*.psess
-*.vsp
-*.vspx
-
-# TFS 2012 Local Workspace
-$tf/
-
-# Guidance Automation Toolkit
-*.gpState
-
-# ReSharper is a .NET coding add-in
-_ReSharper*/
-*.[Rr]e[Ss]harper
-*.DotSettings.user
+bin/
+obj/
-# JustCode is a .NET coding add-in
-.JustCode
-
-# TeamCity is a build add-in
-_TeamCity*
-
-# DotCover is a Code Coverage Tool
-*.dotCover
-
-# NCrunch
-_NCrunch_*
-.*crunch*.local.xml
-
-# MightyMoose
-*.mm.*
-AutoTest.Net/
-
-# Web workbench (sass)
-.sass-cache/
-
-# Installshield output folder
-[Ee]xpress/
-
-# DocProject is a documentation generator add-in
-DocProject/buildhelp/
-DocProject/Help/*.HxT
-DocProject/Help/*.HxC
-DocProject/Help/*.hhc
-DocProject/Help/*.hhk
-DocProject/Help/*.hhp
-DocProject/Help/Html2
-DocProject/Help/html
-
-# Click-Once directory
-publish/
-
-# Publish Web Output
-*.[Pp]ublish.xml
-*.azurePubxml
-## TODO: Comment the next line if you want to checkin your
-## web deploy settings but do note that will include unencrypted
-## passwords
-#*.pubxml
-
-*.publishproj
-
-# NuGet Packages
+# NuGet
*.nupkg
-# The packages folder can be ignored because of Package Restore
-**/packages/*
-# except build/, which is used as an MSBuild target.
-!**/packages/build/
-# Uncomment if necessary however generally it will be regenerated when needed
-#!**/packages/repositories.config
-
-# Windows Azure Build Output
-csx/
-*.build.csdef
-
-# Windows Store app package directory
-AppPackages/
-
-# Visual Studio cache files
-# files ending in .cache can be ignored
-*.[Cc]ache
-# but keep track of directories ending in .cache
-!*.[Cc]ache/
+# The packages folder can be ignored if you use Package Restore
+packages/
# Others
-ClientBin/
-[Ss]tyle[Cc]op.*
-~$*
-*~
-*.dbmdl
-*.dbproj.schemaview
-*.pfx
-*.publishsettings
-node_modules/
-orleans.codegen.cs
-
-# RIA/Silverlight projects
-Generated_Code/
-
-# Backup & report files from converting an old project file
-# to a newer Visual Studio version. Backup files are not needed,
-# because we have git ;-)
-_UpgradeReport_Files/
-Backup*/
-UpgradeLog*.XML
-UpgradeLog*.htm
-
-# SQL Server files
-*.mdf
-*.ldf
+*.log
+*.tlog
+*.cache
+*.pdb
-# Business Intelligence projects
-*.rdl.data
-*.bim.layout
-*.bim_*.settings
+# User-specific files
+*.user
+*.rsuser
+*.sln.docstates
-# Microsoft Fakes
-FakesAssemblies/
+# Build directories for Visual Studio Code
+.vscode/
-# Node.js Tools for Visual Studio
-.ntvs_analysis.dat
+# Windows image file caches
+Thumbs.db
+ehthumbs.db
-# Visual Studio 6 build log
-*.plg
+# Rider
+.idea/
+*.sln.iml
-# Visual Studio 6 workspace options file
-*.opt
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
-# LightSwitch generated files
-GeneratedArtifacts/
-_Pvt_Extensions/
-ModelManifest.xml
+# macOS
+.DS_Store
diff --git a/.vs/ProjectEvaluation/wpfserialassistant.metadata.v9.bin b/.vs/ProjectEvaluation/wpfserialassistant.metadata.v9.bin
new file mode 100644
index 0000000..7a1de80
Binary files /dev/null and b/.vs/ProjectEvaluation/wpfserialassistant.metadata.v9.bin differ
diff --git a/.vs/ProjectEvaluation/wpfserialassistant.projects.v9.bin b/.vs/ProjectEvaluation/wpfserialassistant.projects.v9.bin
new file mode 100644
index 0000000..35754af
Binary files /dev/null and b/.vs/ProjectEvaluation/wpfserialassistant.projects.v9.bin differ
diff --git a/.vs/ProjectEvaluation/wpfserialassistant.strings.v9.bin b/.vs/ProjectEvaluation/wpfserialassistant.strings.v9.bin
new file mode 100644
index 0000000..800622d
Binary files /dev/null and b/.vs/ProjectEvaluation/wpfserialassistant.strings.v9.bin differ
diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json
new file mode 100644
index 0000000..370934a
--- /dev/null
+++ b/.vs/VSWorkspaceState.json
@@ -0,0 +1,5 @@
+{
+ "ExpandedNodes": [],
+ "SelectedNode": "\\WPFSerialAssistant.sln",
+ "PreviewInSolutionExplorer": false
+}
\ No newline at end of file
diff --git a/.vs/WPFSerialAssistant/CopilotIndices/17.14.552.11226/CodeChunks.db b/.vs/WPFSerialAssistant/CopilotIndices/17.14.552.11226/CodeChunks.db
new file mode 100644
index 0000000..b767519
Binary files /dev/null and b/.vs/WPFSerialAssistant/CopilotIndices/17.14.552.11226/CodeChunks.db differ
diff --git a/.vs/WPFSerialAssistant/CopilotIndices/17.14.552.11226/SemanticSymbols.db b/.vs/WPFSerialAssistant/CopilotIndices/17.14.552.11226/SemanticSymbols.db
new file mode 100644
index 0000000..0d8527b
Binary files /dev/null and b/.vs/WPFSerialAssistant/CopilotIndices/17.14.552.11226/SemanticSymbols.db differ
diff --git a/.vs/WPFSerialAssistant/DesignTimeBuild/.dtbcache.v2 b/.vs/WPFSerialAssistant/DesignTimeBuild/.dtbcache.v2
new file mode 100644
index 0000000..8a1c748
Binary files /dev/null and b/.vs/WPFSerialAssistant/DesignTimeBuild/.dtbcache.v2 differ
diff --git a/.vs/WPFSerialAssistant/FileContentIndex/71e071dd-c9a3-4bb1-92a8-f9d91b847523.vsidx b/.vs/WPFSerialAssistant/FileContentIndex/71e071dd-c9a3-4bb1-92a8-f9d91b847523.vsidx
new file mode 100644
index 0000000..ac1c5c0
Binary files /dev/null and b/.vs/WPFSerialAssistant/FileContentIndex/71e071dd-c9a3-4bb1-92a8-f9d91b847523.vsidx differ
diff --git a/.vs/WPFSerialAssistant/FileContentIndex/8700a9cf-82a2-4201-842f-75e3a962c883.vsidx b/.vs/WPFSerialAssistant/FileContentIndex/8700a9cf-82a2-4201-842f-75e3a962c883.vsidx
new file mode 100644
index 0000000..ed98014
Binary files /dev/null and b/.vs/WPFSerialAssistant/FileContentIndex/8700a9cf-82a2-4201-842f-75e3a962c883.vsidx differ
diff --git a/.vs/WPFSerialAssistant/FileContentIndex/95bfab9f-c9f6-4f5c-8e28-d7217fdb244f.vsidx b/.vs/WPFSerialAssistant/FileContentIndex/95bfab9f-c9f6-4f5c-8e28-d7217fdb244f.vsidx
new file mode 100644
index 0000000..eadab61
Binary files /dev/null and b/.vs/WPFSerialAssistant/FileContentIndex/95bfab9f-c9f6-4f5c-8e28-d7217fdb244f.vsidx differ
diff --git a/.vs/WPFSerialAssistant/FileContentIndex/c2956a16-a8ab-497f-8d0f-6c9fff296552.vsidx b/.vs/WPFSerialAssistant/FileContentIndex/c2956a16-a8ab-497f-8d0f-6c9fff296552.vsidx
new file mode 100644
index 0000000..9cb02cc
Binary files /dev/null and b/.vs/WPFSerialAssistant/FileContentIndex/c2956a16-a8ab-497f-8d0f-6c9fff296552.vsidx differ
diff --git a/.vs/WPFSerialAssistant/copilot-chat/60f09ee7/sessions/6e6915c2-696c-49ff-8dc7-9e2884e53369 b/.vs/WPFSerialAssistant/copilot-chat/60f09ee7/sessions/6e6915c2-696c-49ff-8dc7-9e2884e53369
new file mode 100644
index 0000000..8300703
Binary files /dev/null and b/.vs/WPFSerialAssistant/copilot-chat/60f09ee7/sessions/6e6915c2-696c-49ff-8dc7-9e2884e53369 differ
diff --git a/.vs/WPFSerialAssistant/v17/.futdcache.v2 b/.vs/WPFSerialAssistant/v17/.futdcache.v2
new file mode 100644
index 0000000..691953c
Binary files /dev/null and b/.vs/WPFSerialAssistant/v17/.futdcache.v2 differ
diff --git a/.vs/WPFSerialAssistant/v17/.suo b/.vs/WPFSerialAssistant/v17/.suo
new file mode 100644
index 0000000..dc5e107
Binary files /dev/null and b/.vs/WPFSerialAssistant/v17/.suo differ
diff --git a/.vs/WPFSerialAssistant/v17/DocumentLayout.backup.json b/.vs/WPFSerialAssistant/v17/DocumentLayout.backup.json
new file mode 100644
index 0000000..01bff39
--- /dev/null
+++ b/.vs/WPFSerialAssistant/v17/DocumentLayout.backup.json
@@ -0,0 +1,103 @@
+{
+ "Version": 1,
+ "WorkspaceRootPath": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\",
+ "Documents": [
+ {
+ "AbsoluteMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|c:\\users\\hp\\documents\\github\\serialassistant\\wpfserialassistant\\mainwindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}",
+ "RelativeMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|solutionrelative:wpfserialassistant\\mainwindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}"
+ },
+ {
+ "AbsoluteMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\wpfserialassistant\\saserialport.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
+ "RelativeMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|solutionrelative:wpfserialassistant\\saserialport.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
+ },
+ {
+ "AbsoluteMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\wpfserialassistant\\mainwindow.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
+ "RelativeMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|solutionrelative:wpfserialassistant\\mainwindow.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
+ },
+ {
+ "AbsoluteMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\wpfserialassistant\\selectdialog.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
+ "RelativeMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|solutionrelative:wpfserialassistant\\selectdialog.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
+ },
+ {
+ "AbsoluteMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\wpfserialassistant\\selectdialog.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}",
+ "RelativeMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|solutionrelative:wpfserialassistant\\selectdialog.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}"
+ }
+ ],
+ "DocumentGroupContainers": [
+ {
+ "Orientation": 0,
+ "VerticalTabListWidth": 256,
+ "DocumentGroups": [
+ {
+ "DockedWidth": 200,
+ "SelectedChildIndex": 5,
+ "Children": [
+ {
+ "$type": "Bookmark",
+ "Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
+ },
+ {
+ "$type": "Document",
+ "DocumentIndex": 3,
+ "Title": "SelectDialog.xaml.cs",
+ "DocumentMoniker": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\SelectDialog.xaml.cs",
+ "RelativeDocumentMoniker": "WPFSerialAssistant\\SelectDialog.xaml.cs",
+ "ToolTip": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\SelectDialog.xaml.cs",
+ "RelativeToolTip": "WPFSerialAssistant\\SelectDialog.xaml.cs",
+ "ViewState": "AgIAAAAAAAAAAAAAAAAAABYAAAAAAAAAAAAAAA==",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
+ "WhenOpened": "2025-08-01T09:06:28.406Z"
+ },
+ {
+ "$type": "Document",
+ "DocumentIndex": 4,
+ "Title": "SelectDialog.xaml",
+ "DocumentMoniker": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\SelectDialog.xaml",
+ "RelativeDocumentMoniker": "WPFSerialAssistant\\SelectDialog.xaml",
+ "ToolTip": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\SelectDialog.xaml",
+ "RelativeToolTip": "WPFSerialAssistant\\SelectDialog.xaml",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
+ "WhenOpened": "2025-08-01T09:05:51.188Z"
+ },
+ {
+ "$type": "Document",
+ "DocumentIndex": 1,
+ "Title": "SASerialPort.cs",
+ "DocumentMoniker": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\SASerialPort.cs",
+ "RelativeDocumentMoniker": "WPFSerialAssistant\\SASerialPort.cs",
+ "ToolTip": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\SASerialPort.cs",
+ "RelativeToolTip": "WPFSerialAssistant\\SASerialPort.cs",
+ "ViewState": "AgIAAJ0AAAAAAAAAAAAQwL0AAAAAAAAAAAAAAA==",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
+ "WhenOpened": "2025-05-27T10:09:27.392Z"
+ },
+ {
+ "$type": "Document",
+ "DocumentIndex": 2,
+ "Title": "MainWindow.xaml.cs",
+ "DocumentMoniker": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\MainWindow.xaml.cs",
+ "RelativeDocumentMoniker": "WPFSerialAssistant\\MainWindow.xaml.cs",
+ "ToolTip": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\MainWindow.xaml.cs",
+ "RelativeToolTip": "WPFSerialAssistant\\MainWindow.xaml.cs",
+ "ViewState": "AgIAAA0BAAAAAAAAAAAiwCABAAANAAAAAAAAAA==",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
+ "WhenOpened": "2025-05-27T09:53:13.299Z"
+ },
+ {
+ "$type": "Document",
+ "DocumentIndex": 0,
+ "Title": "MainWindow.xaml",
+ "DocumentMoniker": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\MainWindow.xaml",
+ "RelativeDocumentMoniker": "WPFSerialAssistant\\MainWindow.xaml",
+ "ToolTip": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\MainWindow.xaml",
+ "RelativeToolTip": "WPFSerialAssistant\\MainWindow.xaml",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
+ "WhenOpened": "2025-05-27T09:37:17.264Z",
+ "EditorCaption": ""
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/.vs/WPFSerialAssistant/v17/DocumentLayout.json b/.vs/WPFSerialAssistant/v17/DocumentLayout.json
new file mode 100644
index 0000000..a2c9073
--- /dev/null
+++ b/.vs/WPFSerialAssistant/v17/DocumentLayout.json
@@ -0,0 +1,104 @@
+{
+ "Version": 1,
+ "WorkspaceRootPath": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\",
+ "Documents": [
+ {
+ "AbsoluteMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\wpfserialassistant\\mainwindow.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
+ "RelativeMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|solutionrelative:wpfserialassistant\\mainwindow.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
+ },
+ {
+ "AbsoluteMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|c:\\users\\hp\\documents\\github\\serialassistant\\wpfserialassistant\\mainwindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}",
+ "RelativeMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|solutionrelative:wpfserialassistant\\mainwindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}"
+ },
+ {
+ "AbsoluteMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\wpfserialassistant\\saserialport.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
+ "RelativeMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|solutionrelative:wpfserialassistant\\saserialport.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
+ },
+ {
+ "AbsoluteMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\wpfserialassistant\\selectdialog.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
+ "RelativeMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|solutionrelative:wpfserialassistant\\selectdialog.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
+ },
+ {
+ "AbsoluteMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\wpfserialassistant\\selectdialog.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}",
+ "RelativeMoniker": "D:0:0:{DA01B86D-5BC1-4863-BAAC-71B309B09CC0}|WPFSerialAssistant\\WPFSerialAssistant.csproj|solutionrelative:wpfserialassistant\\selectdialog.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}"
+ }
+ ],
+ "DocumentGroupContainers": [
+ {
+ "Orientation": 0,
+ "VerticalTabListWidth": 256,
+ "DocumentGroups": [
+ {
+ "DockedWidth": 200,
+ "SelectedChildIndex": 4,
+ "Children": [
+ {
+ "$type": "Bookmark",
+ "Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}"
+ },
+ {
+ "$type": "Document",
+ "DocumentIndex": 3,
+ "Title": "SelectDialog.xaml.cs",
+ "DocumentMoniker": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\SelectDialog.xaml.cs",
+ "RelativeDocumentMoniker": "WPFSerialAssistant\\SelectDialog.xaml.cs",
+ "ToolTip": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\SelectDialog.xaml.cs",
+ "RelativeToolTip": "WPFSerialAssistant\\SelectDialog.xaml.cs",
+ "ViewState": "AgIAAAAAAAAAAAAAAAAAABYAAAAAAAAAAAAAAA==",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
+ "WhenOpened": "2025-08-01T09:06:28.406Z"
+ },
+ {
+ "$type": "Document",
+ "DocumentIndex": 4,
+ "Title": "SelectDialog.xaml",
+ "DocumentMoniker": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\SelectDialog.xaml",
+ "RelativeDocumentMoniker": "WPFSerialAssistant\\SelectDialog.xaml",
+ "ToolTip": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\SelectDialog.xaml",
+ "RelativeToolTip": "WPFSerialAssistant\\SelectDialog.xaml",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
+ "WhenOpened": "2025-08-01T09:05:51.188Z"
+ },
+ {
+ "$type": "Document",
+ "DocumentIndex": 2,
+ "Title": "SASerialPort.cs",
+ "DocumentMoniker": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\SASerialPort.cs",
+ "RelativeDocumentMoniker": "WPFSerialAssistant\\SASerialPort.cs",
+ "ToolTip": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\SASerialPort.cs",
+ "RelativeToolTip": "WPFSerialAssistant\\SASerialPort.cs",
+ "ViewState": "AgIAAJ0AAAAAAAAAAAAQwL0AAAAAAAAAAAAAAA==",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
+ "WhenOpened": "2025-05-27T10:09:27.392Z"
+ },
+ {
+ "$type": "Document",
+ "DocumentIndex": 0,
+ "Title": "MainWindow.xaml.cs",
+ "DocumentMoniker": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\MainWindow.xaml.cs",
+ "RelativeDocumentMoniker": "WPFSerialAssistant\\MainWindow.xaml.cs",
+ "ToolTip": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\MainWindow.xaml.cs",
+ "RelativeToolTip": "WPFSerialAssistant\\MainWindow.xaml.cs",
+ "ViewState": "AgIAAAgBAAAAAAAAAAAAADwBAAAJAAAAAAAAAA==",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
+ "WhenOpened": "2025-05-27T09:53:13.299Z",
+ "EditorCaption": ""
+ },
+ {
+ "$type": "Document",
+ "DocumentIndex": 1,
+ "Title": "MainWindow.xaml",
+ "DocumentMoniker": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\MainWindow.xaml",
+ "RelativeDocumentMoniker": "WPFSerialAssistant\\MainWindow.xaml",
+ "ToolTip": "C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\MainWindow.xaml",
+ "RelativeToolTip": "WPFSerialAssistant\\MainWindow.xaml",
+ "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|",
+ "WhenOpened": "2025-05-27T09:37:17.264Z",
+ "EditorCaption": ""
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite
new file mode 100644
index 0000000..1d4bb13
Binary files /dev/null and b/.vs/slnx.sqlite differ
diff --git a/DebugPics/1.PNG b/DebugPics/1.PNG
deleted file mode 100644
index 5c9c14b..0000000
Binary files a/DebugPics/1.PNG and /dev/null differ
diff --git a/DebugPics/2.PNG b/DebugPics/2.PNG
deleted file mode 100644
index 445df30..0000000
Binary files a/DebugPics/2.PNG and /dev/null differ
diff --git a/DebugPics/3.PNG b/DebugPics/3.PNG
deleted file mode 100644
index 8e1343a..0000000
Binary files a/DebugPics/3.PNG and /dev/null differ
diff --git a/DebugPics/4.PNG b/DebugPics/4.PNG
deleted file mode 100644
index d2d907b..0000000
Binary files a/DebugPics/4.PNG and /dev/null differ
diff --git a/DebugPics/5.PNG b/DebugPics/5.PNG
deleted file mode 100644
index 971de4c..0000000
Binary files a/DebugPics/5.PNG and /dev/null differ
diff --git a/README.md b/README.md
index 2f571b8..71069f0 100644
--- a/README.md
+++ b/README.md
@@ -1,127 +1,41 @@
-# WPFSerialAssitan 串口助手
+# WPFSerialAssistant 串口助手
+
------------------
## 引言
+
**一款基于C#及WPF的串口助手软件。本串口助手操作方便,UI简洁。软件实现了基本的串口通讯需要的功能,开发者可以基于此添加自定义的功能。此外,可以基于此开发出一些简单的串口控制类软件。**
## 项目主页
-* [基于WPF开放源码的串口调试助手(https://github.com/ChrisLeeGit/SerialAssistant)](https://github.com/ChrisLeeGit/SerialAssistant)
-
-
-## 基本功能
-* 串口数据接收,可以采用多种模式显示接收到的数据:字符,十六进制等
-* 串口数据发送,可以手动/间隔自动发送
-* 保存串口接收到显示区的数据
-* 保存/加载软件配置
-* 独创的“简洁视图模式”, 便于用户专注于数据的接收和发送
-
-## 使用帮助
-**软件操作比较简单,不作过多的介绍。**
-
-
-## 测试图片
-### 启动初始化截图
-
-
-### 打开端口并接收数据
-
-
-### 可自由隐藏的设置面板
-
-
-
-### 简洁无干扰的视图
-
-
-## 使用到的开源库
-* 本软件使用的一个开源的Json.Net库,可以非常方便地使用它用Json格式存储配置信息或者加载Json格式的配置文件。其主页为:http://www.newtonsoft.com/json。
-
-## 自由开发
-这个是一个完整的Visual Studio 2015工程,直接Clone下来即可。
-## 相关开源项目
-暑假同时完成了一个基于Arduino的太阳能自动供水系统。当然,这个系统并没有实际使用上,但是设计的功能基本都实现了。这个项目属于比较综合的了。使用了串口通信的方式与PC端的控制软件进行通信。该PC串口控制软件可以给单片机发送自定义的控制指令,并被执行。所以,便涉及到通信用的自定义的协议设计,Arduino指令解析系统的设计和实现。如果感兴趣的话,也同样可以关注,共同学习进步!!谢谢!以下是项目托管地址:
+- Github:[基于WPF开放源码的串口调试助手](https://github.com/tylhk/SerialAssistant)
+- Blog:[WPFSerialAssistant 串口助手](https://satone1008.cn/wp-admin/post.php?post=412&action=edit)
-1. Github地址:https://github.com/ChrisLeeGit/AutomaticWaterSupplySystem
-2. CSDN Code地址:https://code.csdn.net/u011193957/automaticwatersupplysystem
+## 原项目主页
-# 更新日志
-## 2016年1月24日 周日 Version 1.3
-### 功能
-* 新增 支持多种编码方式,中文收发测试正常
-* 新增 支持发送追加特殊内容,如换行(\n)等,参见“设置->发送追加”菜单项
-* 新增 软件配置信息新增配置项的保存和复原
-* 新增 状态栏新增数据接收状态指示
+* [基于WPF开放源码的串口调试助手](https://github.com/ChrisLeeGit/SerialAssistant)
-### Bug修复
-* 修复 状态栏显示问题:自动发送时状态栏不能正常提示
-* 修复 工具包函数库有时出现字符串转换异常的问题
-
-### 其他
-* 无需再像上一个版本那样,发送换行符时需要手动添加ASCII码,简化了操作
-* 程序的稳定性进一步提升
-
-## 2016年1月21日 周四 Version 1.2
-### 功能
-* 新增 接收到的串口数据可以选择使用某种方式显示:`字符串`,`二进制`,`八进制`,`十进制`,`十六进制`等形式
-* 新增 串口发送可以选择`字符串`和`十六进制`两种模式
-* 新增 给部分面板添加了可滚动的布局,可以自适应窗口尺寸,增加了窗口变化的灵活性
-* 新增 串口数据处理时,采用了一个缓冲区来暂存接收到的数据,当到达一定阈值后,会启动数据处理的线程在后台处理和分析数据,而不会阻塞接收线程,提高了程序的稳定性和可靠性
-
-### Bug修复
-* 修复 某些情况下因为接收数据缓冲区数据没有到达指定阈值而迟迟得不到处理的问题
-* 修复 部分界面显示问题
-* 修复 串口数据接收稳定性问题
-
-## 其他
-* 如何发送带有特殊转义字符的文本数据?
- * 首选选择发送方式为`字符`模式,然后在发送框中输入要发送的文本`Hello world!`
- * 然后选择发送方式为`十六进制`模式,然后再文本输入框中追加要发送的转义字符ASCII码,如换行符`0A`
- * 接下来再次切换到`字符`模式,此时再进行发送时便会将换行符号一并发送了。
-
-* 测试发现,即使发送间隔为1ms,由于采用了多线程模式,软件整体运行正常,数据显示正常,没有卡顿的现象
-
-
-## 2015年9月20日 周日 Version 1.1
-### 功能
-* 新增 软件启动后自动查找可用端口号功能
-* 新增 保存接受区数据到指定存储路径功能
-* 新增 软件退出前自动关闭已开启的端口号;询问是否保存软件的配置功能
-* 新增 快捷保存数据功能(左Ctrl+S)
-* 新增 快捷进入/退出“简洁视图模式”功能(左Ctrl+Enter)
-* 新增 恢复通过菜单项进入或者退出“简洁视图模式”功能
+## 基本功能
-### Bug修复
-* 修复 软件启动后没有恢复到配置保存的上次关闭的位置
-* 修复 退出菜单项无效的问题
-* 修复 某种特别情况下,从简洁视图模式恢复时出现崩溃的现象
+* 串口数据接收,可以采用多种模式显示接收到的数据:字符,十六进制等
-### 其他
-* 移除菜单项“保存(S)”,该菜单项功能与面板中保存数据按钮功能重复
-* 添加“关于”窗体
-* 版本号升级到Version 1.1
+* 串口数据发送,可以手动/间隔自动发送
+* 保存串口接收到显示区的数据
-## 2015年9月15日 周二 Version 1.0
-### 功能
-* 新增 配置信息保存功能,目前保存的配置信息有:
- * 波特率
- * 奇偶校验位
- * 数据位
- * 停止位
- * 字节编码
- * 发送区文本内容
- * 自动发送时间间隔
- * 窗口状态:最大化|高度+宽度
- * 面板显示状态
+* 保存/加载软件配置
-* 新增 软件启动后自动加载配置信息功能
+* 独创的“简洁视图模式”, 便于用户专注于数据的接收和发送
-### Bug修复
-* 加载面板显示配置信息后,面板状态与对应菜单项显示不一致的问题
+## 更新日志
-### 其他
-* 移除菜单“加载配置(L)”,改为软件启动后自动查找配置并加载
-* 移除菜单“简洁模式”,当手动将三个面板全部隐藏后自动进入“简洁模式”,暂时去除一键进入“简洁模式”功能菜单
+### 2025/5/26
+- 增加接收数据时间戳
+- 增加常用命令面板
+- 添加字号调整
+### 2025/5/27
+- 优化字号显示(是否需要储存字号设置?)
+- 优化常用命令面板
+- 增添面板分页功能
diff --git a/WPFSerialAssistant/.vs/WPFSerialAssistant.csproj.dtbcache.json b/WPFSerialAssistant/.vs/WPFSerialAssistant.csproj.dtbcache.json
new file mode 100644
index 0000000..4832c1b
--- /dev/null
+++ b/WPFSerialAssistant/.vs/WPFSerialAssistant.csproj.dtbcache.json
@@ -0,0 +1 @@
+{"RootPath":"C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant","ProjectFileName":"WPFSerialAssistant.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"About.xaml.cs"},{"SourceFile":"CommandConfig.cs"},{"SourceFile":"CommandItem.cs"},{"SourceFile":"CommandSettingsWindow.xaml.cs"},{"SourceFile":"Core.cs"},{"SourceFile":"InputDialog.xaml.cs"},{"SourceFile":"SAFile.cs"},{"SourceFile":"SASerialPort.cs"},{"SourceFile":"SATimer.cs"},{"SourceFile":"SAViewMode.cs"},{"SourceFile":"Utilities.cs"},{"SourceFile":"App.xaml.cs"},{"SourceFile":"configuration\\Configuration.cs"},{"SourceFile":"EventHandler.cs"},{"SourceFile":"MainWindow.xaml.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"Properties\\Resources.Designer.cs"},{"SourceFile":"Properties\\Settings.Designer.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.8.AssemblyAttributes.cs"},{"SourceFile":"C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\obj\\Debug\\About.g.cs"},{"SourceFile":"C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\obj\\Debug\\CommandSettingsWindow.g.cs"},{"SourceFile":"C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\obj\\Debug\\InputDialog.g.cs"},{"SourceFile":"C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\obj\\Debug\\MainWindow.g.cs"},{"SourceFile":"C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\obj\\Debug\\App.g.cs"}],"References":[{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\Microsoft.CSharp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\packages\\Newtonsoft.Json.13.0.3\\lib\\net45\\Newtonsoft.Json.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\PresentationCore.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\PresentationFramework.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.DataSetExtensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Net.Http.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xaml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\WindowsBase.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"C:\\Users\\hp\\Documents\\GitHub\\SerialAssistant\\WPFSerialAssistant\\bin\\Debug\\WPFSerialAssistant.exe","OutputItemRelativePath":"WPFSerialAssistant.exe"},{"OutputItemFullPath":"","OutputItemRelativePath":""}],"CopyToOutputEntries":[]}
\ No newline at end of file
diff --git a/WPFSerialAssistant/About.xaml b/WPFSerialAssistant/About.xaml
index 70dd07b..7b91753 100644
--- a/WPFSerialAssistant/About.xaml
+++ b/WPFSerialAssistant/About.xaml
@@ -22,11 +22,12 @@
- 鐗堟湰缂栧彿锛歏erison 1.3
- 鏇存柊鏃ユ湡锛2016骞01鏈24鏃 鏄熸湡鏃
- 杞欢浣滆咃細Christopher Lee
- 鍙嶉閭锛歝hristopherlee1993@outlook.com
- 灏忓皬璇存槑锛氬紑鏀炬簮鐮侊紝閲囩敤MIT鍗忚銆傛湜鍏卞悓瀛︿範杩涙銆
+ 鐗堟湰鍙凤細1.3.2
+ 鍘熶綔鑰咃細Christopher Lee
+ 鍘熶綔鑰呴偖绠憋細christopherlee1993@outlook.com
+ 鏂扮増鏈础鐚咃細Satone
+ 椤圭洰椤甸潰锛歨ttps://github.com/tylhk/SerialAssistant
+ 璇存槑锛氬紑鏀炬簮鐮侊紝閲囩敤MIT鍗忚銆傛湜鍏卞悓瀛︿範杩涙銆
diff --git a/WPFSerialAssistant/App.config b/WPFSerialAssistant/App.config
index e707b32..92c094c 100644
--- a/WPFSerialAssistant/App.config
+++ b/WPFSerialAssistant/App.config
@@ -2,5 +2,5 @@
-
+
diff --git a/WPFSerialAssistant/CommandConfig.cs b/WPFSerialAssistant/CommandConfig.cs
new file mode 100644
index 0000000..023f65b
--- /dev/null
+++ b/WPFSerialAssistant/CommandConfig.cs
@@ -0,0 +1,16 @@
+锘// CommandConfig.cs
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WPFSerialAssistant
+{
+ public class CommandConfig
+ {
+ public List> AllPagesCommands { get; set; }
+ public int CurrentPageIndex { get; set; } = 0; // 榛樿鏄剧ず绗竴椤
+ public List PageNames { get; set; } = new List(); // 鏂板灞炴у瓨鍌ㄩ〉闈㈠悕绉
+ }
+}
diff --git a/WPFSerialAssistant/CommandItem.cs b/WPFSerialAssistant/CommandItem.cs
new file mode 100644
index 0000000..e04cb80
--- /dev/null
+++ b/WPFSerialAssistant/CommandItem.cs
@@ -0,0 +1,11 @@
+锘縰sing System;
+
+namespace WPFSerialAssistant
+{
+ [Serializable] // 鍏抽敭搴忓垪鍖栨爣璁
+ public class CommandItem
+ {
+ public string Name { get; set; }
+ public string Value { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/WPFSerialAssistant/CommandSettingsWindow.xaml b/WPFSerialAssistant/CommandSettingsWindow.xaml
new file mode 100644
index 0000000..260aec6
--- /dev/null
+++ b/WPFSerialAssistant/CommandSettingsWindow.xaml
@@ -0,0 +1,45 @@
+锘
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WPFSerialAssistant/CommandSettingsWindow.xaml.cs b/WPFSerialAssistant/CommandSettingsWindow.xaml.cs
new file mode 100644
index 0000000..7312307
--- /dev/null
+++ b/WPFSerialAssistant/CommandSettingsWindow.xaml.cs
@@ -0,0 +1,200 @@
+锘// CommandSettingsWindow.xaml.cs
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+
+namespace WPFSerialAssistant
+{
+ public partial class CommandSettingsWindow : Window
+ {
+ public List> AllPagesCommands => commandConfig.AllPagesCommands;
+ public int CurrentPageIndex => commandConfig.CurrentPageIndex;
+
+ private CommandConfig commandConfig;
+ private int currentPageIndex = 0;
+
+ public CommandSettingsWindow(CommandConfig config)
+ {
+ InitializeComponent();
+ commandConfig = config;
+
+ // 纭繚鏈夎嚦灏戜竴涓〉闈
+ if (commandConfig.AllPagesCommands == null || commandConfig.AllPagesCommands.Count == 0)
+ {
+ commandConfig.AllPagesCommands = new List> { new List() };
+ commandConfig.PageNames.Add("椤甸潰1");
+ }
+
+ // 鍔犺浇椤甸潰鍒楄〃
+ for (int i = 0; i < commandConfig.AllPagesCommands.Count; i++)
+ {
+ if (commandConfig.PageNames.Count <= i)
+ {
+ commandConfig.PageNames.Add($"椤甸潰{i + 1}");
+ }
+ pageListBox.Items.Add(commandConfig.PageNames[i]);
+ }
+
+ // 閫変腑褰撳墠椤甸潰
+ if (commandConfig.CurrentPageIndex < pageListBox.Items.Count)
+ {
+ pageListBox.SelectedIndex = commandConfig.CurrentPageIndex;
+ }
+ else
+ {
+ pageListBox.SelectedIndex = 0;
+ }
+
+ commandDataGrid.DataContext = this;
+ }
+
+ private void DeletePageButton_Click(object sender, RoutedEventArgs e)
+ {
+ if (pageListBox.SelectedIndex >= 0 && commandConfig.AllPagesCommands.Count > 1) // 纭繚鑷冲皯鏈変竴涓〉闈
+ {
+ int selectedIndex = pageListBox.SelectedIndex;
+ commandConfig.AllPagesCommands.RemoveAt(selectedIndex);
+ commandConfig.PageNames.RemoveAt(selectedIndex);
+ pageListBox.Items.RemoveAt(selectedIndex);
+
+ if (pageListBox.Items.Count > 0)
+ {
+ if (selectedIndex < pageListBox.Items.Count)
+ {
+ pageListBox.SelectedIndex = selectedIndex;
+ }
+ else
+ {
+ pageListBox.SelectedIndex = pageListBox.Items.Count - 1;
+ }
+ }
+ else
+ {
+ // 濡傛灉娌℃湁椤甸潰浜嗭紝娣诲姞涓涓柊椤甸潰
+ commandConfig.AllPagesCommands.Add(new List());
+ commandConfig.PageNames.Add("椤甸潰1");
+ pageListBox.Items.Add(commandConfig.PageNames[0]);
+ pageListBox.SelectedIndex = 0;
+ }
+
+ commandDataGrid.ItemsSource = CurrentCommands;
+ }
+ }
+
+ public List CurrentCommands
+ {
+ get
+ {
+ if (commandConfig.AllPagesCommands != null &&
+ commandConfig.AllPagesCommands.Count > currentPageIndex)
+ {
+ return commandConfig.AllPagesCommands[currentPageIndex];
+ }
+ return new List();
+ }
+ }
+
+ private void AddPageButton_Click(object sender, RoutedEventArgs e)
+ {
+ commandConfig.AllPagesCommands.Add(new List());
+ string newPageName = $"椤甸潰{commandConfig.AllPagesCommands.Count}";
+ commandConfig.PageNames.Add(newPageName);
+ pageListBox.Items.Add(newPageName);
+ pageListBox.SelectedIndex = commandConfig.AllPagesCommands.Count - 1;
+ }
+
+ private void PageListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (pageListBox.SelectedIndex >= 0)
+ {
+ currentPageIndex = pageListBox.SelectedIndex;
+ commandConfig.CurrentPageIndex = currentPageIndex; // 鏇存柊褰撳墠閫変腑椤甸潰
+ commandDataGrid.ItemsSource = CurrentCommands;
+ }
+ }
+
+ private void AddCommandButton_Click(object sender, RoutedEventArgs e)
+ {
+ CurrentCommands.Add(new MainWindow.CommandItem { Name = "", Value = "" });
+ commandDataGrid.Items.Refresh();
+ }
+
+ private void DeleteCommandButton_Click(object sender, RoutedEventArgs e)
+ {
+ if (commandDataGrid.SelectedItem != null)
+ {
+ CurrentCommands.Remove(commandDataGrid.SelectedItem as MainWindow.CommandItem);
+ commandDataGrid.Items.Refresh();
+ }
+ }
+
+ private void SaveButton_Click(object sender, RoutedEventArgs e)
+ {
+ DialogResult = true;
+ Close();
+ }
+
+ private void PageListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
+ {
+ if (pageListBox.SelectedIndex >= 0)
+ {
+ var inputWindow = new InputWindow((string)pageListBox.SelectedItem);
+ if (inputWindow.ShowDialog() == true)
+ {
+ string newName = inputWindow.InputText;
+ if (!string.IsNullOrEmpty(newName))
+ {
+ int selectedIndex = pageListBox.SelectedIndex;
+ commandConfig.PageNames[selectedIndex] = newName;
+ pageListBox.Items[selectedIndex] = newName;
+ }
+ }
+ }
+ }
+ }
+
+ public class InputWindow : Window
+ {
+ public string InputText { get; set; }
+
+ public InputWindow(string initialText)
+ {
+ Title = "閲嶅懡鍚嶉〉闈";
+ Width = 300;
+ Height = 150;
+ ResizeMode = ResizeMode.NoResize;
+ WindowStartupLocation = WindowStartupLocation.CenterOwner;
+
+ var stackPanel = new StackPanel { Margin = new Thickness(10) };
+
+ var textBox = new TextBox { Text = initialText };
+ stackPanel.Children.Add(textBox);
+
+ var buttonPanel = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Right };
+
+ var okButton = new Button { Content = "纭畾", Width = 75, Margin = new Thickness(5) };
+ okButton.Click += (sender, e) =>
+ {
+ InputText = textBox.Text;
+ DialogResult = true;
+ Close();
+ };
+ buttonPanel.Children.Add(okButton);
+
+ var cancelButton = new Button { Content = "鍙栨秷", Width = 75, Margin = new Thickness(5) };
+ cancelButton.Click += (sender, e) =>
+ {
+ DialogResult = false;
+ Close();
+ };
+ buttonPanel.Children.Add(cancelButton);
+
+ stackPanel.Children.Add(buttonPanel);
+
+ Content = stackPanel;
+ }
+ }
+}
diff --git a/WPFSerialAssistant/Core.cs b/WPFSerialAssistant/Core.cs
index 144a47c..a5f2dfa 100644
--- a/WPFSerialAssistant/Core.cs
+++ b/WPFSerialAssistant/Core.cs
@@ -4,6 +4,7 @@
using System.Text;
//using System.Threading.Tasks;
using System.Windows;
+using System.Windows.Documents;
using System.Windows.Media;
namespace WPFSerialAssistant
@@ -22,11 +23,33 @@ private void InitCore()
InitClockTimer();
InitAutoSendDataTimer();
InitSerialPort();
-
+ // 鏂板锛氬垵濮嬪寲鎵归噺澶勭悊瀹氭椂鍣紙闂撮殧璁句负100ms锛
+ _batchTimer.Interval = TimeSpan.FromMilliseconds(100);
+ _batchTimer.Tick += BatchTimer_Tick;
+ _batchTimer.IsEnabled = true;
// 鏌ユ壘鍙互浣跨敤鐨勭鍙e彿
FindPorts();
}
-
+ private void BatchTimer_Tick(object sender, EventArgs e)
+ {
+ _batchTimer.Stop();
+ lock (_batchLock)
+ {
+ if (_batchBuffer.Length > 0)
+ {
+ string timestamp = DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss] ");
+ Dispatcher.Invoke(() =>
+ {
+ Paragraph para = new Paragraph();
+ Run run = new Run(timestamp + _batchBuffer.ToString() + "\n");
+ para.Inlines.Add(run);
+ recvDataRichTextBox.Document.Blocks.Add(para);
+ recvDataRichTextBox.ScrollToEnd();
+ });
+ _batchBuffer.Clear();
+ }
+ }
+ }
#region 鐘舵佹爮
///
/// 鏇存柊鏃堕棿淇℃伅
@@ -78,15 +101,6 @@ private void Information(string message)
#endregion
- private void RecvDataBoxAppend(string textData)
- {
- if (showRecvDataCheckBox.IsChecked == true)
- {
- this.recvDataRichTextBox.AppendText(textData);
- this.recvDataRichTextBox.ScrollToEnd();
- }
- }
-
private bool SendData()
{
string textToSend = sendDataTextBox.Text;
diff --git a/WPFSerialAssistant/EventHandler.cs b/WPFSerialAssistant/EventHandler.cs
index eac33fb..4f8dc32 100644
--- a/WPFSerialAssistant/EventHandler.cs
+++ b/WPFSerialAssistant/EventHandler.cs
@@ -1,10 +1,13 @@
锘縰sing System;
using System.Collections.Generic;
+using System.Diagnostics;
+using System.Security.Policy;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
+using static System.Net.WebRequestMethods;
namespace WPFSerialAssistant
{
@@ -142,7 +145,11 @@ private void aboutMenuItem_Click(object sender, RoutedEventArgs e)
private void helpMenuItem_Click(object sender, RoutedEventArgs e)
{
-
+ Process.Start(new ProcessStartInfo
+ {
+ FileName = "https://github.com/tylhk/SerialAssistant",
+ UseShellExecute = true
+ });
}
#endregion
@@ -361,7 +368,7 @@ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs
}
// 鎻愮ず鏄惁闇瑕佷繚瀛橀厤缃埌鏂囦欢涓
- if (MessageBox.Show("鏄惁鍦ㄩ鍑哄墠淇濆瓨杞欢閰嶇疆锛", "灏忚创澹", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
+ if (MessageBox.Show("鏄惁鍦ㄩ鍑哄墠淇濆瓨杞欢閰嶇疆锛", "鎻愮ず", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
{
SaveConfig();
}
@@ -493,30 +500,30 @@ private void ReceivedDataHandler(object obj)
{
List recvBuffer = new List();
recvBuffer.AddRange((List)obj);
+ shouldClear = true;
if (recvBuffer.Count == 0)
{
return;
}
- // 蹇呴』搴斿綋淇濊瘉鍏ㄥ眬缂撳啿鍖虹殑鏁版嵁鑳藉琚畬鏁村湴澶囦唤鍑烘潵锛岃繖鏍锋墠鑳借繘琛岃繘涓姝ョ殑澶勭悊銆
- shouldClear = true;
+ // 灏嗗瓧鑺傛暟鎹浆鎹负鏂囨湰
+ string dataText = Utilities.BytesToText(recvBuffer, receiveMode, serialPort.Encoding);
- this.Dispatcher.Invoke(new Action(() =>
+ // 灏嗘暟鎹殏瀛樺埌鎵归噺缂撳啿鍖
+ lock (_batchLock)
{
- if (showReceiveData)
- {
- // 鏍规嵁鏄剧ず妯″紡鏄剧ず鎺ユ敹鍒扮殑瀛楄妭.
- recvDataRichTextBox.AppendText(Utilities.BytesToText(recvBuffer, receiveMode, serialPort.Encoding));
- recvDataRichTextBox.ScrollToEnd();
- }
-
- dataRecvStatusBarItem.Visibility = Visibility.Collapsed;
- }));
+ _batchBuffer.Append(dataText);
+ }
- // TO-DO锛
- // 澶勭悊鏁版嵁锛屾瘮濡傝В鏋愭寚浠ょ瓑绛
+ // 閲嶇疆鎵归噺澶勭悊瀹氭椂鍣紙鍋滄鍚庨噸鏂板惎鍔級
+ Dispatcher.Invoke(() =>
+ {
+ _batchTimer.Stop();
+ _batchTimer.Start();
+ });
}
+
#endregion
}
}
diff --git a/WPFSerialAssistant/InputDialog.xaml b/WPFSerialAssistant/InputDialog.xaml
new file mode 100644
index 0000000..f35adc3
--- /dev/null
+++ b/WPFSerialAssistant/InputDialog.xaml
@@ -0,0 +1,14 @@
+锘
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WPFSerialAssistant/InputDialog.xaml.cs b/WPFSerialAssistant/InputDialog.xaml.cs
new file mode 100644
index 0000000..09f4e78
--- /dev/null
+++ b/WPFSerialAssistant/InputDialog.xaml.cs
@@ -0,0 +1,37 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace WPFSerialAssistant
+{
+ public partial class InputDialog : Window
+ {
+ public string Answer1 { get; set; }
+ public string Answer2 { get; set; }
+
+ public InputDialog(string title, string prompt1, string prompt2)
+ {
+ InitializeComponent();
+ Title = title;
+ promptText1.Text = prompt1;
+ promptText2.Text = prompt2;
+ }
+
+ private void OkButton_Click(object sender, RoutedEventArgs e)
+ {
+ Answer1 = answerTextBox1.Text;
+ Answer2 = answerTextBox2.Text;
+ DialogResult = true; // 鍏抽棴瀵硅瘽妗嗗苟杩斿洖true
+ }
+ }
+}
diff --git a/WPFSerialAssistant/MainWindow.xaml b/WPFSerialAssistant/MainWindow.xaml
index 980454d..e48eeb8 100644
--- a/WPFSerialAssistant/MainWindow.xaml
+++ b/WPFSerialAssistant/MainWindow.xaml
@@ -5,9 +5,9 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPFSerialAssistant"
mc:Ignorable="d" WindowStartupLocation="CenterScreen"
- Title="涓插彛鍔╂墜(Version 1.3)" Height="600" Width="1024"
+ Title="涓插彛鍔╂墜" Height="760" Width="1325"
MinHeight="550" MinWidth="1024"
- Icon="1.ico" Closing="Window_Closing" PreviewKeyDown="Window_KeyDown">
+ Icon="1.ico" Closing="Window_Closing" PreviewKeyDown="Window_KeyDown" >
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ 瀛楃涓
+ 鍗佸叚杩涘埗
+ 鍗佽繘鍒
+ 鍏繘鍒
+ 浜岃繘鍒
+
+
+
+
+
+
+
+
+
- 瀛楃涓
- 鍗佸叚杩涘埗
- 鍗佽繘鍒
- 鍏繘鍒
- 浜岃繘鍒
+
+
+
+
-
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
- 鑷姩鍙戦佹椂闂撮棿闅
-
-
- 姣
- 绉掗挓
- 鍒嗛挓
-
+
+
+
+
+
+
+
+ 鑷姩鍙戦佹椂闂撮棿闅
+
+
+ 姣
+ 绉掗挓
+ 鍒嗛挓
+
-
- 浣胯兘鑷姩鍙戦
-
-
+
+ 浣胯兘鑷姩鍙戦
+
+
@@ -254,7 +300,7 @@
-
+
diff --git a/WPFSerialAssistant/MainWindow.xaml.cs b/WPFSerialAssistant/MainWindow.xaml.cs
index 98565b4..8860324 100644
--- a/WPFSerialAssistant/MainWindow.xaml.cs
+++ b/WPFSerialAssistant/MainWindow.xaml.cs
@@ -1,7 +1,13 @@
-锘縰sing System;
+锘縰sing Newtonsoft.Json;
+using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+
//using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
@@ -12,7 +18,8 @@
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
-
+using System.Windows.Threading;
+using Path = System.IO.Path;
namespace WPFSerialAssistant
{
///
@@ -20,10 +27,351 @@ namespace WPFSerialAssistant
///
public partial class MainWindow : Window
{
+ private StringBuilder _batchBuffer = new StringBuilder(); // 鍚堝苟鐭椂闂村唴鐨勬暟鎹
+ private DispatcherTimer _batchTimer = new DispatcherTimer(); // 鎵归噺澶勭悊瀹氭椂鍣
+ private readonly object _batchLock = new object(); // 绾跨▼閿
+
+ private static readonly string ConfigFolder =
+ Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WPFSerialAssistant");
+
+ private static readonly string CommandsFilePath =
+ Path.Combine(ConfigFolder, "commands.json");
+
+ private List> allPagesCommands = new List>();
+ private CommandConfig commandConfig = new CommandConfig();
+
+
+ // 淇濆瓨鍛戒护鍒楄〃鍒癑SON鏂囦欢
+ private void SaveCommands()
+ {
+ try
+ {
+ // 纭繚鏂囦欢澶瑰瓨鍦
+ Directory.CreateDirectory(ConfigFolder);
+
+ // 灏嗗懡浠ら厤缃簭鍒楀寲涓篔SON瀛楃涓
+ string json = JsonConvert.SerializeObject(commandConfig, Formatting.Indented);
+
+ // 灏咼SON瀛楃涓插啓鍏ユ枃浠
+ File.WriteAllText(CommandsFilePath, json);
+ }
+ catch (DirectoryNotFoundException ex)
+ {
+ MessageBox.Show($"淇濆瓨鍛戒护澶辫触: 鏂囦欢澶 {ConfigFolder} 涓嶅瓨鍦ㄣ倇ex.Message}");
+ }
+ catch (UnauthorizedAccessException ex)
+ {
+ MessageBox.Show($"淇濆瓨鍛戒护澶辫触: 娌℃湁鏉冮檺璁块棶鏂囦欢 {CommandsFilePath}銆倇ex.Message}");
+ }
+ catch (IOException ex)
+ {
+ MessageBox.Show($"淇濆瓨鍛戒护澶辫触: 鏂囦欢璇诲啓閿欒銆倇ex.Message}");
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"淇濆瓨鍛戒护澶辫触: {ex.Message}");
+ }
+ }
+ private void LoadCommands()
+ {
+ try
+ {
+ if (File.Exists(CommandsFilePath))
+ {
+ string json = File.ReadAllText(CommandsFilePath);
+ commandConfig = JsonConvert.DeserializeObject(json) ?? new CommandConfig();
+
+ // 鍔犺浇褰撳墠閫変腑椤甸潰鐨勫懡浠
+ LoadCurrentPageCommands();
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show($"鍔犺浇鍛戒护澶辫触: {ex.Message}");
+ }
+ }
+ // 浠嶫SON鏂囦欢鍔犺浇鍛戒护鍒楄〃
+ private void LoadCurrentPageCommands()
+ {
+ cmdListBox.Items.Clear();
+
+ if (commandConfig.AllPagesCommands != null &&
+ commandConfig.AllPagesCommands.Count > commandConfig.CurrentPageIndex)
+ {
+ var currentCommands = commandConfig.AllPagesCommands[commandConfig.CurrentPageIndex];
+ foreach (var cmd in currentCommands)
+ {
+ cmdListBox.Items.Add(cmd);
+ }
+ }
+ }
+
public MainWindow()
{
InitializeComponent();
InitCore();
+ LoadCommands();
+ quickTestTimer.Interval = TimeSpan.FromMilliseconds(50);
+ quickTestTimer.Tick += QuickTestTimer_Tick;
+ }
+
+ private Dictionary> quickTestCmdDict = new Dictionary>
+ {
+ { "鍒濆鍖", new List { "AT", "AT+PRTR=1", "AT+PRTS=1", "AT+TEST=1," } },
+ { "淇¢亾1", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,1" } },
+ { "淇¢亾2", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,2" } },
+ { "淇¢亾3", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,3" } },
+ { "淇¢亾4", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,4" } },
+ { "淇¢亾5", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,5" } },
+ { "淇¢亾6", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,6" } },
+ { "淇¢亾7", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,7" } },
+ { "淇¢亾8", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,8" } },
+ { "淇¢亾9", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,9" } },
+ { "淇¢亾10", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,10" } },
+ { "淇¢亾11", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,11" } },
+ { "淇¢亾12", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,12" } },
+ { "淇¢亾13", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,13" } },
+ { "淇¢亾14", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,14" } },
+ { "淇¢亾15", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,15" } },
+ { "淇¢亾16", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,16" } },
+ { "淇¢亾17", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,17" } },
+ { "淇¢亾18", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,18" } },
+ { "淇¢亾19", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,19" } },
+ { "淇¢亾20", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,20" } },
+ { "淇¢亾21", new List { "AT", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+SEND=20,0302030405060708091003020304050607080910,1", "AT+TEST=1,21" } },
+ };
+ private List currentQuickTestCmdList = null;
+ private int quickTestCount = 0;
+ private int quickTestTotal = 0;
+ private DispatcherTimer quickTestTimer = new DispatcherTimer();
+ private void QuickTestButton_Click(object sender, RoutedEventArgs e)
+ {
+ // 寮瑰嚭鑷畾涔夐夋嫨绐楀彛
+ var dlg = new SelectDialog(quickTestCmdDict.Keys);
+ dlg.Owner = this;
+ if (dlg.ShowDialog() == true && !string.IsNullOrEmpty(dlg.SelectedType))
+ {
+ currentQuickTestCmdList = quickTestCmdDict[dlg.SelectedType];
+ quickTestCount = 0;
+ quickTestTotal = currentQuickTestCmdList.Count;
+ quickTestTimer.Start();
+ }
+ }
+
+
+
+ private void QuickTestTimer_Tick(object sender, EventArgs e)
+ {
+ if (quickTestCount < quickTestTotal)
+ {
+ string cmd = currentQuickTestCmdList[quickTestCount];
+ SerialPortWrite(cmd);
+ recvDataRichTextBox.ScrollToEnd();
+ quickTestCount++;
+ }
+ else
+ {
+ quickTestTimer.Stop();
+ }
+ }
+
+
+ // 鍛戒护鏁版嵁绫
+ public class CommandItem
+ {
+ public string Name { get; set; }
+ public string Value { get; set; }
+ }
+
+ // 鎺у埗闈㈡澘鍙鎬
+ private void CommonCommandsViewMenuItem_Click(object sender, RoutedEventArgs e)
+ {
+ var menuItem = sender as MenuItem;
+ menuItem.IsChecked = !menuItem.IsChecked; // 鍒囨崲鍕鹃夌姸鎬
+ commonCommandsPanel.Visibility = menuItem.IsChecked ? Visibility.Visible : Visibility.Collapsed;
+ }
+
+ // 浣跨敤鍛戒护
+ private void CmdListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (cmdListBox.SelectedItem is CommandItem selectedCmd)
+ {
+ SerialPortWrite(selectedCmd.Value);
+ }
+ }
+
+ private void SettingsButton_Click(object sender, RoutedEventArgs e)
+ {
+ // 纭繚鍛戒护閰嶇疆宸插垵濮嬪寲
+ if (commandConfig.AllPagesCommands == null)
+ commandConfig.AllPagesCommands = new List>();
+
+ var settingsWindow = new CommandSettingsWindow(commandConfig);
+ if (settingsWindow.ShowDialog() == true)
+ {
+ // 鏇存柊鍛戒护閰嶇疆
+ commandConfig.AllPagesCommands = settingsWindow.AllPagesCommands;
+ commandConfig.CurrentPageIndex = settingsWindow.CurrentPageIndex;
+
+ // 鍔犺浇褰撳墠閫変腑椤甸潰鐨勫懡浠
+ LoadCurrentPageCommands();
+
+ SaveCommands();
+ }
+ }
+
+ // 瀛楀彿鎺у埗鍙傛暟
+ private const double DefaultFontSize = 12; // 榛樿瀛楀彿锛堜笌XAML涓璅lowDocument璁剧疆涓鑷达級
+ private const double MinFontSize = 8; // 鏈灏忓瓧鍙
+ private const double MaxFontSize = 36; // 鏈澶у瓧鍙
+ private const double FontStep = 1; // 瀛楀彿璋冩暣姝ラ暱
+
+ // 鏀惧ぇ瀛楀彿
+ private void IncreaseFontSize_Click(object sender, RoutedEventArgs e)
+ {
+ if (recvDataRichTextBox.FontSize + FontStep <= MaxFontSize)
+ {
+ recvDataRichTextBox.FontSize += FontStep;
+ UpdateDocumentFontSize(recvDataRichTextBox.Document, recvDataRichTextBox.FontSize);
+ }
+ }
+
+ // 缂╁皬瀛楀彿
+ private void DecreaseFontSize_Click(object sender, RoutedEventArgs e)
+ {
+ if (recvDataRichTextBox.FontSize - FontStep >= MinFontSize)
+ {
+ recvDataRichTextBox.FontSize -= FontStep;
+ UpdateDocumentFontSize(recvDataRichTextBox.Document, recvDataRichTextBox.FontSize);
+ }
+ }
+
+ // 閲嶇疆瀛楀彿
+ private void ResetFontSize_Click(object sender, RoutedEventArgs e)
+ {
+ recvDataRichTextBox.FontSize = DefaultFontSize;
+ UpdateDocumentFontSize(recvDataRichTextBox.Document, DefaultFontSize);
+ }
+
+ // 鏇存柊鏂囨。鍐呮墍鏈夋枃瀛楀瓧鍙凤紙鍏煎宸叉湁鍐呭锛
+ private void UpdateDocumentFontSize(FlowDocument document, double newSize)
+ {
+ foreach (var block in document.Blocks)
+ {
+ if (block is Paragraph paragraph)
+ {
+ foreach (var inline in paragraph.Inlines)
+ {
+ if (inline is Run run)
+ {
+ run.FontSize = newSize;
+ }
+ }
+ }
+ }
+ }
+
+ private void FileDropBorder_DragOver(object sender, DragEventArgs e)
+ {
+ e.Effects = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None;
+ e.Handled = true;
+ }
+
+ private string sendFileFullPath = null;
+
+ private void FileDropBorder_Drop(object sender, DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(DataFormats.FileDrop))
+ {
+ string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
+ string path = files[0];
+ if (files.Length > 0)
+ {
+ filePathTextBlock.Text = System.IO.Path.GetFileName(path); // 鍙樉绀烘枃浠跺悕
+ filePathTextBlock.ToolTip = path; // 榧犳爣鎮仠鏄剧ず瀹屾暣璺緞
+ sendFileFullPath = path; // 淇濆瓨瀹屾暣璺緞
+ }
+ }
+ }
+
+ private void SelectFileButton_Click(object sender, RoutedEventArgs e)
+ {
+ var dialog = new Microsoft.Win32.OpenFileDialog();
+ if (dialog.ShowDialog() == true)
+ {
+ filePathTextBlock.Text = System.IO.Path.GetFileName(dialog.FileName);
+ filePathTextBlock.ToolTip = dialog.FileName;
+ sendFileFullPath = dialog.FileName;
+ }
}
+
+ private void SendFileButton_Click(object sender, RoutedEventArgs e)
+ {
+ string path = sendFileFullPath;
+ if (string.IsNullOrWhiteSpace(path) || !System.IO.File.Exists(path))
+ {
+ MessageBox.Show("璇烽夋嫨鏈夋晥鐨勬枃浠讹紒");
+ return;
+ }
+ SendFileBySerial(path);
+ }
+
+ private void SendFileBySerial(string filePath)
+ {
+ Task.Run(() =>
+ {
+ try
+ {
+ string[] lines = System.IO.File.ReadAllLines(filePath);
+ int total = lines.Length;
+
+ // 涓荤嚎绋嬫樉绀鸿繘搴︽潯
+ Application.Current.Dispatcher.Invoke(() =>
+ {
+ progressBar.Visibility = Visibility.Visible;
+ progressBar.Minimum = 0;
+ progressBar.Maximum = 100;
+ progressBar.Value = 0;
+ });
+
+ for (int i = 0; i < total; i++)
+ {
+ SerialPortWrite(lines[i], false); // 鍙彂閫侊紝涓嶅洖鏄
+
+ // 姣50琛屽埛鏂颁竴娆¤繘搴︽潯
+ if (i % 50 == 0 || i == total - 1)
+ {
+ int percent = (int)((i + 1) * 100.0 / total);
+ Application.Current.Dispatcher.Invoke(() =>
+ {
+ progressBar.Value = percent;
+ });
+ }
+
+ Thread.Sleep(1); // 瑙嗕綘鐨勮澶囨ц兘鍙皟灏忎竴鐐
+ }
+
+ Application.Current.Dispatcher.Invoke(() =>
+ {
+ progressBar.Visibility = Visibility.Collapsed;
+ MessageBox.Show($"鏂囦欢宸插叏閮ㄥ彂閫侊細{System.IO.Path.GetFileName(filePath)}");
+ });
+ }
+ catch (Exception ex)
+ {
+ Application.Current.Dispatcher.Invoke(() =>
+ {
+ progressBar.Visibility = Visibility.Collapsed;
+ MessageBox.Show($"鍙戦佹枃浠跺け璐ワ細{ex.Message}");
+ });
+ }
+ });
+ }
+
+
+
+
+
+
}
}
diff --git a/WPFSerialAssistant/Properties/Resources.Designer.cs b/WPFSerialAssistant/Properties/Resources.Designer.cs
index e467f8a..54b661e 100644
--- a/WPFSerialAssistant/Properties/Resources.Designer.cs
+++ b/WPFSerialAssistant/Properties/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace WPFSerialAssistant.Properties {
// 绫婚氳繃绫讳技浜 ResGen 鎴 Visual Studio 鐨勫伐鍏疯嚜鍔ㄧ敓鎴愮殑銆
// 鑻ヨ娣诲姞鎴栫Щ闄ゆ垚鍛橈紝璇风紪杈 .ResX 鏂囦欢锛岀劧鍚庨噸鏂拌繍琛 ResGen
// (浠 /str 浣滀负鍛戒护閫夐」)锛屾垨閲嶆柊鐢熸垚 VS 椤圭洰銆
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -47,8 +47,8 @@ internal Resources() {
}
///
- /// 浣跨敤姝ゅ己绫诲瀷璧勬簮绫伙紝涓烘墍鏈夎祫婧愭煡鎵
- /// 閲嶅啓褰撳墠绾跨▼鐨 CurrentUICulture 灞炴с
+ /// 閲嶅啓褰撳墠绾跨▼鐨 CurrentUICulture 灞炴э紝瀵
+ /// 浣跨敤姝ゅ己绫诲瀷璧勬簮绫荤殑鎵鏈夎祫婧愭煡鎵炬墽琛岄噸鍐欍
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
diff --git a/WPFSerialAssistant/Properties/Settings.Designer.cs b/WPFSerialAssistant/Properties/Settings.Designer.cs
index 9243b31..f53e224 100644
--- a/WPFSerialAssistant/Properties/Settings.Designer.cs
+++ b/WPFSerialAssistant/Properties/Settings.Designer.cs
@@ -12,7 +12,7 @@ namespace WPFSerialAssistant.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
diff --git a/WPFSerialAssistant/SASerialPort.cs b/WPFSerialAssistant/SASerialPort.cs
index 655e4ca..a13cd24 100644
--- a/WPFSerialAssistant/SASerialPort.cs
+++ b/WPFSerialAssistant/SASerialPort.cs
@@ -6,6 +6,8 @@
using System.Threading;
//using System.Threading.Tasks;
using System.Windows;
+using System.Windows.Documents;
+using System.Windows.Media;
using System.Windows.Threading;
namespace WPFSerialAssistant
@@ -185,21 +187,13 @@ private Encoding GetSelectedEncoding()
return enc;
}
- private bool SerialPortWrite(string textData)
- {
- SerialPortWrite(textData, false);
- return false;
- }
-
private string appendContent = "\n";
- private bool SerialPortWrite(string textData, bool reportEnable)
+ ///
+ /// 涓插彛鍐欏叆鏁版嵁銆傚彲閫夊洖鏄撅紙鐢ㄤ簬鎵嬪姩杈撳叆/鍗曟潯鍛戒护锛夈
+ ///
+ private bool SerialPortWrite(string textData, bool echoToUI = true)
{
- if (serialPort == null)
- {
- return false;
- }
-
- if (serialPort.IsOpen == false)
+ if (serialPort == null || !serialPort.IsOpen)
{
Alert("涓插彛鏈墦寮锛屾棤娉曞彂閫佹暟鎹");
return false;
@@ -207,9 +201,6 @@ private bool SerialPortWrite(string textData, bool reportEnable)
try
{
- //serialPort.DiscardOutBuffer();
- //serialPort.DiscardInBuffer();
-
if (sendMode == SendMode.Character)
{
serialPort.Write(textData + appendContent);
@@ -217,32 +208,45 @@ private bool SerialPortWrite(string textData, bool reportEnable)
else if (sendMode == SendMode.Hex)
{
string[] grp = textData.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
-
List list = new List();
-
foreach (var item in grp)
- {
list.Add(Convert.ToByte(item, 16));
- }
-
serialPort.Write(list.ToArray(), 0, list.Count);
}
-
- if (reportEnable)
- {
- // 鎶ュ憡鍙戦佹垚鍔熺殑娑堟伅锛屾彁绀虹敤鎴枫
- Information(string.Format("鎴愬姛鍙戦侊細{0}銆", textData));
- }
}
catch (Exception ex)
{
- Alert(ex.Message);
+ Application.Current.Dispatcher.Invoke(() => Alert(ex.Message));
return false;
}
+ // 鍥炴樉锛屽彧鑳藉湪UI绾跨▼
+ if (echoToUI && sendEchoCheckBox != null && sendEchoCheckBox.IsChecked == true)
+ {
+ Application.Current.Dispatcher.Invoke(() =>
+ {
+ string timeStr = DateTime.Now.ToString("[鍙戦 HH:mm:ss.fff]");
+ Paragraph para = new Paragraph();
+ Run timeRun = new Run(timeStr + "\n") { Foreground = Brushes.Red };
+ Run contentRun = new Run(textData + "\n") { Foreground = Brushes.Red };
+ para.Inlines.Add(timeRun);
+ para.Inlines.Add(contentRun);
+ recvDataRichTextBox.Document.Blocks.Add(para);
+ recvDataRichTextBox.ScrollToEnd();
+ });
+ }
+
return true;
}
+ // 鍏煎浣犵殑鑰佹帴鍙o紝鍙繚鐣欙紝涓嶅缓璁啀鐩存帴鐢
+ private bool SerialPortWrite(string textData)
+ {
+ // 榛樿鍥炴樉
+ return SerialPortWrite(textData, true);
+ }
+
+
#region 瀹氭椂鍣
///
/// 瓒呮椂鏃堕棿涓50ms
diff --git a/WPFSerialAssistant/SAViewMode.cs b/WPFSerialAssistant/SAViewMode.cs
index 0fa9b61..5585927 100644
--- a/WPFSerialAssistant/SAViewMode.cs
+++ b/WPFSerialAssistant/SAViewMode.cs
@@ -10,7 +10,7 @@ namespace WPFSerialAssistant
public partial class MainWindow : Window
{
// 淇濆瓨闈㈡澘鐨勬樉绀虹姸鎬
- private Stack panelVisibilityStack = new Stack(3);
+ private Stack panelVisibilityStack = new Stack(4);
///
/// 鍒ゆ柇鏄惁澶勪簬绠娲佽鍥炬ā寮
@@ -20,7 +20,8 @@ private bool IsCompactViewMode()
{
if (autoSendConfigPanel.Visibility == Visibility.Collapsed &&
serialCommunicationConfigPanel.Visibility == Visibility.Collapsed &&
- autoSendConfigPanel.Visibility == Visibility.Collapsed)
+ autoSendConfigPanel.Visibility == Visibility.Collapsed &&
+ commonCommandsPanel.Visibility == Visibility.Collapsed)
{
return true;
}
@@ -39,26 +40,29 @@ private void EnterCompactViewMode()
panelVisibilityStack.Push(serialPortConfigPanel.Visibility);
panelVisibilityStack.Push(autoSendConfigPanel.Visibility);
panelVisibilityStack.Push(serialCommunicationConfigPanel.Visibility);
+ panelVisibilityStack.Push(commonCommandsPanel.Visibility);
// 杩涘叆绠娲佽鍥炬ā寮
serialPortConfigPanel.Visibility = Visibility.Collapsed;
autoSendConfigPanel.Visibility = Visibility.Collapsed;
serialCommunicationConfigPanel.Visibility = Visibility.Collapsed;
+ commonCommandsPanel.Visibility = Visibility.Collapsed;
// 鎶婂搴旂殑鑿滃崟椤瑰彇娑堥変腑
serialSettingViewMenuItem.IsChecked = false;
autoSendDataSettingViewMenuItem.IsChecked = false;
serialCommunicationSettingViewMenuItem.IsChecked = false;
+ commonCommandsViewMenuItem.IsChecked = false;
// 姝ゆ椂鏃犳硶瑙嗗浘妯″紡锛屽繀椤绘仮澶嶅埌鍘熷厛鐨勮鍥炬ā寮忔墠鍙互
serialSettingViewMenuItem.IsEnabled = false;
autoSendDataSettingViewMenuItem.IsEnabled = false;
serialCommunicationSettingViewMenuItem.IsEnabled = false;
+ commonCommandsViewMenuItem.IsEnabled = false;
// 鍒囨崲鑷崇畝娲佽鍥炬ā寮忥紝鑿滃崟椤归変腑
compactViewMenuItem.IsChecked = true;
- //
Information("杩涘叆绠娲佽鍥炬ā寮忋");
}
@@ -68,6 +72,7 @@ private void EnterCompactViewMode()
private void RestoreViewMode()
{
// 鎭㈠闈㈡澘鏄剧ず鐘舵
+ commonCommandsPanel.Visibility = panelVisibilityStack.Pop();
serialCommunicationConfigPanel.Visibility = panelVisibilityStack.Pop();
autoSendConfigPanel.Visibility = panelVisibilityStack.Pop();
serialPortConfigPanel.Visibility = panelVisibilityStack.Pop();
@@ -88,9 +93,15 @@ private void RestoreViewMode()
serialCommunicationSettingViewMenuItem.IsChecked = true;
}
+ if (commonCommandsPanel.Visibility == Visibility.Visible)
+ {
+ commonCommandsViewMenuItem.IsChecked = true;
+ }
+
serialSettingViewMenuItem.IsEnabled = true;
autoSendDataSettingViewMenuItem.IsEnabled = true;
serialCommunicationSettingViewMenuItem.IsEnabled = true;
+ commonCommandsViewMenuItem.IsEnabled = true;
compactViewMenuItem.IsChecked = false;
diff --git a/WPFSerialAssistant/SelectDialog.xaml b/WPFSerialAssistant/SelectDialog.xaml
new file mode 100644
index 0000000..14bea2e
--- /dev/null
+++ b/WPFSerialAssistant/SelectDialog.xaml
@@ -0,0 +1,16 @@
+锘
+
+
+
+
+
+
+
+
diff --git a/WPFSerialAssistant/SelectDialog.xaml.cs b/WPFSerialAssistant/SelectDialog.xaml.cs
new file mode 100644
index 0000000..a7d8b76
--- /dev/null
+++ b/WPFSerialAssistant/SelectDialog.xaml.cs
@@ -0,0 +1,22 @@
+锘縰sing System.Collections.Generic;
+using System.Windows;
+
+namespace WPFSerialAssistant
+{
+ public partial class SelectDialog : Window
+ {
+ public string SelectedType { get; private set; }
+ public SelectDialog(IEnumerable types)
+ {
+ InitializeComponent();
+ cbTypes.ItemsSource = types;
+ if (cbTypes.Items.Count > 0)
+ cbTypes.SelectedIndex = 0;
+ }
+ private void BtnOK_Click(object sender, RoutedEventArgs e)
+ {
+ SelectedType = cbTypes.SelectedItem as string;
+ this.DialogResult = true;
+ }
+ }
+}
diff --git a/WPFSerialAssistant/WPFSerialAssistant.csproj b/WPFSerialAssistant/WPFSerialAssistant.csproj
index dc4cb92..52aa2ee 100644
--- a/WPFSerialAssistant/WPFSerialAssistant.csproj
+++ b/WPFSerialAssistant/WPFSerialAssistant.csproj
@@ -9,14 +9,14 @@
Properties
WPFSerialAssistant
WPFSerialAssistant
- v4.5
+ v4.8
512
{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
4
true
false
- publish\
+ C:\Users\hp\Desktop\SerialAssistant\
true
Disk
false
@@ -29,6 +29,7 @@
0
1.3.0.%2a
false
+ true
true
@@ -55,9 +56,21 @@
1.ico
+
+ A97176DFCAB30DECD31B15182E3C94C9FF33FA6C
+
+
+ WPFSerialAssistant_TemporaryKey.pfx
+
+
+ true
+
+
+ true
+
-
- lib\Json\Net45\Newtonsoft.Json.dll
+
+ ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll
@@ -82,16 +95,35 @@
About.xaml
+
+
+
+ CommandSettingsWindow.xaml
+
+
+ InputDialog.xaml
+
+
+ SelectDialog.xaml
+
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
MSBuild:Compile
Designer
@@ -106,6 +138,10 @@
MainWindow.xaml
Code
+
+ Designer
+ MSBuild:Compile
+
@@ -125,11 +161,13 @@
ResXFileCodeGenerator
Resources.Designer.cs
+
SettingsSingleFileGenerator
Settings.Designer.cs
+
@@ -153,26 +191,6 @@
false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-