借助网络配置,控制Modbus工具的日志显示,避免卡死界面
智能大石头 authored at 2021-12-11 22:09:19
3.33 KiB
XCoder
<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:loc="using:NewLife.XCoder.Services"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:vm="clr-namespace:NewLife.XCoder.ViewModels"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="600"
        x:Class="NewLife.XCoder.Views.UsbDeviceWindow"
        x:DataType="vm:UsbDeviceViewModel"
        Title="{loc:Tr 'USB device detection'}" Width="800" Height="600"
        WindowStartupLocation="CenterOwner">
    <Window.Styles>
        <Style Selector="TextBox.ConfigTextBox">
            <Setter Property="Margin" Value="2"/>
            <Setter Property="Height" Value="32"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="BorderBrush" Value="{DynamicResource BorderDefault}"/>
        </Style>
        <Style Selector="Button.ActionButton">
            <Setter Property="Height" Value="32"/>
            <Setter Property="Padding" Value="12,0"/>
            <Setter Property="Margin" Value="2"/>
        </Style>
        <Style Selector="Border.GroupBorder">
            <Setter Property="Background" Value="{DynamicResource BgSurface2}"/>
            <Setter Property="BorderBrush" Value="{DynamicResource BorderDefault}"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="CornerRadius" Value="10"/>
            <Setter Property="Padding" Value="8"/>
            <Setter Property="Margin" Value="0"/>
        </Style>
    </Window.Styles>

    <Grid Margin="16" RowSpacing="10">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <!-- 选择 Hub -->
        <Border Grid.Row="0" Classes="GroupBorder">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <TextBlock Text="USB Hub" VerticalAlignment="Center" Margin="4,2"/>
                <ComboBox Grid.Column="1" ItemsSource="{Binding HubList}" SelectedIndex="{Binding SelectedHubIndex}" Height="32" Margin="2"/>
                <Button Grid.Column="2" Content="{loc:Tr 'Refresh'}" Command="{Binding RefreshDevicesCommand}" Classes="ActionButton" Width="60"/>
            </Grid>
        </Border>

        <!-- 设备信息 -->
        <TextBox Grid.Row="1" Text="{Binding DeviceInfo}" AcceptsReturn="True" AcceptsTab="True"
                 FontFamily="{DynamicResource FontMono}" FontSize="12" Margin="0,4"
                 BorderThickness="1" BorderBrush="{DynamicResource BorderDefault}"/>

        <!-- 日志 -->
        <TextBox Classes="console" Grid.Row="2" Text="{Binding Log, Converter={x:Static loc:LocalizedTextConverter.Instance}}" AcceptsReturn="True" AcceptsTab="True"
                 FontFamily="{DynamicResource FontMono}" FontSize="12" MinHeight="80" Margin="0,4"
                 BorderThickness="1" BorderBrush="{DynamicResource BorderDefault}"/>
    </Grid>
</Window>