<mah:MetroWindow x:Class="Deployer.Raspberry.Gui.Views.MainWindow"
                 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:parts="clr-namespace:Deployer.Lumia.Gui.Views.Parts"
                 xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
                 xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
                 xmlns:advanced="clr-namespace:Deployer.Lumia.Gui.Views.Parts.Advanced"
                 xmlns:parts1="clr-namespace:Deployer.Raspberry.Gui.Views.Parts"
                 xmlns:viewModels1="clr-namespace:Deployer.Raspberry.Gui.ViewModels"
                 mc:Ignorable="d"
                 DataContext="{Binding Source={StaticResource Locator}, Path=MainViewModel}"
                 mah:DialogParticipation.Register="{Binding}"
                 Title="{Binding Title}" 
                 Icon="/Assets/appicon.png"
                 WindowStartupLocation="CenterScreen" Closing="MainWindow_OnClosing">
    <Window.Resources>
        <DataTemplate DataType="{x:Type viewModels1:DeploymentViewModel}">
            <parts1:DeploymentPart />
        </DataTemplate>
        <DataTemplate DataType="{x:Type viewModels1:AdvancedViewModel}">
            <advanced:AdvancedPart />
        </DataTemplate>
    </Window.Resources>    
    <mah:MetroWindow.RightWindowCommands>
        <mah:WindowCommands>
            <Button Command="{Binding HelpCommand}" ToolTip="Do you need help?">
                <StackPanel Orientation="Horizontal">
                    <iconPacks:PackIconMaterial Kind="Help" />
                    <TextBlock Margin="4 0 0 0" VerticalAlignment="Center" Text="Help" />
                </StackPanel>
            </Button>
            <Button Command="{Binding DonateCommand}" ToolTip="Please, support this tool. Thanks in advance :)"
                    Padding="10,5,10,5"
                    Opacity="1">
                <Button.Content>
                    <StackPanel Orientation="Horizontal">
                        <Image Height="16" VerticalAlignment="Center" Source="/Assets/heart.png" RenderOptions.BitmapScalingMode="HighQuality" />
                        <TextBlock Margin="8 0 0 0" VerticalAlignment="Center" Text="Donate" />
                    </StackPanel>
                </Button.Content>
            </Button>
        </mah:WindowCommands>
    </mah:MetroWindow.RightWindowCommands>
    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <TabControl Margin="20" Grid.Row="1" Focusable="False"
                    ItemsSource="{Binding Sections}"
                    SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                    IsHitTestVisible="{Binding IsBusy, Converter={StaticResource BoolNegationConverter}}">
            <TabControl.ItemContainerStyle>
                <Style TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}">
                    <Setter Property="Header" Value="{Binding Converter={StaticResource MetadataConverter}, ConverterParameter='Name'}" />
                    <!-- ReSharper disable once Xaml.BindingWithContextNotResolved -->
                    <Setter Property="Content" Value="{Binding Value}" />
                </Style>
            </TabControl.ItemContainerStyle>            
        </TabControl>

        <Grid Grid.Row="1" Visibility="{Binding IsBigProgressVisible, Converter={StaticResource BooleanToVisibilityConverter}}">
            <parts:ProgressPart VerticalAlignment="Center" Margin="0 80 0 0" />
        </Grid>
        
        <Expander Grid.Row="2" Header="Log" IsExpanded="False" MaxHeight="400">
            <parts1:LogPart />
        </Expander>
    </Grid>
</mah:MetroWindow>