<Window x:Class="ServerManagerTool.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:eo="http://schemas.essentialobjects.com/wpf/"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:tb="http://www.hardcodet.net/taskbar"
        xmlns:tsk="clr-namespace:Microsoft.Win32.TaskScheduler;assembly=Microsoft.Win32.TaskScheduler"
        xmlns:sm="clr-namespace:ServerManagerTool"
        xmlns:clib="clr-namespace:ServerManagerTool.Common.Lib;assembly=ServerManager.Common"
        xmlns:cvr="clr-namespace:ServerManagerTool.Common.ValidationRules;assembly=ServerManager.Common"
        xmlns:com="clr-namespace:ServerManagerTool.Common;assembly=ServerManager.Common"
        xmlns:enum="clr-namespace:ServerManagerTool.Enums"
        xmlns:botenum="clr-namespace:ServerManagerTool.DiscordBot.Enums;assembly=ServerManager.Discord"
        MinWidth="900" MinHeight="600" Width="1100" Height="900" Left="50" Top="50" WindowState="Normal"
        Loaded="MainWindow_Loaded" SizeChanged="MainWindow_SizeChanged" StateChanged="MainWindow_StateChanged" LocationChanged="MainWindow_LocationChanged"
        Name="Main" Icon="../Art/favicon.ico" Title="{DynamicResource MainWindow_Title}">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="..\Globalization\en-US\en-US.xaml"/>
                <ResourceDictionary Source="..\Styles\Default.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <Grid>
        <DockPanel x:Name="dockPanel">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <DockPanel Grid.Row="0" LastChildFill="False">
                    <DockPanel.Style>
                        <Style TargetType="{x:Type DockPanel}">
                            <Setter Property="Background" Value="#4F4F4F"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding AppInstance.BetaVersion}" Value="True">
                                    <Setter Property="Background" Value="#378CFB"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </DockPanel.Style>

                    <Grid DockPanel.Dock="Left">
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Label Grid.Row="0" Background="Transparent" Foreground="White" FontSize="20" FontWeight="Bold" Margin="5,0,5,0" Content="{DynamicResource MainWindow_Label}" BorderThickness="0"/>
                        <StackPanel Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Bottom">
                            <Label Margin="5,0,0,0" Background="Transparent" Foreground="White" FontSize="12" HorizontalAlignment="Right" VerticalAlignment="Center">
                                <Label.Style>
                                    <Style BasedOn="{StaticResource {x:Type Label}}" TargetType="{x:Type Label}">
                                        <Setter Property="Content" Value="{DynamicResource MainWindow_VersionLabel}"/>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding AppInstance.BetaVersion}" Value="True">
                                                <Setter Property="Content" Value="{DynamicResource MainWindow_BetaVersionLabel}"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Label.Style>
                            </Label>
                            <Label Margin="5,0,0,0" Background="Transparent" Foreground="White" FontSize="12" Content="{Binding Source={x:Static sm:App.Instance}, Path=Version}" HorizontalAlignment="Right" VerticalAlignment="Center"/>
                            <Button Margin="5" Click="PatchNotes_Click" ToolTip="{DynamicResource ServerSettings_PatchNotesTooltip}" Style="{StaticResource ButtonStyle1}">
                                <Image Source="{com:Icon Path=/ConanServerManager;component/Art/ChangeNotes.ico,Size=32}"/>
                            </Button>
                            <Button Margin="5,0,0,0" Background="#00AA00" Foreground="White" Padding="1" BorderThickness="1" BorderBrush="White" ContentStringFormat="{DynamicResource MainWindow_UpdateToLabelFormat}" Content="{Binding LatestServerManagerVersion}" Click="Upgrade_Click" VerticalAlignment="Center" >
                                <Button.Style>
                                    <Style TargetType="{x:Type Button}">
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding NewServerManagerAvailable}" Value="True">
                                                <Setter Property="Visibility" Value="Visible"/>
                                            </DataTrigger>
                                            <DataTrigger Binding="{Binding NewServerManagerAvailable}" Value="False">
                                                <Setter Property="Visibility" Value="Collapsed"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Button.Style>
                            </Button>
                        </StackPanel>
                    </Grid>

                    <Grid DockPanel.Dock="Right" Margin="5,0,5,0" MinWidth="130">
                        <Grid.RowDefinitions>
                            <RowDefinition MinHeight="22"/>
                            <RowDefinition MinHeight="22"/>
                            <RowDefinition MinHeight="22"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition MinWidth="25"/>
                            <ColumnDefinition MinWidth="25"/>
                            <ColumnDefinition MinWidth="25"/>
                            <ColumnDefinition MinWidth="25"/>
                            <ColumnDefinition MinWidth="25"/>
                            <ColumnDefinition MinWidth="25"/>
                            <ColumnDefinition MinWidth="25"/>
                        </Grid.ColumnDefinitions>

                        <Button Grid.Row="0" Grid.Column="4" Margin="5,2,0,0" Grid.ColumnSpan="3" Click="Donate_Click" ToolTip="{DynamicResource MainWindow_DonateTooltip}" Style="{StaticResource ButtonStyle3}">
                            <Image Source="../Art/Donate.png"/>
                        </Button>

                        <Button Grid.Row="2" Grid.Column="0" Margin="5,0,0,0"  Click="ServerMonitor_Click" ToolTip="{DynamicResource MainWindow_OpenServerMonitorTooltip}" Style="{StaticResource ButtonStyle1}">
                            <Image Source="{com:Icon Path=/ConanServerManager;component/Art/Servers.ico,Size=32}"/>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="1" Margin="5,0,0,0" HorizontalAlignment="Right" Click="GameData_Click" ToolTip="{DynamicResource MainWindow_OpenGameDataTooltip}" Style="{StaticResource ButtonStyle1}">
                            <Image Source="{com:Icon Path=/ConanServerManager;component/Art/Document.ico,Size=32}"/>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="2" Margin="5,0,0,0" Click="Plugins_Click" ToolTip="{DynamicResource MainWindow_OpenPluginsTooltip}" Style="{StaticResource ButtonStyle1}">
                            <Image Source="{com:Icon Path=/ConanServerManager;component/Art/Plugin.ico,Size=32}"/>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="3" Margin="5,0,0,0" Click="OpenLogFolder_Click" ToolTip="{DynamicResource MainWindow_OpenLogFolderTooltip}" Style="{StaticResource ButtonStyle1}">
                            <Image Source="{com:Icon Path=/ConanServerManager;component/Art/Logs.ico,Size=32}"/>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="4" Margin="5,0,0,0" Click="SteamCMD_Click" ToolTip="{DynamicResource MainWindow_SteamCMDTooltip}" Style="{StaticResource ButtonStyle1}">
                            <Image Source="{com:Icon Path=/ConanServerManager;component/Art/Steam.ico,Size=32}"/>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="5" Margin="5,0,0,0" Click="Settings_Click" ToolTip="{DynamicResource MainWindow_OpenSettingsTooltip}" Style="{StaticResource ButtonStyle1}">
                            <Image Source="{com:Icon Path=/ConanServerManager;component/Art/Settings.ico,Size=32}"/>
                        </Button>
                        <Button Grid.Row="2" Grid.Column="6" Margin="5,0,0,0" Click="Help_Click" ToolTip="{DynamicResource MainWindow_OpenHelpTooltip}" Style="{StaticResource ButtonStyle1}">
                            <Image Source="{com:Icon Path=/ConanServerManager;component/Art/Help.ico,Size=32}"/>
                        </Button>
                    </Grid>

                    <Grid DockPanel.Dock="Right" VerticalAlignment="Top" Margin="10,0,10,0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto" MinWidth="50"/>
                            <ColumnDefinition Width="Auto" MinWidth="100"/>
                        </Grid.ColumnDefinitions>

                        <Label Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="0,-2,0,-3" Background="Transparent" Foreground="White" FontWeight="Bold" FontSize="11" Content="{DynamicResource MainWindow_TaskStatusLabel}" VerticalAlignment="Center" HorizontalAlignment="Center"/>

                        <Label Grid.Row="1" Grid.Column="0" Margin="0" Background="Transparent" Foreground="White" FontSize="10" Content="{DynamicResource MainWindow_AutoBackupTaskLabel}" VerticalAlignment="Center" HorizontalAlignment="Left" ToolTip="{Binding AutoBackupNextRunTime}" ToolTipService.IsEnabled="{Binding AutoBackupNextRunTime, Converter={StaticResource HasStringValueConverter}}"/>
                        <Label Grid.Row="1" Grid.Column="1" Margin="0" Background="Transparent" FontSize="10" Content="{Binding AutoBackupStateString}" VerticalAlignment="Center" HorizontalAlignment="Left" ToolTip="{Binding AutoBackupNextRunTime}" ToolTipService.IsEnabled="{Binding AutoBackupNextRunTime, Converter={StaticResource HasStringValueConverter}}">
                            <Label.Style>
                                <Style BasedOn="{StaticResource {x:Type Label}}" TargetType="{x:Type Label}">
                                    <Setter Property="Foreground" Value="White"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding AutoBackupState}" Value="{x:Static tsk:TaskState.Disabled}">
                                            <Setter Property="Foreground" Value="Orange"/>
                                        </DataTrigger>
                                        <DataTrigger Binding="{Binding AutoBackupState}" Value="{x:Static tsk:TaskState.Ready}">
                                            <Setter Property="Foreground" Value="White"/>
                                        </DataTrigger>
                                        <DataTrigger Binding="{Binding AutoBackupState}" Value="{x:Static tsk:TaskState.Running}">
                                            <Setter Property="Foreground" Value="LightGreen"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Label.Style>
                        </Label>
                        <StackPanel Grid.Row="1" Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center" Margin="5,0,0,0">
                            <Button Margin="5,0,0,0" Background="#00AA00" Foreground="White" Padding="1" Content="{DynamicResource MainWindow_AutoBackupTaskRunLabel}" BorderThickness="1" BorderBrush="White" Click="AutoBackupTaskRun_Click" VerticalAlignment="Center" ToolTip="{DynamicResource MainWindow_AutoBackupTaskRunTooltip}">
                                <Button.Style>
                                    <Style TargetType="{x:Type Button}">
                                        <Setter Property="Visibility" Value="Collapsed"/>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding AutoBackupState}" Value="{x:Static tsk:TaskState.Ready}">
                                                <Setter Property="Visibility" Value="Visible"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Button.Style>
                            </Button>
                            <Button Margin="5,0,0,0" Background="#AA8A00" Foreground="White" Padding="1" BorderThickness="1" BorderBrush="White" Click="AutoBackupTaskState_Click" VerticalAlignment="Center">
                                <Button.Style>
                                    <Style TargetType="{x:Type Button}">
                                        <Setter Property="Content" Value="{DynamicResource MainWindow_AutoBackupTaskEnableLabel}"/>
                                        <Setter Property="ToolTip" Value="{DynamicResource MainWindow_AutoBackupTaskEnableTooltip}"/>
                                        <Setter Property="Visibility" Value="Collapsed"/>
                                        <Style.Triggers>
                                            <MultiDataTrigger>
                                                <MultiDataTrigger.Conditions>
                                                    <Condition Binding="{Binding AutoBackupState}" Value="{x:Static tsk:TaskState.Disabled}"/>
                                                </MultiDataTrigger.Conditions>
                                                <Setter Property="Content" Value="{DynamicResource MainWindow_AutoBackupTaskEnableLabel}"/>
                                                <Setter Property="ToolTip" Value="{DynamicResource MainWindow_AutoBackupTaskEnableTooltip}"/>
                                                <Setter Property="Visibility" Value="Visible"/>
                                            </MultiDataTrigger>
                                            <MultiDataTrigger>
                                                <MultiDataTrigger.Conditions>
                                                    <Condition Binding="{Binding AutoBackupState}" Value="{x:Static tsk:TaskState.Ready}"/>
                                                </MultiDataTrigger.Conditions>
                                                <Setter Property="Content" Value="{DynamicResource MainWindow_AutoBackupTaskDisableLabel}"/>
                                                <Setter Property="ToolTip" Value="{DynamicResource MainWindow_AutoBackupTaskDisableTooltip}"/>
                                                <Setter Property="Visibility" Value="Visible"/>
                                            </MultiDataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Button.Style>
                            </Button>
                        </StackPanel>

                        <Label Grid.Row="2" Grid.Column="0" Margin="0" Background="Transparent" Foreground="White" FontSize="10" Content="{DynamicResource MainWindow_AutoUpdateTaskLabel}" VerticalAlignment="Center" HorizontalAlignment="Left" ToolTip="{Binding AutoUpdateNextRunTime}" ToolTipService.IsEnabled="{Binding AutoUpdateNextRunTime, Converter={StaticResource HasStringValueConverter}}"/>
                        <Label Grid.Row="2" Grid.Column="1" Margin="0" Background="Transparent" FontSize="10" Content="{Binding AutoUpdateStateString}" VerticalAlignment="Center" HorizontalAlignment="Left" ToolTip="{Binding AutoUpdateNextRunTime}" ToolTipService.IsEnabled="{Binding AutoUpdateNextRunTime, Converter={StaticResource HasStringValueConverter}}">
                            <Label.Style>
                                <Style BasedOn="{StaticResource {x:Type Label}}" TargetType="{x:Type Label}">
                                    <Setter Property="Foreground" Value="White"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding AutoUpdateState}" Value="{x:Static tsk:TaskState.Disabled}">
                                            <Setter Property="Foreground" Value="Orange"/>
                                        </DataTrigger>
                                        <DataTrigger Binding="{Binding AutoUpdateState}" Value="{x:Static tsk:TaskState.Ready}">
                                            <Setter Property="Foreground" Value="White"/>
                                        </DataTrigger>
                                        <DataTrigger Binding="{Binding AutoUpdateState}" Value="{x:Static tsk:TaskState.Running}">
                                            <Setter Property="Foreground" Value="LightGreen"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Label.Style>
                        </Label>
                        <StackPanel Grid.Row="2" Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center" Margin="5,0,0,0">
                            <Button Margin="5,0,0,0" Background="#00AA00" Foreground="White" Padding="1" Content="{DynamicResource MainWindow_AutoUpdateTaskRunLabel}" BorderThickness="1" BorderBrush="White" Click="AutoUpdateTaskRun_Click" VerticalAlignment="Center" ToolTip="{DynamicResource MainWindow_AutoUpdateTaskRunTooltip}">
                                <Button.Style>
                                    <Style TargetType="{x:Type Button}">
                                        <Setter Property="Visibility" Value="Collapsed"/>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding AutoUpdateState}" Value="{x:Static tsk:TaskState.Ready}">
                                                <Setter Property="Visibility" Value="Visible"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Button.Style>
                            </Button>
                            <Button Margin="5,0,0,0" Background="#AA8A00" Foreground="White" Padding="1" BorderThickness="1" BorderBrush="White" Click="AutoUpdateTaskState_Click" VerticalAlignment="Center">
                                <Button.Style>
                                    <Style TargetType="{x:Type Button}">
                                        <Setter Property="Content" Value="{DynamicResource MainWindow_AutoUpdateTaskEnableLabel}"/>
                                        <Setter Property="ToolTip" Value="{DynamicResource MainWindow_AutoUpdateTaskEnableTooltip}"/>
                                        <Setter Property="Visibility" Value="Collapsed"/>
                                        <Style.Triggers>
                                            <MultiDataTrigger>
                                                <MultiDataTrigger.Conditions>
                                                    <Condition Binding="{Binding AutoUpdateState}" Value="{x:Static tsk:TaskState.Disabled}"/>
                                                </MultiDataTrigger.Conditions>
                                                <Setter Property="Content" Value="{DynamicResource MainWindow_AutoUpdateTaskEnableLabel}"/>
                                                <Setter Property="ToolTip" Value="{DynamicResource MainWindow_AutoUpdateTaskEnableTooltip}"/>
                                                <Setter Property="Visibility" Value="Visible"/>
                                            </MultiDataTrigger>
                                            <MultiDataTrigger>
                                                <MultiDataTrigger.Conditions>
                                                    <Condition Binding="{Binding AutoUpdateState}" Value="{x:Static tsk:TaskState.Ready}"/>
                                                </MultiDataTrigger.Conditions>
                                                <Setter Property="Content" Value="{DynamicResource MainWindow_AutoUpdateTaskDisableLabel}"/>
                                                <Setter Property="ToolTip" Value="{DynamicResource MainWindow_AutoUpdateTaskDisableTooltip}"/>
                                                <Setter Property="Visibility" Value="Visible"/>
                                            </MultiDataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Button.Style>
                            </Button>
                        </StackPanel>

                        <Label Grid.Row="3" Grid.Column="0" Margin="0" Background="Transparent" Foreground="White" FontSize="10" Content="{DynamicResource MainWindow_DiscordBotStatusLabel}" VerticalAlignment="Center" HorizontalAlignment="Left"/>
                        <Label Grid.Row="3" Grid.Column="1" Margin="0" Background="Transparent" FontSize="10" Content="{Binding DiscordBotStateString}" VerticalAlignment="Center" HorizontalAlignment="Left">
                            <Label.Style>
                                <Style BasedOn="{StaticResource {x:Type Label}}" TargetType="{x:Type Label}">
                                    <Setter Property="Foreground" Value="White"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding DiscordBotState}" Value="{x:Static botenum:BotState.Disabled}">
                                            <Setter Property="Foreground" Value="Orange"/>
                                        </DataTrigger>
                                        <DataTrigger Binding="{Binding DiscordBotState}" Value="{x:Static botenum:BotState.Stopped}">
                                            <Setter Property="Foreground" Value="White"/>
                                        </DataTrigger>
                                        <DataTrigger Binding="{Binding DiscordBotState}" Value="{x:Static botenum:BotState.Running}">
                                            <Setter Property="Foreground" Value="LightGreen"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Label.Style>
                        </Label>
                        <StackPanel Grid.Row="3" Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center" Margin="5,0,0,0">
                            <Button Margin="5,0,0,0" Padding="1" BorderThickness="1" BorderBrush="White" Click="DiscordBotTaskState_Click" VerticalAlignment="Center">
                                <Button.Style>
                                    <Style TargetType="{x:Type Button}">
                                        <Setter Property="Background" Value="#00AA00"/>
                                        <Setter Property="Foreground" Value="White"/>
                                        <Setter Property="Content" Value="{DynamicResource MainWindow_DiscordBotTaskStartLabel}"/>
                                        <Setter Property="ToolTip" Value="{DynamicResource MainWindow_DiscordBotTaskStartTooltip}"/>
                                        <Setter Property="Visibility" Value="Collapsed"/>
                                        <Style.Triggers>
                                            <MultiDataTrigger>
                                                <MultiDataTrigger.Conditions>
                                                    <Condition Binding="{Binding DiscordBotState}" Value="{x:Static botenum:BotState.Stopped}"/>
                                                </MultiDataTrigger.Conditions>
                                                <Setter Property="Background" Value="#00AA00"/>
                                                <Setter Property="Foreground" Value="White"/>
                                                <Setter Property="Content" Value="{DynamicResource MainWindow_DiscordBotTaskStartLabel}"/>
                                                <Setter Property="ToolTip" Value="{DynamicResource MainWindow_DiscordBotTaskStartTooltip}"/>
                                                <Setter Property="Visibility" Value="Visible"/>
                                            </MultiDataTrigger>
                                            <MultiDataTrigger>
                                                <MultiDataTrigger.Conditions>
                                                    <Condition Binding="{Binding DiscordBotState}" Value="{x:Static botenum:BotState.Running}"/>
                                                </MultiDataTrigger.Conditions>
                                                <Setter Property="Background" Value="#AA8A00"/>
                                                <Setter Property="Foreground" Value="White"/>
                                                <Setter Property="Content" Value="{DynamicResource MainWindow_DiscordBotTaskStopLabel}"/>
                                                <Setter Property="ToolTip" Value="{DynamicResource MainWindow_DiscordBotTaskStopTooltip}"/>
                                                <Setter Property="Visibility" Value="Visible"/>
                                            </MultiDataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Button.Style>
                            </Button>
                        </StackPanel>
                    </Grid>

                    <Grid DockPanel.Dock="Top" VerticalAlignment="Top" Margin="10,0,10,0" HorizontalAlignment="Center">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        
                        <Label Grid.Row="0" Margin="0,-2,0,-3" Background="Transparent" Foreground="White" FontWeight="Bold" FontSize="11" Content="{DynamicResource MainWindow_MyIpLabel}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        <StackPanel Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Center" Margin="5,0,0,0">
                            <TextBox FontSize="12"  Height="22" Width="120" VerticalAlignment="Bottom" Margin="0" VerticalContentAlignment="Center" ToolTip="{DynamicResource MainWindow_MyIpTooltip}">
                                <Validation.ErrorTemplate>
                                    <ControlTemplate>
                                        <StackPanel>
                                            <!-- Placeholder for the TextBox itself -->
                                            <AdornedElementPlaceholder x:Name="textBox"/>
                                            <TextBlock Text="{DynamicResource MainWindow_MyIpError}" Background="Red" Foreground="White"/>
                                        </StackPanel>
                                    </ControlTemplate>
                                </Validation.ErrorTemplate>
                                <TextBox.Text>
                                    <Binding Path="Config.MachinePublicIP" ElementName="Main">
                                        <Binding.ValidationRules>
                                            <cvr:IpValidationRule ValidatesOnTargetUpdated="true" />
                                        </Binding.ValidationRules>
                                    </Binding>
                                </TextBox.Text>
                            </TextBox>
                            <Button Grid.Row="1" Margin="5,0,0,0" Click="RefreshPublicIP_Click" ToolTip="{DynamicResource MainWindow_RefreshMyIpTooltip}" Style="{StaticResource ButtonStyle2}">
                                <Image Source="{com:Icon Path=/ConanServerManager;component/Art/Reload.ico,Size=32}"/>
                            </Button>
                        </StackPanel>
                    </Grid>
                </DockPanel>

                <eo:TabControl Name="Tabs" Grid.Row ="1" Margin="0,5,0,0" ShowCloseTabButton="True" ShowNewTabButton="True" NewItemRequested="Servers_AddNew" PreviewItemClose="Servers_Remove" ItemsSource="{Binding ServerManager.Servers}">
                    <eo:TabControl.HeaderTemplate>
                        <DataTemplate >
                            <StackPanel Orientation="Horizontal">
                                <Button Grid.Row="0" Grid.Column="4" Margin="5,0,0,0" Command="{Binding StatusButtonCommand, ElementName=Main}" CommandParameter="{Binding}">
                                    <Button.Style>
                                        <Style BasedOn="{StaticResource ButtonStyle5}" TargetType="{x:Type Button}">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Null}">
                                                    <Setter Property="Background" Value="Transparent"/>
                                                    <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusUnknownLabel}"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Initializing}">
                                                    <Setter Property="Background" Value="Transparent"/>
                                                    <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusInitializingLabel}"/>
                                                </DataTrigger>
                                                <MultiDataTrigger>
                                                    <MultiDataTrigger.Conditions>
                                                        <Condition Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Running}"/>
                                                        <Condition Binding="{Binding Config.ServerStatus_EnableActions, ElementName=Main}" Value="false"/>
                                                    </MultiDataTrigger.Conditions>
                                                    <Setter Property="Background" Value="Transparent"/>
                                                    <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusRunningLabel}"/>
                                                </MultiDataTrigger>
                                                <MultiDataTrigger>
                                                    <MultiDataTrigger.Conditions>
                                                        <Condition Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Running}"/>
                                                        <Condition Binding="{Binding Config.ServerStatus_EnableActions, ElementName=Main}" Value="true"/>
                                                    </MultiDataTrigger.Conditions>
                                                    <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusRunningLabel}"/>
                                                </MultiDataTrigger>
                                                <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Stopping}">
                                                    <Setter Property="Background" Value="Transparent"/>
                                                    <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusStoppingLabel}"/>
                                                </DataTrigger>
                                                <MultiDataTrigger>
                                                    <MultiDataTrigger.Conditions>
                                                        <Condition Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Stopped}"/>
                                                        <Condition Binding="{Binding Config.ServerStatus_EnableActions, ElementName=Main}" Value="false"/>
                                                    </MultiDataTrigger.Conditions>
                                                    <Setter Property="Background" Value="Transparent"/>
                                                    <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusStoppedLabel}"/>
                                                </MultiDataTrigger>
                                                <MultiDataTrigger>
                                                    <MultiDataTrigger.Conditions>
                                                        <Condition Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Stopped}"/>
                                                        <Condition Binding="{Binding Config.ServerStatus_EnableActions, ElementName=Main}" Value="true"/>
                                                    </MultiDataTrigger.Conditions>
                                                    <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusStoppedLabel}"/>
                                                </MultiDataTrigger>
                                                <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Unknown}">
                                                    <Setter Property="Background" Value="Transparent"/>
                                                    <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusUnknownLabel}"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Updating}">
                                                    <Setter Property="Background" Value="Transparent"/>
                                                    <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusUpdatingLabel}"/>
                                                </DataTrigger>
                                                <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Uninstalled}">
                                                    <Setter Property="Background" Value="Transparent"/>
                                                    <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusUninstalledLabel}"/>
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Button.Style>
                                    <Image Margin="0,2" VerticalAlignment="Center" Width="16" Height="16">
                                        <Image.Style>
                                            <Style TargetType="{x:Type Image}">
                                                <Style.Triggers>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Null}">
                                                        <Setter Property="Source" Value="{com:Icon Path=/ConanServerManager;component/Art/StatusUnknown.ico,Size=32}"/>
                                                        <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusUnknownLabel}"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Initializing}">
                                                        <Setter Property="Source" Value="{com:Icon Path=/ConanServerManager;component/Art/StatusStarting.ico,Size=32}"/>
                                                        <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusInitializingLabel}"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Running}">
                                                        <Setter Property="Source" Value="{com:Icon Path=/ConanServerManager;component/Art/StatusOn.ico,Size=32}"/>
                                                        <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusRunningLabel}"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Stopping}">
                                                        <Setter Property="Source" Value="{com:Icon Path=/ConanServerManager;component/Art/StatusStarting.ico,Size=32}"/>
                                                        <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusStoppingLabel}"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Stopped}">
                                                        <Setter Property="Source" Value="{com:Icon Path=/ConanServerManager;component/Art/StatusOff.ico,Size=32}"/>
                                                        <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusStoppedLabel}"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Unknown}">
                                                        <Setter Property="Source" Value="{com:Icon Path=/ConanServerManager;component/Art/StatusUnknown.ico,Size=32}"/>
                                                        <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusUnknownLabel}"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Updating}">
                                                        <Setter Property="Source" Value="{com:Icon Path=/ConanServerManager;component/Art/Download.ico,Size=32}"/>
                                                        <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusUpdatingLabel}"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static enum:ServerStatus.Uninstalled}">
                                                        <Setter Property="Source" Value="{com:Icon Path=/ConanServerManager;component/Art/StatusUnknown.ico,Size=32}"/>
                                                        <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_RuntimeStatusUninstalledLabel}"/>
                                                    </DataTrigger>
                                                </Style.Triggers>
                                            </Style>
                                        </Image.Style>
                                    </Image>
                                </Button>
                                <TextBlock Margin="2" VerticalAlignment="Center" Text="{Binding Profile.ProfileName}" ToolTip="{Binding Profile.ProfileToolTip}"/>
                            </StackPanel>
                        </DataTemplate>
                    </eo:TabControl.HeaderTemplate>
                    <eo:TabControl.NewTabButtonStyle>
                        <Style TargetType="eo:BareButton">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate>
                                        <Border BorderBrush="#8C8E94" BorderThickness="1,1,1,0" Padding="3,0">
                                            <Border.Background>
                                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                                    <LinearGradientBrush.GradientStops>
                                                        <GradientStop Offset="0" Color="#F3F3F3" />
                                                        <GradientStop Offset="0.5" Color="#EBEBEB" />
                                                        <GradientStop Offset="0.5" Color="#DDDDDD" />
                                                        <GradientStop Offset="1" Color="#CDCDCD" />
                                                    </LinearGradientBrush.GradientStops>
                                                </LinearGradientBrush>
                                            </Border.Background>
                                            <Image Margin="0,2" VerticalAlignment="Center" Source="{com:Icon Path=/ConanServerManager;component/Art/Add.ico,Size=32}" Width="16" Height="16" ToolTip="{DynamicResource MainWindow_NewProfileTooltip}"/>
                                        </Border>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </eo:TabControl.NewTabButtonStyle>
                    <eo:TabControl.CloseTabButtonStyle>
                        <Style TargetType="eo:BareButton">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate>
                                        <Image Margin="0,2" VerticalAlignment="Center" Source="{com:Icon Path=/ConanServerManager;component/Art/Delete.ico,Size=32}" Width="16" Height="16" ToolTip="{DynamicResource MainWindow_CloseProfileTooltip}"/>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </eo:TabControl.CloseTabButtonStyle>
                    <eo:TabControl.ContentTemplate>
                        <DataTemplate>
                            <sm:ServerSettingsControl Server="{Binding}"/>
                        </DataTemplate>
                    </eo:TabControl.ContentTemplate>
                </eo:TabControl>
            </Grid>
        </DockPanel>

        <!-- It's important that this is in the end of the XAML as it needs to be on top of everything else! -->
        <Grid x:Name="OverlayGrid" Visibility="Collapsed" DockPanel.Dock="Top" >
            <Grid Background="Black" Opacity="0.5"/>
            <Border MinWidth="250" Background="Orange" BorderBrush="Black" BorderThickness="1" CornerRadius="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center">
                <StackPanel>
                    <Label x:Name="OverlayMessage" Margin="5" FontWeight="Bold" HorizontalAlignment="Center" />
                </StackPanel>
            </Border>
        </Grid>

        <tb:TaskbarIcon
            Visibility="Visible"
            ToolTipText="{Binding Title}"
            IconSource="../Art/favicon.ico"
            LeftClickCommand="{Binding ShowWindowCommand, ElementName=Main}"
            MenuActivation="RightClick">

            <tb:TaskbarIcon.Resources>
                <clib:BindingProxy x:Key="proxy" Data="{Binding ElementName=Main}"/>
            </tb:TaskbarIcon.Resources>
            <tb:TaskbarIcon.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="{DynamicResource Application_NotifyIcon_ShowMainWindow}" Command="{Binding Source={StaticResource proxy}, Path=Data.ShowWindowCommand}" />
                </ContextMenu>
            </tb:TaskbarIcon.ContextMenu>

        </tb:TaskbarIcon>
    </Grid>
</Window>
