<?xml version="1.0" encoding="utf-8"?>
<Resource>
  <Folder name="GacGenConfig">
    <Folder name="ResX86">
      <Text name="Resource">..\..\UIRes\32bits\kb_ctemplates.bin</Text>
    </Folder>
    <Folder name="ResX64">
      <Text name="Resource">..\..\UIRes\64bits\kb_ctemplates.bin</Text>
    </Folder>
  </Folder>
  <Folder name="Templates">
    <Instance name="TabHeaderButtonTemplate">
      <Instance ref.Class="sample::TabHeaderButtonTemplate">
        <SelectableButtonTemplate ref.Name="self" MinSizeLimitation="LimitToElementAndChildren">
          <Bounds AlignmentToParent="left:0 top:0 right:0 bottom:0">
            <SolidBackground>
              <att.Color-bind><![CDATA[
                cast Color (
                  not self.VisuallyEnabled ? "#00000000" :
                  self.State == ButtonState::Pressed ? "#3D3D3D" :
                  self.State == ButtonState::Active ? "#808080" :
                  self.Selected ? "#3D3D3D" :
                  "#00000000"
                )
              ]]></att.Color-bind>
            </SolidBackground>
          </Bounds>
          <Bounds AlignmentToParent="left:0 top:0 right:0 bottom:0">
            <att.Visible-bind>self.Focused</att.Visible-bind>
            <FocusRectangle/>
          </Bounds>
          <Bounds AlignmentToParent="left:1 top:1 right:1 bottom:1" MinSizeLimitation="LimitToElement">
            <SolidLabel Text-bind="self.Text" Font-bind="self.Font">
              <att.Color-bind><![CDATA[
                cast Color (
                  self.VisuallyEnabled ? "#FFFFFF" : "808080"
                )
              ]]></att.Color-bind>
            </SolidLabel>
          </Bounds>
        </SelectableButtonTemplate>
      </Instance>
    </Instance>

    <Instance name="TabHeaderTemplate">
      <Instance ref.Class="sample::TabHeaderTemplate">
        <ref.Parameter Name="CurrentTabPage" Class="presentation::controls::GuiTabPage"/>
        <ref.Members>
          <![CDATA[
            prop Commands : ITabCommandExecutor* = null {}
          ]]>
        </ref.Members>
        <ControlTemplate ref.Name="self" MinSizeLimitation="LimitToElementAndChildren">
          <CheckBox AutoFocus="false" AutoSelection="false">
            <att.ControlTemplate>sample::TabHeaderButtonTemplate</att.ControlTemplate>
            <att.BoundsComposition-set AlignmentToParent="left:0 top:0 right:0 bottom:0"/>
            <att.Context-ref>CurrentTabPage</att.Context-ref>
            <att.Text-bind>CurrentTabPage.Text</att.Text-bind>
            <att.Alt-bind>CurrentTabPage.Alt</att.Alt-bind>
            <att.Selected-bind>CurrentTabPage.OwnerTab.SelectedPage == CurrentTabPage</att.Selected-bind>
            <ev.Clicked-eval>
              <![CDATA[
                {
                  self.Commands.ShowTab(CurrentTabPage.OwnerTab.Pages.IndexOf(CurrentTabPage), true);
                }
              ]]>
            </ev.Clicked-eval>
          </CheckBox>
        </ControlTemplate>
      </Instance>
    </Instance>

    <Instance name="TabTemplate">
      <Instance ref.Class="sample::TabTemplate">
        <TabTemplate ref.Name="self" ContainerComposition-ref="container" TabOrder="TopToBottom" MinSizeLimitation="LimitToElementAndChildren">
          <Table AlignmentToParent="left:0 top:0 right:0 bottom:0" MinSizeLimitation="LimitToElementAndChildren">
            <att.Rows>
              <CellOption>composeType:Percentage percentage:1.0</CellOption>
            </att.Rows>
            <att.Columns>
              <CellOption>composeType:MinSize</CellOption>
              <CellOption>composeType:Percentage percentage:1.0</CellOption>
            </att.Columns>

            <Cell Site="row:0 column:0">
              <RepeatStack ref.Name="header" AlignmentToParent="left:0 top:0 right:0 bottom:0" Padding="2" Direction="Vertical" MinSizeLimitation="LimitToElementAndChildren">
                <att.ItemTemplate>sample::TabHeaderTemplate</att.ItemTemplate>
                <att.ItemSource-bind>self.TabPages</att.ItemSource-bind>
                <ev.ItemInserted-eval>
                  <![CDATA[
                    {
                      var stackItem = header.StackItems[arguments.itemIndex];
                      var item = cast (TabHeaderTemplate*) stackItem.Children[0];
                      item.Commands = self.Commands;
                    }
                  ]]>
                </ev.ItemInserted-eval>
              </RepeatStack>
            </Cell>

            <Cell Site="row:0 column:1">
              <SolidBackground Color="#3D3D3D"/>
              <Bounds ref.Name="container" AlignmentToParent="left:1 top:1 right:1 bottom:1"/>
            </Cell>
          </Table>
        </TabTemplate>
      </Instance>
    </Instance>
  </Folder>

  <Folder name="MainWindow">
    <InstanceStyle name="SharedStyle">
      <Styles>
        <Style ref.Path="//Stack" Direction="Vertical" MinSizeLimitation="LimitToElementAndChildren"/>
        <Style ref.Path="//RadioButton" GroupController-ref="groupDirection"/>
        <Style ref.Path="//TabPage">
          <att.ContainerComposition-set InternalMargin="left:10 top:10 right:10 bottom:10"/>
        </Style>
      </Styles>
    </InstanceStyle>
    
    <Instance name="MainWindowResource">
      <Instance ref.Class="sample::MainWindow" ref.Styles="res://MainWindow/SharedStyle" xmlns:x="presentation::controls::GuiSelectableButton::*">
        <Window Text="kb_ctemplates" IconVisible="true" ClientSize="x:640 y:480">
          <att.ContainerComposition-set PreferredMinSize="x:480 y:320"/>
          <x:MutexGroupController ref.Name="groupDirection"/>

          <Tab>
            <att.ControlTemplate>sample::TabTemplate</att.ControlTemplate>
            <att.BoundsComposition-set AlignmentToParent="left:0 top:0 right:0 bottom:0"/>
            <att.Pages>
              <TabPage Text="First TabPage">
                <Button Text="A button in the first page"/>
              </TabPage>

              <TabPage Text="Second TabPage">
                <Stack>
                  <StackItem><CheckBox Text="A check box in the second page"/></StackItem>
                  <StackItem><CheckBox Text="A check box in the second page"/></StackItem>
                  <StackItem><CheckBox Text="A check box in the second page"/></StackItem>
                </Stack>
              </TabPage>

              <TabPage Text="Third TabPage">
                <Stack>
                  <StackItem><RadioButton Text="A radio button in the third page"/></StackItem>
                  <StackItem><RadioButton Text="A radio button in the third page"/></StackItem>
                  <StackItem><RadioButton Text="A radio button in the third page"/></StackItem>
                </Stack>
              </TabPage>
            </att.Pages>
          </Tab>
        </Window>
      </Instance>
    </Instance>
  </Folder>
</Resource>