<Window x:Class="Hiyoko.Themes.ImageBrushSettingsForm" x:Name="this"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:local="clr-namespace:Hiyoko.Themes"
	Title="設定" SizeToContent="WidthAndHeight"
	ShowInTaskbar="false" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" FontSize="12">
	<Window.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="/PresentationFramework.Aero, Version=3.0.0.0, Culture=Neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;component/themes/aero.normalcolor.xaml" />
			</ResourceDictionary.MergedDictionaries>
			
			<local:UriToStringConverter x:Key="UriToStringConverter" />
			
			<Style TargetType="{x:Type TextBox}">
				<Setter Property="Validation.ErrorTemplate">
					<Setter.Value>
						<ControlTemplate>
							<DockPanel LastChildFill="True">
								<Border BorderBrush="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
									Background="{DynamicResource {x:Static SystemColors.InfoBrushKey}}"
									BorderThickness="1" DockPanel.Dock="Bottom">
									<TextBlock Text="{Binding ElementName=MyAdorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}" />
								</Border>
								<AdornedElementPlaceholder Name="MyAdorner" />
							</DockPanel>
						</ControlTemplate>
					</Setter.Value>
				</Setter>
				<Setter Property="local:TextBoxBehaviors.IsSelectAllOnFocus" Value="true" />
			</Style>
		</ResourceDictionary>
	</Window.Resources>
	<Window.CommandBindings>
		<CommandBinding Command="ApplicationCommands.Close" Executed="Close_Execute" CanExecute="Close_CanExecute"/>
		<CommandBinding Command="ApplicationCommands.Save" Executed="Save_Execute" CanExecute="Save_CanExecute"/>
	</Window.CommandBindings>
	<StackPanel Orientation="Vertical" Margin="4" Width="360">
		<GroupBox>
			<GroupBox.Header>
				<Label>画像ファイル(_F):</Label>
			</GroupBox.Header>
			<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="*" />
					<ColumnDefinition Width="auto" />
				</Grid.ColumnDefinitions>
				<TextBox Name="imageFileEdit" Grid.Column="0" Text="{Binding Path=ImageFile, UpdateSourceTrigger=PropertyChanged}" />
				<Button Grid.Column="1" Click="OpenImage"><AccessText Text="開く(_O)..." /></Button>
			</Grid>
		</GroupBox>
		<GroupBox>
			<GroupBox.Header>
				<Label>敷き詰め方法(_T):</Label>
			</GroupBox.Header>
			<ComboBox Name="tileModeBox" DisplayMemberPath="Key" SelectedValuePath="Value"
				SelectedValue="{Binding Path=TempSettings.TileMode, ElementName=this}" ItemsSource="{Binding}"/>
		</GroupBox>
		<GroupBox>
			<GroupBox.Header>
				<Label>引き延ばし(_S):</Label>
			</GroupBox.Header>
			<ComboBox Name="stretchBox" DisplayMemberPath="Key" SelectedValuePath="Value"
				SelectedValue="{Binding Path=TempSettings.Stretch, ElementName=this}" ItemsSource="{Binding}">
				<ComboBox.Style>
					<Style TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
						<Style.Triggers>
							<DataTrigger Binding="{Binding ElementName=tileModeBox, Path=SelectedValue}" Value="Tile">
								<Setter Property="IsEnabled" Value="false" />
							</DataTrigger>
							<DataTrigger Binding="{Binding ElementName=tileModeBox, Path=SelectedValue}" Value="FlipX">
								<Setter Property="IsEnabled" Value="false" />
							</DataTrigger>
							<DataTrigger Binding="{Binding ElementName=tileModeBox, Path=SelectedValue}" Value="FlipY">
								<Setter Property="IsEnabled" Value="false" />
							</DataTrigger>
							<DataTrigger Binding="{Binding ElementName=tileModeBox, Path=SelectedValue}" Value="FlipXY">
								<Setter Property="IsEnabled" Value="false" />
							</DataTrigger>
						</Style.Triggers>
					</Style>
				</ComboBox.Style>
			</ComboBox>
		</GroupBox>
		<GroupBox>
			<GroupBox.Header>
				<Label>位置(_A):</Label>
			</GroupBox.Header>
			<StackPanel Orientation="Vertical">
				<Label Target="{Binding ElementName=alignmentXBox}">横軸方向(_X)</Label>
				<ComboBox Name="alignmentXBox" DisplayMemberPath="Key" SelectedValuePath="Value"
					SelectedValue="{Binding Path=TempSettings.AlignmentX, ElementName=this}" ItemsSource="{Binding}">
					<ComboBox.Style>
						<Style TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
							<Style.Triggers>
								<DataTrigger Binding="{Binding ElementName=tileModeBox, Path=SelectedValue}" Value="Tile">
									<Setter Property="IsEnabled" Value="false" />
								</DataTrigger>
								<DataTrigger Binding="{Binding ElementName=tileModeBox, Path=SelectedValue}" Value="FlipX">
									<Setter Property="IsEnabled" Value="false" />
								</DataTrigger>
								<DataTrigger Binding="{Binding ElementName=tileModeBox, Path=SelectedValue}" Value="FlipY">
									<Setter Property="IsEnabled" Value="false" />
								</DataTrigger>
								<DataTrigger Binding="{Binding ElementName=tileModeBox, Path=SelectedValue}" Value="FlipXY">
									<Setter Property="IsEnabled" Value="false" />
								</DataTrigger>
							</Style.Triggers>
						</Style>
					</ComboBox.Style>
				</ComboBox>

				<Label Target="{Binding ElementName=alignmentYBox}">縦軸方向(_Y)</Label>
				<ComboBox Name="alignmentYBox" DisplayMemberPath="Key" SelectedValuePath="Value"
					SelectedValue="{Binding Path=TempSettings.AlignmentY, ElementName=this}" ItemsSource="{Binding}">
					<ComboBox.Style>
						<Style TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
							<Style.Triggers>
								<DataTrigger Binding="{Binding ElementName=tileModeBox, Path=SelectedValue}" Value="Tile">
									<Setter Property="IsEnabled" Value="false" />
								</DataTrigger>
								<DataTrigger Binding="{Binding ElementName=tileModeBox, Path=SelectedValue}" Value="FlipX">
									<Setter Property="IsEnabled" Value="false" />
								</DataTrigger>
								<DataTrigger Binding="{Binding ElementName=tileModeBox, Path=SelectedValue}" Value="FlipY">
									<Setter Property="IsEnabled" Value="false" />
								</DataTrigger>
								<DataTrigger Binding="{Binding ElementName=tileModeBox, Path=SelectedValue}" Value="FlipXY">
									<Setter Property="IsEnabled" Value="false" />
								</DataTrigger>
							</Style.Triggers>
						</Style>
					</ComboBox.Style>
				</ComboBox>
			</StackPanel>
		</GroupBox>
		<GroupBox>
			<GroupBox.Header>
				<Label>不透明度(_P):</Label>
			</GroupBox.Header>
			<StackPanel Orientation="Vertical">
				<Slider Name="opacitySlider" Maximum="1.0" Minimum="0.0" Value="{Binding Path=Opacity, Mode=TwoWay}"/>
				<TextBox>
					<TextBox.Text>
						<Binding Path="Value" ElementName="opacitySlider" UpdateSourceTrigger="PropertyChanged">
						</Binding>
					</TextBox.Text>
				</TextBox>
			</StackPanel>
		</GroupBox>
		<Grid>
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="2*" />
				<ColumnDefinition Width="*" />
				<ColumnDefinition Width="*" />
			</Grid.ColumnDefinitions>
			<Button Command="ApplicationCommands.Save" Grid.Column="1" Margin="4" IsDefault="true"><AccessText Text="OK" /></Button>
			<Button Command="ApplicationCommands.Close" Grid.Column="2" Margin="4" IsCancel="true"><AccessText Text="キャンセル" /></Button>
		</Grid>
	</StackPanel>
</Window>