<!-- Top level template for appified web algo that provides custom activation behaviour -->
<!-- The underlying serp grid has the following cell size in various view modes  
     The number is [item size] + [extra margin]
        =========================================================
        |    View Mode          |   Cell Width  |  Cell Height  |
        =========================================================
        |   Horizontal          |   400 + 10    |   300         |
        |   Horizontal Large    |   400 + 20    |   300         |
        |   Vertical            |   490         |   20          |
        |   Verical Large       |   630         |   20          |
        |   Vertical Narrow     |   320         |   20          |
        =========================================================
    
    This layout template sets the content control to the following sizes for different view modes
    The size occupied by the content control is shown below as determined by the row span and column span set on the content control
        ======================================================================================
        |    View Mode          |   Content Width           |  Content Height                |
        |                       |  [cell width x col span]  |  [cell height x row span]      |
        ======================================================================================
        |   Horizontal          |   410 x 1 = 410           |   300 x  2 = 600               |
        |   Horizontal Large    |   420 x 1 = 420           |   300 x  3 = 900               |
        |   Vertical            |   490 x 1 = 490           |    20 x 12 = 240               |
        |   Verical Large       |   630 x 1 = 630           |    20 x 15 = 300 = (280 + 20)  |
        |   Vertical Narrow     |   320 x 1 = 320           |    20 x 12 = 240               |
        ======================================================================================
    -->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:tm="using:SearchUI.TemplateManager"
                    xmlns:sc="using:SearchUI.Controls"
                    x:Key="Web.AppifiedAlgo_Home_8_1_RTM">
    <!-- The activation for the top level tile varies based on app install state
            -If app is not installed then top level tile will launch web url
            -If app is installed then top level launches the app
            -If app upgrade is required then top level launches the app store for upgrade
    -->
    <tm:SwitchCaseConverter x:Key="Local.InstallStateActivationConverter"
                            Default="System_ConnectedSearch_ActivateCommand">
        <tm:SwitchCase Case="0"
                       Value="System_ConnectedSearch_ActivateCommand" />
        <tm:SwitchCase Case="1"
                       Value="Extended:appButton.System_ConnectedSearch_ActivateCommand" />
        <tm:SwitchCase Case="2"
                       Value="System_ConnectedSearch_ActivateCommand" />
    </tm:SwitchCaseConverter>

    <Style x:Key="Horizontal"
           TargetType="sc:ResultGridViewItem"
           BasedOn="{CustomResource Resources.Shared.SerpGridViewItem.Horizontal}">
        <Setter Property="VariableSizedWrapGrid.ColumnSpan"
                Value="1" />
        <Setter Property="VariableSizedWrapGrid.RowSpan"
                Value="2" />
        <Setter Property="tm:SetterBinding.Setters">
            <Setter.Value>
                <SetterBaseCollection>
                    <Setter Property="ActivationOverridePath">
                        <Setter.Value>
                            <tm:SetterBinding Path="Extended:appButton.System_ConnectedSearch_AppInstalledState"
                                              Converter="{StaticResource Local.InstallStateActivationConverter}" />
                        </Setter.Value>
                    </Setter>
                    <Setter Property="AutomationProperties.AutomationId">
                        <Setter.Value>
                            <tm:SetterBinding Path="Extended:automation.Extended:Id" />
                        </Setter.Value>
                    </Setter>
                    <Setter Property="AutomationProperties.Name">
                        <Setter.Value>
                            <tm:SetterBinding Path="System_ItemNameDisplay" />
                        </Setter.Value>
                    </Setter>
                </SetterBaseCollection>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="HorizontalLarge"
           TargetType="sc:ResultGridViewItem"
           BasedOn="{CustomResource Resources.Shared.SerpGridViewItem.HorizontalLarge}">
        <Setter Property="VariableSizedWrapGrid.ColumnSpan"
                Value="1" />
        <Setter Property="VariableSizedWrapGrid.RowSpan"
                Value="3" />
        <Setter Property="tm:SetterBinding.Setters">
            <Setter.Value>
                <SetterBaseCollection>
                    <Setter Property="ActivationOverridePath">
                        <Setter.Value>
                            <tm:SetterBinding Path="Extended:appButton.System_ConnectedSearch_AppInstalledState"
                                              Converter="{StaticResource Local.InstallStateActivationConverter}" />
                        </Setter.Value>
                    </Setter>
                    <Setter Property="AutomationProperties.AutomationId">
                        <Setter.Value>
                            <tm:SetterBinding Path="Extended:automation.Extended:Id" />
                        </Setter.Value>
                    </Setter>
                    <Setter Property="AutomationProperties.Name">
                        <Setter.Value>
                            <tm:SetterBinding Path="System_ItemNameDisplay" />
                        </Setter.Value>
                    </Setter>
                </SetterBaseCollection>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="Vertical"
           TargetType="sc:ResultGridViewItem"
           BasedOn="{CustomResource Resources.Shared.SerpGridViewItem.Vertical}">
        <Setter Property="VariableSizedWrapGrid.ColumnSpan"
                Value="1" />
        <Setter Property="VariableSizedWrapGrid.RowSpan"
                Value="12" />
        <Setter Property="tm:SetterBinding.Setters">
            <Setter.Value>
                <SetterBaseCollection>
                    <Setter Property="ActivationOverridePath">
                        <Setter.Value>
                            <tm:SetterBinding Path="Extended:appButton.System_ConnectedSearch_AppInstalledState"
                                              Converter="{StaticResource Local.InstallStateActivationConverter}" />
                        </Setter.Value>
                    </Setter>
                    <Setter Property="AutomationProperties.AutomationId">
                        <Setter.Value>
                            <tm:SetterBinding Path="Extended:automation.Extended:Id" />
                        </Setter.Value>
                    </Setter>
                    <Setter Property="AutomationProperties.Name">
                        <Setter.Value>
                            <tm:SetterBinding Path="System_ItemNameDisplay" />
                        </Setter.Value>
                    </Setter>
                </SetterBaseCollection>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="VerticalLarge"
           TargetType="sc:ResultGridViewItem"
           BasedOn="{CustomResource Resources.Shared.SerpGridViewItem.VerticalLarge}">
        <Setter Property="VariableSizedWrapGrid.ColumnSpan"
                Value="1" />
        <Setter Property="VariableSizedWrapGrid.RowSpan"
                Value="15" />
        <Setter Property="tm:SetterBinding.Setters">
            <Setter.Value>
                <SetterBaseCollection>
                    <Setter Property="ActivationOverridePath">
                        <Setter.Value>
                            <tm:SetterBinding Path="Extended:appButton.System_ConnectedSearch_AppInstalledState"
                                              Converter="{StaticResource Local.InstallStateActivationConverter}" />
                        </Setter.Value>
                    </Setter>
                    <Setter Property="AutomationProperties.AutomationId">
                        <Setter.Value>
                            <tm:SetterBinding Path="Extended:automation.Extended:Id" />
                        </Setter.Value>
                    </Setter>
                    <Setter Property="AutomationProperties.Name">
                        <Setter.Value>
                            <tm:SetterBinding Path="System_ItemNameDisplay" />
                        </Setter.Value>
                    </Setter>
                </SetterBaseCollection>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="VerticalNarrow"
           TargetType="sc:ResultGridViewItem"
           BasedOn="{CustomResource Resources.Shared.SerpGridViewItem.VerticalNarrow}">
        <Setter Property="VariableSizedWrapGrid.ColumnSpan"
                Value="1" />
        <Setter Property="VariableSizedWrapGrid.RowSpan"
                Value="12" />
        <Setter Property="tm:SetterBinding.Setters">
            <Setter.Value>
                <SetterBaseCollection>
                    <Setter Property="ActivationOverridePath">
                        <Setter.Value>
                            <tm:SetterBinding Path="Extended:appButton.System_ConnectedSearch_AppInstalledState"
                                              Converter="{StaticResource Local.InstallStateActivationConverter}" />
                        </Setter.Value>
                    </Setter>
                    <Setter Property="AutomationProperties.AutomationId">
                        <Setter.Value>
                            <tm:SetterBinding Path="Extended:automation.Extended:Id" />
                        </Setter.Value>
                    </Setter>
                    <Setter Property="AutomationProperties.Name">
                        <Setter.Value>
                            <tm:SetterBinding Path="System_ItemNameDisplay" />
                        </Setter.Value>
                    </Setter>
                </SetterBaseCollection>
            </Setter.Value>
        </Setter>
    </Style>
    
</ResourceDictionary>