<UserControl x:Class="FeenPhone.WPFApp.Controls.NetworkWPF"
             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" 
             mc:Ignorable="d" d:DesignWidth="300">
    <UserControl.Resources>
        <Style TargetType="TextBlock">
            <Setter Property="Padding" Value="4 2"/>
        </Style>
        <Style TargetType="Label">
            <Setter Property="HorizontalAlignment" Value="Right" />
            <Setter Property="Padding" Value="8 2"/>
        </Style>
        <Style TargetType="TextBox">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Margin" Value="0"/>
        </Style>
        <Style TargetType="Button">
            <Setter Property="Margin" Value="1"/>
        </Style>
        <Style TargetType="CheckBox">
            <Setter Property="Margin" Value="10 0"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="OverridesDefaultStyle" Value="False"/>
        </Style>
        <Style TargetType="RowDefinition">
            <Setter Property="Height" Value="20"/>
        </Style>
    </UserControl.Resources>
    <DockPanel Background="{StaticResource clrBackgroundPrimary}">
        <Grid DockPanel.Dock="Top">
            <TextBlock TextAlignment="Center" Background="{StaticResource clrBackgroundHeaders}" >NETWORK</TextBlock>
            <TextBlock TextAlignment="Center" Background="{StaticResource clrBackgroundHeaders}" Visibility="{Binding IsServer, Converter={StaticResource BoolToVisConverter}}" >NETWORK: RUNNING SERVER</TextBlock>
        </Grid>
        <TabControl>
            <TabControl.Resources>
                <Style TargetType="TabItem">
                    <Setter Property="Padding" Value="25 0"/>
                </Style>
            </TabControl.Resources>
            <TabItem Header="Client">
                <Grid Background="White">
                    <Grid.Resources>
                    </Grid.Resources>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="3*" />
                        <ColumnDefinition Width="4*"/>
                        <ColumnDefinition Width="2*"/>
                        <ColumnDefinition Width="4*" />
                    </Grid.ColumnDefinitions>
                    <DockPanel Grid.Row="0" Grid.Column="0">
                        <Button Click="AddressBook_Button_Click" Background="{x:Null}" BorderBrush="{x:Null}" ToolTip="Open Feenbook to connect to saved address or add current connection to saved.">
                            <Image Source="/FeenPhone;component/WPFApp/Resources/Images/bookmark-26.png"></Image>
                        </Button>
                        <Label Padding="3 1 3 0">Server</Label>
                    </DockPanel>
                    <TextBox Grid.Row="0" Grid.Column="1" Name="txtServer" IsEnabled="{Binding ControlsEnabled}">localhost</TextBox>
                    <Label Grid.Row="0" Grid.Column="2">Port</Label>
                    <TextBox Grid.Row="0" Grid.Column="3" Name="txtPort" IsEnabled="{Binding ControlsEnabled}" >5150</TextBox>
                    <Label Grid.Row="1" Grid.Column="0">Nickname</Label>
                    <TextBox IsEnabled="{Binding ControlsEnabled}" TextChanged="txtNickname_TextChanged" Name="txtNickname" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2">CHANGE ME</TextBox>
                    <ComboBox Visibility="{Binding ShowAdvancedControls, Converter={StaticResource BoolToVisConverter}}" IsEnabled="{Binding ControlsEnabled}" Name="comboProt" Grid.Row="1" Grid.Column="3" Height="20">
                        <ComboBoxItem IsSelected="True">TCP</ComboBoxItem>
                        <ComboBoxItem>UDP</ComboBoxItem>
                    </ComboBox>
                    <Button Name="btnConnect" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Click="Connect_Click">Connect</Button>
                    <Label Grid.Row="2" Grid.Column="2" Visibility="{Binding ControlsEnabled, Converter={StaticResource InverseBoolToVisConverter}}">Ping</Label>
                    <TextBlock Name="txtPing" Grid.Row="2" Grid.Column="3" Visibility="{Binding ControlsEnabled, Converter={StaticResource InverseBoolToVisConverter}}"></TextBlock>
                </Grid>
            </TabItem>
            <TabItem Header="Server">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="24*" />
                        <ColumnDefinition Width="81*"/>
                        <ColumnDefinition Width="105*"/>
                        <ColumnDefinition Width="79*" />
                        <ColumnDefinition Width="105*" />
                    </Grid.ColumnDefinitions>
                    <Label Grid.Row="0" Grid.Column="1"></Label>
                    <CheckBox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" ClickMode="Release" FontSize="10" IsChecked="{Binding Path=IsServer, Mode=TwoWay}" ToolTip="Run as server" Margin="10 0 0 0" Padding="2"  VerticalAlignment="Center">Run Server</CheckBox>
                    <CheckBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" ClickMode="Release" IsChecked="{Binding Path=RequireAuth, Mode=TwoWay}" ToolTip="Require incoming clients to authenticate" Margin="10,2">Require Auth</CheckBox>
                    <Button Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" ClickMode="Release" Click="ManageAuth_Click" FontSize="9" Visibility="{Binding Path=RequireAuth, Converter={StaticResource BoolToVisConverter}}" ToolTip="Run as server" Margin="10,2">Manage Authentication</Button>
                    <Label Grid.Row="0" Grid.Column="2">Ports</Label>
                    <TextBox Grid.Row="0" Grid.Column="3" Margin="0,1" Text="{Binding Path=TCPPortText, Mode=TwoWay}" IsEnabled="{Binding Path=TCPPortEnabled}"></TextBox>
                    <TextBox Grid.Row="1" Grid.Column="3" Margin="0,1" Text="{Binding Path=UDPPortText, Mode=TwoWay}" Visibility="{Binding ShowAdvancedControls, Converter={StaticResource BoolToVisConverter}}" IsEnabled="{Binding Path=UDPPortEnabled}"></TextBox>
                    <TextBox Grid.Row="2" Grid.Column="3" Margin="0,1" Text="{Binding Path=TelnetPortText, Mode=TwoWay}" Visibility="{Binding ShowAdvancedControls, Converter={StaticResource BoolToVisConverter}}" IsEnabled="{Binding Path=TelnetPortEnabled}"></TextBox>
                    <CheckBox Grid.Row="0" Grid.Column="4" Margin="10,2" IsChecked="{Binding Path=TCPEnabled, Mode=TwoWay}" Visibility="{Binding ShowAdvancedControls, Converter={StaticResource BoolToVisConverter}}">TCP</CheckBox>
                    <CheckBox Grid.Row="1" Grid.Column="4" Margin="10,2" IsChecked="{Binding Path=UDPEnabled, Mode=TwoWay}" Visibility="{Binding ShowAdvancedControls, Converter={StaticResource BoolToVisConverter}}">UDP</CheckBox>
                    <CheckBox Grid.Row="2" Grid.Column="4" Margin="10,2" IsChecked="{Binding Path=TelnetEnabled, Mode=TwoWay}" Visibility="{Binding ShowAdvancedControls, Converter={StaticResource BoolToVisConverter}}" >Telnet</CheckBox>
                </Grid>
            </TabItem>
        </TabControl>
    </DockPanel>
</UserControl>
