<?xml version="1.0" encoding="utf-8"?>
<Window
	x:Class="ICSharpCode.ILSpy.MainWindow"
	x:ClassModifier="public"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:tv="clr-namespace:ICSharpCode.TreeView;assembly=ICSharpCode.TreeView"
	xmlns:local="clr-namespace:ICSharpCode.ILSpy"
	xmlns:avalondock="http://schemas.xceed.com/wpf/xaml/avalondock"
	xmlns:controls="clr-namespace:ICSharpCode.ILSpy.Controls"
	xmlns:docking="clr-namespace:ICSharpCode.ILSpy.Docking"
	xmlns:textview="clr-namespace:ICSharpCode.ILSpy.TextView"
	xmlns:analyzers="clr-namespace:ICSharpCode.ILSpy.Analyzers"
	xmlns:properties="clr-namespace:ICSharpCode.ILSpy.Properties"
	xmlns:viewmodels="clr-namespace:ICSharpCode.ILSpy.ViewModels"
	Title="ILSpy"
	MinWidth="250"
	MinHeight="200"
	UseLayoutRounding="True"
	TextOptions.TextFormattingMode="Display"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" d:DesignHeight="500" d:DesignWidth="500"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
>
	<Window.Resources>
		<controls:BoolToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
		<docking:ActiveTabPageConverter x:Key="ActiveTabPageConverter"/>

		<tv:SharpTreeView x:Key="AssemblyTreeView"
				AutomationProperties.Name="Assemblies and Classes"
				SelectionChanged="TreeView_SelectionChanged"
				ShowRoot="False"
				AllowDropOrder="True"
				AllowDrop="True"
				BorderThickness="0,1,1,1" Visibility="Visible" />

		<DataTemplate x:Key="AssemblyListPaneTemplate">
			<ContentControl Content="{StaticResource AssemblyTreeView}" />
		</DataTemplate>

		<local:DebugSteps x:Key="DebugSteps" />

		<DataTemplate x:Key="DebugStepsPaneTemplate">
			<ContentControl Content="{StaticResource DebugSteps}" />
		</DataTemplate>

		<local:SearchPane x:Key="SearchPane" />

		<DataTemplate x:Key="SearchPaneTemplate">
			<ContentControl Content="{StaticResource SearchPane}" />
		</DataTemplate>

		<analyzers:AnalyzerTreeView x:Key="AnalyzerTreeView" />

		<DataTemplate x:Key="AnalyzerPaneTemplate">
			<ContentControl Content="{StaticResource AnalyzerTreeView}" />
		</DataTemplate>

		<DataTemplate x:Key="DefaultContentTemplate">
			<ContentPresenter Content="{Binding Content}" />
		</DataTemplate>
	</Window.Resources>

	<Window.CommandBindings>
		<CommandBinding
			Command="Open"
			Executed="OpenCommandExecuted" />
		<CommandBinding
			Command="Refresh"
			Executed="RefreshCommandExecuted" />
		<CommandBinding
			Command="Save"
			CanExecute="SaveCommandCanExecute"
			Executed="SaveCommandExecuted" />
		<CommandBinding
			Command="BrowseBack"
			CanExecute="BackCommandCanExecute"
			Executed="BackCommandExecuted" />
		<CommandBinding
			Command="BrowseForward"
			CanExecute="ForwardCommandCanExecute"
			Executed="ForwardCommandExecuted" />
		<CommandBinding
			Command="Search"
			Executed="SearchCommandExecuted" />
	</Window.CommandBindings>
	<Window.InputBindings>
		<KeyBinding Key="R" Modifiers="Control" Command="{x:Static local:ILSpyCommands.Analyze}" />
	</Window.InputBindings>
	<Window.TaskbarItemInfo>
		<TaskbarItemInfo />
	</Window.TaskbarItemInfo>
	<DockPanel>
		<!-- Main menu -->
		<Menu DockPanel.Dock="Top" Name="mainMenu" Height="23" KeyboardNavigation.TabNavigation="None">
			<MenuItem Header="{x:Static properties:Resources._File}" />
			<!-- contents of file menu are added using MEF -->
			<MenuItem Header="{x:Static properties:Resources._View}">
				<MenuItem Header="{x:Static properties:Resources.Show_publiconlyTypesMembers}" IsCheckable="True" IsChecked="{Binding SessionSettings.FilterSettings.ApiVisPublicOnly}" />
				<MenuItem Header="{x:Static properties:Resources.Show_internalTypesMembers}" IsCheckable="True" IsChecked="{Binding SessionSettings.FilterSettings.ApiVisPublicAndInternal}" />
				<MenuItem Header="{x:Static properties:Resources.Show_allTypesAndMembers}" IsCheckable="True" IsChecked="{Binding SessionSettings.FilterSettings.ApiVisAll}" />
			</MenuItem>
			<MenuItem Header="{x:Static properties:Resources._Window}" />
		</Menu>
		<!-- ToolBar -->
		<ToolBar
			Name="toolBar"
			DockPanel.Dock="Top" ToolBarTray.IsLocked="True" KeyboardNavigation.TabNavigation="None">
			<ToolBar.Resources>
				<!-- Make images transparent if menu command is disabled -->
				<Style TargetType="{x:Type Image}">
					<Style.Triggers>
						<DataTrigger
							Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ButtonBase}, AncestorLevel=1}, Path=IsEnabled}"
							Value="False">
							<Setter Property="Opacity" Value="0.30" />
						</DataTrigger>
					</Style.Triggers>
				</Style>
			</ToolBar.Resources>
			<!-- 'Navigation' toolbar category is inserted here -->
			<Separator />
			<!-- 'Open' toolbar category is inserted here -->
			<Separator />
			<ComboBox Name="assemblyListComboBox" Width="100" MaxDropDownHeight="Auto"
			          ItemsSource="{Binding AssemblyListManager.AssemblyLists}" ToolTip="{x:Static properties:Resources.SelectAssemblyListDropdownTooltip}"
			          SelectedItem="{Binding SessionSettings.ActiveAssemblyList}"/>
			<Button Command="{x:Static local:ILSpyCommands.ManageAssemblyListsCommand}" ToolTip="{x:Static properties:Resources.ManageAssemblyLists}">
				<Image Width="16" Height="16" Source="{controls:XamlResource Images/AssemblyList}" />
			</Button>
			<Separator />
			<CheckBox IsChecked="{Binding SessionSettings.FilterSettings.ApiVisPublicOnly}" ToolTip="{x:Static properties:Resources.ShowPublicOnlyTypesMembers}">
				<Image Width="16" Height="16" Source="{controls:XamlResource Images/ShowPublicOnly}" />
			</CheckBox>
			<CheckBox IsChecked="{Binding SessionSettings.FilterSettings.ApiVisPublicAndInternal}" ToolTip="{x:Static properties:Resources.ShowInternalTypesMembers}">
				<Image Width="16" Height="16" Source="{controls:XamlResource Images/ShowPrivateInternal}" />
			</CheckBox>
			<CheckBox IsChecked="{Binding SessionSettings.FilterSettings.ApiVisAll}" ToolTip="{x:Static properties:Resources.ShowAllTypesAndMembers}">
				<Image Width="16" Height="16" Source="{controls:XamlResource Images/ShowAll}" />
			</CheckBox>
			<Separator />
			<ComboBox Name="languageComboBox" DisplayMemberPath="Name" Width="100" MaxDropDownHeight="Auto"
					  IsEnabled="{Binding ActiveTabPage.SupportsLanguageSwitching, Source={x:Static docking:DockWorkspace.Instance}}"
			          ItemsSource="{x:Static local:Languages.AllLanguages}" ToolTip="{x:Static properties:Resources.SelectLanguageDropdownTooltip}"
			          SelectedItem="{Binding SessionSettings.FilterSettings.Language}"/>
			<ComboBox Name="languageVersionComboBox" DisplayMemberPath="DisplayName" Width="120" MaxDropDownHeight="Auto" ToolTip="{x:Static properties:Resources.SelectVersionDropdownTooltip}"
			          Visibility="{Binding SelectedItem.HasLanguageVersions, ElementName=languageComboBox, Converter={StaticResource BooleanToVisibilityConverter}}"
					  IsEnabled="{Binding ActiveTabPage.SupportsLanguageSwitching, Source={x:Static docking:DockWorkspace.Instance}}"
			          ItemsSource="{Binding SelectedItem.LanguageVersions, ElementName=languageComboBox, UpdateSourceTrigger=PropertyChanged}"
			          SelectedItem="{Binding SessionSettings.FilterSettings.LanguageVersion, UpdateSourceTrigger=PropertyChanged}"/>
		</ToolBar>
		<Border DockPanel.Dock="Top" BorderBrush="Black" BorderThickness="1" Name="updatePanel" Visibility="Collapsed">
			<DockPanel KeyboardNavigation.TabNavigation="Contained">
				<Button DockPanel.Dock="Right" Click="updatePanelCloseButtonClick" MinWidth="0">X</Button>
				<StackPanel Orientation="Horizontal">
					<TextBlock Name="updatePanelMessage" Margin="4,0" VerticalAlignment="Center"  Text="{x:Static properties:Resources.ILSpyVersionAvailable}" />
					<Button Name="downloadOrCheckUpdateButton" Click="downloadOrCheckUpdateButtonClick" Content="{x:Static properties:Resources.Download}"/>
				</StackPanel>
			</DockPanel>
		</Border>
		<!-- Status bar -->
		<StatusBar x:Name="statusBar" DockPanel.Dock="Bottom" Height="26" Visibility="Collapsed">
			<StatusBarItem DockPanel.Dock="Right">
				<TextBlock VerticalAlignment="Center"
				           HorizontalAlignment="Right"
				           x:Name="StatusLabel"
				           ToolTip="{x:Static properties:Resources.Status}"
				           Text="{x:Static properties:Resources.StandBy}"/>
			</StatusBarItem>
		</StatusBar>

		<avalondock:DockingManager x:Name="DockManager"
									DataContext="{Binding Workspace}"
									AnchorablesSource="{Binding ToolPanes}"
									DocumentsSource="{Binding TabPages}"
									ActiveContent="{Binding ActiveTabPage, Mode=TwoWay, Converter={StaticResource ActiveTabPageConverter}}"
									AllowMixedOrientation="True">

			<avalondock:DockingManager.DocumentHeaderTemplate>
				<DataTemplate>
					<TextBlock x:Name="headerText" Text="{Binding Title}" />
					<DataTemplate.Triggers>
						<DataTrigger Binding="{Binding IsActive}" Value="True">
							<Setter TargetName="headerText" Property="FontWeight" Value="Bold" />
						</DataTrigger>
					</DataTemplate.Triggers>
				</DataTemplate>
			</avalondock:DockingManager.DocumentHeaderTemplate>

			<avalondock:DockingManager.LayoutItemContainerStyleSelector>
				<docking:PaneStyleSelector>
					<docking:PaneStyleSelector.ToolPaneStyle>
						<Style TargetType="{x:Type avalondock:LayoutAnchorableItem}">
							<Setter Property="Title" Value="{Binding Model.Title}"/>
							<Setter Property="Visibility" Value="{Binding Model.IsVisible, Mode=TwoWay, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter={x:Static Visibility.Hidden}}"/>
							<Setter Property="ContentId" Value="{Binding Model.ContentId}"/>
							<Setter Property="IsSelected" Value="{Binding Model.IsSelected, Mode=TwoWay}"/>
							<Setter Property="IsActive" Value="{Binding Model.IsActive, Mode=TwoWay}"/>
							<Setter Property="CanHide" Value="{Binding Model.IsCloseable}" />
							<Setter Property="HideCommand" Value="{Binding Model.CloseCommand}" />
							<Setter Property="CanClose" Value="{Binding Model.IsCloseable}" />
						</Style>
					</docking:PaneStyleSelector.ToolPaneStyle>
					<docking:PaneStyleSelector.TabPageStyle>
						<Style TargetType="{x:Type avalondock:LayoutItem}">
							<Setter Property="Title" Value="{Binding Model.Title}"/>
							<Setter Property="Visibility" Value="{Binding Model.IsVisible, Mode=TwoWay, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter={x:Static Visibility.Hidden}}"/>
							<Setter Property="ContentId" Value="{Binding Model.ContentId}"/>
							<Setter Property="IsSelected" Value="{Binding Model.IsSelected, Mode=TwoWay}"/>
							<Setter Property="IsActive" Value="{Binding Model.IsActive, Mode=TwoWay}"/>
							<Setter Property="CloseCommand" Value="{Binding Model.CloseCommand}" />
							<Setter Property="CanClose" Value="{Binding Model.IsCloseable, Mode=TwoWay}" />
						</Style>
					</docking:PaneStyleSelector.TabPageStyle>
				</docking:PaneStyleSelector>
			</avalondock:DockingManager.LayoutItemContainerStyleSelector>
		</avalondock:DockingManager>
	</DockPanel>
</Window>
