
	
<Window
	
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell"	
    xmlns:l="clr-namespace:BuzzGUI.ParameterWindow;assembly=BuzzGUI.ParameterWindow"
    xmlns:bgc="clr-namespace:BuzzGUI.Common;assembly=BuzzGUI.Common"
    bgc:CommandSinkBinding.CommandSink="{Binding}"
    Height="300" Width="410" WindowStyle="ToolWindow" ShowInTaskbar="False" SizeToContent="Height"
		UseLayoutRounding="True" TextOptions.TextFormattingMode="Display"
  
    >

	<shell:WindowChrome.WindowChrome>
		<shell:WindowChrome GlassFrameThickness="-1" ResizeBorderThickness="4" CaptionHeight="24"/>
	</shell:WindowChrome.WindowChrome> 
	
	<Window.Template>
			<ControlTemplate TargetType="{x:Type Window}">
				<Grid>
					<Border Margin="0,24,0,0" >
						<ContentPresenter Content="{TemplateBinding Content}"/>
					</Border>

					<Border Margin="1,24,1,0" BorderBrush="Gray" BorderThickness="0,1,0,0" Grid.ZIndex="-1">
						<Rectangle Fill="White" Opacity="0.5" />
					</Border>

					<TextBlock VerticalAlignment="Top" TextAlignment="Left" Padding="8,6,0,0">
						<TextBlock.Text>
							<MultiBinding StringFormat="{}{0} - {1}">
								<Binding Path="MachineName"/>
								<Binding Path="MachineInfoName"/>
							</MultiBinding>
						</TextBlock.Text>
					</TextBlock>

				</Grid>
			</ControlTemplate>

	</Window.Template>

	<Window.Resources>
		<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
			<Setter Property="FontSize" Value="10"/>
		</Style>

		<Style x:Key="ContextMenuItemStyle">
			<Setter Property="MenuItem.Header" Value="{Binding Text}"/>
			<Setter Property="MenuItem.ItemsSource" Value="{Binding Children}"/>
			<Setter Property="MenuItem.Command" Value="{Binding Command}" />
			<Setter Property="MenuItem.CommandParameter" Value="{Binding CommandParameter}" />
			<Setter Property="MenuItem.IsEnabled" Value="{Binding IsEnabled}" />
			<Setter Property="MenuItem.IsChecked" Value="{Binding IsChecked}" />
			<Setter Property="MenuItem.Margin" Value="4,0,0,0" />

			<!--
      <Setter Property="MenuItem.FontFamily" Value="Calibri, Tahoma" />
      <Setter Property="MenuItem.FontSize" Value="12" />
