<Window x:Class="Remotely.Agent.Installer.Win.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:ViewModels="clr-namespace:Remotely.Agent.Installer.Win.ViewModels"
        xmlns:local="clr-namespace:Remotely.Agent.Installer.Win"
        mc:Ignorable="d"
        WindowStyle="None"
        ResizeMode="CanResizeWithGrip"
        AllowsTransparency="True"
        MouseLeftButtonDown="Window_MouseLeftButtonDown"
        Loaded="Window_Loaded"
        WindowStartupLocation="CenterScreen"
        Title="Remotely Installer" Height="335" Width="500"  Icon="{Binding Icon}">
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
    </Window.Resources>
    <Window.DataContext>
        <ViewModels:MainWindowViewModel/>
    </Window.DataContext>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Border Height="50" Background="{Binding TitleBackgroundColor}">
            <DockPanel Margin="10,0,0,0">
                <DockPanel>
                    <Image Height="50" Width="50"  Margin="0,0,10,0" Source="{Binding Icon}"></Image>
                    <TextBlock Foreground="{Binding TitleForegroundColor}" FontWeight="Bold" FontSize="20" VerticalAlignment="Center">
                        <Run Text="{Binding ProductName}"></Run>
                        <Run Text="Installer"></Run>
                    </TextBlock>
                </DockPanel>
                <Button Style="{StaticResource TitlebarButton}" Click="CloseButton_Click" Content="X" Foreground="{Binding TitleButtonForegroundColor}" Background="{Binding TitleBackgroundColor}" />
                <Button Style="{StaticResource TitlebarButton}" Click="MinimizeButton_Click" Content="____" Foreground="{Binding TitleButtonForegroundColor}" Background="{Binding TitleBackgroundColor}"/>
            </DockPanel>
        </Border>
        <Grid Grid.Row="1" Margin="10,15,10,0">

            <StackPanel>
                <TextBlock Style="{StaticResource SectionHeader}" Text="{Binding HeaderMessage}" Margin="0,0,0,10"></TextBlock>
                <Grid Margin="25,5,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="20" />
                        <RowDefinition/>
                        <RowDefinition Height="20" />
                        <RowDefinition/>
                    </Grid.RowDefinitions>

                    <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="0">
                        <TextBlock FontSize="14">Server URL:</TextBlock>
                        
                        <Button Grid.Column="1" Grid.Row="0" 
                                Background="White"
                                FontSize="14" 
                                Margin="5,0"
                                BorderThickness="0" 
                                Padding="3"
                                Cursor="Hand"
                                Click="ShowServerUrlHelp">
                            <TextBlock Text="&#xE897;" 
                             FontWeight="Bold"
                             FontFamily="Segoe MDL2 Assets" 
                             PreviewMouseUp="ShowServerUrlHelp"></TextBlock>
                        </Button>
                    </StackPanel>
                    
                    
                    <TextBox Grid.Column="1" Grid.Row="0" TextWrapping="Wrap" Text="{Binding ServerUrl}" FontSize="14" />

                    <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="2">
                        <TextBlock FontSize="14">Organization ID</TextBlock>

                        <Button Grid.Column="1" Grid.Row="0" 
                                Background="White"
                                FontSize="14"
                                Margin="5,0"
                                BorderThickness="0"
                                Padding="3"
                                Cursor="Hand"
                                Click="ShowOrganizationIdHelp">
                            <TextBlock Text="&#xE897;" 
                             FontWeight="Bold"
                             FontFamily="Segoe MDL2 Assets"></TextBlock>
                        </Button>
                    </StackPanel>
                    
                    <TextBox  Grid.Column="1" Grid.Row="2" TextWrapping="Wrap" Text="{Binding OrganizationID}" FontSize="14" />

                    <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="4">
                        <TextBlock FontSize="14">Support Shortcut</TextBlock>

                        <Button Grid.Column="1" Grid.Row="0" 
                                Background="White"
                                FontSize="14"
                                Margin="5,0" 
                                BorderThickness="0" 
                                Padding="3"
                                Cursor="Hand"
                                Click="ShowSupportShortcutHelp">
                            <TextBlock Text="&#xE897;" 
                             FontWeight="Bold"
                             FontFamily="Segoe MDL2 Assets"></TextBlock>
                        </Button>
                    </StackPanel>
                    <CheckBox  Grid.Column="1" Grid.Row="4" VerticalAlignment="Center" IsChecked="{Binding CreateSupportShortcut}" />

                </Grid>

                <TextBlock TextWrapping="Wrap" Margin="40,25,40,0" Text="{Binding StatusMessage}" FontSize="14"></TextBlock>
                <ProgressBar Height="25" Margin="40,10,40,0" Value="{Binding Progress}" Visibility="{Binding IsProgressVisible, Converter={StaticResource BooleanToVisibilityConverter}}"></ProgressBar>
            </StackPanel>

        </Grid>

        <DockPanel Margin="10" Grid.Row="2">
            <Button DockPanel.Dock="Left" 
                    HorizontalAlignment="Left" 
                    Style="{StaticResource NormalButton}" 
                    Margin="5,0,0,0"
                    Command="{Binding OpenLogsCommand}">
                Logs
            </Button>

            <Button DockPanel.Dock="Right" 
                    HorizontalAlignment="Right" 
                    Style="{StaticResource NormalButton}" 
                    Margin="5,0,0,0"
                    Click="CloseButton_Click">
                Close
            </Button>
            <Button DockPanel.Dock="Right" 
                    HorizontalAlignment="Right"
                    Style="{StaticResource NormalButton}" 
                    Margin="5,0,0,0"
                    IsEnabled="{Binding IsReadyState}"
                    Visibility="{Binding IsServiceInstalled, Converter={StaticResource BooleanToVisibilityConverter}}"
                    Command="{Binding UninstallCommand}">
                Uninstall
            </Button>
            <Button DockPanel.Dock="Right" 
                    HorizontalAlignment="Right" 
                    Style="{StaticResource NormalButton}" 
                    Content="{Binding InstallButtonText}"
                    Margin="5,0,0,0"
                    IsEnabled="{Binding IsReadyState}"
                    Command="{Binding InstallCommand}">
            </Button>
        </DockPanel>
    </Grid>
</Window>
