<UserControl
    x:Class="AppFramework.Views.EditionDetailsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:convert="clr-namespace:AppFramework.Converters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:extensions="clr-namespace:AppFramework.Extensions"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:sync="http://schemas.syncfusion.com/wpf"
    Width="800"
    Height="550"
    mc:Ignorable="d">
    <UserControl.Resources>
        <convert:BoolToVisibilityConverter x:Key="visibilityConverter" />
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>

        <Border
            Grid.RowSpan="3"
            CornerRadius="0"
            Opacity="1"
            Style="{StaticResource BorderStyle}" />

        <TextBlock
            Margin="15"
            FontSize="18"
            FontWeight="Bold"
            Text="{extensions:Translate CreateNewEdition}" />

        <ScrollViewer Grid.Row="1" Margin="15,0">
            <StackPanel>
                <!--  版本名称  -->
                <TextBlock Text="{extensions:Translate EditionName}" />
                <TextBox Margin="0,5" Text="{Binding Model.DisplayName, Mode=TwoWay}" />

                <!--  是否付费  -->
                <TextBlock Text="{extensions:Translate SubscriptionPrice}" />
                <StackPanel Margin="0,5" Orientation="Horizontal">
                    <RadioButton Content="{extensions:Translate Free}" IsChecked="True" />
                    <RadioButton
                        Margin="15,0"
                        Content="{extensions:Translate Paid}"
                        IsChecked="{Binding IsPaid}" />
                </StackPanel>

                <StackPanel Visibility="{Binding IsPaid, Converter={StaticResource visibilityConverter}}">

                    <!--  每天定价  -->
                    <TextBlock Text="{extensions:Translate DailyPrice}" />
                    <TextBox Margin="5" Text="{Binding Model.DailyPrice, Mode=TwoWay}" />

                    <!--  每周定价  -->
                    <TextBlock Text="{extensions:Translate WeeklyPrice}" />
                    <TextBox Margin="5" Text="{Binding Model.WeeklyPrice, Mode=TwoWay}" />

                    <!--  每月定价  -->
                    <TextBlock Text="{extensions:Translate MonthlyPrice}" />
                    <TextBox Margin="5" Text="{Binding Model.MonthlyPrice, Mode=TwoWay}" />

                    <!--  每年定价  -->
                    <TextBlock Text="{extensions:Translate AnnualPrice}" />
                    <TextBox Margin="5" Text="{Binding Model.AnnualPrice, Mode=TwoWay}" />

                    <!--  是否试用  -->
                    <CheckBox Content="{extensions:Translate IsTrialActive}" IsChecked="{Binding IsTrialActive}" />
                    <StackPanel Margin="0,5" Visibility="{Binding IsTrialActive, Converter={StaticResource visibilityConverter}}">
                        <TextBlock Text="{extensions:Translate TrialDayCount}" />
                        <!--<number:SfNumericUpDown
                            Minimum="0"
                            StepValue="1"
                            Value="{Binding Model.TrialDayCount}" />-->
                    </StackPanel>

                    <!--  订阅到期后  -->
                    <CheckBox Content="{extensions:Translate WaitAfterSubscriptionExpireDate}" IsChecked="{Binding IsWaitingDayAfter}" />
                    <StackPanel Margin="0,5" Visibility="{Binding IsWaitingDayAfter, Converter={StaticResource visibilityConverter}}">
                        <TextBlock Text="{extensions:Translate WaitingDayAfterExpire}" />
                        <!--<sync:SfNumericUpDown
                            Minimum="0"
                            StepValue="1"
                            Value="{Binding Model.WaitingDayAfterExpire}" />-->
                    </StackPanel>

                    <!--  订阅到期后怎么做？  -->
                    <TextBlock Text="{extensions:Translate WhatWillDoneAfterSubscriptionExpiry}" />
                    <StackPanel Margin="0,5" Orientation="Horizontal">
                        <RadioButton Content="{extensions:Translate DeactiveTenant}" />
                        <RadioButton
                            Margin="10,0"
                            Content="{extensions:Translate AssignToAnotherEdition}"
                            IsChecked="{Binding IsAssignToAnotherEdition}" />
                    </StackPanel>

                    <!--  指定版本  -->
                    <!--<Picker
                        Title="{extensions:Translate Edition}"
                        Visibility="{Binding IsAssignToAnotherEdition}"
                        ItemDisplayBinding="{Binding DisplayText}"
                        ItemsSource="{Binding Editions}"
                        SelectedItem="{Binding SelectedEdition}" />-->
                </StackPanel>

                <!--  功能列表  -->
                <TextBlock Text="{extensions:Translate Features}" />
                <sync:SfTreeView
                    Margin="0,5"
                    AutoExpandMode="AllNodes"
                    BorderThickness="0"
                    CheckBoxMode="Recursive"
                    CheckedItems="{Binding SelectedItems}"
                    ChildPropertyName="Items"
                    ExpandActionTrigger="Node"
                    IsAnimationEnabled="True"
                    ItemTemplateDataContextType="Node"
                    ItemsSource="{Binding Features}"
                    NodePopulationMode="Instant"
                    SelectionBackgroundColor="Transparent">
                    <sync:SfTreeView.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <CheckBox VerticalAlignment="Center" IsChecked="{Binding IsChecked, Mode=TwoWay}" />
                                <TextBlock VerticalAlignment="Center" Text="{Binding Content.DisplayName}" />
                            </StackPanel>
                        </DataTemplate>
                    </sync:SfTreeView.ItemTemplate>
                </sync:SfTreeView>
            </StackPanel>
        </ScrollViewer>

        <StackPanel
            Grid.Row="2"
            Margin="15"
            HorizontalAlignment="Right"
            Orientation="Horizontal">
            <Button
                Margin="0,0,10,0"
                Padding="10,5"
                Command="{Binding CancelCommand}"
                Content="{extensions:Translate Cancel}" />
            <Button
                Padding="10,5"
                Command="{Binding SaveCommand}"
                Content="{extensions:Translate Save}" />
        </StackPanel>
    </Grid>
</UserControl>
