Compare commits

...

No commits in common. 'main' and 'master' have entirely different histories.
main ... master

63
.gitattributes vendored

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

363
.gitignore vendored

@ -0,0 +1,363 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# 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
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# 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
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

@ -1,9 +0,0 @@
MIT License
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -1,2 +0,0 @@
# RFIDmonitor

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35913.81
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RFIDmonitor", "SocketExample\RFIDmonitor.csproj", "{7E4E4E45-2FB2-4346-A101-4863BCDF50F9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7E4E4E45-2FB2-4346-A101-4863BCDF50F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7E4E4E45-2FB2-4346-A101-4863BCDF50F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7E4E4E45-2FB2-4346-A101-4863BCDF50F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7E4E4E45-2FB2-4346-A101-4863BCDF50F9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {484367ED-A45A-4CF7-89AC-DCD9BFC6E131}
EndGlobalSection
EndGlobal

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

@ -0,0 +1,93 @@
<Application x:Class="SocketExample.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SocketExample"
StartupUri="TCPWindowV2.xaml">
<Application.Resources>
<Style x:Key="BaseButtonStyle" TargetType="Button">
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="Padding" Value="8 5"/>
<Setter Property="Margin" Value="5"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="ButtonBorder" Background="{TemplateBinding Background}" CornerRadius="3">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="ButtonBorder" Property="Opacity" Value="0.8"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="ButtonBorder" Property="Opacity" Value="0.6"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 颜色定义 -->
<Color x:Key="PrimaryColor">#FF4285F4</Color>
<Color x:Key="DarkPrimaryColor">#FF3367D6</Color>
<Color x:Key="AccentColor">#FF34A853</Color>
<Color x:Key="WarningColor">#FFEA4335</Color>
<Color x:Key="LightGray">#FFEEEEEE</Color>
<Color x:Key="DarkGray">#FF757575</Color>
<!-- 笔刷定义 -->
<SolidColorBrush x:Key="PrimaryBrush" Color="{StaticResource PrimaryColor}"/>
<SolidColorBrush x:Key="DarkPrimaryBrush" Color="{StaticResource DarkPrimaryColor}"/>
<SolidColorBrush x:Key="AccentBrush" Color="{StaticResource AccentColor}"/>
<SolidColorBrush x:Key="WarningBrush" Color="{StaticResource WarningColor}"/>
<SolidColorBrush x:Key="LightGrayBrush" Color="{StaticResource LightGray}"/>
<SolidColorBrush x:Key="DarkGrayBrush" Color="{StaticResource DarkGray}"/>
<!-- 终端样式 -->
<Style x:Key="TerminalStyle" TargetType="Border">
<Setter Property="Background" Value="White"/>
<Setter Property="CornerRadius" Value="8"/>
<Setter Property="Padding" Value="1"/>
<Setter Property="Margin" Value="4"/>
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="12"
ShadowDepth="0"
Color="#20000000"/>
</Setter.Value>
</Setter>
</Style>
<!-- 扁平化按钮样式 -->
<Style x:Key="FlatButton" TargetType="Button">
<Setter Property="Background" Value="{StaticResource PrimaryBrush}"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="12 8"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="FontSize" Value="15"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
CornerRadius="4">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{StaticResource DarkPrimaryBrush}"/>
</Trigger>
</Style.Triggers>
</Style>
</Application.Resources>
</Application>

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace SocketExample
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
}
}

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura />
</Weavers>

@ -0,0 +1,29 @@
<Window x:Class="SocketExample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SocketExample"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<StackPanel x:Name="InformationPanel" Margin="0,72,400,10" >
<TextBlock x:Name="InfoTextBlock" TextWrapping="Wrap" Text="" Height="352"/>
</StackPanel>
<StackPanel Margin="0,0,0,368" Orientation="Horizontal">
<Label Content="IP地址" Height="30" Margin="40 8 10 0"/>
<TextBox TextWrapping="Wrap" x:Name="IPtextbox" Text="127.0.0.1" Width="200" Height="30" Margin="0 8 10 0"/>
<Label Content="端口号" Height="30" Margin="40 8 10 0"/>
<TextBox TextWrapping="Wrap" Text="8999" x:Name="Porttextbox" Width="200" Height="30" Margin="0 8 10 0"/>
<Button Content="链接" Height="30" Margin="30 8 10 0" Click="Button_Click"/>
<Button Content="清空" Height="30" Margin="30 8 10 0" Click="Button_Click_Clear"/>
</StackPanel>
<StackPanel Margin="400,67,0,10">
<Button Content="创建客户端界面" Width="200" Click="Button_Click_Create"/>
<Button Content="读取文件信息" Width="200" Click="Button_Click_ReadFile" Margin="10 10 10 0"/>
<Button Content="读取数据库消息" Width="200" Click="Button_Click_ReadSql" Margin="10 10 10 0"/>
</StackPanel>
</Grid>
</Window>

