Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
wieslawsoltes committed Dec 21, 2021
1 parent 18aedf9 commit a4e4b8b
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 34 deletions.
2 changes: 1 addition & 1 deletion build/Avalonia.Desktop.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="0.10.11-rc.2" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.11" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion build/Avalonia.Diagnostics.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.11-rc.2" />
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.11" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion build/Avalonia.ReactiveUI.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.11-rc.2" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.11" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion build/Avalonia.Skia.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="Avalonia.Skia" Version="0.10.11-rc.2" />
<PackageReference Include="Avalonia.Skia" Version="0.10.11" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion build/Avalonia.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.11-rc.2" />
<PackageReference Include="Avalonia" Version="0.10.11" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion build/Base.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VersionPrefix>0.5.11</VersionPrefix>
<VersionSuffix>rc.2</VersionSuffix>
<VersionSuffix></VersionSuffix>
<AvaloniaVersionPrefix>0.10.11</AvaloniaVersionPrefix>
<AvaloniaVersionSuffix>$(VersionSuffix)</AvaloniaVersionSuffix>
<Authors>Wiesław Šoltés</Authors>
Expand Down
2 changes: 1 addition & 1 deletion build/HarfBuzzSharp.NativeAssets.Linux.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2-preview.171" />
<PackageReference Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2-preview.178" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion build/SkiaSharp.HarfBuzz.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="SkiaSharp.HarfBuzz" Version="2.88.0-preview.171" />
<PackageReference Include="SkiaSharp.HarfBuzz" Version="2.88.0-preview.178" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion build/SkiaSharp.Linux.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.0-preview.171" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.0-preview.178" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion build/SkiaSharp.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="SkiaSharp" Version="2.88.0-preview.171" />
<PackageReference Include="SkiaSharp" Version="2.88.0-preview.178" />
</ItemGroup>
</Project>
10 changes: 5 additions & 5 deletions samples/TestApp/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public MainWindowViewModel()

