<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<UIX 
  xmlns="http://schemas.microsoft.com/2007/uix"
  xmlns:iris="assembly://UIX/Microsoft.Iris" 
  xmlns:zune="assembly://ZuneShell/ZuneUI" 
  xmlns:popup="res://ZuneShellResources!Popup.uix" 
  xmlns:dialog="res://ZuneShellResources!Dialog.uix" 
  >
  
  
  

  <UI Name="PopupLayer">
    <Properties>
      <Command Name="MouseDownCommand"/>
      
      
      <Boolean Name="IsModal"/>
    </Properties>
    
    <Input>
      
      <ClickHandler Name="Clicker" ClickType="LeftMouse,RightMouse" Enabled="false"/>
    </Input>

    <Locals>
      <zune:PopupManager Name="PopupManager" PopupManager="{zune:PopupManager.Instance}"/>
      <dialog:Dialog Name="CurrentCodeDialog" Dialog="{null}"/>
    </Locals>

    <Scripts>
      
      <Script>
        bool isModal = [PopupManager.IsModal];

        IsModal = isModal;
        Clicker.Enabled = isModal;
        ModalLayer.Visible = isModal;
        
        
        UI.KeyInteractive = isModal;
      </Script>
      
      
      <Script>
        if ([PopupManager.PendingCodeDialogs.Count] > 0 &amp;&amp; [CurrentCodeDialog] == null)
        {
          zune:DialogHelper info = (zune:DialogHelper)PopupManager.PendingCodeDialogs.get_Item(0);
          PopupManager.PendingCodeDialogs.RemoveAt(0);
          
          CurrentCodeDialog = new dialog:Dialog();
          CurrentCodeDialog.ContentUI = info.ContentUI;
          CurrentCodeDialog.Helper = info;
          CurrentCodeDialog.Helper.Show(CurrentCodeDialog);
        }
      </Script>
      
      
      <Script>
        if (CurrentCodeDialog != null &amp;&amp; ![CurrentCodeDialog.Helper.IsVisible])
        {
          UI.DisposeOwnedObject(CurrentCodeDialog);
          CurrentCodeDialog = null;
        }
      </Script>
      
      
      <Script>
        [DeclareTrigger(MouseDownCommand.Invoked)]

        PopupManager.NotifyMouseDown();
      </Script>

      
      <Script>
        if (![iris:Application.Window.Active])
        {
          PopupManager.NotifyWindowDeactivated();
        }
      </Script>
    </Scripts>
    
    <Content>
      
      <Panel Navigation="ContainAll,WrapAll">
        <Layout>
          <DockLayout DefaultLayoutInput="Client,Fill"/>
        </Layout>
        <Children>

          <Repeater Layout="Popup" Source="{PopupManager.Popups}">
            <Content>
              <popup:PopupHost 
                Popup="{(popup:Popup)(((zune:PopupHelper)RepeatedItem).Popup)}" 
                LayoutInput="{((popup:Popup)(((zune:PopupHelper)RepeatedItem).Popup)).LayoutInput}"/>
            </Content>
          </Repeater>

          <Panel Name="ModalLayer" Visible="true" MouseInteractive="true"/>

        </Children>
      </Panel>

    </Content>
  </UI>
  
</UIX> 
