Skip to content

Commit

Permalink
chore: adjust sample
Browse files Browse the repository at this point in the history
  • Loading branch information
ramezgerges committed May 8, 2024
1 parent e16e747 commit a0d197c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,11 @@ public class SKCanvasElementImpl : SKCanvasElement
{
public static int SampleCount => 3;

public SKCanvasElementImpl()
{
Sample = 0;
}

public static DependencyProperty SampleProperty { get; } = DependencyProperty.Register(
nameof(Sample),
typeof(int),
typeof(SKCanvasElementImpl),
new PropertyMetadata(-1, (o, args) => ((SKCanvasElementImpl)o).SampleChanged((int)args.NewValue)));
new PropertyMetadata(0, (o, args) => ((SKCanvasElementImpl)o).SampleChanged((int)args.NewValue)));

public int Sample
{
Expand All @@ -29,21 +24,14 @@ public int Sample

private void SampleChanged(int newIndex)
{
var coercedIndex = Math.Min(Math.Max(0, newIndex), SampleCount - 1);
if (coercedIndex != Sample)
{
Sample = coercedIndex;
}
Sample = Math.Min(Math.Max(0, newIndex), SampleCount - 1);
}

protected override void RenderOverride(SKCanvas canvas, Size area)
{
var minDim = Math.Min(area.Width, area.Height);
if (minDim > 250)
{
// scale up if area is bigger than needed, assuming each drawing takes is 260x260
canvas.Scale((float)(minDim / 260), (float)(minDim / 260));
}
// rescale to fit the given area, assuming each drawing takes is 260x260
canvas.Scale((float)(minDim / 260), (float)(minDim / 260));

switch (Sample)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
using System;
using Uno.UI.Samples.Controls;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;

#if __SKIA__
using SkiaSharp;
using Windows.Foundation;
#endif

namespace UITests.Shared.Windows_UI_Composition
{
[Sample("Microsoft.UI.Composition")]
Expand Down

0 comments on commit a0d197c

Please sign in to comment.