<UserControl x:Class="NETworkManager.Views.SettingsImportExportView"
        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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:Converter="clr-namespace:NETworkManager.Converters"
        xmlns:Validator="clr-namespace:NETworkManager.Validators"        
        xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
        xmlns:Dialog="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
        Dialog:DialogParticipation.Register="{Binding}"
        Loaded="UserControl_Loaded"
        mc:Ignorable="d">
    <UserControl.Resources>
        <Converter:ValidateSettingsExportConverter x:Key="ValidateSettingsExportConverter" />
        <Converter:ValidateSettingsImportConverter x:Key="ValidateSettingsImportConverter" />
        <Converter:BooleanReverseToVisibilityConverter x:Key="BooleanReverseToVisibilityConverter" />
        <Converter:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </UserControl.Resources>
    <StackPanel >
        <TextBlock Style="{StaticResource HeaderTextBlock}" Text="{DynamicResource String_Header_Import}" />
        <TextBox x:Name="txtImportFilePath" mah:TextBoxHelper.Watermark="{DynamicResource String_Watermark_LocationOfTheImport}" Style="{StaticResource BrowseFolderTextBox}" mah:TextBoxHelper.ButtonCommand="{Binding BrowseFileCommand}" AllowDrop="True" Drop="txtImportFilePath_Drop" PreviewDragOver="txtImportFilePath_PreviewDragOver" Margin="0,0,0,10">
            <TextBox.Text>
                <Binding Path="ImportFilePath" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
                    <Binding.ValidationRules>
                        <Validator:EmptyValidator ValidatesOnTargetUpdated="True" />
                        <Validator:FileExistsValidator ValidatesOnTargetUpdated="True" />
                    </Binding.ValidationRules>
                </Binding>
            </TextBox.Text>
        </TextBox>
        <Button Content="{DynamicResource String_Button_Validate}" Command="{Binding ValidateImportSettingsCommand}" Visibility="{Binding ImportFileIsValid,Converter={StaticResource BooleanReverseToVisibilityConverter}}" HorizontalAlignment="Left" Margin="0,0,0,20" >
            <Button.Style>
                <Style TargetType="{x:Type Button}" BasedOn="{StaticResource DefaultButton}">
                    <Setter Property="IsEnabled" Value="False" />
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ElementName=txtImportFilePath, Path=(Validation.HasError)}" Value="False">
                            <Setter Property="IsEnabled" Value="True" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Button.Style>
        </Button>
        <StackPanel Visibility="{Binding ImportFileIsValid, Converter={StaticResource BooleanToVisibilityConverter}}" Margin="0,0,0,20">
            <TextBlock Style="{StaticResource DefaultTextBlock}" Text="{StaticResource String_SelectTheSettingsYouWantToImport}" Margin="0,0,0,10" />
            <RadioButton x:Name="radioButtonImportEverything" Content="{DynamicResource String_RadioButton_Everything}" IsChecked="{Binding ImportEverything}" Margin="0,0,0,10"/>
            <RadioButton x:Name="radioButtonImportCustom" Content="{DynamicResource String_RadioButton_Custom}" Margin="0,0,0,10"/>
            <GroupBox HorizontalAlignment="Left" Margin="20,0,0,10">
                <GroupBox.Style>
                    <Style TargetType="{x:Type GroupBox}" BasedOn="{StaticResource WithoutHeaderGroupBox}">
                        <Setter Property="IsEnabled" Value="False" />
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ElementName=radioButtonImportCustom, Path=IsChecked}" Value="True">
                                <Setter Property="IsEnabled" Value="True" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </GroupBox.Style>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition MinWidth="240" />
                        <ColumnDefinition Width="10" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="10" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="10" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="10" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="10" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="10" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="10" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="10" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="10" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <CheckBox Grid.Column="0" Grid.Row="0" Content="{DynamicResource String_ApplicationSettings}" IsEnabled="{Binding ImportApplicationSettingsExists}" IsChecked="{Binding ImportApplicationSettings}" />
                    <CheckBox Grid.Column="0" Grid.Row="2" Content="{DynamicResource String_NetworkInterfaceProfiles}" IsEnabled="{Binding ImportNetworkInterfaceProfilesExists}" IsChecked="{Binding ImportNetworkInterfaceProfiles}" />
                    <Grid Grid.Column="2" Grid.Row="2" IsEnabled="{Binding ImportNetworkInterfaceProfilesExists}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition MinWidth="100" />
                            <ColumnDefinition Width="10" />
                            <ColumnDefinition MinWidth="100" />
                        </Grid.ColumnDefinitions>
                        <RadioButton Grid.Column="0" Grid.Row="0" GroupName="ImportNetworkInterfaceProfiles" Content="{DynamicResource String_Override}" IsChecked="{Binding ImportOverrideNetworkInterfaceProfiles}" />
                        <RadioButton Grid.Column="2" Grid.Row="0" GroupName="ImportNetworkInterfaceProfiles" Content="{DynamicResource String_Add}" />
                    </Grid>
                    <CheckBox Grid.Column="0" Grid.Row="4" Content="{DynamicResource String_IPScannerProfiles}" IsEnabled="{Binding ImportIPScannerProfilesExists}" IsChecked="{Binding ImportIPScannerProfiles}" />
                    <Grid Grid.Column="2" Grid.Row="4" IsEnabled="{Binding ImportIPScannerProfilesExists}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition MinWidth="100" />
                            <ColumnDefinition Width="10" />
                            <ColumnDefinition MinWidth="100" />
                        </Grid.ColumnDefinitions>
                        <RadioButton Grid.Column="0" Grid.Row="0" GroupName="ImportIPScannerProfiles" Content="{DynamicResource String_Override}" IsChecked="{Binding ImportOverrideIPScannerProfiles}" />
                        <RadioButton Grid.Column="2" Grid.Row="0" GroupName="ImportIPScannerProfiles" Content="{DynamicResource String_Add}" />
                    </Grid>                  
                    <CheckBox Grid.Column="0" Grid.Row="6" Content="{DynamicResource String_PortScannerProfiles}" IsEnabled="{Binding ImportPortScannerProfilesExists}" IsChecked="{Binding ImportPortScannerProfiles}" />
                    <Grid Grid.Column="2" Grid.Row="6" IsEnabled="{Binding ImportPortScannerProfilesExists}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition MinWidth="100" />
                            <ColumnDefinition Width="10" />
                            <ColumnDefinition MinWidth="100" />
                        </Grid.ColumnDefinitions>
                        <RadioButton Grid.Column="0" Grid.Row="0" GroupName="ImportPortScannerProfiles" Content="{DynamicResource String_Override}" IsChecked="{Binding ImportOverridePortScannerProfiles}" />
                        <RadioButton Grid.Column="2" Grid.Row="0" GroupName="ImportPortScannerProfiles" Content="{DynamicResource String_Add}" />
                    </Grid>
                    <CheckBox Grid.Column="0" Grid.Row="8" Content="{DynamicResource String_PingProfiles}" IsEnabled="{Binding ImportPingProfilesExists}" IsChecked="{Binding ImportPingProfiles}" />
                    <Grid Grid.Column="2" Grid.Row="8" IsEnabled="{Binding ImportPingProfilesExists}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition MinWidth="100" />
                            <ColumnDefinition Width="10" />
                            <ColumnDefinition MinWidth="100" />
                        </Grid.ColumnDefinitions>
                        <RadioButton Grid.Column="0" Grid.Row="0" GroupName="ImportPingProfiles" Content="{DynamicResource String_Override}" IsChecked="{Binding ImportOverridePingProfiles}" />
                        <RadioButton Grid.Column="2" Grid.Row="0" GroupName="ImportPingProfiles" Content="{DynamicResource String_Add}" />
                    </Grid>
                    <CheckBox Grid.Column="0" Grid.Row="10" Content="{DynamicResource String_TracerouteProfiles}" IsEnabled="{Binding ImportTracerouteProfilesExists}" IsChecked="{Binding ImportTracerouteProfiles}" />
                    <Grid Grid.Column="2" Grid.Row="10" IsEnabled="{Binding ImportTracerouteProfilesExists}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition MinWidth="100" />
                            <ColumnDefinition Width="10" />
                            <ColumnDefinition MinWidth="100" />
                        </Grid.ColumnDefinitions>
                        <RadioButton Grid.Column="0" Grid.Row="0" GroupName="ImportTracerouteProfiles" Content="{DynamicResource String_Override}" IsChecked="{Binding ImportOverrideTracerouteProfiles}" />
                        <RadioButton Grid.Column="2" Grid.Row="0" GroupName="ImportTracerouteProfiles" Content="{DynamicResource String_Add}" />
                    </Grid>
                    <CheckBox Grid.Column="0" Grid.Row="12" Content="{DynamicResource String_RemoteDesktopSessions}" IsEnabled="{Binding ImportRemoteDesktopSessionsExists}" IsChecked="{Binding ImportRemoteDesktopSessions}" />
                    <Grid Grid.Column="2" Grid.Row="12" IsEnabled="{Binding ImportRemoteDesktopSessionsExists}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition MinWidth="100" />
                            <ColumnDefinition Width="10" />
                            <ColumnDefinition MinWidth="100" />
                        </Grid.ColumnDefinitions>
                        <RadioButton Grid.Column="0" Grid.Row="0" GroupName="ImportRemoteDesktopSessions" Content="{DynamicResource String_Override}" IsChecked="{Binding ImportOverrideRemoteDesktopSessions}" />
                        <RadioButton Grid.Column="2" Grid.Row="0" GroupName="ImportRemoteDesktopSessions" Content="{DynamicResource String_Add}" />
                    </Grid>
                    <CheckBox Grid.Column="0" Grid.Row="14" Content="{DynamicResource String_PuTTYSessions}" IsEnabled="{Binding ImportPuTTYSessionsExists}" IsChecked="{Binding ImportPuTTYSessions}" />
                    <Grid Grid.Column="2" Grid.Row="14" IsEnabled="{Binding ImportPuTTYSessionsExists}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition MinWidth="100" />
                            <ColumnDefinition Width="10" />
                            <ColumnDefinition MinWidth="100" />
                        </Grid.ColumnDefinitions>
                        <RadioButton Grid.Column="0" Grid.Row="0" GroupName="ImportPuTTYSessions" Content="{DynamicResource String_Override}" IsChecked="{Binding ImportOverridePuTTYSessions}" />
                        <RadioButton Grid.Column="2" Grid.Row="0" GroupName="ImportPuTTYSessions" Content="{DynamicResource String_Add}" />
                    </Grid>
                    <CheckBox Grid.Column="0" Grid.Row="16" Content="{DynamicResource String_WakeOnLANClients}" IsEnabled="{Binding ImportWakeOnLANClientsExists}" IsChecked="{Binding ImportWakeOnLANClients}" />
                    <Grid Grid.Column="2" Grid.Row="16" IsEnabled="{Binding ImportWakeOnLANClientsExists}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition MinWidth="100" />
                            <ColumnDefinition Width="10" />
                            <ColumnDefinition MinWidth="100" />
                        </Grid.ColumnDefinitions>
                        <RadioButton Grid.Column="0" Grid.Row="0" GroupName="ImportWakeOnLANClients" Content="{DynamicResource String_Override}" IsChecked="{Binding ImportOverrideWakeOnLANClients}" />
                        <RadioButton Grid.Column="2" Grid.Row="0" GroupName="ImportWakeOnLANClients" Content="{DynamicResource String_Add}" />
                    </Grid>
                </Grid>
            </GroupBox>
            <Button Content="{DynamicResource String_Button_Import}" Command="{Binding ImportSettingsCommand}" HorizontalAlignment="Left"  >
                <Button.Style>
                    <Style TargetType="{x:Type Button}" BasedOn="{StaticResource DefaultButton}">
                        <Setter Property="IsEnabled" Value="False" />
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ImportEverything}" Value="True">
                                <Setter Property="IsEnabled" Value="True" />
                            </DataTrigger>
                            <DataTrigger Value="True">
                                <DataTrigger.Binding>
                                    <MultiBinding Converter="{StaticResource ValidateSettingsImportConverter}">
                                        <Binding Path="ImportEverything" />
                                        <Binding Path="ImportApplicationSettings" />
                                        <Binding Path="ImportNetworkInterfaceProfiles" />
                                        <Binding Path="ImportIPScannerProfiles" />
                                        <Binding Path="ImportPortScannerProfiles" />
                                        <Binding Path="ImportPingProfiles" />
                                        <Binding Path="ImportTracerouteProfiles" />
                                        <Binding Path="ImportRemoteDesktopSessions" />
                                        <Binding Path="ImportPuTTYSessions" />
                                        <Binding Path="ImportWakeOnLANClients" />
                                    </MultiBinding>
                                </DataTrigger.Binding>
                                <Setter  Property="IsEnabled" Value="True" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Button.Style>
            </Button>
        </StackPanel>
        <TextBlock Style="{StaticResource HeaderTextBlock}" Text="{DynamicResource String_Header_Export}" />
        <TextBlock Style="{StaticResource DefaultTextBlock}" Text="{StaticResource String_SelectTheSettingsYouWantToExport}" Margin="0,0,0,10" />
        <RadioButton x:Name="radioButtonExportEverything" Content="{DynamicResource String_RadioButton_Everything}" IsChecked="{Binding ExportEverything}" Margin="0,0,0,10"/>
        <RadioButton x:Name="radioButtonExportCustom" Content="{DynamicResource String_RadioButton_Custom}" Margin="0,0,0,10"/>
        <GroupBox Margin="20,0,0,10" MinWidth="250" HorizontalAlignment="Left">
            <GroupBox.Style>
                <Style TargetType="{x:Type GroupBox}" BasedOn="{StaticResource WithoutHeaderGroupBox}">
                    <Setter Property="IsEnabled" Value="False" />
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ElementName=radioButtonExportCustom, Path=IsChecked}" Value="True">
                            <Setter Property="IsEnabled" Value="True" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </GroupBox.Style>
            <StackPanel>
                <CheckBox Content="{DynamicResource String_ApplicationSettings}" IsEnabled="{Binding ApplicationSettingsExists}" IsChecked="{Binding ExportApplicationSettings}" Margin="0,0,0,10" />
                <CheckBox Content="{DynamicResource String_NetworkInterfaceProfiles}" IsEnabled="{Binding NetworkInterfaceProfilesExists}" IsChecked="{Binding ExportNetworkInterfaceProfiles}" Margin="0,0,0,10" />
                <CheckBox Content="{DynamicResource String_IPScannerProfiles}" IsEnabled="{Binding IPScannerProfilesExists}" IsChecked="{Binding ExportIPScannerProfiles}" Margin="0,0,0,10" />
                <CheckBox Content="{DynamicResource String_PortScannerProfiles}" IsEnabled="{Binding PortScannerProfilesExists}" IsChecked="{Binding ExportPortScannerProfiles}" Margin="0,0,0,10" />
                <CheckBox Content="{DynamicResource String_PingProfiles}" IsEnabled="{Binding PingProfilesExists}" IsChecked="{Binding ExportPingProfiles}" Margin="0,0,0,10" />
                <CheckBox Content="{DynamicResource String_TracerouteProfiles}" IsEnabled="{Binding TracerouteProfilesExists}" IsChecked="{Binding ExportTracerouteProfiles}" Margin="0,0,0,10" />
                <CheckBox Content="{DynamicResource String_RemoteDesktopSessions}" IsEnabled="{Binding RemoteDesktopSessionsExists}" IsChecked="{Binding ExportRemoteDesktopSessions}" Margin="0,0,0,10" />
                <CheckBox Content="{DynamicResource String_PuTTYSessions}" IsEnabled="{Binding PuTTYSessionsExists}" IsChecked="{Binding ExportPuTTYSessions}" Margin="0,0,0,10" />
                <CheckBox Content="{DynamicResource String_WakeOnLANClients}" IsEnabled="{Binding WakeOnLANClientsExists}" IsChecked="{Binding ExportWakeOnLANClients}" />
            </StackPanel>
        </GroupBox>
        <Button Content="{DynamicResource String_Button_Export}" Command="{Binding ExportSettingsCommand}" HorizontalAlignment="Left">
            <Button.Style>
                <Style TargetType="{x:Type Button}" BasedOn="{StaticResource DefaultButton}">
                    <Setter Property="IsEnabled" Value="False" />
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ExportEverything}" Value="True">
                            <Setter Property="IsEnabled" Value="True" />
                        </DataTrigger>
                        <DataTrigger Value="True">
                            <DataTrigger.Binding>
                                <MultiBinding Converter="{StaticResource ValidateSettingsExportConverter}">
                                    <Binding Path="ExportEverything" />
                                    <Binding Path="ExportApplicationSettings" />                                    
                                    <Binding Path="ExportNetworkInterfaceProfiles" />
                                    <Binding Path="ExportIPScannerProfiles" />
                                    <Binding Path="ExportPingProfiles" />
                                    <Binding Path="ExportTracerouteProfiles" />
                                    <Binding Path="ExportPortScannerProfiles" />
                                    <Binding Path="ExportRemoteDesktopSessions" />
                                    <Binding Path="ExportPuTTYSessions" />
                                    <Binding Path="ExportWakeOnLANClients" />
                                </MultiBinding>
                            </DataTrigger.Binding>
                            <Setter  Property="IsEnabled" Value="True" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Button.Style>
        </Button>
    </StackPanel>
</UserControl>
