1.infotext滑块永远在最下方

2.textblock改为textbox,获得textchanged事件
3.给textbox添加isReadOnly属性
4.下拉框每次选择后去除选择项,防止无法选择重复选项,导致无法触发SelectedChanged
master
zhangxy 1 month ago
parent d338ed4b48
commit b78ebb19d3

@ -97,9 +97,18 @@
</StackPanel>
<StackPanel Orientation="Horizontal" Width="370" Margin="0,5,0,5" Height="100">
<Border Height="Auto" Width="200" BorderBrush="Black" BorderThickness="0.5" Margin="5,5,10,0" >
<ScrollViewer VerticalScrollBarVisibility="Auto">
<TextBlock x:Name="InfoTextBlock_Client" TextWrapping="Wrap" Text="{Binding Infotext}" Height="Auto" Width="Auto" Margin="5,5,5,5"></TextBlock>
<Border Height="Auto" Width="200" BorderBrush="Black" BorderThickness="1" Margin="5,5,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>

@ -44,6 +44,7 @@ namespace SocketExample
int port;
TcpClient client;
public string option;//命令选项
public ICommand TextChangedCommand { get; }
public ICommand SelectionChangedCommand { get; }
public ICommand GPOSelectionChangedCommand { get; }
@ -168,6 +169,7 @@ namespace SocketExample
getpowercomn = new LinkCommand(Button_GetPower);
SelectionChangedCommand = new RelayCommand<ComboBox>(ComboBox_SelectChanged);
GPOSelectionChangedCommand = new RelayCommand<ComboBox>(GPOComboBox_SelectChanged);
TextChangedCommand = new RelayCommand<ScrollViewer>(TextBlock_SelectChanged);
try
{
@ -475,7 +477,7 @@ namespace SocketExample
Thread GPIOthread = new Thread(new ThreadStart(delegate () { byte[] data = strToToHexByte("AA 55 00 81 81 0D"); client.Send(data); Thread.Sleep(3000); }));
//GPIOthread.Start();
GPIOthread.Start();
return EasyTask.CompletedTask;
}
#endregion
@ -651,6 +653,11 @@ namespace SocketExample
Infotext = string.Empty;//清空信息框
}
void TextBlock_SelectChanged(ScrollViewer scrollViewer)
{
scrollViewer.ScrollToVerticalOffset(scrollViewer.ExtentHeight);
}
void ComboBox_SelectChanged(ComboBox sender)
{
string comboxname = sender.Name;
@ -719,7 +726,7 @@ namespace SocketExample
}
if (sender.SelectedItem?.ToString() == "高")
Order += "01 ";
else
else if(sender.SelectedItem?.ToString() == "低")
Order += "00 ";
Order += "00 00 ";
Order += Convert.ToString(GetXor(strToToHexByte(Order), 2), 16) + " 0D";
@ -728,6 +735,7 @@ namespace SocketExample
client.Send(data);
data = strToToHexByte("AA 55 00 81 81 0D");//获取GPIO状态
client.Send(data);
sender.SelectedIndex = -1;
//SaveCommand();
}
catch (Exception ex)

Loading…
Cancel
Save