<Window x:Class="Valg.EVA.Skanning.UserInterfaceElements.MessageBox.MessageBox"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:messageBox1="clr-namespace:Valg.EVA.Skanning.UserInterfaceElements.MessageBox"
        xmlns:system="clr-namespace:System;assembly=mscorlib"
        xmlns:converter="clr-namespace:Valg.EVA.Skanning.Assets.Converter;assembly=Valg.EVA.Skanning.Assets"
        mc:Ignorable="d"
        d:DataContext="{d:DesignInstance d:Type=messageBox1:MessageBoxViewModel}"
        WindowStartupLocation="CenterOwner"
        SizeToContent="WidthAndHeight"
        Style="{DynamicResource Window}"
        Title="{Binding TitleText}"
        MinWidth="600">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Valg.EVA.Skanning.Assets;component/ResourceDictionaries/ResourceLibrary.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <Style TargetType="Window" x:Key="Window">
                <Setter Property="BorderBrush" Value="#4C6E1E" />
                <Setter Property="BorderThickness" Value="4px" />
                <Setter Property="WindowStyle" Value="None" />
                <Setter Property="ResizeMode" Value="NoResize" />
                <Setter Property="MaxHeight" Value="800" />
                <Setter Property="MaxWidth" Value="800" />
                <Setter Property="SnapsToDevicePixels" Value="True"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding MessageBoxType}" Value="Warning">
                        <Setter Property="BorderBrush" Value="#F26700" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding MessageBoxType}" Value="Error">
                        <Setter Property="BorderBrush" Value="#C21A26" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding MessageBoxType}" Value="Information">
                        <Setter Property="BorderBrush" Value="#4C6E1E" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </ResourceDictionary>
    </Window.Resources>

    <DockPanel Margin="30" FocusManager.FocusedElement="{Binding ElementName=CloseButton}">
        <ScrollViewer MaxHeight="600" MaxWidth="800" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" DockPanel.Dock="Top">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="60" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBlock Grid.Column="0" Grid.Row="0" Style="{DynamicResource MessageBoxIcon}" />
                <TextBlock Grid.Column="1" Grid.Row="0" TextWrapping="Wrap"  Style="{StaticResource TextBlockLargeHeader}" Text="{Binding TitleText}" />
                <TextBlock Margin="0,10,0,10" TextWrapping="Wrap" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" Style="{StaticResource TextBlockNormal}" Text="{Binding MessageText}" />
                <TextBlock Visibility="{Binding HasPossibleSolutions, Converter={StaticResource BooleanToVisibilityConverter}}" Margin="0,10,0,10" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" Style="{StaticResource TextBlockMediumHeader}" Text="{Binding LanguageString.Label_ErrorWhatCanBeDone}" />
                <ItemsControl Visibility="{Binding HasPossibleSolutions, Converter={StaticResource BooleanToVisibilityConverter}}" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2" ItemsSource="{Binding PossibleSolutionList}" IsTabStop="False">
                    <ItemsControl.Resources>
                        <DataTemplate DataType="{x:Type system:String}">
                            <BulletDecorator Width="Auto" Margin="10,0,0,0">
                                <BulletDecorator.Bullet>
                                    <Ellipse Fill="Black" Width="5" Height="5" />
                                </BulletDecorator.Bullet>
                                <TextBlock Style="{StaticResource TextBlockNormal}" Text="{Binding}" Margin="10,0,0,0" TextWrapping="Wrap" />
                            </BulletDecorator>
                        </DataTemplate>

                        <DataTemplate DataType="{x:Type messageBox1:ErrorSolutionWithCommand}">
                            <BulletDecorator Width="Auto" Margin="10,0,0,0">
                                <BulletDecorator.Bullet>
                                    <Ellipse Fill="Black" Width="5" Height="5" />
                                </BulletDecorator.Bullet>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Style="{StaticResource TextBlockNormal}" Text="{Binding SolutionText}" Margin="10,0,0,0" TextWrapping="Wrap" />
                                    <Button Content="{Binding CommandText}" Command="{Binding Command}" Style="{StaticResource LinkButtonNormal}"/>
                                </StackPanel>
                            </BulletDecorator>
                        </DataTemplate>
                    </ItemsControl.Resources>
                </ItemsControl>
            </Grid>
        </ScrollViewer>

        <StackPanel Visibility="{Binding ShowTechnicalDetails, Converter={StaticResource BooleanToVisibilityConverter}}" DockPanel.Dock="Bottom">
            <Button 
                HorizontalAlignment="Left" 
                Style="{StaticResource LinkButtonNormal}" 
                Command="{Binding ToggleViewTechnicalDataCommand}"
                Content="{Binding ShowTechnicalDetailButtonText}"/>
            <ScrollViewer MaxHeight="200" MaxWidth="800" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
                <TextBox 
                    Margin="0, 5, 0, 0"
                    Background="Transparent" 
                    BorderThickness="0" 
                    TextWrapping="Wrap" 
                    Text="{Binding TechnicalErrorMessage}" 
                    Visibility="{Binding ShowTechnicalErrorMessage, Converter={StaticResource BooleanToVisibilityConverter}}"/>
            </ScrollViewer>
        </StackPanel>

        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
            <StackPanel.Resources>
                <converter:BooleanToStyleConverter x:Key="cancelOrCloseButtonStyleConverter" 
                                                   True="{StaticResource RedButtonCancel}"
                                                   False="{StaticResource BlueButton}" />
            </StackPanel.Resources>
            <Button 
                Style="{StaticResource BlueButtonOk}"
                Height="49px"
                MinWidth="120"
                TabIndex="1"
                HorizontalAlignment="Right"
                Command="{Binding ConfirmCommand}"
                Margin="0, 30, 30, 0"
                x:Name="ConfirmButton"
                Content="{Binding ConfirmCommandButtonText, FallbackValue='Ok'}"
                DockPanel.Dock="Bottom"
                Visibility="{Binding ShowConfirmButton, Converter={StaticResource BooleanToVisibilityConverter}}">
            </Button>
            <Button Style="{Binding ShowConfirmButton, Converter={StaticResource cancelOrCloseButtonStyleConverter}}"
                Height="49px"
                TabIndex="0"
                MinWidth="115"
                HorizontalAlignment="Right"
                Command="{Binding CancelCommand}"
                Margin="0, 30, 0, 0"
                x:Name="CloseButton"
                Content="{Binding CancelCommandButtonText, FallbackValue='Close'}"
                DockPanel.Dock="Bottom">
            </Button>
        </StackPanel>
    </DockPanel>
</Window>
