<Page x:Class="Install.View.PgUpdate"
      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:Install.View"
      mc:Ignorable="d" 
      d:DesignHeight="450" d:DesignWidth="800"
      Title="PgUpdate">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="174*" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        
        <Grid >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="390*" />
                <ColumnDefinition Width="auto" />
            </Grid.ColumnDefinitions>
            <TextBlock Text="已安装项目" Style="{StaticResource h1}"/>
            <StackPanel Orientation="Horizontal" Grid.Column="1">
                <Button Margin="5" Command="{Binding DownloadCmd}" Visibility="{Binding InstallWizard.HasNewestInstallZip,Converter={StaticResource visbilityconv}}">
                    <TextBlock Margin="10,2">
                        点击下载 最新版本 v<Run Foreground="Red" FontSize="20" Text="{Binding InstallWizard.NewestInstallZipVersion,Mode=OneWay}"/> 
                    </TextBlock>
                </Button>
            </StackPanel>
            
        </Grid>
        <ListBox Margin="5" Name="listBox1" Grid.Row="1" ItemsSource="{Binding Items}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Margin="3">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <CheckBox IsChecked="{Binding IsSelected}" VerticalAlignment="Center" Margin="5"/>
                        <StackPanel Grid.Column="1" Orientation="Horizontal" DataContext="{Binding Item}">
                            <Image Height="30" Width="30" >
                                <Image.Source>
                                    <MultiBinding Converter="{StaticResource iconConv}">
                                        <Binding Path="ProcessName"/>
                                        <Binding Path="DataContext.Icons" ElementName="listBox1"/>
                                    </MultiBinding>
                                </Image.Source>
                            </Image>
                            <StackPanel Margin="2">
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding Name}" FontSize="15" Margin="2"/>
                                    <TextBlock Text="{Binding Version}" Foreground="{StaticResource AccentBaseColorBrush}"/>
                                    <Grid Width="30"/>
                                    <TextBlock Foreground="Red" Visibility="{Binding NeedToUpdate,Converter={StaticResource visbilityconv}}">
                                        -> <Run Text="{Binding NewestVersion,Mode=OneWay}"/>
                                    </TextBlock>
                                </StackPanel>
                                <TextBlock Text="{Binding ProcessName}" Foreground="{StaticResource GrayBrush4}"/>
                            </StackPanel>
                            <CheckBox IsChecked="{Binding IsAutoRun}" Margin="2" Content="开机启动" VerticalAlignment="Center" />
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <GroupBox Grid.Row="2" x:Name="groupbox_opt">
            <StackPanel Orientation="Vertical" Margin="5">
                <StackPanel.Resources>
                    <ResourceDictionary>
                        <Style TargetType="RadioButton" >
                            <Setter Property="Height" Value="20"/>
                            <Setter Property="Margin" Value="2.5"/>
                            <Setter Property="FontWeight" Value="Bold" />
                        </Style>
                    </ResourceDictionary>
                </StackPanel.Resources>
                <RadioButton GroupName="option"  Content="只设置开机启动 &amp; 创建快捷方式" IsChecked="{Binding Option,Converter={StaticResource e2bconv}, ConverterParameter={x:Static local:OPTION.AUTORUN}}"/>
                <RadioButton GroupName="option"  Content="升级(复制*.dll 与 *.exe)" IsChecked="{Binding Option,Converter={StaticResource e2bconv},ConverterParameter={x:Static local:OPTION.UPDATE}}"/>
                <RadioButton GroupName="option"  Content="删除" IsChecked="{Binding Option,Converter={StaticResource e2bconv},ConverterParameter={x:Static local:OPTION.REMOVE}}"/>
            </StackPanel>

        </GroupBox>
        <Grid Style="{StaticResource BottomPanel}" Grid.Row="3" >
            <StackPanel Style="{StaticResource BtnSp}">
                <Button Content="新增" Style="{StaticResource NormalBtn}" Command="{Binding NewCmd}" Visibility="{Binding HasNew,Converter={StaticResource visbilityconv},ConverterParameter=Collapsed}"/>
                <Button Content="下一步" Style="{StaticResource NormalBtn}"  Command="{Binding NextCmd}" />
            </StackPanel>
        </Grid>
    </Grid>
</Page>