<Window x:Class="WpfApplication19.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:resources="clr-namespace:WpfApplication19.Properties;assembly=WpfApplication19"
         xmlns:res="clr-namespace:WpfApplication19.Properties"
        xmlns:c="clr-namespace:WpfApplication19"
        Title="OB Application" Height="768" Width="1098" WindowState="Maximized" Closed="closeWindows" Closing="Window_Closing">

    <Window.Resources>
        <c:NameConverter x:Key="myNameConverter"/>
        <Style TargetType="{x:Type DataGridCell}">
            <Style.Triggers>
                <Trigger Property="DataGridCell.IsFocused" Value="True">
                    <Setter Property="Background" Value="#ff0000" />
                </Trigger>

            </Style.Triggers>
            <Setter Property="FontSize" Value="20" />

        </Style>
    </Window.Resources>
    <Viewbox Stretch="Fill">
        <Grid Width="1066">
            <Grid.Background>
                <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                    <GradientStop Color="#FFC4BDBD" Offset="0.183"/>
                    <GradientStop Color="White" Offset="1"/>
                    <GradientStop Color="White" Offset="0.709"/>
                </LinearGradientBrush>
            </Grid.Background>
            <Menu Name="menu1" Margin="0,0,0,706">
                <MenuItem Header="{Loc Logout}" Name="logoutMenu" Click="logoutMenu_Click" />
                <MenuItem Header="{Loc Settings}" >
                    <MenuItem Header="Configuration" Click="MenuItem_Click" Name="configMenu"/>
                    <MenuItem Header="Edit Using Times" Name="editUsingTime" Click="editUsingTime_Click" />
                    <MenuItem Header="{Loc Language}">
                        <MenuItem Header="ไทย" IsCheckable="True" Name="thaiMenu" Checked="thaiMenu_Checked" />
                        <MenuItem Header="English" IsCheckable="True" Name="engMenu" Checked="engMenu_Checked" />
                    </MenuItem>
                </MenuItem>
                <MenuItem Header="{Loc ViewMode}">
                    <MenuItem Header="{Loc Window}" Name="windowItem" IsCheckable="True" Checked="windowItem_Checked" />
                    <MenuItem Header="{Loc FullScreen}" Name="fullScreenItem" IsCheckable="True" Checked="fullScreenItem_Checked" />
                </MenuItem>
                <MenuItem Header="Help">
                    <MenuItem Header="View Help" />
                    <MenuItem Header="About" Name="about" Click="about_Click" />
                </MenuItem>
            </Menu>
            <Label Content="{Loc LotNo}" Height="28" HorizontalAlignment="Left" Margin="23,29,0,0" Name="label1" VerticalAlignment="Top" />
            <TextBox Height="23" HorizontalAlignment="Left" Margin="77,33,0,0" Name="lotNo" VerticalAlignment="Top" Width="142" Style="{DynamicResource SimpleTextBox}" MouseDown="lotNo_MouseDown" GotFocus="lotNo_GotFocus" GotKeyboardFocus="lotNo_GotKeyboardFocus" GotMouseCapture="lotNo_GotMouseCapture" KeyDown="lotNo_KeyDown" />
            <Label Content="{Loc Code}" Height="28" HorizontalAlignment="Left" Margin="30,62,0,0" Name="label3" VerticalAlignment="Top" />
            <TextBox Height="23" HorizontalAlignment="Left" Margin="77,65,0,0" Name="code" VerticalAlignment="Top" Width="146" Style="{DynamicResource SimpleTextBox}" />
            <Label Content="{Loc Customer}" Height="28" HorizontalAlignment="Left" Margin="233,66,0,0" Name="label4" VerticalAlignment="Top" />
            <TextBox Height="23" HorizontalAlignment="Left" Margin="77,98,0,0" Name="noProduct" VerticalAlignment="Top" Width="147" Style="{DynamicResource SimpleTextBox}" />
            <TextBox Height="23" HorizontalAlignment="Left" Margin="297,68,0,0" Name="customer" VerticalAlignment="Top" Width="181" Style="{DynamicResource SimpleTextBox}" />
            <Label Content="{Loc ProductNo}" Height="28" HorizontalAlignment="Left" Margin="3,97,0,0" Name="label5" VerticalAlignment="Top" />
            <Label Content="{Loc Shape}" Height="28" HorizontalAlignment="Left" Margin="20,130,0,0" Name="label6" VerticalAlignment="Top" />
            <TextBox Height="23" HorizontalAlignment="Left" Margin="78,134,0,0" Name="shape" VerticalAlignment="Top" Width="142" Style="{DynamicResource SimpleTextBox}" />
            <Label Content="{Loc Size}" Height="28" HorizontalAlignment="Left" Margin="256,128,0,0" Name="label7" VerticalAlignment="Top" />
            <TextBox Height="23" HorizontalAlignment="Left" Margin="298,131,0,0" Name="size" VerticalAlignment="Top" Width="138" Style="{DynamicResource SimpleTextBox}" />
            <Label Content="{Loc Spec}" Height="28" HorizontalAlignment="Left" Margin="477,129,0,0" Name="label8" VerticalAlignment="Top" />
            <TextBox HorizontalAlignment="Left" Margin="521,128,0,0" Name="spec" Width="159" Height="23" VerticalAlignment="Top" Style="{DynamicResource SimpleTextBox}" />
            <Label Content="{Loc Sampling}" Height="28" HorizontalAlignment="Left" Margin="12,165,0,0" Name="label9" VerticalAlignment="Top" />
            <TextBox Height="23" HorizontalAlignment="Right" Margin="0,169,846,0" Name="sampling" VerticalAlignment="Top" Width="142" Style="{DynamicResource SimpleTextBox}" />
            <Label Content="{Loc Point}" Height="28" HorizontalAlignment="Left" Margin="252,164,0,0" Name="label10" VerticalAlignment="Top" />
            <TextBox Height="23" HorizontalAlignment="Right" Margin="0,166,629,0" Name="point" VerticalAlignment="Top" Width="138" Style="{DynamicResource SimpleTextBox}" />
            <Label Content="{Loc Condition}" Height="28" HorizontalAlignment="Left" Margin="456,163,0,0" Name="label11" VerticalAlignment="Top" />
            <TextBox HorizontalAlignment="Left" Margin="521,159,0,0" Name="condition" Width="160" Height="34" VerticalAlignment="Top" Style="{DynamicResource SimpleTextBox}" Background="#FF1A1C1E" Foreground="#FFFF5B00" FontSize="14" />
            <Label Content="{Loc Out}" Height="28" HorizontalAlignment="Left" Margin="35,197,0,0" Name="point1Label" VerticalAlignment="Top" />
            <TextBox Height="23" HorizontalAlignment="Left" Margin="78,199,0,0" Name="outTB" VerticalAlignment="Top" Width="142" Style="{DynamicResource SimpleTextBox}" FontWeight="Bold" />
            <Label Content="{Loc In}" Height="28" HorizontalAlignment="Left" Margin="261,195,0,0" Name="point2Label" VerticalAlignment="Top" />
            <TextBox Height="23" HorizontalAlignment="Left" Margin="299,198,0,0" Name="inTB" VerticalAlignment="Top" Width="138" Style="{DynamicResource SimpleTextBox}" FontWeight="Bold" />
            <Label Content="{Loc Middle}" Height="28" HorizontalAlignment="Left" Margin="466,194,0,0" Name="label14" VerticalAlignment="Top" />
            <TextBox HorizontalAlignment="Left" Margin="522,198,0,0" Name="middleTB" Width="159" Height="23" VerticalAlignment="Top" Style="{DynamicResource SimpleTextBox}" />
            <ToolBarTray Height="36" HorizontalAlignment="Left" Margin="9,233,0,0" Name="toolBarTray1" VerticalAlignment="Top" Width="839">
                <ToolBar>
                    <Button Padding="10,2" Name="addRow" Click="addRow_Click" Margin="3,0" BorderBrush="#FF0D6AFF" BorderThickness="1">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/WpfApplication19;component/Images/add_row.png" Width="20"></Image>
                            <TextBlock Padding="3" Text="{Loc AddRow}"/>
                        </StackPanel>
                    </Button>
                    <Button Padding="10,2" Name="addMeasureColumn" Click="addMeasureColumn_Click" BorderBrush="#FF0D6AFF" BorderThickness="1" Margin="3,0">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/WpfApplication19;component/Images/add_column_icon.jpg" Width="20"></Image>
                            <TextBlock Padding="3" Text="{Loc AddColumn}"/>
                        </StackPanel>
                    </Button>
                    <Button Padding="10,2" Name="removeMeasureColumn" Click="removeMeasureColumn_Click" Margin="3,0" BorderThickness="1" BorderBrush="#FF0D6AFF">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/WpfApplication19;component/Images/add_column_icon.jpg" Width="20"></Image>
                            <TextBlock Padding="3" Text="{Loc RemoveCol}"/>
                        </StackPanel>
                    </Button>
                    <Button Padding="10,2" Name="addMiddleBtn" Click="addMiddleBtn_Click" Margin="3,0" BorderBrush="#FF0D6AFF" BorderThickness="1">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/WpfApplication19;component/Images/table_row_insert.png" Width="20"></Image>
                            <TextBlock Padding="3" Text="{Loc AddMiddle}" Name="middleText" />
                        </StackPanel>
                    </Button>
                    <Button Padding="10,2" Name="addInBtn" Click="addInBtn_Click" Margin="3,0" BorderBrush="#FF0D6AFF" BorderThickness="1">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/WpfApplication19;component/Images/table_row_insert.png" Width="20"></Image>
                            <TextBlock Padding="3" Text="{Loc AddIn}" Name="inText" />
                        </StackPanel>
                    </Button>
                    <Button Padding="10,2" Name="deleteData" Click="deleteData_Click" Margin="3,0" BorderBrush="#FF0D6AFF" BorderThickness="1">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/WpfApplication19;component/Images/Delete.png" Width="20"></Image>
                            <TextBlock Padding="3" Text="{Loc Delete}"/>
                        </StackPanel>
                    </Button>
                    <Button Padding="10,2" Name="saveCellBtn" Click="saveCellBtn_Click" Margin="3,0" BorderBrush="#FF0D6AFF">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/WpfApplication19;component/Images/Actions-file-save-as-icon.png" Width="20"></Image>
                            <TextBlock Padding="3" Text="{Loc Save}"/>
                        </StackPanel>
                    </Button>
                    <Button Padding="10,2" Name="printBtn" Click="printBtn_Click" Margin="3,0" BorderBrush="#FF0D6AFF" BorderThickness="2">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/WpfApplication19;component/Images/Print.png" Width="20"></Image>
                            <TextBlock Padding="3" Text="{Loc Print}"/>
                        </StackPanel>
                    </Button>
                </ToolBar>
            </ToolBarTray>
            <DataGrid  AutoGenerateColumns="False" CanUserAddRows="False" HorizontalAlignment="Left" Name="measureGrid" VerticalAlignment="Top" RowEditEnding="measureGrid_RowEditEnding" KeyUp="measureGrid_KeyUp" CellEditEnding="measureGrid_CellEditEnding" LostFocus="measureGrid_LostFocus" LostKeyboardFocus="measureGrid_LostKeyboardFocus" LoadingRow="measureGrid_LoadingRow" BeginningEdit="measureGrid_BeginningEdit" SelectedCellsChanged="measureGrid_SelectedCellsChanged" CurrentCellChanged="measureGrid_CurrentCellChanged" MinHeight="200" Width="844" KeyDown="measureGrid_KeyDown" Loaded="measureGrid_Loaded" SourceUpdated="measureGrid_SourceUpdated" VerticalScrollBarVisibility="Visible" IsEnabled="True" Height="410" Margin="10,276,0,0" ColumnDisplayIndexChanged="measureGrid_ColumnDisplayIndexChanged" PreviewKeyDown="measureGrid_PreviewKeyDown" SelectedIndex="-1" RowBackground="#FFDBD5D5">


                <DataGrid.Columns>
                    <DataGridTextColumn Header="Out/In" IsReadOnly="True" CanUserSort="False">
                        <DataGridTextColumn.Binding>
                            <MultiBinding Converter="{StaticResource myNameConverter}">
                                <Binding Path="Count"/>
                                <Binding Path="Type"/>
                            </MultiBinding>
                        </DataGridTextColumn.Binding>


                    </DataGridTextColumn>


                    <DataGridTextColumn Header="1"  Binding="{Binding P1, StringFormat=0.00}"  Width="*" IsReadOnly="True" CanUserSort="False"  />


                    <DataGridTextColumn Header="2"  Binding="{Binding P2, StringFormat=0.00}"  Width="*" IsReadOnly="True" CanUserSort="False"/>
                    <DataGridTextColumn Header="3"  Binding="{Binding P3, StringFormat=0.00}"  Width="*" IsReadOnly="True" CanUserSort="False"/>
                    <DataGridTextColumn Header="4"  Binding="{Binding P4, StringFormat=0.00}" Visibility="Hidden" IsReadOnly="True" Width="*" CanUserSort="False"/>
                    <DataGridTextColumn Header="5"  Binding="{Binding P5, StringFormat=0.00}" Visibility="Hidden" IsReadOnly="True" Width="*" CanUserSort="False"/>
                    <DataGridTextColumn Header="6"  Binding="{Binding P6, StringFormat=0.00}" Visibility="Hidden" IsReadOnly="True" Width="*" CanUserSort="False"/>
                    <DataGridTextColumn Header="7"  Binding="{Binding P7, StringFormat=0.00}" Visibility="Hidden" IsReadOnly="True" Width="*" CanUserSort="False"/>
                    <DataGridTextColumn Header="8"  Binding="{Binding P8, StringFormat=0.00}" Visibility="Hidden" IsReadOnly="True" Width="*" CanUserSort="False"/>
                    <DataGridTextColumn Header="9"  Binding="{Binding P9, StringFormat=0.00}" Visibility="Hidden" IsReadOnly="True" Width="*" CanUserSort="False"/>
                    <DataGridTextColumn Header="10"  Binding="{Binding P10, StringFormat=0.00}" Visibility="Hidden" IsReadOnly="True" Width="*" CanUserSort="False"/>
                    <DataGridTextColumn Header="{Loc Average}"  Binding="{Binding Avg, StringFormat=0.00}" IsReadOnly="True" Width="*" CanUserSort="False"/>
                    <DataGridTextColumn Header="{Loc Grade}"  Binding="{Binding Grade}" IsReadOnly="True" Width="*" CanUserSort="False"/>
                    <DataGridTextColumn Header="{Loc ResultGrade}"  Binding="{Binding ResultGrade}" IsReadOnly="True" Width="*" CanUserSort="False" />
                </DataGrid.Columns>
                <DataGrid.RowHeaderTemplate>
                    <DataTemplate>

                        <TextBlock>
                        <!--
                    <TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, 
                                      AncestorType={x:Type DataGridRow}}, 
                                      Path=Item.Count}"/>
                    -
                    <TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, 
                                      AncestorType={x:Type DataGridRow}}, 
                                      Path=Item.Type}"/>
                        -->
                        >>
                        </TextBlock>
                    </DataTemplate>
                </DataGrid.RowHeaderTemplate>
            </DataGrid>
            <ToolBar Margin="15,689,214,0" Height="30" VerticalAlignment="Top">

                <Button  Padding="10,2" Name="commitBtn" Click="commitBtn_Click" BorderBrush="#FF0D6AFF" Margin="2,0">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="/WpfApplication19;component/Images/commit.png" Width="20"></Image>
                        <TextBlock Padding="3" Text="{Loc Commit}"/>
                    </StackPanel>
                </Button>
                <Button  Padding="10,2" Name="dailyCheckBtn" Click="dailyCheckBtn_Click" BorderBrush="#FF0D6AFF" Margin="2,0">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="/WpfApplication19;component/Images/check.png" Width="20"></Image>
                        <TextBlock Padding="3" Text="{Loc DailyCheck}"/>
                    </StackPanel>
                </Button>
                <Button  Padding="10,2" Name="undoBtn" Click="undoBtn_Click" BorderBrush="#FF0D6AFF" Margin="2,0">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="/WpfApplication19;component/Images/Undo.png" Width="20"></Image>
                        <TextBlock Padding="3" Text="{Loc Undo}"/>
                    </StackPanel>
                </Button>
            </ToolBar>
            <Label Content="{Loc UsingTime}" Height="28" HorizontalAlignment="Left" Margin="879,331,0,0" Name="label15" VerticalAlignment="Top" Width="83" />
            <TextBlock Height="51" Margin="879,365,0,0" Name="UsingTimeTB" Text="0" Width="132" TextAlignment="Center" Background="Black" Foreground="Red" FontSize="35" Padding="0" HorizontalAlignment="Left" VerticalAlignment="Top" />
            <Label Content="Reading &gt;&gt;" Height="28" Margin="878,234,0,0" Name="label16" Width="83" HorizontalAlignment="Left" VerticalAlignment="Top" />
            <TextBlock Background="Black" FontSize="35" Foreground="Red" Height="51" Margin="879,270,0,0" Name="readingBox" Padding="0" Text="0.00" TextAlignment="Center" Width="132" HorizontalAlignment="Left" VerticalAlignment="Top" Style="{DynamicResource SimpleButtonFocusVisual}" />
            <Button  Height="34" HorizontalAlignment="Left" Margin="238,30,0,0" Name="find" VerticalAlignment="Top" Width="107" Click="find_Click" Style="{DynamicResource SimpleButton}">
                <StackPanel Orientation="Horizontal" Height="27" Width="79">
                    <Image Source="/WpfApplication19;component/Images/search.png"></Image>
                    <TextBlock Padding="5" FontWeight="Bold" FontSize="16" VerticalAlignment="Center" Text="{Loc Find}"></TextBlock>
                </StackPanel>
            </Button>
            <Button  Height="35" HorizontalAlignment="Left" Margin="362,30,0,0" Name="IntranetBtn" VerticalAlignment="Top" Width="115" Click="IntranetBtn_Click" Style="{DynamicResource SimpleButton}">
                <StackPanel Orientation="Horizontal">
                    <Image Source="/WpfApplication19;component/Images/web_blue.png" />
                    <TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="15" Padding="10,0">Intranet</TextBlock>
                </StackPanel>
            </Button>
            <Button  Background="Green" Height="35" HorizontalAlignment="Left" Margin="500,30,0,0" Name="autoBtn" VerticalAlignment="Top" Width="115" Style="{DynamicResource SimpleButton}" FontWeight="Bold" FontSize="14" Click="autoBtn_Click">
                Start Auto
            </Button>
            <Label Content="Header" Height="28" Margin="960,331,0,0" Name="headerLabel" Foreground="Red" FontWeight="Bold" VerticalAlignment="Top" HorizontalAlignment="Left" />
            <TextBlock Height="23" HorizontalAlignment="Left" Margin="961,239,0,0" Name="cellIndicattor" Text="(Row,Col)" VerticalAlignment="Top" />
            <Label Content="{Loc Agreement}" Height="28" HorizontalAlignment="Left" Name="label17" VerticalAlignment="Top" Width="82" Margin="227,93,0,0" />
            <ComboBox Height="23" HorizontalAlignment="Left" Margin="297,96,0,0" Name="agreementCB" VerticalAlignment="Top" Width="182" Style="{DynamicResource SimpleComboBox}" SelectedIndex="0" />
            <Button  Height="34" HorizontalAlignment="Left" Margin="523,90,0,0" Name="agreementBtn" VerticalAlignment="Top" Width="90" Click="agreementBtn_Click" Style="{DynamicResource SimpleButton}">
                <StackPanel Orientation="Horizontal">
                    <Image Source="/WpfApplication19;component/Images/file_pdf.png"></Image>
                    <TextBlock VerticalAlignment="Center" FontWeight="Bold" FontSize="16" Text="{Loc View}"/>
                </StackPanel>
            </Button>
            <Button Content="Reset" Height="23" HorizontalAlignment="Left" Margin="910,426,0,0" Name="resetBtn" VerticalAlignment="Top" Width="75" Click="resetBtn_Click" />

            <Button HorizontalAlignment="Left" Margin="639,85,0,0" Name="searchAgreementBtn" VerticalAlignment="Top" ToolTip="Search Agreement" Click="searchAgreementBtn_Click">
                <StackPanel Orientation="Horizontal">
                    <Image Height="36" HorizontalAlignment="Left"  Name="Agreement" Stretch="Fill" VerticalAlignment="Top" Width="36" Source="/WpfApplication19;component/Images/Icon_Agreement.jpg"  />
                </StackPanel>
            </Button>
            <Button Content="Edit IN*" Height="23" HorizontalAlignment="Left" Margin="692,199,0,0" Name="editINStar" VerticalAlignment="Top" Width="75" Click="editINStar_Click" />
            <Button Content="Edit MID" Height="23" HorizontalAlignment="Left" Margin="774,199,0,0" Name="editMID" VerticalAlignment="Top" Width="75" Click="editMID_Click" />
            <Image HorizontalAlignment="Right" Height="157" Margin="0,33,17.251,0" VerticalAlignment="Top" Width="318.743" Source="/simplico-mgt.png"/>
        </Grid>
    </Viewbox>
</Window>
