借助网络配置,控制Modbus工具的日志显示,避免卡死界面
智能大石头 authored at 2021-12-11 22:09:19
5.49 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="900" d:DesignHeight="700"
        x:Class="NewLife.XCoder.Views.MelSpectrumWindow"
        x:DataType="vm:MelSpectrumViewModel"
        Title="{loc:Tr 'Audio Mel spectrum'}" Width="900" Height="700"
        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="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

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

                <TextBlock Text="{loc:Tr 'WAV file'}" VerticalAlignment="Center" Margin="4,2"/>
                <TextBox Grid.Column="1" Text="{Binding FilePath}" Classes="ConfigTextBox"
                         PlaceholderText="{loc:Tr 'Paste the full path to a WAV file'}"/>
                <Button Grid.Column="2" Content="{loc:Tr 'Read and analyze'}" Command="{Binding OpenCommand}" Classes="ActionButton" Width="100"/>
                <Button Grid.Column="3" Content="{loc:Tr 'Recompute'}" Command="{Binding AnalyzeCommand}" Classes="ActionButton" Width="80"/>
                <Button Grid.Column="4" Content="{loc:Tr 'Export CSV'}" Command="{Binding ExportCommand}" Classes="ActionButton" Width="80"/>
            </Grid>
        </Border>

        <!-- 声道选择 -->
        <Border Grid.Row="1" Classes="GroupBorder" Padding="4">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{loc:Tr 'Channels'}" VerticalAlignment="Center" Margin="4,0"/>
                <ComboBox ItemsSource="{Binding ChannelList}" SelectedIndex="{Binding SelectedChannelIndex}" Width="120" Height="32" Margin="4,0"/>
                <TextBlock Text="{loc:Tr 'Mel bands'}" VerticalAlignment="Center" Margin="12,0,4,0"/>
                <NumericUpDown Value="{Binding MelBins}" Minimum="8" Maximum="128" Increment="8" Width="110" Height="32" Margin="4,0"/>
                <Button Content="{loc:Tr 'Clear'}" Command="{Binding ClearCommand}" Classes="ActionButton" Width="70" Margin="12,0,0,0"/>
            </StackPanel>
        </Border>

        <!-- 频谱与音量 -->
        <Grid Grid.Row="2" Margin="0,4">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <TextBlock Text="{loc:Tr 'Mel spectrum (first 12 frames x first 8 bands, log values)'}" FontWeight="Bold" Margin="4,2"/>
            <TextBox Grid.Row="1" Text="{Binding MelPreview}" IsReadOnly="True" AcceptsReturn="True"
                     FontFamily="{DynamicResource FontMono}" FontSize="12" TextWrapping="NoWrap"
                     BorderThickness="1" BorderBrush="{DynamicResource BorderDefault}" Margin="0,0,0,4"/>
            <TextBlock Grid.Row="2" Text="{loc:Tr 'Volume curve'}" FontWeight="Bold" Margin="4,2"/>
            <TextBox Grid.Row="3" Text="{Binding VolumePreview}" IsReadOnly="True" AcceptsReturn="True"
                     FontFamily="{DynamicResource FontMono}" FontSize="12" TextWrapping="Wrap"
                     BorderThickness="1" BorderBrush="{DynamicResource BorderDefault}" MinHeight="70"/>
        </Grid>

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