@ -0,0 +1,173 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Net.Sockets;
using System.Net;
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.Navigation;
using System.Windows.Shapes;
using System.Threading;
using System.IO;
using System.Data.SqlClient;
using MySql.Data.MySqlClient;
namespace SocketExample
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
IPAddress ip;
int port;
string path;
public MainWindow()
{
path = "C:\\Users\\Administrator\\source\\repos\\SocketExample\\SocketExample\\bin\\Debug\\config.txt";
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
ip = IPAddress.Parse(IPtextbox.Text);
port = int.Parse(Porttextbox.Text);
// 创建TCPListener
TcpListener server = new TcpListener(ip, port);
// 开始监听
server.Start();
InfoTextBlock.Text += "正在监听...\n";
Thread thread = new Thread(Listen);
thread.IsBackground = true;
thread.Start(server);
}
TcpClient client;
void Listen(object o)
{
TcpListener socketWatch = o as TcpListener;
while (true)
{
// 接受客户端连接,进程会一直在这等待,直到客户端链接才会继续下一步。
client = socketWatch.AcceptTcpClient();
Dispatcher.Invoke(() => {
InfoTextBlock.Text += "客户端已连接!\n";
});
Thread thread = new Thread(Recive);
thread.IsBackground = true;
thread.Start(client);
}
}
void Recive(Object o)
{
TcpClient tcpClient = o as TcpClient;
NetworkStream stream = tcpClient.GetStream();
while (true)
{
// 处理客户端请求
try
{
// 读取客户端消息
byte[] buffer = new byte[1024];
int bytesRead = stream.Read(buffer, 0, buffer.Length);
if (bytesRead == 0) {
Dispatcher.Invoke(() =>
{
InfoTextBlock.Text += $"客户端已断开连接\n";
});
break;
}
string request = Encoding.UTF8.GetString(buffer, 0, bytesRead);
Dispatcher.Invoke(() =>
{
InfoTextBlock.Text += $"接收到客户端消息: {request}\n";
});
// 发送响应
string response = $"服务器已收到你的消息: {request}";
byte[] responseBytes = Encoding.UTF8.GetBytes(response);
stream.Write(responseBytes, 0, responseBytes.Length);
Dispatcher.Invoke(() =>
{
InfoTextBlock.Text += "已发送响应给客户端\n";
});
}
catch (Exception ex)
{
Console.WriteLine($"处理请求时出错: {ex.Message}");
}
}
// 关闭连接
stream.Close();
client.Close();
}
private void Button_Click_Clear(object sender, RoutedEventArgs e)
{
this.InfoTextBlock.Text = string.Empty;
}
private void Button_Click_Create(object sender, RoutedEventArgs e)
{
ClientWindow clientWindow = new ClientWindow();
clientWindow.Show();
}
private void Button_Click_ReadFile(object sender, RoutedEventArgs e)
{
try
{
string[] ipconfig = File.ReadAllLines(path);
string[] ip = ipconfig[0].Split(':');
string[] port = ipconfig[1].Split(':');
InfoTextBlock.Text += ip[1];
InfoTextBlock.Text += port[1];
IPtextbox.Text = ip[1];
Porttextbox.Text = port[1];
}
catch(Exception ex)
{
InfoTextBlock.Text += ex.Message;
}
}
private void Button_Click_ReadSql(object sender, RoutedEventArgs e)
{
MySqlConnection conn = new MySqlConnection("server=127.0.0.1;port=3306;database=Test;user=root;password=root;");
MySqlCommand comn = new MySqlCommand("select * from Product",conn);
if (conn.State == System.Data.ConnectionState.Closed) {
conn.Open();
}
MySqlDataReader reader = comn.ExecuteReader();
try
{
if (reader.HasRows) {
while (reader.Read()) {
InfoTextBlock.Text += "" + reader["ID"] + reader["Name"] + "\n";
}
}
}
catch (Exception ex) {
InfoTextBlock.Text += ex.Message;
}
finally
{
conn.Close();
}
}
}
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using TouchSocket;
using TouchSocket.Core;
using TouchSocket.Sockets;
using static SocketExample.TCPWindowV2;
namespace SocketExample
{
public class MyTouchClass
{
public sealed class MySessionClient : TcpSessionClient
{
protected override async Task OnTcpReceived(ReceivedDataEventArgs e)
{
//此处逻辑单线程处理。
//此处处理数据功能相当于Received委托。
var mes = e.ByteBlock.Span.ToString(Encoding.UTF8);
MessageBox.Show($"已接收到信息:{mes}");
await base.OnTcpReceived(e);
}
}
public class MyService : TcpService<MySessionClient>
{
protected override void LoadConfig(TouchSocketConfig config)
{
//此处加载配置,用户可以从配置中获取配置项。
base.LoadConfig(config);
}
protected override MySessionClient NewClient()
{
return new MySessionClient();
}
protected override async Task OnTcpConnecting(MySessionClient socketClient, ConnectingEventArgs e)
{
//此处逻辑会多线程处理。
//e.Id:对新连接的客户端进行ID初始化默认情况下是按照设定的规则随机分配的。
//但是按照需求您可以自定义设置例如设置为其IP地址。但是需要注意的是id必须在生命周期内唯一。
//e.IsPermitOperation:指示是否允许该客户端链接。
await base.OnTcpConnecting(socketClient, e);
}
}
}
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

@ -0,0 +1,52 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("RFIDMultMonitor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RFIDMultMonitor")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
//若要开始生成可本地化的应用程序,请设置
//.csproj 文件中的 <UICulture>CultureYouAreCodingWith</UICulture>
//在 <PropertyGroup> 中。例如,如果你使用的是美国英语。
//使用的是美国英语,请将 <UICulture> 设置为 en-US。 然后取消
//对以下 NeutralResourceLanguage 特性的注释。 更新
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
//(未在页面中找到资源时使用,
//或应用程序资源字典中找到时使用)
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
//(未在页面中找到资源时使用,
//、应用程序或任何主题专用资源字典中找到时使用)
)]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace SocketExample.Properties
{
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// 返回此类使用的缓存 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SocketExample.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SocketExample.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

@ -0,0 +1,297 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Costura.Fody.6.0.0\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.6.0.0\build\Costura.Fody.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7E4E4E45-2FB2-4346-A101-4863BCDF50F9}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>SocketExample</RootNamespace>
<AssemblyName>RFIDMultiMonitor</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Pictogrammers-Material-Monitor-eye.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL">
<HintPath>..\packages\BouncyCastle.Cryptography.2.5.1\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
</Reference>
<Reference Include="CommonServiceLocator, Version=2.0.2.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
<HintPath>..\packages\CommonServiceLocator.2.0.2\lib\net47\CommonServiceLocator.dll</HintPath>
</Reference>
<Reference Include="Costura, Version=6.0.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
<HintPath>..\packages\Costura.Fody.6.0.0\lib\netstandard2.0\Costura.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight, Version=5.4.1.0, Culture=neutral, PublicKeyToken=e7570ab207bcb616, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Extras, Version=5.4.1.0, Culture=neutral, PublicKeyToken=669f0b5e8f868abf, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Extras.dll</HintPath>
</Reference>
<Reference Include="GalaSoft.MvvmLight.Platform, Version=5.4.1.0, Culture=neutral, PublicKeyToken=5f873c45e98af8a1, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.4.1.1\lib\net45\GalaSoft.MvvmLight.Platform.dll</HintPath>
</Reference>
<Reference Include="Google.Protobuf, Version=3.30.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>..\packages\Google.Protobuf.3.30.0\lib\net45\Google.Protobuf.dll</HintPath>
</Reference>
<Reference Include="K4os.Compression.LZ4, Version=1.3.8.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
<HintPath>..\packages\K4os.Compression.LZ4.1.3.8\lib\net462\K4os.Compression.LZ4.dll</HintPath>
</Reference>
<Reference Include="K4os.Compression.LZ4.Streams, Version=1.3.8.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
<HintPath>..\packages\K4os.Compression.LZ4.Streams.1.3.8\lib\net462\K4os.Compression.LZ4.Streams.dll</HintPath>
</Reference>
<Reference Include="K4os.Hash.xxHash, Version=1.0.8.0, Culture=neutral, PublicKeyToken=32cd54395057cec3, processorArchitecture=MSIL">
<HintPath>..\packages\K4os.Hash.xxHash.1.0.8\lib\net462\K4os.Hash.xxHash.dll</HintPath>
</Reference>
<Reference Include="Mesnac.Log">
<HintPath>.\Mesnac.Log.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.135\lib\net462\Microsoft.Xaml.Behaviors.dll</HintPath>
</Reference>
<Reference Include="MySql.Data, Version=9.3.0.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
<HintPath>..\packages\MySql.Data.9.3.0\lib\net48\MySql.Data.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration.ConfigurationManager, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Configuration.ConfigurationManager.8.0.0\lib\net462\System.Configuration.ConfigurationManager.dll</HintPath>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Diagnostics.DiagnosticSource, Version=8.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.8.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
<Reference Include="System.IO.Pipelines, Version=5.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Pipelines.5.0.2\lib\net461\System.IO.Pipelines.dll</HintPath>
</Reference>
<Reference Include="System.Management" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Transactions" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="TouchSocket, Version=3.1.2.0, Culture=neutral, PublicKeyToken=5f39d7da98dac6a9, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.3.1.2\lib\net472\TouchSocket.dll</HintPath>
</Reference>
<Reference Include="TouchSocket.Core, Version=3.1.2.0, Culture=neutral, PublicKeyToken=d6c415a2f58eda72, processorArchitecture=MSIL">
<HintPath>..\packages\TouchSocket.Core.3.1.2\lib\net472\TouchSocket.Core.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="ZstdSharp, Version=0.8.5.0, Culture=neutral, PublicKeyToken=8d151af33a4ad5cf, processorArchitecture=MSIL">
<HintPath>..\packages\ZstdSharp.Port.0.8.5\lib\net462\ZstdSharp.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="BackUP\TCPWindowV2-BackUp.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="BackUP\ClientWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="BackUP\TCPWindowV2-BackUp.xaml.cs">
<DependentUpon>TCPWindowV2-BackUp.xaml</DependentUpon>
</Compile>
<Compile Include="BackUP\ClientWindow.xaml.cs">
<DependentUpon>ClientWindow.xaml</DependentUpon>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="TCPWindowV2.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="BackUP\TCPWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="BackUP\TouchSocketWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="BackUP\MultiClientsWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="MyTouchClass.cs" />
<Compile Include="PanelItem.cs" />
<Compile Include="TCPWindowV2.xaml.cs">
<DependentUpon>TCPWindowV2.xaml</DependentUpon>
</Compile>
<Compile Include="BackUP\TCPWindow.xaml.cs">
<DependentUpon>TCPWindow.xaml</DependentUpon>
</Compile>
<Compile Include="BackUP\TouchSocketWindow.xaml.cs">
<DependentUpon>TouchSocketWindow.xaml</DependentUpon>
</Compile>
<Compile Include="BackUP\MultiClientsWindow.xaml.cs">
<DependentUpon>MultiClientsWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\TouchSocket.Core.3.1.2\analyzers\dotnet\cs\TouchSocket.Core.SourceGenerator.dll" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.8">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.8 %28x86 和 x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Resource Include="Pictogrammers-Material-Monitor-eye.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="海威图标-横.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="全屏.png" />
<Resource Include="关闭.png" />
<Resource Include="减号.png" />
<Resource Include="取消全屏.png" />
<Resource Include="海威图标-竖.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="新增.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="FodyWeavers.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets" Condition="Exists('..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.ValueTuple.4.6.1\build\net471\System.ValueTuple.targets'))" />
<Error Condition="!Exists('..\packages\Fody.6.8.2\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.8.2\build\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.6.0.0\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.6.0.0\build\Costura.Fody.props'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.6.0.0\build\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.6.0.0\build\Costura.Fody.targets'))" />
</Target>
<Import Project="..\packages\Fody.6.8.2\build\Fody.targets" Condition="Exists('..\packages\Fody.6.8.2\build\Fody.targets')" />
<Import Project="..\packages\Costura.Fody.6.0.0\build\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.6.0.0\build\Costura.Fody.targets')" />
</Project>

