<UserControl x:Class="Serein.Workbench.Views.ViewCanvasInfoView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:Serein.Workbench.Views"
             xmlns:vm="clr-namespace:Serein.Workbench.ViewModels"
             xmlns:converter="clr-namespace:Serein.Workbench.Converters"
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="300"
             d:DataContext="{d:DesignInstance vm:ViewCanvasInfoViewModel}">

    <UserControl.Resources>
        <converter:CountToVisibilityConverter x:Key="CountToVisibilityConverter"/>
        <Style  x:Key="InfoTipsTextBlock" TargetType="TextBlock">
            <Setter Property="Width" Value="70"/>
            <Setter Property="MinWidth" Value="70"/>
            <Setter Property="MaxHeight" Value="70"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>
        <Style  x:Key="InfoValueTextBox" TargetType="TextBox">
            <Setter Property="Width" Value="170"/>
            <Setter Property="MinWidth" Value="170"/>
            <Setter Property="MaxHeight" Value="170"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>
    </UserControl.Resources>

    <Border BorderBrush="Black" BorderThickness="1">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="auto"/>
            </Grid.RowDefinitions>

            <StackPanel Grid.Row="1"  Margin="10" >
                <TextBlock Text="公开节点"  HorizontalAlignment="Left"/>
                <ListBox ItemsSource="{Binding Model.PublicNodes}" 
                         Visibility="{Binding ItemsSource, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource CountToVisibilityConverter}}"
                         ScrollViewer.HorizontalScrollBarVisibility="Auto" 
                         ScrollViewer.VerticalScrollBarVisibility="Auto">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid PreviewMouseLeftButtonDown="Grid_PreviewMouseLeftButtonDown">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="auto"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Grid.Column="0" Text="{Binding ControlType}"/>
                                <TextBlock Grid.Column="1" Text="{Binding DisplayName}"/>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>

                </ListBox>
            </StackPanel>
       
            <StackPanel Grid.Row="2" Margin="10">
                <TextBlock Text="流程节点"  HorizontalAlignment="Left"/>
                <ListBox ItemsSource="{Binding Model.Nodes}" 
                         Visibility="{Binding ItemsSource, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource CountToVisibilityConverter}}"
                         ScrollViewer.HorizontalScrollBarVisibility="Auto" 
                         ScrollViewer.VerticalScrollBarVisibility="Auto">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid PreviewMouseLeftButtonDown="Grid_PreviewMouseLeftButtonDown">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <TextBlock Grid.Column="0" Text="{Binding ControlType}"/>
                                <TextBlock Grid.Column="1" Text="{Binding DisplayName}"/>
                            </Grid> 
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </StackPanel>

            <StackPanel  Grid.Row="0" Margin="10">
                <TextBlock Text="画布信息" HorizontalAlignment="Left"/>
                <!--<StackPanel Margin="2" Orientation="Horizontal">
                    <TextBlock Text="GUID" Style="{StaticResource InfoTipsTextBlock}" />
                    <TextBox Text="{Binding Model.Guid, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
                </StackPanel>-->
                <StackPanel Margin="1" Orientation="Horizontal">
                    <TextBlock Text="画布名称" Style="{StaticResource InfoTipsTextBlock}" />
                    <TextBox Text="{Binding Model.Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
                </StackPanel>
                <StackPanel Margin="1" Orientation="Horizontal">
                    <TextBlock Text="尺寸宽度" Style="{StaticResource InfoTipsTextBlock}" />
                    <TextBox Text="{Binding Model.Width, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
                </StackPanel>
                <StackPanel Margin="1" Orientation="Horizontal">
                    <TextBlock Text="尺寸高度" Style="{StaticResource InfoTipsTextBlock}" />
                    <TextBox Text="{Binding Model.Height, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
                </StackPanel>
                <StackPanel Margin="1" Orientation="Horizontal">
                    <TextBlock Text="预览位置X" Style="{StaticResource InfoTipsTextBlock}" />
                    <TextBox Text="{Binding Model.ViewX, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
                </StackPanel>
                <StackPanel Margin="1" Orientation="Horizontal">
                    <TextBlock Text="预览位置Y" Style="{StaticResource InfoTipsTextBlock}" />
                    <TextBox Text="{Binding Model.ViewY, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
                </StackPanel>
                <StackPanel Margin="1" Orientation="Horizontal">
                    <TextBlock Text="缩放比例X" Style="{StaticResource InfoTipsTextBlock}" />
                    <TextBox Text="{Binding Model.ScaleX, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
                </StackPanel>
                <StackPanel Margin="1" Orientation="Horizontal">
                    <TextBlock Text="缩放比例Y" Style="{StaticResource InfoTipsTextBlock}" />
                    <TextBox Text="{Binding Model.ScaleY, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource InfoValueTextBox}"/>
                </StackPanel>
            
            </StackPanel>
        </Grid>
    </Border>
</UserControl>
