借助网络配置,控制Modbus工具的日志显示,避免卡死界面
智能大石头 authored at 2021-12-11 22:09:19
4.74 KiB
XCoder
<Window x:Class="CrazyCoder.Views.AudioDeviceWindow"
        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"
        mc:Ignorable="d"
        Title="声卡选择器" Height="550" Width="700" WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <Style x:Key="GroupBorder" TargetType="Border">
            <Setter Property="BorderBrush" Value="#D0D0D0"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Margin" Value="0,0,0,6"/>
        </Style>
        <Style x:Key="SectionTitle" TargetType="TextBlock">
            <Setter Property="FontWeight" Value="Bold"/>
            <Setter Property="Margin" Value="4,3"/>
            <Setter Property="FontSize" Value="13"/>
        </Style>
        <Style x:Key="ConfigLabel" TargetType="TextBlock">
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="Margin" Value="4,2"/>
        </Style>
        <Style x:Key="ActionButton" TargetType="Button">
            <Setter Property="Height" Value="32"/>
            <Setter Property="Margin" Value="2"/>
            <Setter Property="Padding" Value="16,0"/>
        </Style>
        <Style x:Key="InfoTextBox" TargetType="TextBox">
            <Setter Property="FontFamily" Value="Consolas"/>
            <Setter Property="FontSize" Value="13"/>
            <Setter Property="IsReadOnly" Value="True"/>
            <Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
            <Setter Property="HorizontalScrollBarVisibility" Value="Auto"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="BorderBrush" Value="#D0D0D0"/>
            <Setter Property="TextWrapping" Value="Wrap"/>
        </Style>
    </Window.Resources>

    <Grid Margin="8">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- 设备选择 -->
        <Border Grid.Row="0" Style="{StaticResource GroupBorder}">
            <StackPanel>
                <TextBlock Text="声卡选择" Style="{StaticResource SectionTitle}"/>
                <Grid Margin="4,0,4,4">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <ComboBox Grid.Column="0" ItemsSource="{Binding DeviceList}" SelectedIndex="{Binding SelectedDeviceIndex}"
                              Margin="2" Height="30"/>
                    <Button Grid.Column="1" Content="刷新" Command="{Binding RefreshDevicesCommand}"
                            Style="{StaticResource ActionButton}" Width="80" Margin="4,2"/>
                    <Button Grid.Column="2" Content="测试播放" Command="{Binding TestPlaybackCommand}"
                            Style="{StaticResource ActionButton}" Width="80" Margin="4,2"/>
                </Grid>
            </StackPanel>
        </Border>

        <!-- 音量 -->
        <Border Grid.Row="1" Style="{StaticResource GroupBorder}">
            <StackPanel>
                <TextBlock Text="音量设置" Style="{StaticResource SectionTitle}"/>
                <Grid Margin="4,0,4,4">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0" Text="音量" VerticalAlignment="Center" Margin="4,2"/>
                    <Slider Grid.Column="1" Value="{Binding VolumeValue}" Minimum="0" Maximum="100" Margin="4,2"/>
                    <TextBlock Grid.Column="2" Text="{Binding VolumeValue, StringFormat={}{0:F0}%}" VerticalAlignment="Center" Width="40"/>
                </Grid>
            </StackPanel>
        </Border>

        <!-- 设备详情 -->
        <Border Grid.Row="2" Style="{StaticResource GroupBorder}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <TextBlock Text="设备信息" Style="{StaticResource SectionTitle}"/>
                <TextBox Grid.Row="1" Text="{Binding DeviceDetail, Mode=OneWay}" Style="{StaticResource InfoTextBox}" Margin="2"/>
            </Grid>
        </Border>
    </Grid>
</Window>