Skip to content

Commit

Permalink
Merge pull request #480 from WCKYWCKF/new-control
Browse files Browse the repository at this point in the history
Add a new control AspectRatioLayout
  • Loading branch information
rabbitism authored Nov 14, 2024
2 parents a530a3e + 06ba9af commit 8fe15b2
Show file tree
Hide file tree
Showing 9 changed files with 444 additions and 1 deletion.
79 changes: 79 additions & 0 deletions demo/Ursa.Demo/Pages/AspectRatioLayoutDemo.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="https://irihi.tech/ursa"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Ursa.Demo.Pages.AspectRatioLayoutDemo">
<Grid
RowDefinitions="Auto,*">
<StackPanel
Grid.Row="0">
<u:NumericDoubleUpDown InnerLeftContent="AspectRatioTolerance"
Value="{Binding #AspectRatioLayout.AspectRatioTolerance}">
</u:NumericDoubleUpDown>
<TextBlock Text="{Binding #AspectRatioLayout.AspectRatioValue,StringFormat='AspectRatioValue: {0}'}"></TextBlock>
</StackPanel>

<u:AspectRatioLayout Name="AspectRatioLayout" Grid.Row="1"
BorderThickness="1"
BorderBrush="Red"
Margin="2"
CornerRadius="10">
<u:AspectRatioLayoutItem AcceptAspectRatioMode="HorizontalRectangle">
<Button>HorizontalRectangle ControlLayout</Button>
</u:AspectRatioLayoutItem>
<u:AspectRatioLayoutItem AcceptAspectRatioMode="VerticalRectangle">
<Button>VerticalRectangle ControlLayout</Button>
</u:AspectRatioLayoutItem>
<u:AspectRatioLayoutItem AcceptAspectRatioMode="Square">
<Button>Square ControlLayout</Button>
</u:AspectRatioLayoutItem>
<u:AspectRatioLayoutItem StartAspectRatioValue="2" EndAspectRatioValue="2.2">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Run Text="{Binding $parent[u:AspectRatioLayoutItem].StartAspectRatioValue,StringFormat='StartAspectRatioValue {0}'}"></Run>
<LineBreak></LineBreak>
<Run Text="{Binding $parent[u:AspectRatioLayoutItem].EndAspectRatioValue,StringFormat='EndAspectRatioValue {0}'}"></Run>
</TextBlock>
</u:AspectRatioLayoutItem>
<u:AspectRatioLayoutItem StartAspectRatioValue="2" EndAspectRatioValue="2.4">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Run Text="{Binding $parent[u:AspectRatioLayoutItem].StartAspectRatioValue,StringFormat='StartAspectRatioValue {0}'}"></Run>
<LineBreak></LineBreak>
<Run Text="{Binding $parent[u:AspectRatioLayoutItem].EndAspectRatioValue,StringFormat='EndAspectRatioValue {0}'}"></Run>
</TextBlock>
</u:AspectRatioLayoutItem>
<u:AspectRatioLayoutItem StartAspectRatioValue="2" EndAspectRatioValue="2.6">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Run Text="{Binding $parent[u:AspectRatioLayoutItem].StartAspectRatioValue,StringFormat='StartAspectRatioValue {0}'}"></Run>
<LineBreak></LineBreak>
<Run Text="{Binding $parent[u:AspectRatioLayoutItem].EndAspectRatioValue,StringFormat='EndAspectRatioValue {0}'}"></Run>
</TextBlock>
</u:AspectRatioLayoutItem>
<u:AspectRatioLayoutItem StartAspectRatioValue="2" EndAspectRatioValue="2.8">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Run Text="{Binding $parent[u:AspectRatioLayoutItem].StartAspectRatioValue,StringFormat='StartAspectRatioValue {0}'}"></Run>
<LineBreak></LineBreak>
<Run Text="{Binding $parent[u:AspectRatioLayoutItem].EndAspectRatioValue,StringFormat='EndAspectRatioValue {0}'}"></Run>
</TextBlock>
</u:AspectRatioLayoutItem>
<u:AspectRatioLayoutItem StartAspectRatioValue="1.3" EndAspectRatioValue="1.5">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Run Text="{Binding $parent[u:AspectRatioLayoutItem].StartAspectRatioValue,StringFormat='StartAspectRatioValue {0}'}"></Run>
<LineBreak></LineBreak>
<Run Text="{Binding $parent[u:AspectRatioLayoutItem].EndAspectRatioValue,StringFormat='EndAspectRatioValue {0}'}"></Run>
</TextBlock>
</u:AspectRatioLayoutItem>
</u:AspectRatioLayout>
</Grid>
</UserControl>
13 changes: 13 additions & 0 deletions demo/Ursa.Demo/Pages/AspectRatioLayoutDemo.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;

namespace Ursa.Demo.Pages;

public partial class AspectRatioLayoutDemo : UserControl
{
public AspectRatioLayoutDemo()
{
InitializeComponent();
}
}
5 changes: 5 additions & 0 deletions demo/Ursa.Demo/ViewModels/AspectRatioLayoutDemoViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace Ursa.Demo.ViewModels;

public class AspectRatioLayoutDemoViewModel : ViewModelBase
{
}
1 change: 1 addition & 0 deletions demo/Ursa.Demo/ViewModels/MainViewViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ private void OnNavigation(MainViewViewModel vm, string s)
MenuKeys.MenuKeyToolBar => new ToolBarDemoViewModel(),
MenuKeys.MenuKeyTreeComboBox => new TreeComboBoxDemoViewModel(),
MenuKeys.MenuKeyTwoTonePathIcon => new TwoTonePathIconDemoViewModel(),
MenuKeys.AspectRatioLayout => new AspectRatioLayoutDemoViewModel(),
_ => throw new ArgumentOutOfRangeException(nameof(s), s, null)
};
}
Expand Down
2 changes: 2 additions & 0 deletions demo/Ursa.Demo/ViewModels/MenuViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public MenuViewModel()
new() { MenuHeader = "ToolBar", Key = MenuKeys.MenuKeyToolBar },
new() { MenuHeader = "TreeComboBox", Key = MenuKeys.MenuKeyTreeComboBox },
new() { MenuHeader = "TwoTonePathIcon", Key = MenuKeys.MenuKeyTwoTonePathIcon },
new() { MenuHeader = "AspectRatioLayout", Key = MenuKeys.AspectRatioLayout ,Status = "WIP"},
};
}
}
Expand Down Expand Up @@ -111,4 +112,5 @@ public static class MenuKeys
public const string MenuKeyToolBar = "ToolBar";
public const string MenuKeyTreeComboBox = "TreeComboBox";
public const string MenuKeyTwoTonePathIcon = "TwoTonePathIcon";
public const string AspectRatioLayout = "AspectRatioLayout";
}
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"sdk": {
"version": "8.0.0",
"rollForward": "latestMajor",
"allowPrerelease": false
"allowPrerelease": true
}
}
Loading

0 comments on commit 8fe15b2

Please sign in to comment.