<Window x:Class="DesktopMagic.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
        xmlns:busyIndicator="https://github.com/moh3ngolshani/BusyIndicator"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:local="clr-namespace:DesktopMagic"
        xmlns:dataContext="clr-namespace:DesktopMagic.DataContexts"
        d:DataContext="{d:DesignInstance Type=dataContext:MainWindowDataContext}"
        Closing="Window_Closing"
        Closed="Window_Closed"
        ShowInTaskbar="True"
        Icon="{StaticResource Icon}"
        Background="{DynamicResource MaterialDesignPaper}"
        FontFamily="{DynamicResource MaterialDesignFont}"
        Height="520"
        Width="570"
        MinHeight="520"
        MinWidth="570"
        WindowState="Minimized"
        Loaded="Window_Loaded">

    <busyIndicator:BusyMask x:Name="BusyIndicator" IsBusy="{Binding IsLoading}"  IndicatorType="Cogs"  BusyContent="Please wait..."  BusyContentMargin="0,20,0,0"  IsBusyAtStartup="False">
        <Grid>
            <TextBlock TextWrapping="Wrap" Text="0" VerticalAlignment="Top" FontFamily="Comic Sans MS" Loaded="TextBlock_Loaded" Foreground="Transparent" />
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="1*" />
                </Grid.RowDefinitions>
                <Grid Margin="{StaticResource DefaultMargin}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="1*" />
                        <ColumnDefinition Width="1*" />
                    </Grid.ColumnDefinitions>
                    <DockPanel Margin="0,0,2.5,0">
                        <Grid DockPanel.Dock="Top">
                            <Rectangle Grid.Row="1" Fill="#FFECECEC" Height="24" />
                            <CheckBox x:Name="EditCheckBox" VerticalAlignment="Center" Grid.Row="1" Content="{DynamicResource edit}" Click="EditCheckBox_Click" Foreground="Black" BorderBrush="#FF323232" Style="{StaticResource MaterialDesignDarkCheckBox}" IsChecked="True" />
                        </Grid>
                        <ScrollViewer Background="#FFBBBBBB" PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
                            <ItemsControl ItemsSource="{Binding Settings.CurrentLayout.Plugins}">
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <StackPanel />
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <CheckBox Click="PluginCheckBox_Click" Content="{Binding Value.Name}" Tag="{Binding Key}" IsChecked="{Binding Value.Enabled}"  Style="{StaticResource MaterialDesignDarkCheckBox}" />
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </ScrollViewer>
                    </DockPanel>

                    <DockPanel Grid.Column="1"  Margin="2.5,0,0,0">
                        <ComboBox x:Name="optionsComboBox" DisplayMemberPath="Name" DockPanel.Dock="Top" Height="24" SelectedIndex="0" SelectionChanged="OptionsComboBox_SelectionChanged" Background="#FFECECEC" Padding="4" VerticalAlignment="Center" />
                        <ScrollViewer Background="#FFBBBBBB">
                            <Grid>
                                <StackPanel x:Name="optionsPanel" Margin="3,3,3,0" HorizontalAlignment="Stretch" Visibility="Collapsed">
                                </StackPanel>
                            </Grid>
                        </ScrollViewer>
                    </DockPanel>
                </Grid>
                <Grid Grid.Row="1">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="110" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid Grid.Column="0" Margin="{StaticResource DefaultMargin}" HorizontalAlignment="Stretch">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <TextBlock Text="Display Font: " Grid.Column="0" Grid.Row="0" VerticalAlignment="Center"></TextBlock>
                        <ComboBox x:Name="fontComboBox" Grid.Column="1" Grid.Row="0" HorizontalAlignment="Stretch" VerticalAlignment="Top" SelectionChanged="FontComboBox_SelectionChanged" Margin="0,0,0,5" />

                        <TextBlock Text="Corner Radius: " Grid.Column="0" Grid.Row="1" VerticalAlignment="Center"></TextBlock>
                        <TextBox x:Name="cornerRadiusTextBox" Grid.Column="1" Grid.Row="1" TextChanged="CornerRadiusTextBox_TextChanged" materialDesign:HintAssist.Hint="Enter a number">
                            <materialDesign:TextFieldAssist.CharacterCounterStyle>
                                <Style TargetType="TextBlock" />
                            </materialDesign:TextFieldAssist.CharacterCounterStyle>
                        </TextBox>

                        <TextBlock Text="Margin: " Grid.Column="0" Grid.Row="3" VerticalAlignment="Center"></TextBlock>
                        <TextBox x:Name="marginTextBox" Grid.Column="1" Grid.Row="3" TextChanged="MarginTextBox_TextChanged" materialDesign:HintAssist.Hint="Enter a number">
                            <materialDesign:TextFieldAssist.CharacterCounterStyle>
                                <Style TargetType="TextBlock" />
                            </materialDesign:TextFieldAssist.CharacterCounterStyle>
                        </TextBox>
                    </Grid>
                    <StackPanel Grid.Column="1" Margin="{StaticResource DefaultMargin}" HorizontalAlignment="Stretch">
                        <DockPanel Margin="0,0,0,5">
                            <Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23"  Margin="0,0,5,0">
                                <Rectangle x:Name="primaryColorRechtangle" Fill="White" />
                            </Border>
                            <Button Content="Change Primary Color" Height="23" FontSize="12" FontWeight="Regular" Click="ChangePrimaryColorButton_Click" />
                        </DockPanel>
                        <DockPanel Margin="0,0,0,5">
                            <Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23"  Margin="0,0,5,0">
                                <Rectangle x:Name="secondaryColorRechtangle" Fill="White" />
                            </Border>
                            <Button Content="Change Secondary Color" Height="23" FontSize="12" FontWeight="Regular" Click="ChangeSecondaryColorButton_Click" />
                        </DockPanel>
                        <DockPanel>
                            <Border CornerRadius="1" BorderThickness="1.5" BorderBrush="Gray" Height="23" Width="23"  Margin="0,0,5,0">
                                <Rectangle x:Name="backgroundColorRechtangle" Fill="White" />
                            </Border>
                            <Button Content="Change Background Color" Height="23" FontSize="12" FontWeight="Regular" Click="ChangeBackgroundColorButton_Click" />
                        </DockPanel>
                    </StackPanel>
                    <Grid Grid.Row="1" Grid.ColumnSpan="2" VerticalAlignment="Bottom">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>

                        <Rectangle Fill="#FFC5C5C5" Stroke="#FFC5C5C5" Grid.ColumnSpan="3" />
                        <StackPanel Margin="{StaticResource DefaultMargin}" VerticalAlignment="Bottom">
                            <ComboBox x:Name="layoutsComboBox" ItemsSource="{Binding Settings.Layouts}" DisplayMemberPath="Name" SelectedValue="{Binding Settings.CurrentLayoutName}" SelectedValuePath="Name" HorizontalAlignment="Left" Margin="0,0,0,5" Width="170" Height="20" SelectionChanged="LayoutsComboBox_SelectionChanged" />
                            <Button x:Name="newLayoutButton" Margin="0,0,0,5" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="170" Click="NewLayoutButton_Click" FontWeight="Regular">
                                <StackPanel Orientation="Horizontal">
                                    <materialDesign:PackIcon Kind="Add" Margin="0 0 10 0" />
                                    <TextBlock Text="{DynamicResource newLayout}" />
                                </StackPanel>
                            </Button>
                            <Button x:Name="removeLayoutButton" HorizontalAlignment="Left"  VerticalAlignment="Bottom" Width="170" Click="RemoveLayoutButton_Click" FontWeight="Regular">
                                <StackPanel Orientation="Horizontal">
                                    <materialDesign:PackIcon Kind="DeleteOutline" Margin="0 0 10 0" />
                                    <TextBlock Text="{DynamicResource deleteLayout}" />
                                </StackPanel>
                            </Button>
                        </StackPanel>
                        <StackPanel Grid.Column="1" Margin="{StaticResource DefaultMargin}" VerticalAlignment="Bottom">
                            <Button x:Name="updatePluginsButton" Margin="0,0,0,5" HorizontalAlignment="Center" Width="170" Click="UpdatePluginsButton_Click" FontWeight="Regular">
                                <StackPanel Orientation="Horizontal">
                                    <materialDesign:PackIcon Kind="Reload" Margin="0 0 10 0" />
                                    <TextBlock Text="{DynamicResource updatePlugins}" />
                                </StackPanel>
                            </Button>
                            <Button x:Name="githubButton" HorizontalAlignment="Center" Width="170" Click="GitHubButton_Click"  FontWeight="Regular" Cursor="Hand">
                                <StackPanel Orientation="Horizontal">
                                    <materialDesign:PackIcon Kind="Github" Margin="0 0 10 0" />
                                    <TextBlock Text="GitHub" />
                                </StackPanel>
                            </Button>
                        </StackPanel>
                        <StackPanel Grid.Column="2" Margin="{StaticResource DefaultMargin}" VerticalAlignment="Bottom">
                            <Button x:Name="downloadPluginsButton" Margin="0,0,0,5" HorizontalAlignment="Right" Width="170" Click="PluginManagerButton_Click"  FontWeight="Regular" Cursor="Hand">
                                <StackPanel Orientation="Horizontal">
                                    <materialDesign:PackIcon Kind="ExtensionOutline" Margin="0 0 10 0" />
                                    <TextBlock Text="{DynamicResource pluginManager}" />
                                </StackPanel>
                            </Button>
                            <Button x:Name="openPluginsFolderButton" HorizontalAlignment="Right" Width="170" Click="OpenPluginsFolderButton_Click" FontWeight="Regular">
                                <StackPanel Orientation="Horizontal">
                                    <materialDesign:PackIcon Kind="FolderOutline" Margin="0 0 10 0" />
                                    <TextBlock Text="{DynamicResource pluginsFolder}" />
                                </StackPanel>
                            </Button>
                        </StackPanel>
                    </Grid>
                </Grid>
            </Grid>
        </Grid>
    </busyIndicator:BusyMask>
</Window>