<Window x:Class="ServerManagerTool.Windows.ServerMonitorWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:tb="http://www.hardcodet.net/taskbar"
        xmlns:sm="clr-namespace:ServerManagerTool"
        xmlns:cctl="clr-namespace:ServerManagerTool.Common.Controls;assembly=ServerManager.Common"
        xmlns:controls="clr-namespace:ServerManagerTool.Common.Controls;assembly=ServerManager.Common"
        xmlns:ce="clr-namespace:ServerManagerTool.Common.Enums;assembly=ServerManager.Common"
        xmlns:clib="clr-namespace:ServerManagerTool.Common.Lib;assembly=ServerManager.Common"
        xmlns:com="clr-namespace:ServerManagerTool.Common;assembly=ServerManager.Common"
        xmlns:vm="clr-namespace:ServerManagerTool.Lib.ViewModel"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        mc:Ignorable="d"
        MinWidth="600" MinHeight="500" Width="900" Height="500" Left="50" Top="50" ResizeMode="CanResize"
        Loaded="ServerMonitorWindow_Loaded" SizeChanged="ServerMonitorWindow_SizeChanged" StateChanged="ServerMonitorWindow_StateChanged" LocationChanged="ServerMonitorWindow_LocationChanged"
        Icon="../Art/favicon.ico" Title="{DynamicResource ServerMonitor_Title}"
        FocusManager.FocusedElement="{Binding ElementName=ShutdownReasonTextBox}"
        Name="ServerMonitorUI">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="..\Globalization\en-US\en-US.xaml"/>
                <ResourceDictionary Source="..\Styles\Default.xaml"/>
            </ResourceDictionary.MergedDictionaries>

            <sm:ScrollToBottomAction x:Key="ScrollToBottomAction" />
            <vm:MapNameValueConverter x:Key="MapNameValueConverter"/>

            <DataTemplate x:Key="StopButtonContent">
                <StackPanel Orientation="Horizontal">
                    <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/Stop.ico,Size=32}" Width="16" VerticalAlignment="Center"/>
                    <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/DropArrow.ico,Size=32}" Width="8" Margin="2,0,0,0" VerticalAlignment="Center"/>
                </StackPanel>
            </DataTemplate>
            <DataTemplate x:Key="UpdateButtonContent">
                <StackPanel Orientation="Horizontal">
                    <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/Download.ico,Size=32}" Width="16" VerticalAlignment="Center"/>
                    <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/DropArrow.ico,Size=32}" Width="8" Margin="2,0,0,0" VerticalAlignment="Center"/>
                </StackPanel>
            </DataTemplate>
        </ResourceDictionary>
    </Window.Resources>

    <Grid Background="{StaticResource BeigeGradient}" MouseLeftButtonUp="OnMouseLeftButtonUp" MouseMove="OnMouseMove">
        <DockPanel x:Name="dockPanel">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*" MinHeight="200"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto" MinHeight="100"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <Button Grid.Row="0" Grid.Column="0" Width="22" Height="22" Margin="5,5,5,0" HorizontalAlignment="Left" VerticalAlignment="Top" Click="CreateShortcut_Click" ToolTip="{DynamicResource ServerMonitor_CreateShortcutButtonTooltip}">
                    <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/Shortcut.ico,Size=32}"/>
                </Button>

                <Button Grid.Row="0" Grid.Column="1" Width="22" Height="22" Margin="10,5,5,0" HorizontalAlignment="Left" VerticalAlignment="Top" Click="SelectAllServers_Click" ToolTip="{DynamicResource ServerMonitor_SelectAllServersButtonTooltip}">
                    <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/Checked.ico,Size=32}"/>
                </Button>

                <Button Grid.Row="0" Grid.Column="2" Width="22" Height="22" Margin="0,5,5,0" HorizontalAlignment="Left" VerticalAlignment="Top" Click="UnselectAllServers_Click" ToolTip="{DynamicResource ServerMonitor_UnselectAllServersButtonTooltip}">
                    <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/Unchecked.ico,Size=32}"/>
                </Button>

                <Button Grid.Row="0" Grid.Column="3" Width="22" Height="22" Margin="10,5,5,0" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding StartServersCommand}" CommandParameter="{Binding}" ToolTip="{DynamicResource ServerMonitor_StartServersButtonTooltip}">
                    <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/Start.ico,Size=32}"/>
                </Button>

                <Button Grid.Row="0" Grid.Column="4" Width="22" Height="22" Margin="0,5,5,0" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding RestartServersCommand}" CommandParameter="{Binding}" ToolTip="{DynamicResource ServerMonitor_RestartServersButtonTooltip}">
                    <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/Restart.ico,Size=32}"/>
                </Button>

                <controls:DropDownButton Grid.Row="0" Grid.Column="5" Width="35" Height="22" Margin="0,5,5,0" HorizontalAlignment="Left" VerticalAlignment="Center">
                    <ContentControl ContentTemplate="{StaticResource StopButtonContent}" />
                    
                    <controls:DropDownButton.Menu>
                        <ContextMenu>
                            <MenuItem Header="{DynamicResource ServerMonitor_ShutdownServersButtonLabel}" Command="{Binding ShutdownServersCommand}" CommandParameter="{Binding}"/>
                            <MenuItem Header="{DynamicResource ServerMonitor_StopServersButtonLabel}" Command="{Binding StopServersCommand}" CommandParameter="{Binding}"/>
                        </ContextMenu>
                    </controls:DropDownButton.Menu>
                </controls:DropDownButton>

                <controls:DropDownButton Grid.Row="0" Grid.Column="6" Width="35" Height="22" Margin="0,5,5,0" HorizontalAlignment="Left" VerticalAlignment="Center">
                    <ContentControl ContentTemplate="{StaticResource UpdateButtonContent}" />

                    <controls:DropDownButton.Menu>
                        <ContextMenu>
                            <MenuItem Header="{DynamicResource ServerMonitor_UpdateServersButtonLabel}" Command="{Binding UpdateServersCommand}" CommandParameter="{Binding}"/>
                            <MenuItem Header="{DynamicResource ServerMonitor_UpdateModsButtonLabel}" Command="{Binding UpdateModsCommand}" CommandParameter="{Binding}"/>
                        </ContextMenu>
                    </controls:DropDownButton.Menu>
                </controls:DropDownButton>

                <Button Grid.Row="0" Grid.Column="7" Width="22" Height="22" Margin="0,5,5,0" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding BackupServersCommand}" CommandParameter="{Binding}" ToolTip="{DynamicResource ServerMonitor_BackupServersButtonTooltip}">
                    <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/Save.ico,Size=32}"/>
                </Button>

                <Button Grid.Row="0" Grid.Column="8" Width="22" Height="22" Margin="10,5,5,0" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding CancelServersCommand}" CommandParameter="{Binding}" ToolTip="{DynamicResource ServerMonitor_CancelServersButtonTooltip}">
                    <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/Stop.ico,Size=32}"/>
                </Button>

                <CheckBox Grid.Row="0" Grid.Column="9" Content="{DynamicResource ServerMonitor_ProcessServersSequentiallyLabel}" IsChecked="{Binding ProcessServersSequentially}" Margin="10,5,5,0" VerticalAlignment="Center" ToolTip="{DynamicResource ServerMonitor_ProcessServersSequentiallyTooltip}"/>

                <StackPanel Grid.Row="0" Grid.Column="10" Orientation="Horizontal">
                    <TextBlock Margin="30,5,5,0" Text="{DynamicResource ServerMonitor_TotalCountLabel}" VerticalAlignment="Center" />
                    <TextBlock Margin="5,5,5,0" Text="{Binding ServerManager.Servers.Count}" VerticalAlignment="Center" />
                </StackPanel>

                <Button Grid.Row="0" Grid.Column="11" Height="22" Margin="5,5,5,0" Background="#00AA00" Foreground="White" Padding="1" BorderThickness="1" BorderBrush="White" ContentStringFormat="{DynamicResource MainWindow_UpdateToLabelFormat}" Content="{Binding LatestServerManagerVersion}" Click="UpgradeApplication_Click" VerticalAlignment="Center" >
                    <Button.Style>
                        <Style TargetType="{x:Type Button}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding ShowUpdateButton}" Value="True">
                                    <Setter Property="Visibility" Value="Visible"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding ShowUpdateButton}" Value="False">
                                    <Setter Property="Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Button.Style>
                </Button>

                <Button Grid.Row="0" Grid.Column="12" Width="22" Height="22" Margin="5,5,5,0" HorizontalAlignment="Left" VerticalAlignment="Top" Click="PatchNotes_Click" ToolTip="{DynamicResource ServerSettings_PatchNotesTooltip}">
                    <Button.Style>
                        <Style TargetType="{x:Type Button}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsStandAloneWindow}" Value="True">
                                    <Setter Property="Visibility" Value="Visible"/>
                                </DataTrigger>
                                <DataTrigger Binding="{Binding IsStandAloneWindow}" Value="False">
                                    <Setter Property="Visibility" Value="Collapsed"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Button.Style>

                    <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/ChangeNotes.ico,Size=32}"/>
                </Button>

                <Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="13" Margin="1,2,5,1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <Label Grid.Row="0" Grid.Column="0" Content="{DynamicResource ShutdownWindow_ShutdownReasonLabel}" ToolTip="{DynamicResource ShutdownWindow_ShutdownReasonTooltip}" VerticalAlignment="Center"/>
                    <TextBox x:Name="ShutdownReasonTextBox" Grid.Row="0" Grid.Column="1" Text="{Binding ShutdownReason}" ToolTip="{DynamicResource ShutdownWindow_ShutdownReasonTooltip}" VerticalContentAlignment="Center"/>
                </Grid>

                <cctl:AnnotatedSlider Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="13" Margin="1" Label="{DynamicResource ServerMonitor_SequentialProcessDelayLabel}" Value="{Binding SequentialProcessDelay}" Minimum="0" Maximum="300" SmallChange="1" LargeChange="5" TickFrequency="1" LabelRelativeWidth="Auto" SliderRelativeWidth="15*" SuffixRelativeWidth="Auto" Suffix="{DynamicResource SliderUnits_Seconds}" Visibility="{Binding ProcessServersSequentially, Converter={StaticResource BooleanToVisibilityConverter}}" ToolTip="{DynamicResource ServerMonitor_SequentialProcessDelayTooltip}"/>

                <DataGrid Name="ServersGrid" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="13" Margin="5,5,5,0" HorizontalAlignment="Stretch" ItemsSource="{Binding ServerManager.Servers}" GridLinesVisibility="Horizontal" HeadersVisibility="All" AutoGenerateColumns="False" CanUserAddRows="False" CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" RowHeaderWidth="25" SelectionMode="Single" PreviewMouseLeftButtonDown="OnMouseLeftButtonDown">
                    <DataGrid.Resources>
                        <ResourceDictionary>
                            <Style TargetType="{x:Type DataGridCell}">
                                <Style.Triggers>
                                    <Trigger Property="IsSelected" Value="True">
                                        <Setter Property="Background" Value="Transparent"/>
                                        <Setter Property="BorderBrush" Value="Transparent"/>
                                        <Setter Property="Foreground" Value="Black"/>
                                    </Trigger>
                                </Style.Triggers>
                            </Style>

                            <Style TargetType="{x:Type DataGridRow}">
                                <Setter Property="Background" Value="White" />

                                <Style.Resources>
                                    <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="Transparent"/>
                                    <SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}" Color="Black"/>
                                    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
                                    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"/>
                                </Style.Resources>

                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Null}">
                                        <Setter Property="Background" Value="#26FF0000" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Initializing}">
                                        <Setter Property="Background" Value="#26FFA500" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Running}">
                                        <Setter Property="Background" Value="#26008000" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Stopping}">
                                        <Setter Property="Background" Value="#26FFA500" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Stopped}">
                                        <Setter Property="Background" Value="White" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Unknown}">
                                        <Setter Property="Background" Value="#26FF0000" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Updating}">
                                        <Setter Property="Background" Value="#260000FF" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Uninstalled}">
                                        <Setter Property="Background" Value="#260000FF" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </ResourceDictionary>
                    </DataGrid.Resources>

                    <DataGrid.HorizontalGridLinesBrush>
                        <SolidColorBrush Color="#FFB4B4B4"/>
                    </DataGrid.HorizontalGridLinesBrush>
                    <DataGrid.VerticalGridLinesBrush>
                        <SolidColorBrush Color="#FFB4B4B4"/>
                    </DataGrid.VerticalGridLinesBrush>

                    <DataGrid.Columns>

                        <DataGridTemplateColumn Width="Auto" Header="{DynamicResource ServerMonitor_SelectedColumnLabel}">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <CheckBox IsChecked="{Binding Selected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True}" HorizontalAlignment="Center" VerticalAlignment="Center" />
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="Auto" MinWidth="100">
                            <DataGridTemplateColumn.Header>
                                <TextBlock Text="{DynamicResource ServerMonitor_ProfileColumnLabel}" />
                            </DataGridTemplateColumn.Header>

                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Label Content="{Binding Profile.ProfileName}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellStyle>
                                <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
                                    <Setter Property="VerticalAlignment" Value="Center"/>
                                </Style>
                            </DataGridTemplateColumn.CellStyle>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="*" MinWidth="100">
                            <DataGridTemplateColumn.Header>
                                <TextBlock Text="{DynamicResource ServerMonitor_ServerColumnLabel}" />
                            </DataGridTemplateColumn.Header>

                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Label Content="{Binding Profile.ServerName}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellStyle>
                                <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
                                    <Setter Property="VerticalAlignment" Value="Center"/>
                                </Style>
                            </DataGridTemplateColumn.CellStyle>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="Auto" MinWidth="50">
                            <DataGridTemplateColumn.Header>
                                <TextBlock Text="{DynamicResource ServerMonitor_MapColumnLabel}" />
                            </DataGridTemplateColumn.Header>

                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Label Content="{Binding Profile.ServerMap, Converter={StaticResource MapNameValueConverter}}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellStyle>
                                <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
                                    <Setter Property="VerticalAlignment" Value="Center"/>
                                </Style>
                            </DataGridTemplateColumn.CellStyle>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="Auto" MinWidth="50">
                            <DataGridTemplateColumn.Header>
                                <TextBlock Text="{DynamicResource ServerMonitor_PortsColumnLabel}" />
                            </DataGridTemplateColumn.Header>

                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Label Content="{Binding Profile.PortsString}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellStyle>
                                <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
                                    <Setter Property="VerticalAlignment" Value="Center"/>
                                </Style>
                            </DataGridTemplateColumn.CellStyle>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="Auto" MinWidth="50">
                            <DataGridTemplateColumn.Header>
                                <TextBlock Text="{DynamicResource ServerMonitor_ModsColumnLabel}" />
                            </DataGridTemplateColumn.Header>

                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Label Content="{Binding Profile.ServerModIds, Converter={StaticResource CommaDelimitedStringCountConverter}}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellStyle>
                                <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
                                    <Setter Property="VerticalAlignment" Value="Center"/>
                                </Style>
                            </DataGridTemplateColumn.CellStyle>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="Auto" MinWidth="50">
                            <DataGridTemplateColumn.Header>
                                <TextBlock Text="{DynamicResource ServerMonitor_VersionColumnLabel}" />
                            </DataGridTemplateColumn.Header>

                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Label Content="{Binding Profile.LastInstalledVersion, Converter={StaticResource InstalledVersionConverter}}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellStyle>
                                <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
                                    <Setter Property="VerticalAlignment" Value="Center"/>
                                </Style>
                            </DataGridTemplateColumn.CellStyle>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="Auto" MinWidth="50">
                            <DataGridTemplateColumn.Header>
                                <TextBlock Text="{DynamicResource ServerMonitor_PlayersColumnLabel}" />
                            </DataGridTemplateColumn.Header>

                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                                        <Label Content="{Binding Runtime.Players}" />
                                        <Label Content="/" />
                                        <Label Content="{Binding Runtime.MaxPlayers}"/>
                                    </StackPanel>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellStyle>
                                <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
                                    <Setter Property="VerticalAlignment" Value="Center"/>
                                </Style>
                            </DataGridTemplateColumn.CellStyle>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="Auto" MinWidth="100">
                            <DataGridTemplateColumn.Header>
                                <TextBlock Text="{DynamicResource ServerMonitor_StatusColumnLabel}" />
                            </DataGridTemplateColumn.Header>

                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Label Content="{Binding Runtime.StatusString}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellStyle>
                                <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
                                    <Setter Property="VerticalAlignment" Value="Center"/>
                                </Style>
                            </DataGridTemplateColumn.CellStyle>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="30" CanUserResize="False">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button Width="22" Height="22" Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" Click="StartStopServer_Click">
                                        <Button.Style>
                                            <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
                                                <Style.Triggers>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Null}">
                                                        <Setter Property="ToolTip" Value="{DynamicResource ServerMonitor_StopServerTooltip}" />
                                                        <Setter Property="Visibility" Value="Hidden"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Initializing}">
                                                        <Setter Property="ToolTip" Value="{DynamicResource ServerMonitor_StopServerTooltip}" />
                                                        <Setter Property="IsEnabled" Value="True"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Running}">
                                                        <Setter Property="ToolTip" Value="{DynamicResource ServerMonitor_StopServerTooltip}" />
                                                        <Setter Property="IsEnabled" Value="True"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Stopping}">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Stopped}">
                                                        <Setter Property="ToolTip" Value="{DynamicResource ServerMonitor_StartServerTooltip}" />
                                                        <Setter Property="IsEnabled" Value="True"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Unknown}">
                                                        <Setter Property="Visibility" Value="Hidden"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Updating}">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Uninstalled}">
                                                        <Setter Property="Visibility" Value="Hidden"/>
                                                    </DataTrigger>
                                                </Style.Triggers>
                                            </Style>
                                        </Button.Style>
                                        <Image>
                                            <Image.Style>
                                                <Style TargetType="{x:Type Image}">
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Null}">
                                                            <Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/Cancel.ico,Size=32}"/>
                                                        </DataTrigger>
                                                        <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Initializing}">
                                                            <Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/Stop.ico,Size=32}"/>
                                                        </DataTrigger>
                                                        <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Running}">
                                                            <Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/Stop.ico,Size=32}"/>
                                                        </DataTrigger>
                                                        <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Stopping}">
                                                            <Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/Stop.ico,Size=32}"/>
                                                        </DataTrigger>
                                                        <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Stopped}">
                                                            <Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/Start.ico,Size=32}"/>
                                                        </DataTrigger>
                                                        <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Unknown}">
                                                            <Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/Cancel.ico,Size=32}"/>
                                                        </DataTrigger>
                                                        <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Updating}">
                                                            <Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/Cancel.ico,Size=32}"/>
                                                        </DataTrigger>
                                                        <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Uninstalled}">
                                                            <Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/Cancel.ico,Size=32}"/>
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </Image.Style>
                                        </Image>
                                    </Button>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellStyle>
                                <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
                                    <Setter Property="VerticalAlignment" Value="Center"/>
                                </Style>
                            </DataGridTemplateColumn.CellStyle>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="30" CanUserResize="False">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button Width="22" Height="22" Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" Click="UpdateServer_Click">
                                        <Button.Style>
                                            <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
                                                <Style.Triggers>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Null}">
                                                        <Setter Property="Visibility" Value="Hidden"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Initializing}">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Running}">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Stopping}">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Stopped}">
                                                        <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_UpgradeButtonTooltip}" />
                                                        <Setter Property="IsEnabled" Value="True"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Unknown}">
                                                        <Setter Property="Visibility" Value="Hidden"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Updating}">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Uninstalled}">
                                                        <Setter Property="ToolTip" Value="{DynamicResource ServerSettings_InstallButtonTooltip}" />
                                                        <Setter Property="IsEnabled" Value="True"/>
                                                    </DataTrigger>
                                                </Style.Triggers>
                                            </Style>
                                        </Button.Style>
                                        <Image>
                                            <Image.Style>
                                                <Style TargetType="{x:Type Image}">
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Null}">
                                                            <Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/Cancel.ico,Size=32}"/>
                                                        </DataTrigger>
                                                        <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Initializing}">
                                                            <Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/Download.ico,Size=32}"/>
                                                        </DataTrigger>
                                                        <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Running}">
                                                            <Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/Download.ico,Size=32}"/>
                                                        </DataTrigger>
                                                        <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Stopping}">
                                                            <Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/Download.ico,Size=32}"/>
                                                        </DataTrigger>
                                                        <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Stopped}">
                                                            <Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/Download.ico,Size=32}"/>
                                                        </DataTrigger>
                                                        <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Unknown}">
                                                            <Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/Cancel.ico,Size=32}"/>
                                                        </DataTrigger>
                                                        <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Updating}">
                                                            <Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/Stop.ico,Size=32}"/>
                                                        </DataTrigger>
                                                        <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Uninstalled}">
                                                            <Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/Download.ico,Size=32}"/>
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </Image.Style>
                                        </Image>
                                    </Button>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellStyle>
                                <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
                                    <Setter Property="VerticalAlignment" Value="Center"/>
                                </Style>
                            </DataGridTemplateColumn.CellStyle>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="30" CanUserResize="False">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button Width="22" Height="22" Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" Click="OpenPlayerList_Click">
                                        <Button.Style>
                                            <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
                                                <Style.Triggers>
                                                    <DataTrigger Binding="{Binding Profile.RCONEnabled}" Value="False">
                                                        <Setter Property="ToolTip" Value="{DynamicResource ServerMonitor_PlayerListButtonTooltip}" />
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Profile.RCONEnabled}" Value="True">
                                                        <Setter Property="ToolTip" Value="{DynamicResource ServerMonitor_RCONButtonTooltip}" />
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Null}">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Initializing}">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Running}">
                                                        <Setter Property="IsEnabled" Value="True"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Stopping}">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Stopped}">
                                                        <Setter Property="IsEnabled" Value="True"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Unknown}">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Updating}">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Uninstalled}">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                    </DataTrigger>
                                                </Style.Triggers>
                                            </Style>
                                        </Button.Style>
                                        <Image>
                                            <Image.Style>
                                                <Style TargetType="{x:Type Image}">
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding Profile.RCONEnabled}" Value="False">
                                                            <Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/Players.ico,Size=32}"/>
                                                        </DataTrigger>
                                                        <DataTrigger Binding="{Binding Profile.RCONEnabled}" Value="True">
                                                            <Setter Property="Source" Value="{com:Icon Path=/Ark Server Manager;component/Art/Command.ico,Size=32}"/>
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </Image.Style>
                                        </Image>
                                    </Button>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellStyle>
                                <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
                                    <Setter Property="VerticalAlignment" Value="Center"/>
                                </Style>
                            </DataGridTemplateColumn.CellStyle>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="30" CanUserResize="False">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button Width="22" Height="22" Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" Click="BackupServer_Click" ToolTip="{DynamicResource ServerSettings_SaveBackupButtonTooltip}">
                                        <Button.Style>
                                            <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
                                                <Style.Triggers>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Null}">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Initializing}">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Running}">
                                                        <Setter Property="IsEnabled" Value="True"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Stopping}">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Stopped}">
                                                        <Setter Property="IsEnabled" Value="True"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Unknown}">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Updating}">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding Runtime.Status}" Value="{x:Static ce:ServerStatus.Uninstalled}">
                                                        <Setter Property="IsEnabled" Value="False"/>
                                                    </DataTrigger>
                                                </Style.Triggers>
                                            </Style>
                                        </Button.Style>
                                        <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/Save.ico,Size=32}" />
                                    </Button>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellStyle>
                                <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
                                    <Setter Property="VerticalAlignment" Value="Center"/>
                                </Style>
                            </DataGridTemplateColumn.CellStyle>
                        </DataGridTemplateColumn>

                        <DataGridTemplateColumn Width="30" CanUserResize="False">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button Width="22" Height="22" Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" Click="OpenServerFolder_Click" ToolTip="{DynamicResource ServerSettings_OpenServerFolderTooltip}">
                                        <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/FolderOpen.ico,Size=32}" />
                                    </Button>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                            <DataGridTemplateColumn.CellStyle>
                                <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
                                    <Setter Property="VerticalAlignment" Value="Center"/>
                                </Style>
                            </DataGridTemplateColumn.CellStyle>
                        </DataGridTemplateColumn>

                    </DataGrid.Columns>
                </DataGrid>

                <GridSplitter Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="13" Height="5" ShowsPreview="True" HorizontalAlignment="Stretch" VerticalAlignment="Center" Opacity="0"/>

                <RichTextBox Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="13" Margin="5,0,5,5" BorderBrush="LightGray" HorizontalAlignment="Stretch" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Auto" IsReadOnlyCaretVisible="True" IsReadOnly="True" IsTabStop="False">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="TextChanged" >
                            <sm:ScrollToBottomAction IsEnabled="True"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    <RichTextBox.Resources>
                        <Style TargetType="{x:Type Paragraph}">
                            <Setter Property="Margin" Value="0"/>
                        </Style>
                    </RichTextBox.Resources>
                    <FlowDocument Name="ConsoleContent"/>
                </RichTextBox>
            </Grid>
        </DockPanel>

        <!-- Drag and Drop Popup -->
        <Popup x:Name="popup" IsHitTestVisible="False" Placement="RelativePoint" PlacementTarget="{Binding ElementName=ServerMonitorUI}" AllowsTransparency="True" Grid.ColumnSpan="2">
            <Border BorderBrush="LightSteelBlue" BorderThickness="2" Background="White" Opacity="0.75">
                <StackPanel Orientation="Horizontal" Margin="4,3,8,3">
                    <Image Source="{com:Icon Path=/Ark Server Manager;component/Art/Drag.ico,Size=32}" Width="16" Height="16"/>
                    <TextBlock FontSize="14" VerticalAlignment="Center" Text="{Binding DraggedItem.Profile.ProfileName, ElementName=ServerMonitorUI}" Margin="8,0,0,0" />
                </StackPanel>
            </Border>
        </Popup>

        <!-- 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="{Binding IsStandAloneWindow, Converter={StaticResource BooleanToVisibilityConverter}}"
            ToolTipText="{Binding Title}"
            IconSource="../Art/favicon.ico"
            LeftClickCommand="{Binding ShowWindowCommand, ElementName=ServerMonitorUI}" Grid.ColumnSpan="2">

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

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