misc: update XML namespace references and converters in XAML files. (#726)

This commit is contained in:
Zhang Dian
2026-02-06 23:09:13 +08:00
committed by GitHub
parent ddad2a80d5
commit f46bd16904
10 changed files with 48 additions and 128 deletions

View File

@@ -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">
<Style Selector="Popup LayoutTransformControl#PART_LayoutTransform">
<Setter Property="RenderTransformOrigin" Value="{Binding $parent[Popup].Placement, Converter={x:Static converters:PlacementToRenderTransformOriginConverter.Instance}}" />
<Setter Property="RenderTransformOrigin" Value="{Binding $parent[Popup].Placement, Converter={semi:PlacementToRenderTransformOriginConverter}}" />
</Style>
<Style Selector="Popup[IsOpen=True] LayoutTransformControl#PART_LayoutTransform">

View File

@@ -1,7 +1,7 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converter="clr-namespace:Semi.Avalonia.Converters">
xmlns:semi="https://irihi.tech/semi">
<Design.PreviewWith>
<StackPanel Spacing="20" Width="800" Height="800">
<StackPanel.Styles>
@@ -197,8 +197,8 @@
HorizontalAlignment="Center"
VerticalAlignment="Center"
ItemContainerTheme="{DynamicResource CarouselIndicatorDotListBoxItem}"
ItemsSource="{TemplateBinding ItemCount, Converter={x:Static converter:ItemConverter.ItemToObjectConverter}}"
IsVisible="{TemplateBinding ItemCount, Converter={x:Static converter:ItemConverter.ItemVisibleConverter}}"
ItemsSource="{TemplateBinding ItemCount, Converter={x:Static semi:ItemConverter.ItemToObjectConverter}}"
IsVisible="{TemplateBinding ItemCount, Converter={x:Static semi:ItemConverter.ItemVisibleConverter}}"
SelectedIndex="{TemplateBinding SelectedIndex, Mode=TwoWay}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
@@ -213,7 +213,7 @@
Theme="{DynamicResource CarouselButton}"
Margin="{DynamicResource CarouselButtonMargin}"
Foreground="{DynamicResource CarouselButtonForeground}"
IsVisible="{TemplateBinding ItemCount, Converter={x:Static converter:ItemConverter.ItemVisibleConverter}}"
IsVisible="{TemplateBinding ItemCount, Converter={x:Static semi:ItemConverter.ItemVisibleConverter}}"
Command="{Binding $parent[Carousel].Previous}" />
<Button
Grid.Row="0"
@@ -222,7 +222,7 @@
Theme="{DynamicResource CarouselButton}"
Margin="{DynamicResource CarouselButtonMargin}"
Foreground="{DynamicResource CarouselButtonForeground}"
IsVisible="{TemplateBinding ItemCount, Converter={x:Static converter:ItemConverter.ItemVisibleConverter}}"
IsVisible="{TemplateBinding ItemCount, Converter={x:Static semi:ItemConverter.ItemVisibleConverter}}"
Command="{Binding $parent[Carousel].Next}"
RenderTransform="rotate(180deg)" />
</Grid>

View File

@@ -1,9 +1,9 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:Semi.Avalonia.Converters"
xmlns:dialogs="clr-namespace:Avalonia.Dialogs;assembly=Avalonia.Dialogs"
xmlns:internal="clr-namespace:Avalonia.Dialogs.Internal;assembly=Avalonia.Dialogs"
xmlns:iri="https://irihi.tech/shared"
xmlns:dialogs="using:Avalonia.Dialogs"
xmlns:internal="using:Avalonia.Dialogs.Internal"
xmlns:cvt="using:Avalonia.Controls.Converters">
<Design.PreviewWith>
<Border
@@ -14,11 +14,11 @@
</Border>
</Design.PreviewWith>
<converters:KeyToPathConverter x:Key="Icons">
<iri:ResourceConverter x:Key="Icons">
<StreamGeometry x:Key="Icon_Folder">M19,20H4C2.89,20 2,19.1 2,18V6C2,4.89 2.89,4 4,4H10L12,6H19A2,2 0 0,1 21,8H21L4,8V18L6.14,10H23.21L20.93,18.5C20.7,19.37 19.92,20 19,20Z</StreamGeometry>
<StreamGeometry x:Key="Icon_File">M13,9H18.5L13,3.5V9M6,2H14L20,8V20A2,2 0 0,1 18,22H6C4.89,22 4,21.1 4,20V4C4,2.89 4.89,2 6,2M15,18V16H6V18H15M18,14V12H6V14H18Z</StreamGeometry>
<StreamGeometry x:Key="Icon_Volume">M6,2H18A2,2 0 0,1 20,4V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V4A2,2 0 0,1 6,2M12,4A6,6 0 0,0 6,10C6,13.31 8.69,16 12.1,16L11.22,13.77C10.95,13.29 11.11,12.68 11.59,12.4L12.45,11.9C12.93,11.63 13.54,11.79 13.82,12.27L15.74,14.69C17.12,13.59 18,11.9 18,10A6,6 0 0,0 12,4M12,9A1,1 0 0,1 13,10A1,1 0 0,1 12,11A1,1 0 0,1 11,10A1,1 0 0,1 12,9M7,18A1,1 0 0,0 6,19A1,1 0 0,0 7,20A1,1 0 0,0 8,19A1,1 0 0,0 7,18M12.09,13.27L14.58,19.58L17.17,18.08L12.95,12.77L12.09,13.27Z</StreamGeometry>
</converters:KeyToPathConverter>
</iri:ResourceConverter>
<ControlTheme x:Key="{x:Type dialogs:ManagedFileChooser}" TargetType="dialogs:ManagedFileChooser">
<Setter Property="Template">
<ControlTemplate x:DataType="internal:ManagedFileChooserViewModel" TargetType="dialogs:ManagedFileChooser">

View File

@@ -1,8 +1,8 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:Avalonia.Controls.Converters"
xmlns:semiConverters="clr-namespace:Semi.Avalonia.Converters">
xmlns:semi="https://irihi.tech/semi"
xmlns:converters="using:Avalonia.Controls.Converters">
<Design.PreviewWith>
<StackPanel Margin="20" Spacing="20">
<ProgressBar
@@ -338,8 +338,6 @@
</Style>
</ControlTheme>
<semiConverters:PositionToAngleConverter x:Key="AngleConverter" />
<ControlTheme x:Key="ProgressRing" TargetType="ProgressBar">
<Setter Property="Foreground" Value="{DynamicResource ProgressBarIndicatorBrush}" />
<Setter Property="Background" Value="{DynamicResource ProgressBarBackground}" />
@@ -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}}" />
<Arc
Name="IndeterminateIndicator"
Opacity="0"
@@ -376,8 +373,7 @@
StrokeJoin="Round"
StrokeLineCap="Round"
StrokeThickness="{Binding BorderThickness.Left, RelativeSource={RelativeSource TemplatedParent}}"
SweepAngle="{TemplateBinding Percentage,
Converter={StaticResource AngleConverter}}" />
SweepAngle="{TemplateBinding Percentage,Converter={semi:PositionToAngleConverter}}" />
<TextBlock
Name="PART_ProgressText"
HorizontalAlignment="Center"
@@ -443,4 +439,4 @@
</Style.Animations>
</Style>
</ControlTheme>
</ResourceDictionary>
</ResourceDictionary>

