<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<UIX 
  xmlns="http://schemas.microsoft.com/2007/uix"
  xmlns:iris="assembly://UIX/Microsoft.Iris"
  xmlns:styles="res://ZuneShellResources!Styles.uix"
  xmlns:me="Me">

  <UI Name="Default">
    <Content>
      <me:CheckBox>
        <Model>
          <iris:BooleanChoice Description="Hello"/>
        </Model>
      </me:CheckBox>
    </Content>
  </UI>

  <UI Name="CheckBox">
    <Properties>
      
      <iris:BooleanChoice Name="Model" BooleanChoice="$Required"/>
      <Boolean Name="Available" Boolean="true"/>
      <Boolean Name="WordWrap" Boolean="true"/>
      <Size Name="BoxSize" Size="18,18"/>
      <Boolean Name="KeyInteractive" Boolean="true"/>

      
      <Image Name="BoxFocusImage" Source="res://ZuneShellResources!CheckBoxFocus.png"/>
      <Image Name="BoxNonFocusImage" Source="res://ZuneShellResources!CheckBoxNonFocus.png"/>
      <Image Name="BoxCheckedImage" Source="res://ZuneShellResources!CheckBoxChecked.png"/>
      <Image Name="BoxDisabledImage" Image="res://ZuneShellResources!CheckBoxDisabled.png"/>
      
      
      <Color Name="LabelColor" Color="{styles:Styles.TextActive}"/>
      <Color Name="LabelFocusedColor" Color="{styles:Styles.TextActive}"/>
      <Color Name="LabelHoverColor" Color="{styles:Styles.TextActive}"/>
      <Color Name="LabelPressedColor" Color="{styles:Styles.TextActive}"/>
      <Color Name="LabelDisabledColor" Color="{styles:Styles.TextInactive}"/>

      
      <Font Name="LabelFont" Font="{styles:Styles.StandardSubHeaderText}"/>

      <String Name="AccessibleDescription" String="{null}"/>
    </Properties>

    <Input>
      
      <ClickHandler Name="Clicker" ClickType="LeftMouse, SpaceKey" />
    </Input>

    <Locals>
      <Accessible Name="Accessible"/>
    </Locals>

    <Scripts>
      
      <Script>
        if (!KeyInteractive) Clicker.ClickType = ClickType.LeftMouse;
      </Script>

      <Script>UI.AllowDoubleClicks = false;</Script>

      
      <Script>
        if (Model != null)
        {
          Check.Visible = [Model.Value];
        }
      </Script>

      
      <Script>
        if (Model != null)
        {
          Label.Content = [Model.Description];
        }
      </Script>

      
      <Script>
        [DeclareTrigger(Clicker.Invoked)]
        if (Model != null)
        {
          Model.Value = !Model.Value;
        }
      </Script>

      <Script>
        UI.Enabled = [Available];
      </Script>

      
      <Script>

        if (![UI.FullyEnabled])
        {
          Box.Content = BoxDisabledImage;
          Label.Color = LabelDisabledColor;
          Check.Alpha = 0.5;
        }
        else
        {
            Check.Alpha = 1.0;
            
            if ([Clicker.Clicking])
            {
              Label.Color = LabelPressedColor;
              Box.Content = BoxFocusImage;
            }
            
            else if ([UI.MouseFocus])
            {
              Label.Color = LabelHoverColor;
              Box.Content = BoxFocusImage;
            }
            else if ([UI.KeyFocus])
            {
              Label.Color = LabelFocusedColor;
              Box.Content = BoxFocusImage;
            }
            else
            {
              Label.Color = LabelColor;
              Box.Content = BoxNonFocusImage;
            }
        }
      </Script>

      <Script>
        if ([Accessible.Enabled])
        {
          if (AccessibleDescription != null)
          {
            Accessible.Name = [AccessibleDescription];
          }
          else
          {
            Accessible.Name = [Label.Content];
          }
          
          if (Model != null)
          {
            Accessible.IsChecked = [Model.Value];
          }
          Accessible.Role = AccessibleRole.CheckButton;
        }
      </Script>
    </Scripts>

    <Content>
      <Panel MouseInteractive="true">
        <Layout>
          <FlowLayout Orientation="Horizontal" ItemAlignment="Center"/>
        </Layout>
        <Children>

          
          <Graphic Name="Box" Content="{BoxNonFocusImage}" MaximumSize="{BoxSize}" Layout="Form">
            <Children>

              
              <Graphic Name="Check" Content="{BoxCheckedImage}">
                <LayoutInput>
                  <FormLayoutInput Left="Parent,0" Top="Parent,0"/>
                </LayoutInput>
              </Graphic>

            </Children>
          </Graphic>

          
          <Text Name="Label" Color="{LabelColor}" Font="{LabelFont}" WordWrap="{WordWrap}" Margins="5,0,0,0"/>

        </Children>
      </Panel>
    </Content>
  </UI>

</UIX>
