<?xml version="1.0" encoding="utf-8"?>
<Resource>
  <Folder name="GacGenConfig">
    <Xml name="Metadata">
      <ResourceMetadata Name="DataGridEditor" Version="1.0">
        <Dependencies>
          <Resource Name="DataGridBase"/>
        </Dependencies>
      </ResourceMetadata>
    </Xml>
    <Folder name="ResX86">
      <Text name="Resource">..\..\UIRes\32bits\control_datagrid_editor.bin</Text>
    </Folder>
    <Folder name="ResX64">
      <Text name="Resource">..\..\UIRes\64bits\control_datagrid_editor.bin</Text>
    </Folder>
  </Folder>
  <Folder name="MainWindow">
    <Instance name="TextEditorResource">
      <Instance ref.Class="sample::TextEditor">
        <GridEditorTemplate ref.Name="self" CellValue-bind="textBox.Text" FocusControl-ref="textBox">
          <SinglelineTextBox ref.Name="textBox" Text-bind="(cast string self.CellValue) ?? ''">
            <att.BoundsComposition-set AlignmentToParent="left:0 top:0 right:0 bottom:0"/>
          </SinglelineTextBox>
        </GridEditorTemplate>
      </Instance>
    </Instance>

    <Instance name="DateEditorResource">
      <Instance ref.Class="sample::DateEditor">
        <GridEditorTemplate ref.Name="self" CellValue-bind="comboBox.SelectedDate" FocusControl-ref="comboBox">
          <DateComboBox ref.Name="comboBox" SelectedDate-bind="(cast DateTime self.CellValue) ?? (cast DateTime '2000-01-01 00:00:00.000')">
            <att.BoundsComposition-set AlignmentToParent="left:0 top:0 right:0 bottom:0"/>
          </DateComboBox>
        </GridEditorTemplate>
      </Instance>
    </Instance>

    <Instance name="SummaryEditorWindowResource">
      <Instance ref.Class="sample::SummaryEditorWindow">
        <ref.Members><![CDATA[
          prop Summary : string = "" {}
          prop Confirmed : bool = false {}
        ]]></ref.Members>
        <Window ref.Name="self" Text="Edit Summary" ClientSize="x:480 y:320" ev.WindowOpened-eval="documentViewer.Text = self.Summary;">
          <Table AlignmentToParent="left:10 top:0 right:10 bottom:0" CellPadding="5" BorderVisible="false" MinSizeLimitation="LimitToElementAndChildren">
            <att.Rows>
              <CellOption>composeType:MinSize</CellOption>
              <CellOption>composeType:Percentage percentage:1.0</CellOption>
              <CellOption>composeType:MinSize</CellOption>
            </att.Rows>
            <att.Columns>
              <CellOption>composeType:Percentage percentage:1.0</CellOption>
              <CellOption>composeType:MinSize</CellOption>
              <CellOption>composeType:MinSize</CellOption>
            </att.Columns>

            <Cell Site="row:0 column:0 columnSpan:3">
              <Label Text="Summary:"/>
            </Cell>

            <Cell Site="row:1 column:0 columnSpan:3">
              <DocumentViewer ref.Name="documentViewer" EditMode="Editable" HorizontalAlwaysVisible="false" VerticalAlwaysVisible="false">
                <att.BoundsComposition-set AlignmentToParent="left:0 top:0 right:0 bottom:0"/>
              </DocumentViewer>
            </Cell>

            <Cell Site="row:2 column:1">
              <Button Text="OK" ev.Clicked-eval="{ self.Summary = documentViewer.Text; self.Confirmed = true; self.Close(); }"/>
            </Cell>
            <Cell Site="row:2 column:2">
              <Button Text="Cancel" ev.Clicked-eval="self.Close();"/>
            </Cell>
          </Table>
        </Window>
      </Instance>
    </Instance>

    <Instance name="SummaryEditorResource">
      <Instance ref.Class="sample::SummaryEditor">
        <GridEditorTemplate ref.Name="self" FocusControl-ref="buttonEdit">
          <Table AlignmentToParent="left:10 top:0 right:10 bottom:0" CellPadding="5" BorderVisible="false" MinSizeLimitation="LimitToElementAndChildren">
            <att.Rows>
              <CellOption>composeType:Percentage percentage:1.0</CellOption>
              <CellOption>composeType:MinSize</CellOption>
              <CellOption>composeType:Percentage percentage:1.0</CellOption>
            </att.Rows>
            <att.Columns>
              <CellOption>composeType:Percentage percentage:1.0</CellOption>
              <CellOption>composeType:MinSize</CellOption>
            </att.Columns>

            <Cell Site="row:0 column:0 rowSpan:3">
              <SolidLabel Text-bind="cast string self.CellValue ?? ''" Font-bind="self.Font" Color-bind="self.PrimaryTextColor" Ellipse="true" VerticalAlignment="Center"/>
            </Cell>

            <Cell Site="row:1 column:1">
              <Button ref.Name="buttonEdit" Text="...">
                <ev.Clicked-eval><![CDATA[
                  $Async{
                    var mainWindow = cast (GuiWindow*) self.RelatedControlHost;
                    var editorWindow = new SummaryEditorWindow*();
                    editorWindow.Summary = cast string self.CellValue;
                    editorWindow.MoveToScreenCenter(mainWindow.RelatedScreen);
                    $Await editorWindow.ShowModalAsync(mainWindow);
                    if (editorWindow.Confirmed)
                    {
                      self.CellValue = editorWindow.Summary;
                    }
                    delete editorWindow;
                  }
                ]]></ev.Clicked-eval>
              </Button>
            </Cell>
          </Table>
        </GridEditorTemplate>
      </Instance>
    </Instance>

    <Instance name="MainWindowResource">
      <Instance ref.Class="sample::MainWindow" xmlns:sample="sample::*">
        <sample:DataGridWindowBase ref.Name="self" Text="control_datagrid_editor" env.ItemType="sample::BookItem^">
          <att.TitleColumn-set EditorFactory="sample::TextEditor"/>
          <att.AuthorColumn-set EditorFactory="sample::TextEditor"/>
          <att.DatePublishedColumn-set EditorFactory="sample::DateEditor"/>
          <att.SummaryColumn-set EditorFactory="sample::SummaryEditor"/>
        </sample:DataGridWindowBase>
      </Instance>
    </Instance>
  </Folder>
</Resource>