<Window x:Class="K11_CNC.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:K11_CNC.ViewModel"
        
        Title="K11-CNC-Messeinrichtung" FontSize="20" Height="1000" Width="1000">
    <Window.Resources>
        <ControlTemplate x:Key="btnround" TargetType="Button">
            <Grid>
                <Ellipse Fill="{TemplateBinding Background}" Stroke="{TemplateBinding Foreground}"/>
                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
            </Grid>
        </ControlTemplate>
        
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary  Source="Resources\NavigationButtons.xaml" />
            <ResourceDictionary Source="Resources\AnzeigeTextboxen.xaml" />
        </ResourceDictionary.MergedDictionaries>
            <local:MainViewModel x:Key="vm" />
        </ResourceDictionary>
       
    </Window.Resources>
    
    <Grid Background="{DynamicResource MainWindowBackgroudBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="40" />
            <RowDefinition Height="40" />
            <RowDefinition Height="10*"/>
            <RowDefinition Height="60*"/>
            <RowDefinition Height="60*"/>
            <RowDefinition Height="100"/>
            <RowDefinition Height="40" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <StackPanel Grid.Row="1" Grid.ColumnSpan="3" Orientation="Horizontal">
            <ComboBox x:Name="cbxCOMport" Height="30" Width="180" VerticalAlignment="Center" />
            <Button Height="40" Width="100" VerticalAlignment="Bottom" Content="Open"
                x:Name="btnPortOpen" Click="btnPortOpen_Click" IsEnabled="False">
            </Button>
        </StackPanel>

        <StackPanel  VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10" Orientation="Horizontal">
        </StackPanel>
        <Grid Grid.Row="3" Grid.Column="1" Margin="0,0,0,35">
            <Grid.Resources>
                <Style TargetType="{x:Type Button}">
                    <Setter Property="Margin" Value="8,8,8,8" />
                </Style>
            </Grid.Resources>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Button x:Name="btnUp" Grid.Row="0" Grid.Column="1" Content="up" Click="btnUp_Click" />
            <Button Template="{StaticResource btnround}" x:Name="btnStop" Grid.Column="1" Grid.Row="1" Content="stop" Click="btnStop_Click" />
            <Button Template="{StaticResource btnround}" x:Name="btnSave" Grid.Column="0" Grid.Row="0" Content="save"/>
            <Button x:Name="btnDown" Grid.Row="2" Grid.Column="1" Content="down" Click="btnDown_Click"/>
            <Button x:Name="btnLeft" Grid.Row="1" Grid.Column="0" Content="left" Click="btnLeft_Click"/>
            <Button x:Name="btnRight" Grid.Row="1" Grid.Column="2" Content="right" Click="btnRight_Click"/>
            <TextBox x:Name="tbxSpeed" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,0" Grid.Row="2" Width="80" HorizontalContentAlignment="Center" Text="400"/>
            <Label Content="Speed" HorizontalAlignment="Center" Grid.Row="2" VerticalAlignment="Top"/>
            <TextBox x:Name="tbxSteps" Grid.Column="2" HorizontalAlignment="Center" Margin="0,0,0,0" Grid.Row="2" VerticalAlignment="Bottom" Width="80" HorizontalContentAlignment="Center" Text="400"/>
            <Label Content="Steps" HorizontalAlignment="Center" Grid.Row="2" Grid.Column="2" VerticalAlignment="Top"/>
            <RadioButton x:Name="rbnCruise" Grid.Column="2" Content="cruise" HorizontalAlignment="Left" Margin="5,0,0,0" VerticalAlignment="Center"/>
        </Grid>
        <Label Grid.Column="1" Content="DALI A/V" HorizontalAlignment="Left" Grid.Row="3" VerticalAlignment="Bottom"/>
        <TextBox x:Name="tbxDALIadr" Grid.Column="1" HorizontalAlignment="Center" Margin="0,0,0,5" Grid.Row="3" VerticalAlignment="Bottom" Width="60" HorizontalContentAlignment="Center" Text="17"/>
        <TextBox x:Name="tbxDALIval" Grid.Column="1" HorizontalAlignment="Right" Margin="0,0,10,5" Grid.Row="3" VerticalAlignment="Bottom" Width="60" HorizontalContentAlignment="Center" Text="240"/>
        <Label Content="Port Status:" HorizontalAlignment="Left" Margin="4,0,0,0" Grid.Row="6" VerticalAlignment="Center"/>
        <Label x:Name="lblPortStatus" Content="disconnected" HorizontalAlignment="Right" Margin="0,0,5,0" Grid.Row="6" VerticalAlignment="Center"/>
        <StackPanel Grid.Row="6" Grid.Column="1" Orientation="Horizontal">
            <Label Content="X:" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Center"/>
            <Label x:Name="lblXPos" Content="-------" HorizontalAlignment="Left" VerticalAlignment="Center"/>
            <Label Content="Y:" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Center"/>
            <Label x:Name="lblYPos" Content="-------" HorizontalAlignment="Left" VerticalAlignment="Center"/>
            <Label Content="Z:" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Center"/>
            <Label x:Name="lblZPos" Content="-------" HorizontalAlignment="Left" VerticalAlignment="Center"/>
        </StackPanel>
        <Grid Grid.Column="2" Grid.Row="3">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Button Content="go home" x:Name="btnHome" Grid.Column="0" Grid.Row="0"/>
            <Button Content="span" x:Name="btnSpan" Grid.Column="1" Grid.Row="0"/>
        </Grid>
        <ListView ItemsSource="{Binding PositionsView, Mode=OneWay}"  Grid.Row="4" Grid.ColumnSpan="3" >
            <ListView.View>
                <GridView>
                    <GridViewColumn DisplayMemberBinding="{Binding Changed}" Header="*" Width="40" />
                    <GridViewColumn DisplayMemberBinding="{Binding NotifyOnValidationError.Value}" Header="ID" Width="60" />
                    <GridViewColumn DisplayMemberBinding="{Binding XPos.Value, TargetNullValue=[keine Angabe]}" Header="XPos" Width="75"/>
                    <GridViewColumn DisplayMemberBinding="{Binding YPos.Value, TargetNullValue=[keine Angabe]}" Header="YPos" Width="75"/>
                    <GridViewColumn DisplayMemberBinding="{Binding ZPos.Value, TargetNullValue=[keine Angabe]}" Header="ZPos" Width="75"/>
                    <GridViewColumn DisplayMemberBinding="{Binding Dwell.Value}" Header="Dwell" Width="75" />
                    <GridViewColumn DisplayMemberBinding="{Binding DaliAdr.Value}" Header="DALI Adr" Width="100" />
                    <GridViewColumn DisplayMemberBinding="{Binding DaliVal.Value}" Header="DALI Val" Width="100" />
                </GridView>
            </ListView.View>
        </ListView>
        <DockPanel Grid.Row="5" VerticalAlignment="Top" Height="50" Background="LightGray" LastChildFill="False" >
            <Button Width="50" Content="|c" Command="{Binding FirstCommand}" Margin="3"/>
            <Button Width="50" Content="c" Command="{Binding PreviousCommand}" Margin="3"/>
            <Button Width="50" Content=">" Command="{Binding NextCommand}" Margin="80,0,0,3"/>
            <Button Width="50" Content=">|" Command="{Binding LastCommand}" Margin="3"/>

        </DockPanel>
        <TextBox Grid.Row="5" Height="50" VerticalAlignment="Bottom"
            Width="150" Text="{Binding ActualPosition, Mode=OneWay}"/>
        <Grid Grid.Row="5" Grid.Column="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Label Grid.Row="0" Grid.Column="0" Content="X"/>
            <Label Grid.Row="0" Grid.Column="1" Content="Y"/>
            <Label Grid.Row="0" Grid.Column="2" Content="Z"/>
            <Label Grid.Row="0" Grid.Column="3" Content="dw"/>
            <Label Grid.Row="0" Grid.Column="4" Content="Adr"/>
            <Label Grid.Row="0" Grid.Column="5" Content="Val"/>
            <TextBox local:FocusControl.Focus="{Binding Source={StaticResource vm}, Path=SetFocus, Mode=TwoWay}" DataContext="{Binding XPos}" Text="{Binding Value}" Name="tbxXpos"  Grid.Row="1" Grid.Column="0" />
            <TextBox DataContext="{Binding YPos}" Text="{Binding Value}" Name="tbxYpos" Grid.Row="1" Grid.Column="1" />
            <TextBox DataContext="{Binding ZPos}" Text="{Binding Value}" Name="tbxZpos" Grid.Row="1" Grid.Column="2" />
            <TextBox DataContext="{Binding Dwell}" Text="{Binding Value}" Name="tbxDwell" Grid.Row="1" Grid.Column="3" />
            <TextBox DataContext="{Binding DaliAdr}" Text="{Binding Value}" Name="tbxDaliAdr" Grid.Row="1" Grid.Column="4" />
            <TextBox DataContext="{Binding DaliVal}" Text="{Binding Value}" Name="tbxDaliVal" Grid.Row="1" Grid.Column="5" />
        </Grid>
        <Grid Grid.Row="5" Grid.Column="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Button Width="Auto" Margin="5 12 0 5" Grid.Row="0" Grid.Column="0"
                    Command="ApplicationCommands.New" Content="{Binding Text, Source={x:Static ApplicationCommands.New}}" />
            <Button Width="Auto" Margin="5 12 0 5" Grid.Row="0" Grid.Column="1"
                    Command="ApplicationCommands.Save" Content="{Binding Text,Source={x:Static ApplicationCommands.Save}}"/>
            <Button Width="Auto" Margin="5 12 0 5" Grid.Row="1" Grid.Column="0"
                    Command="ApplicationCommands.Delete" Content="{Binding Text, Source={x:Static ApplicationCommands.Delete}}"/>
            <Button Width="Auto" Margin="5 12 0 5" Grid.Row="1" Grid.Column="1"
                    Command="ApplicationCommands.Undo" Content="{Binding Text, Source={x:Static ApplicationCommands.Undo}}" />
        </Grid>
    </Grid>
</Window>