View File

@@ -1,7 +1,7 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:Semi.Avalonia.Converters">
xmlns:converters="using:Avalonia.Controls.Converters">
<Design.PreviewWith>
<StackPanel

View File

@@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using Avalonia;
using Avalonia.Data.Converters;
using Avalonia.Metadata;
namespace Semi.Avalonia.Converters;
public class KeyToPathConverter: IValueConverter
{
[Content]
public IDictionary<string, object?> Resources { get; } = new Dictionary<string, object?>();
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();
}
}

View File

@@ -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)
};
}
}

View File

@@ -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;
}
}

View File

@@ -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<object?> values, Type targetType, object? parameter, CultureInfo culture)
{
if (values.Count > 1 && values[0] is int level && values[1] is double indent)
{
return new Thickness(indent * level, 0, 0, 0);
}
return new Thickness(0);
}
}

View File

@@ -1,4 +1,5 @@
using Avalonia.Metadata;
[assembly:XmlnsPrefix("https://irihi.tech/semi", "semi")]
[assembly:XmlnsDefinition("https://irihi.tech/semi", "Semi.Avalonia")]
[assembly: XmlnsPrefix("https://irihi.tech/semi", "semi")]
[assembly: XmlnsDefinition("https://irihi.tech/semi", "Semi.Avalonia")]
[assembly: XmlnsDefinition("https://irihi.tech/semi", "Semi.Avalonia.Converters")]