﻿<ResourceDictionary 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"
                    mc:Ignorable="d"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                    xmlns:local="clr-namespace:IDE.Controls">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/IDE.Presentation;component/Controls/ItemPicker/ItemPicker.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <!-- Define color of watermark in AdvancedTextBox name space -->
    <SolidColorBrush x:Key="brushWatermarkForeground"
                     Color="#AA000033" />
    <SolidColorBrush x:Key="brushWatermarkBackground"
                     Color="Transparent" />

    <Style TargetType="{x:Type local:TextBoxWithWatermark}">
        <Setter Property="SnapsToDevicePixels"
                Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:TextBoxWithWatermark}">
                    <ControlTemplate.Resources>
                        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
                        <local:WatermarkHelper x:Key="WatermarkHelper" />
                    </ControlTemplate.Resources>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <Label Content="{Binding Path=LabelTextBox, RelativeSource={RelativeSource FindAncestor, AncestorType=local:TextBoxWithWatermark, AncestorLevel=1}}"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Bottom"
                               Grid.Column="0"
                               Grid.Row="0" />

                        <TextBox Name="txtUserEntry1"
                                 Text="{Binding Path=Text, RelativeSource={RelativeSource FindAncestor, AncestorType=local:TextBoxWithWatermark, AncestorLevel=1}}"
                                 VerticalAlignment="Center"
                                 HorizontalAlignment="Stretch"
                                 Grid.Column="0"
                                 Grid.Row="1" />
                        <TextBlock Text="{Binding Path=Watermark, RelativeSource={RelativeSource FindAncestor, AncestorType=local:TextBoxWithWatermark, AncestorLevel=1}}"
                                   Foreground="{StaticResource brushWatermarkForeground}"
                                   Background="{StaticResource brushWatermarkBackground}"
                                   IsHitTestVisible="False"
                                   VerticalAlignment="Center"
                                   HorizontalAlignment="Stretch"
                                   Grid.Column="0"
                                   Grid.Row="1"
                                   Margin="5,2">
                            <TextBlock.Visibility>
                                <Binding ElementName="txtUserEntry1"
                                         Path="Text.IsEmpty"
                                         Converter="{StaticResource BooleanToVisibilityConverter}" />
                            </TextBlock.Visibility>
                        </TextBlock>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -->
    <Style TargetType="{x:Type local:FileHyperlink}">
        <Setter Property="SnapsToDevicePixels"
                Value="True" />
        <Setter Property="ContextMenu">
            <Setter.Value>
                <ContextMenu>
                    <MenuItem Header="Copy Url to Clipboard"
                              Command="{x:Static local:FileHyperlink.CopyUri}"
                              CommandTarget="{Binding PlacementTarget, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}}" />

                    <MenuItem Header="Open with Windows Application..."
                              Command="{x:Static local:FileHyperlink.NavigateToUri}"
                              CommandTarget="{Binding PlacementTarget, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}}" />

                    <MenuItem Header="Open containing folder"
                              Command="{x:Static local:FileHyperlink.OpenContainingFolder}"
                              CommandTarget="{Binding PlacementTarget, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}}" />
                </ContextMenu>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:FileHyperlink}">
                    <TextBlock  ToolTip="{Binding ElementName=PART_Hyperlink, Path=NavigateUri}">
                        <TextBlock.InputBindings>
                            <KeyBinding Key="C"
                                        Modifiers="Ctrl"
                                        Command="{x:Static local:FileHyperlink.CopyUri}"
                                        CommandParameter="{Binding ElementName=PART_Hyperlink,Path=NavigateUri}" />
                        </TextBlock.InputBindings>
            <Hyperlink Name="PART_Hyperlink"
                        NavigateUri="{Binding Path=NavigateUri, RelativeSource={RelativeSource FindAncestor, AncestorType=local:FileHyperlink, AncestorLevel=1}}">
              <!-- Moved link to event handler RequestNavigate="Hyperlink_RequestNavigate" to code behind -->
              <TextBlock Text="{Binding Path=Text, RelativeSource={RelativeSource FindAncestor, AncestorType=local:FileHyperlink, AncestorLevel=1}}" />
            </Hyperlink>
          </TextBlock>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -->
    <Style TargetType="{x:Type local:WebHyperlink}">
        <Setter Property="SnapsToDevicePixels"
                Value="True" />
        <Setter Property="ContextMenu">
            <Setter.Value>
                <ContextMenu>
                    <MenuItem Header="Copy Url to Clipboard"
                              Command="{x:Static local:WebHyperlink.CopyUri}"
                              CommandTarget="{Binding PlacementTarget,
                    RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}}" />

                    <MenuItem Header="Open Target in Browser"
                              Command="{x:Static local:WebHyperlink.NavigateToUri}"
                              CommandTarget="{Binding PlacementTarget,
                    RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}}" />
                </ContextMenu>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:WebHyperlink}">
                    <TextBlock ToolTip="{Binding ElementName=PART_Hyperlink,Path=NavigateUri}">
                        <TextBlock.InputBindings>
                            <KeyBinding Key="C"
                                        Modifiers="Ctrl"
                                        Command="{x:Static local:WebHyperlink.CopyUri}"
                                        CommandParameter="{Binding ElementName=PART_Hyperlink,Path=NavigateUri}" />
                        </TextBlock.InputBindings>

            <Hyperlink Name="PART_Hyperlink"
                        NavigateUri="{Binding Path=NavigateUri, RelativeSource={RelativeSource FindAncestor, AncestorType=local:WebHyperlink, AncestorLevel=1}}">
              <TextBlock Text="{Binding Path=Text, RelativeSource={RelativeSource FindAncestor, AncestorType=local:WebHyperlink, AncestorLevel=1}}" />
            </Hyperlink>
          </TextBlock>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        Checkbox style for pin visual
        Original source of animation (is replaced with own XAML image)
        http://stackoverflow.com/questions/7459642/how-do-i-create-a-wpf-checkbox-control-template-in-xaml-with-the-following-requi
      -->
    <Style TargetType="{x:Type local:PinnableCheckbox}">
        <Setter Property="SnapsToDevicePixels"
                Value="true" />
        <!-- Setter Property="OverridesDefaultStyle" Value="true" -->
        <Setter Property="FocusVisualStyle"
                Value="{DynamicResource CheckBoxFocusVisual}" />
        <Setter Property="LayoutTransform">
            <Setter.Value>
                <ScaleTransform CenterX="50"
                                CenterY="50"
                                ScaleX=".15"
                                ScaleY=".15" />
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CheckBox}">
                    <BulletDecorator Background="Transparent">
                        <BulletDecorator.Bullet>

                            <Grid>
                                <Canvas Width="100"
                                        Height="100"
                                        x:Name="NoCheckMark"
                                        Opacity="0"
                                        Visibility="Visible">
                                    <!-- Needle Pin in unpined mode (Opacity is set to different value on MouseOver) -->
                                    <Path VerticalAlignment="Center"
                                          Fill="Black">
                                        <Path.Data>
                                            <PathGeometry>
                                                <PathGeometry.Figures>
                                                    <PathFigureCollection>
                                                        <PathFigure IsClosed="True"
                                                                    StartPoint="0,0">
                                                            <PathFigure.Segments>
                                                                <PathSegmentCollection>
                                                                    <LineSegment Point="75,65" />
                                                                    <LineSegment Point="75,85" />
                                                                </PathSegmentCollection>
                                                            </PathFigure.Segments>
                                                        </PathFigure>
                                                    </PathFigureCollection>
                                                </PathGeometry.Figures>
                                            </PathGeometry>
                                        </Path.Data>
                                    </Path>

                                    <Line X1="0"
                                          Y1="0"
                                          X2="75"
                                          Y2="65"
                                          Stroke="Black" />
                                    <Line X1="0"
                                          Y1="0"
                                          X2="75"
                                          Y2="85"
                                          Stroke="Black" />

                                    <Ellipse Canvas.Left="50"
                                             Canvas.Top="50"
                                             Width="50"
                                             Height="50"
                                             Fill="Blue" />
                                    <Ellipse Canvas.Left="50"
                                             Canvas.Top="50"
                                             Width="50"
                                             Height="50">
                                        <Ellipse.Fill>
                                            <RadialGradientBrush GradientOrigin="0.15,0">
                                                <!-- Source: http://www.codeproject.com/Articles/32257/A-Style-for-Round-Glassy-WPF-Buttons -->
                                                <RadialGradientBrush.RelativeTransform>
                                                    <TransformGroup>
                                                        <RotateTransform Angle="0.45"
                                                                         CenterX="50"
                                                                         CenterY="20" />
                                                        <ScaleTransform CenterX="0.5"
                                                                        CenterY="0.5"
                                                                        ScaleX="1.5"
                                                                        ScaleY="1.5" />
                                                        <TranslateTransform X="0.02"
                                                                            Y="0.3" />
                                                    </TransformGroup>
                                                </RadialGradientBrush.RelativeTransform>
                                                <GradientStop Offset="1"
                                                              Color="#00000000" />
                                                <GradientStop Offset="0.4"
                                                              Color="#FFFFFFFF" />
                                            </RadialGradientBrush>
                                        </Ellipse.Fill>
                                    </Ellipse>
                                </Canvas>

                                <Canvas Width="100"
                                        Height="100"
                                        x:Name="CheckMark">
                                    <!-- Needle Pin in pined mode XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -->
                                    <!-- Canvas.LayoutTransform>
  		                                      <ScaleTransform CenterX="50" CenterY="50" ScaleX=".15" ScaleY=".15" />
  	                                          </Canvas.LayoutTransform -->
                                    <!-- Border BorderBrush="Black" BorderThickness="1" Width ="100" Height="100" / -->

                                    <Path VerticalAlignment="Center"
                                          Fill="Red">
                                        <Path.Data>
                                            <PathGeometry>
                                                <PathGeometry.Figures>
                                                    <PathFigureCollection>
                                                        <PathFigure IsClosed="True"
                                                                    StartPoint="50,90">
                                                            <PathFigure.Segments>
                                                                <PathSegmentCollection>
                                                                    <LineSegment Point="40,25" />
                                                                    <LineSegment Point="60,25" />
                                                                </PathSegmentCollection>
                                                            </PathFigure.Segments>
                                                        </PathFigure>
                                                    </PathFigureCollection>
                                                </PathGeometry.Figures>
                                            </PathGeometry>
                                        </Path.Data>
                                    </Path>

                                    <Line X1="50"
                                          Y1="90"
                                          X2="40"
                                          Y2="25"
                                          Stroke="Black" />
                                    <Line X1="50"
                                          Y1="90"
                                          X2="60"
                                          Y2="25"
                                          Stroke="Black" />

                                    <Ellipse Canvas.Left="25"
                                             Canvas.Top="5"
                                             Width="50"
                                             Height="50"
                                             Fill="Blue" />
                                    <Ellipse Canvas.Left="25"
                                             Canvas.Top="5"
                                             Width="50"
                                             Height="50">
                                        <Ellipse.Fill>
                                            <RadialGradientBrush GradientOrigin="0.15,0">
                                                <!-- Source: http://www.codeproject.com/Articles/32257/A-Style-for-Round-Glassy-WPF-Buttons -->
                                                <RadialGradientBrush.RelativeTransform>
                                                    <TransformGroup>
                                                        <RotateTransform Angle="0.45"
                                                                         CenterX="50"
                                                                         CenterY="20" />
                                                        <ScaleTransform CenterX="0.5"
                                                                        CenterY="0.5"
                                                                        ScaleX="1.5"
                                                                        ScaleY="1.5" />
                                                        <TranslateTransform X="0.02"
                                                                            Y="0.3" />
                                                    </TransformGroup>
                                                </RadialGradientBrush.RelativeTransform>
                                                <GradientStop Offset="1"
                                                              Color="#00000000" />
                                                <GradientStop Offset="0.4"
                                                              Color="#FFFFFFFF" />
                                            </RadialGradientBrush>
                                        </Ellipse.Fill>
                                    </Ellipse>
                                </Canvas>
                            </Grid>

                        </BulletDecorator.Bullet>
                    </BulletDecorator>

                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <!-- Condition Property="IsMouseOver" Value="True"/ -->
                                <Condition Property="IsChecked"
                                           Value="False" />
                            </MultiTrigger.Conditions>

                            <MultiTrigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetProperty="Opacity"
                                                         Storyboard.TargetName="NoCheckMark"
                                                         To="0.3"
                                                         Duration="0:0:0.1" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.EnterActions>
                            <MultiTrigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetProperty="Opacity"
                                                         Storyboard.TargetName="NoCheckMark"
                                                         To="0"
                                                         Duration="0:0:0.1" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.ExitActions>

                        </MultiTrigger>

                        <Trigger Property="IsChecked"
                                 Value="True">
                            <!-- Setter TargetName="CheckBorder" Property="Opacity" Value="1"/ -->
                            <Setter TargetName="CheckMark"
                                    Property="Opacity"
                                    Value="1" />
                        </Trigger>
                        <Trigger Property="IsChecked"
                                 Value="False">
                            <!-- Setter TargetName="CheckBorder" Property="Opacity" Value="0"/ -->
                            <Setter TargetName="CheckMark"
                                    Property="Opacity"
                                    Value="0" />
                        </Trigger>

                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:PinableListViewItem}">
        <Setter Property="SnapsToDevicePixels"
                Value="true" />
        <Setter Property="Padding"
                Value="1" />
        <Setter Property="HorizontalContentAlignment"
                Value="Stretch" />
        <!-- This is required for the PathTrimmingTextBlock -->
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListViewItem">
                    <Border Name="ListemBackgroundBorder"
                            Padding="3"
                            BorderBrush="Transparent"
                            BorderThickness="1"
                            CornerRadius="3"
                            SnapsToDevicePixels="true"
                            Background="Transparent">
                        <GridViewRowPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Border>
                    <!-- ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
              <Setter TargetName="ListemBackgroundBorder" Property="Background" Value="{StaticResource ListViewItemMouseOverGradient}"/>
              <Setter TargetName="ListemBackgroundBorder" Property="BorderBrush" Value="{StaticResource ListViewItemMouseOverBorder}" />
              <Setter TargetName="ListemBackgroundBorder" Property="BorderThickness" Value="1" />
            </Trigger>
            <!- Trigger Property="IsSelected" Value="true">
              <Setter TargetName="Border" Property="Background" Value="Black"/>
            </Trigger ->
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Foreground" Value="{StaticResource PinableListViewForegroundDisabled}"/>
            </Trigger>
          </ControlTemplate.Triggers -->
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:PinableListView}">
        <Setter Property="SnapsToDevicePixels"
                Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:PinableListView}">
                    <Border Padding="0"
                            BorderThickness="0"
                            BorderBrush="Transparent"
                            Name="Bd"
                            SnapsToDevicePixels="True">
                        <!-- Background="{StaticResource ToolViewBackground}" -->
                        <ScrollViewer Padding="0"
                                      Focusable="False">
                            <ItemsPresenter SnapsToDevicePixels="True" />
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