-->

			<Style.Triggers>
				<DataTrigger Binding="{Binding IsDefault}" Value="True">
					<Setter Property="MenuItem.FontWeight" Value="Bold"/>
				</DataTrigger>
			</Style.Triggers>

		</Style>

		<Style TargetType="MenuItem" BasedOn="{StaticResource ContextMenuItemStyle}"/>

		<Style x:Key="LockButtonStyle" TargetType="{x:Type ToggleButton}">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type ToggleButton}">
						<Image Name="image" Source="../Default/gfx/button_param_unlocked.png"/>
						<ControlTemplate.Triggers>
							<Trigger Property="IsChecked" Value="True">
								<Setter TargetName="image" Property="Source" Value="../Default/gfx/button_param_locked_alt.png"/>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>


	</Window.Resources>

	<Window.CommandBindings>
		<bgc:CommandSinkBinding Command="l:ParameterWindowVM.PresetsCommand"/>
		<bgc:CommandSinkBinding Command="l:ParameterWindowVM.CopyCommand"/>
		<bgc:CommandSinkBinding Command="l:ParameterWindowVM.EditCommand"/>
		<bgc:CommandSinkBinding Command="l:ParameterWindowVM.HelpCommand"/>
		<bgc:CommandSinkBinding Command="l:ParameterWindowVM.SelectPresetCommand"/>
	</Window.CommandBindings>


	<Window.Style>
		<Style TargetType="{x:Type Window}">
			<!--
      <Style.Triggers>
        <DataTrigger Binding="{Binding Path=Machine.DLL.Info.Type}" Value="Master">
          <Setter Property="Background">
            <Setter.Value>
              <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                <GradientStop Color="{Binding Path=ThemeColors[MV Master]}" Offset="0.0"/>
                <GradientStop Color="White" Offset="1.0"/>
              </LinearGradientBrush>
            </Setter.Value>
          </Setter>
        </DataTrigger>
        <DataTrigger Binding="{Binding Path=Machine.DLL.Info.Type}" Value="Generator">
          <Setter Property="Background">
            <Setter.Value>
              <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                <GradientStop Color="{Binding Path=ThemeColors[MV Generator]}" Offset="0.0"/>
                <GradientStop Color="White" Offset="1.0"/>
              </LinearGradientBrush>
            </Setter.Value>
          </Setter>
        </DataTrigger>
        <DataTrigger Binding="{Binding Path=Machine.DLL.Info.Type}" Value="Effect">
          <Setter Property="Background">
            <Setter.Value>
              <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                <GradientStop Color="{Binding Path=ThemeColors[MV Effect]}" Offset="0.0"/>
                <GradientStop Color="White" Offset="1.0"/>
              </LinearGradientBrush>
            </Setter.Value>
          </Setter>
        </DataTrigger>
        <DataTrigger Binding="{Binding Path=Machine.IsControlMachine}" Value="True">
          <Setter Property="Background">
            <Setter.Value>
              <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                <GradientStop Color="{Binding Path=ThemeColors[MV Control]}" Offset="0.0"/>
                <GradientStop Color="White" Offset="1.0"/>
              </LinearGradientBrush>
            </Setter.Value>
          </Setter>
        </DataTrigger>
      </Style.Triggers>
