alielie
2026-04-23 ef52fd6fd07508883dce4eb002acda59f0169e59
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<UserControl x:Class="Plugin.UICollection.TcpDebugger"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:Plugin.UICollection"
             mc:Ignorable="d" 
             xmlns:pu="https://opensource.panuon.com/wpf-ui"
             xmlns:dp="clr-namespace:UILib.DpUtil;assembly=UILib"
             xmlns:uic="clr-namespace:UILib.Converter;assembly=UILib"
             FontSize="16"
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <ResourceDictionary>
            <!--<ResourceDictionary.MergedDictionaries>
                <pu:StyleDictionary Excludes="Button" />
            </ResourceDictionary.MergedDictionaries>-->
            <Style TargetType="ComboBox"/>
            <Style TargetType="ComboBoxItem"/>
            <Style TargetType="Button">
                
            </Style>
            <Style TargetType="GroupBox">
 
            </Style>
            <Style TargetType="TextBox">
                <Setter Property="VerticalContentAlignment" Value="Center"/>
                <Setter Property="MinWidth" Value="120"/>
                <Setter Property="Height" Value="Auto"/>
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>
 
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <StackPanel dp:StackPanelHelper.ChildSpace="10" Margin="0,10,0,10">
            <pu:FormGroup Header="IP" GroupName="client">
                <TextBox Text="{Binding Ip}"/>
            </pu:FormGroup>
 
            <pu:FormGroup Header="Port" GroupName="client">
                <TextBox Text="{Binding Port}"/>
            </pu:FormGroup>
 
            <pu:FormGroup Header="客户端端口" GroupName="client">
                <TextBox Text="{Binding ClientPort}"/>
            </pu:FormGroup>
 
            <Label>
                <Label.Style>
                    <Style TargetType="Label">
                        <Setter Property="Foreground" Value="White"/>
                        <Setter Property="Background" Value="Red"/>
                        <Setter Property="VerticalContentAlignment" Value="Center"/>
                        <Setter Property="HorizontalContentAlignment" Value="Center"/>
                        <Setter Property="Content" Value="未连接"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsConnected}" Value="True">
                                <Setter Property="Background" Value="Green"/>
                                <Setter Property="Content" Value="已连接"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Label.Style>
            </Label>
 
            <Button Tag="Connect" Content="连接" Click="Button_Click"/>
            <GroupBox Header="接收设置">
                <StackPanel dp:StackPanelHelper.ChildSpace="10" Margin="0,10">
                    <StackPanel Orientation="Horizontal">
                        <RadioButton Content="字符串" IsChecked="{Binding ReceiveDataType,Converter={x:Static uic:RadioEnumConverter.Instance},ConverterParameter={x:Static local:DataType.String}}" GroupName="ReceiveType"/>
                        <RadioButton Content="Hex"  IsChecked="{Binding ReceiveDataType,Converter={x:Static uic:RadioEnumConverter.Instance},ConverterParameter={x:Static local:DataType.HEX}}" GroupName="ReceiveType"/>
                    </StackPanel>
                    <pu:FormGroup Header="编码格式">
                        <ComboBox x:Name="receiveEncodeInput" SelectedValue="{Binding ReceiveEncode}"/>
                        <pu:FormGroup.Style>
                            <Style TargetType="pu:FormGroup">
                                <Setter Property="IsEnabled" Value="False"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding ReceiveDataType}" Value="{x:Static local:DataType.String}">
                                        <Setter Property="IsEnabled" Value="True"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </pu:FormGroup.Style>
                    </pu:FormGroup>
                </StackPanel>
            </GroupBox>
        </StackPanel>
 
        <StackPanel Grid.Row="1" Grid.Column="0">
            <GroupBox Header="发送设置">
                <StackPanel dp:StackPanelHelper.ChildSpace="10" Margin="0,10">
                    <StackPanel Orientation="Horizontal">
                        <RadioButton Content="字符串" IsChecked="{Binding SendDataType,Converter={x:Static uic:RadioEnumConverter.Instance},ConverterParameter={x:Static local:DataType.String}}" GroupName="SendType"/>
                        <RadioButton Content="Hex"  IsChecked="{Binding SendDataType,Converter={x:Static uic:RadioEnumConverter.Instance},ConverterParameter={x:Static local:DataType.HEX}}" GroupName="SendType"/>
                    </StackPanel>
 
                    <pu:FormGroup Header="编码格式">
                        <ComboBox x:Name="sendEncodeInput" SelectedValue="{Binding SendEncode}"/>
                        <pu:FormGroup.Style>
                            <Style TargetType="pu:FormGroup">
                                <Setter Property="IsEnabled" Value="False"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding SendDataType}" Value="{x:Static local:DataType.String}">
                                        <Setter Property="IsEnabled" Value="True"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </pu:FormGroup.Style>
                    </pu:FormGroup>
 
                    <pu:FormGroup Header="分隔符">
                        <ComboBox ItemsSource="{Binding EndMarkSource}" SelectedValue="{Binding EndMark}" DisplayMemberPath="Name" SelectedValuePath="Type"/>
                        <pu:FormGroup.Style>
                            <Style TargetType="pu:FormGroup">
                                <Setter Property="IsEnabled" Value="False"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding SendDataType}" Value="{x:Static local:DataType.String}">
                                        <Setter Property="IsEnabled" Value="True"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </pu:FormGroup.Style>
                    </pu:FormGroup>
                    <pu:FormGroup Header="自定义分隔符">
                        <TextBox Text="{Binding CustomEndMark}"/>
                        <pu:FormGroup.Style>
                            <Style TargetType="pu:FormGroup">
                                <Setter Property="IsEnabled" Value="False"/>
                                <Style.Triggers>
                                    <MultiDataTrigger>
                                        <MultiDataTrigger.Conditions>
                                            <Condition Binding="{Binding SendDataType}" Value="{x:Static local:DataType.String}"/>
                                            <Condition Binding="{Binding EndMark}" Value="2"/>
                                        </MultiDataTrigger.Conditions>
                                        <Setter Property="IsEnabled" Value="True"/>
                                    </MultiDataTrigger>
                                </Style.Triggers>
                            </Style>
                        </pu:FormGroup.Style>
                    </pu:FormGroup>
                </StackPanel>
            </GroupBox>
        </StackPanel>
 
        <Grid Grid.Row="1" Grid.Column="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <GroupBox Header="数据发送">
                <TextBox x:Name="sendBox" TextWrapping="Wrap" VerticalContentAlignment="Top"
                         PreviewTextInput="TextBox_PreviewTextInput"/>
            </GroupBox>
            <Button Grid.Column="1" Padding="20" Content="发送" Tag="Send" Click="Button_Click"/>
        </Grid>
 
        <Grid Grid.Row="0" Grid.Column="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <GroupBox Header="数据接收">
                <RichTextBox x:Name="console" IsReadOnly="True"/>
            </GroupBox>
        </Grid>
    </Grid>
</UserControl>