├── .github
└── workflows
│ └── dotnet-desktop.yml
├── .gitignore
├── LICENSE
├── MetaCom.sln
├── MetaCom
├── App.xaml
├── App.xaml.cs
├── Images
│ ├── Close.png
│ ├── Max.png
│ ├── Min.png
│ ├── Normal.png
│ ├── favicon.ico
│ ├── favicon.png
│ └── send.png
├── Interfaces
│ └── TextBoxAppend.cs
├── MetaCom.csproj
├── Models
│ ├── ConfigModel.cs
│ ├── HelpModel.cs
│ ├── RecvModel.cs
│ ├── SendModel.cs
│ ├── SerialModel.cs
│ └── TimerModel.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── ViewModels
│ ├── AboutWindowVM.cs
│ ├── MainWindowBase.cs
│ └── MainWindowVM.cs
├── Views
│ ├── AboutWindow.xaml
│ ├── AboutWindow.xaml.cs
│ ├── MainWindow.xaml
│ └── MainWindow.xaml.cs
├── app.config
└── packages.config
├── README.md
└── docs
├── MetaCom.png
└── about.png
/.github/workflows/dotnet-desktop.yml:
--------------------------------------------------------------------------------
1 | # This workflow uses actions that are not certified by GitHub.
2 | # They are provided by a third-party and are governed by
3 | # separate terms of service, privacy policy, and support
4 | # documentation.
5 |
6 | # This workflow will build, test, sign and package a WPF or Windows Forms desktop application
7 | # built on .NET Core.
8 | # To learn how to migrate your existing application to .NET Core,
9 | # refer to https://docs.microsoft.com/en-us/dotnet/desktop-wpf/migration/convert-project-from-net-framework
10 | #
11 | # To configure this workflow:
12 | #
13 | # 1. Configure environment variables
14 | # GitHub sets default environment variables for every workflow run.
15 | # Replace the variables relative to your project in the "env" section below.
16 | #
17 | # 2. Signing
18 | # Generate a signing certificate in the Windows Application
19 | # Packaging Project or add an existing signing certificate to the project.
20 | # Next, use PowerShell to encode the .pfx file using Base64 encoding
21 | # by running the following Powershell script to generate the output string:
22 | #
23 | # $pfx_cert = Get-Content '.\SigningCertificate.pfx' -Encoding Byte
24 | # [System.Convert]::ToBase64String($pfx_cert) | Out-File 'SigningCertificate_Encoded.txt'
25 | #
26 | # Open the output file, SigningCertificate_Encoded.txt, and copy the
27 | # string inside. Then, add the string to the repo as a GitHub secret
28 | # and name it "Base64_Encoded_Pfx."
29 | # For more information on how to configure your signing certificate for
30 | # this workflow, refer to https://github.com/microsoft/github-actions-for-desktop-apps#signing
31 | #
32 | # Finally, add the signing certificate password to the repo as a secret and name it "Pfx_Key".
33 | # See "Build the Windows Application Packaging project" below to see how the secret is used.
34 | #
35 | # For more information on GitHub Actions, refer to https://github.com/features/actions
36 | # For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications,
37 | # refer to https://github.com/microsoft/github-actions-for-desktop-apps
38 |
39 | name: MetaCom
40 |
41 | on:
42 | push:
43 | branches: [ main ]
44 | pull_request:
45 | branches: [ main ]
46 |
47 | jobs:
48 |
49 | build:
50 |
51 | strategy:
52 | matrix:
53 | configuration: [Debug, Release]
54 |
55 | runs-on: windows-latest # For a list of available runner types, refer to
56 | # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
57 |
58 | env:
59 | Solution_Name: MetaCom.sln # Replace with your solution name, i.e. MyWpfApp.sln.
60 | Test_Project_Path: your-test-project-path # Replace with the path to your test project, i.e. MyWpfApp.Tests\MyWpfApp.Tests.csproj.
61 | Wap_Project_Directory: your-wap-project-directory-name # Replace with the Wap project directory relative to the solution, i.e. MyWpfApp.Package.
62 | Wap_Project_Path: your-wap-project-path # Replace with the path to your Wap project, i.e. MyWpf.App.Package\MyWpfApp.Package.wapproj.
63 |
64 | steps:
65 | - name: Checkout
66 | uses: actions/checkout@v2
67 | with:
68 | fetch-depth: 0
69 |
70 | # Install the .NET Core workload
71 | - name: Install .NET Core
72 | uses: actions/setup-dotnet@v1
73 | with:
74 | dotnet-version: 5.0.x
75 |
76 | # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
77 | - name: Setup MSBuild.exe
78 | uses: microsoft/setup-msbuild@v1.0.2
79 |
80 | # Execute all unit tests in the solution
81 | - name: Execute unit tests
82 | run: dotnet test
83 |
84 | # Restore the application to populate the obj folder with RuntimeIdentifiers
85 | - name: Restore the application
86 | run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration
87 | env:
88 | Configuration: ${{ matrix.configuration }}
89 |
90 | # Decode the base 64 encoded pfx and save the Signing_Certificate
91 | - name: Decode the pfx
92 | run: |
93 | $pfx_cert_byte = [System.Convert]::FromBase64String("${{ secrets.Base64_Encoded_Pfx }}")
94 | $certificatePath = Join-Path -Path $env:Wap_Project_Directory -ChildPath GitHubActionsWorkflow.pfx
95 | [IO.File]::WriteAllBytes("$certificatePath", $pfx_cert_byte)
96 |
97 | # Create the app package by building and packaging the Windows Application Packaging project
98 | - name: Create the app package
99 | run: msbuild $env:Wap_Project_Path /p:Configuration=$env:Configuration /p:UapAppxPackageBuildMode=$env:Appx_Package_Build_Mode /p:AppxBundle=$env:Appx_Bundle /p:PackageCertificateKeyFile=GitHubActionsWorkflow.pfx /p:PackageCertificatePassword=${{ secrets.Pfx_Key }}
100 | env:
101 | Appx_Bundle: Always
102 | Appx_Bundle_Platforms: x86|x64
103 | Appx_Package_Build_Mode: StoreUpload
104 | Configuration: ${{ matrix.configuration }}
105 |
106 | # Remove the pfx
107 | - name: Remove the pfx
108 | run: Remove-Item -path $env:Wap_Project_Directory\$env:Signing_Certificate
109 |
110 | # Upload the MSIX package: https://github.com/marketplace/actions/upload-a-build-artifact
111 | - name: Upload build artifacts
112 | uses: actions/upload-artifact@v3
113 | with:
114 | name: MSIX Package
115 | path: ${{ env.Wap_Project_Directory }}\AppPackages
116 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # NCrunch
145 | _NCrunch_*
146 | .*crunch*.local.xml
147 | nCrunchTemp_*
148 |
149 | # MightyMoose
150 | *.mm.*
151 | AutoTest.Net/
152 |
153 | # Web workbench (sass)
154 | .sass-cache/
155 |
156 | # Installshield output folder
157 | [Ee]xpress/
158 |
159 | # DocProject is a documentation generator add-in
160 | DocProject/buildhelp/
161 | DocProject/Help/*.HxT
162 | DocProject/Help/*.HxC
163 | DocProject/Help/*.hhc
164 | DocProject/Help/*.hhk
165 | DocProject/Help/*.hhp
166 | DocProject/Help/Html2
167 | DocProject/Help/html
168 |
169 | # Click-Once directory
170 | publish/
171 |
172 | # Publish Web Output
173 | *.[Pp]ublish.xml
174 | *.azurePubxml
175 | # Note: Comment the next line if you want to checkin your web deploy settings,
176 | # but database connection strings (with potential passwords) will be unencrypted
177 | *.pubxml
178 | *.publishproj
179 |
180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
181 | # checkin your Azure Web App publish settings, but sensitive information contained
182 | # in these scripts will be unencrypted
183 | PublishScripts/
184 |
185 | # NuGet Packages
186 | *.nupkg
187 | # NuGet Symbol Packages
188 | *.snupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 | *.appxbundle
214 | *.appxupload
215 |
216 | # Visual Studio cache files
217 | # files ending in .cache can be ignored
218 | *.[Cc]ache
219 | # but keep track of directories ending in .cache
220 | !?*.[Cc]ache/
221 |
222 | # Others
223 | ClientBin/
224 | ~$*
225 | *~
226 | *.dbmdl
227 | *.dbproj.schemaview
228 | *.jfm
229 | *.pfx
230 | *.publishsettings
231 | orleans.codegen.cs
232 |
233 | # Including strong name files can present a security risk
234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235 | #*.snk
236 |
237 | # Since there are multiple workflows, uncomment next line to ignore bower_components
238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239 | #bower_components/
240 |
241 | # RIA/Silverlight projects
242 | Generated_Code/
243 |
244 | # Backup & report files from converting an old project file
245 | # to a newer Visual Studio version. Backup files are not needed,
246 | # because we have git ;-)
247 | _UpgradeReport_Files/
248 | Backup*/
249 | UpgradeLog*.XML
250 | UpgradeLog*.htm
251 | ServiceFabricBackup/
252 | *.rptproj.bak
253 |
254 | # SQL Server files
255 | *.mdf
256 | *.ldf
257 | *.ndf
258 |
259 | # Business Intelligence projects
260 | *.rdl.data
261 | *.bim.layout
262 | *.bim_*.settings
263 | *.rptproj.rsuser
264 | *- [Bb]ackup.rdl
265 | *- [Bb]ackup ([0-9]).rdl
266 | *- [Bb]ackup ([0-9][0-9]).rdl
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # CodeRush personal settings
303 | .cr/personal
304 |
305 | # Python Tools for Visual Studio (PTVS)
306 | __pycache__/
307 | *.pyc
308 |
309 | # Cake - Uncomment if you are using it
310 | # tools/**
311 | # !tools/packages.config
312 |
313 | # Tabs Studio
314 | *.tss
315 |
316 | # Telerik's JustMock configuration file
317 | *.jmconfig
318 |
319 | # BizTalk build output
320 | *.btp.cs
321 | *.btm.cs
322 | *.odx.cs
323 | *.xsd.cs
324 |
325 | # OpenCover UI analysis results
326 | OpenCover/
327 |
328 | # Azure Stream Analytics local run output
329 | ASALocalRun/
330 |
331 | # MSBuild Binary and Structured Log
332 | *.binlog
333 |
334 | # NVidia Nsight GPU debugger configuration file
335 | *.nvuser
336 |
337 | # MFractors (Xamarin productivity tool) working folder
338 | .mfractor/
339 |
340 | # Local History for Visual Studio
341 | .localhistory/
342 |
343 | # BeatPulse healthcheck temp database
344 | healthchecksdb
345 |
346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
347 | MigrationBackup/
348 |
349 | # Ionide (cross platform F# VS Code tools) working folder
350 | .ionide/
351 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 linkmeta
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/MetaCom.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.1.32210.238
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MetaCom", "MetaCom\MetaCom.csproj", "{B1148E4A-5E2D-4469-87ED-980AF372464C}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {B1148E4A-5E2D-4469-87ED-980AF372464C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {B1148E4A-5E2D-4469-87ED-980AF372464C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {B1148E4A-5E2D-4469-87ED-980AF372464C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {B1148E4A-5E2D-4469-87ED-980AF372464C}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {F3AA94C1-3806-431C-A06A-48AA1DAFB6B7}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/MetaCom/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
21 |
22 |
23 |
27 |
32 |
33 |
34 |
37 |
38 |
39 |
44 |
49 |
50 |
51 |
55 |
64 |
65 |
66 |
67 |
71 |
79 |
80 |
81 |
86 |
91 |
92 |
93 |
97 |
103 |
109 |
110 |
111 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/MetaCom/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace MetaCom
4 | {
5 | ///
6 | /// App.xaml 的交互逻辑
7 | ///
8 | public partial class App : Application
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/MetaCom/Images/Close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkmeta/MetaCom/71bef4da05ca2053ecc5061dbe61c6e3ead768af/MetaCom/Images/Close.png
--------------------------------------------------------------------------------
/MetaCom/Images/Max.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkmeta/MetaCom/71bef4da05ca2053ecc5061dbe61c6e3ead768af/MetaCom/Images/Max.png
--------------------------------------------------------------------------------
/MetaCom/Images/Min.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkmeta/MetaCom/71bef4da05ca2053ecc5061dbe61c6e3ead768af/MetaCom/Images/Min.png
--------------------------------------------------------------------------------
/MetaCom/Images/Normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkmeta/MetaCom/71bef4da05ca2053ecc5061dbe61c6e3ead768af/MetaCom/Images/Normal.png
--------------------------------------------------------------------------------
/MetaCom/Images/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkmeta/MetaCom/71bef4da05ca2053ecc5061dbe61c6e3ead768af/MetaCom/Images/favicon.ico
--------------------------------------------------------------------------------
/MetaCom/Images/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkmeta/MetaCom/71bef4da05ca2053ecc5061dbe61c6e3ead768af/MetaCom/Images/favicon.png
--------------------------------------------------------------------------------
/MetaCom/Images/send.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkmeta/MetaCom/71bef4da05ca2053ecc5061dbe61c6e3ead768af/MetaCom/Images/send.png
--------------------------------------------------------------------------------
/MetaCom/Interfaces/TextBoxAppend.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 |
4 | namespace MetaCom.Interfaces
5 | {
6 | public interface TextBoxAppend
7 | {
8 | ///
9 | /// 移除所有字符
10 | ///
11 | void Delete();
12 |
13 | ///
14 | /// 从startIndex开始移除length个字符
15 | ///
16 | ///
17 | ///
18 | void Delete(int startIndex, int length);
19 |
20 | ///
21 | /// 追加字符串
22 | ///
23 | ///
24 | void Append(string value);
25 |
26 | ///
27 | /// 将字符串插入到指定位置
28 | ///
29 | ///
30 | ///
31 | void Append(string value, int index);
32 |
33 | ///
34 | /// 获取当前值
35 | ///
36 | ///
37 | string GetCurrentValue();
38 |
39 | ///
40 | /// 移除所有字符事件的处理方法
41 | ///
42 | event EventHandler BufferClearingHandler;
43 |
44 | ///
45 | /// 追加字符串事件的处理方法
46 | ///
47 | event EventHandler BufferAppendedHandler;
48 | }
49 |
50 | #region 接口实现
51 | public class IClassTextBoxAppend : TextBoxAppend
52 | {
53 | readonly StringBuilder stringBuilder = new StringBuilder();
54 |
55 | readonly BufferClearingHandlerEventArgs bufferClearingHandlerEventArgs =
56 | new BufferClearingHandlerEventArgs();
57 |
58 | readonly BufferAppendedHandlerEventArgs bufferAppendedHandlerEventArgs =
59 | new BufferAppendedHandlerEventArgs();
60 |
61 | public void Delete()
62 | {
63 | stringBuilder.Clear();
64 |
65 | System.Windows.Application.Current.Dispatcher.Invoke(() =>
66 | {
67 | BufferClearingHandler(this, bufferClearingHandlerEventArgs);
68 | });
69 | }
70 |
71 | public void Delete(int startIndex, int length)
72 | {
73 | stringBuilder.Remove(startIndex, length);
74 | }
75 |
76 | public void Append(string value)
77 | {
78 | stringBuilder.Append(value);
79 |
80 | bufferAppendedHandlerEventArgs.AppendedText = value;
81 |
82 | System.Windows.Application.Current.Dispatcher.Invoke(() =>
83 | {
84 | BufferAppendedHandler(this, bufferAppendedHandlerEventArgs);
85 | });
86 | }
87 |
88 | public void Append(string value, int index)
89 | {
90 | if (index == stringBuilder.Length)
91 | {
92 | stringBuilder.Append(value);
93 | }
94 | else
95 | {
96 | stringBuilder.Insert(index, value);
97 | }
98 | }
99 |
100 | public string GetCurrentValue()
101 | {
102 | return stringBuilder.ToString();
103 | }
104 |
105 | public event EventHandler BufferClearingHandler;
106 |
107 | public event EventHandler BufferAppendedHandler;
108 | }
109 |
110 | public class BufferClearingHandlerEventArgs : EventArgs
111 | {
112 | public string ClearingText { get; set; }
113 | }
114 |
115 | public class BufferAppendedHandlerEventArgs : EventArgs
116 | {
117 | public string AppendedText { get; set; }
118 | }
119 | #endregion
120 | }
121 |
--------------------------------------------------------------------------------
/MetaCom/MetaCom.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {B1148E4A-5E2D-4469-87ED-980AF372464C}
8 | WinExe
9 | MetaCom
10 | MetaCom
11 | v4.8
12 | 512
13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
14 | 4
15 | true
16 |
17 |
18 |
19 | false
20 | publish\
21 | true
22 | Disk
23 | false
24 | Foreground
25 | 7
26 | Days
27 | false
28 | false
29 | true
30 | 0
31 | 1.0.0.%2a
32 | false
33 | true
34 |
35 |
36 | AnyCPU
37 | true
38 | full
39 | false
40 | bin\Debug\
41 | DEBUG;TRACE
42 | prompt
43 | 4
44 | false
45 |
46 |
47 | AnyCPU
48 | pdbonly
49 | true
50 | bin\Release\
51 | TRACE
52 | prompt
53 | 4
54 | false
55 |
56 |
57 | true
58 |
59 |
60 | Images\favicon.ico
61 |
62 |
63 |
64 | ..\packages\Ben.Demystifier.0.1.3\lib\net45\Ben.Demystifier.dll
65 |
66 |
67 | ..\packages\Microsoft.TeamFoundationServer.Client.16.170.0\lib\net462\Microsoft.Azure.DevOps.Comments.WebApi.dll
68 |
69 |
70 | ..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.5.2.6\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll
71 |
72 |
73 | ..\packages\Microsoft.IdentityModel.JsonWebTokens.5.6.0\lib\net461\Microsoft.IdentityModel.JsonWebTokens.dll
74 |
75 |
76 | ..\packages\Microsoft.IdentityModel.Logging.5.6.0\lib\net461\Microsoft.IdentityModel.Logging.dll
77 |
78 |
79 | ..\packages\Microsoft.IdentityModel.Tokens.5.6.0\lib\net461\Microsoft.IdentityModel.Tokens.dll
80 |
81 |
82 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.Build.Client.dll
83 |
84 |
85 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.Build.Common.dll
86 |
87 |
88 | ..\packages\Microsoft.TeamFoundationServer.Client.16.170.0\lib\net462\Microsoft.TeamFoundation.Build2.WebApi.dll
89 |
90 |
91 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.Client.dll
92 |
93 |
94 | ..\packages\Microsoft.VisualStudio.Services.Client.16.170.0\lib\net462\Microsoft.TeamFoundation.Common.dll
95 |
96 |
97 | ..\packages\Microsoft.TeamFoundationServer.Client.16.170.0\lib\net462\Microsoft.TeamFoundation.Core.WebApi.dll
98 |
99 |
100 | ..\packages\Microsoft.TeamFoundationServer.Client.16.170.0\lib\net462\Microsoft.TeamFoundation.Dashboards.WebApi.dll
101 |
102 |
103 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.DeleteTeamProject.dll
104 |
105 |
106 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.Diff.dll
107 |
108 |
109 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.Discussion.Client.dll
110 |
111 |
112 | ..\packages\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.16.170.0\lib\net462\Microsoft.TeamFoundation.DistributedTask.Common.Contracts.dll
113 |
114 |
115 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.Git.Client.dll
116 |
117 |
118 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.Lab.Client.dll
119 |
120 |
121 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.Lab.Common.dll
122 |
123 |
124 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.Lab.TestIntegration.Client.dll
125 |
126 |
127 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.Lab.WorkflowIntegration.Client.dll
128 |
129 |
130 | ..\packages\Microsoft.TeamFoundationServer.Client.16.170.0\lib\net462\Microsoft.TeamFoundation.Policy.WebApi.dll
131 |
132 |
133 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.ProjectManagement.dll
134 |
135 |
136 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.SharePointReporting.Integration.dll
137 |
138 |
139 | ..\packages\Microsoft.TeamFoundationServer.Client.16.170.0\lib\net462\Microsoft.TeamFoundation.SourceControl.WebApi.dll
140 |
141 |
142 | ..\packages\Microsoft.TeamFoundationServer.Client.16.170.0\lib\net462\Microsoft.TeamFoundation.Test.WebApi.dll
143 |
144 |
145 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.TestImpact.Client.dll
146 |
147 |
148 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.TestManagement.Client.dll
149 |
150 |
151 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.TestManagement.Common.dll
152 |
153 |
154 | ..\packages\Microsoft.TeamFoundationServer.Client.16.170.0\lib\net462\Microsoft.TeamFoundation.TestManagement.WebApi.dll
155 |
156 |
157 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.VersionControl.Client.dll
158 |
159 |
160 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.VersionControl.Common.dll
161 |
162 |
163 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.VersionControl.Common.Integration.dll
164 |
165 |
166 | ..\packages\Microsoft.TeamFoundationServer.Client.16.170.0\lib\net462\Microsoft.TeamFoundation.Wiki.WebApi.dll
167 |
168 |
169 | ..\packages\Microsoft.TeamFoundationServer.Client.16.170.0\lib\net462\Microsoft.TeamFoundation.Work.WebApi.dll
170 |
171 |
172 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.WorkItemTracking.Client.dll
173 |
174 |
175 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.WorkItemTracking.Client.DataStoreLoader.dll
176 |
177 |
178 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.WorkItemTracking.Client.QueryLanguage.dll
179 |
180 |
181 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.WorkItemTracking.Common.dll
182 |
183 |
184 | ..\packages\Microsoft.TeamFoundationServer.Client.16.170.0\lib\net462\Microsoft.TeamFoundation.WorkItemTracking.Process.WebApi.dll
185 |
186 |
187 | ..\packages\Microsoft.TeamFoundationServer.ExtendedClient.16.170.0\lib\net462\Microsoft.TeamFoundation.WorkItemTracking.Proxy.dll
188 |
189 |
190 | ..\packages\Microsoft.TeamFoundationServer.Client.16.170.0\lib\net462\Microsoft.TeamFoundation.WorkItemTracking.WebApi.dll
191 |
192 |
193 | ..\packages\Microsoft.VisualStudio.Services.InteractiveClient.16.170.0\lib\net462\Microsoft.VisualStudio.Services.Client.Interactive.dll
194 |
195 |
196 | ..\packages\Microsoft.VisualStudio.Services.Client.16.170.0\lib\net462\Microsoft.VisualStudio.Services.Common.dll
197 |
198 |
199 | ..\packages\Microsoft.TeamFoundationServer.Client.16.170.0\lib\net462\Microsoft.VisualStudio.Services.TestManagement.TestPlanning.WebApi.dll
200 |
201 |
202 | ..\packages\Microsoft.TeamFoundationServer.Client.16.170.0\lib\net462\Microsoft.VisualStudio.Services.TestResults.WebApi.dll
203 |
204 |
205 | ..\packages\Microsoft.VisualStudio.Services.Client.16.170.0\lib\net462\Microsoft.VisualStudio.Services.WebApi.dll
206 |
207 |
208 | ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll
209 |
210 |
211 |
212 | ..\packages\System.Collections.Immutable.1.4.0\lib\netstandard2.0\System.Collections.Immutable.dll
213 |
214 |
215 |
216 |
217 |
218 |
219 | ..\packages\System.IdentityModel.Tokens.Jwt.5.6.0\lib\net461\System.IdentityModel.Tokens.Jwt.dll
220 |
221 |
222 | ..\packages\System.IO.4.3.0\lib\net462\System.IO.dll
223 | True
224 | True
225 |
226 |
227 |
228 | ..\packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll
229 | True
230 | True
231 |
232 |
233 | ..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll
234 |
235 |
236 | ..\packages\System.Reflection.Metadata.1.5.0\lib\netstandard2.0\System.Reflection.Metadata.dll
237 |
238 |
239 | ..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll
240 | True
241 | True
242 |
243 |
244 |
245 | ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll
246 | True
247 | True
248 |
249 |
250 | ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll
251 | True
252 | True
253 |
254 |
255 | ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll
256 | True
257 | True
258 |
259 |
260 | ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll
261 | True
262 | True
263 |
264 |
265 | ..\packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll
266 |
267 |
268 | ..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.7\lib\net45\System.Web.Http.WebHost.dll
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 | 4.0
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 | MSBuild:Compile
286 | Designer
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 | App.xaml
296 | Code
297 |
298 |
299 |
300 | MSBuild:Compile
301 | Designer
302 |
303 |
304 | MSBuild:Compile
305 | Designer
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 | Code
316 |
317 |
318 | True
319 | True
320 | Resources.resx
321 |
322 |
323 | True
324 | Settings.settings
325 | True
326 |
327 |
328 | ResXFileCodeGenerator
329 | Resources.Designer.cs
330 | Designer
331 |
332 |
333 |
334 |
335 | SettingsSingleFileGenerator
336 | Settings.Designer.cs
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 | False
357 | Microsoft .NET Framework 4.8 %28x86 和 x64%29
358 | true
359 |
360 |
361 | False
362 | .NET Framework 3.5 SP1
363 | false
364 |
365 |
366 |
367 |
368 |
369 |
370 | 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
371 |
372 |
373 |
374 |
--------------------------------------------------------------------------------
/MetaCom/Models/ConfigModel.cs:
--------------------------------------------------------------------------------
1 | using MetaCom.ViewModels;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Collections.ObjectModel;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Xml;
9 | using System.Xml.Serialization;
10 |
11 | namespace MetaCom.Models
12 | {
13 | [XmlRoot(ElementName = "Config")]
14 | public class ConfigModel : MainWindowBase
15 | {
16 | private string _port;
17 | [XmlAttribute(AttributeName = "port", Namespace = "")]
18 | public string Port
19 | {
20 | get
21 | {
22 | return _port;
23 | }
24 | set
25 | {
26 | _port = value;
27 | RaisePropertyChanged(nameof(Port));
28 | }
29 | }
30 |
31 |
32 | [XmlRoot(ElementName = "commoncmd")]
33 | public class CommonCmd : MainWindowBase
34 | {
35 | private string _item;
36 | [XmlElement(ElementName = "item", Namespace = "")]
37 | public string Item
38 | {
39 | get
40 | {
41 | return _item;
42 | }
43 | set
44 | {
45 | _item = value;
46 | RaisePropertyChanged(nameof(Item));
47 | }
48 | }
49 | }
50 | private ObservableCollection _commoncmds;
51 | [XmlElement(ElementName = "commoncmds", Namespace = "")]
52 | public ObservableCollection CommonCmds
53 | {
54 | get
55 | {
56 | return _commoncmds;
57 | }
58 | set
59 | {
60 | _commoncmds = value;
61 | RaisePropertyChanged(nameof(CommonCmds));
62 | }
63 | }
64 | [XmlRoot(ElementName = "rescentcmd")]
65 | public class RescentCmd : MainWindowBase
66 | {
67 | private string _item;
68 | [XmlElement(ElementName = "item", Namespace = "")]
69 | public string Item
70 | {
71 | get
72 | {
73 | return _item;
74 | }
75 | set
76 | {
77 | _item = value;
78 | RaisePropertyChanged(nameof(Item));
79 | }
80 | }
81 |
82 | }
83 | private ObservableCollection _rescentcmds;
84 | [XmlElement(ElementName = "rescentcmds", Namespace = "")]
85 | public ObservableCollection RescentCmds
86 | {
87 | get
88 | {
89 | return _rescentcmds;
90 | }
91 | set
92 | {
93 | _rescentcmds = value;
94 | //NotifyPropertyChange("RescentCmds");
95 | RaisePropertyChanged(nameof(RescentCmds));
96 | }
97 | }
98 |
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/MetaCom/Models/HelpModel.cs:
--------------------------------------------------------------------------------
1 | using MetaCom.ViewModels;
2 | using System;
3 | using System.Runtime.Serialization;
4 |
5 | namespace MetaCom.Models
6 | {
7 | [DataContract]
8 |
9 | internal class HelpModel : MainWindowBase
10 | {
11 | ///
12 | /// 版本号
13 | ///
14 | public string VerInfoNumber { get; set; }
15 |
16 | ///
17 | /// 版本信息
18 | ///
19 | private string _VerInfo;
20 | public string VerInfo
21 | {
22 | get
23 | {
24 | return _VerInfo;
25 | }
26 | set
27 | {
28 | if (_VerInfo != value)
29 | {
30 | _VerInfo = value;
31 | RaisePropertyChanged(nameof(VerInfo));
32 | }
33 | }
34 | }
35 | public void HelpDataContext()
36 | {
37 | VerInfoNumber = "1.3.0";
38 | VerInfo = "MetaCom V" + VerInfoNumber;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/MetaCom/Models/RecvModel.cs:
--------------------------------------------------------------------------------
1 | using MetaCom.Interfaces;
2 | using MetaCom.ViewModels;
3 |
4 | namespace MetaCom.Models
5 | {
6 | internal class RecvModel : MainWindowBase
7 | {
8 | #region 接收区 - Header
9 | ///
10 | /// 接收区Header中的接收计数
11 | ///
12 | private int _RecvDataCount;
13 | public int RecvDataCount
14 | {
15 | get
16 | {
17 | return _RecvDataCount;
18 | }
19 | set
20 | {
21 | if (_RecvDataCount != value)
22 | {
23 | _RecvDataCount = value;
24 | RaisePropertyChanged(nameof(RecvDataCount));
25 | }
26 | }
27 | }
28 |
29 | ///
30 | /// 接收区Header中的 [保存中/已停止] 字符串
31 | ///
32 | private string _RecvAutoSave;
33 | public string RecvAutoSave
34 | {
35 | get
36 | {
37 | return _RecvAutoSave;
38 | }
39 | set
40 | {
41 | if (_RecvAutoSave != value)
42 | {
43 | _RecvAutoSave = value;
44 | RaisePropertyChanged(nameof(RecvAutoSave));
45 | }
46 | }
47 | }
48 |
49 | ///
50 | /// 接收区Header中的 [允许/暂停] 字符串
51 | ///
52 | private string _RecvEnable;
53 | public string RecvEnable
54 | {
55 | get
56 | {
57 | return _RecvEnable;
58 | }
59 | set
60 | {
61 | if (_RecvEnable != value)
62 | {
63 | _RecvEnable = value;
64 | RaisePropertyChanged(nameof(RecvEnable));
65 | }
66 | }
67 | }
68 | #endregion
69 |
70 | ///
71 | /// 接收区 - 允许/暂停 接收数据
72 | ///
73 | private bool _EnableRecv;
74 | public bool EnableRecv
75 | {
76 | get
77 | {
78 | return _EnableRecv;
79 | }
80 | set
81 | {
82 | if (_EnableRecv != value)
83 | {
84 | _EnableRecv = value;
85 | RaisePropertyChanged(nameof(EnableRecv));
86 | }
87 | }
88 | }
89 |
90 | private TextBoxAppend _RecvData;
91 | public TextBoxAppend RecvData
92 | {
93 | get
94 | {
95 | return _RecvData;
96 | }
97 | set
98 | {
99 | if (_RecvData != value)
100 | {
101 | _RecvData = value;
102 | RaisePropertyChanged(nameof(RecvData));
103 | }
104 | }
105 | }
106 |
107 | ///
108 | /// 辅助区 - 十六进制接收
109 | ///
110 | private bool _HexRecv;
111 | public bool HexRecv
112 | {
113 | get
114 | {
115 | return _HexRecv;
116 | }
117 | set
118 | {
119 | if (_HexRecv != value)
120 | {
121 | _HexRecv = value;
122 | RaisePropertyChanged(nameof(HexRecv));
123 | }
124 | }
125 | }
126 |
127 | public void RecvDataContext()
128 | {
129 | RecvData = new IClassTextBoxAppend();
130 |
131 | RecvDataCount = 0;
132 | RecvAutoSave = string.Format(CultureInfos, "已停止");
133 | RecvEnable = string.Format(CultureInfos, "允许");
134 |
135 | EnableRecv = true;
136 | HexRecv = false;
137 | }
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/MetaCom/Models/SendModel.cs:
--------------------------------------------------------------------------------
1 | using MetaCom.ViewModels;
2 |
3 | namespace MetaCom.Models
4 | {
5 | internal class SendModel : MainWindowBase
6 | {
7 | ///
8 | /// 发送区Header中的发送计数
9 | ///
10 | private int _SendDataCount;
11 | public int SendDataCount
12 | {
13 | get
14 | {
15 | return _SendDataCount;
16 | }
17 | set
18 | {
19 | if (_SendDataCount != value)
20 | {
21 | _SendDataCount = value;
22 | RaisePropertyChanged(nameof(SendDataCount));
23 | }
24 | }
25 | }
26 |
27 | private string _SendData;
28 | public string SendData
29 | {
30 | get
31 | {
32 | return _SendData;
33 | }
34 | set
35 | {
36 | if (_SendData != value)
37 | {
38 | _SendData = value;
39 | RaisePropertyChanged(nameof(SendData));
40 | }
41 | }
42 | }
43 |
44 | ///
45 | /// 辅助区 - 自送发送的时间间隔
46 | ///
47 | private string _AutoSendNum;
48 | public string AutoSendNum
49 | {
50 | get
51 | {
52 | return _AutoSendNum;
53 | }
54 | set
55 | {
56 | if (_AutoSendNum != value)
57 | {
58 | _AutoSendNum = value;
59 | RaisePropertyChanged(nameof(AutoSendNum));
60 | }
61 | }
62 | }
63 |
64 | #region 菜单栏 - 选项 - 发送换行
65 | private bool _NonesEnable;
66 | public bool NonesEnable
67 | {
68 | get
69 | {
70 | return _NonesEnable;
71 | }
72 | set
73 | {
74 | if (_NonesEnable != value)
75 | {
76 | _NonesEnable = value;
77 | RaisePropertyChanged(nameof(NonesEnable));
78 | }
79 | }
80 | }
81 |
82 | private bool _CrEnable;
83 | public bool CrEnable
84 | {
85 | get
86 | {
87 | return _CrEnable;
88 | }
89 | set
90 | {
91 | if (_CrEnable != value)
92 | {
93 | _CrEnable = value;
94 | RaisePropertyChanged(nameof(CrEnable));
95 | }
96 | }
97 | }
98 |
99 | private bool _LfEnable;
100 | public bool LfEnable
101 | {
102 | get
103 | {
104 | return _LfEnable;
105 | }
106 | set
107 | {
108 | if (_LfEnable != value)
109 | {
110 | _LfEnable = value;
111 | RaisePropertyChanged(nameof(LfEnable));
112 | }
113 | }
114 | }
115 |
116 | private bool _CrLfEnable;
117 | public bool CrLfEnable
118 | {
119 | get
120 | {
121 | return _CrLfEnable;
122 | }
123 | set
124 | {
125 | if (_CrLfEnable != value)
126 | {
127 | _CrLfEnable = value;
128 | RaisePropertyChanged(nameof(CrLfEnable));
129 | }
130 | }
131 | }
132 | #endregion
133 | #region 状态栏 - 发送文件进度条可见性
134 | private string _StatusBarProgressBarVisibility;
135 | public string StatusBarProgressBarVisibility
136 | {
137 | get
138 | {
139 | return _StatusBarProgressBarVisibility;
140 | }
141 | set
142 | {
143 | if (_StatusBarProgressBarVisibility != value)
144 | {
145 | _StatusBarProgressBarVisibility = value;
146 | RaisePropertyChanged(nameof(StatusBarProgressBarVisibility));
147 | }
148 | }
149 | }
150 |
151 | private double _StatusBarProgressBarValue;
152 | public double StatusBarProgressBarValue
153 | {
154 | get
155 | {
156 | return _StatusBarProgressBarValue;
157 | }
158 | set
159 | {
160 | if (_StatusBarProgressBarValue != value)
161 | {
162 | _StatusBarProgressBarValue = value;
163 | RaisePropertyChanged(nameof(StatusBarProgressBarValue));
164 | }
165 | }
166 | }
167 |
168 | private bool _StatusBarProgressBarIsIndeterminate;
169 | public bool StatusBarProgressBarIsIndeterminate
170 | {
171 | get
172 | {
173 | return _StatusBarProgressBarIsIndeterminate;
174 | }
175 | set
176 | {
177 | if (_StatusBarProgressBarIsIndeterminate != value)
178 | {
179 | _StatusBarProgressBarIsIndeterminate = value;
180 | RaisePropertyChanged(nameof(StatusBarProgressBarIsIndeterminate));
181 | }
182 | }
183 | }
184 | #endregion
185 | public void SendDataContext()
186 | {
187 | SendData = string.Empty;
188 | SendDataCount = 0;
189 |
190 | AutoSendNum = "1000";
191 |
192 | NonesEnable = false;
193 | CrEnable = false;
194 | LfEnable = false;
195 | CrLfEnable = true;
196 |
197 | StatusBarProgressBarVisibility = "Collapsed";
198 | StatusBarProgressBarValue = 0;
199 | StatusBarProgressBarIsIndeterminate = false;
200 | }
201 | }
202 | }
203 |
--------------------------------------------------------------------------------
/MetaCom/Models/SerialModel.cs:
--------------------------------------------------------------------------------
1 | using MetaCom.ViewModels;
2 | using System;
3 | using System.Collections.ObjectModel;
4 | using System.IO.Ports;
5 | using System.Management;
6 | using System.Windows;
7 | using System.Windows.Media;
8 |
9 | namespace MetaCom.Models
10 | {
11 | internal class SerialPortModel : MainWindowBase
12 | {
13 | public string[] PortItemsSource { get; set; }
14 | public Collection BaudRateItemsSource { get; set; }
15 | public Collection DataBitsItemsSource { get; set; }
16 | public Collection StopBitsItemsSource { get; set; }
17 | public Collection ParityItemsSource { get; set; }
18 |
19 | #region 串口配置区 - 缓冲区
20 | private int _RecvBuf;
21 | public int RecvBufSize
22 | {
23 | get
24 | {
25 | return _RecvBuf;
26 | }
27 | set
28 | {
29 | if (_RecvBuf != value)
30 | {
31 | _RecvBuf = value;
32 | RaisePropertyChanged(nameof(RecvBufSize));
33 | }
34 | }
35 | }
36 | private bool _RecvBuf1M;
37 | public bool RecvBuf1M
38 | {
39 | get
40 | {
41 | return _RecvBuf1M;
42 | }
43 | set
44 | {
45 | if (_RecvBuf1M != value)
46 | {
47 | _RecvBuf1M = value;
48 | RaisePropertyChanged(nameof(RecvBuf1M));
49 | }
50 | }
51 | }
52 | private bool _RecvBuf2M;
53 | public bool RecvBuf2M
54 | {
55 | get
56 | {
57 | return _RecvBuf2M;
58 | }
59 | set
60 | {
61 | if (_RecvBuf2M != value)
62 | {
63 | _RecvBuf2M = value;
64 | RaisePropertyChanged(nameof(RecvBuf2M));
65 | }
66 | }
67 | }
68 | private bool _RecvBuf4M;
69 | public bool RecvBuf4M
70 | {
71 | get
72 | {
73 | return _RecvBuf4M;
74 | }
75 | set
76 | {
77 | if (_RecvBuf4M != value)
78 | {
79 | _RecvBuf4M = value;
80 | RaisePropertyChanged(nameof(RecvBuf4M));
81 | }
82 | }
83 | }
84 | private bool _RecvBuf8M;
85 | public bool RecvBuf8M
86 | {
87 | get
88 | {
89 | return _RecvBuf8M;
90 | }
91 | set
92 | {
93 | if (_RecvBuf8M != value)
94 | {
95 | _RecvBuf8M = value;
96 | RaisePropertyChanged(nameof(RecvBuf8M));
97 | }
98 | }
99 | }
100 | private int _SendBuf;
101 | public int SendBufSize
102 | {
103 | get
104 | {
105 | return _SendBuf;
106 | }
107 | set
108 | {
109 | if (_SendBuf != value)
110 | {
111 | _SendBuf = value;
112 | RaisePropertyChanged(nameof(SendBufSize));
113 | }
114 | }
115 | }
116 | private bool _SendBuf1M;
117 | public bool SendBuf1M
118 | {
119 | get
120 | {
121 | return _SendBuf1M;
122 | }
123 | set
124 | {
125 | if (_SendBuf1M != value)
126 | {
127 | _SendBuf1M = value;
128 | RaisePropertyChanged(nameof(SendBuf1M));
129 | }
130 | }
131 | }
132 | private bool _SendBuf4M;
133 | public bool SendBuf4M
134 | {
135 | get
136 | {
137 | return _SendBuf4M;
138 | }
139 | set
140 | {
141 | if (_SendBuf4M != value)
142 | {
143 | _SendBuf4M = value;
144 | RaisePropertyChanged(nameof(SendBuf4M));
145 | }
146 | }
147 | }
148 | #endregion
149 |
150 | #region 串口配置区 - 串口属性
151 | private string _Port;
152 | public string Port
153 | {
154 | get
155 | {
156 | return _Port;
157 | }
158 | set
159 | {
160 | if (_Port != value)
161 | {
162 | _Port = value;
163 | RaisePropertyChanged(nameof(Port));
164 | }
165 | }
166 | }
167 |
168 | private int _BaudRate;
169 | public int BaudRate
170 | {
171 | get
172 | {
173 | return _BaudRate;
174 | }
175 | set
176 | {
177 | if (_BaudRate != value)
178 | {
179 | _BaudRate = value;
180 | RaisePropertyChanged(nameof(BaudRate));
181 | }
182 | }
183 | }
184 |
185 | private int _DataBits;
186 | public int DataBits
187 | {
188 | get
189 | {
190 | return _DataBits;
191 | }
192 | set
193 | {
194 | if (_DataBits != value)
195 | {
196 | _DataBits = value;
197 | RaisePropertyChanged(nameof(DataBits));
198 | }
199 | }
200 | }
201 |
202 | private StopBits _StopBits;
203 | public StopBits StopBits
204 | {
205 | get
206 | {
207 | return _StopBits;
208 | }
209 | set
210 | {
211 | if (_StopBits != value)
212 | {
213 | _StopBits = value;
214 | RaisePropertyChanged(nameof(StopBits));
215 | }
216 | }
217 | }
218 |
219 | private Parity _Parity;
220 | public Parity Parity
221 | {
222 | get
223 | {
224 | return _Parity;
225 | }
226 | set
227 | {
228 | if (_Parity != value)
229 | {
230 | _Parity = value;
231 | RaisePropertyChanged(nameof(Parity));
232 | }
233 | }
234 | }
235 | #endregion
236 |
237 | #region 串口配置区 - 打开/关闭
238 | private Brush _Brush;
239 | public Brush Brush
240 | {
241 | get
242 | {
243 | return _Brush;
244 | }
245 | set
246 | {
247 | if (_Brush != value)
248 | {
249 | _Brush = value;
250 | RaisePropertyChanged(nameof(Brush));
251 | }
252 | }
253 | }
254 |
255 | private string _OpenClose;
256 | public string OpenClose
257 | {
258 | get
259 | {
260 | return _OpenClose;
261 | }
262 | set
263 | {
264 | if (_OpenClose != value)
265 | {
266 | _OpenClose = value;
267 | RaisePropertyChanged(nameof(OpenClose));
268 | }
269 | }
270 | }
271 | #endregion
272 |
273 | #region 串口属性控件 - 启用/不启用
274 | private bool _PortEnable;
275 | public bool PortEnable
276 | {
277 | get
278 | {
279 | return _PortEnable;
280 | }
281 | set
282 | {
283 | if (_PortEnable != value)
284 | {
285 | _PortEnable = value;
286 | RaisePropertyChanged(nameof(PortEnable));
287 | }
288 | }
289 | }
290 |
291 | private bool _BaudRateEnable;
292 | public bool BaudRateEnable
293 | {
294 | get
295 | {
296 | return _BaudRateEnable;
297 | }
298 | set
299 | {
300 | if (_BaudRateEnable != value)
301 | {
302 | _BaudRateEnable = value;
303 | RaisePropertyChanged(nameof(BaudRateEnable));
304 | }
305 | }
306 | }
307 |
308 | private bool _DataBitsEnable;
309 | public bool DataBitsEnable
310 | {
311 | get
312 | {
313 | return _DataBitsEnable;
314 | }
315 | set
316 | {
317 | if (_DataBitsEnable != value)
318 | {
319 | _DataBitsEnable = value;
320 | RaisePropertyChanged(nameof(DataBitsEnable));
321 | }
322 | }
323 | }
324 |
325 | private bool _StopBitsEnable;
326 | public bool StopBitsEnable
327 | {
328 | get
329 | {
330 | return _StopBitsEnable;
331 | }
332 | set
333 | {
334 | if (_StopBitsEnable != value)
335 | {
336 | _StopBitsEnable = value;
337 | RaisePropertyChanged(nameof(StopBitsEnable));
338 | }
339 | }
340 | }
341 |
342 | private bool _ParityEnable;
343 | public bool ParityEnable
344 | {
345 | get
346 | {
347 | return _ParityEnable;
348 | }
349 | set
350 | {
351 | if (_ParityEnable != value)
352 | {
353 | _ParityEnable = value;
354 | RaisePropertyChanged(nameof(ParityEnable));
355 | }
356 | }
357 | }
358 | #endregion
359 |
360 | #region 菜单栏 - 选项 - 字节编码
361 | private bool _ASCIIEnable;
362 | public bool ASCIIEnable
363 | {
364 | get
365 | {
366 | return _ASCIIEnable;
367 | }
368 | set
369 | {
370 | if (_ASCIIEnable != value)
371 | {
372 | _ASCIIEnable = value;
373 | RaisePropertyChanged(nameof(ASCIIEnable));
374 | }
375 | }
376 | }
377 |
378 | private bool _UTF8Enable;
379 | public bool UTF8Enable
380 | {
381 | get
382 | {
383 | return _UTF8Enable;
384 | }
385 | set
386 | {
387 | if (_UTF8Enable != value)
388 | {
389 | _UTF8Enable = value;
390 | RaisePropertyChanged(nameof(UTF8Enable));
391 | }
392 | }
393 | }
394 |
395 | private bool _UTF16Enable;
396 | public bool UTF16Enable
397 | {
398 | get
399 | {
400 | return _UTF16Enable;
401 | }
402 | set
403 | {
404 | if (_UTF16Enable != value)
405 | {
406 | _UTF16Enable = value;
407 | RaisePropertyChanged(nameof(UTF16Enable));
408 | }
409 | }
410 | }
411 |
412 | private bool _UTF32Enable;
413 | public bool UTF32Enable
414 | {
415 | get
416 | {
417 | return _UTF32Enable;
418 | }
419 | set
420 | {
421 | if (_UTF32Enable != value)
422 | {
423 | _UTF32Enable = value;
424 | RaisePropertyChanged(nameof(UTF32Enable));
425 | }
426 | }
427 | }
428 | #endregion
429 |
430 | #region 菜单栏 - 选项 - DTR/RTS
431 | private bool _DtrEnable;
432 | public bool DtrEnable
433 | {
434 | get
435 | {
436 | return _DtrEnable;
437 | }
438 | set
439 | {
440 | if (_DtrEnable != value)
441 | {
442 | _DtrEnable = value;
443 | RaisePropertyChanged(nameof(DtrEnable));
444 | }
445 | }
446 | }
447 |
448 | private bool _RtsEnable;
449 | public bool RtsEnable
450 | {
451 | get
452 | {
453 | return _RtsEnable;
454 | }
455 | set
456 | {
457 | if (_RtsEnable != value)
458 | {
459 | _RtsEnable = value;
460 | RaisePropertyChanged(nameof(RtsEnable));
461 | }
462 | }
463 | }
464 | #endregion
465 |
466 | #region 菜单栏 - 选项 - 流控制
467 | private bool _NoneEnable;
468 | public bool NoneEnable
469 | {
470 | get
471 | {
472 | return _NoneEnable;
473 | }
474 | set
475 | {
476 | if (_NoneEnable != value)
477 | {
478 | _NoneEnable = value;
479 | RaisePropertyChanged(nameof(NoneEnable));
480 | }
481 | }
482 | }
483 |
484 | private bool _RequestToSendEnable;
485 | public bool RequestToSendEnable
486 | {
487 | get
488 | {
489 | return _RequestToSendEnable;
490 | }
491 | set
492 | {
493 | if (_RequestToSendEnable != value)
494 | {
495 | _RequestToSendEnable = value;
496 | RaisePropertyChanged(nameof(RequestToSendEnable));
497 | }
498 | }
499 | }
500 |
501 | private bool _XOnXOffEnable;
502 | public bool XOnXOffEnable
503 | {
504 | get
505 | {
506 | return _XOnXOffEnable;
507 | }
508 | set
509 | {
510 | if (_XOnXOffEnable != value)
511 | {
512 | _XOnXOffEnable = value;
513 | RaisePropertyChanged(nameof(XOnXOffEnable));
514 | }
515 | }
516 | }
517 |
518 | private bool _RequestToSendXOnXOffEnable;
519 | public bool RequestToSendXOnXOffEnable
520 | {
521 | get
522 | {
523 | return _RequestToSendXOnXOffEnable;
524 | }
525 | set
526 | {
527 | if (_RequestToSendXOnXOffEnable != value)
528 | {
529 | _RequestToSendXOnXOffEnable = value;
530 | RaisePropertyChanged(nameof(RequestToSendXOnXOffEnable));
531 | }
532 | }
533 | }
534 | #endregion
535 |
536 | #region 信号状态区 - 信号指示灯
537 | private Brush _DcdBrush;
538 | public Brush DcdBrush
539 | {
540 | get
541 | {
542 | return _DcdBrush;
543 | }
544 | set
545 | {
546 | if (_DcdBrush != value)
547 | {
548 | _DcdBrush = value;
549 | RaisePropertyChanged(nameof(DcdBrush));
550 | }
551 | }
552 | }
553 |
554 | private Brush _CtsBrush;
555 | public Brush CtsBrush
556 | {
557 | get
558 | {
559 | return _CtsBrush;
560 | }
561 | set
562 | {
563 | if (_CtsBrush != value)
564 | {
565 | _CtsBrush = value;
566 | RaisePropertyChanged(nameof(CtsBrush));
567 | }
568 | }
569 | }
570 |
571 | private Brush _DsrBrush;
572 | public Brush DsrBrush
573 | {
574 | get
575 | {
576 | return _DsrBrush;
577 | }
578 | set
579 | {
580 | if (_DsrBrush != value)
581 | {
582 | _DsrBrush = value;
583 | RaisePropertyChanged(nameof(DsrBrush));
584 | }
585 | }
586 | }
587 | #endregion
588 |
589 | public string GetPortInformation( String PortName )
590 | {
591 | ManagementClass processClass = new ManagementClass("Win32_PnPEntity");
592 | ManagementObjectCollection Ports = processClass.GetInstances();
593 | foreach (ManagementObject property in Ports)
594 | {
595 | var name = property.GetPropertyValue("Name");
596 | if (name != null && name.ToString().Contains(PortName))
597 | {
598 | // var portInfo = new SerialPortInfo(property);
599 | Console.WriteLine("Port Name: " + name);
600 | Console.WriteLine("Port description: " + property.GetPropertyValue("Description"));
601 | return property.GetPropertyValue("Description").ToString();
602 | //Thats all information i got from port.
603 | //Do whatever you want with this information
604 | }
605 | }
606 | return string.Empty;
607 | }
608 |
609 | public void SerialPortDataContext()
610 | {
611 | PortItemsSource = SerialPort.GetPortNames();
612 | int i = 0;
613 | foreach (var port in PortItemsSource)
614 | {
615 | String PortDesc = GetPortInformation(port.ToString());
616 | PortItemsSource[i] = PortItemsSource[i] + " " + PortDesc;
617 | i++;
618 | }
619 |
620 | BaudRateItemsSource = new Collection
621 | {
622 | 1200, 2400, 4800, 7200, 9600, 14400, 19200, 28800, 38400, 57600, 115200, 128000, 153600, 230400, 256000
623 | };
624 | DataBitsItemsSource = new Collection
625 | {
626 | 5, 6, 7, 8
627 | };
628 | StopBitsItemsSource = new Collection
629 | {
630 | StopBits.One, StopBits.Two, StopBits.OnePointFive
631 | };
632 | ParityItemsSource = new Collection
633 | {
634 | Parity.None, Parity.Odd, Parity.Even, Parity.Mark, Parity.Space
635 | };
636 |
637 | //RecvBufSize = 2;
638 | Port = string.Format(CultureInfos, "COM1 通信端口");
639 | BaudRate = 115200;
640 | DataBits = 8;
641 | StopBits = StopBits.One;
642 | Parity = Parity.None;
643 |
644 | Brush = Brushes.DarkBlue;
645 | OpenClose = string.Format(CultureInfos, "打开串口");
646 |
647 | /* 串口属性控件 */
648 | PortEnable = true;
649 | BaudRateEnable = true;
650 | DataBitsEnable = true;
651 | StopBitsEnable = true;
652 | ParityEnable = true;
653 |
654 | /* 字节编码 */
655 | ASCIIEnable = false;
656 | UTF8Enable = true;
657 | UTF16Enable = false;
658 | UTF32Enable = false;
659 |
660 | /* 缓冲区设置*/
661 | RecvBuf1M = false;
662 | RecvBuf2M = false;
663 | RecvBuf4M = false;
664 | RecvBuf8M = true;
665 | SendBuf1M = true;
666 | SendBuf4M = false;
667 |
668 | DtrEnable = false;
669 | RtsEnable = false;
670 |
671 | /* 流控制 */
672 | NoneEnable = true;
673 | RequestToSendEnable = false;
674 | XOnXOffEnable = false;
675 | RequestToSendXOnXOffEnable = false;
676 |
677 | /* 信号状态 */
678 | DcdBrush = Brushes.Black;
679 | CtsBrush = Brushes.Black;
680 | DsrBrush = Brushes.Black;
681 | }
682 | }
683 | }
684 |
--------------------------------------------------------------------------------
/MetaCom/Models/TimerModel.cs:
--------------------------------------------------------------------------------
1 | using MetaCom.ViewModels;
2 | using System;
3 | using System.Timers;
4 |
5 | namespace MetaCom.Models
6 | {
7 | internal class TimerModel : MainWindowBase
8 | {
9 | #region 字段
10 | private static Timer SystemTimer = null; /* 该对象持续存在于整个应用程序运行期间 */
11 | #endregion
12 |
13 | ///
14 | /// 菜单栏 - 时间戳
15 | ///
16 | private bool _TimeStampEnable;
17 | public bool TimeStampEnable
18 | {
19 | get
20 | {
21 | return _TimeStampEnable;
22 | }
23 | set
24 | {
25 | if (_TimeStampEnable != value)
26 | {
27 | _TimeStampEnable = value;
28 | RaisePropertyChanged(nameof(TimeStampEnable));
29 | }
30 | }
31 | }
32 |
33 | ///
34 | /// 状态栏 - 系统时间
35 | ///
36 | private string _SystemTime;
37 | public string SystemTime
38 | {
39 | get
40 | {
41 | return _SystemTime;
42 | }
43 | set
44 | {
45 | if (_SystemTime != value)
46 | {
47 | _SystemTime = value;
48 | RaisePropertyChanged(nameof(SystemTime));
49 | }
50 | }
51 | }
52 |
53 | public void InitSystemClockTimer()
54 | {
55 | SystemTimer = new Timer
56 | {
57 | Interval = 1000
58 | };
59 |
60 | SystemTimer.Elapsed += SystemTimer_Elapsed;
61 | SystemTimer.AutoReset = true;
62 | SystemTimer.Enabled = true;
63 | }
64 |
65 | private void SystemTimer_Elapsed(object sender, ElapsedEventArgs e)
66 | {
67 | SystemTime = SystemTimeData();
68 | }
69 |
70 | private string SystemTimeData()
71 | {
72 | DateTime _DateTime = DateTime.Now;
73 |
74 | return string.Format(CultureInfos, "{0}-{1}-{2} {3}:{4}:{5}",
75 | _DateTime.Year.ToString("0000", CultureInfos),
76 | _DateTime.Month.ToString("00", CultureInfos),
77 | _DateTime.Day.ToString("00", CultureInfos),
78 | _DateTime.Hour.ToString("00", CultureInfos),
79 | _DateTime.Minute.ToString("00", CultureInfos),
80 | _DateTime.Second.ToString("00", CultureInfos));
81 | }
82 |
83 | public void TimerDataContext()
84 | {
85 | TimeStampEnable = false;
86 |
87 | SystemTime = string.Format(CultureInfos, "2022-03-09 12:13:15");
88 | InitSystemClockTimer();
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/MetaCom/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 | using System.Windows;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("MetaCom 串口调试工具")]
9 | [assembly: AssemblyDescription("串口调试工具")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("LinkMeta")]
12 | [assembly: AssemblyProduct("MetaCom 串口调试工具")]
13 | [assembly: AssemblyCopyright("Copyright © 2022")]
14 | [assembly: AssemblyTrademark("LinkMeta")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | //若要开始生成可本地化的应用程序,请设置
23 | //.csproj 文件中的 CultureYouAreCodingWith
24 | //例如,如果您在源文件中使用的是美国英语,
25 | //使用的是美国英语,请将 设置为 en-US。 然后取消
26 | //对以下 NeutralResourceLanguage 特性的注释。 更新
27 | //以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
28 |
29 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
30 |
31 |
32 | [assembly: ThemeInfo(
33 | ResourceDictionaryLocation.None, //主题特定资源词典所处位置
34 | //(未在页面中找到资源时使用,
35 | //或应用程序资源字典中找到时使用)
36 | ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
37 | //(未在页面中找到资源时使用,
38 | //、应用程序或任何主题专用资源字典中找到时使用)
39 | )]
40 |
41 |
42 | // 程序集的版本信息由下列四个值组成:
43 | //
44 | // 主版本
45 | // 次版本
46 | // 生成号
47 | // 修订号
48 | //
49 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
50 | //通过使用 "*",如下所示:
51 | // [assembly: AssemblyVersion("1.0.*")]
52 | //[assembly: AssemblyVersion("1.2.0")]
53 | //[assembly: AssemblyFileVersion("1.2.0")]
54 |
--------------------------------------------------------------------------------
/MetaCom/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace MetaCom.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// 返回此类使用的缓存的 ResourceManager 实例。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MetaCom.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 重写当前线程的 CurrentUICulture 属性,对
51 | /// 使用此强类型资源类的所有资源查找执行重写。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/MetaCom/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/MetaCom/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace MetaCom.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.1.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/MetaCom/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/MetaCom/ViewModels/AboutWindowVM.cs:
--------------------------------------------------------------------------------
1 | using MetaCom.Models;
2 |
3 | namespace MetaCom.ViewModels
4 | {
5 | internal class AboutViewModel : MainWindowBase
6 | {
7 | public HelpModel HelpModel { get; set; }
8 |
9 | public AboutViewModel()
10 | {
11 | HelpModel = new HelpModel();
12 | HelpModel.HelpDataContext();
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/MetaCom/ViewModels/MainWindowBase.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Globalization;
3 | using System.Runtime.CompilerServices;
4 |
5 | namespace MetaCom.ViewModels
6 | {
7 | public class MainWindowBase : INotifyPropertyChanged
8 | {
9 | public event PropertyChangedEventHandler PropertyChanged;
10 |
11 | ///
12 | /// 提供区域性信息
13 | ///
14 | internal CultureInfo CultureInfos = new CultureInfo(CultureInfo.CurrentUICulture.Name);
15 |
16 | ///
17 | /// 提供属性更改事件的方法
18 | ///
19 | ///
20 | internal void RaisePropertyChanged([CallerMemberName] string propertyName = null)
21 | {
22 | var handler = PropertyChanged;
23 |
24 | if (handler != null)
25 | {
26 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/MetaCom/Views/AboutWindow.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
42 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
62 |
64 |
65 |
67 |
69 |
71 |
72 | https://github.com/linkmeta/MetaCom
73 |
74 |
76 |
77 | https://gitee.com/linkmeta/MetaCom
78 |
79 |
80 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
95 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/MetaCom/Views/AboutWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using MetaCom.ViewModels;
2 | using System.Diagnostics;
3 | using System.Windows;
4 |
5 | namespace MetaCom.Views
6 | {
7 | ///
8 | /// AboutWindow.xaml 的交互逻辑
9 | ///
10 | public partial class AboutWindow : Window
11 | {
12 | internal AboutViewModel aboutViewModel = null;
13 |
14 | public AboutWindow()
15 | {
16 | InitializeComponent();
17 |
18 | Height = 300;
19 | Width = Height / 0.725;
20 |
21 | aboutViewModel = new AboutViewModel();
22 | DataContext = aboutViewModel;
23 | }
24 | private void GithubButton_Click(object sender, RoutedEventArgs e)
25 | {
26 | Process.Start("https://github.com/linkmeta/MetaCom");
27 |
28 | Close();
29 | }
30 | private void GiteeButton_Click(object sender, RoutedEventArgs e)
31 | {
32 | Process.Start("https://gitee.com/linkmeta/MetaCom");
33 |
34 | Close();
35 | }
36 | private void UpdateButton_Click(object sender, RoutedEventArgs e)
37 | {
38 | Process.Start("https://gitee.com/linkmeta/MetaCom/releases");
39 |
40 | Close();
41 | }
42 |
43 | private void CloseButton_Click(object sender, RoutedEventArgs e)
44 | {
45 | Close();
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/MetaCom/Views/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
52 |
54 |
57 |
58 |
66 |
75 |
84 |
85 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
269 |
270 |
271 |
272 |
273 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
344 |
349 |
352 |
356 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
374 |
379 |
381 |
386 |
388 |
393 |
395 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
413 |
416 |
419 |
424 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
439 |
443 |
447 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
478 |
479 |
480 |
481 |
482 |
483 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
561 |
562 |
563 |
564 |
565 |
566 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
--------------------------------------------------------------------------------
/MetaCom/Views/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using MetaCom.Interfaces;
2 | using MetaCom.Models;
3 | using MetaCom.ViewModels;
4 |
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Collections.ObjectModel;
8 | using System.ComponentModel;
9 | using System.Diagnostics;
10 | using System.IO;
11 | using System.Text.RegularExpressions;
12 | using System.Threading;
13 | using System.Windows;
14 | using System.Windows.Controls;
15 | //using System.Windows.Forms;
16 | using System.Windows.Input;
17 | using System.Windows.Threading;
18 | using System.Xml.Linq;
19 | using System.Xml.Serialization;
20 | using static MetaCom.Models.ConfigModel;
21 | //using System.Windows;
22 | //using System.Windows.Controls;
23 | //using System.Windows.Forms;
24 | //using System.Windows.Input;
25 |
26 | namespace MetaCom.Views
27 | {
28 | public partial class MainWindow : Window, IDisposable
29 | {
30 | internal MainWindowViewModel mainWindowViewModel = null;
31 |
32 | public class Command : INotifyPropertyChanged
33 | {
34 | public event PropertyChangedEventHandler PropertyChanged;
35 | private string _CmdStr;
36 | public string CmdStr
37 | {
38 | get { return _CmdStr; }
39 | set
40 | {
41 | _CmdStr = value;
42 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("CmdStr"));
43 | }
44 | }
45 | public override string ToString()
46 | {
47 | return this.CmdStr;
48 | }
49 | public Command()
50 | {
51 | _CmdStr = CmdStr;
52 | }
53 | }
54 |
55 | public MainWindow()
56 | {
57 | InitializeComponent();
58 |
59 | Height = 700;
60 | Width = Height / 0.8;
61 |
62 | mainWindowViewModel = new MainWindowViewModel();
63 |
64 | DataContext = mainWindowViewModel;
65 | CommonCmdDataList.ItemsSource = mainWindowViewModel.ConfigModel.CommonCmds;
66 | HistoryCmdDataList.ItemsSource = mainWindowViewModel.ConfigModel.RescentCmds;
67 |
68 | }
69 |
70 | #region Menu Mouse Support
71 | ///
72 | /// 鼠标移动
73 | ///
74 | ///
75 | ///
76 | private void MouseMove_Click(object sender, System.Windows.Input.MouseEventArgs e)
77 | {
78 | if (e.LeftButton == MouseButtonState.Pressed)
79 | {
80 | DragMove();
81 | }
82 | }
83 | #endregion
84 |
85 | #region 菜单栏
86 |
87 | #region 文件
88 | ///
89 | /// 退出
90 | ///
91 | ///
92 | ///
93 | private void ExitMenuItem_Click(object sender, RoutedEventArgs e)
94 | {
95 | mainWindowViewModel.ExitWindow();
96 |
97 | Close();
98 | }
99 | #endregion
100 |
101 | #region 工具
102 | ///
103 | /// 计算器
104 | ///
105 | ///
106 | ///
107 | private void CalcMenuItem_Click(object sender, RoutedEventArgs e)
108 | {
109 | Process.Start("calc.exe");
110 | }
111 | #endregion
112 |
113 | #region 选项
114 |
115 | #region 字节编码
116 | private void ASCIIMenuItem_Click(object sender, RoutedEventArgs e)
117 | {
118 | mainWindowViewModel.ASCIIEnable();
119 | }
120 |
121 | private void UTF8MenuItem_Click(object sender, RoutedEventArgs e)
122 | {
123 | mainWindowViewModel.UTF8Enable();
124 | }
125 |
126 | private void UTF16MenuItem_Click(object sender, RoutedEventArgs e)
127 | {
128 | mainWindowViewModel.UTF16Enable();
129 | }
130 |
131 | private void UTF32MenuItem_Click(object sender, RoutedEventArgs e)
132 | {
133 | mainWindowViewModel.UTF32Enable();
134 | }
135 | #endregion
136 |
137 | private void RecvBuf1MMenuItem_Click(object sender, RoutedEventArgs e)
138 | {
139 | mainWindowViewModel.RecvBuf1M();
140 | }
141 | private void RecvBuf2MMenuItem_Click(object sender, RoutedEventArgs e)
142 | {
143 | mainWindowViewModel.RecvBuf2M();
144 | }
145 | private void RecvBuf4MMenuItem_Click(object sender, RoutedEventArgs e)
146 | {
147 | mainWindowViewModel.RecvBuf4M();
148 | }
149 | private void RecvBuf8MMenuItem_Click(object sender, RoutedEventArgs e)
150 | {
151 | mainWindowViewModel.RecvBuf8M();
152 | }
153 | private void SendBuf1MMenuItem_Click(object sender, RoutedEventArgs e)
154 | {
155 | mainWindowViewModel.SendBuf1M();
156 | }
157 | private void SendBuf4MMenuItem_Click(object sender, RoutedEventArgs e)
158 | {
159 | mainWindowViewModel.SendBuf4M();
160 | }
161 |
162 |
163 | private void RtsEnableMenuItem_Click(object sender, RoutedEventArgs e)
164 | {
165 | mainWindowViewModel.RtsEnable();
166 | }
167 |
168 | private void DtrEnableMenuItem_Click(object sender, RoutedEventArgs e)
169 | {
170 | mainWindowViewModel.DtrEnable();
171 | }
172 |
173 | #region 流控制
174 | private void NoneMenuItem_Click(object sender, RoutedEventArgs e)
175 | {
176 | mainWindowViewModel.NoneEnable();
177 | }
178 |
179 | private void RequestToSendMenuItem_Click(object sender, RoutedEventArgs e)
180 | {
181 | mainWindowViewModel.RequestToSendEnable();
182 | }
183 |
184 | private void XOnXOffMenuItem_Click(object sender, RoutedEventArgs e)
185 | {
186 | mainWindowViewModel.XOnXOffEnable();
187 | }
188 |
189 | private void RequestToSendXOnXOffMenuItem_Click(object sender, RoutedEventArgs e)
190 | {
191 | mainWindowViewModel.RequestToSendXOnXOffEnable();
192 | }
193 | #endregion
194 |
195 | private void TimeStampMenuItem_Click(object sender, RoutedEventArgs e)
196 | {
197 | mainWindowViewModel.TimeStampEnable();
198 | }
199 |
200 | #region 发送换行
201 | private void NonesMenuItem_Click(object sender, RoutedEventArgs e)
202 | {
203 | mainWindowViewModel.NonesEnable();
204 | }
205 |
206 | private void CrMenuItem_Click(object sender, RoutedEventArgs e)
207 | {
208 | mainWindowViewModel.CrEnable();
209 | }
210 |
211 | private void LfMenuItem_Click(object sender, RoutedEventArgs e)
212 | {
213 | mainWindowViewModel.LfEnable();
214 | }
215 |
216 | private void CrLfMenuItem_Click(object sender, RoutedEventArgs e)
217 | {
218 | mainWindowViewModel.CrLfEnable();
219 | }
220 | #endregion
221 |
222 | #endregion
223 |
224 | #region 帮助
225 | ///
226 | /// 检查更新
227 | ///
228 | ///
229 | ///
230 | private void AboutMenuItem_Click(object sender, RoutedEventArgs e)
231 | {
232 | mainWindowViewModel.ShowAboutWindow();
233 | }
234 |
235 | ///
236 | /// 问题反馈(Github)
237 | ///
238 | ///
239 | ///
240 | private void GithubMenuItem_Click(object sender, RoutedEventArgs e)
241 | {
242 | Process.Start("https://github.com/linkmeta/MetaCom/issues");
243 | }
244 |
245 | ///
246 | /// 问题反馈(Gitee)
247 | ///
248 | ///
249 | ///
250 | private void GiteeMenuItem_Click(object sender, RoutedEventArgs e)
251 | {
252 | Process.Start("https://gitee.com/linkmeta/MetaCom/issues");
253 | }
254 | #endregion
255 |
256 | ///
257 | /// 最小化
258 | ///
259 | ///
260 | ///
261 | private void MinButton_Click(object sender, RoutedEventArgs e)
262 | {
263 | WindowState = WindowState.Minimized;
264 | }
265 | private void MaxButton_Click(object sender, RoutedEventArgs e)
266 | {
267 | //WindowState = WindowState.Maximized;
268 | if(WindowState== WindowState.Maximized)
269 | {
270 | WindowState = WindowState.Normal;
271 | mainWindowViewModel.NormalWinIcon = "Hidden";
272 | mainWindowViewModel.MaxWinIcon = "Visible";
273 | }
274 | else if(WindowState == WindowState.Normal)
275 | {
276 | WindowState = WindowState.Maximized;
277 | mainWindowViewModel.NormalWinIcon = "Visible";
278 | mainWindowViewModel.MaxWinIcon = "Hidden";
279 | }
280 | }
281 | ///
282 | /// 关闭
283 | ///
284 | ///
285 | ///
286 | private void CloseButton_Click(object sender, RoutedEventArgs e)
287 | {
288 | mainWindowViewModel.SaveConfig();
289 | Close();
290 | Application.Current.Shutdown();
291 | }
292 | #endregion
293 |
294 | #region 打开/关闭串口
295 | private void OpenCloseSP(object sender, RoutedEventArgs e)
296 | {
297 | mainWindowViewModel.OpenSP();
298 | }
299 | #endregion
300 |
301 | #region 发送
302 | private async void Send(object sender, RoutedEventArgs e)
303 | {
304 | if (SendTextBox.Text != "")
305 | {
306 | mainWindowViewModel.SaveRescentCmd(SendTextBox.Text);
307 | HistoryCmdDataList.SelectedIndex = mainWindowViewModel.ConfigModel.RescentCmds.Count;
308 | HistoryCmdDataList.ScrollIntoView(HistoryCmdDataList.SelectedItem);
309 | }
310 |
311 | await mainWindowViewModel.SendAsync().ConfigureAwait(false);
312 |
313 | }
314 | #endregion
315 |
316 | #region 发送文件
317 | private async void SendFile(object sender, RoutedEventArgs e)
318 | {
319 | await mainWindowViewModel.SendFileAsync().ConfigureAwait(false);
320 | }
321 | #endregion
322 |
323 | #region 路径选择
324 | private void SaveRecvPath(object sender, RoutedEventArgs e)
325 | {
326 | mainWindowViewModel.SaveRecvPath();
327 | }
328 | #endregion
329 |
330 | #region 清接收区
331 | private void ClearReceData(object sender, RoutedEventArgs e)
332 | {
333 | mainWindowViewModel.ClearReceData();
334 | }
335 | #endregion
336 |
337 | #region 清发送区
338 | private void ClearSendData(object sender, RoutedEventArgs e)
339 | {
340 | mainWindowViewModel.ClearSendData();
341 | }
342 | #endregion
343 |
344 | #region 清空计数
345 | private void ClearCount(object sender, RoutedEventArgs e)
346 | {
347 | mainWindowViewModel.ClearCount();
348 | }
349 | #endregion
350 |
351 | #region TextBox Support
352 | ///
353 | /// 只允许输入0-9的数字
354 | ///
355 | ///
356 | ///
357 | private void AutoSendNumTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
358 | {
359 | Regex re = new Regex("[^0-9]+");
360 |
361 | e.Handled = re.IsMatch(e.Text);
362 | }
363 | #endregion
364 |
365 | #region RecvTextBox Support
366 | ///
367 | /// Mouse Double(鼠标双击)
368 | ///
369 | ///
370 | ///
371 | private void RecvTextBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
372 | {
373 | mainWindowViewModel.EnableRecv();
374 | }
375 |
376 | ///
377 | /// ScrollToEnd
378 | ///
379 | ///
380 | ///
381 | private void RecvTextBox_TextChanged(object sender, TextChangedEventArgs e)
382 | {
383 | RecvTextBox.ScrollToEnd();
384 | }
385 | #endregion
386 | #region TextBox Support
387 | ///
388 | /// 只允许输入0-9的数字
389 | ///
390 | ///
391 | ///
392 | private async void RecvTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
393 | {
394 |
395 | }
396 |
397 | private async void SearchBox_OnKeyDown(object sender, KeyEventArgs e)
398 | {
399 |
400 | }
401 | #endregion
402 | #region IDisposable Support
403 | private bool disposedValue = false; /* 冗余检测 */
404 |
405 | ///
406 | /// 释放组件所使用的非托管资源,并且有选择的释放托管资源(可以看作是Dispose()的安全实现)
407 | ///
408 | ///
409 | protected virtual void Dispose(bool disposing)
410 | {
411 | /* 检查是否已调用dispose */
412 | if (!disposedValue)
413 | {
414 | if (disposing)
415 | {
416 | /* 释放托管资源(如果需要) */
417 |
418 | /* 由于mainWindowViewModel对象拥有SerialPort,因此间接拥有SerialPort的非托管资源,所以需要实现IDisposable */
419 | mainWindowViewModel.Dispose();
420 | }
421 |
422 | /* 释放非托管资源(如果有的话) */
423 | disposedValue = true; /* 处理完毕 */
424 | }
425 | }
426 |
427 | ///
428 | /// 实现IDisposable,释放组件所使用的所有资源
429 | ///
430 | public void Dispose()
431 | {
432 | Dispose(true);
433 | GC.SuppressFinalize(this);/* this: MetaTerm.Views.MainWindow */
434 | }
435 | #endregion
436 |
437 | private void CommonCmd_SelectionChanged(object sender, SelectionChangedEventArgs e)
438 | {
439 | try
440 | {
441 | var selected = (CommonCmd)((ListView)sender).SelectedItem;
442 | if (selected != null)
443 | {
444 | string cmd = selected.Item;
445 | if (cmd != null)
446 | {
447 | mainWindowViewModel.SendCmd(cmd);
448 | }
449 | }
450 | }
451 | catch (Exception exc)
452 | {
453 | mainWindowViewModel.DebugInfo = exc.Message.Replace("\r\n", "");
454 | }
455 | }
456 |
457 | private void HistoryCmd_SelectionChanged(object sender, SelectionChangedEventArgs e)
458 | {
459 | try
460 | {
461 | var selected = (RescentCmd)((ListView)sender).SelectedItem;
462 | if (selected != null)
463 | {
464 | string cmd = selected.Item;
465 | if (cmd != null)
466 | {
467 | mainWindowViewModel.SendCmd(cmd);
468 | }
469 | }
470 | }
471 | catch (Exception excp)
472 | {
473 | mainWindowViewModel.DebugInfo = excp.Message.Replace("\r\n", "");
474 | }
475 | }
476 |
477 | private async void AddToCommonCmdList(object sender, RoutedEventArgs e)
478 | {
479 | string cmd = "";
480 | int num = HistoryCmdDataList.SelectedIndex;//选中的listview的行
481 | cmd = mainWindowViewModel.ConfigModel.RescentCmds[num].Item;
482 | mainWindowViewModel.SaveCommonCmd(cmd);
483 | CommonCmdDataList.SelectedIndex = mainWindowViewModel.ConfigModel.CommonCmds.Count - 1;
484 | CommonCmdDataList.ScrollIntoView(CommonCmdDataList.SelectedItem);
485 | }
486 |
487 | private void DelFromHistoryCmdList(object sender, RoutedEventArgs e)
488 | {
489 | int num = HistoryCmdDataList.SelectedIndex; //选中的listview的行
490 | HistoryCmdDataList.ItemsSource = null;
491 | if (mainWindowViewModel.ConfigModel.RescentCmds.Count != 0)
492 | mainWindowViewModel.ConfigModel.RescentCmds.RemoveAt(num); //删除listview的选中的行
493 | HistoryCmdDataList.ItemsSource = mainWindowViewModel.ConfigModel.RescentCmds;
494 | }
495 | private void DelAllCmdList(object sender, RoutedEventArgs e)
496 | {
497 | mainWindowViewModel.ConfigModel.RescentCmds.Clear();
498 | }
499 | private void DelFromCommonCmdList(object sender, RoutedEventArgs e)
500 | {
501 | int num = CommonCmdDataList.SelectedIndex; //选中的listview的行
502 | CommonCmdDataList.ItemsSource = null;
503 | if (mainWindowViewModel.ConfigModel.CommonCmds.Count != 0)
504 | mainWindowViewModel.ConfigModel.CommonCmds.RemoveAt(num); //删除listview的选中的行
505 | CommonCmdDataList.ItemsSource = mainWindowViewModel.ConfigModel.CommonCmds;
506 | }
507 | }
508 |
509 | #region RecvTextBox Append Text Support
510 | public static class MvvmTextBox
511 | {
512 | public static readonly DependencyProperty BufferProperty =
513 | DependencyProperty.RegisterAttached(
514 | "Buffer",
515 | typeof(TextBoxAppend),
516 | typeof(MvvmTextBox),
517 | new UIPropertyMetadata(null, PropertyChangedCallback)
518 | );
519 |
520 | private static void PropertyChangedCallback(
521 | DependencyObject dependencyObject,
522 | DependencyPropertyChangedEventArgs depPropChangedEvArgs)
523 | {
524 | var textBox = (TextBox)dependencyObject;
525 | var textBuffer = (TextBoxAppend)depPropChangedEvArgs.NewValue;
526 |
527 | var detectChanges = true;
528 |
529 | textBuffer.BufferClearingHandler += (sender, clearingText) =>
530 | {
531 | detectChanges = false;
532 | textBox.Clear();
533 | detectChanges = true;
534 | };
535 |
536 | textBox.Text = textBuffer.GetCurrentValue();
537 | textBuffer.BufferAppendedHandler += (sender, appendedText) =>
538 | {
539 | detectChanges = false;
540 | textBox.AppendText(appendedText.AppendedText);
541 | detectChanges = true;
542 | };
543 |
544 | textBox.TextChanged += (sender, args) =>
545 | {
546 | if (!detectChanges)
547 | return;
548 |
549 | foreach (var change in args.Changes)
550 | {
551 | if (change.AddedLength > 0)
552 | {
553 | var addedContent = textBox.Text.Substring(
554 | change.Offset, change.AddedLength);
555 |
556 | textBuffer.Append(addedContent, change.Offset);
557 | }
558 | else
559 | {
560 | textBuffer.Delete(change.Offset, change.RemovedLength);
561 | }
562 | }
563 |
564 | Debug.WriteLine(textBuffer.GetCurrentValue());
565 | };
566 | }
567 |
568 | public static void SetBuffer(UIElement element, bool value)
569 | {
570 | if (element != null)
571 | {
572 | element.SetValue(BufferProperty, value);
573 | }
574 | }
575 | public static TextBoxAppend GetBuffer(UIElement element)
576 | {
577 | if (element == null)
578 | {
579 | return (TextBoxAppend)null;
580 | }
581 |
582 | return (TextBoxAppend)element.GetValue(BufferProperty);
583 | }
584 | }
585 | #endregion
586 | }
587 |
--------------------------------------------------------------------------------
/MetaCom/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/MetaCom/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # MetaCom
3 | 
4 | 
5 | 
6 | 
7 |
8 | 
9 |
10 | MetaCom 串口调试工具,基于WPF框架,MVVM模型开发,专注于串口常用功能,接收发送稳定性。
11 |
12 |
13 | ## 功能列表
14 |
15 | - [x] 界面基本功能(打开、关闭、接收、发送、清空接收、清空发送和清空计数)
16 | - [x] 支持常用波特率选择(不支持自定义波特率)
17 | - [x] 支持流控制(握手协议、控制协议)
18 | - [x] 支持接收与发送字节数统计
19 | - [x] 支持自动发送,可设置发送时间间隔,默认1000ms
20 | - [x] 支持切换为HEX发送、接收
21 | - [x] 支持自动保存串口接收数据为文件,支持文件路径设置
22 | - [x] 编码方式(ASCII,UTF-8,UTF-16,UTF-32)
23 | - [x] 支持接收缓冲区与发送缓冲区设置,最大支持8M
24 | - [x] 支持文件发送
25 | - [x] 支持github或者gitee 问题反馈
26 | - [ ] 在线更新
27 | - [x] 增加常用命令功能,支持删除
28 | - [x] 增加最近命令功能,支持添加到常用命令,删除等
29 | - [x] 增加保存为xml配置文件
30 |
31 | #### 默认设置
32 | * 编码方式为 UTF-8
33 | * 接收缓冲区大小配置为 8MB
34 | * 发送缓冲区大小配置为 1MB
35 | * 流控为 None(无控制流)
36 | * 串行端口信号控制 Rts 和 Dtr 默认均未启用
37 |
38 |
39 |
40 | ## 构建
41 |
42 | - [x] VisualStudio 2022(基于 .NET WPF框架验证)
43 |
44 | ```bash
45 | $ git clone https://github.com/linkmeta/MetaCom.git
46 | $ cd MetaCom
47 | ```
48 | *双击 `MetaCom.sln`
49 |
50 | ## 特别感谢
51 |
52 | 本项目参考了leven99的OSDA项目,特此感谢!
53 |
54 | ## License
55 |
56 | 软件采用 MIT License 授权([License MIT](./LICENSE))。
57 |
58 |
--------------------------------------------------------------------------------
/docs/MetaCom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkmeta/MetaCom/71bef4da05ca2053ecc5061dbe61c6e3ead768af/docs/MetaCom.png
--------------------------------------------------------------------------------
/docs/about.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/linkmeta/MetaCom/71bef4da05ca2053ecc5061dbe61c6e3ead768af/docs/about.png
--------------------------------------------------------------------------------