<?xml version="1.0" encoding="utf-8"?>
<ContentDialog
    x:Class="was.touchcopy.features.calendar.CalendarEventDetailsContentDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:converters="using:was.touchcopy.features.calendar.converters"
    xmlns:commonConverters="using:was.touchcopy.features.converters"
    xmlns:icalcomponents="using:Ical.Net.CalendarComponents"
    xmlns:calendardata="using:was.touchcopy.features.calendar.data" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    x:Uid="CalendarEventDetailsContentDialog"
    CloseButtonText="XX Dismiss"
    DefaultButton="Close">
    <ContentDialog.Resources>
        <converters:CalendarEventToAttachmentListConverter x:Key="CalendarEventToAttachmentListConverter" />
        <converters:CalendarEventToAttachmentVisibilityConverter x:Key="CalendarEventToAttachmentVisibilityConverter" />
        <converters:CalendarEventToStringConverter x:Key="CalendarEventToStringConverter"/>
        <converters:ICalPropertiesToColorConverter x:Key="ICalPropertiesToColorConverter"/>
        <converters:ICalPropertiesToCalendarName x:Key="ICalPropertiesToCalendarName"/>
        <commonConverters:ValueToVisibilityConverter x:Key="ValueToVisibilityConverter"/>
    </ContentDialog.Resources>
    <ContentDialog.TitleTemplate>
        <DataTemplate x:DataType="icalcomponents:CalendarEvent">
            <StackPanel Orientation="Vertical">
                <StackPanel Orientation="Horizontal" Spacing="16">
                    <Border Width="12" CornerRadius="4" Background="{x:Bind Properties, Converter={StaticResource ICalPropertiesToColorConverter}}" />
                    <TextBlock Text="{x:Bind Summary}" Style="{ThemeResource TitleTextBlockStyle}" />
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="20,0,0,0">
                    <StackPanel.Resources>
                        <Style TargetType="Button">
                            <Setter Property="Background" Value="Transparent" />
                            <Setter Property="Foreground" Value="{ThemeResource SystemAccentColor}" />
                            <Setter Property="BorderThickness" Value="0" />
                            <Setter Property="CornerRadius" Value="4" />
                            <Setter Property="FontSize" Value="12" />
                            <Setter Property="Padding" Value="6" />
                        </Style>
                        <Style TargetType="HyperlinkButton">
                            <Setter Property="CornerRadius" Value="0" />
                            <Setter Property="FontSize" Value="12" />
                            <Setter Property="Padding" Value="6" />
                        </Style>
                    </StackPanel.Resources>
                    <HyperlinkButton Click="_saveAsICal_Click">
                        <StackPanel Orientation="Horizontal" Spacing="4">
                            <FontIcon Glyph="&#xE787;" FontSize="12" />
                            <TextBlock x:Uid="TextBlockSaveAsICal" Text="XX Save as iCal" />
                        </StackPanel>
                    </HyperlinkButton>
                    <HyperlinkButton Click="_saveNote_Click" Visibility="{x:Bind Description, Converter={StaticResource ValueToVisibilityConverter}}">
                        <StackPanel Orientation="Horizontal" Spacing="4">
                            <FontIcon Glyph="&#xE70B;" FontSize="12" />
                            <TextBlock x:Uid="TextBlockSaveNote" Text="XX Save Note" />
                        </StackPanel>
                    </HyperlinkButton>
                    <HyperlinkButton Click="_saveUrl_Click" Visibility="{x:Bind Url, Converter={StaticResource ValueToVisibilityConverter}}">
                        <StackPanel Orientation="Horizontal" Spacing="4">
                            <FontIcon Glyph="&#xE774;" FontSize="12" />
                            <TextBlock x:Uid="TextBlockSaveUrl" Text="XX Save URL" />
                        </StackPanel>
                    </HyperlinkButton>
                </StackPanel>
            </StackPanel>
        </DataTemplate>
    </ContentDialog.TitleTemplate>
    <ScrollViewer Margin="0,8,0,0" VerticalScrollBarVisibility="Auto">
        <StackPanel Margin="24,0,0,0">
            <Grid ColumnSpacing="12">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <FontIcon Glyph="&#xE787;" VerticalAlignment="Top" Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}" />
                <TextBlock Grid.Column="1" Text="{x:Bind CalendarEvent, Converter={StaticResource CalendarEventToStringConverter}}" Style="{ThemeResource CaptionTextBlockStyle}" VerticalAlignment="Center" />
            </Grid>
            <MenuFlyoutSeparator Visibility="{x:Bind CalendarEvent.Location, Converter={StaticResource ValueToVisibilityConverter}}" Padding="0" Margin="36,8,0,8" />
            <Grid Visibility="{x:Bind CalendarEvent.Location, Converter={StaticResource ValueToVisibilityConverter}}" ColumnSpacing="12">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <FontIcon Glyph="&#xE707;" VerticalAlignment="Top" Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}" />
                <TextBlock Grid.Column="1" Text="{x:Bind CalendarEvent.Location}" Style="{ThemeResource BodyTextBlockStyle}" VerticalAlignment="Center"  />
            </Grid>
            <MenuFlyoutSeparator Visibility="{x:Bind CalendarEvent.Description, Converter={StaticResource ValueToVisibilityConverter}}" Padding="0" Margin="36,8,0,8" />
            <Grid Visibility="{x:Bind CalendarEvent.Description, Converter={StaticResource ValueToVisibilityConverter}}" ColumnSpacing="12">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <FontIcon Glyph="&#xE70B;" VerticalAlignment="Top" Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}" />
                <TextBlock Grid.Column="1" Text="{x:Bind CalendarEvent.Description}" Style="{ThemeResource BodyTextBlockStyle}" TextWrapping="Wrap" VerticalAlignment="Center" />
            </Grid>
            <MenuFlyoutSeparator Visibility="{x:Bind CalendarEvent.Url, Converter={StaticResource ValueToVisibilityConverter}}" Padding="0" Margin="36,8,0,8" />
            <Grid Visibility="{x:Bind CalendarEvent.Url, Converter={StaticResource ValueToVisibilityConverter}}" ColumnSpacing="12">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <FontIcon Glyph="&#xE774;" VerticalAlignment="Top" Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}" />
                <HyperlinkButton Grid.Column="1" Margin="-4,-4,0,0" Padding="4, 2" NavigateUri="{x:Bind CalendarEvent.Url}">
                    <TextBlock Text="{x:Bind CalendarEvent.Url}" Style="{ThemeResource BodyTextBlockStyle}" TextWrapping="Wrap" VerticalAlignment="Center" />
                </HyperlinkButton>
            </Grid>
            <MenuFlyoutSeparator Visibility="{x:Bind CalendarEvent, Converter={StaticResource CalendarEventToAttachmentVisibilityConverter}}" Padding="0" Margin="36,8,0,8" />
            <Grid Visibility="{x:Bind CalendarEvent, Converter={StaticResource CalendarEventToAttachmentVisibilityConverter}}" ColumnSpacing="12">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <FontIcon Glyph="&#xe723;" VerticalAlignment="Top" Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}" />
                <ItemsRepeater Grid.Column="1" ItemsSource="{x:Bind CalendarEvent, Converter={StaticResource CalendarEventToAttachmentListConverter}}" VerticalAlignment="Center">
                    <ItemsRepeater.ItemTemplate>
                        <DataTemplate x:DataType="calendardata:CalendarAttachment">
                            <TextBlock Text="{x:Bind Name}" Style="{ThemeResource BodyTextBlockStyle}" TextWrapping="Wrap" />
                        </DataTemplate>
                    </ItemsRepeater.ItemTemplate>
                </ItemsRepeater>
            </Grid>
        </StackPanel>
    </ScrollViewer>
</ContentDialog>
