<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:TheBoxSoftware.DeveloperSuite.LiveDocumenter"
    xmlns:model="clr-namespace:TheBoxSoftware.DeveloperSuite.LiveDocumenter.Model"
    xmlns:controls="clr-namespace:TheBoxSoftware.DeveloperSuite.LiveDocumenter.Controls"
    xmlns:extend="clr-namespace:TheBoxSoftware.DeveloperSuite.LiveDocumenter.Extensions"
    xmlns:diagnostics="clr-namespace:System.Diagnostics;assembly=WindowsBase"
    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=DotNetProjects.Input.Toolkit"
    xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="TheBoxSoftware.DeveloperSuite.LiveDocumenter.MainWindow"
    x:Name="mainWindow"
    Title="Live Documenter" 
    Height="639" 
    Width="969" 
    UseLayoutRounding="True"
    PreviewKeyDown="mainWindow_PreviewKeyDown"
    Loaded="mainWindow_Loaded" 
    Closing="mainWindow_Closing" 
    Activated="mainWindow_Activated">

    <Window.Resources>
        <model:TreeViewItemDataTemplateSelector x:Key="treeViewDataTemplateSelector" />
        <HierarchicalDataTemplate x:Key="documentMapItemTemplate" ItemsSource="{Binding Children}">
            <StackPanel Orientation="Horizontal">
                <Image Source="{Binding IconPath}" Width="16" Height="16" Margin="1,1,4,1" />
                <TextBlock Padding="0,2,0,2" Text="{Binding Name}" />
            </StackPanel>
        </HierarchicalDataTemplate>
        <HierarchicalDataTemplate x:Key="documentMapItemNoIconTemplate" ItemsSource="{Binding Children}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Padding="0,2,0,2" Text="{Binding Name}" />
            </StackPanel>
        </HierarchicalDataTemplate>

        <HierarchicalDataTemplate x:Key="RecentFileMenuItem">
            <TextBlock Text="{Binding DisplayName}" />
        </HierarchicalDataTemplate>

        <Style TargetType="{x:Type TreeViewItem}" x:Key="TreeViewItemStyle">
            <Setter Property="extend:TreeViewItemBehavior.IsBroughtIntoViewWhenSelected" Value="True" />
            <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
            <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
            <Setter Property="FontWeight" Value="Normal" />
            <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="FontWeight" Value="Bold" />
                </Trigger>
            </Style.Triggers>
        </Style>

        <DataTemplate x:Key="searchResultDataTemplate">
            <Border BorderBrush="#dddddd" BorderThickness="0,0,0,1" Padding="0,5,0,5">
                <Grid Width="500" MaxWidth="500">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="20" />
                        <ColumnDefinition Width="480" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Image OpacityMask="#FF00FF" Grid.Column="0" Grid.Row="0" Width="16" Height="16" Source="{Binding Icon}"  />
                    <TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Name}" />
                    <TextBlock Grid.ColumnSpan="2" Grid.Row="1" Text="{Binding Summary}" FontStyle="Italic" TextWrapping="Wrap" Foreground="#888888" />
                </Grid>
            </Border>
        </DataTemplate>

        <SolidColorBrush x:Key="ToolBarButtonHoverBorder" Color="#3399FF"/>
        <SolidColorBrush x:Key="ToolBarButtonHover" Color="#C2E0FF"/>
        <SolidColorBrush x:Key="ToolBarButtonPressedBorder" Color="#3399FF"/>
        <SolidColorBrush x:Key="ToolBarButtonPressed" Color="#99CCFF"/>
        
        <Style x:Key="ForwardBackButtonStyle" TargetType="{x:Type Button}">
        	<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        	<Setter Property="Padding" Value="2"/>
        	<Setter Property="BorderThickness" Value="1"/>
        	<Setter Property="Background" Value="Transparent"/>
        	<Setter Property="BorderBrush" Value="Transparent"/>
        	<Setter Property="HorizontalAlignment" Value="Center"/>
        	<Setter Property="VerticalAlignment" Value="Center"/>
        	<Setter Property="HorizontalContentAlignment" Value="Center"/>
        	<Setter Property="VerticalContentAlignment" Value="Center"/>
        	<Setter Property="Template">
        		<Setter.Value>
        			<ControlTemplate TargetType="{x:Type Button}">
        				<Border SnapsToDevicePixels="true" x:Name="Bd" 
                                Background="{TemplateBinding Background}" 
                                BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                Padding="{TemplateBinding Padding}">
        					<ContentPresenter x:Name="content"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
        				</Border>
        				<ControlTemplate.Triggers>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsMouseOver" Value="True" />
                                    <Condition Property="IsEnabled" Value="True" />
                                </MultiTrigger.Conditions>
                                <Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource ToolBarButtonHoverBorder}"/>
                                <Setter Property="Background" TargetName="Bd" Value="{StaticResource ToolBarButtonHover}"/>
                            </MultiTrigger>
        					<Trigger Property="IsKeyboardFocused" Value="true">
        						<Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource ToolBarButtonHoverBorder}"/>
        						<Setter Property="Background" TargetName="Bd" Value="{StaticResource ToolBarButtonHover}"/>
        					</Trigger>
        					<Trigger Property="IsPressed" Value="true">
        						<Setter Property="BorderBrush" TargetName="Bd" Value="{StaticResource ToolBarButtonPressedBorder}"/>
        						<Setter Property="Background" TargetName="Bd" Value="{StaticResource ToolBarButtonPressed}"/>
        					</Trigger>
        					<Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Opacity" Value="0.30" />
        					</Trigger>
        				</ControlTemplate.Triggers>
        			</ControlTemplate>
        		</Setter.Value>
        	</Setter>
        </Style>
		
		<Style x:Key="SearchBoxStyle" TargetType="{x:Type toolkit:AutoCompleteBox}">
			<Setter Property="IsTabStop" Value="False"/>
			<Setter Property="Padding" Value="2"/>
			<Setter Property="BorderThickness" Value="1"/>
			<Setter Property="BorderBrush">
				<Setter.Value>
					<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
						<GradientStop Color="#FFA3AEB9" Offset="0"/>
						<GradientStop Color="#FF8399A9" Offset="0.375"/>
						<GradientStop Color="#FF718597" Offset="0.375"/>
						<GradientStop Color="#FF617584" Offset="1"/>
					</LinearGradientBrush>
				</Setter.Value>
			</Setter>
			<Setter Property="Background" Value="White"/>
			<Setter Property="Foreground" Value="Black"/>
			<Setter Property="MinWidth" Value="45"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type toolkit:AutoCompleteBox}">
						<Grid Opacity="{TemplateBinding Opacity}" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="PopupStates">
									<VisualStateGroup.Transitions>
										<VisualTransition GeneratedDuration="00:00:00.1000000" To="PopupOpened"/>
										<VisualTransition GeneratedDuration="00:00:00.2000000" To="PopupClosed"/>
									</VisualStateGroup.Transitions>
									<VisualState x:Name="PopupOpened">
										<Storyboard>
											<DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="PopupBorder" Storyboard.TargetProperty="Opacity" To="1"/>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="PopupClosed">
										<Storyboard>
											<DoubleAnimation Duration="00:00:00.2000000" Storyboard.TargetName="PopupBorder" Storyboard.TargetProperty="Opacity" To="0"/>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
								<VisualStateGroup x:Name="ValidationStates">
									<VisualState x:Name="Valid"/>
									<VisualState x:Name="InvalidUnfocused">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorElement" Storyboard.TargetProperty="Visibility">
												<DiscreteObjectKeyFrame KeyTime="00:00:00">
													<DiscreteObjectKeyFrame.Value>
														<Visibility>Visible</Visibility>
													</DiscreteObjectKeyFrame.Value>
												</DiscreteObjectKeyFrame>
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="InvalidFocused">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorElement" Storyboard.TargetProperty="Visibility">
												<DiscreteObjectKeyFrame KeyTime="00:00:00">
													<DiscreteObjectKeyFrame.Value>
														<Visibility>Visible</Visibility>
													</DiscreteObjectKeyFrame.Value>
												</DiscreteObjectKeyFrame>
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip" Storyboard.TargetProperty="IsOpen">
												<DiscreteObjectKeyFrame KeyTime="00:00:00">
													<DiscreteObjectKeyFrame.Value>
														<System:Boolean>True</System:Boolean>
													</DiscreteObjectKeyFrame.Value>
												</DiscreteObjectKeyFrame>
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0,0,0,1" Background="{TemplateBinding Background}" Padding="0,0,2,0">
								<DockPanel Focusable="False">
									<Image DockPanel.Dock="Right" Source="resources\srch_16x16.png" Margin="0,0,0,0" Width="17" Height="16" Opacity="0.6" />
									<TextBox x:Name="Text" Margin="0" Focusable="True" Style="{TemplateBinding TextBoxStyle}" BorderBrush="{TemplateBinding BorderBrush}" Foreground="{TemplateBinding Foreground}" IsTabStop="True" BorderThickness="0" Padding="5,2,2,2"/>
								</DockPanel>
							</Border>
							<Border x:Name="ValidationErrorElement" Visibility="Collapsed" BorderBrush="#FFDB000C" BorderThickness="1" CornerRadius="1">
								<Border.ToolTip>
									<ToolTip x:Name="validationTooltip" Placement="Right">
										<ToolTip.Template>
											<ControlTemplate TargetType="{x:Type ToolTip}">
												<Grid x:Name="Root" Margin="5,0" Opacity="0" RenderTransformOrigin="0,0">
													<VisualStateManager.VisualStateGroups>
														<VisualStateGroup x:Name="OpenStates">
															<VisualStateGroup.Transitions>
																<VisualTransition GeneratedDuration="00:00:00"/>
																<VisualTransition GeneratedDuration="00:00:00.2000000" To="Open">
																	<Storyboard>
																		<DoubleAnimation Duration="00:00:00.2000000" Storyboard.TargetName="Translation" Storyboard.TargetProperty="X" To="0"/>
																		<DoubleAnimation Duration="00:00:00.2000000" Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="1"/>
																	</Storyboard>
																</VisualTransition>
															</VisualStateGroup.Transitions>
															<VisualState x:Name="Closed">
																<Storyboard>
																	<DoubleAnimation Duration="00:00:00" Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="0"/>
																</Storyboard>
															</VisualState>
															<VisualState x:Name="Open">
																<Storyboard>
																	<DoubleAnimation Duration="00:00:00" Storyboard.TargetName="Translation" Storyboard.TargetProperty="X" To="0"/>
																	<DoubleAnimation Duration="00:00:00" Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="1"/>
																</Storyboard>
															</VisualState>
														</VisualStateGroup>
													</VisualStateManager.VisualStateGroups>
													<Grid.RenderTransform>
														<TranslateTransform X="-25"/>
													</Grid.RenderTransform>
													<Border Margin="4,4,-4,-4" Background="#052A2E31" CornerRadius="5"/>
													<Border Margin="3,3,-3,-3" Background="#152A2E31" CornerRadius="4"/>
													<Border Margin="2,2,-2,-2" Background="#252A2E31" CornerRadius="3"/>
													<Border Margin="1,1,-1,-1" Background="#352A2E31" CornerRadius="2"/>
													<Border Background="#FFDC000C" CornerRadius="2">
														<TextBlock Margin="8,4" MaxWidth="250" Foreground="White" Text="{Binding (Validation.Errors)[0].ErrorContent}" TextWrapping="Wrap"/>
													</Border>
												</Grid>
											</ControlTemplate>
										</ToolTip.Template>
										<ToolTip.Triggers>
											<EventTrigger RoutedEvent="FrameworkElement.Loaded">
												<BeginStoryboard>
													<Storyboard>
														<ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip" Storyboard.TargetProperty="IsHitTestVisible">
															<DiscreteObjectKeyFrame KeyTime="00:00:00">
																<DiscreteObjectKeyFrame.Value>
																	<System:Boolean>True</System:Boolean>
																</DiscreteObjectKeyFrame.Value>
															</DiscreteObjectKeyFrame>
														</ObjectAnimationUsingKeyFrames>
													</Storyboard>
												</BeginStoryboard>
											</EventTrigger>
										</ToolTip.Triggers>
									</ToolTip>
								</Border.ToolTip>
								<Grid HorizontalAlignment="Right" Margin="1,-4,-4,0" VerticalAlignment="Top" Width="12" Height="12" Background="Transparent">
									<Path Fill="#FFDC000C" Margin="1,3,0,0" Data="M1,0L6,0A2,2,90,0,1,8,2L8,7z"/>
									<Path Fill="White" Margin="1,3,0,0" Data="M0,0L2,0 8,6 8,8"/>
								</Grid>
							</Border>
							<Popup x:Name="Popup" Placement="Bottom" PlacementTarget="{Binding Text}" ScrollViewer.HorizontalScrollBarVisibility="Hidden" HorizontalOffset="5" Margin="1,0,0,0" PopupAnimation="Fade">
								<Grid Opacity="{TemplateBinding Opacity}" Margin="0" Background="White">
									<Border x:Name="PopupBorder" HorizontalAlignment="Stretch" Opacity="0" BorderThickness="0" Background="White">
										<Border.RenderTransform>
											<TranslateTransform X="1" Y="1"/>
										</Border.RenderTransform>
										<Border HorizontalAlignment="Stretch" Opacity="1" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="0" Padding="0" Margin="0" Background="White">
											<Border.RenderTransform>
												<TransformGroup>
													<TranslateTransform X="-1" Y="-1"/>
												</TransformGroup>
											</Border.RenderTransform>
											<ListBox x:Name="Selector" MaxHeight="380"
                                                     ScrollViewer.IsDeferredScrollingEnabled="True"
                                                     VirtualizingStackPanel.IsVirtualizing="True" 
                                                     VirtualizingStackPanel.VirtualizationMode="Recycling"
                                                     Background="{TemplateBinding Background}" 
                                                     BorderThickness="0" 
                                                     Foreground="{TemplateBinding Foreground}" 
                                                     ItemContainerStyle="{TemplateBinding ItemContainerStyle}" 
                                                     ItemTemplate="{TemplateBinding ItemTemplate}" 
                                                     ScrollViewer.HorizontalScrollBarVisibility="Hidden" 
                                                     ScrollViewer.VerticalScrollBarVisibility="Visible"/>
										</Border>
									</Border>
								</Grid>
							</Popup>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

        <BitmapImage x:Shared="False" x:Key="AssemblyMenuItemIcon" UriSource="resources\elementicons\vsobject_assembly.png" />
		
    	<Style x:Key="RemoveAssemblyMenuItem" TargetType="{x:Type MenuItem}" x:Shared="False">
    		<Setter Property="Icon">
    			<Setter.Value>
    				<Image Source="resources\elementicons\vsobject_assembly.png" Width="16" Height="16" />
    			</Setter.Value>
    		</Setter>
    		<Setter Property="Header" Value="{Binding Name}" />
    		<Setter Property="Command" Value="local:Commands.Remove" />
    		<Setter Property="CommandParameter" Value="{Binding UniqueId}" />
    		<Setter Property="Template" Value="{DynamicResource RemoveAssemblyMenuItemTemplate}"/>
    	</Style>
		
    	<ControlTemplate x:Key="RemoveAssemblyMenuItemTemplate" TargetType="{x:Type MenuItem}">
    		<Grid SnapsToDevicePixels="True">
    			<Rectangle x:Name="Bg" Fill="{TemplateBinding Background}" RadiusY="2" RadiusX="2" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1"/>
    			<Rectangle x:Name="InnerBorder" Margin="1" RadiusY="2" RadiusX="2" Stroke="Transparent" StrokeThickness="1"/>
    			<Grid>
    				<Grid.ColumnDefinitions>
    					<ColumnDefinition MinWidth="24" SharedSizeGroup="MenuItemIconColumnGroup" Width="Auto"/>
    					<ColumnDefinition Width="4"/>
    					<ColumnDefinition Width="*"/>
    					<ColumnDefinition Width="37"/>
    					<ColumnDefinition SharedSizeGroup="MenuItemIGTColumnGroup" Width="Auto"/>
    					<ColumnDefinition Width="17"/>
    				</Grid.ColumnDefinitions>
					<Image x:Name="Icon" Source="resources\elementicons\vsobject_assembly.png" Width="16" Height="16" Margin="1" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center" />
    				<Border x:Name="GlyphPanel" BorderBrush="#FFCDD3E6" BorderThickness="1" Background="#FFE6EFF4" CornerRadius="3" Height="22" Margin="1" Visibility="Hidden" Width="22">
    					<Path x:Name="Glyph" Data="M0,5.1L1.7,5.2 3.4,7.1 8,0.4 9.2,0 3.3,10.8z" Fill="#FF0C12A1" FlowDirection="LeftToRight" Height="11" Width="9"/>
    				</Border>
    				<ContentPresenter ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" Grid.Column="2" ContentStringFormat="{TemplateBinding HeaderStringFormat}" ContentSource="Header" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
    				<TextBlock Grid.Column="4" Margin="{TemplateBinding Padding}" Text="{TemplateBinding InputGestureText}" Visibility="Collapsed"/>
    			</Grid>
    			<Popup x:Name="PART_Popup" AllowsTransparency="True" Focusable="False" HorizontalOffset="-2" IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}" Placement="Right" VerticalOffset="-3">
    				<Microsoft_Windows_Themes:SystemDropShadowChrome x:Name="Shdw" Color="Transparent">
    					<Border x:Name="SubMenuBorder" BorderBrush="#FF959595" BorderThickness="1" Background="WhiteSmoke">
    						<ScrollViewer x:Name="SubMenuScrollViewer" Margin="1,0" Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}">
    							<Grid RenderOptions.ClearTypeHint="Enabled">
    								<Canvas HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
    									<Rectangle x:Name="OpaqueRect" Fill="WhiteSmoke" Height="{Binding ActualHeight, ElementName=SubMenuBorder}" Width="{Binding ActualWidth, ElementName=SubMenuBorder}"/>
    								</Canvas>
    								<Rectangle Fill="#FFF1F1F1" HorizontalAlignment="Left" Margin="1,2" RadiusY="2" RadiusX="2" Width="28"/>
    								<Rectangle Fill="#FFE2E3E3" HorizontalAlignment="Left" Margin="29,2,0,2" Width="1"/>
    								<Rectangle Fill="White" HorizontalAlignment="Left" Margin="30,2,0,2" Width="1"/>
    								<ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Cycle" Grid.IsSharedSizeScope="True" Margin="2" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" KeyboardNavigation.TabNavigation="Cycle"/>
    							</Grid>
    						</ScrollViewer>
    					</Border>
    				</Microsoft_Windows_Themes:SystemDropShadowChrome>
    			</Popup>
    		</Grid>
    		<ControlTemplate.Triggers>
    			<Trigger Property="IsSuspendingPopupAnimation" Value="True">
    				<Setter Property="PopupAnimation" TargetName="PART_Popup" Value="None"/>
    			</Trigger>
    			<Trigger Property="IsHighlighted" Value="True">
    				<Setter Property="Stroke" TargetName="InnerBorder" Value="#D1DBF4FF"/>
    			</Trigger>
    			<Trigger Property="Icon" Value="{x:Null}">
    				<Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
    			</Trigger>
    			<Trigger Property="IsChecked" Value="True">
    				<Setter Property="Visibility" TargetName="GlyphPanel" Value="Visible"/>
    				<Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
    			</Trigger>
    			<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="True">
    				<Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
    				<Setter Property="Color" TargetName="Shdw" Value="#71000000"/>
    			</Trigger>
    			<Trigger Property="IsHighlighted" Value="True">
    				<Setter Property="Fill" TargetName="Bg">
    					<Setter.Value>
    						<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
    							<GradientStop Color="#34C5EBFF" Offset="0"/>
    							<GradientStop Color="#3481D8FF" Offset="1"/>
    						</LinearGradientBrush>
    					</Setter.Value>
    				</Setter>
    				<Setter Property="Stroke" TargetName="Bg" Value="#8571CBF1"/>
    			</Trigger>
    			<Trigger Property="IsEnabled" Value="False">
    				<Setter Property="Foreground" Value="#FF9A9A9A"/>
    				<Setter Property="Background" TargetName="GlyphPanel" Value="#FFEEE9E9"/>
    				<Setter Property="BorderBrush" TargetName="GlyphPanel" Value="#FFDBD6D6"/>
    				<Setter Property="Fill" TargetName="Glyph" Value="#FF848589"/>
    			</Trigger>
    			<Trigger Property="CanContentScroll" SourceName="SubMenuScrollViewer" Value="False">
    				<Setter Property="Canvas.Top" TargetName="OpaqueRect" Value="{Binding VerticalOffset, ElementName=SubMenuScrollViewer}"/>
    				<Setter Property="Canvas.Left" TargetName="OpaqueRect" Value="{Binding HorizontalOffset, ElementName=SubMenuScrollViewer}"/>
    			</Trigger>
    		</ControlTemplate.Triggers>
    	</ControlTemplate>
    </Window.Resources>

    <Window.InputBindings>
        <KeyBinding Key="Left" Modifiers="Alt" Command="NavigationCommands.BrowseBack" />
        <KeyBinding Key="Right" Modifiers="Alt" Command="NavigationCommands.BrowseForward" />
        <KeyBinding Key="O" Modifiers="Control" Command="ApplicationCommands.Open" />
        <KeyBinding Key="P" Modifiers="Control" Command="ApplicationCommands.Print" />
        <KeyBinding Key="F" Modifiers="Control" Command="ApplicationCommands.Find" />
        <KeyBinding Key="A" Modifiers="Control" Command="local:Commands.Add" />
        <KeyBinding Key="E" Modifiers="Control" Command="local:Commands.Export" />
    </Window.InputBindings>
	
    <Window.CommandBindings>
        <CommandBinding Command="NavigationCommands.BrowseForward" CanExecute="CanExecuteCommand" Executed="ExecuteCommand" />
        <CommandBinding Command="NavigationCommands.BrowseBack" CanExecute="CanExecuteCommand" Executed="ExecuteCommand" />
        <CommandBinding Command="ApplicationCommands.Close" CanExecute="CanExecuteCommand" Executed="ExecuteCommand" />
        <CommandBinding Command="ApplicationCommands.Open" CanExecute="CanExecuteCommand" Executed="ExecuteCommand" />
        <CommandBinding Command="ApplicationCommands.Print" CanExecute="CanExecuteCommand" Executed="ExecuteCommand" />
        <CommandBinding Command="ApplicationCommands.Find" CanExecute="CanExecuteCommand" Executed="ExecuteCommand" />
        <CommandBinding Command="ApplicationCommands.Save" CanExecute="CanExecuteCommand" Executed="ExecuteCommand" />
        <CommandBinding Command="ApplicationCommands.SaveAs" CanExecute="CanExecuteCommand" Executed="ExecuteCommand" />
        <CommandBinding Command="local:Commands.Export" CanExecute="CanExecuteCommand" Executed="ExecuteCommand" />
        <CommandBinding Command="local:Commands.Add" CanExecute="CanExecuteCommand" Executed="ExecuteCommand" />
        <CommandBinding Command="local:Commands.Remove" CanExecute="CanExecuteCommand" Executed="ExecuteCommand" />
        <CommandBinding Command="local:Commands.DocumentSettings" CanExecute="CanExecuteCommand" Executed="ExecuteCommand" />
    </Window.CommandBindings>
	
    <DockPanel>
        <Menu DockPanel.Dock="Top" VerticalAlignment="Top" x:Name="menu">
            <MenuItem Header="File" x:Name="fileMenu">
                <MenuItem Header="_Open..." Command="ApplicationCommands.Open" />
                <MenuItem x:Name="recentFiles" Header="Recent Files" Click="recentFiles_Click" ItemsSource="{Binding ''}" ItemTemplate="{StaticResource RecentFileMenuItem}" />
                <Separator />
                <MenuItem Header="_Add..." Command="local:Commands.Add" />
            	<MenuItem x:Name="removeAssemblyMenuItem" Header="_Remove" Command="local:Commands.Remove" />
                <MenuItem Header="_Save Project" Command="ApplicationCommands.Save" />
                <MenuItem Header="_Save Project As..." Command="ApplicationCommands.SaveAs" />
                <MenuItem Header="Export..." x:Name="export" Command="local:Commands.Export" />
                <Separator />                
                <MenuItem Header="E_xit" Command="ApplicationCommands.Close" />
                <!--<MenuItem Click="MenuItem_Click" Header="Test Exporting" />
                <MenuItem Name="TestException" Click="MenuItem_Click" Header="Test Exception Handling" />-->
            </MenuItem>
            <MenuItem Header="Tools">
                <MenuItem Header="Document Settings" Command="local:Commands.DocumentSettings" />
            </MenuItem>
            <MenuItem Header="Help">
                <MenuItem Header="About" Click="ShowAbout" />
            </MenuItem>
        </Menu>
        
        <ToolBar DockPanel.Dock="Top">
            <Button Command="ApplicationCommands.Open" Style="{DynamicResource ForwardBackButtonStyle}">
                <Button.ToolTip>
                    <TextBlock Text="Open (Ctrl + O)" />
                </Button.ToolTip>
                <Image Source="resources\open_24x24.png" Height="24" Width="24" />
            </Button>
            <Button Command="ApplicationCommands.Save" Style="{DynamicResource ForwardBackButtonStyle}">
                <Button.ToolTip>
                    <TextBlock Text="Save documentation project (Ctrl + S)" />
                </Button.ToolTip>
                <Image Source="resources\save_24x24.png" Height="24" Width="24" />
            </Button>
            <Separator />
            <Button Command="ApplicationCommands.Print" Style="{DynamicResource ForwardBackButtonStyle}">
                <Button.ToolTip>
                    <TextBlock Text="Print current page (Ctrl + P)" />
                </Button.ToolTip>
                <Image Source="resources\print_24x24.png" Height="24" Width="24"/>
            </Button>
            <Button Style="{DynamicResource ForwardBackButtonStyle}" Command="local:Commands.Export">
                <Button.ToolTip>
                    <TextBlock Text="Export documentation set (Ctrl + E)" />
                </Button.ToolTip>
                <Image Source="resources\exp_24x24.png" Height="24" Width="24" />
            </Button>
            <Separator />
            <Button Command="NavigationCommands.BrowseBack"
                    x:Name="back"
                    IsEnabled="{Binding CanMoveBackward, Mode=TwoWay}" 
                    Style="{DynamicResource ForwardBackButtonStyle}">
                <Button.ToolTip>
                    <TextBlock Text="Navigate backward (Alt + Left)" />
                </Button.ToolTip>
                <Image Source="resources\back_24x24.png" Height="24" Width="24"/>
            </Button>
            <Button Command="NavigationCommands.BrowseForward"
                    x:Name="forward"
                    IsEnabled="{Binding CanMoveForward, Mode=TwoWay}" 
                    Style="{DynamicResource ForwardBackButtonStyle}">
                <Button.ToolTip>
                    <TextBlock Text="Navigate forward (Alt + Right)" />
                </Button.ToolTip>
                <Image Source="resources\forwd_24x24.png" Height="24" Width="24"/>
            </Button>
            <Separator />
            <Button Style="{DynamicResource ForwardBackButtonStyle}" Command="local:Commands.Add">
                <Button.ToolTip>
                    <TextBlock Text="Add files to project (Ctrl + A)" />
                </Button.ToolTip>
                <Image Source="resources\add_24x24.png" Height="24" Width="24" />
            </Button>
            <Button Command="local:Commands.Remove" Style="{DynamicResource ForwardBackButtonStyle}">
                <Button.ToolTip>
                    <TextBlock Text="Remove assembly from project" />
                </Button.ToolTip>
                <Image Source="resources\remov_24x24.png" Height="24" Width="24" />
            </Button>
        </ToolBar>
        
		<StatusBar DockPanel.Dock="Bottom">
            <StatusBar.ContextMenu>
                <ContextMenu>
                    <MenuItem Icon=""/>
                </ContextMenu>
            </StatusBar.ContextMenu>
			<StatusBarItem>
                <TextBlock />
            </StatusBarItem>
		</StatusBar>
		<Grid>
			<DockPanel x:Name="documentpage" Visibility="Visible" d:IsHidden="True">
				<Border BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" BorderThickness="0,1,0,1">
		        <Grid>
		            <Grid.ColumnDefinitions>
		                <ColumnDefinition Width="*" />
		                <ColumnDefinition Width="3" />
		                <ColumnDefinition Width="3*" />
		            </Grid.ColumnDefinitions>
		            <DockPanel Grid.Column="0">
	                    <toolkit:AutoCompleteBox ItemTemplate="{DynamicResource searchResultDataTemplate}"
	                       x:Name="searchBox" DockPanel.Dock="Top"
	                       Populating="searchBox_Populating" FilterMode="None"                                             
	                       MaxDropDownHeight="300" MinimumPrefixLength="4" BorderThickness="1"
	                       SelectionChanged="searchBox_SelectionChanged" IsTextCompletionEnabled="False"
	                       Style="{DynamicResource SearchBoxStyle}" BorderBrush="{DynamicResource ToolBarGripper}"
	                       />
	                    <TreeView x:Name="documentMap" 
							SelectedItemChanged="documentMap_SelectedItemChanged" 
							BorderBrush="{x:Null}"
	                        ItemContainerStyle="{DynamicResource TreeViewItemStyle}" 
	                        ItemTemplateSelector="{DynamicResource treeViewDataTemplateSelector}"
	                              />
	                </DockPanel>            
		            <GridSplitter Grid.Column="1" Width="3" 
	                              ResizeBehavior="PreviousAndNext" 
	                              BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" 
	                              BorderThickness="1,0,1,0" />
	                <DockPanel Grid.Column="3">
	                    <FlowDocumentReader x:Name="pageViewer" IsFindEnabled="False" />
	                </DockPanel>
		        </Grid>
			</Border>
			</DockPanel>
			<DockPanel x:Name="startpage">
				<Grid>
			    	<Grid.RowDefinitions>
			    		<RowDefinition Height="67.9" />
			    		<RowDefinition Height="*"/>
			    	</Grid.RowDefinitions>

                    <Border Grid.Row="0" BorderBrush="#FF57bfcb" BorderThickness="0,0,0,1" Background="#FF57bfcb" Margin="0,0,0,-0.04" Height="67.9">
                        <TextBlock Margin="16,17,0,10" Text="Live Documenter" TextWrapping="Wrap" FontSize="24" Foreground="#FFFFFFFF"/>
                    </Border>

                    <Grid Grid.Row="1" Background="#FFEFEEE8" RenderTransformOrigin="0.501,0.51">
	                    <Grid.ColumnDefinitions>
	                    	<ColumnDefinition Width="300" />
	                    	<ColumnDefinition />
	                    </Grid.ColumnDefinitions>
	                    <Grid.RowDefinitions>
	                    	<RowDefinition Height="65"/>
	                    	<RowDefinition Height="*"/>
	                    </Grid.RowDefinitions>
						
	                    <StackPanel Margin="10" Grid.Row="0" Grid.ColumnSpan="2">
	                    	<TextBlock Style="{DynamicResource header}"><Run Text="Welcome to the Live Documenter"/></TextBlock>
	                    	<TextBlock FontSize="14"><Run Text="To start you can open a solution, project or library. Or select a recent file from the recent file list."/></TextBlock>
	                    </StackPanel>
						
	                    <StackPanel Margin="10" Grid.Row="1" Grid.Column="0" x:Name="recent">
                            <StackPanel x:Name="start_recentFiles">
                                <TextBlock Style="{DynamicResource header}"><Run Text="Recent files"/></TextBlock>
	                    	    <TextBlock/>
                                <ListView x:Name="start_recentFileList" BorderBrush="#FFC4C4C4" Background="White" SelectionChanged="start_recentFileList_SelectionChanged">
                                	<ListView.Resources>
                                		<Style TargetType="{x:Type ListViewItem}">
                                			<Style.Triggers>
                                				<Trigger Property="IsMouseOver" Value="True">
                                					<Setter Property="Background" Value="#FF212120" />
													<Setter Property="Foreground" Value="#FFA67D3D" />
												</Trigger>                     			
											</Style.Triggers>                      		
										</Style>
									</ListView.Resources>
                                    <ListView.ItemTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding DisplayName}" Padding="5" />
                                        </DataTemplate>
                                    </ListView.ItemTemplate>
                                </ListView>
                            </StackPanel>
                            <Button Command="Open" Width="{Binding ElementName=recent, Path=ActualWidth}">
	                    		<Grid>
	                    			<Grid.ColumnDefinitions>
	                    				<ColumnDefinition Width="*" />
										<ColumnDefinition Width="26" />
									</Grid.ColumnDefinitions>           				
											
									<TextBlock Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,0,10,0">Open file...</TextBlock>
									<Image Grid.Column="1" Source="resources\open_24x24.png" Height="24" Width="24" Margin="0,2"  />
								</Grid>
	                    	</Button>
	                    </StackPanel>
                        
                        <Canvas Grid.Row="1" Grid.Column="2">
                            <Image Source="Resources\frontpage-background.png" Width="400" Height="250" Canvas.Bottom="0" Canvas.Right="0" />
                        </Canvas>
                    </Grid>
				</Grid>
			</DockPanel>
		</Grid>
    </DockPanel>
</Window>
