8 changed files with 146 additions and 9 deletions
@ -0,0 +1,33 @@ |
|||
<Window xmlns="https://github.com/avaloniaui" MinWidth="500" MinHeight="300" |
|||
Title="Avalonia Control Gallery" |
|||
Icon="resm:ControlCatalog.Assets.test_icon.ico?assembly=ControlCatalog" |
|||
xmlns:local="clr-namespace:ControlCatalog;assembly=ControlCatalog" HasSystemDecorations="False"> |
|||
<Grid RowDefinitions="5,*,5" ColumnDefinitions="5,*,5"> |
|||
<DockPanel Grid.Column="1" Grid.Row="1" > |
|||
<Grid Name="TitleBar" Background="LightBlue" DockPanel.Dock="Top" ColumnDefinitions="Auto,*,Auto"> |
|||
<TextBlock VerticalAlignment="Center" Margin="5,0,0,0">Title</TextBlock> |
|||
<StackPanel Grid.Column="2" Orientation="Horizontal"> |
|||
<StackPanel.Styles> |
|||
<Style Selector="Button"> |
|||
<Setter Property="Margin" Value="2"/> |
|||
</Style> |
|||
</StackPanel.Styles> |
|||
<Button Name="MinimizeButton">_</Button> |
|||
<Button Name="MaximizeButton">[ ]</Button> |
|||
<Button Name="CloseButton">X</Button> |
|||
</StackPanel> |
|||
</Grid> |
|||
<Border Background="White" Margin="5"> |
|||
<TextBlock>Hello world!</TextBlock> |
|||
</Border> |
|||
</DockPanel> |
|||
<Border Name="TopLeft" Background="Red"/> |
|||
<Border Name="TopRight" Background="Red" Grid.Column="2" /> |
|||
<Border Name="BottomLeft" Background="Red" Grid.Row="2" /> |
|||
<Border Name="BottomRight" Background="Red" Grid.Row="2" Grid.Column="2"/> |
|||
<Border Name="Top" Background="Blue" Grid.Column="1" /> |
|||
<Border Name="Right" Background="Blue" Grid.Row="1" Grid.Column="2" /> |
|||
<Border Name="Bottom" Background="Blue" Grid.Row="2" Grid.Column="1" /> |
|||
<Border Name="Left" Background="Blue" Grid.Row="1" /> |
|||
</Grid> |
|||
</Window> |
|||
@ -0,0 +1,53 @@ |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
using System; |
|||
using Avalonia.Input; |
|||
|
|||
namespace ControlCatalog |
|||
{ |
|||
public class DecoratedWindow : Window |
|||
{ |
|||
public DecoratedWindow() |
|||
{ |
|||
this.InitializeComponent(); |
|||
this.AttachDevTools(); |
|||
} |
|||
|
|||
void SetupSide(string name, StandardCursorType cursor, WindowEdge edge) |
|||
{ |
|||
var ctl = this.FindControl<Control>(name); |
|||
ctl.Cursor = new Cursor(cursor); |
|||
ctl.PointerPressed += delegate |
|||
{ |
|||
PlatformImpl.BeginResizeDrag(edge); |
|||
}; |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
this.FindControl<Control>("TitleBar").PointerPressed += delegate |
|||
{ |
|||
PlatformImpl.BeginMoveDrag(); |
|||
}; |
|||
SetupSide("Left", StandardCursorType.LeftSide, WindowEdge.West); |
|||
SetupSide("Right", StandardCursorType.RightSide, WindowEdge.East); |
|||
SetupSide("Top", StandardCursorType.TopSide, WindowEdge.South); |
|||
SetupSide("Bottom", StandardCursorType.BottomSize, WindowEdge.North); |
|||
SetupSide("TopLeft", StandardCursorType.TopLeftCorner, WindowEdge.NorthWest); |
|||
SetupSide("TopRight", StandardCursorType.TopRightCorner, WindowEdge.NorthEast); |
|||
SetupSide("BottomLeft", StandardCursorType.BottomLeftCorner, WindowEdge.SouthWest); |
|||
SetupSide("BottomRight", StandardCursorType.BottomRightCorner, WindowEdge.SouthEast); |
|||
this.FindControl<Button>("MinimizeButton").Click += delegate { this.WindowState = WindowState.Minimized; }; |
|||
this.FindControl<Button>("MaximizeButton").Click += delegate |
|||
{ |
|||
WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; |
|||
}; |
|||
this.FindControl<Button>("CloseButton").Click += delegate |
|||
{ |
|||
Close(); |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue