using System.Text;
using Microsoft.UI.Xaml.Markup;
namespace XFEEDToolBox.Controls;
public sealed partial class GalaxyFilterPanel
{
private void InstallStaticCheckBoxTemplate()=>Resources[typeof(CheckBox)]=CreateStaticCheckBoxStyle();
internal static Style CreateStaticCheckBoxStyle()
{
// The platform AnimatedAccept glyph can retain its initial frame even
// after CheckBox has entered CheckedNormal. Keep native CheckBox input,
// accessibility and three-state semantics, with explicit static marks.
var states=new StringBuilder();
foreach(var value in new[]{"Unchecked","Checked","Indeterminate"})
foreach(var interaction in new[]{"Normal","PointerOver","Pressed","Disabled"})
{
var selected=value!="Unchecked";
states.Append($"""
<VisualState x:Name="{value}{interaction}"><Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Check" Storyboard.TargetProperty="Visibility"><DiscreteObjectKeyFrame KeyTime="0" Value="{(value=="Checked"?"Visible":"Collapsed")}"/></ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Mixed" Storyboard.TargetProperty="Visibility"><DiscreteObjectKeyFrame KeyTime="0" Value="{(value=="Indeterminate"?"Visible":"Collapsed")}"/></ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Box" Storyboard.TargetProperty="Fill"><DiscreteObjectKeyFrame KeyTime="0"><DiscreteObjectKeyFrame.Value><SolidColorBrush Color="{(selected?"#FFAE48":"#111923")}"/></DiscreteObjectKeyFrame.Value></DiscreteObjectKeyFrame></ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Box" Storyboard.TargetProperty="Stroke"><DiscreteObjectKeyFrame KeyTime="0"><DiscreteObjectKeyFrame.Value><SolidColorBrush Color="{(selected||interaction is "PointerOver" or "Pressed"?"#FFAE48":"#8493A3")}"/></DiscreteObjectKeyFrame.Value></DiscreteObjectKeyFrame></ObjectAnimationUsingKeyFrames>
<DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="{(interaction=="Disabled"?"0.4":"1")}" Duration="0"/>
</Storyboard></VisualState>
""");
}
return (Style)XamlReader.Load($$"""
<Style xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" TargetType="CheckBox">
<Setter Property="Foreground" Value="#E8EFF8"/>
<Setter Property="MinHeight" Value="32"/><Setter Property="Padding" Value="9,4,0,4"/>
<Setter Property="UseSystemFocusVisuals" Value="True"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template"><Setter.Value><ControlTemplate TargetType="CheckBox">
<Grid x:Name="Root" Background="Transparent">
<VisualStateManager.VisualStateGroups><VisualStateGroup x:Name="CombinedStates">{{states}}</VisualStateGroup></VisualStateManager.VisualStateGroups>
<Grid.ColumnDefinitions><ColumnDefinition Width="20"/><ColumnDefinition Width="*"/></Grid.ColumnDefinitions>
<Grid Width="20" Height="20" VerticalAlignment="Center">
<Rectangle x:Name="Box" RadiusX="4" RadiusY="4" StrokeThickness="1.2" Fill="#111923" Stroke="#8493A3"/>
<Path x:Name="Check" Data="M 4,10 L 8,14 L 16,6" Stroke="#101923" StrokeThickness="2" Visibility="Collapsed"/>
<Path x:Name="Mixed" Data="M 4,10 L 16,10" Stroke="#101923" StrokeThickness="2" Visibility="Collapsed"/>
</Grid>
<ContentPresenter Grid.Column="1" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Foreground="{TemplateBinding Foreground}" Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" TextWrapping="Wrap" AutomationProperties.AccessibilityView="Raw"/>
</Grid>
</ControlTemplate></Setter.Value></Setter>
</Style>
""");
}
}
using System.Text;
using Microsoft.UI.Xaml.Markup;
namespace XFEEDToolBox.Controls;
public sealed partial class GalaxyFilterPanel
{
private void InstallStaticCheckBoxTemplate()=>Resources[typeof(CheckBox)]=CreateStaticCheckBoxStyle();
internal static Style CreateStaticCheckBoxStyle()
{
// The platform AnimatedAccept glyph can retain its initial frame even
// after CheckBox has entered CheckedNormal. Keep native CheckBox input,
// accessibility and three-state semantics, with explicit static marks.
var states=new StringBuilder();
foreach(var value in new[]{"Unchecked","Checked","Indeterminate"})
foreach(var interaction in new[]{"Normal","PointerOver","Pressed","Disabled"})
{
var selected=value!="Unchecked";
states.Append($"""
<VisualState x:Name="{value}{interaction}"><Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Check" Storyboard.TargetProperty="Visibility"><DiscreteObjectKeyFrame KeyTime="0" Value="{(value=="Checked"?"Visible":"Collapsed")}"/></ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Mixed" Storyboard.TargetProperty="Visibility"><DiscreteObjectKeyFrame KeyTime="0" Value="{(value=="Indeterminate"?"Visible":"Collapsed")}"/></ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Box" Storyboard.TargetProperty="Fill"><DiscreteObjectKeyFrame KeyTime="0"><DiscreteObjectKeyFrame.Value><SolidColorBrush Color="{(selected?"#FFAE48":"#111923")}"/></DiscreteObjectKeyFrame.Value></DiscreteObjectKeyFrame></ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Box" Storyboard.TargetProperty="Stroke"><DiscreteObjectKeyFrame KeyTime="0"><DiscreteObjectKeyFrame.Value><SolidColorBrush Color="{(selected||interaction is "PointerOver" or "Pressed"?"#FFAE48":"#8493A3")}"/></DiscreteObjectKeyFrame.Value></DiscreteObjectKeyFrame></ObjectAnimationUsingKeyFrames>
<DoubleAnimation Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity" To="{(interaction=="Disabled"?"0.4":"1")}" Duration="0"/>
</Storyboard></VisualState>
""");
}
return (Style)XamlReader.Load($$"""
<Style xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" TargetType="CheckBox">
<Setter Property="Foreground" Value="#E8EFF8"/>
<Setter Property="MinHeight" Value="32"/><Setter Property="Padding" Value="9,4,0,4"/>
<Setter Property="UseSystemFocusVisuals" Value="True"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template"><Setter.Value><ControlTemplate TargetType="CheckBox">
<Grid x:Name="Root" Background="Transparent">
<VisualStateManager.VisualStateGroups><VisualStateGroup x:Name="CombinedStates">{{states}}</VisualStateGroup></VisualStateManager.VisualStateGroups>
<Grid.ColumnDefinitions><ColumnDefinition Width="20"/><ColumnDefinition Width="*"/></Grid.ColumnDefinitions>
<Grid Width="20" Height="20" VerticalAlignment="Center">
<Rectangle x:Name="Box" RadiusX="4" RadiusY="4" StrokeThickness="1.2" Fill="#111923" Stroke="#8493A3"/>
<Path x:Name="Check" Data="M 4,10 L 8,14 L 16,6" Stroke="#101923" StrokeThickness="2" Visibility="Collapsed"/>
<Path x:Name="Mixed" Data="M 4,10 L 16,10" Stroke="#101923" StrokeThickness="2" Visibility="Collapsed"/>
</Grid>
<ContentPresenter Grid.Column="1" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" Foreground="{TemplateBinding Foreground}" Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" TextWrapping="Wrap" AutomationProperties.AccessibilityView="Raw"/>
</Grid>
</ControlTemplate></Setter.Value></Setter>
</Style>
""");
}
}