committed by
GitHub
842 changed files with 26577 additions and 12988 deletions
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,46 @@ |
|||
//
|
|||
// AvnTextInputMethod.h
|
|||
// Avalonia.Native.OSX
|
|||
//
|
|||
// Created by Benedikt Stebner on 22.11.22.
|
|||
// Copyright © 2022 Avalonia. All rights reserved.
|
|||
//
|
|||
|
|||
#ifndef AvnTextInputMethod_h |
|||
#define AvnTextInputMethod_h |
|||
|
|||
#import <Foundation/Foundation.h> |
|||
|
|||
#include "com.h" |
|||
#include "comimpl.h" |
|||
#include "avalonia-native.h" |
|||
#import "AvnTextInputMethodDelegate.h" |
|||
|
|||
class AvnTextInputMethod: public virtual ComObject, public virtual IAvnTextInputMethod{ |
|||
private: |
|||
id<AvnTextInputMethodDelegate> _inputMethodDelegate; |
|||
public: |
|||
FORWARD_IUNKNOWN() |
|||
|
|||
BEGIN_INTERFACE_MAP() |
|||
INTERFACE_MAP_ENTRY(IAvnTextInputMethod, IID_IAvnTextInputMethod) |
|||
END_INTERFACE_MAP() |
|||
|
|||
virtual ~AvnTextInputMethod(); |
|||
|
|||
AvnTextInputMethod(id<AvnTextInputMethodDelegate> inputMethodDelegate); |
|||
|
|||
bool IsActive (); |
|||
|
|||
HRESULT SetClient (IAvnTextInputMethodClient* client) override; |
|||
|
|||
virtual void Reset () override; |
|||
|
|||
virtual void SetCursorRect (AvnRect rect) override; |
|||
|
|||
virtual void SetSurroundingText (char* text, int anchorOffset, int cursorOffset) override; |
|||
|
|||
public: |
|||
ComPtr<IAvnTextInputMethodClient> Client; |
|||
}; |
|||
#endif /* AvnTextInputMethod_h */ |
|||
@ -0,0 +1,41 @@ |
|||
// |
|||
// AvnTextInputMethod.mm |
|||
// Avalonia.Native.OSX |
|||
// |
|||
// Created by Benedikt Stebner on 23.11.22. |
|||
// Copyright © 2022 Avalonia. All rights reserved. |
|||
// |
|||
|
|||
#include "AvnTextInputMethod.h" |
|||
|
|||
AvnTextInputMethod::~AvnTextInputMethod() { |
|||
Client = nullptr; |
|||
} |
|||
|
|||
AvnTextInputMethod::AvnTextInputMethod(id<AvnTextInputMethodDelegate> inputMethodDelegate) { |
|||
_inputMethodDelegate = inputMethodDelegate; |
|||
} |
|||
|
|||
bool AvnTextInputMethod::IsActive() { |
|||
return Client != nullptr; |
|||
} |
|||
|
|||
HRESULT AvnTextInputMethod::SetClient(IAvnTextInputMethodClient *client) { |
|||
START_COM_CALL; |
|||
|
|||
Client = client; |
|||
|
|||
return S_OK; |
|||
} |
|||
|
|||
void AvnTextInputMethod::Reset() { |
|||
} |
|||
|
|||
void AvnTextInputMethod::SetSurroundingText(char* text, int anchorOffset, int cursorOffset) { |
|||
[_inputMethodDelegate setText:[NSString stringWithUTF8String:text]]; |
|||
[_inputMethodDelegate setSelection: anchorOffset : cursorOffset]; |
|||
} |
|||
|
|||
void AvnTextInputMethod::SetCursorRect(AvnRect rect) { |
|||
[_inputMethodDelegate setCursorRect: rect]; |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
//
|
|||
// AvnTextInputMethodHost.h
|
|||
// Avalonia.Native.OSX
|
|||
//
|
|||
// Created by Benedikt Stebner on 24.11.22.
|
|||
// Copyright © 2022 Avalonia. All rights reserved.
|
|||
//
|
|||
|
|||
#ifndef AvnTextInputMethodHost_h |
|||
#define AvnTextInputMethodHost_h |
|||
|
|||
@protocol AvnTextInputMethodDelegate |
|||
@required |
|||
-(void) setText:(NSString* _Nonnull) text; |
|||
-(void) setCursorRect:(AvnRect) cursorRect; |
|||
-(void) setSelection: (int) start : (int) end; |
|||
|
|||
@end |
|||
|
|||
#endif /* AvnTextInputMethodHost_h */ |
|||
@ -0,0 +1,4 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<resources> |
|||
<color name="splash_background">#212121</color> |
|||
</resources> |
|||
@ -1,19 +1,12 @@ |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
using Avalonia.Controls; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public class RelativePanelPage : UserControl |
|||
public partial class RelativePanelPage : UserControl |
|||
{ |
|||
public RelativePanelPage() |
|||
{ |
|||
this.InitializeComponent(); |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
InitializeComponent(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,222 +0,0 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
d:DesignHeight="800" |
|||
d:DesignWidth="400" |
|||
x:Class="ControlCatalog.Pages.ScrollSnapPage" |
|||
xmlns:pages="using:ControlCatalog.Pages" |
|||
x:DataType="pages:ScrollSnapPageViewModel"> |
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<TextBlock TextWrapping="Wrap" |
|||
Classes="h2">Scrollviewer can snap supported content both vertically and horizontally. Snapping occurs from scrolling with touch or pen.</TextBlock> |
|||
|
|||
<Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto"> |
|||
<StackPanel Orientation="Horizontal" |
|||
Spacing="4"> |
|||
<StackPanel Orientation="Vertical" |
|||
Spacing="4"> |
|||
<TextBlock Text="Snap Point Type" /> |
|||
<ComboBox Items="{Binding AvailableSnapPointsType}" |
|||
SelectedItem="{Binding SnapPointsType}" /> |
|||
</StackPanel> |
|||
|
|||
<StackPanel Orientation="Vertical" |
|||
Spacing="4"> |
|||
<TextBlock Text="Snap Point Alignment" /> |
|||
<ComboBox Items="{Binding AvailableSnapPointsAlignment}" |
|||
SelectedItem="{Binding SnapPointsAlignment}" /> |
|||
</StackPanel> |
|||
|
|||
<ToggleSwitch IsChecked="{Binding AreSnapPointsRegular}" |
|||
OffContent="No" |
|||
OnContent="Yes" |
|||
Content="Are Snap Points regular?" /> |
|||
</StackPanel> |
|||
<TextBlock TextWrapping="Wrap" |
|||
Grid.Row="1" |
|||
Margin="0,10" |
|||
Classes="h2">Vertical Snapping</TextBlock> |
|||
|
|||
<Border |
|||
BorderBrush="Green" |
|||
BorderThickness="1" |
|||
Padding="0" |
|||
Grid.Row="2" |
|||
Margin="10, 5"> |
|||
<ScrollViewer x:Name="VerticalSnapsScrollViewer" |
|||
VerticalSnapPointsType="{Binding SnapPointsType}" |
|||
VerticalSnapPointsAlignment="{Binding SnapPointsAlignment}" |
|||
HorizontalAlignment="Stretch" |
|||
Height="350" |
|||
HorizontalScrollBarVisibility="Disabled"> |
|||
<StackPanel AreVerticalSnapPointsRegular="{Binding AreSnapPointsRegular}" |
|||
Orientation="Vertical" |
|||
HorizontalAlignment="Stretch"> |
|||
<Border Padding="5, 30" |
|||
BorderBrush="Red" |
|||
HorizontalAlignment="Stretch" |
|||
BorderThickness="1"> |
|||
<TextBlock FontWeight="Bold" |
|||
Text="Child 1"/> |
|||
</Border> |
|||
<Border Padding="5, 30" |
|||
BorderBrush="Red" |
|||
HorizontalAlignment="Stretch" |
|||
BorderThickness="1"> |
|||
<TextBlock FontWeight="Bold" |
|||
Text="Child 2"/> |
|||
</Border> |
|||
<Border Padding="5, 20" |
|||
BorderBrush="Red" |
|||
HorizontalAlignment="Stretch" |
|||
BorderThickness="1"> |
|||
<TextBlock FontWeight="Bold" |
|||
Text="Child 3"/> |
|||
</Border> |
|||
<Border Padding="5, 30" |
|||
BorderBrush="Red" |
|||
HorizontalAlignment="Stretch" |
|||
BorderThickness="1"> |
|||
<TextBlock FontWeight="Bold" |
|||
Text="Child 4"/> |
|||
</Border> |
|||
<Border Padding="5, 30" |
|||
BorderBrush="Red" |
|||
HorizontalAlignment="Stretch" |
|||
BorderThickness="1"> |
|||
<TextBlock FontWeight="Bold" |
|||
Text="Child 5"/> |
|||
</Border> |
|||
<Border Padding="5, 30" |
|||
BorderBrush="Red" |
|||
HorizontalAlignment="Stretch" |
|||
BorderThickness="1"> |
|||
<TextBlock FontWeight="Bold" |
|||
Text="Child 6"/> |
|||
</Border> |
|||
<Border Padding="5,8" |
|||
BorderBrush="Red" |
|||
HorizontalAlignment="Stretch" |
|||
BorderThickness="1"> |
|||
<TextBlock FontWeight="Bold" |
|||
Text="Child 7"/> |
|||
</Border> |
|||
<Border Padding="5, 30" |
|||
BorderBrush="Red" |
|||
HorizontalAlignment="Stretch" |
|||
BorderThickness="1"> |
|||
<TextBlock FontWeight="Bold" |
|||
Text="Child 8"/> |
|||
</Border> |
|||
<Border Padding="5,4" |
|||
BorderBrush="Red" |
|||
HorizontalAlignment="Stretch" |
|||
BorderThickness="1"> |
|||
<TextBlock FontWeight="Bold" |
|||
Text="Child 9"/> |
|||
</Border> |
|||
<Border Padding="5, 30" |
|||
BorderBrush="Red" |
|||
HorizontalAlignment="Stretch" |
|||
BorderThickness="1"> |
|||
<TextBlock FontWeight="Bold" |
|||
Text="Child 20"/> |
|||
</Border> |
|||
<Border Padding="5, 30" |
|||
BorderBrush="Red" |
|||
HorizontalAlignment="Stretch" |
|||
BorderThickness="1"> |
|||
<TextBlock FontWeight="Bold" |
|||
Text="Child 11"/> |
|||
</Border> |
|||
<Border Padding="5, 30" |
|||
BorderBrush="Red" |
|||
HorizontalAlignment="Stretch" |
|||
BorderThickness="1"> |
|||
<TextBlock FontWeight="Bold" |
|||
Text="Child 12"/> |
|||
</Border> |
|||
</StackPanel> |
|||
</ScrollViewer> |
|||
</Border> |
|||
<TextBlock TextWrapping="Wrap" |
|||
Grid.Row="3" |
|||
Margin="0,10" |
|||
Classes="h2">Horizontal Snapping</TextBlock> |
|||
<Border |
|||
BorderBrush="Green" |
|||
BorderThickness="1" |
|||
Padding="0" |
|||
Grid.Row="4" |
|||
Margin="10, 10"> |
|||
<ScrollViewer x:Name="HorizontalSnapsScrollViewer" |
|||
HorizontalSnapPointsType="{Binding SnapPointsType}" |
|||
HorizontalSnapPointsAlignment="{Binding SnapPointsAlignment}" |
|||
HorizontalAlignment="Stretch" |
|||
Height="350" |
|||
HorizontalScrollBarVisibility="Auto" |
|||
VerticalScrollBarVisibility="Disabled"> |
|||
<StackPanel AreHorizontalSnapPointsRegular="{Binding AreSnapPointsRegular}" |
|||
Orientation="Horizontal" |
|||
HorizontalAlignment="Stretch"> |
|||
<Border Padding="5, 30" |
|||
Width="300" |
|||
BorderBrush="Red" |
|||
HorizontalAlignment="Stretch" |
|||
BorderThickness="1"> |
|||
<TextBlock FontWeight="Bold" |
|||
VerticalAlignment="Center" |
|||
Text="Child 1"/> |
|||
</Border> |
|||
<Border Padding="5, 30" |
|||
Width="300" |
|||
BorderBrush="Red" |
|||
VerticalAlignment="Stretch" |
|||
BorderThickness="1"> |
|||
<TextBlock FontWeight="Bold" |
|||
VerticalAlignment="Center" |
|||
Text="Child 2"/> |
|||
</Border> |
|||
<Border Padding="5, 20" |
|||
Width="300" |
|||
BorderBrush="Red" |
|||
VerticalAlignment="Stretch" |
|||
BorderThickness="1"> |
|||
<TextBlock FontWeight="Bold" |
|||
VerticalAlignment="Center" |
|||
Text="Child 3"/> |
|||
</Border> |
|||
<Border Padding="5, 30" |
|||
Width="300" |
|||
BorderBrush="Red" |
|||
VerticalAlignment="Stretch" |
|||
BorderThickness="1"> |
|||
<TextBlock FontWeight="Bold" |
|||
VerticalAlignment="Center" |
|||
Text="Child 4"/> |
|||
</Border> |
|||
<Border Padding="5, 30" |
|||
Width="300" |
|||
BorderBrush="Red" |
|||
VerticalAlignment="Stretch" |
|||
BorderThickness="1"> |
|||
<TextBlock FontWeight="Bold" |
|||
VerticalAlignment="Center" |
|||
Text="Child 5"/> |
|||
</Border> |
|||
<Border Padding="5, 30" |
|||
Width="300" |
|||
BorderBrush="Red" |
|||
VerticalAlignment="Stretch" |
|||
BorderThickness="1"> |
|||
<TextBlock FontWeight="Bold" |
|||
VerticalAlignment="Center" |
|||
Text="Child 6"/> |
|||
</Border> |
|||
|
|||
</StackPanel> |
|||
</ScrollViewer> |
|||
</Border> |
|||
</Grid> |
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -1,68 +0,0 @@ |
|||
using System.Collections.Generic; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.Primitives; |
|||
using Avalonia.Markup.Xaml; |
|||
using MiniMvvm; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public class ScrollSnapPageViewModel : ViewModelBase |
|||
{ |
|||
private SnapPointsType _snapPointsType; |
|||
private SnapPointsAlignment _snapPointsAlignment; |
|||
private bool _areSnapPointsRegular; |
|||
|
|||
public ScrollSnapPageViewModel() |
|||
{ |
|||
|
|||
AvailableSnapPointsType = new List<SnapPointsType>() |
|||
{ |
|||
SnapPointsType.None, |
|||
SnapPointsType.Mandatory, |
|||
SnapPointsType.MandatorySingle |
|||
}; |
|||
|
|||
AvailableSnapPointsAlignment = new List<SnapPointsAlignment>() |
|||
{ |
|||
SnapPointsAlignment.Near, |
|||
SnapPointsAlignment.Center, |
|||
SnapPointsAlignment.Far, |
|||
}; |
|||
} |
|||
|
|||
public bool AreSnapPointsRegular |
|||
{ |
|||
get => _areSnapPointsRegular; |
|||
set => this.RaiseAndSetIfChanged(ref _areSnapPointsRegular, value); |
|||
} |
|||
|
|||
public SnapPointsType SnapPointsType |
|||
{ |
|||
get => _snapPointsType; |
|||
set => this.RaiseAndSetIfChanged(ref _snapPointsType, value); |
|||
} |
|||
|
|||
public SnapPointsAlignment SnapPointsAlignment |
|||
{ |
|||
get => _snapPointsAlignment; |
|||
set => this.RaiseAndSetIfChanged(ref _snapPointsAlignment, value); |
|||
} |
|||
public List<SnapPointsType> AvailableSnapPointsType { get; } |
|||
public List<SnapPointsAlignment> AvailableSnapPointsAlignment { get; } |
|||
} |
|||
|
|||
public class ScrollSnapPage : UserControl |
|||
{ |
|||
public ScrollSnapPage() |
|||
{ |
|||
this.InitializeComponent(); |
|||
|
|||
DataContext = new ScrollSnapPageViewModel(); |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
<Application xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:Class="Generators.Sandbox.App"> |
|||
<Application.Styles> |
|||
<FluentTheme /> |
|||
</Application.Styles> |
|||
</Application> |
|||
@ -0,0 +1,20 @@ |
|||
using Avalonia; |
|||
using Avalonia.Markup.Xaml; |
|||
using Generators.Sandbox.ViewModels; |
|||
|
|||
namespace Generators.Sandbox; |
|||
|
|||
public class App : Application |
|||
{ |
|||
public override void Initialize() => AvaloniaXamlLoader.Load(this); |
|||
|
|||
public override void OnFrameworkInitializationCompleted() |
|||
{ |
|||
var view = new Views.SignUpView |
|||
{ |
|||
ViewModel = new SignUpViewModel() |
|||
}; |
|||
view.Show(); |
|||
base.OnFrameworkInitializationCompleted(); |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using System; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Styling; |
|||
|
|||
namespace Generators.Sandbox.Controls; |
|||
|
|||
public class CustomTextBox : TextBox, IStyleable |
|||
{ |
|||
Type IStyleable.StyleKey => typeof(TextBox); |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:controls="using:Generators.Sandbox.Controls" |
|||
x:Class="Generators.Sandbox.Controls.SignUpView"> |
|||
<StackPanel> |
|||
<controls:CustomTextBox Margin="0 10 0 0" |
|||
x:Name="UserNameTextBox" |
|||
Watermark="Please, enter user name..." |
|||
UseFloatingWatermark="True" /> |
|||
<TextBlock x:Name="UserNameValidation" |
|||
Foreground="Red" |
|||
FontSize="12" /> |
|||
<TextBox Margin="0 10 0 0" |
|||
x:Name="PasswordTextBox" |
|||
Watermark="Please, enter your password..." |
|||
UseFloatingWatermark="True" |
|||
PasswordChar="*" /> |
|||
<TextBlock x:Name="PasswordValidation" |
|||
Foreground="Red" |
|||
FontSize="12" /> |
|||
<TextBox Margin="0 10 0 0" |
|||
x:Name="ConfirmPasswordTextBox" |
|||
Watermark="Please, confirm the password..." |
|||
UseFloatingWatermark="True" |
|||
PasswordChar="*" /> |
|||
<TextBlock x:Name="ConfirmPasswordValidation" |
|||
TextWrapping="Wrap" |
|||
Foreground="Red" |
|||
FontSize="12" /> |
|||
<TextBlock> |
|||
<TextBlock.Inlines> |
|||
<InlineCollection> |
|||
<Run x:Name="SignUpButtonDescription" /> |
|||
</InlineCollection> |
|||
</TextBlock.Inlines> |
|||
</TextBlock> |
|||
<Button Margin="0 10 0 5" |
|||
Content="Sign up" |
|||
x:Name="SignUpButton" /> |
|||
<TextBlock x:Name="CompoundValidation" |
|||
TextWrapping="Wrap" |
|||
Foreground="Red" |
|||
FontSize="12" /> |
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -0,0 +1,54 @@ |
|||
using System; |
|||
using System.Reactive.Disposables; |
|||
using Avalonia.ReactiveUI; |
|||
using Generators.Sandbox.ViewModels; |
|||
using ReactiveUI; |
|||
using ReactiveUI.Validation.Extensions; |
|||
using ReactiveUI.Validation.Formatters; |
|||
|
|||
namespace Generators.Sandbox.Controls; |
|||
|
|||
/// <summary>
|
|||
/// This is a sample view class with typed x:Name references generated using
|
|||
/// .NET 5 source generators. The class has to be partial because x:Name
|
|||
/// references are living in a separate partial class file. See also:
|
|||
/// https://devblogs.microsoft.com/dotnet/new-c-source-generator-samples/
|
|||
/// </summary>
|
|||
public partial class SignUpView : ReactiveUserControl<SignUpViewModel> |
|||
{ |
|||
public SignUpView() |
|||
{ |
|||
// The InitializeComponent method is also generated automatically
|
|||
// and lives in the autogenerated part of the partial class.
|
|||
InitializeComponent(); |
|||
this.WhenActivated(disposables => |
|||
{ |
|||
this.Bind(ViewModel, x => x.UserName, x => x.UserNameTextBox.Text) |
|||
.DisposeWith(disposables); |
|||
this.Bind(ViewModel, x => x.Password, x => x.PasswordTextBox.Text) |
|||
.DisposeWith(disposables); |
|||
this.Bind(ViewModel, x => x.ConfirmPassword, x => x.ConfirmPasswordTextBox.Text) |
|||
.DisposeWith(disposables); |
|||
this.BindCommand(ViewModel, x => x.SignUp, x => x.SignUpButton) |
|||
.DisposeWith(disposables); |
|||
|
|||
this.BindValidation(ViewModel, x => x.UserName, x => x.UserNameValidation.Text) |
|||
.DisposeWith(disposables); |
|||
this.BindValidation(ViewModel, x => x.Password, x => x.PasswordValidation.Text) |
|||
.DisposeWith(disposables); |
|||
this.BindValidation(ViewModel, x => x.ConfirmPassword, x => x.ConfirmPasswordValidation.Text) |
|||
.DisposeWith(disposables); |
|||
|
|||
var newLineFormatter = new SingleLineFormatter(Environment.NewLine); |
|||
this.BindValidation(ViewModel, x => x.CompoundValidation.Text, newLineFormatter) |
|||
.DisposeWith(disposables); |
|||
|
|||
// The references to text boxes below are also auto generated.
|
|||
// Use Ctrl+Click in order to view the generated sources.
|
|||
UserNameTextBox.Text = "Joseph!"; |
|||
PasswordTextBox.Text = "1234"; |
|||
ConfirmPasswordTextBox.Text = "1234"; |
|||
SignUpButtonDescription.Text = "Press the button below to sign up."; |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
<IncludeAvaloniaGenerators>true</IncludeAvaloniaGenerators> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<AvaloniaResource Include="**\*.xaml"/> |
|||
<!-- Note this AdditionalFiles directive. --> |
|||
<AdditionalFiles Include="**\*.xaml"/> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="ReactiveUI.Validation" Version="3.0.22"/> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\packages\Avalonia\Avalonia.csproj"/> |
|||
<ProjectReference Include="..\..\src\Avalonia.Desktop\Avalonia.Desktop.csproj"/> |
|||
<ProjectReference Include="..\..\src\Avalonia.ReactiveUI\Avalonia.ReactiveUI.csproj"/> |
|||
<ProjectReference Include="..\..\src\Avalonia.Themes.Fluent\Avalonia.Themes.Fluent.csproj"/> |
|||
<ProjectReference Include="..\..\src\Avalonia.Fonts.Inter\Avalonia.Fonts.Inter.csproj"/> |
|||
</ItemGroup> |
|||
|
|||
<Import Project="..\..\build\BuildTargets.targets"/> |
|||
<Import Project="..\..\build\SourceGenerators.props"/> |
|||
</Project> |
|||
@ -0,0 +1,15 @@ |
|||
using Avalonia; |
|||
using Avalonia.ReactiveUI; |
|||
|
|||
namespace Generators.Sandbox; |
|||
|
|||
internal static class Program |
|||
{ |
|||
public static void Main(string[] args) => BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); |
|||
|
|||
private static AppBuilder BuildAvaloniaApp() |
|||
=> AppBuilder.Configure<App>() |
|||
.UseReactiveUI() |
|||
.UsePlatformDetect() |
|||
.LogToTrace(); |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
using System.Reactive; |
|||
using ReactiveUI; |
|||
using ReactiveUI.Validation.Extensions; |
|||
using ReactiveUI.Validation.Helpers; |
|||
|
|||
namespace Generators.Sandbox.ViewModels; |
|||
|
|||
public class SignUpViewModel : ReactiveValidationObject |
|||
{ |
|||
private string _userName = string.Empty; |
|||
private string _password = string.Empty; |
|||
private string _confirmPassword = string.Empty; |
|||
|
|||
public SignUpViewModel() |
|||
{ |
|||
this.ValidationRule( |
|||
vm => vm.UserName, |
|||
name => !string.IsNullOrWhiteSpace(name), |
|||
"UserName is required."); |
|||
|
|||
this.ValidationRule( |
|||
vm => vm.Password, |
|||
password => !string.IsNullOrWhiteSpace(password), |
|||
"Password is required."); |
|||
|
|||
this.ValidationRule( |
|||
vm => vm.Password, |
|||
password => password?.Length > 2, |
|||
password => $"Password should be longer, current length: {password.Length}"); |
|||
|
|||
this.ValidationRule( |
|||
vm => vm.ConfirmPassword, |
|||
confirmation => !string.IsNullOrWhiteSpace(confirmation), |
|||
"Confirm password field is required."); |
|||
|
|||
var passwordsObservable = |
|||
this.WhenAnyValue( |
|||
x => x.Password, |
|||
x => x.ConfirmPassword, |
|||
(password, confirmation) => |
|||
password == confirmation); |
|||
|
|||
this.ValidationRule( |
|||
vm => vm.ConfirmPassword, |
|||
passwordsObservable, |
|||
"Passwords must match."); |
|||
|
|||
SignUp = ReactiveCommand.Create(() => {}, this.IsValid()); |
|||
} |
|||
|
|||
public ReactiveCommand<Unit, Unit> SignUp { get; } |
|||
|
|||
public string UserName |
|||
{ |
|||
get => _userName; |
|||
set => this.RaiseAndSetIfChanged(ref _userName, value); |
|||
} |
|||
|
|||
public string Password |
|||
{ |
|||
get => _password; |
|||
set => this.RaiseAndSetIfChanged(ref _password, value); |
|||
} |
|||
|
|||
public string ConfirmPassword |
|||
{ |
|||
get => _confirmPassword; |
|||
set => this.RaiseAndSetIfChanged(ref _confirmPassword, value); |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
<Window xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:controls="using:Generators.Sandbox.Controls" |
|||
x:Class="Generators.Sandbox.Views.SignUpView"> |
|||
<StackPanel Margin="10"> |
|||
<TextBlock Text="Sign Up" /> |
|||
<controls:SignUpView x:Name="SignUpControl" /> |
|||
</StackPanel> |
|||
</Window> |
|||
@ -0,0 +1,28 @@ |
|||
using System.Reactive.Disposables; |
|||
using Avalonia.ReactiveUI; |
|||
using Generators.Sandbox.ViewModels; |
|||
using ReactiveUI; |
|||
|
|||
namespace Generators.Sandbox.Views; |
|||
|
|||
/// <summary>
|
|||
/// This is a sample view class with typed x:Name references generated using
|
|||
/// .NET 5 source generators. The class has to be partial because x:Name
|
|||
/// references are living in a separate partial class file. See also:
|
|||
/// https://devblogs.microsoft.com/dotnet/new-c-source-generator-samples/
|
|||
/// </summary>
|
|||
public partial class SignUpView : ReactiveWindow<SignUpViewModel> |
|||
{ |
|||
public SignUpView() |
|||
{ |
|||
// The InitializeComponent method is also generated automatically
|
|||
// and lives in the autogenerated part of the partial class.
|
|||
InitializeComponent(); |
|||
this.WhenActivated(disposables => |
|||
{ |
|||
this.WhenAnyValue(view => view.ViewModel) |
|||
.BindTo(this, view => view.SignUpControl.ViewModel) |
|||
.DisposeWith(disposables); |
|||
}); |
|||
} |
|||
} |
|||
@ -1,41 +1,60 @@ |
|||
<Window xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:integrationTestApp="clr-namespace:IntegrationTestApp" |
|||
x:Class="IntegrationTestApp.ShowWindowTest" |
|||
Name="SecondaryWindow" |
|||
x:DataType="Window" |
|||
Title="Show Window Test"> |
|||
<Grid ColumnDefinitions="Auto,Auto" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto"> |
|||
<Label Grid.Column="0" Grid.Row="1">Client Size</Label> |
|||
<TextBox Name="ClientSize" Grid.Column="1" Grid.Row="1" IsReadOnly="True" |
|||
Text="{Binding ClientSize, Mode=OneWay}"/> |
|||
|
|||
<Label Grid.Column="0" Grid.Row="2">Frame Size</Label> |
|||
<TextBox Name="FrameSize" Grid.Column="1" Grid.Row="2" IsReadOnly="True" |
|||
Text="{Binding FrameSize, Mode=OneWay}"/> |
|||
|
|||
<Label Grid.Column="0" Grid.Row="3">Position</Label> |
|||
<TextBox Name="Position" Grid.Column="1" Grid.Row="3" IsReadOnly="True"/> |
|||
|
|||
<Label Grid.Column="0" Grid.Row="4">Owner Rect</Label> |
|||
<TextBox Name="OwnerRect" Grid.Column="1" Grid.Row="4" IsReadOnly="True"/> |
|||
|
|||
<Label Grid.Column="0" Grid.Row="5">Screen Rect</Label> |
|||
<TextBox Name="ScreenRect" Grid.Column="1" Grid.Row="5" IsReadOnly="True"/> |
|||
|
|||
<Label Grid.Column="0" Grid.Row="6">Scaling</Label> |
|||
<TextBox Name="Scaling" Grid.Column="1" Grid.Row="6" IsReadOnly="True"/> |
|||
|
|||
<Label Grid.Column="0" Grid.Row="7">WindowState</Label> |
|||
<ComboBox Name="WindowState" Grid.Column="1" Grid.Row="7" SelectedIndex="{Binding WindowState}"> |
|||
<ComboBoxItem Name="WindowStateNormal">Normal</ComboBoxItem> |
|||
<ComboBoxItem Name="WindowStateMinimized">Minimized</ComboBoxItem> |
|||
<ComboBoxItem Name="WindowStateMaximized">Maximized</ComboBoxItem> |
|||
<ComboBoxItem Name="WindowStateFullScreen">FullScreen</ComboBoxItem> |
|||
</ComboBox> |
|||
|
|||
<Label Grid.Column="0" Grid.Row="8">Order (mac)</Label> |
|||
<TextBox Name="Order" Grid.Column="1" Grid.Row="8" IsReadOnly="True"/> |
|||
|
|||
<Button Name="HideButton" Grid.Row="9" Command="{Binding $parent[Window].Hide}">Hide</Button> |
|||
</Grid> |
|||
<integrationTestApp:MeasureBorder Name="MyBorder"> |
|||
<Grid ColumnDefinitions="Auto,Auto" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto,Auto"> |
|||
<Label Grid.Column="0" Grid.Row="1">Client Size</Label> |
|||
<TextBox Name="CurrentClientSize" Grid.Column="1" Grid.Row="1" IsReadOnly="True" |
|||
Text="{Binding ClientSize, Mode=OneWay}" /> |
|||
|
|||
<Label Grid.Column="0" Grid.Row="2">Frame Size</Label> |
|||
<TextBox Name="CurrentFrameSize" Grid.Column="1" Grid.Row="2" IsReadOnly="True" |
|||
Text="{Binding FrameSize, Mode=OneWay}" /> |
|||
|
|||
<Label Grid.Column="0" Grid.Row="3">Position</Label> |
|||
<TextBox Name="CurrentPosition" Grid.Column="1" Grid.Row="3" IsReadOnly="True" /> |
|||
|
|||
<Label Grid.Column="0" Grid.Row="4">Owner Rect</Label> |
|||
<TextBox Name="CurrentOwnerRect" Grid.Column="1" Grid.Row="4" IsReadOnly="True" /> |
|||
|
|||
<Label Grid.Column="0" Grid.Row="5">Screen Rect</Label> |
|||
<TextBox Name="CurrentScreenRect" Grid.Column="1" Grid.Row="5" IsReadOnly="True" /> |
|||
|
|||
<Label Grid.Column="0" Grid.Row="6">Scaling</Label> |
|||
<TextBox Name="CurrentScaling" Grid.Column="1" Grid.Row="6" IsReadOnly="True" /> |
|||
|
|||
<Label Grid.Column="0" Grid.Row="7">WindowState</Label> |
|||
<ComboBox Name="CurrentWindowState" Grid.Column="1" Grid.Row="7" SelectedIndex="{Binding WindowState}"> |
|||
<ComboBoxItem Name="WindowStateNormal">Normal</ComboBoxItem> |
|||
<ComboBoxItem Name="WindowStateMinimized">Minimized</ComboBoxItem> |
|||
<ComboBoxItem Name="WindowStateMaximized">Maximized</ComboBoxItem> |
|||
<ComboBoxItem Name="WindowStateFullScreen">FullScreen</ComboBoxItem> |
|||
</ComboBox> |
|||
|
|||
<Label Grid.Column="0" Grid.Row="8">SystemDecorations</Label> |
|||
<ComboBox Name="CurrentSystemDecorations" Grid.Column="1" Grid.Row="8" SelectedIndex="{Binding SystemDecorations}"> |
|||
<ComboBoxItem Name="SystemDecorationsNone">None</ComboBoxItem> |
|||
<ComboBoxItem Name="SystemDecorationsBorderOnly">BorderOnly</ComboBoxItem> |
|||
<ComboBoxItem Name="SystemDecorationsFull">Full</ComboBoxItem> |
|||
</ComboBox> |
|||
|
|||
<CheckBox Name="CurrentExtendClientAreaToDecorationsHint" Grid.ColumnSpan="2" Grid.Row="9" |
|||
IsChecked="{Binding ExtendClientAreaToDecorationsHint}"> |
|||
ExtendClientAreaToDecorationsHint |
|||
</CheckBox> |
|||
|
|||
<Label Grid.Column="0" Grid.Row="10">Order (mac)</Label> |
|||
<TextBox Name="CurrentOrder" Grid.Column="1" Grid.Row="10" IsReadOnly="True" /> |
|||
|
|||
<Label Grid.Row="11" Content="MeasuredWith:" /> |
|||
<TextBlock Grid.Column="1" Grid.Row="11" Name="CurrentMeasuredWithText" Text="{Binding #MyBorder.MeasuredWith}" /> |
|||
|
|||
<Button Name="HideButton" Grid.Row="12" Command="{Binding $parent[Window].Hide}">Hide</Button> |
|||
|
|||
</Grid> |
|||
</integrationTestApp:MeasureBorder> |
|||
</Window> |
|||
|
|||
@ -1,5 +1,12 @@ |
|||
#!/usr/bin/env bash |
|||
|
|||
cd $(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) |
|||
dotnet restore -r osx-arm64 |
|||
dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=osx-arm64 -p:_AvaloniaUseExternalMSBuild=false |
|||
|
|||
arch="x64" |
|||
|
|||
if [[ $(uname -m) == 'arm64' ]]; then |
|||
arch="arm64" |
|||
fi |
|||
|
|||
dotnet restore -r osx-$arch |
|||
dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=osx-$arch -p:_AvaloniaUseExternalMSBuild=false |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue