1.调整标签显示

master
zhangxy 4 days ago
parent 865fb34ba5
commit 72cad5efd3

@ -8,7 +8,7 @@
xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
xmlns:local="clr-namespace:SocketExample" xmlns:local="clr-namespace:SocketExample"
mc:Ignorable="d" mc:Ignorable="d"
Title="RFID读写器多终端监控软件v1.091" Height="680" Width="1180" Title="RFID读写器多终端监控软件v1.093" Height="680" Width="1180"
Background="Transparent" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterScreen"> Background="Transparent" AllowsTransparency="True" WindowStyle="None" WindowStartupLocation="CenterScreen">
<Window.Resources> <Window.Resources>
@ -187,7 +187,8 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<Border BorderBrush="Black" BorderThickness="0.5"> <Border BorderBrush="Black" BorderThickness="0.5">
<ScrollViewer VerticalScrollBarVisibility="Visible" Margin="0.5 0.1 0.5 0.1" Height="150"> <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 ItemsSource="{Binding TagItems}">
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
@ -197,28 +198,28 @@
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate> <DataTemplate>
<Border BorderThickness="0.5" CornerRadius="10" BorderBrush="Black" Padding="2.5 3 2.5 3" Margin="0.5 1 0.5 1"> <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"> <!--<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden">-->
<Grid Margin="0.5"> <Grid Margin="0.5">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 5 0"> <StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 3 0" HorizontalAlignment="Left">
<Label Content="标签:" FontWeight="Bold"/> <Label Content="标签:" FontWeight="Bold"/>
<TextBlock Text="{Binding EPCinfo}" FontSize="15" FontWeight="Bold" Foreground="{Binding InfoColor}" VerticalAlignment="Center" FontFamily="Tahoma"></TextBlock> <TextBlock Text="{Binding EPCinfo}" FontSize="15" FontWeight="Bold" Foreground="{Binding InfoColor}" VerticalAlignment="Center" FontFamily="Tahoma"></TextBlock>
</StackPanel> </StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="0 0 5 0"> <StackPanel Grid.Column="1" Orientation="Horizontal" Margin="0 0 3 0">
<Label Content="HEX:" FontWeight="Bold"/> <Label Content="HEX:" FontWeight="Bold"/>
<TextBlock Text="{Binding EPCASC}" VerticalAlignment="Center" FontFamily="Tahoma"/> <TextBlock Text="{Binding EPCASC}" VerticalAlignment="Center" FontFamily="Tahoma"/>
</StackPanel> </StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" Margin="0 0 5 0"> <StackPanel Grid.Column="2" Orientation="Horizontal" Margin="0 0 3 0">
<Label Content="RSSI:" FontWeight="Bold"/> <Label Content="RSSI:" FontWeight="Bold"/>
<TextBlock Text="{Binding RSSIinfo}" VerticalAlignment="Center" FontFamily="Tahoma"/> <TextBlock Text="{Binding RSSIinfo}" VerticalAlignment="Center" FontFamily="Tahoma"/>
</StackPanel> </StackPanel>
<StackPanel Grid.Column="3" Orientation="Horizontal" Margin="0 0 5 0"> <StackPanel Grid.Column="3" Orientation="Horizontal" Margin="0 0 3 0">
<Label Margin="5 0 0 0" Content="Count:" FontWeight="Bold"/> <Label Margin="5 0 0 0" Content="Count:" FontWeight="Bold"/>
<TextBlock Text="{Binding Countinfo}" VerticalAlignment="Center" FontFamily="Tahoma"/> <TextBlock Text="{Binding Countinfo}" VerticalAlignment="Center" FontFamily="Tahoma"/>
</StackPanel> </StackPanel>
@ -227,11 +228,12 @@
<TextBlock Text="{Binding Timeinfo}" VerticalAlignment="Center" FontFamily="Tahoma"/> <TextBlock Text="{Binding Timeinfo}" VerticalAlignment="Center" FontFamily="Tahoma"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</ScrollViewer> <!--</ScrollViewer>-->
</Border> </Border>
</DataTemplate> </DataTemplate>
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
</ItemsControl> </ItemsControl>
</StackPanel>
</ScrollViewer> </ScrollViewer>
</Border> </Border>

