<commit_before>﻿<Fluent:RibbonWindow x:Class="VisualJsonEditor.Views.MainWindow"
                     xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent"
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:viewModels="clr-namespace:VisualJsonEditor.ViewModels"
                     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                     xmlns:converters="clr-namespace:MyToolkit.Converters;assembly=MyToolkit.Extended"
                     xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
                     xmlns:localization="clr-namespace:VisualJsonEditor.Localization"
                     xmlns:controls="clr-namespace:VisualJsonEditor.Controls"
                     xmlns:models="clr-namespace:VisualJsonEditor.Models"
                     mc:Ignorable="d" Title="{x:Static localization:Strings.HeaderMainWindow}" 
                     Height="600" Width="700" MinWidth="400" MinHeight="400" Background="LightGray"
                     WindowStartupLocation="CenterScreen" ContentRendered="RibbonWindow_ContentRendered">

    <Window.Resources>
        <viewModels:MainWindowModel x:Key="ViewModel" />
        <converters:VisibilityConverter x:Key="VisibilityConverter" />
        <converters:NotConverter x:Key="NotConverter" />
    </Window.Resources>

    <Grid DataContext="{StaticResource ViewModel}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <!-- ribbons -->
        <Fluent:Ribbon ShowQuickAccessToolBarAboveRibbon="True" 
                       IsQuickAccessToolBarVisible="True" x:Name="Ribbon"
                       AutomaticStateManagement="True" Grid.ColumnSpan="3">
            
            <!--Backstage-->
            <Fluent:Ribbon.Menu>
                <Fluent:Backstage>
                    <Fluent:BackstageTabControl>
                        <Fluent:BackstageTabItem Header="{Binding Strings.HeaderRecentDocuments}">
                            <Grid Margin="8,0,0,0">
                                <ScrollViewer VerticalScrollBarVisibility="Visible">
                                    <ItemsControl ItemsSource="{Binding Configuration.RecentFiles}" Margin="0,0,8,0">
                                        <ItemsControl.ItemTemplate>
                                            <DataTemplate>
                                                <Button Click="OnOpenDocument" HorizontalContentAlignment="Left" 
                                                        Background="Transparent" BorderThickness="0" Margin="0,8,0,0"
                                                        Command="{Binding OpenDocumentFromPathCommand, Source={StaticResource ViewModel}}"
                                                        CommandParameter="{Binding FilePath}">
                                                    <Button.Content>
                                                        <StackPanel Orientation="Horizontal" Margin="4">
                                                            <Image Source="/Images/ButtonCreateLarge.png" Margin="0,0,4,0" />
                                                            <StackPanel Margin="0,-3,0,0">
                                                                <TextBlock Text="{Binding FileName}" FontSize="16" />
                                                                <TextBlock Text="{Binding FilePath}" FontSize="10" />
                                                            </StackPanel>
                                                        </StackPanel>
                                                    </Button.Content>
                                                </Button>
                                            </DataTemplate>
                                        </ItemsControl.ItemTemplate>
                                    </ItemsControl>
                                </ScrollViewer>
                            </Grid>
                        </Fluent:BackstageTabItem>

                        <Fluent:Button Header="{Binding Strings.ButtonNew}" Width="200"
                                       Command="{Binding CreateDocumentCommand}" 
                                       ToolTip="{Binding Strings.ShortcutCtrlN}"
                                       Icon="/Images/ButtonCreateLarge.png" />

                        <Fluent:Button Header="{Binding Strings.ButtonOpen}" 
                                       Command="{Binding OpenDocumentCommand}" 
                                       ToolTip="{Binding Strings.ShortcutCtrlO}"
                                       Icon="/Images/ButtonOpenLarge.png" />

                        <Fluent:Button Header="{Binding Strings.ButtonSave}"  
                                       Command="{Binding SaveDocumentCommand}" CommandParameter="{Binding SelectedDocument}"
                                       ToolTip="{Binding Strings.ShortcutCtrlS}"
                                       Icon="/Images/ButtonSaveLarge.png" />
                        
                        <Fluent:Button Header="{Binding Strings.ButtonSaveAs}" 
                                       Command="{Binding SaveDocumentAsCommand}" CommandParameter="{Binding SelectedDocument}"
                                       Icon="/Images/ButtonSaveLarge.png" />
                        <Fluent:Button Header="{Binding Strings.ButtonSaveSchemaAs}" 
                                       Command="{Binding SaveDocumentSchemaAsCommand}" CommandParameter="{Binding SelectedDocument}"
                                       Icon="/Images/ButtonSaveLarge.png" />
                        
                        <Fluent:Button Header="{Binding Strings.ButtonExit}" 
                                       Click="OnExitApplication" Icon="/Images/ButtonExitSmall.png" KeyTip="X" />
                    </Fluent:BackstageTabControl>
                </Fluent:Backstage>
            </Fluent:Ribbon.Menu>
            
            <Fluent:Ribbon.QuickAccessItems>
                <Fluent:QuickAccessMenuItem Icon="/Images/ButtonSaveLarge.png" 
                                            Command="{Binding SaveDocumentCommand}" CommandParameter="{Binding SelectedDocument}" />
                <Fluent:QuickAccessMenuItem Icon="/Images/ButtonUndoSmall.png" 
                                            Command="{Binding UndoCommand}" CommandParameter="{Binding SelectedDocument}" />
                <Fluent:QuickAccessMenuItem Icon="/Images/ButtonRedoSmall.png" 
                                            Command="{Binding RedoCommand}" CommandParameter="{Binding SelectedDocument}" />
            </Fluent:Ribbon.QuickAccessItems>
            
            <!--Tabs-->
            <Fluent:RibbonTabItem Header="Home" KeyTip="H" >
                <Fluent:RibbonGroupBox Header="{Binding Strings.RibbonGroupFile}">
                    <Fluent:Button Icon="/Images/ButtonCloseSmall.png" Padding="4,0,4,0"
                                   LargeIcon="/Images/ButtonCloseLarge.png"
                                   Header="{Binding Strings.ButtonClose}" 
                                   ToolTip="{Binding Strings.ShortcutCtrlW}"
                                   Command="{Binding CloseDocumentCommand}" CommandParameter="{Binding SelectedDocument}" />
                    <Fluent:Button Icon="/Images/ButtonValidateSmall.png" Padding="4,0,4,0"
                                   LargeIcon="/Images/ButtonValidateLarge.png"
                                   Header="{Binding Strings.ButtonValidate}" 
                                   ToolTip="{Binding Strings.ShortcutCtrlU}"
                                   Command="{Binding ValidateDocumentCommand}" CommandParameter="{Binding SelectedDocument}" />
                </Fluent:RibbonGroupBox>
                <Fluent:RibbonGroupBox Header="{Binding Strings.RibbonGroupMore}">
                    <Fluent:Button Icon="/Images/ButtonAboutSmall.png" Padding="4,0,4,0"
                                   LargeIcon="/Images/ButtonAboutLarge.png"
                                   Header="{Binding Strings.ButtonAbout}" Click="OnShowAboutWindow" />
                </Fluent:RibbonGroupBox>
            </Fluent:RibbonTabItem>
        </Fluent:Ribbon>
        
        <!-- documents -->
        <xcad:DockingManager DocumentsSource="{Binding Documents}" Grid.Row="1" Margin="0,8,0,0"
                             ActiveContent="{Binding SelectedDocument, Mode=TwoWay}"<commit_msg>Add Save Button in Tabs (#30)<commit_after>﻿<Fluent:RibbonWindow x:Class="VisualJsonEditor.Views.MainWindow"
                     xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent"
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:viewModels="clr-namespace:VisualJsonEditor.ViewModels"
                     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                     xmlns:converters="clr-namespace:MyToolkit.Converters;assembly=MyToolkit.Extended"
                     xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
                     xmlns:localization="clr-namespace:VisualJsonEditor.Localization"
                     xmlns:controls="clr-namespace:VisualJsonEditor.Controls"
                     xmlns:models="clr-namespace:VisualJsonEditor.Models"
                     mc:Ignorable="d" Title="{x:Static localization:Strings.HeaderMainWindow}" 
                     Height="600" Width="700" MinWidth="400" MinHeight="400" Background="LightGray"
                     WindowStartupLocation="CenterScreen" ContentRendered="RibbonWindow_ContentRendered">

    <Window.Resources>
        <viewModels:MainWindowModel x:Key="ViewModel" />
        <converters:VisibilityConverter x:Key="VisibilityConverter" />
        <converters:NotConverter x:Key="NotConverter" />
    </Window.Resources>

    <Grid DataContext="{StaticResource ViewModel}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <!-- ribbons -->
        <Fluent:Ribbon ShowQuickAccessToolBarAboveRibbon="True" 
                       IsQuickAccessToolBarVisible="True" x:Name="Ribbon"
                       AutomaticStateManagement="True" Grid.ColumnSpan="3">
            
            <!--Backstage-->
            <Fluent:Ribbon.Menu>
                <Fluent:Backstage>
                    <Fluent:BackstageTabControl>
                        <Fluent:BackstageTabItem Header="{Binding Strings.HeaderRecentDocuments}">
                            <Grid Margin="8,0,0,0">
                                <ScrollViewer VerticalScrollBarVisibility="Visible">
                                    <ItemsControl ItemsSource="{Binding Configuration.RecentFiles}" Margin="0,0,8,0">
                                        <ItemsControl.ItemTemplate>
                                            <DataTemplate>
                                                <Button Click="OnOpenDocument" HorizontalContentAlignment="Left" 
                                                        Background="Transparent" BorderThickness="0" Margin="0,8,0,0"
                                                        Command="{Binding OpenDocumentFromPathCommand, Source={StaticResource ViewModel}}"
                                                        CommandParameter="{Binding FilePath}">
                                                    <Button.Content>
                                                        <StackPanel Orientation="Horizontal" Margin="4">
                                                            <Image Source="/Images/ButtonCreateLarge.png" Margin="0,0,4,0" />
                                                            <StackPanel Margin="0,-3,0,0">
                                                                <TextBlock Text="{Binding FileName}" FontSize="16" />
                                                                <TextBlock Text="{Binding FilePath}" FontSize="10" />
                                                            </StackPanel>
                                                        </StackPanel>
                                                    </Button.Content>
                                                </Button>
                                            </DataTemplate>
                                        </ItemsControl.ItemTemplate>
                                    </ItemsControl>
                                </ScrollViewer>
                            </Grid>
                        </Fluent:BackstageTabItem>

                        <Fluent:Button Header="{Binding Strings.ButtonNew}" Width="200"
                                       Command="{Binding CreateDocumentCommand}" 
                                       ToolTip="{Binding Strings.ShortcutCtrlN}"
                                       Icon="/Images/ButtonCreateLarge.png" />

                        <Fluent:Button Header="{Binding Strings.ButtonOpen}" 
                                       Command="{Binding OpenDocumentCommand}" 
                                       ToolTip="{Binding Strings.ShortcutCtrlO}"
                                       Icon="/Images/ButtonOpenLarge.png" />

                        <Fluent:Button Header="{Binding Strings.ButtonSave}"  
                                       Command="{Binding SaveDocumentCommand}" CommandParameter="{Binding SelectedDocument}"
                                       ToolTip="{Binding Strings.ShortcutCtrlS}"
                                       Icon="/Images/ButtonSaveLarge.png" />
                        
                        <Fluent:Button Header="{Binding Strings.ButtonSaveAs}" 
                                       Command="{Binding SaveDocumentAsCommand}" CommandParameter="{Binding SelectedDocument}"
                                       Icon="/Images/ButtonSaveLarge.png" />
                        <Fluent:Button Header="{Binding Strings.ButtonSaveSchemaAs}" 
                                       Command="{Binding SaveDocumentSchemaAsCommand}" CommandParameter="{Binding SelectedDocument}"
                                       Icon="/Images/ButtonSaveLarge.png" />
                        
                        <Fluent:Button Header="{Binding Strings.ButtonExit}" 
                                       Click="OnExitApplication" Icon="/Images/ButtonExitSmall.png" KeyTip="X" />
                    </Fluent:BackstageTabControl>
                </Fluent:Backstage>
            </Fluent:Ribbon.Menu>
            
            <Fluent:Ribbon.QuickAccessItems>
                <Fluent:QuickAccessMenuItem Icon="/Images/ButtonSaveLarge.png" 
                                            Command="{Binding SaveDocumentCommand}" CommandParameter="{Binding SelectedDocument}" />
                <Fluent:QuickAccessMenuItem Icon="/Images/ButtonUndoSmall.png" 
                                            Command="{Binding UndoCommand}" CommandParameter="{Binding SelectedDocument}" />
                <Fluent:QuickAccessMenuItem Icon="/Images/ButtonRedoSmall.png" 
                                            Command="{Binding RedoCommand}" CommandParameter="{Binding SelectedDocument}" />
            </Fluent:Ribbon.QuickAccessItems>
            
            <!--Tabs-->
            <Fluent:RibbonTabItem Header="Home" KeyTip="H" >
                <Fluent:RibbonGroupBox Header="{Binding Strings.RibbonGroupFile}">
                    <Fluent:Button Icon="/Images/ButtonSaveSmall.png" Padding="4,0,4,0"
                                   LargeIcon="/Images/ButtonSaveLarge.png"
                                   Header="{Binding Strings.ButtonSave}" 
                                   ToolTip="{Binding Strings.ShortcutCtrlS}"
                                   Command="{Binding SaveDocumentCommand}" CommandParameter="{Binding SelectedDocument}" />
                    <Fluent:Button Icon="/Images/ButtonCloseSmall.png" Padding="4,0,4,0"
                                   LargeIcon="/Images/ButtonCloseLarge.png"
                                   Header="{Binding Strings.ButtonClose}" 
                                   ToolTip="{Binding Strings.ShortcutCtrlW}"
                                   Command="{Binding CloseDocumentCommand}" CommandParameter="{Binding SelectedDocument}" />
                    <Fluent:Button Icon="/Images/ButtonValidateSmall.png" Padding="4,0,4,0"
                                   LargeIcon="/Images/ButtonValidateLarge.png"
                                   Header="{Binding Strings.ButtonValidate}" 
                                   ToolTip="{Binding Strings.ShortcutCtrlU}"
                                   Command="{Binding ValidateDocumentCommand}" CommandParameter="{Binding SelectedDocument}" />
                </Fluent:RibbonGroupBox>
                <Fluent:RibbonGroupBox Header="{Binding Strings.RibbonGroupMore}">
                    <Fluent:Button Icon="/Images/ButtonAboutSmall.png" Padding="4,0,4,0"
                                   LargeIcon="/Images/ButtonAboutLarge.png"
                                   Header="{Binding Strings.ButtonAbout}" Click="OnShowAboutWindow" />
                </Fluent:RibbonGroupBox>
            </Fluent:RibbonTabItem>
        </Fluent:Ribbon>
        
        <!-- documents -->
        <xcad:DockingManager DocumentsSource="{Binding Documents}" Grid.Row="1" Margin="0,8,0,0"
                             ActiveContent="{Binding SelectedDocument, Mode=TwoWay}"
{'fraction_non_alphanumeric': 0.0988275633226413, 'fraction_numerical': 0.008627364229620618, 'mean_word_length': 1.3390247057301772, 'pattern_counts': {'":': 0, '<': 140, '<?xml version=': 0, '>': 138, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 24}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 136, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2546928', 'n_tokens_mistral': 4091, 'n_tokens_neox': 3684, 'n_words': 478}