<UserControl x:Class="PDFViewWPFTestCS.AnnotationsControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="using:PDFViewWPFTestCS"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <UserControl.Resources>
        <Style x:Key="ListBoxStyle" TargetType="ListBox">
            <Style.Resources>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="LightSkyBlue" Opacity="0.5"/>
                <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="LightSkyBlue" Opacity="0.5"/>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"/>
            </Style.Resources>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBox">
                        <ScrollViewer Name="PART_scrollviewer">
                            <WrapPanel IsItemsHost="True" Width="{Binding (FrameworkElement.ActualWidth), RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}"
                                   MinWidth="{Binding ItemWidth, RelativeSource={RelativeSource Self}}"
                                   Orientation= "Horizontal" Background="White"/>
                        </ScrollViewer>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>

    <ScrollViewer VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Disabled" >
        <Grid Name="ctrl_viewer" Background="White" IsEnabled="False">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
        
            <Grid Grid.Row="0">
                <Expander Header="Annotations" Background="WhiteSmoke" Name="m_annots" IsExpanded="False" Margin="0,5,0,5" BorderBrush="Silver" BorderThickness="1" >
                    <ListBox Name="listbox_annots" SelectionMode="Single"
                             SelectionChanged="listbox_annots_SelectionChanged" 
                             SelectedValuePath="Tag" Style="{StaticResource ResourceKey=ListBoxStyle}" >
                        <!--<ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel IsItemsHost="True" Orientation= "Horizontal" Background="White"
                                           Width="{Binding (FrameworkElement.ActualWidth), RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}"
                                           MinWidth="{Binding ItemWidth, RelativeSource={RelativeSource Self}}" />
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>-->
                        <ListBox.ItemContainerStyle>
                            <Style TargetType="{x:Type ListBoxItem}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                                <Setter Property="VerticalContentAlignment" Value="Center"/>
                            </Style>
                        </ListBox.ItemContainerStyle>
                        <ListBox.Items>
                            <ListBoxItem Tag="AnnotationCreateSticky">
                                <Image Source="../Resources/Annotations/annot_sticky_note.png" Stretch="None"/>
                                <ToolTipService.ToolTip>
                                    <ToolTip Placement="Bottom">
                                        <TextBlock Text="Add Sticky Note"/>
                                    </ToolTip>
                                </ToolTipService.ToolTip>
                            </ListBoxItem>
                            <ListBoxItem Tag="AnnotationCreateTextHighlight">
                                <Image Source="../Resources/Annotations/annot_highlight.png" Stretch="None"/>
                                <ToolTipService.ToolTip>
                                    <ToolTip Placement="Bottom">
                                        <TextBlock Text="Highlight Text"/>
                                    </ToolTip>
                                </ToolTipService.ToolTip>
                            </ListBoxItem>
                            <ListBoxItem Tag="AnnotationCreateTextUnderline">
                                <Image Source="../Resources/Annotations/annot_underline.png" Stretch="None"/>
                                <ToolTipService.ToolTip>
                                    <ToolTip Placement="Bottom">
                                        <TextBlock Text="Underline"/>
                                    </ToolTip>
                                </ToolTipService.ToolTip>
                            </ListBoxItem>
                            <ListBoxItem Tag="AnnotationCreateTextStrikeout">
                                <Image Source="../Resources/Annotations/annot_strikethrough.png" Stretch="None"/>
                                <ToolTipService.ToolTip>
                                    <ToolTip Placement="Bottom">
                                        <TextBlock Text="Strikethough"/>
                                    </ToolTip>
                                </ToolTipService.ToolTip>
                            </ListBoxItem>
                            <ListBoxItem Tag="AnnotationCreateRectangle">
                                <Image Source="../Resources/Annotations/annot_rectangle.png" Stretch="None"/>
                                <ToolTipService.ToolTip>
                                    <ToolTip Placement="Bottom">
                                        <TextBlock Text="Draw Rectangle"/>
                                    </ToolTip>
                                </ToolTipService.ToolTip>
                            </ListBoxItem>
                            <ListBoxItem Tag="AnnotationCreateEllipse">
                                <Image Source="../Resources/Annotations/annot_ellipse.png" Stretch="None"/>
                                <ToolTipService.ToolTip>
                                    <ToolTip Placement="Bottom">
                                        <TextBlock Text="Draw Oval"/>
                                    </ToolTip>
                                </ToolTipService.ToolTip>
                            </ListBoxItem>
                            <ListBoxItem Tag="AnnotationCreateLine" >
                                <Image Source="../Resources/Annotations/annot_line.png" Stretch="None"/>
                                <ToolTipService.ToolTip>
                                    <ToolTip Placement="Bottom">
                                        <TextBlock Text="Draw Line"/>
                                    </ToolTip>
                                </ToolTipService.ToolTip>
                            </ListBoxItem>
                            <ListBoxItem Tag="AnnotationCreateArrow">
                                <Image Source="../Resources/Annotations/annot_arrow.png" Stretch="None"/>
                                <ToolTipService.ToolTip>
                                    <ToolTip Placement="Bottom">
                                        <TextBlock Text="Draw Arrow"/>
                                    </ToolTip>
                                </ToolTipService.ToolTip>
                            </ListBoxItem>
                            <ListBoxItem Tag="AnnotationCreateFreeHand" >
                                <Image Source="../Resources/Annotations/annot_paintbrush.png" Stretch="None"/>
                                <ToolTipService.ToolTip>
                                    <ToolTip Placement="Bottom">
                                        <TextBlock Text="Draw Freehand"/>
                                    </ToolTip>
                                </ToolTipService.ToolTip>
                            </ListBoxItem>
                        </ListBox.Items>
                    </ListBox>
                </Expander>
            </Grid>
            
            <Grid Grid.Row="2">
                <Expander  Background="WhiteSmoke" Header="Appearance" Name="m_appearance" IsExpanded="True" Margin="0,5,0,5" BorderBrush="Silver" BorderThickness="1" Visibility="Collapsed" >
                    <Grid Margin="2,0,2,0" Background="White">
                        <StackPanel Name="properties_panel" Orientation="Vertical">
                            <!--Type-->
                            <StackPanel>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="40"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Grid.Column="0" Text="Type:" Margin="2"/>
                                    <TextBlock Grid.Column="1" Name="m_annot_type_field" Margin="2"/>
                                </Grid>
                                <Separator/>
                            </StackPanel>
                            <!--Color-->
                            <StackPanel Name="ColorPanel">
                                <TextBlock Text="Color" Margin="2"/>
                                <StackPanel Name="text_markup_color_picker"/>
                            </StackPanel>
                            <!--Line-->
                            <StackPanel Name="LinePanel">
                                <TextBlock Text="Begin Style" Margin="2"/>
                                <ComboBox Name="line_begin_style_box" SelectionChanged="line_begin_style_box_SelectionChanged" SelectedValuePath="Tag" IsEditable="False" IsReadOnly="True" Margin="2">
                                    <ComboBoxItem Content="Square" Tag="t_sq"/>
                                    <ComboBoxItem Content="Circle" Tag="t_circle"/>
                                    <ComboBoxItem Content="Diamond" Tag="t_diamond"/>
                                    <ComboBoxItem Content="Open Arrow" Tag="t_openA"/>
                                    <ComboBoxItem Content="Closed Arrow" Tag="t_closedA"/>
                                    <ComboBoxItem Content="Butt" Tag="t_butt"/>
                                    <ComboBoxItem Content="Reversed Open Arrow" Tag="t_revOpenA"/>
                                    <ComboBoxItem Content="Reversed Closed Arrow" Tag="t_revClosedA"/>
                                    <ComboBoxItem Content="Slash" Tag="t_slash"/>
                                    <ComboBoxItem Content="None" Tag="t_none"/>                                    
                                </ComboBox>
                                <TextBlock Text="End Style" Margin="2"/>
                                <ComboBox Name="line_end_style_box" SelectionChanged="line_end_style_box_SelectionChanged" SelectedValuePath="Tag" IsEditable="False" IsReadOnly="True" Margin="2">
                                    <ComboBoxItem Content="Square" Tag="t_sq"/>
                                    <ComboBoxItem Content="Circle" Tag="t_circle"/>
                                    <ComboBoxItem Content="Diamond" Tag="t_diamond"/>
                                    <ComboBoxItem Content="Open Arrow" Tag="t_openA"/>
                                    <ComboBoxItem Content="Closed Arrow" Tag="t_closedA"/>
                                    <ComboBoxItem Content="Butt" Tag="t_butt"/>
                                    <ComboBoxItem Content="Reversed Open Arrow" Tag="t_revOpenA"/>
                                    <ComboBoxItem Content="Reversed Closed Arrow" Tag="t_revClosedA"/>
                                    <ComboBoxItem Content="Slash" Tag="t_slash"/>
                                    <ComboBoxItem Content="None" Tag="t_none"/>
                                </ComboBox>
                            </StackPanel>
                           <!--Color-->
                            <StackPanel Name="LineColorPanel">
                                <TextBlock Text="Line Color" Margin="2"/>
                                <StackPanel Name="line_color_picker"/>
                            </StackPanel>
                            <StackPanel Name="FillColorPanel">
                                <TextBlock Text="Fill Color" Margin="2"/>
                                <StackPanel Name="fill_color_picker"/>
                            </StackPanel>
                            <StackPanel Name="LineStylePanel">
                                <TextBlock Text="Line Style" Margin="2"/>
                                <ComboBox Name="line_style_box" SelectionChanged="line_style_box_SelectionChanged" Margin="2" SelectedValuePath="Tag" IsEditable="False" IsReadOnly="True">
                                    <ComboBoxItem Content="Solid" Tag="t_solid"/>
                                    <ComboBoxItem Content="Dotted" Tag="t_dotted"/>
                                    <ComboBoxItem Content="Dashed" Tag="t_dashed"/>
                                    <ComboBoxItem Content="Dash-dot" Tag="t_dashdot"/>
                                    <ComboBoxItem Content="Long-short" Tag="t_longshort"/>
                                    <ComboBoxItem Content="Long dash" Tag="t_longdash"/>
                                    <ComboBoxItem Content="Custom" Tag="t_custom"/>
                                </ComboBox>
                            </StackPanel>   
                            <StackPanel Name="StrokeThicknessPanel">
                                <TextBlock Text="Line Thickness" Margin="2"/>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="45"/>
                                    </Grid.ColumnDefinitions>
                                    <Slider Grid.Column="0" Value="1" Name="m_thickness_slider" Margin="2" ValueChanged="m_thickness_slider_ValueChanged" Maximum="20" Minimum="0"/>
                                    <TextBox Grid.Column="1" Name="m_thickness_txtbox" HorizontalContentAlignment="Center" Margin="2" Text="{Binding ElementName=m_thickness_slider, Path=Value, StringFormat=N0}" IsReadOnly="True"/>
                                </Grid>
                            </StackPanel>
                            
                            <TextBlock Text="Opacity" Margin="2"/>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="45"/>
                                </Grid.ColumnDefinitions>
                                <Slider Grid.Column="0" Value="1" Name="m_opacity_slider" Margin="2" ValueChanged="m_opacity_slider_ValueChanged" Maximum="1" Minimum="0"/>
                                <TextBox Grid.Column="1" Name="m_opacity_txtbox" HorizontalContentAlignment="Center" Margin="2,2,0,2" Text="{Binding ElementName=m_opacity_slider, Path=Value, StringFormat=P0}" IsReadOnly="True"/>
                            </Grid>
                        </StackPanel>
                    </Grid>
                </Expander>
        </Grid>

            <Grid Grid.Row="3">
                <Expander  Background="WhiteSmoke" Header="General Properties" Name="m_general" IsExpanded="False" Visibility="Collapsed" Margin="0,5,0,5" BorderBrush="Silver" BorderThickness="1">
                    <Grid Margin="2,0,2,0" Background="White">
                        <StackPanel Orientation="Vertical">
                            <TextBlock Text="Subject" Margin="2"/>
                            <TextBox Name="m_subject" Margin="2" TextChanged="m_subject_TextChanged"/>
                            <Separator/>
                            <TextBlock Text="Author" Margin="2"/>
                            <TextBox Name="m_author" Margin="2" TextChanged="m_author_TextChanged"/>
                            <Separator/>
                            <WrapPanel Orientation="Horizontal" Margin="2">
                                <TextBlock Text="Last Modified: " />
                                <TextBlock Text="0000-00-00 00:00:00" Name="m_dateModified"/>
                            </WrapPanel>
                            <WrapPanel Orientation="Horizontal" Margin="2">
                                <TextBlock Text="Creation Date: "/>
                                <TextBlock Text="0000-00-00 00:00:00" Name="m_dateCreated"/>
                            </WrapPanel>
                        </StackPanel>
                    </Grid>
                </Expander>
            </Grid>

            <Grid Grid.Row="1">
                <Expander  Background="WhiteSmoke" Header="Comments List" Name="m_annotList" IsExpanded="True" Margin="0,5,0,5" BorderBrush="Silver" BorderThickness="1">
                    <ListBox x:Name="annotlistbox" SelectionMode="Extended" SelectionChanged="annotlistbox_SelectionChanged" Margin="2"
                            KeyDown="annotlistbox_KeyDown" ScrollViewer.CanContentScroll="True" SelectedIndex="-1" ScrollViewer.VerticalScrollBarVisibility="Auto"
                             ScrollViewer.HorizontalScrollBarVisibility="Auto">
                        <ListBox.ItemContainerStyle>
                            <Style TargetType="{x:Type ListBoxItem}">
                                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                                <Setter Property="VerticalContentAlignment" Value="Center"/>
                            </Style>
                        </ListBox.ItemContainerStyle>
                    </ListBox>
                </Expander>
            </Grid>
        </Grid>
    </ScrollViewer>
</UserControl>