@ -30,6 +30,7 @@ using K4os.Compression.LZ4.Streams.Abstractions;
using Mesnac.Log; using Mesnac.Log;
using Microsoft.Xaml.Behaviors.Core; using Microsoft.Xaml.Behaviors.Core;
using Mysqlx.Crud; using Mysqlx.Crud;
using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.Utilities.Encoders; using Org.BouncyCastle.Utilities.Encoders;
using TouchSocket.Core; using TouchSocket.Core;
using TouchSocket.Sockets; using TouchSocket.Sockets;
@ -276,7 +277,7 @@ namespace SocketExample
string commandState = readStateString.Substring(6, 2);//获取命令 string commandState = readStateString.Substring(6, 2);//获取命令
if (commandState != "81") if (commandState != "81")
Infotext += $"({currentTime})客户端接收到信息:\n{hexString}\n"; Infotext += $"\n({currentTime})客户端接收到信息:\n{hexString}\n";
int i = Convert.ToInt32(dataLength, 16); int i = Convert.ToInt32(dataLength, 16);
if (i != 0) if (i != 0)
@ -291,9 +292,6 @@ namespace SocketExample
Array.Copy(data, 5, newData, 5, 4); Array.Copy(data, 5, newData, 5, 4);
Array.Copy(data, 5, newData, 6, data.Length - 5); Array.Copy(data, 5, newData, 6, data.Length - 5);
Timeinfo = $"{time}";//获取时间 Timeinfo = $"{time}";//获取时间
string NewDataString = BitConverter.ToString(newData).Replace("-", " ");
int startTemp = 33;
//Infotext += $"({currentTime})客户端接收到EPC信息\n{EPCASC}\n\n"; //Infotext += $"({currentTime})客户端接收到EPC信息\n{EPCASC}\n\n";
@ -301,13 +299,11 @@ namespace SocketExample
ObservableCollection<TagItem> items = new ObservableCollection<TagItem>(); ObservableCollection<TagItem> items = new ObservableCollection<TagItem>();
for (int j = 0; j < taglist.Count; j++) for (int j = 0; j < taglist.Count; j++)
{ {
int TempLength = taglist[j].EPCstring.Length * 3 - 1; EPCinfo = BitConverter.ToString(taglist[j].EPC).Replace("-", "");
EPCinfo = NewDataString.Substring(startTemp, TempLength);
items.Add(new TagItem(hexString, taglist[j].EPCstring, EPCinfo, taglist[j].RSSI.ToString(), taglist[j].Count.ToString(), Timeinfo)); items.Add(new TagItem(hexString, taglist[j].EPCstring, EPCinfo, taglist[j].RSSI.ToString(), taglist[j].Count.ToString(), Timeinfo));
startTemp += 16 + TempLength;
string year = DateTime.Now.ToString("yyyy-MM-dd"); string year = DateTime.Now.ToString("yyyy-MM-dd");
EnsureFolderExists($"日志文件夹/{year}/{Text}"); EnsureFolderExists($"日志文件夹/{year}/{Text}");
path = $"日志文件夹/{year}/{Text}/" + Text + "(" + IPtext + ")" + ".txt"; path = $"日志文件夹/{year}/{Text}/" + Text + "标签(" + IPtext + ")" + ".txt";
EnsureTxtExists(path, Text, IPtext, Porttext); EnsureTxtExists(path, Text, IPtext, Porttext);
writeToTxt(path, $"接收消息:{hexString}\nEPC:{taglist[j].EPCstring}\nHEX:{EPCinfo}\nRSSI:{taglist[j].RSSI.ToString()} Count:{taglist[j].Count.ToString()} Time:{Timeinfo}\n____________________________"); writeToTxt(path, $"接收消息:{hexString}\nEPC:{taglist[j].EPCstring}\nHEX:{EPCinfo}\nRSSI:{taglist[j].RSSI.ToString()} Count:{taglist[j].Count.ToString()} Time:{Timeinfo}\n____________________________");
path = ""; path = "";
@ -328,22 +324,17 @@ namespace SocketExample
try try
{ {
Timeinfo = $"{time}";//获取时间 Timeinfo = $"{time}";//获取时间
int startTemp = 33;
//Infotext += $"({currentTime})客户端接收到EPC信息\n{EPCASC}\n\n"; //Infotext += $"({currentTime})客户端接收到EPC信息\n{EPCASC}\n\n";
List<TagInfo> taglist = GetTagInfos(data); List<TagInfo> taglist = GetTagInfos(data);
ObservableCollection<TagItem> items = new ObservableCollection<TagItem>(); ObservableCollection<TagItem> items = new ObservableCollection<TagItem>();
for (int j = 0; j < taglist.Count; j++) for (int j = 0; j < taglist.Count; j++)
{ {
int TempLength = taglist[j].EPCstring.Length * 3 - 1; EPCinfo = BitConverter.ToString(taglist[j].EPC).Replace("-", "");
EPCinfo = hexString.Substring(startTemp, TempLength);
items.Add(new TagItem(hexString, taglist[j].EPCstring, EPCinfo, taglist[j].RSSI.ToString(), taglist[j].Count.ToString(), Timeinfo)); items.Add(new TagItem(hexString, taglist[j].EPCstring, EPCinfo, taglist[j].RSSI.ToString(), taglist[j].Count.ToString(), Timeinfo));
startTemp += 16 + TempLength;
string year = DateTime.Now.ToString("yyyy-MM-dd"); string year = DateTime.Now.ToString("yyyy-MM-dd");
EnsureFolderExists($"日志文件夹/{year}/{Text}"); EnsureFolderExists($"日志文件夹/{year}/{Text}");
path = $"日志文件夹/{year}/{Text}/" + Text + "(" + IPtext + ")" + ".txt"; path = $"日志文件夹/{year}/{Text}/" + Text + "标签(" + IPtext + ")" + ".txt";
EnsureTxtExists(path, Text, IPtext, Porttext); EnsureTxtExists(path, Text, IPtext, Porttext);
writeToTxt(path, $"接收消息:{hexString}\nEPC:{taglist[j].EPCstring}\nHEX:{EPCinfo}\nRSSI:{taglist[j].RSSI.ToString()} Count:{taglist[j].Count.ToString()} Time:{Timeinfo}\n____________________________"); writeToTxt(path, $"接收消息:{hexString}\nEPC:{taglist[j].EPCstring}\nHEX:{EPCinfo}\nRSSI:{taglist[j].RSSI.ToString()} Count:{taglist[j].Count.ToString()} Time:{Timeinfo}\n____________________________");
path = ""; path = "";
@ -570,7 +561,7 @@ namespace SocketExample
TagItems = items; TagItems = items;
string year = DateTime.Now.ToString("yyyy-MM-dd"); string year = DateTime.Now.ToString("yyyy-MM-dd");
EnsureFolderExists($"日志文件夹/{year}/{Text}"); EnsureFolderExists($"日志文件夹/{year}/{Text}");
path = $"日志文件夹/{year}/{Text}/" + Text + "(" + IPtext + ")" + ".txt"; path = $"日志文件夹/{year}/{Text}/" + Text + "标签(" + IPtext + ")" + ".txt";
EnsureTxtExists(path, Text, IPtext, Porttext); EnsureTxtExists(path, Text, IPtext, Porttext);
writeToTxt(path, $"接收消息:{hexString}\nEPC:{EPCASC}\nHEX:{EPCinfo}\nRSSI:{RSSIinfo} Count:{Countinfo} Time:{Timeinfo}\n____________________________"); writeToTxt(path, $"接收消息:{hexString}\nEPC:{EPCASC}\nHEX:{EPCinfo}\nRSSI:{RSSIinfo} Count:{Countinfo} Time:{Timeinfo}\n____________________________");
path = ""; path = "";

Loading…
Cancel
Save