-->
		</Style>
	</Window.Style>


	<Grid Margin="8">

		<Grid.RowDefinitions>
			<RowDefinition Height="23"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="8"/>
			<RowDefinition Height="2"/>
			<RowDefinition Height="8"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="*"/>
		</Grid.RowDefinitions>


		<Grid>
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="2.5*"/>
				<ColumnDefinition Width="*"/>
				<ColumnDefinition Width="*"/>
				<ColumnDefinition Width="*"/>
				<ColumnDefinition Width="*"/>
			</Grid.ColumnDefinitions>

			<bgc:ComboBoxEx ItemsSource="{Binding PresetsWithDefault}" SelectedIndex="0" bgc:ItemSelectedBehavior.ItemSelected="l:ParameterWindowVM.SelectPresetCommand" Text="{Binding PresetAName}" ToolTip="Preset A"/>
			<Button Command="l:ParameterWindowVM.PresetsCommand" Grid.Column="1" Margin="6,0,0,0">Presets...</Button>
			<Button Command="l:ParameterWindowVM.CopyCommand" Grid.Column="2" Margin="6,0,0,0">Copy</Button>
			<Button Command="l:ParameterWindowVM.HelpCommand" Grid.Column="3" Margin="6,0,0,0">Help</Button>
			<Button Command="l:ParameterWindowVM.EditCommand" Grid.Column="4" Margin="6,0,0,0" Content="{Binding EditButtonText}"/>
		</Grid>

		<Grid Grid.Row="1" Visibility="{Binding EditGridVisibility}">

			<Grid.RowDefinitions>
				<RowDefinition Height="31"/>
				<RowDefinition Height="31"/>
			</Grid.RowDefinitions>

			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="2.5*"/>
				<ColumnDefinition Width="*"/>
				<ColumnDefinition Width="*"/>
				<ColumnDefinition Width="*"/>
				<ColumnDefinition Width="*"/>
			</Grid.ColumnDefinitions>

			<bgc:ComboBoxEx Grid.Row="0" Margin="0,8,0,0" ItemsSource="{Binding PresetsWithDefault}" SelectedIndex="0" ToolTip="Preset B" Text="{Binding PresetBName}" IsEnabled="{Binding IsPresetBEnabled}"/>

			<ComboBox Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="3" Margin="6,8,0,0" SelectedIndex="{Binding EditFunctionIndex}" ToolTip="Edit Function">
				<ComboBoxItem>Randomize (Absolute)</ComboBoxItem>
				<ComboBoxItem>Randomize (Relative)</ComboBoxItem>
				<ComboBoxItem>Randomize (A..B)</ComboBoxItem>
				<ComboBoxItem>Randomize (A or B)</ComboBoxItem>
				<ComboBoxItem>Morph (A..B)</ComboBoxItem>
			</ComboBox>

			<Button Grid.Column="4" Grid.ColumnSpan="1" Margin="6,8,0,0" Command="{Binding ApplyCommand}">Apply</Button>

			<Slider Grid.Row="1" Grid.ColumnSpan="5" Margin="0,8,0,0" ToolTip="Edit Function Parameter" Minimum="0" Maximum="1" SmallChange="0.01" LargeChange="0.1" Value="{Binding EditFunctionParameter}" IsEnabled="{Binding IsEditFunctionParameterEnabled}"/>


		</Grid>

		<Border Grid.Row="3" BorderThickness="0,1,0,0" BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"/>
		<Border Grid.Row="3" BorderThickness="0,0,0,1" BorderBrush="White"/>

		<ContentControl Grid.Row="5" Content="{Binding EmbeddedGUI}"/>

		<ScrollViewer Grid.Row="6" VerticalScrollBarVisibility="Auto">
			<ItemsControl ItemsSource="{Binding Parameters}" Focusable="False">
				<ItemsControl.ItemTemplate>
					<DataTemplate>
						<Grid Height="16">

							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto"/>
								<ColumnDefinition Width="90"/>
								<ColumnDefinition Width="*"/>
								<ColumnDefinition Width="90"/>
							</Grid.ColumnDefinitions>

							<ToggleButton Grid.Column="0" Style="{StaticResource LockButtonStyle}" Margin="0,0,4,0" ClickMode="Press" IsChecked="{Binding IsLocked}" Visibility="{Binding LockButtonVisibility}"/>

							<TextBlock Grid.Column="1" Text="{Binding Name}" ToolTip="{Binding Description}"/>
							<Border Grid.Column="2" Height="14" BorderThickness="0,0,1,1" BorderBrush="White" SnapsToDevicePixels="True">
								<Border BorderThickness="1,1,0,0" BorderBrush="#5000" SnapsToDevicePixels="True">
									<bgc:ParameterSlider MinimumThumbWidth="12" Focusable="True" Value="{Binding Value}" Minimum="{Binding MinValue}" Maximum="{Binding MaxValue}"/>
								</Border>
							</Border>
							<TextBlock Grid.Column="3" Margin="4,0,0,0" Text="{Binding ValueDescription}"/>

							<Grid.ContextMenu>
								<ContextMenu>
									<MenuItem Header="_Bind to MIDI Controller" ItemsSource="{Binding MIDIControllers}" ItemContainerStyle="{StaticResource ContextMenuItemStyle}"/>
									<MenuItem Header="_Unbind All" Command="{Binding UnbindMIDICommand}"/>
									<Separator/>
									<MenuItem Header="_Attributes" ItemsSource="{Binding Attributes}" IsEnabled="{Binding HasAttributes}" ItemContainerStyle="{StaticResource ContextMenuItemStyle}"/>
									<Separator/>
									<MenuItem Header="_Copy Preset (ASCII)" Command="{Binding CopyPresetCommand}" CommandParameter="ASCII"/>
									<MenuItem Header="_Copy Preset (XML)" Command="{Binding CopyPresetCommand}" CommandParameter="XML"/>
									<MenuItem Header="_Paste Preset" Command="{Binding PastePresetCommand}"/>
									<Separator/>
									<MenuItem Header="_Unlock All" Command="{Binding UnlockAllCommand}"/>
									<MenuItem Header="_Invert Locks" Command="{Binding InvertLocksCommand}"/>
								</ContextMenu>
							</Grid.ContextMenu>

						</Grid>
					</DataTemplate>
				</ItemsControl.ItemTemplate>
			</ItemsControl>
		</ScrollViewer>

	</Grid>

</Window>
