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

<!--
This is the master template for standard menu screens:
A header text, left the menu, under the menu a small video preview,
at the right side the content pane and at the bottom the current play control.

Usage:

  <Include
      xmlns="www.team-mediaportal.com/2008/mpf/directx"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Source="screens\master_menu.xaml">
    <Include.Resources>
      <ResourceWrapper x:Key="Header_Text">
        [Header text]
      </ResourceWrapper>
      <ControlTemplate x:Key="Contents_Template">
        [UI element to be displayed in the content 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
 - Contents_Template (ConrolTemplate): Template for element to be displayed
   in the content area at the right side
-->

<Include
    xmlns="www.team-mediaportal.com/2008/mpf/directx"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Source="screens\master_bare.xaml"
    xmlns:mp_special_controls="clr-namespace:MediaPortal.UI.SkinEngine.SpecialElements.Controls;assembly=SkinEngine"
    >
  <Include.Resources>
    <!-- Defines the default margins for the content area -->
    <ResourceWrapper x:Key="DefaultContentMargin" Resource="-30,-170,-10,-120" />

    <!-- Header has to be defined by the includer: "Header_Text" -->

    <!-- Client_Template -->
    <ControlTemplate x:Key="Client_Template">
      <Border x:Name="ContentBackground" Margin="{StaticResource DefaultContentMargin}" >
        <Border.Background>
          <ImageBrush ImageSource="panel_settings.png" />
        </Border.Background>
        <DockPanel LastChildFill="True">
          <Grid x:Name="LeftPanel" DockPanel.Dock="Left" VerticalAlignment="Stretch" Margin="80,75,0,70">
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="450"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
              <RowDefinition Height="Auto"/>
              <RowDefinition Height="*"/>
              <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.Resources>
              <Model x:Key="MenuModel" Id="9E9D0CD9-4FDB-4c0f-A0C4-F356E151BDE0"/>
            </Grid.Resources>

            <ListView x:Name="MainMenu" Grid.Column="0" Grid.Row="1" Style="{ThemeResource MainMenuListViewStyle}"
              HorizontalAlignment="Stretch" VerticalAlignment="Stretch" SetFocusPrio="Default"
              ItemsSource="{Binding Source={StaticResource MenuModel},Path=MenuItems,Mode=OneTime}">
              <ListView.Resources>
                <CommandBridge x:Key="Menu_Command" Command="{Binding Path=Command,Mode=OneTime}"/>
              </ListView.Resources>
            </ListView>
          </Grid>

          <!-- Order matters here: The content grid has to be the last control to fill the rest of the space -->
          <Grid x:Name="ContentPanel" SetFocusPrio="DefaultHigh" Margin="60,70,70,60">
            <Grid.ColumnDefinitions>
              <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
              <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <!-- Border is placed as single element here without children, because OpacityMask would apply to them too -->
            <!--<Border x:Name="ContentBorder" Grid.Row="0" Grid.Column="0" Margin="10,0,10,10"
              VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
              IsVisible="{Binding ElementName=ContentControl,Path=Template,Converter={StaticResource ReferenceToBoolConverter}}"
              BorderBrush="{ThemeResource ContentBorderBrush}" 
              BorderThickness="{ThemeResource ContentBorderThickness}" 
              CornerRadius="{ThemeResource ContentBorderCornerRadius}"
              OpacityMask="{ThemeResource ContentBorderOpacityMask}"
              Background="Black"/>-->

            <Control x:Name="ContentControl" Template="{DynamicResource ResourceKey=Contents_Template}"
              IsVisible="{Binding ElementName=ContentControl,Path=Template,Converter={StaticResource ReferenceToBoolConverter}}"
              Grid.Row="0" Grid.Column="0" Margin="15,5,15,15"/>

            <Control x:Name="AlternativeContentControl" Grid.Row="0" Grid.Column="0"
             VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
             Template="{DynamicResource ResourceKey=Alternative_Contents_Template}"
             IsVisible="{Binding RelativeSource={RelativeSource Self},Path=Template,Converter={StaticResource ReferenceToBoolConverter}}"/>
          </Grid>
        </DockPanel>
      </Border>
    </ControlTemplate>

  </Include.Resources>
</Include>
