<UserControl
    x:Class="NixExampleWinUI.Views.SpectralPlot"
    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:helpers="using:NixExampleWinUI.Helpers" 
    xmlns:viewmodels="using:NixExampleWinUI.ViewModels" d:DataContext="{d:DesignInstance Type=viewmodels:SpectralPlotViewModel}"
    mc:Ignorable="d">

    <Control.Resources>
        <helpers:NullableBooleanToVisibilityConverter x:Key="NullableBooleanToVisibilityConverter"/>
    </Control.Resources>

    <Grid>
        <Rectangle x:Name="PlotBackground"
                   HorizontalAlignment="Stretch"
                   VerticalAlignment="Stretch"
                   RadiusX="6"
                   RadiusY="6"
                   Fill="{ThemeResource CardBackgroundFillColorDefault}"/>
        
        <UserControl xmlns:lvc="using:LiveChartsCore.SkiaSharpView.WinUI"
                     x:Name="SpectralPlotControl"
                     HorizontalAlignment="Stretch"
                     VerticalAlignment="Stretch"
                     Visibility="{x:Bind ViewModel.IsPlotVisible, Mode=OneWay, Converter={StaticResource NullableBooleanToVisibilityConverter}}">
            <lvc:CartesianChart Series="{x:Bind ViewModel.SpectralSeries, Mode=OneWay}"
                                XAxes="{x:Bind ViewModel.XAxes, Mode=OneWay}"
                                YAxes="{x:Bind ViewModel.YAxes, Mode=OneWay}"
                                EasingFunction="{x:Null}"
                                ZoomMode="Both"/>
        </UserControl>

        <TextBlock x:Name="EmptyPlotLabel"
                   Text="{x:Bind ViewModel.EmptyPlotLabel, Mode=OneWay}"
                   FontStyle="Italic"
                   FontSize="16"
                   Visibility="{x:Bind ViewModel.IsPlotEmpty, Mode=OneWay, Converter={StaticResource NullableBooleanToVisibilityConverter}}"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Center"/>

        <Button x:Name="ZoomOutButton"
                VerticalAlignment="Top"
                HorizontalAlignment="Left"
                Margin="12,12,12,12"
                Visibility="{x:Bind ViewModel.IsPlotVisible, Mode=OneWay, Converter={StaticResource NullableBooleanToVisibilityConverter}}"
                Click="ZoomOutButton_Click">
            <ToolTipService.ToolTip>
                <ToolTip x:Uid="SpectralPlot_ResetZoomButton_ToolTip"/>
            </ToolTipService.ToolTip>
            <Button.Content>
                <FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE71f;"/>
            </Button.Content>

        </Button>
    </Grid>
</UserControl>