@ -0,0 +1,548 @@
<Window x:Class="SocketExample.TCPWindowV2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:controls="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
xmlns:local="clr-namespace:SocketExample"
mc:Ignorable="d"
Title="RFID读写器多终端监控软件v1.11" Height="680" Width="1180"
Background="Transparent" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterScreen">
<Window.Resources>
<Style x:Key="SocketButton" TargetType="Button" BasedOn="{StaticResource BaseButtonStyle}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="ButtonBorder" CornerRadius="3">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#FF4A90E2" Offset="0"/>
<GradientStop Color="#FF1E62D0" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="ButtonBorder" Property="Background">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#FF5D9CEC" Offset="0"/>
<GradientStop Color="#FF2D76DB" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="ButtonBorder" Property="Background">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#FF3D7BC8" Offset="0"/>
<GradientStop Color="#FF0D4BB6" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Border CornerRadius="30" BorderThickness="2" BorderBrush="#ebedf3" Padding="10" MouseDown="Border_MouseDown" Background="#FFCFD5E5">
<Border CornerRadius="30">
<Border.Background>
<LinearGradientBrush>
<GradientStop Color="#fefefe" Offset="0"/>
<GradientStop Color="#ededef" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<Border CornerRadius="30">
<!--
<Border.Background>
<DrawingBrush Opacity="0.2" TileMode="Tile" Viewport="0,0,300,80" ViewportUnits="Absolute">
<DrawingBrush.Transform>
<RotateTransform Angle="-45" CenterX="0" CenterY="0"/>
</DrawingBrush.Transform>
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="Transparent">
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="30,70,300,300"/>
</GeometryDrawing.Geometry>
</GeometryDrawing>
<ImageDrawing ImageSource="/海威图标-横.png" Rect="5,5,100,100"/>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Border.Background>
-->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="90"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0" CornerRadius="20" Background="{StaticResource PrimaryBrush}" Margin="10">
<Grid>
<TextBlock Text="RFID设备监控平台" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" FontSize="38" FontWeight="SemiBold"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="400"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" >
<StackPanel x:Name="Welcome_StackPanel" Orientation="Horizontal" Visibility="Hidden">
<Button x:Name="CreateTerminal_Button" Height="40" Width="50" Margin="10 0 0 0" Style="{StaticResource FlatButton}" Click="CreateTerminal_Button_Click">
<Image Source="/新增.png"/>
</Button>
<Image Source="/海威图标-横.png" Margin="2 14 14 13"/>
</StackPanel>
<StackPanel x:Name="NewTerminal_StackPanel" Orientation="Horizontal" Margin="10 0 0 0" VerticalAlignment="Center">
<TextBlock Text="监控终端生成数量:" VerticalAlignment="Center" Margin="0,0,10,0" Foreground="White" FontSize="15" FontWeight="SemiBold"/>
<TextBox x:Name="CountTextBox" Width="50" Margin="0,0,10,0" VerticalAlignment="Center" FontSize="15" FontWeight="SemiBold"/>
<Button Content="生成" Click="GenerateButton_Click" Height="40" Width="50" Margin="10 0 0 0" Style="{StaticResource FlatButton}"/>
<Button Content="清空" Click="ClearButton_Click" Height="40" Width="50" Margin="10 0 0 0" Style="{StaticResource FlatButton}"/>
<Button x:Name="ListenButton" Content="侦听" Click="ListenButton_Click" Height="40" Width="50" Margin="10 0 0 0" Style="{StaticResource FlatButton}"/>
</StackPanel>
</Grid>
<Grid Grid.Column="1" HorizontalAlignment="Right" Margin="0 0 10 0" VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock x:Name="ClockText" Grid.Column="0" Margin="0 0 5 0"
Foreground="White"
FontSize="36"
FontWeight="Bold"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="Consolas"/>
<Button x:Name="Minimize_Button" Grid.Column="1" Height="40" Width="50" Style="{StaticResource FlatButton}" Margin="0 0 0 0" Click="Minimize_Button_Click">
<Image Source="/减号.png" />
</Button>
<Button x:Name="Maxmize_Button" Grid.Column="2" Height="40" Width="50" Style="{StaticResource FlatButton}" Margin="0 0 0 0" Click="Maxmize_Button_Click">
<Image x:Name="MaxMinImage" Source="/全屏.png"/>
</Button>
<Button x:Name="Shutdown_Button" Grid.Column="3" Height="40" Width="50" Style="{StaticResource FlatButton}" Click="Shutdown_Button_Click">
<Image Source="/关闭.png"/>
</Button>
</Grid>
</Grid>
</Grid>
</Border>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<ItemsControl x:Name="PanelContainer">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"></WrapPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Style="{StaticResource TerminalStyle}" Width="{Binding Borderwidth}">
<StackPanel Orientation="Vertical" Margin="5 5 5 5" >
<Border Width="Auto" Background="LightSkyBlue" CornerRadius="6" Padding="3">
<TextBox Width="Auto" Foreground="Black" Background="LightSkyBlue" Text="{Binding Text}" BorderThickness="0" FontSize="15" FontWeight="SemiBold"></TextBox>
</Border>
<StackPanel Orientation="Horizontal" Margin="5 1 5 1">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Label Content="IP地址" Height="30" Margin="10 8 0 0" FontWeight="SemiBold"/>
<TextBox TextWrapping="Wrap" x:Name="IPtextbox" Text="{Binding IPtext}" Width="100" Height="20" Margin="5 8 0 0" IsReadOnly="{Binding IPtext_ReadOnly}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="端口号" Height="30" Margin="10 8 0 0" FontWeight="SemiBold"/>
<TextBox TextWrapping="Wrap" Text="{Binding Porttext}" x:Name="Porttextbox" Width="45" Height="20" Margin="5 8 0 0" IsReadOnly="{Binding Porttext_ReadOnly}"/>
<!-- <Button Content="读取" Height="20" Width="40" Margin="10 8 0 0" Command="{Binding _readcomn}" Style="{StaticResource SocketButton}"/>-->
</StackPanel>
</StackPanel>
<Ellipse Width="20" Height="20" Fill="{Binding StateColour}" Margin="8 8 0 0"/>
<Label Height="30" Content="{Binding LinkState}" Margin="2 8 0 0"></Label>
<Button Content="{Binding LinkButtonText}" Height="30" Width="45" Margin="10 8 0 0" Command="{Binding _linkcomn}" Style="{StaticResource SocketButton}"/>
<Button Content="清空" Height="30" Width="45" Margin="10 8 0 0" Command="{Binding _clearcomn}" Style="{StaticResource SocketButton}"/>
<!--<Button Content="断开" Height="30" Margin="10 8 10 0" Command="{Binding _disconnectcomn}" Style="{StaticResource SocketButton}"/>-->
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,1,0,5" Height="100">
<Border Height="Auto" Width="200" BorderBrush="Black" BorderThickness="1" Margin="5,2,10,0" >
<ScrollViewer x:Name="TextScrollViewer" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
<TextBox x:Name="InfoTextBlock_Client" TextWrapping="Wrap" BorderThickness="0" IsReadOnly="True" Text="{Binding Infotext}" Height="Auto" Width="Auto">
<i:Interaction.Triggers>
<i:EventTrigger EventName="TextChanged">
<i:InvokeCommandAction
Command="{Binding TextChangedCommand}"
CommandParameter="{Binding ElementName=TextScrollViewer}"
/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
</ScrollViewer>
</Border>
<StackPanel Orientation="Vertical" Margin="0,2,0,0">
<TextBlock Text="请输入需要发送的内容:" FontWeight="SemiBold"></TextBlock>
<TextBox TextWrapping="Wrap" x:Name="MessageTextBox_Client" Text="{Binding MessageText}" Height="50" Width="140" Margin="0,0,0,1"/>
<Button Content="发送" Width="40" Height="22" Command="{Binding _sendcomn}" Style="{StaticResource SocketButton}"/>
</StackPanel>
</StackPanel>
<Border BorderBrush="Black" BorderThickness="0.5">
<ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Auto" Margin="0.5 0.1 0.5 0.1" Height="150" >
<StackPanel Orientation="Vertical" MaxWidth="800">
<ItemsControl ItemsSource="{Binding TagItems}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"></WrapPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderThickness="0.5" CornerRadius="10" BorderBrush="Black" Padding="2.5 3 2.5 3" Margin="0.5 1 0.5 1">
<!--<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden">-->
<Grid Margin="0.5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 3 0" HorizontalAlignment="Left">
<Label Content="标签:" FontWeight="Bold"/>
<TextBlock Text="{Binding EPCinfo}" FontSize="15" FontWeight="Bold" Foreground="{Binding InfoColor}" VerticalAlignment="Center" FontFamily="Tahoma"></TextBlock>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="0 0 3 0">
<Label Content="HEX:" FontWeight="Bold"/>
<TextBlock Text="{Binding EPCASC}" VerticalAlignment="Center" FontFamily="Tahoma"/>
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" Margin="0 0 3 0">
<Label Content="RSSI:" FontWeight="Bold"/>
<TextBlock Text="{Binding RSSIinfo}" VerticalAlignment="Center" FontFamily="Tahoma"/>
</StackPanel>
<StackPanel Grid.Column="3" Orientation="Horizontal" Margin="0 0 3 0">
<Label Margin="5 0 0 0" Content="Count:" FontWeight="Bold"/>
<TextBlock Text="{Binding Countinfo}" VerticalAlignment="Center" FontFamily="Tahoma"/>
</StackPanel>
<StackPanel Grid.Column="4" Orientation="Horizontal">
<Label Margin="5 0 0 0" Content="Time:" FontWeight="Bold"/>
<TextBlock Text="{Binding Timeinfo}" VerticalAlignment="Center" FontFamily="Tahoma"/>
</StackPanel>
</Grid>
<!--</ScrollViewer>-->
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</ScrollViewer>
</Border>
<!--触发动作部分-->
<Border BorderBrush="Black" BorderThickness="0.5">
<StackPanel Orientation="Horizontal" Margin="1 2 1 2">
<Label Content="触发动作:" FontWeight="Bold" FontSize="13"/>
<TextBox Text="{Binding ActionType}" Width="70" TextAlignment="Center" VerticalContentAlignment="Center" FontSize="13"/>
<ComboBox x:Name="TextComboBox" Width="20" Height="25" ItemsSource="{Binding SendTextComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding SendTextChangedCommand}"
CommandParameter="{Binding ElementName=TextComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
<Label Content="时间段:" FontWeight="Bold" FontSize="13"/>
<TextBox Text="{Binding TimeOut}" Width="50" TextAlignment="Center" VerticalContentAlignment="Center" FontSize="13"/>
<Button Content="发送" Width="50" Margin="15 2 0 2" Command="{Binding _sendactioncomn}" Style="{StaticResource SocketButton}"/>
</StackPanel>
</Border>
<!-- 功率部分,已备份,注释后不再生成该部分
<Border BorderBrush="Black" BorderThickness="0.5">
<Grid Margin="0 0 0 0">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border BorderBrush="Black" BorderThickness="0.5" Grid.Row="0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Content="功率状态" FontSize="14" FontWeight="Bold" FontStyle="Oblique" HorizontalAlignment="Center" Grid.Row="0"/>
<StackPanel Orientation="Horizontal" Margin="0 1 0 1" Grid.Row="1">
<Label Content="读:" FontSize="14"/>
<Label Content="端①:" FontSize="14"/>
<TextBox Text="{Binding Port1ReadText}" Width="20" Height="20" VerticalAlignment="Center" HorizontalContentAlignment="Center"/>
<ComboBox x:Name="Port1ReadComboBox" Width="20" Height="20" ItemsSource="{Binding PortComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding SelectionChangedCommand}"
CommandParameter="{Binding ElementName=Port1ReadComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
<Label Content="端②:" FontSize="14"/>
<TextBox Text="{Binding Port2ReadText}" Width="20" Height="20" VerticalAlignment="Center" HorizontalContentAlignment="Center"/>
<ComboBox x:Name="Port2ReadComboBox" Width="20" Height="20" ItemsSource="{Binding PortComboBox,Mode=TwoWay}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding SelectionChangedCommand}"
CommandParameter="{Binding ElementName=Port2ReadComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
<Label Content="端③:" FontSize="14"/>
<TextBox Text="{Binding Port3ReadText}" Width="20" Height="20" VerticalAlignment="Center" HorizontalContentAlignment="Center"/>
<ComboBox x:Name="Port3ReadComboBox" Width="20" Height="20" ItemsSource="{Binding PortComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding SelectionChangedCommand}"
CommandParameter="{Binding ElementName=Port3ReadComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
<Label Content="端④:" FontSize="14"/>
<TextBox Text="{Binding Port4ReadText}" Width="20" Height="20" VerticalAlignment="Center" HorizontalContentAlignment="Center"/>
<ComboBox x:Name="Port4ReadComboBox" Width="20" Height="20" ItemsSource="{Binding PortComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding SelectionChangedCommand}"
CommandParameter="{Binding ElementName=Port4ReadComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 1 0 1" Grid.Row="2">
<Label Content="写:" FontSize="14"/>
<Label Content="端①:" FontSize="14"/>
<TextBox Text="{Binding Port1WriteText}" Width="20" Height="20" VerticalAlignment="Center" HorizontalContentAlignment="Center"/>
<ComboBox x:Name="Port1WriteComboBox" Width="20" Height="20" ItemsSource="{Binding PortComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding SelectionChangedCommand}"
CommandParameter="{Binding ElementName=Port1WriteComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
<Label Content="端②:" FontSize="14"/>
<TextBox Text="{Binding Port2WriteText}" Width="20" Height="20" VerticalAlignment="Center" HorizontalContentAlignment="Center"/>
<ComboBox x:Name="Port2WriteComboBox" Width="20" Height="20" ItemsSource="{Binding PortComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding SelectionChangedCommand}"
CommandParameter="{Binding ElementName=Port2WriteComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
<Label Content="端③:" FontSize="14"/>
<TextBox Text="{Binding Port3WriteText}" Width="20" Height="20" VerticalAlignment="Center" HorizontalContentAlignment="Center"/>
<ComboBox x:Name="Port3WriteComboBox" Width="20" Height="20" ItemsSource="{Binding PortComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding SelectionChangedCommand}"
CommandParameter="{Binding ElementName=Port3WriteComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
<Label Content="端④:" FontSize="14"/>
<TextBox Text="{Binding Port4WriteText}" Width="20" Height="20" VerticalAlignment="Center" HorizontalContentAlignment="Center"/>
<ComboBox x:Name="Port4WriteComboBox" Width="20" Height="20" ItemsSource="{Binding PortComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding SelectionChangedCommand}"
CommandParameter="{Binding ElementName=Port4WriteComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 1 0 3" Grid.Row="3">
<Button Content="设置功率" Command="{Binding _setpowercomn}" Width="50" Height="25" Margin="100 0 0 0" Style="{StaticResource SocketButton}" />
<Button Content="获取功率" Command="{Binding _getpowercomn}" Width="50" Height="25" Margin="60 0 0 0" Style="{StaticResource SocketButton}" />
</StackPanel>
</Grid>
</Border>
</Grid>
</Border>
-->
<!--gpio部分-->
<Border BorderBrush="Black" BorderThickness="0.5">
<Grid Margin="0 0 0 2">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" HorizontalAlignment="Center" Content="GPIO状态" FontSize="14" FontWeight="Bold" FontStyle="Oblique"></Label>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal">
<Label Content="GPO1" HorizontalAlignment="Left"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPO1}"></Label>
</Border>
<ComboBox x:Name="GPO1ComboBox" Width="20" Height="25" ItemsSource="{Binding GPOComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding GPOSelectionChangedCommand}"
CommandParameter="{Binding ElementName=GPO1ComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<Label Content="GPO2" HorizontalAlignment="Left"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPO2}"></Label>
</Border>
<ComboBox x:Name="GPO2ComboBox" Width="20" Height="25" ItemsSource="{Binding GPOComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding GPOSelectionChangedCommand}"
CommandParameter="{Binding ElementName=GPO2ComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<Label Content="GPO3" HorizontalAlignment="Left"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPO3}"></Label>
</Border>
<ComboBox x:Name="GPO3ComboBox" Width="20" Height="25" ItemsSource="{Binding GPOComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding GPOSelectionChangedCommand}"
CommandParameter="{Binding ElementName=GPO3ComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</StackPanel>
<StackPanel Grid.Column="3" Orientation="Horizontal">
<Label Content="GPO4" HorizontalAlignment="Left"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPO4}"></Label>
</Border>
<ComboBox x:Name="GPO4ComboBox" Width="20" Height="25" ItemsSource="{Binding GPOComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding GPOSelectionChangedCommand}"
CommandParameter="{Binding ElementName=GPO4ComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Margin="0 0 0 5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal">
<Label Content="GPI1" HorizontalAlignment="Left" Margin="0 0 6 0"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPI1}" >
<!-- 标签修改事件
<i:Interaction.Triggers>
<i:EventTrigger EventName="">
</i:EventTrigger>
</i:Interaction.Triggers>
-->
</Label>
</Border>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<Label Content="GPI2" HorizontalAlignment="Left" Margin="0 0 6 0"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPI2}"></Label>
</Border>
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<Label Content="GPI3" HorizontalAlignment="Left" Margin="0 0 6 0"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPI3}"></Label>
</Border>
</StackPanel>
<StackPanel Grid.Column="3" Orientation="Horizontal">
<Label Content="GPI4" HorizontalAlignment="Left" Margin="0 0 6 0"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPI4}"></Label>
</Border>
</StackPanel>
</Grid>
</Grid>
</Border>
<Border BorderBrush="Black" BorderThickness="0.5">
<Grid Margin="0 0 0 2">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="版本信息" HorizontalAlignment="Center" FontSize="14" FontWeight="Bold" FontStyle="Oblique"/>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="模块型号:" HorizontalAlignment="Left" FontSize="13" FontWeight="Bold"/>
<Label Grid.Column="1" Content="{Binding moduleInfo}" VerticalContentAlignment="Center"></Label>
<Label Grid.Column="2" Content="主板固件号:" HorizontalAlignment="Left" FontSize="13" FontWeight="Bold"/>
<Label Grid.Column="3" Content="{Binding motherboardFirmware}" VerticalContentAlignment="Center"></Label>
</Grid>
</Grid>
</Border>
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Border>
</Border>
</Border>
</Window>

