<Window x:Class="SyncTrayzor.Pages.ShellView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:s="https://github.com/canton7/Stylet"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:xaml="clr-namespace:SyncTrayzor.Xaml"
        xmlns:l="clr-namespace:SyncTrayzor.Localization"
        FlowDirection="{x:Static l:Localizer.FlowDirection}"
        Height="700" Width="1100"
        MinHeight="300" MinWidth="400"
        Title="SyncTrayzor">
    <i:Interaction.Behaviors>
        <xaml:WindowPlacementBehaviour Placement="{Binding Placement}"/>
        <xaml:ActivateBehaviour ActivateObservable="{Binding ActivateObservable}"/>
    </i:Interaction.Behaviors>
    <Window.InputBindings>
        <MouseBinding Gesture="{x:Static xaml:MouseWheelGesture.CtrlUp}" Command="{s:Action BrowserZoomIn}"/>
        <MouseBinding Gesture="{x:Static xaml:MouseWheelGesture.CtrlDown}" Command="{s:Action BrowserZoomOut}"/>
        <!-- Lots of different sorts of + and - on the keyboard: gotta catch em all! -->
        <KeyBinding Key="OemPlus" Modifiers="Control+Shift" Command="{s:Action BrowserZoomIn}"/>
        <KeyBinding Key="OemPlus" Modifiers="Control" Command="{s:Action BrowserZoomIn}"/>
        <KeyBinding Key="Add" Modifiers="Control" Command="{s:Action BrowserZoomIn}"/>
        <KeyBinding Key="OemMinus" Modifiers="Control" Command="{s:Action BrowserZoomOut}"/>
        <KeyBinding Key="Subtract" Modifiers="Control" Command="{s:Action BrowserZoomOut}"/>
        <KeyBinding Key="D0" Modifiers="Control" Command="{s:Action BrowserZoomReset}"/>
        <KeyBinding Key="NumPad0" Modifiers="Control" Command="{s:Action BrowserZoomReset}"/>
        <KeyBinding Key="F5" Command="{s:Action RefreshBrowser}"/>
    </Window.InputBindings>
    <DockPanel>
        <Grid DockPanel.Dock="Top">
            <Menu>
                <MenuItem Header="{l:Loc ShellView_Menu_File}">
                    <MenuItem Header="{l:Loc ShellView_Menu_File_Settings}" Command="{s:Action ShowSettings}"/>
                    <MenuItem Header="{l:Loc ShellView_Menu_File_ConflictResolver}" Command="{s:Action ShowConflictResolver}"/>
                    <Separator/>
                    <MenuItem Header="{l:Loc ShellView_Menu_File_Exit}" Command="{s:Action Shutdown}"/>
                </MenuItem>
                <MenuItem Header="{l:Loc ShellView_Menu_Syncthing}">
                    <MenuItem Header="{l:Loc ShellView_Menu_Syncthing_Start}" Command="{s:Action Start}"/>
                    <MenuItem Header="{l:Loc ShellView_Menu_Syncthing_Stop}" Command="{s:Action Stop}"/>
                    <MenuItem Header="{l:Loc ShellView_Menu_Syncthing_Restart}" Command="{s:Action Restart}"/>
                    <Separator/>
                    <MenuItem Header="{l:Loc ShellView_Menu_Syncthing_Refresh}" InputGestureText="F5" Command="{s:Action RefreshBrowser}"/>
                    <MenuItem Header="{l:Loc ShellView_Menu_Syncthing_OpenExternal}" Command="{s:Action OpenBrowser}"/>
                    <Separator/>
                    <MenuItem Header="{l:Loc ShellView_Menu_Syncthing_KillAll}" Command="{s:Action KillAllSyncthingProcesses}"/>
                </MenuItem>
                <MenuItem Header="{l:Loc ShellView_Menu_View}">
                    <MenuItem Header="{l:Loc ShellView_Menu_View_SyncthingConsole}" IsCheckable="True" IsChecked="{Binding ShowConsole}"/>
                    <Separator/>
                    <MenuItem Header="{l:Loc ShellView_Menu_Zoom}" IsEnabled="{Binding CanZoomBrowser}">
                        <MenuItem Header="{l:Loc ShellView_Menu_Zoom_In}" InputGestureText="Ctrl++" Command="{s:Action BrowserZoomIn}"/>
                        <MenuItem Header="{l:Loc ShellView_Menu_Zoom_Out}" InputGestureText="Ctrl+-" Command="{s:Action BrowserZoomOut}"/>
                        <MenuItem Header="{l:Loc ShellView_Menu_Zoom_Reset}" InputGestureText="Ctrl+0" Command="{s:Action BrowserZoomReset}"/>
                    </MenuItem>
                </MenuItem>
                <MenuItem Header="{l:Loc ShellView_Menu_Help}">
                    <MenuItem Header="{l:Loc ShellView_Menu_Help_About}" Command="{s:Action ShowAbout}"/>
                </MenuItem>
            </Menu>
            <TextBlock HorizontalAlignment="Right" Margin="0,0,5,0" Visibility="{Binding DonationManager.HaveDonated, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}}">
                <Hyperlink s:View.ActionTarget="{Binding DonationManager}" Command="{s:Action Donate}" >
                    <TextBlock Text="{l:Loc ShellView_Donate}"/>
                </Hyperlink>
            </TextBlock>
        </Grid>

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition/>
                <RowDefinition>
                    <i:Interaction.Behaviors>
                        <xaml:CollapsingRowDefinitionBehaviour Height="Auto" RowVisibility="{Binding ShowConsole, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"/>
                    </i:Interaction.Behaviors>
                </RowDefinition>
                <RowDefinition>
                    <i:Interaction.Behaviors>
                        <xaml:CollapsingRowDefinitionBehaviour Height="{Binding ConsoleHeight, Mode=TwoWay, Converter={x:Static xaml:GridLengthToAbsoluteConverter.Instance}}"
                                                               MinHeight="100" RowVisibility="{Binding ShowConsole, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"/>
                    </i:Interaction.Behaviors>
                </RowDefinition>
            </Grid.RowDefinitions>

            <ContentControl Grid.Row="0" s:View.Model="{Binding BarAlerts}"/>
            
            <ContentControl Grid.Row="1" s:View.Model="{Binding Viewer}"/>

            <GridSplitter Grid.Row="2" Height="5" VerticalAlignment="Center" HorizontalAlignment="Stretch" ShowsPreview="True" ResizeDirection="Rows"/>

            <ContentControl Grid.Row="3" s:View.Model="{Binding Console}"/>
        </Grid>
    </DockPanel>
</Window>
