28 changed files with 456 additions and 213 deletions
@ -0,0 +1,62 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Avalonia.Layout |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Extension methods for layout types.
|
||||
|
/// </summary>
|
||||
|
public static class LayoutExtensions |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Aligns a rect in a constraining rect according to horizontal and vertical alignment
|
||||
|
/// settings.
|
||||
|
/// </summary>
|
||||
|
/// <param name="rect">The rect to align.</param>
|
||||
|
/// <param name="constraint">The constraining rect.</param>
|
||||
|
/// <param name="horizontalAlignment">The horizontal alignment.</param>
|
||||
|
/// <param name="verticalAlignment">The vertical alignment.</param>
|
||||
|
/// <returns></returns>
|
||||
|
public static Rect Align( |
||||
|
this Rect rect, |
||||
|
Rect constraint, |
||||
|
HorizontalAlignment horizontalAlignment, |
||||
|
VerticalAlignment verticalAlignment) |
||||
|
{ |
||||
|
switch (horizontalAlignment) |
||||
|
{ |
||||
|
case HorizontalAlignment.Center: |
||||
|
rect = rect.WithX((constraint.Width - rect.Width) / 2); |
||||
|
break; |
||||
|
case HorizontalAlignment.Right: |
||||
|
rect = rect.WithX(constraint.Width - rect.Width); |
||||
|
break; |
||||
|
case HorizontalAlignment.Stretch: |
||||
|
rect = new Rect( |
||||
|
0, |
||||
|
rect.Y, |
||||
|
Math.Max(constraint.Width, rect.Width), |
||||
|
rect.Height); |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
switch (verticalAlignment) |
||||
|
{ |
||||
|
case VerticalAlignment.Center: |
||||
|
rect = rect.WithY((constraint.Height - rect.Height) / 2); |
||||
|
break; |
||||
|
case VerticalAlignment.Bottom: |
||||
|
rect = rect.WithY(constraint.Height - rect.Height); |
||||
|
break; |
||||
|
case VerticalAlignment.Stretch: |
||||
|
rect = new Rect( |
||||
|
rect.X, |
||||
|
0, |
||||
|
rect.Width, |
||||
|
Math.Max(constraint.Height, rect.Height)); |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
return rect; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,10 +0,0 @@ |
|||||
namespace Avalonia.Styling |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// This is an interface for advanced scenarios to assist users in correct style development.
|
|
||||
/// You as a user will not need to use this interface directly.
|
|
||||
/// </summary>
|
|
||||
public interface IRequiresTemplateInSetter |
|
||||
{ |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,13 @@ |
|||||
|
namespace Avalonia.Styling |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Customizes the behavior of a class when added as a value to an <see cref="ISetter"/>.
|
||||
|
/// </summary>
|
||||
|
public interface ISetterValue |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Notifies that the object has been added as a setter value.
|
||||
|
/// </summary>
|
||||
|
void Initialize(ISetter setter); |
||||
|
} |
||||
|
} |
||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.5 KiB |
Loading…
Reference in new issue