@ -0,0 +1,577 @@
using System;
using System.Buffers.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.Eventing.Reader;
using System.IO;
using System.IO.Ports;
using System.Linq;
using System.Net.NetworkInformation;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Messaging;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
using System.Xml;
using Google.Protobuf.WellKnownTypes;
using K4os.Compression.LZ4.Streams.Abstractions;
using Mesnac.Log;
using Microsoft.Xaml.Behaviors.Core;
using Mysqlx.Crud;
using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.Utilities.Encoders;
using TouchSocket.Core;
using TouchSocket.Sockets;
using ZstdSharp.Unsafe;
using static SocketExample.MyTouchClass;
namespace SocketExample
{
/// <summary>
/// MultiClientsWindow.xaml 的交互逻辑
/// </summary>
public partial class TCPWindowV2 : Window
{
public sealed class MySessionClient : TcpSessionClient
{
public Action<ReceivedDataEventArgs> OnMessageReceived { get; set; }
protected override async Task OnTcpReceived(ReceivedDataEventArgs e)
{
//此处逻辑单线程处理。
//此处处理数据功能相当于Received委托
OnMessageReceived?.Invoke(e);
await base.OnTcpReceived(e);
}
}
#region 主界面参数
int currentcount = 0;//目前客户端的数量
List<PanelItem> items = new List<PanelItem>();//客户端组件列表
public static double? WindowLeft { get; set; }
public static double? WindowTop { get; set; }
public static double? WindowWidth { get; set; }
public static double? WindowHeight { get; set; }
public static WindowState? OriginWindowState { get; set; }
public static int? Buttonflag { get; set; }
private DispatcherTimer _timer;
public TCPWindowV2()
{
InitializeComponent();
EnsureFolderExists("日志文件夹");
InitializeTimer();
this.Closing += TCPWindowV2_Closing;
PanelContainer.ItemsSource = items;
SaveWindowSettings();
Buttonflag = 0;
}
#endregion
//结束所有线程,防止心跳线程冗余
private void TCPWindowV2_Closing(object sender, CancelEventArgs e)
{
System.Environment.Exit(0);
}
#region 主界面按钮事件
private void GenerateButton_Click(object sender, RoutedEventArgs e)//添加客户端框体
{
if (int.TryParse(CountTextBox.Text, out int count) && count > 0)
{
//var items = new List<PanelItem>();
for (int i = 0; i < count; i++)
{
items.Add(new PanelItem(i + currentcount));
}
currentcount += count;
PanelContainer.ItemsSource = null;//刷新
PanelContainer.ItemsSource = items;
}
else
{
MessageBox.Show("请输入有效的正整数", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
Welcome_StackPanel.Visibility = Visibility.Visible;
NewTerminal_StackPanel.Visibility = Visibility.Collapsed;
}
private void Shutdown_Button_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
private void CreateTerminal_Button_Click(object sender, RoutedEventArgs e)
{
Welcome_StackPanel.Visibility = Visibility.Collapsed;
NewTerminal_StackPanel.Visibility = Visibility.Visible;
}
private void Maxmize_Button_Click(object sender, RoutedEventArgs e)
{
if (Buttonflag == 0)
{
this.WindowState = WindowState.Maximized;
MaxMinImage.Source = new BitmapImage(new Uri(@"/取消全屏.png", UriKind.Relative));
Buttonflag = 1;
}
else
{
LoadWindowSettings();
MaxMinImage.Source = new BitmapImage(new Uri(@"/全屏.png", UriKind.Relative));
Buttonflag = 0;
}
}
private void Minimize_Button_Click(object sender, RoutedEventArgs e)
{
this.WindowState = WindowState.Minimized;
}
private void ClearButton_Click(object sender, RoutedEventArgs e)//清空客户端
{
foreach (PanelItem item in items)
{
item.dispose();
item.Sessiondispose();
}
items = new List<PanelItem>();
PanelContainer.ItemsSource = null;
currentcount = 0;
}
private void ListenButton_Click(object sender, RoutedEventArgs e)
{
Thread ListeningPortThread = new Thread(ListeningTheard);
ListeningPortThread.IsBackground = true;
ListeningPortThread.Start();
Welcome_StackPanel.Visibility = Visibility.Visible;
NewTerminal_StackPanel.Visibility = Visibility.Collapsed;
}
#endregion
#region 其他功能
private void ListeningTheard() //监听线程
{
IEnumerable<NetworkInterface> networkInterfaces = NetworkInterface.GetAllNetworkInterfaces()
.Where(nic => nic.NetworkInterfaceType == NetworkInterfaceType.Ethernet // 仅以太网
&& nic.OperationalStatus == OperationalStatus.Up); // 仅已启用的接口
CreateListenConnect(networkInterfaces);
while (true)
{
IEnumerable<NetworkInterface> NewnetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces()
.Where(nic => nic.NetworkInterfaceType == NetworkInterfaceType.Ethernet // 仅以太网
&& nic.OperationalStatus == OperationalStatus.Up); // 仅已启用的接口
var UniquenetworkInterfaces = NewnetworkInterfaces
.Where(newNic => !networkInterfaces.Any(oldNic => oldNic.Id == newNic.Id))
.ToList();
if (!UniquenetworkInterfaces.Any())
{
Thread.Sleep(1000);
continue;
}
networkInterfaces = NewnetworkInterfaces;
CreateListenConnect(UniquenetworkInterfaces);
}
}
private void CreateListenConnect(IEnumerable<NetworkInterface> networkInterfaces) //创建连接
{
foreach (var nic in networkInterfaces)
{
var ipProperties = nic.GetIPProperties();
var unicastAddresses = ipProperties.UnicastAddresses
.Where(addr => addr.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork);
foreach (var addr in unicastAddresses)
{
var tcpService = new MyService();
tcpService.SetupAsync(new TouchSocketConfig()//载入配置
.SetListenIPHosts($"tcp://{addr.Address}:20108", 7790)//可以同时监听两个地址
.ConfigureContainer(a =>//容器的配置顺序应该在最前面
{
a.AddConsoleLogger();//添加一个控制台日志注入注意在maui中控制台日志不可用
})
.ConfigurePlugins(a =>
{
//a.Add();//此处可以添加插件
}));
tcpService.Connected += ListeningConnected;
tcpService.Closed += ListeningClosed;
tcpService.StartAsync();
Console.WriteLine($"网卡: {nic.Description}, IP: {addr.Address}");
MessageBox.Show($"{addr.Address}监听成功!");
}
}
}
private Task ListeningConnected(MySessionClient client, ConnectedEventArgs e) //连接事件
{
Application.Current.Dispatcher.Invoke(() =>
{
items.Add(new PanelItem(client));
PanelContainer.ItemsSource = null;
PanelContainer.ItemsSource = items;
});
return EasyTask.CompletedTask;
}
private Task ListeningClosed(MySessionClient client, ClosedEventArgs e) //断开事件
{
try {
Application.Current.Dispatcher.Invoke(() =>
{
foreach (PanelItem item in items)
{
if (item.SessionID.Equals(client.Id))
{
try
{
item.Sessiondispose();
items.Remove(item);
PanelContainer.ItemsSource = null;
PanelContainer.ItemsSource = items;
if (items.Count == 0)
break;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
});
}catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
return EasyTask.CompletedTask;
}
public class LinkCommand : ICommand //command方法实现
{
private Action _excute;
private Action<int> _excutewithindex;
public LinkCommand(Action action)
{
_excute = action;
}
public LinkCommand(Action<int> action)
{
_excutewithindex = action;
}
public event EventHandler CanExecuteChanged;
public bool CanExecute(object parameter)
{
return true;
}
public void Execute(object parameter)
{
_excute();
}
}
private static List<TagInfo> GetTagInfos(byte[] AutoDealReportData)
{
List<TagInfo> tagInfoList = new List<TagInfo>();
try
{
int iFirstCountPos = 6; //第一次读取标签次数位置
int iFirstRSSIPos = 7; //第一次读取标签强度位置
int iFirstAnt = 8;
int iFirstPC = 9; //第一次读取标签天线位置
int iFirstLeftBarcketPos = 11;//EPC数据起始位置
UInt16 tempDataCount = 0;
int tempDataRSSI = 0;
UInt16 tempDataANT = 0;
int iBarcodeGroupCount = Convert.ToInt32(AutoDealReportData[5].ToString()); //标签组数
int iBarcodeLength = 16; //标签长度
int iCommonSecondFlag = 0;
int dataLength = Convert.ToInt32(AutoDealReportData[2].ToString());
for (int j = 0; j < iBarcodeGroupCount; j++)
{
TagInfo tag = new TagInfo();
byte[] tempPCByte = new byte[2]; //取出PC
Array.Clear(tempPCByte, 0, 2);
Array.Copy(AutoDealReportData, iFirstPC, tempPCByte, 0, 2);
//PC转二进制取前五位转十进制
int epcLength = Convert.ToInt32(Convert.ToString(Convert.ToInt64(tempPCByte[0].ToString("X"), 16), 2).PadLeft(8, '0').Substring(0, 5), 2) * 2;
iBarcodeLength = epcLength;
byte[] tempDataByte = new byte[epcLength];
Array.Clear(tempDataByte, 0, iBarcodeLength);
Array.Copy(AutoDealReportData, iFirstLeftBarcketPos, tempDataByte, 0, iBarcodeLength);
byte[] tempCountByte = new byte[1]; //取出标签次数
Array.Clear(tempCountByte, 0, 1);
Array.Copy(AutoDealReportData, iFirstCountPos, tempCountByte, 0, 1);
tempDataCount = tempCountByte[0];
byte[] tempRSSIByte = new byte[1]; //取出标签强度
Array.Clear(tempRSSIByte, 0, 1);
Array.Copy(AutoDealReportData, iFirstRSSIPos, tempRSSIByte, 0, 1);
tempDataRSSI = HexStringToNegative(bytesToHexStr(tempRSSIByte, 1));
#region add by wenjy 20220829 取出天线号
byte[] tempAntByte = new byte[1]; //取出天线号
Array.Clear(tempAntByte, 0, 1);
Array.Copy(AutoDealReportData, iFirstAnt, tempAntByte, 0, 1);
tempDataANT = tempAntByte[0];
#endregion
tag.Count = tempDataCount;
tag.RSSI = tempDataRSSI;
tag.EPC = tempDataByte;
tag.EPCstring = System.Text.Encoding.ASCII.GetString(tempDataByte);
tag.PC = tempPCByte;
tag.Antana = tempDataANT;
tagInfoList.Add(tag);
int iBarcodeListLen = tagInfoList.Count; //特别注意,必须这样,要不然会多一条数据
iFirstCountPos = iFirstCountPos + iBarcodeLength + 5; //次数
iFirstRSSIPos = iFirstCountPos + 1; //强度
iFirstAnt = iFirstRSSIPos + 1; //天线
iFirstPC = iFirstAnt + 1;
iFirstLeftBarcketPos = iFirstLeftBarcketPos + iBarcodeLength + 5;
iCommonSecondFlag++;
if (iCommonSecondFlag == iBarcodeGroupCount)
{
//mutauto.ReleaseMutex();
return tagInfoList;
}
}
}
catch (Exception ex)
{
//LogInfo.Info("----函数调用:Device_AutoDealContent 自动处理函数异常:" + ex.ToString());
//mutauto.ReleaseMutex();
}
return tagInfoList;
}
public static int HexStringToNegative(string strNumber)
{
int iNegate = 0;
int iNumber = Convert.ToInt32(strNumber, 16);
if (iNumber > 127)
{
int iComplement = iNumber - 1;
string strNegate = string.Empty;
char[] binchar = Convert.ToString(iComplement, 2).PadLeft(8, '0').ToArray();
foreach (char ch in binchar)
{
if (Convert.ToInt32(ch) == 48)
{
strNegate += "1";
}
else
{
strNegate += "0";
}
}
iNegate = -Convert.ToInt32(strNegate, 2);
}
return iNegate;
}
public class TagInfo
{
public byte[] PC = new byte[2];
public int Count;
public int RSSI;
public int Antana;
public byte[] EPC;
public byte[] Data;
public string PCstring = null;
public string EPCstring = null;
public DateTime Time;
}
/// <summary>
/// 将byte数组转换成十六进制字符串 //e.g. { 0x01, 0x01} ---> " 01 01"
/// </summary>
/// <param name="bytes">byte数组</param>
/// <param name="iLen">数组长度</param>
/// <returns>十六进制字符串</returns>
public static string bytesToHexStr(byte[] bytes, int iLen)
{
string returnStr = "";
if (bytes != null)
{
for (int i = 0; i < iLen; i++)
{
returnStr += bytes[i].ToString("X2");
}
}
return returnStr;
}
private static void EnsureFolderExists(string folderPath)
{
// 检查指定的文件夹路径对应的文件夹是否已经存在
if (!Directory.Exists(folderPath))
{
try
{
// 如果文件夹不存在,则尝试创建该文件夹
Directory.CreateDirectory(folderPath);
}
catch (IOException ex)
{
// 如果在创建文件夹过程中出现IOException异常比如权限不足、磁盘已满等原因导致无法创建文件夹
// 这里通过消息框向用户展示创建文件夹失败的异常信息,方便用户知晓问题所在
MessageBox.Show($"创建文件夹 {folderPath} 失败,异常信息: {ex.Message}");
// 重新抛出异常,让调用这个方法的上层代码知道创建文件夹出现了问题,以便进行进一步的处理,比如终止程序或者尝试其他恢复操作
throw;
}
}
}
private static void EnsureTxtExists(string txtPath, string MachineName, string IPinfo, string Portinfo)
{
// 检查指定的txt路径对应的txt是否已经存在
if (!File.Exists(txtPath))
{
try
{
StreamWriter streamWriter = new StreamWriter(txtPath, true);
streamWriter.WriteLineAsync($"设备名称:{MachineName}\nIP地址:{IPinfo}\n端口号:{Portinfo}\n____________________________");
streamWriter.Close();
}
catch (IOException ex)
{
// 如果在创建文件夹过程中出现IOException异常比如权限不足、磁盘已满等原因导致无法创建文件夹
// 这里通过消息框向用户展示创建文件夹失败的异常信息,方便用户知晓问题所在
MessageBox.Show($"创建txt {txtPath} 失败,异常信息: {ex.Message}");
// 重新抛出异常,让调用这个方法的上层代码知道创建文件夹出现了问题,以便进行进一步的处理,比如终止程序或者尝试其他恢复操作
throw;
}
}
}
private void Border_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
{
this.DragMove();
}
}
private void LoadWindowSettings()
{
if (WindowLeft.HasValue && WindowTop.HasValue)
{
this.Left = WindowLeft.Value;
this.Top = WindowTop.Value;
}
if (WindowWidth.HasValue && WindowHeight.HasValue)
{
this.Width = WindowWidth.Value;
this.Height = WindowHeight.Value;
}
if (OriginWindowState.HasValue)
{
this.WindowState = OriginWindowState.Value;
}
}
private void SaveWindowSettings()
{
WindowLeft = this.Left;
WindowTop = this.Top;
WindowWidth = this.Width;
WindowHeight = this.Height;
OriginWindowState = this.WindowState;
}
private void InitializeTimer()
{
_timer = new DispatcherTimer();
_timer.Interval = TimeSpan.FromSeconds(1); // 每秒更新一次
_timer.Tick += Timer_Tick;
_timer.Start();
// 立即显示时间
UpdateClock();
}
private void Timer_Tick(object sender, EventArgs e)
{
UpdateClock();
}
private void UpdateClock()
{
DateTime now = DateTime.Now;
ClockText.Text = now.ToString("HH:mm:ss");
}
#endregion
public class MyService : TcpService<MySessionClient>
{
protected override void LoadConfig(TouchSocketConfig config)
{
//此处加载配置,用户可以从配置中获取配置项。
base.LoadConfig(config);
}
protected override MySessionClient NewClient()
{
return new MySessionClient();
}
protected override async Task OnTcpConnecting(MySessionClient socketClient, ConnectingEventArgs e)
{
//此处逻辑会多线程处理。
//e.Id:对新连接的客户端进行ID初始化默认情况下是按照设定的规则随机分配的。
//但是按照需求您可以自定义设置例如设置为其IP地址。但是需要注意的是id必须在生命周期内唯一。
//e.IsPermitOperation:指示是否允许该客户端链接。
await base.OnTcpConnecting(socketClient, e);
}
}
}
}

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BouncyCastle.Cryptography" version="2.5.1" targetFramework="net48" />
<package id="CommonServiceLocator" version="2.0.2" targetFramework="net48" />
<package id="Costura.Fody" version="6.0.0" targetFramework="net48" developmentDependency="true" />
<package id="Fody" version="6.8.2" targetFramework="net48" developmentDependency="true" />
<package id="Google.Protobuf" version="3.30.0" targetFramework="net48" />
<package id="K4os.Compression.LZ4" version="1.3.8" targetFramework="net48" />
<package id="K4os.Compression.LZ4.Streams" version="1.3.8" targetFramework="net48" />
<package id="K4os.Hash.xxHash" version="1.0.8" targetFramework="net48" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="5.0.0" targetFramework="net48" />
<package id="Microsoft.Xaml.Behaviors.Wpf" version="1.1.135" targetFramework="net48" />
<package id="MvvmLightLibs" version="5.4.1.1" targetFramework="net48" />
<package id="MySql.Data" version="9.3.0" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Configuration.ConfigurationManager" version="8.0.0" targetFramework="net48" />
<package id="System.Diagnostics.DiagnosticSource" version="8.0.1" targetFramework="net48" />
<package id="System.IO.Pipelines" version="5.0.2" targetFramework="net48" />
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
<package id="System.ValueTuple" version="4.6.1" targetFramework="net48" />
<package id="TouchSocket" version="3.1.2" targetFramework="net48" />
<package id="TouchSocket.Core" version="3.1.2" targetFramework="net48" />
<package id="ZstdSharp.Port" version="0.8.5" targetFramework="net48" />
</packages>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Loading…
Cancel
Save