25 changed files with 398 additions and 62 deletions
@ -0,0 +1,23 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:Class="ControlCatalog.Pages.EllipsePage"> |
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<TextBlock Classes="h1">Ellipse</TextBlock> |
|||
<TextBlock Classes="h2">A control which represents an ellipse with a fill and a stroke.</TextBlock> |
|||
|
|||
<StackPanel Orientation="Vertical" |
|||
Margin="0,16,0,0" |
|||
HorizontalAlignment="Center" |
|||
Spacing="16"> |
|||
<Ellipse Width="200" Height="200" Fill="Red" Stroke="Blue" StrokeThickness="{Binding #StrokeThickness.Value}"/> |
|||
|
|||
<Ellipse Width="200" Height="100" Fill="Red" Stroke="Blue" StrokeThickness="{Binding #StrokeThickness.Value}"/> |
|||
|
|||
<Grid ColumnDefinitions="Auto,*"> |
|||
<TextBlock Grid.Column="0" Text="Stroke thickness"/> |
|||
<Slider Grid.Column="1" Name="StrokeThickness" Maximum="10" Value="1"/> |
|||
</Grid> |
|||
|
|||
</StackPanel> |
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -0,0 +1,18 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public class EllipsePage : UserControl |
|||
{ |
|||
public EllipsePage() |
|||
{ |
|||
this.InitializeComponent(); |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:Class="ControlCatalog.Pages.LinePage"> |
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<TextBlock Classes="h1">Line</TextBlock> |
|||
<TextBlock Classes="h2">A control which represents a line.</TextBlock> |
|||
|
|||
<StackPanel Orientation="Vertical" |
|||
Margin="0,16,0,0" |
|||
HorizontalAlignment="Center" |
|||
Spacing="16"> |
|||
<Line StartPoint="0,0" EndPoint="200,100" Stroke="Blue" StrokeThickness="{Binding #StrokeThickness.Value}"/> |
|||
|
|||
<Grid ColumnDefinitions="Auto,*"> |
|||
<TextBlock Grid.Column="0" Text="Stroke thickness"/> |
|||
<Slider Grid.Column="1" Name="StrokeThickness" Maximum="10" Value="1"/> |
|||
</Grid> |
|||
|
|||
</StackPanel> |
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -0,0 +1,18 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public class LinePage : UserControl |
|||
{ |
|||
public LinePage() |
|||
{ |
|||
this.InitializeComponent(); |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:Class="ControlCatalog.Pages.RectanglePage"> |
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<TextBlock Classes="h1">Rectangle</TextBlock> |
|||
<TextBlock Classes="h2">A control which represents a rectangle with a fill and a stroke.</TextBlock> |
|||
|
|||
<StackPanel Orientation="Vertical" |
|||
Margin="0,16,0,0" |
|||
HorizontalAlignment="Center" |
|||
Spacing="16"> |
|||
<Rectangle Width="200" Height="32" Fill="Red" Stroke="Blue" StrokeThickness="{Binding #StrokeThickness.Value}"/> |
|||
|
|||
<Grid ColumnDefinitions="Auto,*"> |
|||
<TextBlock Grid.Column="0" Text="Stroke thickness"/> |
|||
<Slider Grid.Column="1" Name="StrokeThickness" Maximum="10" Value="1"/> |
|||
</Grid> |
|||
|
|||
</StackPanel> |
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -0,0 +1,18 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public class RectanglePage : UserControl |
|||
{ |
|||
public RectanglePage() |
|||
{ |
|||
this.InitializeComponent(); |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
namespace Avalonia.Platform |
|||
{ |
|||
/// <summary>
|
|||
/// Defines the platform-specific interface for a <see cref="Avalonia.Media.EllipseGeometry"/>.
|
|||
/// </summary>
|
|||
public interface IEllipseGeometryImpl : IGeometryImpl |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
namespace Avalonia.Platform |
|||
{ |
|||
/// <summary>
|
|||
/// Defines the platform-specific interface for a <see cref="Avalonia.Media.LineGeometry"/>.
|
|||
/// </summary>
|
|||
public interface ILineGeometryImpl : IGeometryImpl |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
namespace Avalonia.Platform |
|||
{ |
|||
/// <summary>
|
|||
/// Defines the platform-specific interface for a <see cref="Avalonia.Media.RectangleGeometry"/>.
|
|||
/// </summary>
|
|||
public interface IRectangleGeometryImpl : IGeometryImpl |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using Avalonia.Platform; |
|||
using SkiaSharp; |
|||
|
|||
namespace Avalonia.Skia |
|||
{ |
|||
/// <summary>
|
|||
/// A Skia implementation of a <see cref="Avalonia.Media.EllipseGeometry"/>.
|
|||
/// </summary>
|
|||
internal class EllipseGeometryImpl : GeometryImpl, IEllipseGeometryImpl |
|||
{ |
|||
public override Rect Bounds { get; } |
|||
public override SKPath EffectivePath { get; } |
|||
|
|||
public EllipseGeometryImpl(Rect rect) |
|||
{ |
|||
var path = new SKPath(); |
|||
path.AddOval(rect.ToSKRect()); |
|||
|
|||
EffectivePath = path; |
|||
Bounds = rect; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using Avalonia.Platform; |
|||
using SkiaSharp; |
|||
|
|||
namespace Avalonia.Skia |
|||
{ |
|||
/// <summary>
|
|||
/// A Skia implementation of a <see cref="Avalonia.Media.LineGeometry"/>.
|
|||
/// </summary>
|
|||
internal class LineGeometryImpl : GeometryImpl, ILineGeometryImpl |
|||
{ |
|||
public override Rect Bounds { get; } |
|||
public override SKPath EffectivePath { get; } |
|||
|
|||
public LineGeometryImpl(Point p1, Point p2) |
|||
{ |
|||
var path = new SKPath(); |
|||
path.MoveTo(p1.ToSKPoint()); |
|||
path.LineTo(p2.ToSKPoint()); |
|||
|
|||
EffectivePath = path; |
|||
Bounds = new Rect( |
|||
new Point(Math.Min(p1.X, p2.X), Math.Min(p1.Y, p2.Y)), |
|||
new Point(Math.Max(p1.X, p2.X), Math.Max(p1.Y, p2.Y))); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using Avalonia.Platform; |
|||
using SkiaSharp; |
|||
|
|||
namespace Avalonia.Skia |
|||
{ |
|||
/// <summary>
|
|||
/// A Skia implementation of a <see cref="Avalonia.Media.RectangleGeometry"/>.
|
|||
/// </summary>
|
|||
internal class RectangleGeometryImpl : GeometryImpl, IRectangleGeometryImpl |
|||
{ |
|||
public override Rect Bounds { get; } |
|||
public override SKPath EffectivePath { get; } |
|||
|
|||
public RectangleGeometryImpl(Rect rect) |
|||
{ |
|||
var path = new SKPath(); |
|||
path.AddRect(rect.ToSKRect()); |
|||
|
|||
EffectivePath = path; |
|||
Bounds = rect; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using Avalonia.Platform; |
|||
using SharpDX.Direct2D1; |
|||
|
|||
namespace Avalonia.Direct2D1.Media |
|||
{ |
|||
/// <summary>
|
|||
/// A Direct2D implementation of a <see cref="Avalonia.Media.EllipseGeometry"/>.
|
|||
/// </summary>
|
|||
internal class EllipseGeometryImpl : GeometryImpl, IEllipseGeometryImpl |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="StreamGeometryImpl"/> class.
|
|||
/// </summary>
|
|||
public EllipseGeometryImpl(Rect rect) |
|||
: base(CreateGeometry(rect)) |
|||
{ |
|||
} |
|||
|
|||
private static Geometry CreateGeometry(Rect rect) |
|||
{ |
|||
var ellipse = new Ellipse(rect.Center.ToSharpDX(), (float)rect.Width / 2, (float)rect.Height / 2); |
|||
return new EllipseGeometry(Direct2D1Platform.Direct2D1Factory, ellipse); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using Avalonia.Platform; |
|||
using SharpDX.Direct2D1; |
|||
|
|||
namespace Avalonia.Direct2D1.Media |
|||
{ |
|||
/// <summary>
|
|||
/// A Direct2D implementation of a <see cref="Avalonia.Media.LineGeometry"/>.
|
|||
/// </summary>
|
|||
internal class LineGeometryImpl : StreamGeometryImpl, ILineGeometryImpl |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="StreamGeometryImpl"/> class.
|
|||
/// </summary>
|
|||
public LineGeometryImpl(Point p1, Point p2) |
|||
{ |
|||
using (var sink = ((PathGeometry)Geometry).Open()) |
|||
{ |
|||
sink.BeginFigure(p1.ToSharpDX(), FigureBegin.Hollow); |
|||
sink.AddLine(p2.ToSharpDX()); |
|||
sink.EndFigure(FigureEnd.Open); |
|||
sink.Close(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using Avalonia.Platform; |
|||
using SharpDX.Direct2D1; |
|||
|
|||
namespace Avalonia.Direct2D1.Media |
|||
{ |
|||
/// <summary>
|
|||
/// A Direct2D implementation of a <see cref="Avalonia.Media.RectangleGeometry"/>.
|
|||
/// </summary>
|
|||
internal class RectangleGeometryImpl : GeometryImpl, IRectangleGeometryImpl |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="StreamGeometryImpl"/> class.
|
|||
/// </summary>
|
|||
public RectangleGeometryImpl(Rect rect) |
|||
: base(CreateGeometry(rect)) |
|||
{ |
|||
} |
|||
|
|||
private static Geometry CreateGeometry(Rect rect) |
|||
{ |
|||
return new RectangleGeometry(Direct2D1Platform.Direct2D1Factory, rect.ToDirect2D()); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue