diff --git a/src/Semi.Avalonia/Animations/SemiPopupAnimations.axaml b/src/Semi.Avalonia/Animations/SemiPopupAnimations.axaml
index 21c6443..d3b4034 100644
--- a/src/Semi.Avalonia/Animations/SemiPopupAnimations.axaml
+++ b/src/Semi.Avalonia/Animations/SemiPopupAnimations.axaml
@@ -2,9 +2,9 @@
x:Class="Semi.Avalonia.SemiPopupAnimations"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:converters="clr-namespace:Semi.Avalonia.Converters">
+ xmlns:semi="https://irihi.tech/semi">
-
-
@@ -365,8 +363,7 @@
StrokeJoin="Round"
StrokeLineCap="Round"
StrokeThickness="{Binding BorderThickness.Left, RelativeSource={RelativeSource TemplatedParent}}"
- SweepAngle="{TemplateBinding Percentage,
- Converter={StaticResource AngleConverter}}" />
+ SweepAngle="{TemplateBinding Percentage,Converter={semi:PositionToAngleConverter}}" />
+ SweepAngle="{TemplateBinding Percentage,Converter={semi:PositionToAngleConverter}}" />
-
+
\ No newline at end of file
diff --git a/src/Semi.Avalonia/Controls/TreeView.axaml b/src/Semi.Avalonia/Controls/TreeView.axaml
index 11488a8..c086004 100644
--- a/src/Semi.Avalonia/Controls/TreeView.axaml
+++ b/src/Semi.Avalonia/Controls/TreeView.axaml
@@ -1,7 +1,7 @@
+ xmlns:converters="using:Avalonia.Controls.Converters">
Resources { get; } = new Dictionary();
-
- public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
- {
- if(value is string s && Resources.TryGetValue(s, out var v))
- return v;
- return AvaloniaProperty.UnsetValue;
- }
-
- public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
-}
\ No newline at end of file
diff --git a/src/Semi.Avalonia/Converters/PlacementToRenderTransformOriginConverter.cs b/src/Semi.Avalonia/Converters/PlacementToRenderTransformOriginConverter.cs
index a370678..d93fc7c 100644
--- a/src/Semi.Avalonia/Converters/PlacementToRenderTransformOriginConverter.cs
+++ b/src/Semi.Avalonia/Converters/PlacementToRenderTransformOriginConverter.cs
@@ -2,56 +2,36 @@ using System;
using System.Globalization;
using Avalonia;
using Avalonia.Controls;
-using Avalonia.Data.Converters;
+using Irihi.Avalonia.Shared.Converters;
namespace Semi.Avalonia.Converters;
-public class PlacementToRenderTransformOriginConverter: IValueConverter
+public class PlacementToRenderTransformOriginConverter : MarkupValueConverter
{
- public static PlacementToRenderTransformOriginConverter Instance { get; } = new PlacementToRenderTransformOriginConverter();
- public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
+ public override object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is not PlacementMode p)
{
return new RelativePoint(0.5, 0.5, RelativeUnit.Relative);
}
- switch (p)
- {
- case PlacementMode.Bottom:
- return new RelativePoint(0.5, 0.0, RelativeUnit.Relative);
- case PlacementMode.Left:
- return new RelativePoint(1.0, 0.5, RelativeUnit.Relative);
- case PlacementMode.Right:
- return new RelativePoint(0.0, 0.5, RelativeUnit.Relative);
- case PlacementMode.Top:
- return new RelativePoint(0.5, 1.0, RelativeUnit.Relative);
- case PlacementMode.Pointer:
- return new RelativePoint(0.0, 0.0, RelativeUnit.Relative);
- case PlacementMode.Center:
- case PlacementMode.AnchorAndGravity:
- return new RelativePoint(0.5, 0.5, RelativeUnit.Relative);
- case PlacementMode.BottomEdgeAlignedLeft:
- return new RelativePoint(0.0, 0.0, RelativeUnit.Relative);
- case PlacementMode.BottomEdgeAlignedRight:
- return new RelativePoint(1.0, 0.0, RelativeUnit.Relative);
- case PlacementMode.LeftEdgeAlignedTop:
- return new RelativePoint(1.0, 1.0, RelativeUnit.Relative);
- case PlacementMode.LeftEdgeAlignedBottom:
- return new RelativePoint(1.0, 0.0, RelativeUnit.Relative);
- case PlacementMode.RightEdgeAlignedTop:
- return new RelativePoint(0.0, 1.0, RelativeUnit.Relative);
- case PlacementMode.RightEdgeAlignedBottom:
- return new RelativePoint(0.0, 0.0, RelativeUnit.Relative);
- case PlacementMode.TopEdgeAlignedLeft:
- return new RelativePoint(0.0, 1.0, RelativeUnit.Relative);
- case PlacementMode.TopEdgeAlignedRight:
- return new RelativePoint(1.0, 1.0, RelativeUnit.Relative);
- }
- return new RelativePoint(0.5, 0.5, RelativeUnit.Relative);
- }
- public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
+ return p switch
+ {
+ PlacementMode.Bottom => new RelativePoint(0.5, 0.0, RelativeUnit.Relative),
+ PlacementMode.Left => new RelativePoint(1.0, 0.5, RelativeUnit.Relative),
+ PlacementMode.Right => new RelativePoint(0.0, 0.5, RelativeUnit.Relative),
+ PlacementMode.Top => new RelativePoint(0.5, 1.0, RelativeUnit.Relative),
+ PlacementMode.Pointer => new RelativePoint(0.0, 0.0, RelativeUnit.Relative),
+ PlacementMode.Center or PlacementMode.AnchorAndGravity => new RelativePoint(0.5, 0.5, RelativeUnit.Relative),
+ PlacementMode.BottomEdgeAlignedLeft => new RelativePoint(0.0, 0.0, RelativeUnit.Relative),
+ PlacementMode.BottomEdgeAlignedRight => new RelativePoint(1.0, 0.0, RelativeUnit.Relative),
+ PlacementMode.LeftEdgeAlignedTop => new RelativePoint(1.0, 1.0, RelativeUnit.Relative),
+ PlacementMode.LeftEdgeAlignedBottom => new RelativePoint(1.0, 0.0, RelativeUnit.Relative),
+ PlacementMode.RightEdgeAlignedTop => new RelativePoint(0.0, 1.0, RelativeUnit.Relative),
+ PlacementMode.RightEdgeAlignedBottom => new RelativePoint(0.0, 0.0, RelativeUnit.Relative),
+ PlacementMode.TopEdgeAlignedLeft => new RelativePoint(0.0, 1.0, RelativeUnit.Relative),
+ PlacementMode.TopEdgeAlignedRight => new RelativePoint(1.0, 1.0, RelativeUnit.Relative),
+ _ => new RelativePoint(0.5, 0.5, RelativeUnit.Relative)
+ };
}
}
\ No newline at end of file
diff --git a/src/Semi.Avalonia/Converters/PositionToAngleConverter.cs b/src/Semi.Avalonia/Converters/PositionToAngleConverter.cs
index 1fd9f7a..a769907 100644
--- a/src/Semi.Avalonia/Converters/PositionToAngleConverter.cs
+++ b/src/Semi.Avalonia/Converters/PositionToAngleConverter.cs
@@ -1,27 +1,18 @@
using System;
using System.Globalization;
-using Avalonia.Data.Converters;
+using Irihi.Avalonia.Shared.Converters;
namespace Semi.Avalonia.Converters;
-public class PositionToAngleConverter: IValueConverter
+public class PositionToAngleConverter : MarkupValueConverter
{
- public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
+ public override object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
- if (value is double d)
- {
- return d * 3.6;
- }
-
- return 0;
+ return value is double d ? d * 3.6 : 0;
}
- public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
+ public override object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
- if (value is double d)
- {
- return d / 3.6;
- }
- return 0;
+ return value is double d ? d / 3.6 : 0;
}
}
\ No newline at end of file
diff --git a/src/Semi.Avalonia/Converters/TreeViewItemIndentConverter.cs b/src/Semi.Avalonia/Converters/TreeViewItemIndentConverter.cs
deleted file mode 100644
index e448131..0000000
--- a/src/Semi.Avalonia/Converters/TreeViewItemIndentConverter.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using Avalonia;
-using Avalonia.Data.Converters;
-
-namespace Semi.Avalonia.Converters;
-
-public class TreeViewItemIndentConverter : IMultiValueConverter
-{
- public static readonly TreeViewItemIndentConverter Instance = new();
-
- public object? Convert(IList