Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
wieslawsoltes committed Jan 26, 2024
1 parent 2daaa02 commit 29833b2
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 63 deletions.
4 changes: 2 additions & 2 deletions samples/AvaloniaSvgSkiaStylingSample/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
VerticalAlignment="Center">
<Panel.Styles>
<Style Selector="Panel:pointerover Svg">
<Setter Property="(Svg.Style)" Value=".Black { fill: #FF0000; }" />
<Setter Property="(Svg.Css)" Value=".Black { fill: #FF0000; }" />
</Style>
</Panel.Styles>
<Viewbox Stretch="Uniform">
Expand All @@ -51,7 +51,7 @@
Name="SvgImageButton">
<Button.Styles>
<Style Selector="Button:pointerover">
<Setter Property="(Svg.Style)" Value=".Black { fill: #FF0000; }" />
<Setter Property="(Svg.Css)" Value=".Black { fill: #FF0000; }" />
</Style>
</Button.Styles>
</Button>
Expand Down
4 changes: 2 additions & 2 deletions samples/AvaloniaSvgSkiaStylingSample/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public MainWindow()

private void ApplySvgStyleButtonClick(object sender, EventArgs e)
{
SvgControl.SetCurrentValue(Avalonia.Svg.Skia.Svg.StyleProperty, ".Black { fill: #AAAAFF; }");
SvgControl.SetCurrentValue(Avalonia.Svg.Skia.Svg.CssProperty, ".Black { fill: #AAAAFF; }");
}

private void ApplySvgImageStyleButtonClick(object sender, EventArgs e)
{
SvgImageButton.SetCurrentValue(Avalonia.Svg.Skia.Svg.StyleProperty, ".Black { fill: #AAAAFF; }");
SvgImageButton.SetCurrentValue(Avalonia.Svg.Skia.Svg.CssProperty, ".Black { fill: #AAAAFF; }");
}
}
56 changes: 28 additions & 28 deletions src/Avalonia.Svg.Skia/Svg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ public class Svg : Control
private Dictionary<string, SKSvg>? _cache;

/// <summary>
/// Defines the <see cref="Style"/> property.
/// Defines the <see cref="Css"/> property.
/// </summary>
public static readonly AttachedProperty<string?> StyleProperty =
AvaloniaProperty.RegisterAttached<Svg, AvaloniaObject, string?>("Style", inherits: true);
public static readonly AttachedProperty<string?> CssProperty =
AvaloniaProperty.RegisterAttached<Svg, AvaloniaObject, string?>("Css", inherits: true);

/// <summary>
/// Defines the <see cref="CurrentStyle"/> property.
/// Defines the <see cref="CurrentCss"/> property.
/// </summary>
public static readonly AttachedProperty<string?> CurrentStyleProperty =
AvaloniaProperty.RegisterAttached<Svg, AvaloniaObject, string?>("CurrentStyle", inherits: true);
public static readonly AttachedProperty<string?> CurrentCssProperty =
AvaloniaProperty.RegisterAttached<Svg, AvaloniaObject, string?>("CurrentCss", inherits: true);

/// <summary>
/// Defines the <see cref="Path"/> property.
Expand Down Expand Up @@ -132,31 +132,31 @@ static Svg()
AffectsRender<Svg>(PathProperty, SourceProperty, StretchProperty, StretchDirectionProperty);
AffectsMeasure<Svg>(PathProperty, SourceProperty, StretchProperty, StretchDirectionProperty);

StyleProperty.Changed.AddClassHandler<Control>(OnStylePropertyAttachedPropertyChanged);
CurrentStyleProperty.Changed.AddClassHandler<Control>(OnStylePropertyAttachedPropertyChanged);
CssProperty.Changed.AddClassHandler<Control>(OnCssPropertyAttachedPropertyChanged);
CurrentCssProperty.Changed.AddClassHandler<Control>(OnCssPropertyAttachedPropertyChanged);
}

public static string? GetStyle(AvaloniaObject element)
public static string? GetCss(AvaloniaObject element)
{
return element.GetValue(StyleProperty);
return element.GetValue(CssProperty);
}

public static void SetStyle(AvaloniaObject element, string? value)
public static void SetCss(AvaloniaObject element, string? value)
{
element.SetValue(StyleProperty, value);
element.SetValue(CssProperty, value);
}

