<?xml version="1.0" encoding="utf-8"?>

<!--
This is the master template for all screens:
A header text, player controls and a client area.
Below the client area, the navigation bar is visible.

Usage:

  <Include
      xmlns="www.team-mediaportal.com/2008/mpf/directx"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Source="screens\master_bare.xaml">
    <Include.Resources>
      <ResourceWrapper x:Key="Header_Text">
        [Header text]
      </ResourceWrapper>
      <ControlTemplate x:Key="Client_Template">
        [UI element to be displayed in the client area]
      </ControlTemplate>
    </Include.Resources>
  </Include>

Parameters which have to be accessible by a DynamicResource lookup:
 - Header_Text (String): The text to be displayed as header
 - Client_Template (ConrolTemplate): Template for element to be shown in the client area.
-->
<Screen
    xmlns="www.team-mediaportal.com/2008/mpf/directx"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mp_special_workflow="clr-namespace:MediaPortal.UI.SkinEngine.SpecialElements.Workflow;assembly=SkinEngine"
    xmlns:mp_special_controls="clr-namespace:MediaPortal.UI.SkinEngine.SpecialElements.Controls;assembly=SkinEngine"
    xmlns:bvc="clr-namespace:MediaPortal.UiComponents.BlueVision.Converters;assembly=BlueVision"
    xmlns:bvm="clr-namespace:MediaPortal.UiComponents.BlueVision.Models;assembly=BlueVision"
    xmlns:bgm="clr-namespace:MediaPortal.UiComponents.BackgroundManager.Converter;assembly=BackgroundManager"
    mp_special_workflow:WorkflowContext.StateSlot="Root"
    x:Name="Screen"
    >
  <Canvas Width="1920" Height="1080">
    <Canvas.Resources>
      <Model x:Key="MouseModel" Id="CA6428A7-A6E2-4dd3-9661-F89CEBAF8E62"/>
      <Model x:Key="HomeServerModel" Id="854ABA9A-71A1-420b-A657-9641815F9C01"/>
      <Model x:Key="TimeModel" Id="E821B1C8-0666-4339-8027-AA45A4F6F107"/>
      <Model x:Key="MenuModel" Id="A6C6D5DA-55FE-4b5f-AE83-B03E8BBFA177"/>
      <Model x:Key="CurrentWeatherModel" Id="FC57FF5C-F72F-47E9-B973-338E31FF7FF1"/>
      <Model x:Key="BackgroundManagerModel" Id="1F4CAEDE-7108-483d-B5C8-18BEC7EC58E5"/>
    </Canvas.Resources>

    <!--Image Canvas.Left="0" Canvas.Top="0" Width="1920" Height="150" Source="groupmenu_fade.png" Stretch="Fill"
        IsVisible="{Binding Source={StaticResource MenuModel},Path=IsHomeScreen}"/-->
    
    <Grid x:Name="HeaderPanel" Canvas.Top="0" Canvas.Left="0" Width="1920">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/> <!-- NavBar -->
        <ColumnDefinition Width="Auto"/> <!-- Weather -->
        <ColumnDefinition Width="Auto"/> <!-- Time -->
      </Grid.ColumnDefinitions>

      <!--mp_special_controls:WorkflowNavigationBar Grid.Column="0" Grid.Row="0" Style="{ThemeResource NewWorkflowNavigationBarStyle}"
            VerticalAlignment="Center" Margin="40,0,0,0" IsVisible="{Binding Source={StaticResource MouseModel},Path=IsMouseUsed}"/-->
      <Grid Grid.Row="0" Height="7" IsVisible="{Binding Source={StaticResource MenuModel},Path=IsHomeScreen}" />
     
      <Image Grid.Row="1" Grid.RowSpan="2" Grid.Column="2" x:Name="BigIcon" Stretch="Uniform" Height="100" 
             Source="{Binding Source={StaticResource CurrentWeatherModel}, Path=CurrentLocation.Condition.BigIconProperty}" 
             IsVisible="{Binding UseInHome}" HorizontalAlignment="Right" Margin="0,0,60,0"/>

      <Label x:Name="TimeLabel" Content="{Binding Source={StaticResource TimeModel}, Path=CurrentTime}" Grid.Column="1" Grid.Row="1" Margin="0,10,10,0"
             FontSize="{ThemeResource DialogTitleFontSize}" FontFamily="Titan"
             Color="{ThemeResource TextColor}" VerticalAlignment="Center" HorizontalAlignment="Right"/>

      <StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="2" Margin="0,-20,10,0">
        <Label x:Name="DateLabel" Content="{Binding Source={StaticResource TimeModel}, Path=CurrentDate}" FontFamily="TitanBold"
               Color="{ThemeResource TextColor}" VerticalAlignment="Center" HorizontalAlignment="Right"/>
        <Label x:Name="PlaceHolder" Content=" / " FontFamily="TitanBold" Color="{ThemeResource TextColor}" 
               VerticalAlignment="Center" HorizontalAlignment="Right"/>
        <Label x:Name="Temp" Content="{Binding Source={StaticResource CurrentWeatherModel}, Path=CurrentLocation.Condition.Temperature}"
               FontFamily="TitanBold" Color="{ThemeResource TextColor}" IsVisible="{Binding UseInHome}"
               VerticalAlignment="Center" HorizontalAlignment="Right"/>
      </StackPanel>

    </Grid>    <!-- HeaderPanel -->

    <Image Canvas.Left="20" Canvas.Top="300" Width="1880" Height="740" Stretch="Fill" Source="panel_thumbs_noinfo.png" Opacity="1"
           IsVisible="{Binding Source={StaticResource MenuModel},Path=IsHomeScreen}"/>
 
        <!--Image Canvas.Left="60" Canvas.Top="950" Width="1820" Height="91" Stretch="Fill" Source="info_bar.png" Opacity="1"
           IsVisible="{Binding Source={StaticResource MenuModel},Path=!IsHomeScreen}"/-->

    <Grid Canvas.Left="50" Canvas.Top="980" Width="1824" IsVisible="{Binding Source={StaticResource MenuModel},Path=IsHomeScreen}">
      <Grid.RowDefinitions>
        <RowDefinition Height="100"/>
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>     
      <Label x:Name="HeaderLabel" Margin="0,6,0,0"  VerticalAlignment="Top" HorizontalAlignment="Center"
            FontSize="{ThemeResource BigFontSize}" Color="{ThemeResource WindowHeaderColor}"
            Content="{Binding Source={DynamicResource Header_Text},Path=Resource}" />
      <Control x:Name="AlternativeHeaderControl" 
             VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
             Template="{DynamicResource ResourceKey=Alternative_Header_Template}"
             IsVisible="{Binding RelativeSource={RelativeSource Self},Path=Template,Converter={StaticResource ReferenceToBoolConverter}}"/>
    </Grid>
    
    <Grid Width="800" Canvas.Top="20" Canvas.Left="60" IsVisible="{Binding Source={StaticResource MenuModel},Path=IsHomeScreen}">
      <Label x:Name="SelectedItem"
          Content="{Binding Source={StaticResource MenuModel}, Path=LastSelectedItemName}"
          VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="{ThemeResource HeaderFontSize}" FontFamily="Titan"
          Color="{ThemeResource TextColor}">
      </Label>
    </Grid>
    
    <Grid Canvas.Left="50" Canvas.Top="15" Width="1824" IsVisible="{Binding Source={StaticResource MenuModel},Path=!IsHomeScreen}">
      <Grid.RowDefinitions>
        <RowDefinition Height="100"/>
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>
      
      <StackPanel Margin="0" Orientation="Horizontal">
        <Image VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="Uniform">
          <Image.Source>
            <MultiBinding Converter="{StaticResource ExpressionMultiValueConverter}" ConverterParameter="{}{0} + {1}">
              <Binding Path="{Binding Source={DynamicResource Header_Text},Path=Resource}"/>
              <Binding Source=".png"/>
            </MultiBinding>
            <!--Binding Path="{Binding Source={DynamicResource Header_Text},Path=Resource}" Converter="{StaticResource StringFormatConverter}" ConverterParameter="{}{0}.png"/-->
          </Image.Source>
        </Image>
        <Label x:Name="HeaderLabel_" Margin="10,0,0,0"  VerticalAlignment="Top" HorizontalAlignment="Left"
              FontSize="{ThemeResource HeaderFontSize}" Color="{ThemeResource WindowHeaderColor}"
              Content="{Binding Source={DynamicResource Header_Text},Path=Resource}" />
      </StackPanel>
      
      <Control x:Name="AlternativeHeaderControl_"
             VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
             Template="{DynamicResource ResourceKey=Alternative_Header_Template}"
             IsVisible="{Binding RelativeSource={RelativeSource Self},Path=Template,Converter={StaticResource ReferenceToBoolConverter}}"/>
    </Grid>

    <Control x:Name="ClientArea" Height="580" Width="1795" Canvas.Left="66" Canvas.Bottom="952"
             Template="{DynamicResource ResourceKey=Client_Template}"/>

    <Grid Canvas.Top="-32" Canvas.Left="0" Width="1920" Height="120" IsVisible="{Binding Source={StaticResource MenuModel},Path=IsHomeScreen}">
      <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
      </Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>
      <Grid Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center">
        <Border Name="mask" Background="#99000000" CornerRadius="23"/>
        <bvm:GroupMenuListView x:Name="GroupList" Style="{ThemeResource HomeGroupListViewStyle}"
                              VerticalAlignment="Center" HorizontalAlignment="Center"
                              HomeMenuModel="{StaticResource MenuModel}" Margin="20,30,0,0" FontFamily="Titan" 
                              ItemsSource="{Binding Source={StaticResource MenuModel},Path=MainMenuGroupList,Mode=OneTime}"
                              SelectionChanged="{CommandStencil Source={StaticResource MenuModel},Path=OnGroupItemSelectionChanged}">
         <bvm:GroupMenuListView.Resources>
           <CommandBridge x:Key="Menu_Command" Command="{Binding Path=Command,Mode=OneTime}"/>
         </bvm:GroupMenuListView.Resources>
        </bvm:GroupMenuListView>
      </Grid>
    </Grid>
    
    <!-- Player controls, located on top but drawn as last item so it overlays other content, if present-->    
    <Grid Canvas.Left="350" Canvas.Top="120" Width="1220">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
      </Grid.ColumnDefinitions>

      <StackPanel x:Name="PlayerControls" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Top">

        <mp_special_controls:PlayerControl x:Name="PrimaryPC" Margin="0,0,10,0" Style="{ThemeResource NewNavigationScreenPlayerControlStyle}" Width="570"
                HorizontalAlignment="Center" VerticalAlignment="Top"
                AutoVisibility="True" PlayerContext="PrimaryPlayer"/>

        <mp_special_controls:PlayerControl x:Name="SecondaryPC" Margin="10,0,0,0" Style="{ThemeResource NewNavigationScreenPlayerControlStyle}" Width="570"
                HorizontalAlignment="Center" VerticalAlignment="Top" 
                AutoVisibility="True" PlayerContext="SecondaryPlayer"/>
      </StackPanel>
    </Grid>

    <!-- Notification icon needs also be placed after the main content area, so it will be on top and can be clicked -->
    <Control Canvas.Left="1800" Canvas.Top="130" Style="{ThemeResource NotificationControlStyle}"
            HorizontalAlignment="Right" VerticalAlignment="Center"/>

  </Canvas>
</Screen>