<UserControl x:Class="CyberX8_Themes.UserControls.PowerSupplyChannelControl"
             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:CyberX8_Themes.UserControls"
             xmlns:control="clr-namespace:MECF.Framework.UI.Core.Control;assembly=MECF.Framework.UI.Core"
             xmlns:converters="clr-namespace:CyberX8_Themes.Converters"
             mc:Ignorable="d" x:Name="self"
             d:DesignHeight="300" d:DesignWidth="600">

    <UserControl.Resources>
        <converters:BoolToColor x:Key="boolToColor"/>
        <converters:BoolToBool x:Key="boolToBool"/>
    </UserControl.Resources>
    <Grid>
        <GroupBox Header="{Binding ElementName=self,Path= ModuleName}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="40"></RowDefinition>
                    <RowDefinition Height="40"></RowDefinition>
                    <RowDefinition Height="40"></RowDefinition>
                    <RowDefinition Height="40"></RowDefinition>
                    <RowDefinition Height="40"></RowDefinition>
                    <RowDefinition Height="40"></RowDefinition>
                    <RowDefinition Height="40"></RowDefinition>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="260"></ColumnDefinition>
                    <ColumnDefinition Width="300"></ColumnDefinition>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Ellipse Grid.Row="0" Width="16" Height="16"  Fill="{Binding ElementName=self,Path=Connected, Converter={StaticResource boolToColor}}"  
                         Stroke="Silver" HorizontalAlignment="Left" Margin="39,12,0,12"/>
                <Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Content="{Binding ElementName=self,Path=MetalCellSideName}" Width="120" Height="30" FontSize="16" VerticalContentAlignment="Center"></Label>

                <Grid Grid.Row="1" Grid.Column="0" IsEnabled="{Binding ElementName=self,Path=Connected}">
                    <Ellipse Width="16" Height="16"  Fill="{Binding ElementName=self,Path=OutputEnabled, Converter={StaticResource boolToColor}}"  
                             Stroke="Silver" HorizontalAlignment="Left" Margin="39,12,0,12"/>
                    <Button Style="{StaticResource SysBtnStyle}"  Content="Enable" Click="Enable_Click" Width="60" Height="25" 
                            IsEnabled="{Binding ElementName=self,Path=OutputEnabled,Converter={StaticResource boolToBool}}" HorizontalAlignment="Left"
                            Margin="74,8,0,8"></Button>
                    <Button Style="{StaticResource SysBtnStyle}"  Grid.Row="1" Content="Disable" Click="Disable_Click" Width="60" Height="25"
                            IsEnabled="{Binding ElementName=self,Path=OutputEnabled}" HorizontalAlignment="Left" Margin="159,8,0,7"></Button>
                </Grid>

                <Label Grid.Row="2" Grid.Column="0" Content="Status" VerticalContentAlignment="Center" HorizontalAlignment="Left" Margin="16,0,0,0"></Label>
                <TextBlock Grid.Row="2" Width="70" Margin="0,0,30,0" Text="{Binding ElementName=self,Path=PowerStatus}" Background="Black"
            Foreground="Lime" FontSize="16" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>

                <Label Grid.Row="2" Grid.Column="1" Content="Run Model" VerticalContentAlignment="Center" HorizontalAlignment="Left" Margin="16,0,0,0"></Label>
                <TextBlock Grid.Row="2" Grid.Column="1" Width="70" Margin="0,0,30,0" Text="{Binding ElementName=self,Path=PowerRunModel}" Background="Black"
                           Foreground="Lime" FontSize="16" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>

                <Grid Grid.Row="3" Grid.Column="0" IsEnabled="{Binding ElementName=self,Path=Connected}">
                    <Label Grid.Row="3" Grid.Column="0" Content="Set Point" VerticalContentAlignment="Center" HorizontalAlignment="Left" Margin="12,0,0,0"></Label>
                    <control:NumbericTextBox Grid.Row="3" Width="70" Margin="0,8,30,7" Height="25" Value="{Binding ElementName=self,Path=InputSetPoint,StringFormat={}{0:F3},Mode=TwoWay}" HorizontalAlignment="Center"
                          ></control:NumbericTextBox>
                    <Button Style="{StaticResource SysBtnStyle}" Grid.Row="3" Content="Set" Click="SetPoint_Click" Width="40" Height="25" HorizontalAlignment="Left" 
                            Margin="160,8,0,7" IsEnabled="{Binding ElementName=self,Path=OutputEnabled,Converter={StaticResource boolToBool}}"></Button>
                </Grid>
                


                <Label Grid.Row="4" Grid.Column="0" Content="Set Point" VerticalContentAlignment="Center" HorizontalAlignment="Left" Margin="12,0,0,0"></Label>
                <TextBlock Grid.Row="4" Width="70" Margin="0,0,30,0" Text="{Binding ElementName=self,Path=SetPoint,StringFormat=\{0:F3\},Mode=TwoWay}" Background="Black"
                           Foreground="Lime" FontSize="16" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                <TextBlock Grid.Row="4" Margin="160,0,0,0" Width="40" Text="A" Background="Black" Foreground="Lime" FontWeight="Bold" VerticalAlignment="Center" 
                           FontSize="16" HorizontalAlignment="Left"/>


                <Label Grid.Row="5" Grid.Column="0" Content="Current" VerticalContentAlignment="Center" HorizontalAlignment="Left" Margin="12,0,0,0"></Label>
                <TextBlock Grid.Row="5" Width="70" Margin="0,0,30,0" Text="{Binding ElementName=self,Path=Current,StringFormat=\{0:F3\},Mode=TwoWay}" Background="Black"
            Foreground="Lime" FontSize="16" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                <TextBlock Grid.Row="5" Margin="160,0,0,0" Width="40" Text="A" Background="Black" Foreground="Lime" FontWeight="Bold" VerticalAlignment="Center" 
            FontSize="16" HorizontalAlignment="Left"/>

                <Label Grid.Row="6" Grid.Column="0" Content="Voltage" VerticalContentAlignment="Center" HorizontalAlignment="Left" Margin="12,0,0,0"></Label>
                <TextBlock Grid.Row="6" Width="70" Margin="0,0,30,0" Text="{Binding ElementName=self,Path=Voltage,StringFormat=\{0:F3\},Mode=TwoWay}" Background="Black"
                           Foreground="Lime" FontSize="16" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                <TextBlock Grid.Row="6" Margin="160,0,0,0" Width="40" Text="V" Background="Black" Foreground="Lime" FontWeight="Bold" VerticalAlignment="Center" 
                           FontSize="16" HorizontalAlignment="Left"/>

                <Grid Grid.Row="1" Grid.Column="1" IsEnabled="{Binding ElementName=self,Path=Connected}">
                     <TextBlock Width="70" Text="{Binding PowerControl, ElementName=self}" Background="Black"
                    Foreground="Lime" FontSize="16" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="14,0,0,0"/>
                    <Button Style="{StaticResource SysBtnStyle}" Content="Local" Click="Local_Click" Width="60" Height="25" 
                            HorizontalAlignment="Left" Margin="184,8,0,7"></Button>
                    <Button Style="{StaticResource SysBtnStyle}" Content="Remote" Click="Remote_Click" Width="60" Height="25"
                            HorizontalAlignment="Left" Margin="101,8,0,7"></Button>
                </Grid>
               

                <GroupBox Grid.Row="3" Grid.Column="1" Grid.RowSpan="4" Header="Step" IsEnabled="{Binding ElementName=self,Path=Connected}">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="35"></RowDefinition>
                            <RowDefinition Height="35"></RowDefinition>
                            <RowDefinition Height="35"></RowDefinition>
                            <RowDefinition Height="35"></RowDefinition>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <local:PowerSupplierStepControl Grid.Row="0" Current="{Binding ElementName=self,Path=Step1Data.Current,Mode=TwoWay}"
                                                        Hour="{Binding ElementName=self,Path=Step1Data.Hour,Mode=TwoWay}" Minute="{Binding ElementName=self,Path=Step1Data.Minute,Mode=TwoWay}"
                                                        Second="{Binding ElementName=self,Path=Step1Data.Second,Mode=TwoWay}" MicroSecond="{Binding ElementName=self,Path=Step1Data.Microsecond,Mode=TwoWay}"></local:PowerSupplierStepControl>
                        <local:PowerSupplierStepControl Grid.Row="1" Current="{Binding ElementName=self,Path=Step2Data.Current,Mode=TwoWay}"
                                                        Hour="{Binding ElementName=self,Path=Step2Data.Hour,Mode=TwoWay}" Minute="{Binding ElementName=self,Path=Step2Data.Minute,Mode=TwoWay}"
                                                        Second="{Binding ElementName=self,Path=Step2Data.Second,Mode=TwoWay}" MicroSecond="{Binding ElementName=self,Path=Step2Data.Microsecond,Mode=TwoWay}"></local:PowerSupplierStepControl>
                        <local:PowerSupplierStepControl Grid.Row="2" Current="{Binding ElementName=self,Path=Step3Data.Current,Mode=TwoWay}"
                                                        Hour="{Binding ElementName=self,Path=Step3Data.Hour,Mode=TwoWay}" Minute="{Binding ElementName=self,Path=Step3Data.Minute,Mode=TwoWay}"
                                                        Second="{Binding ElementName=self,Path=Step3Data.Second,Mode=TwoWay}" MicroSecond="{Binding ElementName=self,Path=Step3Data.Microsecond,Mode=TwoWay}"></local:PowerSupplierStepControl>
                        <Button Style="{StaticResource SysBtnStyle}"  Grid.Row="3" Content="Start" Click="Start_Click" Width="60" Height="25" 
                                HorizontalAlignment="Left" Margin="59,5,0,5"></Button>
                        <Button Style="{StaticResource SysBtnStyle}"  Grid.Row="3" Content="Abort" Click="Abort_Click" Width="60" Height="25" 
         HorizontalAlignment="Left" Margin="168,5,0,5"></Button>
                    </Grid>
                </GroupBox>
            </Grid>
        </GroupBox>
    </Grid>
</UserControl>