<Page Name="ManufacturedMachinesPage"
      x:Class="SdbS.View_Manager.Pages.ManufacturedMachines"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:local="clr-namespace:SdbS.View_Manager.Pages"
      mc:Ignorable="d"
      d:DesignHeight="450" 
      d:DesignWidth="800">
    
    <!--Кастомный ListBox-->
    <Page.Resources>
        <DataTemplate x:Key="CustomListBox">
            <Grid Background="#FFEFF5F7">
                
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition Width="250"/>
                    <ColumnDefinition Width="150"/>
                </Grid.ColumnDefinitions>

                <Label Content="{Binding Name}"
                       Grid.Column="0"
                       VerticalAlignment="Center"
                       HorizontalAlignment="Left"
                       BorderBrush="#FF4CB034"
                       BorderThickness="1"
                       Width="90"
                       Margin="5">

                    <Label.Resources>
                        <Style TargetType="Border">
                            <Setter Property="CornerRadius" 
                                    Value="5 0 0 0"/>
                        </Style>
                    </Label.Resources>

                </Label>

                <Label Content="{Binding Type}"
                       Grid.Column="1"
                       VerticalAlignment="Center"
                       HorizontalAlignment="Left"
                       Width="245"
                       Margin="0 5 5 5"
                       BorderBrush="#FF4CB034"
                       BorderThickness="1"/>

                <Label Content="{Binding MakingDate}"
                       Grid.Column="3"
                       VerticalAlignment="Center"
                       HorizontalAlignment="Left"
                       Margin="0 5 5 5"
                       BorderBrush="#FF4CB034"
                       BorderThickness="1"
                       Width="145">

                    <Label.Resources>
                        <Style TargetType="Border">
                            <Setter Property="CornerRadius" 
                                    Value="0 5 0 0"/>
                        </Style>
                    </Label.Resources>

                </Label>

            </Grid>
        </DataTemplate>
    </Page.Resources>

    <!--Сетка 'ОСНОВНОЙ ЧАСТИ'-->
    <Grid Background="White">

        <Grid.RowDefinitions>
            <RowDefinition Height="50"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="150"/>
        </Grid.ColumnDefinitions>
        
        <!--Кнопка выхода в начальное меню-->
        <Button Name="button_BrowseBack"
                Content="Назад"
                Grid.Row="0"
                Grid.Column="0"
                Padding="3"
                BorderBrush="#FF4CB034"
                BorderThickness="2"
                Background="#FFEFF5F7"
                Margin="5"
                HorizontalAlignment="Left"
                VerticalAlignment="Top"
                Command="NavigationCommands.BrowseBack">

            <Button.Resources>
                <Style TargetType="Border">
                    <Setter Property="CornerRadius" 
                            Value="5"/>
                </Style>

            </Button.Resources>
            
        </Button>

        <!--Поиск-->
        <GroupBox VerticalAlignment="Center"
                  HorizontalAlignment="Center"
                  Header="Поиск"
                  BorderThickness="2"
                  BorderBrush="#FF4CB034">

            <Grid>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                
                <TextBox Name="textBox_SearxMachines"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Center"
                         Height="20"
                         Width="100" 
                         Margin="3 0 0 0"
                         TextChanged="textBox_SearxMachines_TextChanged"
                         BorderBrush="#FF4CB034"
                         Background="#FFEFF5F7"/>

                <ComboBox Name="comboBox_SearxMachines"
                          Grid.Column="1"
                          Width="90"
                          FontSize="10"
                          Height="20"
                          BorderThickness="2"
                          Margin="5 0 0 0" 
                          SelectionChanged="comboBox_SearxMachines_SelectionChanged">

                </ComboBox>

                <Button Name="button_Drop_ComboBoxAndListBox"
                        Grid.Column="2"
                        Width="15"
                        Height="15"
                        Margin="5 5 3 5"
                        Content="X"
                        Padding="0"
                        FontSize="9"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center" 
                        Foreground="Red"
                        Click="button_Drop_ComboBoxAndListBox_Click">

                    <Button.Resources>
                        <Style TargetType="Border">
                            <Setter Property="CornerRadius" 
                            Value="3"/>
                        </Style>

                    </Button.Resources>

                </Button>
            </Grid>
        </GroupBox>

        <TextBlock Name="textBlock_SearxCountMachines"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Center" 
                   Margin="340 10 0 0"
                   Foreground="Red"
                   Visibility="Hidden"
                   Text="Найдено записей (0)"
                   FontSize="10"/>


        <!--Сетка части 'ОТОБРАЖЕНИЕ ДАННЫХ'-->
        <Grid Grid.Row="1"
              Grid.Column="0">

            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="25"/>
            </Grid.RowDefinitions>
            
            <!--Отображаемый список из таблицы-->
            <GroupBox Grid.Row="0"
                      Header="Изготавливаемые станки"
                      BorderBrush="Black"
                      BorderThickness="2"
                      Margin="5">

                <Grid>

                    <ListBox Grid.Row="1"
                             ItemTemplate="{DynamicResource CustomListBox}" 
                             Name="listBox_ManufacturedMachines"
                             BorderThickness="0"
                             d:ItemsSource="{d:SampleData ItemCount=3}"
                             SelectionChanged="listBox_ManufacturedMachines_SelectionChanged"/>
                </Grid>

            </GroupBox>

            <!--Отображение общего количества записей-->
            <TextBlock Grid.Row="1"
                       Text="Общее количество записей"
                       Margin="10 0 0 0"
                       VerticalAlignment="Top"
                       HorizontalAlignment="Left"/>
            <TextBlock Grid.Row="1"
                       Name="textBlock_AllCountRecords"
                       Text="(...)"
                       Foreground="#FF4CB034"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Margin="165 0 0 0"/>

        </Grid>

        <!--Сетка части 'МАНИПУЛЯЦИИ'-->
        <Grid Grid.Row="1"
              Grid.Column="1">

            <Grid.RowDefinitions>
                <RowDefinition Height="55"/>
                <RowDefinition Height="50"/>
                <RowDefinition Height="100"/>
                <RowDefinition Height="30"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            
            <!--Поле с манипуляцией названия станка-->
            <TextBlock Text="Название станка:"
                       Grid.Row="0"
                       VerticalAlignment="Top"
                       HorizontalAlignment="Left"
                       Background="#FF4CB034"
                       Foreground="White"
                       Padding="3 0 3 1"
                       Margin="0 10 0 0"/>
            <TextBox Name="textBox_NameMachine"
                     Grid.Row="0"
                     BorderBrush="#FF4CB034"
                     BorderThickness="1"
                     Background="#FFEFF5F7"
                     VerticalAlignment="Top"
                     HorizontalAlignment="Left"
                     Height="20"
                     Width="140"
                     Margin="0 30 0 0"/>

            <!--Поле с манипуляцией типа станка-->
            <TextBlock Text="Тип станка:"
                       Grid.Row="1"
                       VerticalAlignment="Top"
                       Background="#FF4CB034"
                       Foreground="White"
                       Padding="3 0 3 1"
                       Margin="0 10 0 0"
                       HorizontalAlignment="Left"/>
            <ComboBox Grid.Row="1"
                      Name="comboBox_TypeMachine"
                      VerticalAlignment="Bottom"
                      BorderThickness="2"
                      HorizontalAlignment="Left"
                      Height="20"
                      Width="140"
                      Margin="0 0 0 0"/>
            
            <!--Поле с манипуляцией фото станка-->
            <GroupBox Grid.Row="2"
                      Margin="5"
                      Width="120"
                      Header="Фото станка"
                      BorderThickness="2"
                      BorderBrush="#FF4CB034">

                <Grid>

                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="20"/>
                    </Grid.RowDefinitions>

                    <Image Grid.Row="0"
                           Name="image_ManufacturedMachine"
                           Source="/Images/Machine/notPhoto.png"
                           VerticalAlignment="Center"
                           HorizontalAlignment="Center"
                           Margin="3">
                    </Image>

                    <Button Grid.Row="1"
                            Name="button_EditPhoto"
                            FontSize="10"
                            BorderThickness="0"
                            BorderBrush="#FFEFF5F7"
                            IsEnabled="false"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Content="Изменить фото" 
                            Click="button_EditPhoto_Click">
                        <Button.Resources>
                            <Style TargetType="Border">
                                <Setter Property="CornerRadius" 
                            Value="3"/>
                            </Style>

                        </Button.Resources>
                    </Button>

                </Grid>

            </GroupBox>

            <!--Дата изготовления станка-->
            <DatePicker Name="datePicker_ManufacturedMachines"
                        Grid.Row="3"
                        VerticalAlignment="Center"
                        HorizontalAlignment="Center" 
                        FirstDayOfWeek="Monday"
                        BorderThickness="2"/>

            <!--Действия (функциональные клавиши)-->
            <GroupBox Grid.Row="4"
                      Margin="5"
                      Header="Действия"
                      BorderThickness="2"
                      BorderBrush="#FF4CB034">

                <!--Сетка для части 'ФУНКЦИОНАЛЬНЫЕ КЛАВИШИ'-->
                <Grid>

                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>

                    <Button Name="button_EditMachine"
                            Grid.Row="0"
                            IsEnabled="False"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Content="Изменить"
                            Width="100" 
                            BorderBrush="#FF4CB034"
                            Background="#FFEFF5F7"
                            Click="button_EditMachine_Click">

                        <Button.Resources>
                            <Style TargetType="Border">
                                <Setter Property="CornerRadius" 
                            Value="5"/>
                            </Style>

                        </Button.Resources>

                    </Button>

                    <Button Name="button_AddMachine"
                            Grid.Row="1"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Content="Добавить"
                            Width="100" 
                            Click="button_AddMachine_Click"
                            Background="#FFEFF5F7"
                            BorderBrush="#FF4CB034">
                        <Button.Resources>
                            <Style TargetType="Border">
                                <Setter Property="CornerRadius" 
                            Value="5"/>
                            </Style>

                        </Button.Resources>
                    </Button>

                    <Button Name="button_DeleteMachine"
                            Grid.Row="2"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Content="Удалить"
                            IsEnabled="False"
                            Width="100" 
                            Click="button_DeleteMachine_Click"
                            BorderBrush="#FF4CB034"
                            Background="#FFEFF5F7">
                        <Button.Resources>
                            <Style TargetType="Border">
                                <Setter Property="CornerRadius" 
                            Value="5"/>
                            </Style>

                        </Button.Resources>
                    </Button>

                    <Button Name="button_DropFields"
                            Grid.Row="3"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Width="100"
                            Content="Сброс"
                            Background="#FFEFF5F7"
                            BorderBrush="#FF4CB034"
                            Click="button_DropFields_Click">

                        <Button.Resources>
                            <Style TargetType="Border">
                                <Setter Property="CornerRadius" 
                            Value="5"/>
                            </Style>

                        </Button.Resources>
                    </Button>

                </Grid>

            </GroupBox>

        </Grid>

    </Grid>
    
</Page>
