Add another example app

This commit is contained in:
Daniel Clark
2022-11-03 12:33:23 +00:00
parent 854d393b43
commit c601957dd9
38 changed files with 1070 additions and 30 deletions
@@ -1,6 +0,0 @@
namespace TheXamlGuy.UI.Avalonia.Controls
{
public class DataTemplateSelector : FluentAvalonia.UI.Controls.DataTemplateSelector
{
}
}
@@ -0,0 +1,66 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:TheXamlGuy.UI.Avalonia.Controls;assembly=TheXamlGuy.UI.Avalonia.Controls">
<Design.PreviewWith>
<Border Padding="20">
<ProgressRing />
</Border>
</Design.PreviewWith>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<StaticResource x:Key="ProgressRingForeground" ResourceKey="AccentFillColorDefaultBrush" />
<StaticResource x:Key="ProgressRingBackground" ResourceKey="SubtleFillColorSecondaryBrush" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<x:Double x:Key="ProgressRingStrokeThickness">4</x:Double>
<ControlTheme x:Key="{x:Type controls:ProgressRing}" TargetType="controls:ProgressRing">
<Setter Property="MinWidth" Value="16" />
<Setter Property="MinHeight" Value="16" />
<Setter Property="Height" Value="32" />
<Setter Property="Width" Value="32" />
<Setter Property="Template">
<ControlTemplate>
<Grid>
<Arc
StartAngle="0"
Stroke="{DynamicResource ProgressRingBackground}"
StrokeThickness="{DynamicResource ProgressRingStrokeThickness}"
SweepAngle="360" />
<Arc
x:Name="Arc"
StartAngle="0"
Stroke="{DynamicResource ProgressRingForeground}"
StrokeLineCap="Round"
StrokeThickness="{DynamicResource ProgressRingStrokeThickness}" />
</Grid>
</ControlTemplate>
</Setter>
<Style Selector="^:indeterminate">
<Style Selector="^ /template/ Arc#Arc">
<Setter Property="StartAngle" Value="0" />
<Setter Property="SweepAngle" Value="90" />
<Style.Animations>
<Animation
Easing="SplineEasing"
FillMode="Both"
IterationCount="Infinite"
Duration="0:0:.75">
<KeyFrame Cue="0%">
<Setter Property="StartAngle" Value="0" />
<Setter Property="SweepAngle" Value="180" />
</KeyFrame>
<KeyFrame Cue="50%">
<Setter Property="StartAngle" Value="270" />
<Setter Property="SweepAngle" Value="22.5" />
</KeyFrame>
<KeyFrame Cue="100%">
<Setter Property="StartAngle" Value="360" />
<Setter Property="SweepAngle" Value="180" />
</KeyFrame>
</Animation>
</Style.Animations>
</Style>
</Style>
</ControlTheme>
</ResourceDictionary>
@@ -0,0 +1,37 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
namespace TheXamlGuy.UI.Avalonia.Controls
{
public class ProgressRing : RangeBase
{
public static readonly StyledProperty<bool> IsIndeterminateProperty =
AvaloniaProperty.Register<ProgressRing, bool>(nameof(IsIndeterminate), true);
public bool IsIndeterminate
{
get => GetValue(IsIndeterminateProperty);
set => SetValue(IsIndeterminateProperty, value);
}
protected override void OnApplyTemplate(TemplateAppliedEventArgs args)
{
UpdateIsIndeterminate();
}
private void UpdateIsIndeterminate()
{
PseudoClasses.Set(":indeterminate", IsIndeterminate);
}
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);
if (change.Property == IsIndeterminateProperty)
{
UpdateIsIndeterminate();
}
}
}
}
@@ -0,0 +1,9 @@
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Styles.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="avares://TheXamlGuy.UI.Avalonia.Controls/ProgressRing/ProgressRing.axaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Styles.Resources>
</Styles>
+14 -5
View File
@@ -1,14 +1,23 @@
using FluentAvalonia.Styling;
using Avalonia.Markup.Xaml;
using Avalonia.Styling;
using FluentAvalonia.Styling;
using FluentAvalonia.UI.Controls.Primitives;
namespace TheXamlGuy.UI.Avalonia;
public class XamlControlsResources : FluentAvaloniaTheme
{
public XamlControlsResources(Uri baseUri) : base(baseUri)
{
}
public XamlControlsResources(IServiceProvider serviceProvider) : base(serviceProvider)
{
}
//private void XamlControlsResources_OwnerChanged(object? sender, EventArgs e)
//{
// Styles styles = (Styles)AvaloniaXamlLoader.Load(new Uri($"avares://TheXamlGuy.UI.Avalonia/Themes/ControlResources.axaml"));
// foreach (var style in styles)
// {
// style.add
// }
//}
}