<Window
    x:Class="FPGACoder.MainWindow"
    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:local="clr-namespace:FPGACoder"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vm="clr-namespace:FPGACoder.ViewModel"
    Title="MainWindow"
    Width="800"
    Height="450"
    d:DataContext="{d:DesignInstance {x:Type vm:MainViewModel}}"
    DataContext="{x:Static vm:MainViewModel.Instance}"
    mc:Ignorable="d">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="48" />
            <RowDefinition Height="*" />
            <RowDefinition Height="48" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <ListView
            Grid.Row="1"
            Grid.Column="0"
            VerticalAlignment="Top"
            Foreground="Black"
            ItemsSource="{Binding Register}">
            <ListView.Style>
                <Style TargetType="ListView" BasedOn="{x:Null}">
                    <Setter Property="Background" Value="Transparent" />
                    <Setter Property="BorderBrush" Value="Transparent" />
                    <Setter Property="VerticalContentAlignment" Value="Stretch" />
                    <Setter Property="Padding" Value="0" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="ListView">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="32" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                    <UniformGrid Rows="1">
                                        <TextBlock
                                            HorizontalAlignment="Center"
                                            VerticalAlignment="Center"
                                            Text="控件名" />
                                        <TextBlock
                                            HorizontalAlignment="Center"
                                            VerticalAlignment="Center"
                                            Text="属性名" />
                                    </UniformGrid>
                                    <ScrollViewer
                                        Grid.Row="1"
                                        HorizontalScrollBarVisibility="Hidden"
                                        VerticalScrollBarVisibility="Auto">
                                        <ItemsPresenter Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />

                                    </ScrollViewer>
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="ItemTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <UniformGrid Rows="1">
                                    <TextBlock
                                        HorizontalAlignment="Center"
                                        VerticalAlignment="Center"
                                        Text="{Binding TargetName}" />
                                    <TextBox
                                        Width="220"
                                        HorizontalAlignment="Center"
                                        VerticalAlignment="Center"
                                        Text="{Binding PropertyName}" />
                                </UniformGrid>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="ItemContainerStyle">
                        <Setter.Value>
                            <Style TargetType="ListViewItem">
                                <Setter Property="Background" Value="Transparent" />
                                <Setter Property="BorderBrush" Value="Transparent" />
                                <Setter Property="BorderThickness" Value="0" />
                                <Setter Property="Height" Value="32" />
                                <Setter Property="SnapsToDevicePixels" Value="True" />
                                <Setter Property="OverridesDefaultStyle" Value="True" />
                                <Setter Property="IsEnabled" Value="True" />
                                <Setter Property="Padding" Value="0" />
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="ListViewItem">
                                            <ContentPresenter
                                                Margin="4"
                                                Content="{TemplateBinding Content}"
                                                ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                                ContentTemplateSelector="{x:Null}" />
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="ItemsPanel">
                        <Setter.Value>
                            <ItemsPanelTemplate>
                                <UniformGrid Columns="1" />
                            </ItemsPanelTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ListView.Style>
        </ListView>

        <ListView
            Grid.Row="1"
            Grid.Column="1"
            VerticalAlignment="Top"
            Foreground="Black"
            ItemsSource="{Binding Project.DMA}">
            <ListView.Style>
                <Style TargetType="ListView" BasedOn="{x:Null}">
                    <Setter Property="Background" Value="Transparent" />
                    <Setter Property="BorderBrush" Value="Transparent" />
                    <Setter Property="VerticalContentAlignment" Value="Stretch" />
                    <Setter Property="Padding" Value="0" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="ListView">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="32" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                    <UniformGrid Rows="1">
                                        <TextBlock
                                            HorizontalAlignment="Center"
                                            VerticalAlignment="Center"
                                            Text="Fifo名" />
                                        <TextBlock
                                            HorizontalAlignment="Center"
                                            VerticalAlignment="Center"
                                            Text="属性名" />
                                    </UniformGrid>
                                    <ScrollViewer
                                        Grid.Row="1"
                                        HorizontalScrollBarVisibility="Hidden"
                                        VerticalScrollBarVisibility="Auto">
                                        <ItemsPresenter Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />

                                    </ScrollViewer>
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="ItemTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <UniformGrid Rows="1">
                                    <TextBlock
                                        HorizontalAlignment="Center"
                                        VerticalAlignment="Center"
                                        Text="{Binding TargetName}" />
                                    <TextBox
                                        Width="220"
                                        HorizontalAlignment="Center"
                                        VerticalAlignment="Center"
                                        Text="{Binding PropertyName}" />
                                </UniformGrid>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="ItemContainerStyle">
                        <Setter.Value>
                            <Style TargetType="ListViewItem">
                                <Setter Property="Background" Value="Transparent" />
                                <Setter Property="BorderBrush" Value="Transparent" />
                                <Setter Property="BorderThickness" Value="0" />
                                <Setter Property="Height" Value="32" />
                                <Setter Property="SnapsToDevicePixels" Value="True" />
                                <Setter Property="OverridesDefaultStyle" Value="True" />
                                <Setter Property="IsEnabled" Value="True" />
                                <Setter Property="Padding" Value="0" />
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="ListViewItem">
                                            <ContentPresenter
                                                Margin="4"
                                                Content="{TemplateBinding Content}"
                                                ContentStringFormat="{TemplateBinding ContentStringFormat}"
                                                ContentTemplate="{TemplateBinding ContentTemplate}"
                                                ContentTemplateSelector="{x:Null}" />
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="ItemsPanel">
                        <Setter.Value>
                            <ItemsPanelTemplate>
                                <UniformGrid Columns="1" />
                            </ItemsPanelTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ListView.Style>
        </ListView>
        <UniformGrid
            Grid.Row="0"
            Grid.ColumnSpan="2"
            Rows="1">
            <StackPanel Orientation="Horizontal">
                <TextBlock
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Text="命名空间:" />
                <TextBox
                    Width="120"
                    Height="24"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    VerticalContentAlignment="Center"
                    Text="{Binding NamespaceName}" />
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Text="类名:" />
                <TextBox
                    Width="120"
                    Height="24"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    VerticalContentAlignment="Center"
                    Text="{Binding ClassName}" />
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Text="设备型号:" />
                <TextBlock
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Text="{Binding Project.TargetClass}" />
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Text="顶层VI名:" />
                <TextBlock
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Text="{Binding VIName}" />
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <TextBlock
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Text="生成时间:" />
                <TextBlock
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Text="{Binding LastTime}" />
            </StackPanel>
        </UniformGrid>
        <Button
            Grid.Row="2"
            Width="120"
            Height="32"
            Command="{Binding OpenFileCommand}"
            Content="选择文件" />
        <Button
            Grid.Row="2"
            Grid.Column="1"
            Width="120"
            Height="32"
            Command="{Binding GenerateCommand}"
            Content="生成代码" />
    </Grid>
</Window>