LoadConfigurationCommand = ReactiveCommand.CreateFromTask(async () =>
{
var window = (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow;
var window = (Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow;
if (window is null)
{
return;
Expand All @@ -106,7 +106,7 @@ public MainWindowViewModel()

SaveConfigurationCommand = ReactiveCommand.CreateFromTask(async () =>
{
var window = (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow;
var window = (Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow;
if (window is null)
{
return;
Expand All @@ -130,7 +130,7 @@ public MainWindowViewModel()

AddItemCommand = ReactiveCommand.CreateFromTask(async () =>
{
var window = (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow;
var window = (Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow;
if (window is null)
{
return;
Expand Down Expand Up @@ -162,7 +162,7 @@ await Dispatcher.UIThread.InvokeAsync(() =>
{
try
{
Application.Current.Clipboard.SetTextAsync(code);
Application.Current?.Clipboard?.SetTextAsync(code);
}
catch
{
Expand All @@ -173,7 +173,7 @@ await Dispatcher.UIThread.InvokeAsync(() =>

ExportCommand = ReactiveCommand.CreateFromTask<Avalonia.Svg.Skia.Svg>(async svg =>
{
var window = (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow;
var window = (Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow;
if (window is null)
{
return;
Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.Svg.Skia/Svg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private void Load(string? path)
{
_svg = SvgSource.Load<SvgSource>(path, _baseUri);

if (_enableCache && _cache is { })
if (_enableCache && _cache is { } && _svg is { })
{
_cache[path] = _svg;
}
Expand Down Expand Up @@ -283,4 +283,4 @@ private void DisposeCache()
/// </summary>
/// <param name="e">The event args.</param>
protected void RaiseInvalidated(EventArgs e) => Invalidated?.Invoke(this, e);
}
}
10 changes: 7 additions & 3 deletions src/Avalonia.Svg.Skia/SvgSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class SvgSource : SKSvg
/// <param name="path">The path to file or resource.</param>
/// <param name="baseUri">The base uri.</param>
/// <returns>The svg source.</returns>
public static T Load<T>(string path, Uri? baseUri) where T : SKSvg, new()
public static T? Load<T>(string path, Uri? baseUri) where T : SKSvg, new()
{
var uri = path.StartsWith("/") ? new Uri(path, UriKind.Relative) : new Uri(path, UriKind.RelativeOrAbsolute);
if (uri.IsAbsoluteUri && uri.IsFile)
Expand All @@ -29,10 +29,14 @@ public class SvgSource : SKSvg
else
{
var loader = AvaloniaLocator.Current.GetService<IAssetLoader>();
var stream = loader.Open(uri, baseUri);
var stream = loader?.Open(uri, baseUri);
if (stream is null)
{
return default;
}
var source = new T();
source.Load(stream);
return source;
}
}
}
}
2 changes: 1 addition & 1 deletion src/Avalonia.Svg.Skia/SvgSourceTypeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext? context, Type source
}

/// <inheritdoc/>
public override object ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
{
var path = (string)value;
var baseUri = context?.GetContextBaseUri();
Expand Down
16 changes: 12 additions & 4 deletions src/Avalonia.Svg/AvaloniaModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Avalonia.Svg;

public static class AvaloniaModelExtensions
{
private static AP.IPlatformRenderInterface Factory => A.AvaloniaLocator.Current.GetService<AP.IPlatformRenderInterface>();
private static AP.IPlatformRenderInterface? Factory => A.AvaloniaLocator.Current?.GetService<AP.IPlatformRenderInterface>();

public static Point Transform(this Matrix m, Point point)
{
Expand Down Expand Up @@ -522,7 +522,11 @@ public static AM.SweepDirection ToSweepDirection(this SKPathDirection pathDirect

public static AP.IGeometryImpl? ToGeometry(this IList<SKPoint> points, bool isFilled)
{
var geometry = Factory.CreateStreamGeometry();
var geometry = Factory?.CreateStreamGeometry();
if (geometry is null)
{
return null;
}

using var context = geometry.Open();

Expand All @@ -548,7 +552,11 @@ public static AM.SweepDirection ToSweepDirection(this SKPathDirection pathDirect
return null;
}

var streamGeometry = Factory.CreateStreamGeometry();
var streamGeometry = Factory?.CreateStreamGeometry();
if (streamGeometry is null)
{
return null;
}

using var streamGeometryContext = streamGeometry.Open();

Expand Down Expand Up @@ -709,4 +717,4 @@ public static AM.SweepDirection ToSweepDirection(this SKPathDirection pathDirect
// TODO: clipPath
return null;
}
}
}
12 changes: 6 additions & 6 deletions src/Avalonia.Svg/AvaloniaPicture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Avalonia.Svg;

public sealed class AvaloniaPicture : IDisposable
{
private static AP.IPlatformRenderInterface Factory => A.AvaloniaLocator.Current.GetService<AP.IPlatformRenderInterface>();
private static AP.IPlatformRenderInterface? Factory => A.AvaloniaLocator.Current?.GetService<AP.IPlatformRenderInterface>();

private readonly List<DrawCommand>? _commands;

Expand All @@ -23,9 +23,9 @@ private AvaloniaPicture()
_commands = new List<DrawCommand>();
}

private static void Record(CanvasCommand canvasCommand, AvaloniaPicture avaloniaPicture)
private static void Record(CanvasCommand canvasCommand, AvaloniaPicture? avaloniaPicture)
{
if (avaloniaPicture is null || avaloniaPicture._commands is null)
if (avaloniaPicture?._commands is null)
{
return;
}
Expand Down Expand Up @@ -131,7 +131,7 @@ private static void Record(CanvasCommand canvasCommand, AvaloniaPicture avalonia
case AddOvalPathCommand addOvalPathCommand:
{
var rect = addOvalPathCommand.Rect.ToRect();
var ellipseGeometry = Factory.CreateEllipseGeometry(rect);
var ellipseGeometry = Factory?.CreateEllipseGeometry(rect);
avaloniaPicture._commands.Add(new GeometryDrawCommand(brush, pen, ellipseGeometry));
success = true;
}
Expand All @@ -143,7 +143,7 @@ private static void Record(CanvasCommand canvasCommand, AvaloniaPicture avalonia
var y = addCirclePathCommand.Y;
var radius = addCirclePathCommand.Radius;
var rect = new A.Rect(x - radius, y - radius, radius + radius, radius + radius);
var ellipseGeometry = Factory.CreateEllipseGeometry(rect);
var ellipseGeometry = Factory?.CreateEllipseGeometry(rect);
avaloniaPicture._commands.Add(new GeometryDrawCommand(brush, pen, ellipseGeometry));
success = true;
}
Expand Down Expand Up @@ -369,4 +369,4 @@ public void Dispose()
command.Dispose();
}
}
}
}
8 changes: 6 additions & 2 deletions src/Avalonia.Svg/SvgSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ public class SvgSource
else
{
var loader = AvaloniaLocator.Current.GetService<IAssetLoader>();
var stream = loader.Open(uri, baseUri);
var stream = loader?.Open(uri, baseUri);
if (stream is null)
{
return default;
}
var document = SM.SvgExtensions.Open(stream);
if (document is { })
{
Expand All @@ -58,4 +62,4 @@ public static SvgSource Load(string path, Uri? baseUri)
{
return new() { Picture = LoadPicture(path, baseUri) };
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.0.0-4.final" PrivateAssets="all" />
<PackageReference Include="Fizzler" Version="1.2.0" GeneratePathProperty="true" PrivateAssets="all" />
<PackageReference Include="System.Drawing.Common" Version="5.0.0" GeneratePathProperty="true" PrivateAssets="all" />
<PackageReference Include="SkiaSharp" Version="2.88.0-preview.171" GeneratePathProperty="true" />
<PackageReference Include="SkiaSharp" Version="2.88.0-preview.178" GeneratePathProperty="true" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit a4e4b8b

Please sign in to comment.