<UserControl xmlns="https://github.com/avaloniaui"
             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"
             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
             x:Class="SourceGit.Views.CaptionButtonsMacOS"
             x:Name="ThisControl">
  <UserControl.Resources>
    <ResourceDictionary>
      <ResourceDictionary.ThemeDictionaries>
        <ResourceDictionary x:Key="Light">
          <Color x:Key="Color.MacOS.Close">#FFED6A5E</Color>
          <Color x:Key="Color.MacOS.CloseFG">#FF69110A</Color>
          <Color x:Key="Color.MacOS.ClosePressed">#FFB24F46</Color>
          <Color x:Key="Color.MacOS.ClosePressedFG">#FF2E0402</Color>
          <Color x:Key="Color.MacOS.Minimize">#FFF4BF4F</Color>
          <Color x:Key="Color.MacOS.MinimizeFG">#FF8F591D</Color>
          <Color x:Key="Color.MacOS.MinimizePressed">#FFB78F3A</Color>
          <Color x:Key="Color.MacOS.MinimizePressedFG">#FF522A0A</Color>
          <Color x:Key="Color.MacOS.Maximize">#FF61C554</Color>
          <Color x:Key="Color.MacOS.MaximizeFG">#FF296017</Color>
          <Color x:Key="Color.MacOS.MaximizePressed">#FF48943F</Color>
          <Color x:Key="Color.MacOS.MaximizePressedFG">#FF102F07</Color>
        </ResourceDictionary>
        <ResourceDictionary x:Key="Dark">
          <Color x:Key="Color.MacOS.Close">#FFED6A5E</Color>
          <Color x:Key="Color.MacOS.CloseFG">#FF8C1A10</Color>
          <Color x:Key="Color.MacOS.ClosePressed">#FFF09389</Color>
          <Color x:Key="Color.MacOS.ClosePressedFG">#FF69120A</Color>
          <Color x:Key="Color.MacOS.Minimize">#FFF4BF4F</Color>
          <Color x:Key="Color.MacOS.MinimizeFG">#FF8F591D</Color>
          <Color x:Key="Color.MacOS.MinimizePressed">#FFFBEB74</Color>
          <Color x:Key="Color.MacOS.MinimizePressedFG">#FF705F1B</Color>
          <Color x:Key="Color.MacOS.Maximize">#FF61C554</Color>
          <Color x:Key="Color.MacOS.MaximizeFG">#FF296017</Color>
          <Color x:Key="Color.MacOS.MaximizePressed">#FF86F37F</Color>
          <Color x:Key="Color.MacOS.MaximizePressedFG">#FF2C681A</Color>
        </ResourceDictionary>
      </ResourceDictionary.ThemeDictionaries>
      
      <SolidColorBrush x:Key="Brush.MacOS.Close" Color="{DynamicResource Color.MacOS.Close}"/>
      <SolidColorBrush x:Key="Brush.MacOS.CloseFG" Color="{DynamicResource Color.MacOS.CloseFG}"/>
      <SolidColorBrush x:Key="Brush.MacOS.ClosePressed" Color="{DynamicResource Color.MacOS.ClosePressed}"/>
      <SolidColorBrush x:Key="Brush.MacOS.ClosePressedFG" Color="{DynamicResource Color.MacOS.ClosePressedFG}"/>
      <SolidColorBrush x:Key="Brush.MacOS.Minimize" Color="{DynamicResource Color.MacOS.Minimize}"/>
      <SolidColorBrush x:Key="Brush.MacOS.MinimizeFG" Color="{DynamicResource Color.MacOS.MinimizeFG}"/>
      <SolidColorBrush x:Key="Brush.MacOS.MinimizePressed" Color="{DynamicResource Color.MacOS.MinimizePressed}"/>
      <SolidColorBrush x:Key="Brush.MacOS.MinimizePressedFG" Color="{DynamicResource Color.MacOS.MinimizePressedFG}"/>
      <SolidColorBrush x:Key="Brush.MacOS.Maximize" Color="{DynamicResource Color.MacOS.Maximize}"/>
      <SolidColorBrush x:Key="Brush.MacOS.MaximizeFG" Color="{DynamicResource Color.MacOS.MaximizeFG}"/>
      <SolidColorBrush x:Key="Brush.MacOS.MaximizePressed" Color="{DynamicResource Color.MacOS.MaximizePressed}"/>
      <SolidColorBrush x:Key="Brush.MacOS.MaximizePressedFG" Color="{DynamicResource Color.MacOS.MaximizePressedFG}"/>
    </ResourceDictionary>
  </UserControl.Resources>
  
  <UserControl.Styles>
    <Style Selector="Button">
      <Setter Property="Width" Value="24"/>
      <Setter Property="Height" Value="24"/>
      <Setter Property="Background" Value="Transparent"/>
      <Setter Property="BorderThickness" Value="0"/>
      <Setter Property="VerticalAlignment" Value="Center"/>
    </Style>
    <Style Selector="Button /template/ ContentPresenter#PART_ContentPresenter">
      <Setter Property="Background" Value="Transparent"/>
    </Style>
    <Style Selector="Button:pointerover /template/ ContentPresenter#PART_ContentPresenter">
      <Setter Property="Background" Value="Transparent"/>
    </Style>
    
    <Style Selector="Button>Grid>Ellipse">
      <Setter Property="Width" Value="14"/>
      <Setter Property="Height" Value="14"/>
      <Setter Property="VerticalAlignment" Value="Center"/>
      <Setter Property="StrokeThickness" Value=".5"/>
      <Setter Property="Stroke" Value="#40000000"/>
    </Style>
    
    <Style Selector="Button.close>Grid>Ellipse">
      <Setter Property="Fill" Value="{DynamicResource Brush.MacOS.Close}"/>
    </Style>
    <Style Selector="Button.minimize>Grid>Ellipse">
      <Setter Property="Fill" Value="{DynamicResource Brush.MacOS.Minimize}"/>
    </Style>
    <Style Selector="Button.maximize>Grid>Ellipse">
      <Setter Property="Fill" Value="{DynamicResource Brush.MacOS.Maximize}"/>
    </Style>
    <Style Selector="Button.close:pressed>Grid>Ellipse">
      <Setter Property="Fill" Value="{DynamicResource Brush.MacOS.ClosePressed}"/>
    </Style>
    <Style Selector="Button.minimize:pressed>Grid>Ellipse">
      <Setter Property="Fill" Value="{DynamicResource Brush.MacOS.MinimizePressed}"/>
    </Style>
    <Style Selector="Button.maximize:pressed>Grid>Ellipse">
      <Setter Property="Fill" Value="{DynamicResource Brush.MacOS.MaximizePressed}"/>
    </Style>
    
    <Style Selector="Button>Grid>Path">
      <Setter Property="Stretch" Value="Fill"/>
      <Setter Property="Fill" Value="Black"/>
      <Setter Property="IsVisible" Value="False"/>
      <Setter Property="VerticalAlignment" Value="Center"/>
    </Style>
    <Style Selector="Button.close>Grid>Path">
      <Setter Property="Width" Value="6"/>
      <Setter Property="Height" Value="6"/>
      <Setter Property="Fill" Value="{DynamicResource Brush.MacOS.CloseFG}"/>
      <Setter Property="Data" Value="{StaticResource Icons.MacOS.Close}"/>
    </Style>
    <Style Selector="Button.minimize>Grid>Path">
      <Setter Property="Width" Value="8"/>
      <Setter Property="Height" Value="2"/>
      <Setter Property="Fill" Value="{DynamicResource Brush.MacOS.MinimizeFG}"/>
      <Setter Property="Data" Value="{StaticResource Icons.MacOS.Minimize}"/>
    </Style>
    <Style Selector="Button.maximize>Grid>Path">
      <Setter Property="Width" Value="6"/>
      <Setter Property="Height" Value="6"/>
      <Setter Property="Fill" Value="{DynamicResource Brush.MacOS.MaximizeFG}"/>
      <Setter Property="Data" Value="{StaticResource Icons.MacOS.Maximize}"/>
    </Style>
    <Style Selector="Button.close:pressed>Grid>Path">
      <Setter Property="Fill" Value="{DynamicResource Brush.MacOS.ClosePressedFG}"/>
    </Style>
    <Style Selector="Button.minimize:pressed>Grid>Path">
      <Setter Property="Fill" Value="{DynamicResource Brush.MacOS.MinimizePressedFG}"/>
    </Style>
    <Style Selector="Button.maximize:pressed>Grid>Path">
      <Setter Property="Fill" Value="{DynamicResource Brush.MacOS.MaximizePressedFG}"/>
    </Style>
    
    <Style Selector="Grid.caption_button_box:pointerover>StackPanel>Button>Grid>Path">
      <Setter Property="IsVisible" Value="True"/>
    </Style>
  </UserControl.Styles>
  
  <Grid Classes="caption_button_box">
    <StackPanel Orientation="Horizontal" Margin="8,0,0,0">
      <Button Classes="close" Click="CloseWindow">
        <Grid>
          <Ellipse/>
          <Path/>
        </Grid>
      </Button>
      <Button Classes="minimize" Click="MinimizeWindow" IsVisible="{Binding !#ThisControl.IsCloseButtonOnly}">
        <Grid>
          <Ellipse/>
          <Path/>
        </Grid>
      </Button>
      <Button Classes="maximize" Click="MaximizeOrRestoreWindow" IsVisible="{Binding !#ThisControl.IsCloseButtonOnly}">
        <Grid>
          <Ellipse/>
          <Path/>
        </Grid>
      </Button>
    </StackPanel>
  </Grid>
</UserControl>
