<!-- 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:style="res://ZuneShellResources!Style.uix"  
  xmlns:button="res://ZuneShellResources!Button.uix"  
  xmlns:me="Me"
  >

  



































































































  <UI Name="Slider">
    <Properties>
      <Image   Name="BackgroundImage" Image="{styles:Styles.SliderBackground}"/>
      <Image   Name="FilledBackgroundImage" Image="{null}"/>
      <Image   Name="ThumbImage" Image="{styles:Styles.SliderThumb}"/>
      <Image   Name="ThumbImageFocus" Image="{styles:Styles.SliderHoverThumb}"/>
      <Int32   Name="ThumbOffset" Int32="4"/>
      <Single  Name="KeyDelta" Single="1.0"/>
      <Single  Name="KeyDeltaShift" Single="0.0"/>
      <Single  Name="KeyDeltaCtrl" Single="0.0"/>
      <Single  Name="KeyDeltaCtrlShift" Single="0.0"/>
      <Single  Name="KeyDeltaPage" Single="1.0"/>

      
      
      <Int32  Name="FillAdjustment" Int32="3"/>

      <Command Name="ValueChanged" Command="{null}"/>
      <Single  Name="UpdateValue"/>

      <Boolean Name="AutoUpdateDuringDrag" Boolean="true"/>
      <Boolean Name="CancelDragOnModelChange" Boolean="true"/>
      <Boolean Name="Dragging"/>
      <Boolean Name="ReadOnly" Boolean="false"/>
      <Boolean Name="DiscreteValues" Boolean="false"/>
      <iris:RangedValue Name="Model" RangedValue="$Required"/>
      <Boolean Name="KeyFocusOnMouseDown" Boolean="true"/>
      <String Name="AccessibleDescription" String="{null}"/>
      <String Name="AccessibleValue" String="{null}"/>
    </Properties>

    <Input>
      <DragHandler Name="Dragger" CancelOnEscape="true"/>

      <KeyHandler Name="KH_PGU"   Key="PageUp"   Command="{PageUpValue}"               DisallowedModifiers="Ctrl,Shift,Alt,Windows"/>
      <KeyHandler Name="KH_PGD"   Key="PageDown" Command="{PageDownValue}"             DisallowedModifiers="Ctrl,Shift,Alt,Windows"/>
      <KeyHandler Name="KH_HOM"   Key="Home"     Command="{OnHome}"                    DisallowedModifiers="Ctrl,Shift,Alt,Windows"/>
      <KeyHandler Name="KH_END"   Key="End"      Command="{OnEnd}"                     DisallowedModifiers="Ctrl,Shift,Alt,Windows"/>

      <KeyHandler Name="KH_L"     Key="Left"     Command="{DecrementValue}"            DisallowedModifiers="Ctrl,Shift,Alt,Windows"/>
      <KeyHandler Name="KH_U"     Key="Up"       Command="{IncrementValue}"            DisallowedModifiers="Ctrl,Shift,Alt,Windows"/>
      <KeyHandler Name="KH_R"     Key="Right"    Command="{IncrementValue}"            DisallowedModifiers="Ctrl,Shift,Alt,Windows"/>
      <KeyHandler Name="KH_D"     Key="Down"     Command="{DecrementValue}"            DisallowedModifiers="Ctrl,Shift,Alt,Windows"/>

      <KeyHandler Name="KH_S_L"   Key="Left"     Command="{DecrementValueShift}"       RequiredModifiers="Shift" DisallowedModifiers="Ctrl,Alt,Windows"/>
      <KeyHandler Name="KH_S_U"   Key="Up"       Command="{IncrementValueShift}"       RequiredModifiers="Shift" DisallowedModifiers="Ctrl,Alt,Windows"/>
      <KeyHandler Name="KH_S_R"   Key="Right"    Command="{IncrementValueShift}"       RequiredModifiers="Shift" DisallowedModifiers="Ctrl,Alt,Windows"/>
      <KeyHandler Name="KH_S_D"   Key="Down"     Command="{DecrementValueShift}"       RequiredModifiers="Shift" DisallowedModifiers="Ctrl,Alt,Windows"/>

      <KeyHandler Name="KH_C_L"   Key="Left"     Command="{DecrementValueCtrl}"        RequiredModifiers="Ctrl" DisallowedModifiers="Shift,Alt,Windows"/>
      <KeyHandler Name="KH_C_U"   Key="Up"       Command="{IncrementValueCtrl}"        RequiredModifiers="Ctrl" DisallowedModifiers="Shift,Alt,Windows"/>
      <KeyHandler Name="KH_C_R"   Key="Right"    Command="{IncrementValueCtrl}"        RequiredModifiers="Ctrl" DisallowedModifiers="Shift,Alt,Windows"/>
      <KeyHandler Name="KH_C_D"   Key="Down"     Command="{DecrementValueCtrl}"        RequiredModifiers="Ctrl" DisallowedModifiers="Shift,Alt,Windows"/>

      <KeyHandler Name="KH_CS_L"  Key="Left"     Command="{DecrementValueCtrlShift}"   RequiredModifiers="Ctrl,Shift" DisallowedModifiers="Alt,Windows"/>
      <KeyHandler Name="KH_CS_U"  Key="Up"       Command="{IncrementValueCtrlShift}"   RequiredModifiers="Ctrl,Shift" DisallowedModifiers="Alt,Windows"/>
      <KeyHandler Name="KH_CS_R"  Key="Right"    Command="{IncrementValueCtrlShift}"   RequiredModifiers="Ctrl,Shift" DisallowedModifiers="Alt,Windows"/>
      <KeyHandler Name="KH_CS_D"  Key="Down"     Command="{DecrementValueCtrlShift}"   RequiredModifiers="Ctrl,Shift" DisallowedModifiers="Alt,Windows"/>
    </Input>

    <Locals>
      <AnchorLayoutInput Name="ThumbLayoutInput"
        ContributesToWidth="false" Horizontal="Center"
        Top="Parent,0" Left="Parent,0,-999" Right="Parent,0,999"/>

      <AnchorLayoutInput Name="FillLayoutInput"
        Top="Parent,0" Left="Parent,0" Right="Parent,0"/>

      <AnchorLayoutInput Name="DummyLayoutInput"/>

      <Command Name="IncrementValue"/>
      <Command Name="IncrementValueShift"/>
      <Command Name="IncrementValueCtrl"/>
      <Command Name="IncrementValueCtrlShift"/>
      <Command Name="DecrementValue"/>
      <Command Name="DecrementValueShift"/>
      <Command Name="DecrementValueCtrl"/>
      <Command Name="DecrementValueCtrlShift"/>
      <Command Name="PageUpValue"/>
      <Command Name="PageDownValue"/>
      <Command Name="OnHome"/>
      <Command Name="OnEnd"/>

      <Single  Name="RawKeyDelta"/>
      <Single  Name="RawKeyDeltaShift"/>
      <Single  Name="RawKeyDeltaCtrl"/>
      <Single  Name="RawKeyDeltaCtrlShift"/>
      <Single  Name="RawKeyDeltaPage"/>

      <float Name="InitialValue"/>
      <float Name="ThumbPosition"/>

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

    <Scripts>
      <Script>
        if ([Accessible.Enabled])
        {
          Accessible.Name = [AccessibleDescription];
          Accessible.Value = [AccessibleValue];
          Accessible.Role = AccessibleRole.Slider;
        }
      </Script>

      <Script>
        Dragger.RelativeTo = DragRect;

        DragRect.Margins = new Inset(ThumbOffset,0,ThumbOffset,0);

        FilledBackground.Visible = ([FilledBackgroundImage] != null);
      </Script>

      <Script>
        UI.KeyFocusOnMouseDown = [KeyFocusOnMouseDown];
      </Script>

      <Script>
        [InitialEvaluate(true)]
        [DeclareTrigger(KeyDelta)]
        [DeclareTrigger(KeyDeltaShift)]
        [DeclareTrigger(KeyDeltaCtrl)]
        [DeclareTrigger(KeyDeltaCtrlShift)]
        [DeclareTrigger(KeyDeltaPage)]
        [DeclareTrigger(Model.MaxValue)]
        [DeclareTrigger(Model.MinValue)]
        [DeclareTrigger(ReadOnly)]

        

        float range = (Model.MaxValue - Model.MinValue);

        if ( [KeyDelta] &lt; 0.0 )
        {
           RawKeyDelta = (-1.0 * KeyDelta) * range;
        }
        else
        {
           RawKeyDelta = KeyDelta;
        }

        if ( [KeyDeltaShift] &lt; 0.0 )
        {
           RawKeyDeltaShift = (-1.0 * KeyDeltaShift) * range;
        }
        else
        {
           RawKeyDeltaShift = KeyDeltaShift;
        }

        if ( [KeyDeltaCtrl] &lt; 0.0 )
        {
           RawKeyDeltaCtrl = (-1.0 * KeyDeltaCtrl) * range;
        }
        else
        {
           RawKeyDeltaCtrl = KeyDeltaCtrl;
        }

        if ( [KeyDeltaCtrlShift] &lt; 0.0 )
        {
           RawKeyDeltaCtrlShift = (-1.0 * KeyDeltaCtrlShift) * range;
        }
        else
        {
           RawKeyDeltaCtrlShift = KeyDeltaCtrlShift;
        }

        if ( [KeyDeltaPage] &lt; 0.0 )
        {
           RawKeyDeltaPage = (-1.0 * KeyDeltaPage) * range;
        }
        else
        {
           RawKeyDeltaPage = KeyDeltaPage;
        }

        
        

        bool enable = (KeyDelta != 0.0 &amp;&amp; !ReadOnly);

        KH_L.Enabled     = enable;
        KH_U.Enabled     = enable;
        KH_R.Enabled     = enable;
        KH_D.Enabled     = enable;

        enable = (KeyDeltaShift != 0.0 &amp;&amp; !ReadOnly);

        KH_S_L.Enabled   = enable;
        KH_S_U.Enabled   = enable;
        KH_S_R.Enabled   = enable;
        KH_S_D.Enabled   = enable;

        enable = (KeyDeltaCtrl != 0.0 &amp;&amp; !ReadOnly);

        KH_C_L.Enabled   = enable;
        KH_C_U.Enabled   = enable;
        KH_C_R.Enabled   = enable;
        KH_C_D.Enabled   = enable;

        enable = (KeyDeltaCtrlShift != 0.0 &amp;&amp; !ReadOnly);

        KH_CS_L.Enabled  = enable;
        KH_CS_U.Enabled  = enable;
        KH_CS_R.Enabled  = enable;
        KH_CS_D.Enabled  = enable;

        KH_PGU.Enabled   = (KeyDeltaPage != 0.0 &amp;&amp; !ReadOnly);
        KH_PGD.Enabled   = (KeyDeltaPage != 0.0 &amp;&amp; !ReadOnly);
        KH_HOM.Enabled   = (!ReadOnly);
        KH_END.Enabled   = (!ReadOnly);
      </Script>

      <Script>
        [DeclareTrigger(OnHome.Invoked)]
        Model.Value = Model.MinValue;
        UpdateValue = Model.Value;

        if (ValueChanged != null)
           ValueChanged.Invoke();
      </Script>

      <Script>
        [DeclareTrigger(OnEnd.Invoked)]
        Model.Value = Model.MaxValue;
        UpdateValue = Model.Value;

        if (ValueChanged != null)
           ValueChanged.Invoke();
      </Script>

      <Script>
        [DeclareTrigger(PageUpValue.Invoked)]
        Model.Value = Model.Value + RawKeyDeltaPage;
        UpdateValue = Model.Value;

        if (ValueChanged != null)
           ValueChanged.Invoke();
      </Script>

      <Script>
        [DeclareTrigger(PageDownValue.Invoked)]
        Model.Value = Model.Value - RawKeyDeltaPage;
        UpdateValue = Model.Value;

        if (ValueChanged != null)
           ValueChanged.Invoke();
      </Script>

      <Script>
        [DeclareTrigger(DecrementValue.Invoked)]
        Model.Value = Model.Value - RawKeyDelta;
        UpdateValue = Model.Value;

        if (ValueChanged != null)
           ValueChanged.Invoke();
      </Script>

      <Script>
        [DeclareTrigger(DecrementValueShift.Invoked)]
        Model.Value = Model.Value - RawKeyDeltaShift;
        UpdateValue = Model.Value;

        if (ValueChanged != null)
           ValueChanged.Invoke();
      </Script>

      <Script>
        [DeclareTrigger(DecrementValueCtrl.Invoked)]
        Model.Value = Model.Value - RawKeyDeltaCtrl;
        UpdateValue = Model.Value;

        if (ValueChanged != null)
           ValueChanged.Invoke();
      </Script>

      <Script>
        [DeclareTrigger(DecrementValueCtrlShift.Invoked)]
        Model.Value = Model.Value - RawKeyDeltaCtrlShift;
        UpdateValue = Model.Value;

        if (ValueChanged != null)
           ValueChanged.Invoke();
      </Script>

      <Script>
        [DeclareTrigger(IncrementValue.Invoked)]
        Model.Value = Model.Value + RawKeyDelta;
        UpdateValue = Model.Value;

        if (ValueChanged != null)
           ValueChanged.Invoke();
      </Script>

      <Script>
        [DeclareTrigger(IncrementValueShift.Invoked)]
        Model.Value = Model.Value + RawKeyDeltaShift;
        UpdateValue = Model.Value;

        if (ValueChanged != null)
           ValueChanged.Invoke();
      </Script>

      <Script>
        [DeclareTrigger(IncrementValueCtrl.Invoked)]
        Model.Value = Model.Value + RawKeyDeltaCtrl;
        UpdateValue = Model.Value;

        if (ValueChanged != null)
           ValueChanged.Invoke();
      </Script>

      <Script>
        [DeclareTrigger(IncrementValueCtrlShift.Invoked)]
        Model.Value = Model.Value + RawKeyDeltaCtrlShift;
        UpdateValue = Model.Value;

        if (ValueChanged != null)
           ValueChanged.Invoke();
      </Script>

      <Script>
        Dragger.Enabled = ![ReadOnly];
      </Script>

      <Script>
        [DeclareTrigger(Model.MinValue)]
        [DeclareTrigger(Model.MaxValue)]

        
        

        if (Dragging &amp;&amp; CancelDragOnModelChange)
        {
           Dragger.CancelDrag();
           Dragging = false;
        }
      </Script>

      <Script>
        [DeclareTrigger(Dragger.Started)]
        InitialValue = Model.Value;
        UpdateValue = Model.Value;
        Dragging = true;
      </Script>

      <Script>
        [DeclareTrigger(Dragging)]
        [DeclareTrigger(Dragger.EndPosition)]
        [DeclareTrigger(Model.MaxValue)]
        [DeclareTrigger(Model.MinValue)]

        

        if (Dragging)
        {
           float min   = Model.MinValue;
           float max   = Model.MaxValue;
           float step  = Model.Step;
           float raw   = Dragger.EndPosition.X * (max - min);

           
           if (DiscreteValues)
           {
              raw = step * (float)(int)((raw / step) + 0.5);
           }

           float value = min + raw;

           
           
           

           if (value &lt; min)
              value = min;
           else if (value &gt; max)
              value = max;

           

           UpdateValue = value;

           

           if (AutoUpdateDuringDrag)
           {
              Model.Value = UpdateValue;

              if (ValueChanged != null)
                 ValueChanged.Invoke();
           }
        }
      </Script>

      <Script>
        [InitialEvaluate(true)]
        [DeclareTrigger(Model.MaxValue)]
        [DeclareTrigger(Model.MinValue)]
        [DeclareTrigger(Model.Value)]
        [DeclareTrigger(Dragging)]
        [DeclareTrigger(FilledBackground.Visible)]

        float min = Model.MinValue;
        float max = Model.MaxValue;
        float pos = (Model.Value - min) / (max - min);

        
        

        
        
        

        if (FilledBackground.Visible)
        {
           FilledBackground.LayoutInput = DummyLayoutInput;

           FillLayoutInput.Right.Percent = pos;
           FillLayoutInput.Left.Offset = (-1 * ThumbOffset) + FillAdjustment;

           FilledBackground.LayoutInput = FillLayoutInput;
        }

        
        
        
        

        if (AutoUpdateDuringDrag || !Dragging)
        {
           ThumbPosition = pos;
        }
      </Script>

      <Script>
        [DeclareTrigger(UpdateValue)]
        [DeclareTrigger(Model.MaxValue)]
        [DeclareTrigger(Model.MinValue)]
        [DeclareTrigger(Dragging)]

        
        
        
        
        

        if (Dragging &amp;&amp; !AutoUpdateDuringDrag)
        {
           float min = Model.MinValue;
           float max = Model.MaxValue;
           float pos = (UpdateValue - min) / (max - min);

           ThumbPosition = pos;
        }
      </Script>

      <Script>
        [InitialEvaluate(true)]
        [DeclareTrigger(ThumbPosition)]

        

        Thumb.LayoutInput = DummyLayoutInput;

        ThumbLayoutInput.Left.Percent  = ThumbPosition;
        ThumbLayoutInput.Right.Percent = ThumbPosition;

        Thumb.LayoutInput = ThumbLayoutInput;
      </Script>

      <Script>
        [DeclareTrigger(Dragger.Cancelled)]

        
        
        
        
        
        

        if (AutoUpdateDuringDrag)
        {
           Model.Value = InitialValue;
           UpdateValue = Model.Value;

           if (ValueChanged != null)
              ValueChanged.Invoke();
        }

        Dragging = false;
      </Script>

      <Script>
        [DeclareTrigger(Dragger.Ended)]

        if (!AutoUpdateDuringDrag)
        {
           Model.Value = UpdateValue;

           if (ValueChanged != null)
              ValueChanged.Invoke();
        }

        Dragging = false;
      </Script>

      <Script>
        if ([UI.MouseFocus])
        {
           Thumb.Content = [ThumbImageFocus];
        }
        else
        {
           Thumb.Content = [ThumbImage];
        }
      </Script>

      <Script>FilledBackground.Content = [FilledBackgroundImage];</Script>
      <Script>Background.Content = [BackgroundImage];</Script>
    </Scripts>

    <Content>
      <Panel Name="Root" Layout="Anchor">
        <Children>

          <Panel Name="DragRect" Layout="Form">
            <LayoutInput>
              <AnchorLayoutInput Left="Background,0" Right="Background,1" Top="Background,0" Bottom="Background,1"/>
            </LayoutInput>
            <Children>
              <Graphic Name="Thumb" Content="{ThumbImage}"/>
              <Graphic Name="FilledBackground" Content="{FilledBackgroundImage}"/>
            </Children>
          </Panel>

          <Graphic Name="Background" Content="{BackgroundImage}">
            <LayoutInput>
              <AnchorLayoutInput Left="Parent,0" Right="Parent,1"/>
            </LayoutInput>
          </Graphic>

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

  

  <UI Name="ChoiceSlider">
    <Properties>
      <Int32   Name="ThumbOffset" Int32="4"/>
      <iris:Choice Name="Model"/>
      <String Name="AccessibleDescription" String="{null}"/>
    </Properties>

    <Locals>
      <iris:RangedValue Name="RawModel"/>
    </Locals>

    <Scripts>
      <Script>
        RawModel.MinValue = 0.0;
        if ((Model == null) || (Model.Options == null))
        {
          RawModel.MaxValue = 0.0;
          RawModel.Value    = 0.0;
        }
        else
        {
          RawModel.MaxValue = (float)([Model.Options.Count] - 1);
          RawModel.Value    = (float)[Model.ChosenIndex];
        }
      </Script>
      <Script>
        if ((Model != null) &amp;&amp; (Model.Options != null))
        {
          Model.ChosenIndex = (int)[RawModel.Value];
        }
      </Script>
    </Scripts>

    <Content>
      <me:Slider
        ThumbOffset="{ThumbOffset}"
        Model="{RawModel}"
        DiscreteValues="true"
        AccessibleDescription="{AccessibleDescription}"
        />
    </Content>
  </UI>

  
  <UI Name="LabeledChoiceSlider">
    <Properties>
      <String Name="MinValueString" String="$Required"/>
      <String Name="MaxValueString" String="$Required"/>
      <iris:Choice Name="Model" Choice="$Required"/>
      <String Name="AccessibleDescription" String="{null}"/>
      <style:Style Name="TextStyle" Color="{styles:Styles.TextActive}" Font="{styles:Styles.SettingsText}"/>
    </Properties>

    <Scripts>
      <Script>
        Slider.Model = [Model];
      </Script>
    </Scripts>

    <Content>
      <Panel Name="SliderPanel">
        <Layout>
          <FlowLayout Orientation="Horizontal" ItemAlignment="Center" Spacing="10,0"/>
        </Layout>

        <Children>
          <button:Label Content="{MinValueString}" Style="{TextStyle}"  WordWrap="false"/>
          <me:ChoiceSlider
            Name="Slider"
            Model="{null}"
            MaximumSize="75,0"
            AccessibleDescription="{AccessibleDescription}"/>
          <button:Label Content="{MaxValueString}" Style="{TextStyle}"  WordWrap="false"/>
        </Children>
      </Panel>
    </Content>
  </UI>
</UIX>