public static string? GetCurrentStyle(AvaloniaObject element)
public static string? GetCurrentCss(AvaloniaObject element)
{
return element.GetValue(CurrentStyleProperty);
return element.GetValue(CurrentCssProperty);
}

public static void SetCurrentStyle(AvaloniaObject element, string? value)
public static void SetCurrentCss(AvaloniaObject element, string? value)
{
element.SetValue(CurrentStyleProperty, value);
element.SetValue(CurrentCssProperty, value);
}

private static void OnStylePropertyAttachedPropertyChanged(AvaloniaObject d, AvaloniaPropertyChangedEventArgs e)
private static void OnCssPropertyAttachedPropertyChanged(AvaloniaObject d, AvaloniaPropertyChangedEventArgs e)
{
if (d is Control control)
{
Expand Down Expand Up @@ -259,29 +259,29 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
if (change.Property == PathProperty)
{
var path = change.GetNewValue<string?>();
var style = GetStyle(this);
var currentStyle = GetCurrentStyle(this);
var parameters = new SvgParameters(null, string.Concat(style, ' ', currentStyle));
var css = GetCss(this);
var currentCss = GetCurrentCss(this);
var parameters = new SvgParameters(null, string.Concat(css, ' ', currentCss));
LoadFromPath(path, parameters);
InvalidateVisual();
}

if (change.Property == StyleProperty)
if (change.Property == CssProperty)
{
var path = Path;
var style = change.GetNewValue<string?>();
var currentStyle = GetCurrentStyle(this);
var parameters = new SvgParameters(null, string.Concat(style, ' ', currentStyle));
var css = change.GetNewValue<string?>();
var currentCss = GetCurrentCss(this);
var parameters = new SvgParameters(null, string.Concat(css, ' ', currentCss));
LoadFromPath(path, parameters);
InvalidateVisual();
}

if (change.Property == CurrentStyleProperty)
if (change.Property == CurrentCssProperty)
{
var path = Path;
var style = GetStyle(this);
var currentStyle = change.GetNewValue<string?>();
var parameters = new SvgParameters(null, string.Concat(style, ' ', currentStyle));
var css = GetCss(this);
var currentCss = change.GetNewValue<string?>();
var parameters = new SvgParameters(null, string.Concat(css, ' ', currentCss));
LoadFromPath(path, parameters);
InvalidateVisual();
}
Expand Down
40 changes: 20 additions & 20 deletions src/Avalonia.Svg.Skia/SvgImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ public class SvgImage : AvaloniaObject, IImage
AvaloniaProperty.Register<SvgImage, SvgSource?>(nameof(Source));

/// <summary>
/// Defines the <see cref="Style"/> property.
/// Defines the <see cref="Css"/> property.
/// </summary>
public static readonly StyledProperty<string?> StyleProperty =
AvaloniaProperty.Register<SvgImage, string?>(nameof(Style));
public static readonly StyledProperty<string?> CssProperty =
AvaloniaProperty.Register<SvgImage, string?>(nameof(Css));

/// <summary>
/// Defines the <see cref="CurrentStyle"/> property.
/// Defines the <see cref="CurrentCss"/> property.
/// </summary>
public static readonly StyledProperty<string?> CurrentStyleProperty =
AvaloniaProperty.Register<SvgImage, string?>(nameof(CurrentStyle));
public static readonly StyledProperty<string?> CurrentCssProperty =
AvaloniaProperty.Register<SvgImage, string?>(nameof(CurrentCss));

/// <summary>
/// Gets or sets the <see cref="SvgSource"/> content.
Expand All @@ -40,19 +40,19 @@ public SvgSource? Source
/// <summary>
/// Gets or sets the <see cref="SvgSource"/> style.
/// </summary>
public string? Style
public string? Css
{
get => GetValue(StyleProperty);
set => SetValue(StyleProperty, value);
get => GetValue(CssProperty);
set => SetValue(CssProperty, value);
}

/// <summary>
/// Gets or sets the <see cref="SvgSource"/> current style.
/// </summary>
public string? CurrentStyle
public string? CurrentCss
{
get => GetValue(CurrentStyleProperty);
set => SetValue(CurrentStyleProperty, value);
get => GetValue(CurrentCssProperty);
set => SetValue(CurrentCssProperty, value);
}

/// <inheritdoc/>
Expand Down Expand Up @@ -101,23 +101,23 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
// TODO: Invalidate IImage
}

if (change.Property == StyleProperty)
if (change.Property == CssProperty)
{
var style = string.Concat(change.GetNewValue<string>(), ' ', CurrentStyle);
var css = string.Concat(change.GetNewValue<string>(), ' ', CurrentCss);

if (Source?.Style != style)
if (Source?.Css != css)
{
Source?.ReLoad(new SvgParameters(null, style));
Source?.ReLoad(new SvgParameters(null, css));
}
}

if (change.Property == CurrentStyleProperty)
if (change.Property == CurrentCssProperty)
{
var style = string.Concat(Style, ' ', change.GetNewValue<string>());
var css = string.Concat(Css, ' ', change.GetNewValue<string>());

if (Source?.Style != style)
if (Source?.Css != css)
{
Source?.ReLoad(new SvgParameters(null, style));
Source?.ReLoad(new SvgParameters(null, css));
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/Avalonia.Svg.Skia/SvgImageExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ private static IImage CreateImage(string path, Uri baseUri, Control? targetContr
{
if (targetControl is not null)
{
var style = Svg.GetStyle(targetControl);
var currentStyle = Svg.GetCurrentStyle(targetControl);
var css = Svg.GetCss(targetControl);
var currentCss = Svg.GetCurrentCss(targetControl);
var source = SvgSource.Load<SvgSource>(
path,
baseUri,
new SvgParameters(null, string.Concat(style, ' ', currentStyle)));
new SvgParameters(null, string.Concat(css, ' ', currentCss)));

return CreateSvgImage(source, targetControl);
}
Expand All @@ -80,11 +80,11 @@ private static SvgImage CreateSvgImage(SvgSource? source, Control? targetControl
return result;
}

var styleBinding = targetControl.GetObservable(Svg.StyleProperty).ToBinding();
var currentStyleBinding = targetControl.GetObservable(Svg.CurrentStyleProperty).ToBinding();
var styleBinding = targetControl.GetObservable(Svg.CssProperty).ToBinding();
var currentStyleBinding = targetControl.GetObservable(Svg.CurrentCssProperty).ToBinding();

result.Bind(SvgImage.StyleProperty, styleBinding);
result.Bind(SvgImage.CurrentStyleProperty, currentStyleBinding);
result.Bind(SvgImage.CssProperty, styleBinding);
result.Bind(SvgImage.CurrentCssProperty, currentStyleBinding);

return result;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Svg.Model/SvgExtensions.IO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ internal static SvgDocument LoadSvgz(System.IO.Stream stream, Uri baseUri)

public static SvgDocument? OpenSvg(string path, SvgParameters? parameters = null)
{
return SvgDocument.Open<SvgDocument>(path, new SvgOptions(parameters?.Entities, parameters?.Style));
return SvgDocument.Open<SvgDocument>(path, new SvgOptions(parameters?.Entities, parameters?.Css));
}

public static SvgDocument? OpenSvgz(string path, SvgParameters? parameters = null)
Expand Down Expand Up @@ -303,7 +303,7 @@ internal static SvgDocument LoadSvgz(System.IO.Stream stream, Uri baseUri)

public static SvgDocument? Open(System.IO.Stream stream, SvgParameters? parameters = null)
{
return SvgDocument.Open<SvgDocument>(stream, new SvgOptions(parameters?.Entities, parameters?.Style));
return SvgDocument.Open<SvgDocument>(stream, new SvgOptions(parameters?.Entities, parameters?.Css));
}

public static SvgDocument? FromSvg(string svg)
Expand Down
2 changes: 1 addition & 1 deletion src/Svg.Model/SvgParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

namespace Svg.Model;

public readonly record struct SvgParameters(Dictionary<string, string>? Entities, string? Style);
public readonly record struct SvgParameters(Dictionary<string, string>? Entities, string? Css);
2 changes: 1 addition & 1 deletion src/Svg.Skia/SKSvg.Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static void Draw(SkiaSharp.SKCanvas skCanvas, string path, SkiaModel skia

public SkiaSharp.SKPicture? Picture { get; private set; }

public string? Style => _originalParameters?.Style;
public string? Css => _originalParameters?.Css;

public Dictionary<string, string>? Entities => _originalParameters?.Entities;

Expand Down

0 comments on commit 29833b2

Please sign in to comment.