committed by
GitHub
701 changed files with 34742 additions and 7611 deletions
@ -0,0 +1,5 @@ |
|||||
|
<ProjectConfiguration> |
||||
|
<Settings> |
||||
|
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
||||
|
</Settings> |
||||
|
</ProjectConfiguration> |
||||
@ -1,5 +1,6 @@ |
|||||
<Project> |
<Project> |
||||
<PropertyGroup> |
<PropertyGroup> |
||||
<PackageOutputPath Condition="'$(PackageOutputPath)' == ''">$(MSBuildThisFileDirectory)build-intermediate/nuget</PackageOutputPath> |
<PackageOutputPath Condition="'$(PackageOutputPath)' == ''">$(MSBuildThisFileDirectory)build-intermediate/nuget</PackageOutputPath> |
||||
|
<AvaloniaPreviewerNetCoreToolPath>$(MSBuildThisFileDirectory)\src\tools\Avalonia.Designer.HostApp\bin\$(Configuration)\netcoreapp2.0\Avalonia.Designer.HostApp.dll</AvaloniaPreviewerNetCoreToolPath> |
||||
</PropertyGroup> |
</PropertyGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -1,7 +1,9 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||
|
|
||||
<configuration> |
<configuration> |
||||
<packageSources> |
<packageSources> |
||||
<clear /> |
<clear /> |
||||
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" /> |
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" /> |
||||
|
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" /> |
||||
</packageSources> |
</packageSources> |
||||
</configuration> |
</configuration> |
||||
|
|||||
@ -0,0 +1,12 @@ |
|||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
<PropertyGroup> |
||||
|
<ApiContractPackageVersion>0.10.0-preview3</ApiContractPackageVersion> |
||||
|
<NugetPackageName Condition="'$(PackageId)' != ''">$(PackageId)</NugetPackageName> |
||||
|
<NugetPackageName Condition="'$(PackageId)' == ''">Avalonia</NugetPackageName> |
||||
|
</PropertyGroup> |
||||
|
<ItemGroup> |
||||
|
<PackageDownload Include="$(NugetPackageName)" Version="[$(ApiContractPackageVersion)]" /> |
||||
|
<PackageReference Include="Microsoft.DotNet.ApiCompat" Version="5.0.0-beta.20372.2" PrivateAssets="All" /> |
||||
|
<ResolvedMatchingContract Include="$(NuGetPackageRoot)\$(NugetPackageName.ToLower())\$(ApiContractPackageVersion)\lib\$(TargetFramework)\$(AssemblyName).dll" /> |
||||
|
</ItemGroup> |
||||
|
</Project> |
||||
@ -1,6 +1,6 @@ |
|||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="HarfBuzzSharp" Version="2.6.1" /> |
<PackageReference Include="HarfBuzzSharp" Version="2.6.1.5" /> |
||||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.6.1" /> |
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.6.1.5" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -1,5 +1,5 @@ |
|||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="ReactiveUI" Version="10.3.6" /> |
<PackageReference Include="ReactiveUI" Version="11.5.17" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -1,6 +1,6 @@ |
|||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="SkiaSharp" Version="1.68.2.1" /> |
<PackageReference Include="SkiaSharp" Version="2.80.1" /> |
||||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="1.68.2.1" /> |
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.80.0" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -0,0 +1,160 @@ |
|||||
|
#include "common.h" |
||||
|
|
||||
|
|
||||
|
IAvnNativeControlHostTopLevelAttachment* CreateAttachment(); |
||||
|
|
||||
|
class AvnNativeControlHost : |
||||
|
public ComSingleObject<IAvnNativeControlHost, &IID_IAvnNativeControlHost> |
||||
|
{ |
||||
|
public: |
||||
|
FORWARD_IUNKNOWN(); |
||||
|
NSView* View; |
||||
|
AvnNativeControlHost(NSView* view) |
||||
|
{ |
||||
|
View = view; |
||||
|
} |
||||
|
|
||||
|
virtual HRESULT CreateDefaultChild(void* parent, void** retOut) override |
||||
|
{ |
||||
|
NSView* view = [NSView new]; |
||||
|
[view setWantsLayer: true]; |
||||
|
|
||||
|
*retOut = (__bridge_retained void*)view; |
||||
|
return S_OK; |
||||
|
}; |
||||
|
|
||||
|
virtual IAvnNativeControlHostTopLevelAttachment* CreateAttachment() override |
||||
|
{ |
||||
|
return ::CreateAttachment(); |
||||
|
}; |
||||
|
|
||||
|
virtual void DestroyDefaultChild(void* child) override |
||||
|
{ |
||||
|
// ARC will release the object for us |
||||
|
(__bridge_transfer NSView*) child; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
class AvnNativeControlHostTopLevelAttachment : |
||||
|
public ComSingleObject<IAvnNativeControlHostTopLevelAttachment, &IID_IAvnNativeControlHostTopLevelAttachment> |
||||
|
{ |
||||
|
NSView* _holder; |
||||
|
NSView* _child; |
||||
|
public: |
||||
|
FORWARD_IUNKNOWN(); |
||||
|
|
||||
|
AvnNativeControlHostTopLevelAttachment() |
||||
|
{ |
||||
|
_holder = [NSView new]; |
||||
|
[_holder setWantsLayer:true]; |
||||
|
} |
||||
|
|
||||
|
virtual ~AvnNativeControlHostTopLevelAttachment() |
||||
|
{ |
||||
|
if(_child != nil && [_child superview] == _holder) |
||||
|
{ |
||||
|
[_child removeFromSuperview]; |
||||
|
} |
||||
|
|
||||
|
if([_holder superview] != nil) |
||||
|
{ |
||||
|
[_holder removeFromSuperview]; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
virtual void* GetParentHandle() override |
||||
|
{ |
||||
|
return (__bridge void*)_holder; |
||||
|
}; |
||||
|
|
||||
|
virtual HRESULT InitializeWithChildHandle(void* child) override |
||||
|
{ |
||||
|
if(_child != nil) |
||||
|
return E_FAIL; |
||||
|
_child = (__bridge NSView*)child; |
||||
|
if(_child == nil) |
||||
|
return E_FAIL; |
||||
|
[_holder addSubview:_child]; |
||||
|
[_child setHidden: false]; |
||||
|
return S_OK; |
||||
|
}; |
||||
|
|
||||
|
virtual HRESULT AttachTo(IAvnNativeControlHost* host) override |
||||
|
{ |
||||
|
if(host == nil) |
||||
|
{ |
||||
|
[_holder removeFromSuperview]; |
||||
|
[_holder setHidden: true]; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
AvnNativeControlHost* chost = dynamic_cast<AvnNativeControlHost*>(host); |
||||
|
if(chost == nil || chost->View == nil) |
||||
|
return E_FAIL; |
||||
|
[_holder setHidden:true]; |
||||
|
[chost->View addSubview:_holder]; |
||||
|
} |
||||
|
return S_OK; |
||||
|
}; |
||||
|
|
||||
|
virtual void ShowInBounds(float x, float y, float width, float height) override |
||||
|
{ |
||||
|
if(_child == nil) |
||||
|
return; |
||||
|
if(AvnInsidePotentialDeadlock::IsInside()) |
||||
|
{ |
||||
|
IAvnNativeControlHostTopLevelAttachment* slf = this; |
||||
|
slf->AddRef(); |
||||
|
dispatch_async(dispatch_get_main_queue(), ^{ |
||||
|
slf->ShowInBounds(x, y, width, height); |
||||
|
slf->Release(); |
||||
|
}); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
NSRect childFrame = {0, 0, width, height}; |
||||
|
NSRect holderFrame = {x, y, width, height}; |
||||
|
|
||||
|
[_child setFrame: childFrame]; |
||||
|
[_holder setFrame: holderFrame]; |
||||
|
[_holder setHidden: false]; |
||||
|
if([_holder superview] != nil) |
||||
|
[[_holder superview] setNeedsDisplay:true]; |
||||
|
} |
||||
|
|
||||
|
virtual void HideWithSize(float width, float height) override |
||||
|
{ |
||||
|
if(_child == nil) |
||||
|
return; |
||||
|
if(AvnInsidePotentialDeadlock::IsInside()) |
||||
|
{ |
||||
|
IAvnNativeControlHostTopLevelAttachment* slf = this; |
||||
|
slf->AddRef(); |
||||
|
dispatch_async(dispatch_get_main_queue(), ^{ |
||||
|
slf->HideWithSize(width, height); |
||||
|
slf->Release(); |
||||
|
}); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
NSRect frame = {0, 0, width, height}; |
||||
|
[_holder setHidden: true]; |
||||
|
[_child setFrame: frame]; |
||||
|
} |
||||
|
|
||||
|
virtual void ReleaseChild() override |
||||
|
{ |
||||
|
[_child removeFromSuperview]; |
||||
|
_child = nil; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
IAvnNativeControlHostTopLevelAttachment* CreateAttachment() |
||||
|
{ |
||||
|
return new AvnNativeControlHostTopLevelAttachment(); |
||||
|
} |
||||
|
|
||||
|
extern IAvnNativeControlHost* CreateNativeControlHost(NSView* parent) |
||||
|
{ |
||||
|
return new AvnNativeControlHost(parent); |
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
#include "common.h" |
||||
|
|
||||
|
static int Counter = 0; |
||||
|
AvnInsidePotentialDeadlock::AvnInsidePotentialDeadlock() |
||||
|
{ |
||||
|
Counter++; |
||||
|
} |
||||
|
|
||||
|
AvnInsidePotentialDeadlock::~AvnInsidePotentialDeadlock() |
||||
|
{ |
||||
|
Counter--; |
||||
|
} |
||||
|
|
||||
|
bool AvnInsidePotentialDeadlock::IsInside() |
||||
|
{ |
||||
|
return Counter!=0; |
||||
|
} |
||||
@ -0,0 +1,76 @@ |
|||||
|
using System; |
||||
|
using System.IO; |
||||
|
using System.IO.Compression; |
||||
|
using System.Linq; |
||||
|
using ILRepacking; |
||||
|
using Mono.Cecil; |
||||
|
|
||||
|
public class BuildTasksPatcher |
||||
|
{ |
||||
|
public static void PatchBuildTasksInPackage(string packagePath) |
||||
|
{ |
||||
|
using (var archive = new ZipArchive(File.Open(packagePath, FileMode.Open, FileAccess.ReadWrite), |
||||
|
ZipArchiveMode.Update)) |
||||
|
{ |
||||
|
|
||||
|
foreach (var entry in archive.Entries.ToList()) |
||||
|
{ |
||||
|
if (entry.Name == "Avalonia.Build.Tasks.dll") |
||||
|
{ |
||||
|
var temp = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".dll"); |
||||
|
var output = temp + ".output"; |
||||
|
var patched = new MemoryStream(); |
||||
|
try |
||||
|
{ |
||||
|
entry.ExtractToFile(temp, true); |
||||
|
var repack = new ILRepacking.ILRepack(new RepackOptions() |
||||
|
{ |
||||
|
Internalize = true, |
||||
|
InputAssemblies = new[] |
||||
|
{ |
||||
|
temp, typeof(Mono.Cecil.AssemblyDefinition).Assembly.GetModules()[0] |
||||
|
.FullyQualifiedName |
||||
|
}, |
||||
|
SearchDirectories = new string[0], |
||||
|
OutputFile = output |
||||
|
}); |
||||
|
repack.Repack(); |
||||
|
|
||||
|
|
||||
|
// 'hurr-durr assembly with the same name is already loaded' prevention
|
||||
|
using (var asm = AssemblyDefinition.ReadAssembly(output, |
||||
|
new ReaderParameters { ReadWrite = true, InMemory = true, })) |
||||
|
{ |
||||
|
asm.Name = new AssemblyNameDefinition( |
||||
|
"Avalonia.Build.Tasks." |
||||
|
+ Guid.NewGuid().ToString().Replace("-", ""), |
||||
|
new Version(0, 0, 0)); |
||||
|
asm.Write(patched); |
||||
|
patched.Position = 0; |
||||
|
} |
||||
|
} |
||||
|
finally |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
if (File.Exists(temp)) |
||||
|
File.Delete(temp); |
||||
|
if (File.Exists(output)) |
||||
|
File.Delete(output); |
||||
|
} |
||||
|
catch |
||||
|
{ |
||||
|
//ignore
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
var fn = entry.FullName; |
||||
|
entry.Delete(); |
||||
|
var newEntry = archive.CreateEntry(fn, CompressionLevel.Optimal); |
||||
|
using (var s = newEntry.Open()) |
||||
|
patched.CopyTo(s); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1 +1 @@ |
|||||
Subproject commit 4464343aef5c8ab7a42fcb20a483a6058199f8b8 |
Subproject commit aef10ae67dc55c95f49b52a505a0be33bfa297a5 |
||||
@ -1,3 +1,11 @@ |
|||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
<ItemGroup> |
||||
|
<AvailableItemName Include="AvaloniaXaml" /> |
||||
|
<AvailableItemName Include="AvaloniaResource" /> |
||||
|
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)AvaloniaItemSchema.xaml" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup Condition="'$(EnableDefaultItems)'=='True'"> |
||||
|
<AvaloniaXaml Include="**\*.axaml" SubType="Designer" /> |
||||
|
<AvaloniaXaml Include="**\*.paml" SubType="Designer" /> |
||||
|
</ItemGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -0,0 +1,18 @@ |
|||||
|
<ProjectSchemaDefinitions xmlns="http://schemas.microsoft.com/build/2009/properties"> |
||||
|
<ContentType |
||||
|
Name="AvaloniaXaml" |
||||
|
DisplayName="Avalonia XAML" |
||||
|
ItemType="AvaloniaXaml"> |
||||
|
<NameValuePair Name="DependentFileExtensions" Value=".cs" /> |
||||
|
<NameValuePair Name="DefaultMetadata_SubType" Value="Designer" /> |
||||
|
</ContentType> |
||||
|
|
||||
|
<ItemType Name="AvaloniaXaml" DisplayName="Avalonia XAML" /> |
||||
|
<FileExtension Name=".axaml" ContentType="AvaloniaXaml" /> |
||||
|
<FileExtension Name=".paml" ContentType="AvaloniaXaml" /> |
||||
|
<ContentType |
||||
|
Name="AvaloniaResource" |
||||
|
DisplayName="Avalonia Resource" |
||||
|
ItemType="AvaloniaResource" |
||||
|
/> |
||||
|
</ProjectSchemaDefinitions> |
||||
@ -0,0 +1,139 @@ |
|||||
|
<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" |
||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" |
||||
|
x:Class="ControlCatalog.Pages.AcrylicPage"> |
||||
|
<Border Padding="20" HorizontalAlignment="Center"> |
||||
|
<StackPanel Spacing="20"> |
||||
|
|
||||
|
<ExperimentalAcrylicBorder Width="660" CornerRadius="5"> |
||||
|
<ExperimentalAcrylicBorder.Material> |
||||
|
<ExperimentalAcrylicMaterial |
||||
|
TintColor="White" |
||||
|
BackgroundSource="Digger" /> |
||||
|
</ExperimentalAcrylicBorder.Material> |
||||
|
<StackPanel Spacing="5" Margin="40 10"> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="TintOpacity" Foreground="Black" /> |
||||
|
<Slider Name="TintOpacitySlider" Minimum="0" Maximum="1" Value="0.9" Width="400" /> |
||||
|
<TextBlock Text="{Binding #TintOpacitySlider.Value}" Foreground="Black" /> |
||||
|
</StackPanel> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<TextBlock Text="MaterialOpacity" Foreground="Black" /> |
||||
|
<Slider Name="MaterialOpacitySlider" Minimum="0" Maximum="1" Value="0.8" Width="400" /> |
||||
|
<TextBlock Text="{Binding #MaterialOpacitySlider.Value}" Foreground="Black" /> |
||||
|
</StackPanel> |
||||
|
</StackPanel> |
||||
|
</ExperimentalAcrylicBorder> |
||||
|
|
||||
|
|
||||
|
<StackPanel Orientation="Horizontal" Spacing="20"> |
||||
|
<ExperimentalAcrylicBorder Height="200" Width="200" CornerRadius="5"> |
||||
|
<ExperimentalAcrylicBorder.Material> |
||||
|
<ExperimentalAcrylicMaterial |
||||
|
TintColor="#FF0000" |
||||
|
TintOpacity="{Binding #TintOpacitySlider.Value}" |
||||
|
MaterialOpacity="{Binding #MaterialOpacitySlider.Value}" |
||||
|
BackgroundSource="Digger" /> |
||||
|
</ExperimentalAcrylicBorder.Material> |
||||
|
</ExperimentalAcrylicBorder> |
||||
|
|
||||
|
<ExperimentalAcrylicBorder Height="200" Width="200" CornerRadius="5"> |
||||
|
<ExperimentalAcrylicBorder.Material> |
||||
|
<ExperimentalAcrylicMaterial |
||||
|
TintColor="#00FF00" |
||||
|
TintOpacity="{Binding #TintOpacitySlider.Value}" |
||||
|
MaterialOpacity="{Binding #MaterialOpacitySlider.Value}" |
||||
|
BackgroundSource="Digger" /> |
||||
|
</ExperimentalAcrylicBorder.Material> |
||||
|
</ExperimentalAcrylicBorder> |
||||
|
|
||||
|
<ExperimentalAcrylicBorder Height="200" Width="200" CornerRadius="5"> |
||||
|
<ExperimentalAcrylicBorder.Material> |
||||
|
<ExperimentalAcrylicMaterial |
||||
|
TintColor="#000000" |
||||
|
TintOpacity="{Binding #TintOpacitySlider.Value}" |
||||
|
MaterialOpacity="{Binding #MaterialOpacitySlider.Value}" |
||||
|
BackgroundSource="Digger" /> |
||||
|
</ExperimentalAcrylicBorder.Material> |
||||
|
</ExperimentalAcrylicBorder> |
||||
|
</StackPanel> |
||||
|
|
||||
|
|
||||
|
<StackPanel Orientation="Horizontal" Spacing="20"> |
||||
|
<ExperimentalAcrylicBorder Height="200" Width="200" CornerRadius="5"> |
||||
|
<ExperimentalAcrylicBorder.Material> |
||||
|
<ExperimentalAcrylicMaterial |
||||
|
TintColor="#0000FF" |
||||
|
TintOpacity="{Binding #TintOpacitySlider.Value}" |
||||
|
MaterialOpacity="{Binding #MaterialOpacitySlider.Value}" |
||||
|
BackgroundSource="Digger" /> |
||||
|
</ExperimentalAcrylicBorder.Material> |
||||
|
</ExperimentalAcrylicBorder> |
||||
|
|
||||
|
<ExperimentalAcrylicBorder Height="200" Width="200" CornerRadius="5"> |
||||
|
<ExperimentalAcrylicBorder.Material> |
||||
|
<ExperimentalAcrylicMaterial |
||||
|
TintColor="#FFFF00" |
||||
|
TintOpacity="{Binding #TintOpacitySlider.Value}" |
||||
|
MaterialOpacity="{Binding #MaterialOpacitySlider.Value}" |
||||
|
BackgroundSource="Digger" /> |
||||
|
</ExperimentalAcrylicBorder.Material> |
||||
|
</ExperimentalAcrylicBorder> |
||||
|
|
||||
|
<ExperimentalAcrylicBorder Height="200" Width="200" CornerRadius="5"> |
||||
|
<ExperimentalAcrylicBorder.Material> |
||||
|
<ExperimentalAcrylicMaterial |
||||
|
TintColor="#000000" |
||||
|
TintOpacity="{Binding #TintOpacitySlider.Value}" |
||||
|
MaterialOpacity="{Binding #MaterialOpacitySlider.Value}" |
||||
|
BackgroundSource="Digger" /> |
||||
|
</ExperimentalAcrylicBorder.Material> |
||||
|
</ExperimentalAcrylicBorder> |
||||
|
</StackPanel> |
||||
|
|
||||
|
<StackPanel Orientation="Horizontal" Spacing="20"> |
||||
|
<ExperimentalAcrylicBorder Height="200" Width="200" CornerRadius="5"> |
||||
|
<ExperimentalAcrylicBorder.Material> |
||||
|
<ExperimentalAcrylicMaterial |
||||
|
TintColor="White" |
||||
|
TintOpacity="{Binding #TintOpacitySlider.Value}" |
||||
|
MaterialOpacity="{Binding #MaterialOpacitySlider.Value}" |
||||
|
BackgroundSource="Digger" /> |
||||
|
</ExperimentalAcrylicBorder.Material> |
||||
|
</ExperimentalAcrylicBorder> |
||||
|
|
||||
|
<ExperimentalAcrylicBorder Height="200" Width="200" CornerRadius="5"> |
||||
|
<ExperimentalAcrylicBorder.Material> |
||||
|
<ExperimentalAcrylicMaterial |
||||
|
TintColor="#3c3c3c" |
||||
|
TintOpacity="{Binding #TintOpacitySlider.Value}" |
||||
|
MaterialOpacity="{Binding #MaterialOpacitySlider.Value}" |
||||
|
BackgroundSource="Digger" /> |
||||
|
</ExperimentalAcrylicBorder.Material> |
||||
|
</ExperimentalAcrylicBorder> |
||||
|
|
||||
|
<ExperimentalAcrylicBorder Height="200" Width="200" CornerRadius="5"> |
||||
|
<ExperimentalAcrylicBorder.Material> |
||||
|
<ExperimentalAcrylicMaterial |
||||
|
TintColor="White" |
||||
|
TintOpacity="{Binding #TintOpacitySlider.Value}" |
||||
|
MaterialOpacity="{Binding #MaterialOpacitySlider.Value}" |
||||
|
BackgroundSource="Digger" /> |
||||
|
</ExperimentalAcrylicBorder.Material> |
||||
|
</ExperimentalAcrylicBorder> |
||||
|
</StackPanel> |
||||
|
|
||||
|
<ExperimentalAcrylicBorder Height="200" Width="660" CornerRadius="5"> |
||||
|
<ExperimentalAcrylicBorder.Material> |
||||
|
<ExperimentalAcrylicMaterial |
||||
|
TintColor="Red" |
||||
|
TintOpacity="{Binding #TintOpacitySlider.Value}" |
||||
|
MaterialOpacity="{Binding #MaterialOpacitySlider.Value}" |
||||
|
BackgroundSource="Digger" /> |
||||
|
</ExperimentalAcrylicBorder.Material> |
||||
|
</ExperimentalAcrylicBorder> |
||||
|
</StackPanel> |
||||
|
</Border> |
||||
|
</UserControl> |
||||
@ -0,0 +1,19 @@ |
|||||
|
using Avalonia; |
||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.Markup.Xaml; |
||||
|
|
||||
|
namespace ControlCatalog.Pages |
||||
|
{ |
||||
|
public class AcrylicPage : UserControl |
||||
|
{ |
||||
|
public AcrylicPage() |
||||
|
{ |
||||
|
this.InitializeComponent(); |
||||
|
} |
||||
|
|
||||
|
private void InitializeComponent() |
||||
|
{ |
||||
|
AvaloniaXamlLoader.Load(this); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,123 @@ |
|||||
|
<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" |
||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" |
||||
|
x:Class="ControlCatalog.Pages.DateTimePickerPage"> |
||||
|
<StackPanel Orientation="Vertical" Spacing="4" HorizontalAlignment="Stretch"> |
||||
|
<TextBlock Classes="h1">DatePicker and TimePicker</TextBlock> |
||||
|
<TextBlock Name="DatePickerDesc" Classes="h2" TextWrapping="Wrap"/> |
||||
|
<TextBlock Name="TimePickerDesc" Classes="h2" TextWrapping="Wrap"/> |
||||
|
|
||||
|
<StackPanel Orientation="Vertical" |
||||
|
Margin="16" |
||||
|
HorizontalAlignment="Stretch" |
||||
|
Spacing="16"> |
||||
|
<TextBlock FontSize="18">A simple DatePicker with a header</TextBlock> |
||||
|
<StackPanel Orientation="Vertical"> |
||||
|
<Border BorderBrush="{DynamicResource SystemControlHighlightBaseLowBrush}" |
||||
|
BorderThickness="1" Padding="15"> |
||||
|
<DatePicker Header="Pick a date" /> |
||||
|
</Border> |
||||
|
<Panel Background="{DynamicResource SystemControlBackgroundBaseLowBrush}"> |
||||
|
<TextBlock Padding="15"> |
||||
|
<TextBlock.Text> |
||||
|
<x:String> |
||||
|
<DatePicker Header="Pick a date" /> |
||||
|
</x:String> |
||||
|
</TextBlock.Text> |
||||
|
</TextBlock> |
||||
|
</Panel> |
||||
|
</StackPanel> |
||||
|
|
||||
|
<TextBlock FontSize="18">A DatePicker with day formatted and year hidden.</TextBlock> |
||||
|
<StackPanel Orientation="Vertical"> |
||||
|
<Border BorderBrush="{DynamicResource SystemControlHighlightBaseLowBrush}" |
||||
|
BorderThickness="1" Padding="15"> |
||||
|
<DatePicker x:Name="Control2" DayFormat="d (ddd)" |
||||
|
YearVisible="False" /> |
||||
|
</Border> |
||||
|
<Panel Background="{DynamicResource SystemControlBackgroundBaseLowBrush}"> |
||||
|
<TextBlock Padding="15"> |
||||
|
<TextBlock.Text> |
||||
|
<x:String> |
||||
|
<DatePicker DayFormat="d (ddd)" YearVisible="False" /> |
||||
|
</x:String> |
||||
|
</TextBlock.Text> |
||||
|
</TextBlock> |
||||
|
</Panel> |
||||
|
</StackPanel> |
||||
|
|
||||
|
<Border Background="{DynamicResource SystemControlHighlightBaseLowBrush}" BorderThickness="1" Margin="15" /> |
||||
|
|
||||
|
<TextBlock FontSize="18">A simple TimePicker.</TextBlock> |
||||
|
<StackPanel Orientation="Vertical"> |
||||
|
<Border BorderBrush="{DynamicResource SystemControlHighlightBaseLowBrush}" |
||||
|
BorderThickness="1" Padding="15"> |
||||
|
<TimePicker /> |
||||
|
</Border> |
||||
|
<Panel Background="{DynamicResource SystemControlBackgroundBaseLowBrush}"> |
||||
|
<TextBlock Padding="15"> |
||||
|
<TextBlock.Text> |
||||
|
<x:String> |
||||
|
<TimePicker /> |
||||
|
</x:String> |
||||
|
</TextBlock.Text> |
||||
|
</TextBlock> |
||||
|
</Panel> |
||||
|
</StackPanel> |
||||
|
|
||||
|
<TextBlock FontSize="18">A TimePicker with a header and minute increments specified.</TextBlock> |
||||
|
<StackPanel Orientation="Vertical"> |
||||
|
<Border BorderBrush="{DynamicResource SystemControlHighlightBaseLowBrush}" |
||||
|
BorderThickness="1" Padding="15"> |
||||
|
<TimePicker Header="Arrival time" MinuteIncrement="15" /> |
||||
|
</Border> |
||||
|
<Panel Background="{DynamicResource SystemControlBackgroundBaseLowBrush}"> |
||||
|
<TextBlock Padding="15"> |
||||
|
<TextBlock.Text> |
||||
|
<x:String> |
||||
|
<TimePicker Header="Arrival time" MinuteIncrement="15" /> |
||||
|
</x:String> |
||||
|
</TextBlock.Text> |
||||
|
</TextBlock> |
||||
|
</Panel> |
||||
|
</StackPanel> |
||||
|
|
||||
|
<TextBlock FontSize="18">A TimePicker using a 12-hour clock.</TextBlock> |
||||
|
<StackPanel Orientation="Vertical"> |
||||
|
<Border BorderBrush="{DynamicResource SystemControlHighlightBaseLowBrush}" |
||||
|
BorderThickness="1" Padding="15"> |
||||
|
<TimePicker ClockIdentifier="12HourClock" Header="12 hour clock" /> |
||||
|
</Border> |
||||
|
<Panel Background="{DynamicResource SystemControlBackgroundBaseLowBrush}"> |
||||
|
<TextBlock Padding="15"> |
||||
|
<TextBlock.Text> |
||||
|
<x:String> |
||||
|
<TimePicker ClockIdentifier="12HourClock" Header="12 hour clock" /> |
||||
|
</x:String> |
||||
|
</TextBlock.Text> |
||||
|
</TextBlock> |
||||
|
</Panel> |
||||
|
</StackPanel> |
||||
|
|
||||
|
<TextBlock FontSize="18">A TimePicker using a 24-hour clock.</TextBlock> |
||||
|
<StackPanel Orientation="Vertical"> |
||||
|
<Border BorderBrush="{DynamicResource SystemControlHighlightBaseLowBrush}" |
||||
|
BorderThickness="1" Padding="15"> |
||||
|
<TimePicker ClockIdentifier="24HourClock" Header="24 hour clock" /> |
||||
|
</Border> |
||||
|
<Panel Background="{DynamicResource SystemControlBackgroundBaseLowBrush}"> |
||||
|
<TextBlock Padding="15"> |
||||
|
<TextBlock.Text> |
||||
|
<x:String> |
||||
|
<TimePicker ClockIdentifier="24HourClock" Header="24 hour clock" /> |
||||
|
</x:String> |
||||
|
</TextBlock.Text> |
||||
|
</TextBlock> |
||||
|
</Panel> |
||||
|
</StackPanel> |
||||
|
|
||||
|
</StackPanel> |
||||
|
</StackPanel> |
||||
|
</UserControl> |
||||
@ -0,0 +1,30 @@ |
|||||
|
using Avalonia; |
||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.Markup.Xaml; |
||||
|
|
||||
|
namespace ControlCatalog.Pages |
||||
|
{ |
||||
|
public class DateTimePickerPage : UserControl |
||||
|
{ |
||||
|
public DateTimePickerPage() |
||||
|
{ |
||||
|
this.InitializeComponent(); |
||||
|
this.FindControl<TextBlock>("DatePickerDesc").Text = "Use a DatePicker to let users set a date in your app, " + |
||||
|
"for example to schedule an appointment. The DatePicker displays three controls for month, day, and year. " + |
||||
|
"These controls are easy to use with touch or mouse, and they can be styled and configured in several different ways. " + |
||||
|
"Order of month, day, and year is dynamically set based on user date settings"; |
||||
|
|
||||
|
this.FindControl<TextBlock>("TimePickerDesc").Text = "Use a TimePicker to let users set a time in your app, for example " + |
||||
|
"to set a reminder. The TimePicker displays three controls for hour, minute, and AM / PM(if necessary).These controls " + |
||||
|
"are easy to use with touch or mouse, and they can be styled and configured in several different ways. " + |
||||
|
"12 - hour or 24 - hour clock and visiblility of AM / PM is dynamically set based on user time settings, or can be overridden."; |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
private void InitializeComponent() |
||||
|
{ |
||||
|
AvaloniaXamlLoader.Load(this); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,60 @@ |
|||||
|
<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" |
||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" |
||||
|
x:Class="ControlCatalog.Pages.RelativePanelPage"> |
||||
|
<RelativePanel Width="620" Height="700" Margin="32"> |
||||
|
<Border Name="Rect1" Background="Red" Height="50" Width="50"> |
||||
|
<TextBlock Text="Rect1" Foreground="White" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/> |
||||
|
</Border> |
||||
|
<Border Name="Rect2" Background="Blue" Height="50" Width="50" RelativePanel.AlignHorizontalCenterWithPanel="True"> |
||||
|
<TextBlock Text="Rect2" Foreground="White" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/> |
||||
|
</Border> |
||||
|
<Border Name="Rect3" Background="Green" Height="50" Width="50" RelativePanel.AlignRightWithPanel="True"> |
||||
|
<TextBlock Text="Rect3" Foreground="White" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/> |
||||
|
</Border> |
||||
|
<Border Name="Rect4" Background="Red" Height="50" Width="50" RelativePanel.AlignBottomWithPanel="True"> |
||||
|
<TextBlock Text="Rect4" Foreground="White" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/> |
||||
|
</Border> |
||||
|
<Border Name="Rect5" Background="Blue" Height="50" Width="50" RelativePanel.AlignBottomWithPanel="True" RelativePanel.AlignHorizontalCenterWithPanel="True"> |
||||
|
<TextBlock Text="Rect5" Foreground="White" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/> |
||||
|
</Border> |
||||
|
<Border Name="Rect6" Background="Green" Height="50" Width="50" RelativePanel.AlignBottomWithPanel="True" RelativePanel.AlignRightWithPanel="True"> |
||||
|
<TextBlock Text="Rect6" Foreground="White" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/> |
||||
|
</Border> |
||||
|
<Border Name="Rect7" Background="Blue" Height="50" RelativePanel.RightOf="{Binding ElementName=Rect1}"> |
||||
|
<TextBlock Text="Rect7 (RightOf Rect1)" Padding="10,0" Foreground="White" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/> |
||||
|
</Border> |
||||
|
<Border Name="Rect8" Background="Green" Height="50" RelativePanel.Below="{Binding ElementName=Rect7}"> |
||||
|
<TextBlock Text="Rect8 (Below Rect7)" Padding="10,0" Foreground="White" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/> |
||||
|
</Border> |
||||
|
<Border Name="Rect9" Background="Blue" Height="140" Width="460" RelativePanel.AlignHorizontalCenterWithPanel="True" RelativePanel.AlignVerticalCenterWithPanel="True"> |
||||
|
<TextBlock Text="Rect9" Padding="10" Foreground="White" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Top"/> |
||||
|
</Border> |
||||
|
<Border Name="Rect10" Background="Red" Width="50" RelativePanel.RightOf="{Binding ElementName=Rect9}" RelativePanel.AlignVerticalCenterWith="{Binding ElementName=Rect9}"> |
||||
|
<TextBlock Text="Rect14 (RightOf Rect9, AlignVerticalCenterWith Rect9)" Padding="10,0" Foreground="White" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"> |
||||
|
<TextBlock.RenderTransform> |
||||
|
<TransformGroup> |
||||
|
<RotateTransform Angle="-90"/> |
||||
|
</TransformGroup> |
||||
|
</TextBlock.RenderTransform> |
||||
|
</TextBlock> |
||||
|
</Border> |
||||
|
<Border Name="Rect11" Background="Red" Height="50" RelativePanel.AlignBottomWith="{Binding ElementName=Rect9}" RelativePanel.AlignHorizontalCenterWith="{Binding ElementName=Rect9}"> |
||||
|
<TextBlock Text="Rect11 (AlignBottomWith Rect9, AlignHorizontalCenterWith Rect9)" Padding="10,0" Foreground="White" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/> |
||||
|
</Border> |
||||
|
<Border Name="Rect12" Background="Red" Height="50" RelativePanel.Below="{Binding ElementName=Rect8}" RelativePanel.AlignLeftWith="{Binding ElementName=Rect7}"> |
||||
|
<TextBlock Text="Rect12 (Below Rect8, AlignLeftWith Rect7)" Padding="10,0" Foreground="White" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/> |
||||
|
</Border> |
||||
|
<Border Name="Rect13" Background="Blue" Height="50" RelativePanel.Below="{Binding ElementName=Rect12}" RelativePanel.AlignRightWith="{Binding ElementName=Rect12}"> |
||||
|
<TextBlock Text="Rect13 (Below Rect12, AlignRightWith Rect12)" Padding="10,0" Foreground="White" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/> |
||||
|
</Border> |
||||
|
<Border Name="Rect14" Background="Green" Height="50" RelativePanel.Above="{Binding ElementName=Rect9}" RelativePanel.AlignRightWith="{Binding ElementName=Rect9}"> |
||||
|
<TextBlock Text="Rect14 (Above Rect9, AlignRightWith Rect9)" Padding="10,0" Foreground="White" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/> |
||||
|
</Border> |
||||
|
<Border Name="Rect15" Background="Red" Height="50" RelativePanel.LeftOf="{Binding ElementName=Rect2}" RelativePanel.AlignTopWith="{Binding ElementName=Rect9}"> |
||||
|
<TextBlock Text="Rect15 (LeftOf Rect2, AlignTopWith Rect9)" Padding="10,0" Foreground="White" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/> |
||||
|
</Border> |
||||
|
</RelativePanel> |
||||
|
</UserControl> |
||||
@ -0,0 +1,19 @@ |
|||||
|
using Avalonia; |
||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.Markup.Xaml; |
||||
|
|
||||
|
namespace ControlCatalog.Pages |
||||
|
{ |
||||
|
public class RelativePanelPage : UserControl |
||||
|
{ |
||||
|
public RelativePanelPage() |
||||
|
{ |
||||
|
this.InitializeComponent(); |
||||
|
} |
||||
|
|
||||
|
private void InitializeComponent() |
||||
|
{ |
||||
|
AvaloniaXamlLoader.Load(this); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,97 @@ |
|||||
|
<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" |
||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" |
||||
|
x:Class="ControlCatalog.Pages.SplitViewPage"> |
||||
|
|
||||
|
<Border> |
||||
|
|
||||
|
<Grid ColumnDefinitions="*,225"> |
||||
|
|
||||
|
<StackPanel Grid.Column="1" Orientation="Vertical" Spacing="4" Margin="5"> |
||||
|
<ToggleButton Name="PaneOpenButton" |
||||
|
Content="IsPaneOpen" |
||||
|
IsChecked="{Binding IsPaneOpen, ElementName=SplitView}" /> |
||||
|
|
||||
|
<ToggleButton Name="UseLightDismissOverlayModeButton" |
||||
|
Content="UseLightDismissOverlayMode" |
||||
|
IsChecked="{Binding UseLightDismissOverlayMode, ElementName=SplitView}" /> |
||||
|
|
||||
|
<ToggleSwitch OffContent="Left" OnContent="Right" Content="Placement" IsChecked="{Binding !IsLeft}" /> |
||||
|
|
||||
|
<TextBlock Text="DisplayMode" /> |
||||
|
<ComboBox Name="DisplayModeSelector" Width="170" Margin="10" SelectedIndex="{Binding DisplayMode}"> |
||||
|
<ComboBoxItem>Inline</ComboBoxItem> |
||||
|
<ComboBoxItem>CompactInline</ComboBoxItem> |
||||
|
<ComboBoxItem>Overlay</ComboBoxItem> |
||||
|
<ComboBoxItem>CompactOverlay</ComboBoxItem> |
||||
|
</ComboBox> |
||||
|
|
||||
|
<TextBlock Text="PaneBackground" /> |
||||
|
<ComboBox Name="PaneBackgroundSelector" SelectedIndex="0" Width="170" Margin="10"> |
||||
|
<ComboBoxItem Tag="{DynamicResource SystemControlBackgroundChromeMediumLowBrush}">SystemControlBackgroundChromeMediumLowBrush</ComboBoxItem> |
||||
|
<ComboBoxItem Tag="Red">Red</ComboBoxItem> |
||||
|
<ComboBoxItem Tag="Blue">Blue</ComboBoxItem> |
||||
|
<ComboBoxItem Tag="Green">Green</ComboBoxItem> |
||||
|
</ComboBox> |
||||
|
|
||||
|
<TextBlock Text="{Binding Value, ElementName=OpenPaneLengthSlider, StringFormat='{}OpenPaneLength: {0}'}" /> |
||||
|
<Slider Name="OpenPaneLengthSlider" Value="256" Minimum="128" Maximum="500" |
||||
|
Width="150" /> |
||||
|
|
||||
|
<TextBlock Text="{Binding Value, ElementName=CompactPaneLengthSlider, StringFormat='{}CompactPaneLength: {0}'}" /> |
||||
|
<Slider Name="CompactPaneLengthSlider" Value="48" Minimum="24" Maximum="128" |
||||
|
Width="150" /> |
||||
|
|
||||
|
</StackPanel> |
||||
|
|
||||
|
<Border BorderBrush="{DynamicResource SystemControlHighlightBaseLowBrush}" |
||||
|
BorderThickness="1"> |
||||
|
<!--{Binding SelectedItem.Tag, ElementName=PaneBackgroundSelector}--> |
||||
|
<SplitView Name="SplitView" |
||||
|
PanePlacement="{Binding PanePlacement}" |
||||
|
PaneBackground="{Binding SelectedItem.Tag, ElementName=PaneBackgroundSelector}" |
||||
|
OpenPaneLength="{Binding Value, ElementName=OpenPaneLengthSlider}" |
||||
|
CompactPaneLength="{Binding Value, ElementName=CompactPaneLengthSlider}" |
||||
|
DisplayMode="{Binding CurrentDisplayMode}"> |
||||
|
<SplitView.Pane> |
||||
|
<Grid> |
||||
|
<Grid.RowDefinitions> |
||||
|
<RowDefinition Height="Auto" /> |
||||
|
<RowDefinition Height="*" /> |
||||
|
<RowDefinition Height="Auto" /> |
||||
|
</Grid.RowDefinitions> |
||||
|
<TextBlock Text="PANE CONTENT" FontWeight="Bold" Name="PaneHeader" Margin="5,12,0,0" /> |
||||
|
<ListBoxItem Grid.Row="1" VerticalAlignment="Top" Margin="0 10"> |
||||
|
<StackPanel Orientation="Horizontal"> |
||||
|
<!--Path glyph from materialdesignicons.com--> |
||||
|
<Border Width="48"> |
||||
|
<Viewbox Width="24" Height="24" HorizontalAlignment="Left"> |
||||
|
<Canvas Width="24" Height="24"> |
||||
|
<Path Fill="{DynamicResource SystemControlForegroundBaseHighBrush}" Data="M16 17V19H2V17S2 13 9 13 16 17 16 17M12.5 7.5A3.5 3.5 0 1 0 9 11A3.5 3.5 0 0 0 12.5 7.5M15.94 13A5.32 5.32 0 0 1 18 17V19H22V17S22 13.37 15.94 13M15 4A3.39 3.39 0 0 0 13.07 4.59A5 5 0 0 1 13.07 10.41A3.39 3.39 0 0 0 15 11A3.5 3.5 0 0 0 15 4Z" /> |
||||
|
</Canvas> |
||||
|
</Viewbox> |
||||
|
</Border> |
||||
|
<TextBlock Text="People" VerticalAlignment="Center" /> |
||||
|
</StackPanel> |
||||
|
</ListBoxItem> |
||||
|
<TextBlock Grid.Row="2" Text="Item at bottom" Margin="60,12" /> |
||||
|
</Grid> |
||||
|
</SplitView.Pane> |
||||
|
|
||||
|
<Grid> |
||||
|
<TextBlock FontSize="14" FontWeight="700" Text="SplitViewContent" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{DynamicResource SystemControlForegroundBaseHighBrush}" /> |
||||
|
<TextBlock FontSize="14" FontWeight="700" Text="SplitViewContent" TextAlignment="Left" Foreground="{DynamicResource SystemControlForegroundBaseHighBrush}" /> |
||||
|
<TextBlock FontSize="14" FontWeight="700" Text="SplitViewContent" HorizontalAlignment="Right" TextAlignment="Left" Foreground="{DynamicResource SystemControlForegroundBaseHighBrush}" /> |
||||
|
<TextBlock FontSize="14" FontWeight="700" Text="SplitViewContent" VerticalAlignment="Bottom" TextAlignment="Left" Foreground="{DynamicResource SystemControlForegroundBaseHighBrush}" /> |
||||
|
<TextBlock FontSize="14" FontWeight="700" Text="SplitViewContent" VerticalAlignment="Bottom" HorizontalAlignment="Right" TextAlignment="Left" Foreground="{DynamicResource SystemControlForegroundBaseHighBrush}" /> |
||||
|
</Grid> |
||||
|
|
||||
|
</SplitView> |
||||
|
</Border> |
||||
|
|
||||
|
</Grid> |
||||
|
</Border> |
||||
|
|
||||
|
</UserControl> |
||||
@ -0,0 +1,21 @@ |
|||||
|
using Avalonia; |
||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.Markup.Xaml; |
||||
|
using ControlCatalog.ViewModels; |
||||
|
|
||||
|
namespace ControlCatalog.Pages |
||||
|
{ |
||||
|
public class SplitViewPage : UserControl |
||||
|
{ |
||||
|
public SplitViewPage() |
||||
|
{ |
||||
|
this.InitializeComponent(); |
||||
|
DataContext = new SplitViewPageViewModel(); |
||||
|
} |
||||
|
|
||||
|
private void InitializeComponent() |
||||
|
{ |
||||
|
AvaloniaXamlLoader.Load(this); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
<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" |
||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" |
||||
|
x:Class="ControlCatalog.Pages.WindowCustomizationsPage"> |
||||
|
<StackPanel Spacing="10" Margin="25"> |
||||
|
<CheckBox Content="Extend Client Area to Decorations" IsChecked="{Binding ExtendClientAreaEnabled}" /> |
||||
|
<CheckBox Content="Title Bar" IsChecked="{Binding SystemTitleBarEnabled}" /> |
||||
|
<CheckBox Content="Prefer System Chrome" IsChecked="{Binding PreferSystemChromeEnabled}" /> |
||||
|
<Slider Minimum="-1" Maximum="200" Value="{Binding TitleBarHeight}" /> |
||||
|
<ComboBox x:Name="TransparencyLevels" SelectedIndex="{Binding TransparencyLevel}"> |
||||
|
<ComboBoxItem>None</ComboBoxItem> |
||||
|
<ComboBoxItem>Transparent</ComboBoxItem> |
||||
|
<ComboBoxItem>Blur</ComboBoxItem> |
||||
|
<ComboBoxItem>AcrylicBlur</ComboBoxItem> |
||||
|
</ComboBox> |
||||
|
</StackPanel> |
||||
|
</UserControl> |
||||
@ -0,0 +1,19 @@ |
|||||
|
using Avalonia; |
||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.Markup.Xaml; |
||||
|
|
||||
|
namespace ControlCatalog.Pages |
||||
|
{ |
||||
|
public class WindowCustomizationsPage : UserControl |
||||
|
{ |
||||
|
public WindowCustomizationsPage() |
||||
|
{ |
||||
|
this.InitializeComponent(); |
||||
|
} |
||||
|
|
||||
|
private void InitializeComponent() |
||||
|
{ |
||||
|
AvaloniaXamlLoader.Load(this); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,65 @@ |
|||||
|
using System; |
||||
|
using System.Collections.ObjectModel; |
||||
|
using System.Linq; |
||||
|
using System.Reactive; |
||||
|
using Avalonia.Controls; |
||||
|
using ReactiveUI; |
||||
|
|
||||
|
namespace ControlCatalog.ViewModels |
||||
|
{ |
||||
|
public class ListBoxPageViewModel : ReactiveObject |
||||
|
{ |
||||
|
private int _counter; |
||||
|
private SelectionMode _selectionMode; |
||||
|
|
||||
|
public ListBoxPageViewModel() |
||||
|
{ |
||||
|
Items = new ObservableCollection<string>(Enumerable.Range(1, 10000).Select(i => GenerateItem())); |
||||
|
Selection = new SelectionModel(); |
||||
|
Selection.Select(1); |
||||
|
|
||||
|
AddItemCommand = ReactiveCommand.Create(() => Items.Add(GenerateItem())); |
||||
|
|
||||
|
RemoveItemCommand = ReactiveCommand.Create(() => |
||||
|
{ |
||||
|
while (Selection.SelectedItems.Count > 0) |
||||
|
{ |
||||
|
Items.Remove((string)Selection.SelectedItems.First()); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
SelectRandomItemCommand = ReactiveCommand.Create(() => |
||||
|
{ |
||||
|
var random = new Random(); |
||||
|
|
||||
|
using (Selection.Update()) |
||||
|
{ |
||||
|
Selection.ClearSelection(); |
||||
|
Selection.Select(random.Next(Items.Count - 1)); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
public ObservableCollection<string> Items { get; } |
||||
|
|
||||
|
public SelectionModel Selection { get; } |
||||
|
|
||||
|
public ReactiveCommand<Unit, Unit> AddItemCommand { get; } |
||||
|
|
||||
|
public ReactiveCommand<Unit, Unit> RemoveItemCommand { get; } |
||||
|
|
||||
|
public ReactiveCommand<Unit, Unit> SelectRandomItemCommand { get; } |
||||
|
|
||||
|
public SelectionMode SelectionMode |
||||
|
{ |
||||
|
get => _selectionMode; |
||||
|
set |
||||
|
{ |
||||
|
Selection.ClearSelection(); |
||||
|
this.RaiseAndSetIfChanged(ref _selectionMode, value); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private string GenerateItem() => $"Item {_counter++.ToString()}"; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,46 @@ |
|||||
|
using System; |
||||
|
using Avalonia.Controls; |
||||
|
using ReactiveUI; |
||||
|
|
||||
|
namespace ControlCatalog.ViewModels |
||||
|
{ |
||||
|
public class SplitViewPageViewModel : ReactiveObject |
||||
|
{ |
||||
|
private bool _isLeft = true; |
||||
|
private int _displayMode = 3; //CompactOverlay
|
||||
|
|
||||
|
public bool IsLeft |
||||
|
{ |
||||
|
get => _isLeft; |
||||
|
set |
||||
|
{ |
||||
|
this.RaiseAndSetIfChanged(ref _isLeft, value); |
||||
|
this.RaisePropertyChanged(nameof(PanePlacement)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public int DisplayMode |
||||
|
{ |
||||
|
get => _displayMode; |
||||
|
set |
||||
|
{ |
||||
|
this.RaiseAndSetIfChanged(ref _displayMode, value); |
||||
|
this.RaisePropertyChanged(nameof(CurrentDisplayMode)); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public SplitViewPanePlacement PanePlacement => _isLeft ? SplitViewPanePlacement.Left : SplitViewPanePlacement.Right; |
||||
|
|
||||
|
public SplitViewDisplayMode CurrentDisplayMode |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
if (Enum.IsDefined(typeof(SplitViewDisplayMode), _displayMode)) |
||||
|
{ |
||||
|
return (SplitViewDisplayMode)_displayMode; |
||||
|
} |
||||
|
return SplitViewDisplayMode.CompactOverlay; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,92 @@ |
|||||
|
using System.Diagnostics; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using Avalonia; |
||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.LogicalTree; |
||||
|
using Avalonia.Media; |
||||
|
using Avalonia.Media.Imaging; |
||||
|
using Avalonia.Media.Immutable; |
||||
|
using Avalonia.Platform; |
||||
|
using Avalonia.Threading; |
||||
|
|
||||
|
namespace RenderDemo.Pages |
||||
|
{ |
||||
|
public class WriteableBitmapPage : Control |
||||
|
{ |
||||
|
private WriteableBitmap _unpremulBitmap; |
||||
|
private WriteableBitmap _premulBitmap; |
||||
|
private readonly Stopwatch _st = Stopwatch.StartNew(); |
||||
|
|
||||
|
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) |
||||
|
{ |
||||
|
_unpremulBitmap = new WriteableBitmap(new PixelSize(256, 256), new Vector(96, 96), PixelFormat.Bgra8888, AlphaFormat.Unpremul); |
||||
|
_premulBitmap = new WriteableBitmap(new PixelSize(256, 256), new Vector(96, 96), PixelFormat.Bgra8888, AlphaFormat.Premul); |
||||
|
|
||||
|
base.OnAttachedToLogicalTree(e); |
||||
|
} |
||||
|
|
||||
|
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) |
||||
|
{ |
||||
|
base.OnDetachedFromLogicalTree(e); |
||||
|
|
||||
|
_unpremulBitmap?.Dispose(); |
||||
|
_unpremulBitmap = null; |
||||
|
|
||||
|
_premulBitmap?.Dispose(); |
||||
|
_unpremulBitmap = null; |
||||
|
} |
||||
|
|
||||
|
public override void Render(DrawingContext context) |
||||
|
{ |
||||
|
void FillPixels(WriteableBitmap bitmap, byte fillAlpha, bool premul) |
||||
|
{ |
||||
|
using (var fb = bitmap.Lock()) |
||||
|
{ |
||||
|
var data = new int[fb.Size.Width * fb.Size.Height]; |
||||
|
|
||||
|
for (int y = 0; y < fb.Size.Height; y++) |
||||
|
{ |
||||
|
for (int x = 0; x < fb.Size.Width; x++) |
||||
|
{ |
||||
|
var color = new Color(fillAlpha, 0, 255, 0); |
||||
|
|
||||
|
if (premul) |
||||
|
{ |
||||
|
byte r = (byte) (color.R * color.A / 255); |
||||
|
byte g = (byte) (color.G * color.A / 255); |
||||
|
byte b = (byte) (color.B * color.A / 255); |
||||
|
|
||||
|
color = new Color(fillAlpha, r, g, b); |
||||
|
} |
||||
|
|
||||
|
data[y * fb.Size.Width + x] = (int) color.ToUint32(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
Marshal.Copy(data, 0, fb.Address, fb.Size.Width * fb.Size.Height); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
base.Render(context); |
||||
|
|
||||
|
byte alpha = (byte)((_st.ElapsedMilliseconds / 10) % 256); |
||||
|
|
||||
|
FillPixels(_unpremulBitmap, alpha, false); |
||||
|
FillPixels(_premulBitmap, alpha, true); |
||||
|
|
||||
|
context.FillRectangle(Brushes.Red, new Rect(0, 0, 256 * 3, 256)); |
||||
|
|
||||
|
context.DrawImage(_unpremulBitmap, |
||||
|
new Rect(0, 0, 256, 256), |
||||
|
new Rect(0, 0, 256, 256)); |
||||
|
|
||||
|
context.DrawImage(_premulBitmap, |
||||
|
new Rect(0, 0, 256, 256), |
||||
|
new Rect(256, 0, 256, 256)); |
||||
|
|
||||
|
context.FillRectangle(new ImmutableSolidColorBrush(Colors.Lime, alpha / 255d), new Rect(512, 0, 256, 256)); |
||||
|
|
||||
|
Dispatcher.UIThread.Post(InvalidateVisual, DispatcherPriority.Background); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,65 +1,68 @@ |
|||||
<Styles xmlns="https://github.com/avaloniaui" |
<Styles xmlns="https://github.com/avaloniaui" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
||||
<Style Selector="TabControl.sidebar"> |
<Style Selector="TabControl.sidebar"> |
||||
<Setter Property="TabStripPlacement" Value="Left"/> |
<Setter Property="TabStripPlacement" Value="Left"/> |
||||
<Setter Property="Padding" Value="8 0 0 0"/> |
<Setter Property="Padding" Value="8 0 0 0"/> |
||||
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush}"/> |
<Setter Property="Background" Value="{DynamicResource SystemAccentColor}"/> |
||||
<Setter Property="Template"> |
<Setter Property="Template"> |
||||
<ControlTemplate> |
<ControlTemplate> |
||||
<Border |
<Border |
||||
Margin="{TemplateBinding Margin}" |
Margin="{TemplateBinding Margin}" |
||||
BorderBrush="{TemplateBinding BorderBrush}" |
BorderBrush="{TemplateBinding BorderBrush}" |
||||
BorderThickness="{TemplateBinding BorderThickness}"> |
BorderThickness="{TemplateBinding BorderThickness}"> |
||||
<DockPanel> |
<DockPanel> |
||||
<ScrollViewer |
<ScrollViewer |
||||
Name="PART_ScrollViewer" |
Name="PART_ScrollViewer" |
||||
HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}" |
HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}" |
||||
VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}" |
VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}" |
||||
Background="{TemplateBinding Background}"> |
Background="{TemplateBinding Background}"> |
||||
<ItemsPresenter |
<ItemsPresenter |
||||
Name="PART_ItemsPresenter" |
Name="PART_ItemsPresenter" |
||||
Items="{TemplateBinding Items}" |
Items="{TemplateBinding Items}" |
||||
ItemsPanel="{TemplateBinding ItemsPanel}" |
ItemsPanel="{TemplateBinding ItemsPanel}" |
||||
ItemTemplate="{TemplateBinding ItemTemplate}"> |
ItemTemplate="{TemplateBinding ItemTemplate}"> |
||||
</ItemsPresenter> |
</ItemsPresenter> |
||||
</ScrollViewer> |
</ScrollViewer> |
||||
<ContentPresenter |
<ContentPresenter |
||||
Name="PART_SelectedContentHost" |
Name="PART_SelectedContentHost" |
||||
Margin="{TemplateBinding Padding}" |
Margin="{TemplateBinding Padding}" |
||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
||||
Content="{TemplateBinding SelectedContent}" |
Content="{TemplateBinding SelectedContent}" |
||||
ContentTemplate="{TemplateBinding SelectedContentTemplate}"> |
ContentTemplate="{TemplateBinding SelectedContentTemplate}"> |
||||
</ContentPresenter> |
</ContentPresenter> |
||||
</DockPanel> |
</DockPanel> |
||||
</Border> |
</Border> |
||||
</ControlTemplate> |
</ControlTemplate> |
||||
</Setter> |
</Setter> |
||||
</Style> |
</Style> |
||||
|
|
||||
<Style Selector="TabControl.sidebar > TabItem"> |
<Style Selector="TabControl.sidebar > TabItem"> |
||||
<Setter Property="BorderThickness" Value="0"/> |
<Setter Property="BorderThickness" Value="0"/> |
||||
<Setter Property="Foreground" Value="White"/> |
<Setter Property="Foreground" Value="White"/> |
||||
<Setter Property="FontSize" Value="14"/> |
<Setter Property="FontSize" Value="14"/> |
||||
<Setter Property="Margin" Value="0"/> |
<Setter Property="Margin" Value="0"/> |
||||
<Setter Property="Padding" Value="16"/> |
<Setter Property="Padding" Value="16"/> |
||||
<Setter Property="Opacity" Value="0.5"/> |
<Setter Property="Opacity" Value="0.5"/> |
||||
<Setter Property="Transitions"> |
<Setter Property="Transitions"> |
||||
<Transitions> |
<Transitions> |
||||
<DoubleTransition Property="Opacity" Duration="0:0:0.150"/> |
<DoubleTransition Property="Opacity" Duration="0:0:0.150"/> |
||||
</Transitions> |
</Transitions> |
||||
</Setter> |
</Setter> |
||||
</Style> |
</Style> |
||||
<Style Selector="TabControl.sidebar > TabItem:pointerover"> |
<Style Selector="TabControl.sidebar > TabItem:selected /template/ Border#PART_SelectedPipe"> |
||||
<Setter Property="Opacity" Value="1"/> |
<Setter Property="IsVisible" Value="False" /> |
||||
</Style> |
</Style> |
||||
<Style Selector="TabControl.sidebar > TabItem:pointerover /template/ ContentPresenter#PART_ContentPresenter"> |
<Style Selector="TabControl.sidebar > TabItem:pointerover"> |
||||
<Setter Property="Background" Value="Transparent"/> |
<Setter Property="Opacity" Value="1"/> |
||||
</Style> |
</Style> |
||||
<Style Selector="TabControl.sidebar > TabItem:selected"> |
<Style Selector="TabControl.sidebar > TabItem:pointerover /template/ Border#PART_LayoutRoot"> |
||||
<Setter Property="Opacity" Value="1"/> |
<Setter Property="Background" Value="{DynamicResource SystemAccentColorLight2}"/> |
||||
</Style> |
</Style> |
||||
<Style Selector="TabControl.sidebar > TabItem:selected /template/ ContentPresenter#PART_ContentPresenter"> |
<Style Selector="TabControl.sidebar > TabItem:selected"> |
||||
<Setter Property="Background" Value="{DynamicResource ThemeAccentBrush2}"/> |
<Setter Property="Opacity" Value="1"/> |
||||
</Style> |
</Style> |
||||
|
<Style Selector="TabControl.sidebar > TabItem:selected /template/ Border#PART_LayoutRoot"> |
||||
|
<Setter Property="Background" Value="{DynamicResource SystemAccentColorLight1}"/> |
||||
|
</Style> |
||||
</Styles> |
</Styles> |
||||
|
|||||
@ -0,0 +1,8 @@ |
|||||
|
<Application xmlns="https://github.com/avaloniaui" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
x:Class="NativeEmbedSample.App"> |
||||
|
<Application.Styles> |
||||
|
<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml"/> |
||||
|
<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml"/> |
||||
|
</Application.Styles> |
||||
|
</Application> |
||||
@ -0,0 +1,22 @@ |
|||||
|
using Avalonia; |
||||
|
using Avalonia.Controls.ApplicationLifetimes; |
||||
|
using Avalonia.Markup.Xaml; |
||||
|
|
||||
|
namespace NativeEmbedSample |
||||
|
{ |
||||
|
public class App : Application |
||||
|
{ |
||||
|
public override void Initialize() |
||||
|
{ |
||||
|
AvaloniaXamlLoader.Load(this); |
||||
|
} |
||||
|
|
||||
|
public override void OnFrameworkInitializationCompleted() |
||||
|
{ |
||||
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime) |
||||
|
desktopLifetime.MainWindow = new MainWindow(); |
||||
|
|
||||
|
base.OnFrameworkInitializationCompleted(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,121 @@ |
|||||
|
using System; |
||||
|
using System.Diagnostics; |
||||
|
using System.IO; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using System.Text; |
||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.Platform; |
||||
|
using Avalonia.Threading; |
||||
|
using MonoMac.AppKit; |
||||
|
using MonoMac.Foundation; |
||||
|
using MonoMac.WebKit; |
||||
|
using Encoding = SharpDX.Text.Encoding; |
||||
|
|
||||
|
namespace NativeEmbedSample |
||||
|
{ |
||||
|
public class EmbedSample : NativeControlHost |
||||
|
{ |
||||
|
public bool IsSecond { get; set; } |
||||
|
private Process _mplayer; |
||||
|
|
||||
|
IPlatformHandle CreateLinux(IPlatformHandle parent) |
||||
|
{ |
||||
|
if (IsSecond) |
||||
|
{ |
||||
|
var chooser = GtkHelper.CreateGtkFileChooser(parent.Handle); |
||||
|
if (chooser != null) |
||||
|
return chooser; |
||||
|
} |
||||
|
|
||||
|
var control = base.CreateNativeControlCore(parent); |
||||
|
var nodes = Path.GetFullPath(Path.Combine(typeof(EmbedSample).Assembly.GetModules()[0].FullyQualifiedName, |
||||
|
"..", |
||||
|
"nodes.mp4")); |
||||
|
_mplayer = Process.Start(new ProcessStartInfo("mplayer", |
||||
|
$"-vo x11 -zoom -loop 0 -wid {control.Handle.ToInt64()} \"{nodes}\"") |
||||
|
{ |
||||
|
UseShellExecute = false, |
||||
|
|
||||
|
}); |
||||
|
return control; |
||||
|
} |
||||
|
|
||||
|
void DestroyLinux(IPlatformHandle handle) |
||||
|
{ |
||||
|
_mplayer?.Kill(); |
||||
|
_mplayer = null; |
||||
|
base.DestroyNativeControlCore(handle); |
||||
|
} |
||||
|
|
||||
|
private const string RichText = |
||||
|
@"{\rtf1\ansi\ansicpg1251\deff0\nouicompat\deflang1049{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
|
||||
|
{\colortbl ;\red255\green0\blue0;\red0\green77\blue187;\red0\green176\blue80;\red155\green0\blue211;\red247\green150\blue70;\red75\green172\blue198;} |
||||
|
{\*\generator Riched20 6.3.9600}\viewkind4\uc1 |
||||
|
\pard\sa200\sl276\slmult1\f0\fs22\lang9 <PREFIX>I \i am\i0 a \cf1\b Rich Text \cf0\b0\fs24 control\cf2\fs28 !\cf3\fs32 !\cf4\fs36 !\cf1\fs40 !\cf5\fs44 !\cf6\fs48 !\cf0\fs44\par |
||||
|
}";
|
||||
|
|
||||
|
IPlatformHandle CreateWin32(IPlatformHandle parent) |
||||
|
{ |
||||
|
WinApi.LoadLibrary("Msftedit.dll"); |
||||
|
var handle = WinApi.CreateWindowEx(0, "RICHEDIT50W", |
||||
|
@"Rich Edit", |
||||
|
0x800000 | 0x10000000 | 0x40000000 | 0x800000 | 0x10000 | 0x0004, 0, 0, 1, 1, parent.Handle, |
||||
|
IntPtr.Zero, WinApi.GetModuleHandle(null), IntPtr.Zero); |
||||
|
var st = new WinApi.SETTEXTEX { Codepage = 65001, Flags = 0x00000008 }; |
||||
|
var text = RichText.Replace("<PREFIX>", IsSecond ? "\\qr " : ""); |
||||
|
var bytes = Encoding.UTF8.GetBytes(text); |
||||
|
WinApi.SendMessage(handle, 0x0400 + 97, ref st, bytes); |
||||
|
return new PlatformHandle(handle, "HWND"); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void DestroyWin32(IPlatformHandle handle) |
||||
|
{ |
||||
|
WinApi.DestroyWindow(handle.Handle); |
||||
|
} |
||||
|
|
||||
|
IPlatformHandle CreateOSX(IPlatformHandle parent) |
||||
|
{ |
||||
|
// Note: We are using MonoMac for example purposes
|
||||
|
// It shouldn't be used in production apps
|
||||
|
MacHelper.EnsureInitialized(); |
||||
|
|
||||
|
var webView = new WebView(); |
||||
|
Dispatcher.UIThread.Post(() => |
||||
|
{ |
||||
|
webView.MainFrame.LoadRequest(new NSUrlRequest(new NSUrl( |
||||
|
IsSecond ? "https://bing.com": "https://google.com/"))); |
||||
|
}); |
||||
|
return new MacOSViewHandle(webView); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
void DestroyOSX(IPlatformHandle handle) |
||||
|
{ |
||||
|
((MacOSViewHandle)handle).Dispose(); |
||||
|
} |
||||
|
|
||||
|
protected override IPlatformHandle CreateNativeControlCore(IPlatformHandle parent) |
||||
|
{ |
||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) |
||||
|
return CreateLinux(parent); |
||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) |
||||
|
return CreateWin32(parent); |
||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) |
||||
|
return CreateOSX(parent); |
||||
|
return base.CreateNativeControlCore(parent); |
||||
|
} |
||||
|
|
||||
|
protected override void DestroyNativeControlCore(IPlatformHandle control) |
||||
|
{ |
||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) |
||||
|
DestroyLinux(control); |
||||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) |
||||
|
DestroyWin32(control); |
||||
|
else if(RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) |
||||
|
DestroyOSX(control); |
||||
|
else |
||||
|
base.DestroyNativeControlCore(control); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,58 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Avalonia.Controls.Platform; |
||||
|
using Avalonia.Platform; |
||||
|
using Avalonia.Platform.Interop; |
||||
|
using Avalonia.X11.NativeDialogs; |
||||
|
using static Avalonia.X11.NativeDialogs.Gtk; |
||||
|
using static Avalonia.X11.NativeDialogs.Glib; |
||||
|
namespace NativeEmbedSample |
||||
|
{ |
||||
|
public class GtkHelper |
||||
|
{ |
||||
|
private static Task<bool> s_gtkTask; |
||||
|
class FileChooser : INativeControlHostDestroyableControlHandle |
||||
|
{ |
||||
|
private readonly IntPtr _widget; |
||||
|
|
||||
|
public FileChooser(IntPtr widget, IntPtr xid) |
||||
|
{ |
||||
|
_widget = widget; |
||||
|
Handle = xid; |
||||
|
} |
||||
|
|
||||
|
public IntPtr Handle { get; } |
||||
|
public string HandleDescriptor => "XID"; |
||||
|
public void Destroy() |
||||
|
{ |
||||
|
RunOnGlibThread(() => |
||||
|
{ |
||||
|
gtk_widget_destroy(_widget); |
||||
|
return 0; |
||||
|
}).Wait(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
public static IPlatformHandle CreateGtkFileChooser(IntPtr parentXid) |
||||
|
{ |
||||
|
if (s_gtkTask == null) |
||||
|
s_gtkTask = StartGtk(); |
||||
|
if (!s_gtkTask.Result) |
||||
|
return null; |
||||
|
return RunOnGlibThread(() => |
||||
|
{ |
||||
|
using (var title = new Utf8Buffer("Embedded")) |
||||
|
{ |
||||
|
var widget = gtk_file_chooser_dialog_new(title, IntPtr.Zero, GtkFileChooserAction.SelectFolder, |
||||
|
IntPtr.Zero); |
||||
|
gtk_widget_realize(widget); |
||||
|
var xid = gdk_x11_window_get_xid(gtk_widget_get_window(widget)); |
||||
|
gtk_window_present(widget); |
||||
|
return new FileChooser(widget, xid); |
||||
|
} |
||||
|
}).Result; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,39 @@ |
|||||
|
using System; |
||||
|
using Avalonia.Platform; |
||||
|
using MonoMac.AppKit; |
||||
|
|
||||
|
namespace NativeEmbedSample |
||||
|
{ |
||||
|
public class MacHelper |
||||
|
{ |
||||
|
private static bool _isInitialized; |
||||
|
|
||||
|
public static void EnsureInitialized() |
||||
|
{ |
||||
|
if (_isInitialized) |
||||
|
return; |
||||
|
_isInitialized = true; |
||||
|
NSApplication.Init(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
class MacOSViewHandle : IPlatformHandle, IDisposable |
||||
|
{ |
||||
|
private NSView _view; |
||||
|
|
||||
|
public MacOSViewHandle(NSView view) |
||||
|
{ |
||||
|
_view = view; |
||||
|
} |
||||
|
|
||||
|
public IntPtr Handle => _view?.Handle ?? IntPtr.Zero; |
||||
|
public string HandleDescriptor => "NSView"; |
||||
|
|
||||
|
public void Dispose() |
||||
|
{ |
||||
|
_view.Dispose(); |
||||
|
_view = null; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,52 @@ |
|||||
|
<Window xmlns="https://github.com/avaloniaui" MinWidth="500" MinHeight="300" |
||||
|
Width="1024" Height="800" |
||||
|
Title="Native embedding sample" |
||||
|
xmlns:local="clr-namespace:NativeEmbedSample" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
x:Class="NativeEmbedSample.MainWindow"> |
||||
|
<DockPanel> |
||||
|
<Menu DockPanel.Dock="Top"> |
||||
|
<MenuItem Header="Test"> |
||||
|
<MenuItem Header="SubMenu"> |
||||
|
<MenuItem Header="Item 1"/> |
||||
|
<MenuItem Header="Item 2"/> |
||||
|
<MenuItem Header="Item 3"/> |
||||
|
</MenuItem> |
||||
|
<MenuItem Header="Item 1"/> |
||||
|
<MenuItem Header="Item 2"/> |
||||
|
<MenuItem Header="Item 3"/> |
||||
|
</MenuItem> |
||||
|
</Menu> |
||||
|
<DockPanel DockPanel.Dock="Top"> |
||||
|
<Button DockPanel.Dock="Right" Click="ShowPopupDelay">Show popup (delay)</Button> |
||||
|
<Button DockPanel.Dock="Right" Click="ShowPopup">Show popup</Button> |
||||
|
<Border DockPanel.Dock="Right" Background="#c0c0c0"> |
||||
|
<ToolTip.Tip> |
||||
|
<ToolTip> |
||||
|
<TextBlock>Text</TextBlock> |
||||
|
</ToolTip> |
||||
|
</ToolTip.Tip> |
||||
|
<TextBlock>Tooltip</TextBlock> |
||||
|
</Border> |
||||
|
<TextBox Text="Lorem ipsum dolor sit amet"/> |
||||
|
|
||||
|
</DockPanel> |
||||
|
<Grid ColumnDefinitions="*,5,*"> |
||||
|
<DockPanel> |
||||
|
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top"> |
||||
|
<CheckBox x:Name="firstVisible" IsChecked="True"/> |
||||
|
<TextBlock>Visible</TextBlock> |
||||
|
</StackPanel> |
||||
|
<local:EmbedSample IsVisible="{Binding #firstVisible.IsChecked}"/> |
||||
|
</DockPanel> |
||||
|
<GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Stretch" /> |
||||
|
<DockPanel Grid.Column="2"> |
||||
|
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top"> |
||||
|
<CheckBox x:Name="secondVisible" IsChecked="True"/> |
||||
|
<TextBlock>Visible</TextBlock> |
||||
|
</StackPanel> |
||||
|
<local:EmbedSample IsSecond="True" IsVisible="{Binding #secondVisible.IsChecked}"/> |
||||
|
</DockPanel> |
||||
|
</Grid> |
||||
|
</DockPanel> |
||||
|
</Window> |
||||
@ -0,0 +1,36 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Avalonia; |
||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.Interactivity; |
||||
|
using Avalonia.Markup.Xaml; |
||||
|
|
||||
|
namespace NativeEmbedSample |
||||
|
{ |
||||
|
public class MainWindow : Window |
||||
|
{ |
||||
|
public MainWindow() |
||||
|
{ |
||||
|
AvaloniaXamlLoader.Load(this); |
||||
|
this.AttachDevTools(); |
||||
|
} |
||||
|
|
||||
|
public async void ShowPopupDelay(object sender, RoutedEventArgs args) |
||||
|
{ |
||||
|
await Task.Delay(3000); |
||||
|
ShowPopup(sender, args); |
||||
|
} |
||||
|
|
||||
|
public void ShowPopup(object sender, RoutedEventArgs args) |
||||
|
{ |
||||
|
|
||||
|
new ContextMenu() |
||||
|
{ |
||||
|
Items = new List<MenuItem> |
||||
|
{ |
||||
|
new MenuItem() { Header = "Test" }, new MenuItem() { Header = "Test" } |
||||
|
} |
||||
|
}.Open((Control)sender); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<OutputType>Exe</OutputType> |
||||
|
<TargetFramework>netcoreapp2.0</TargetFramework> |
||||
|
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> |
||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="MonoMac.NetStandard" Version="0.0.4" /> |
||||
|
<ProjectReference Include="..\..\..\src\Avalonia.Desktop\Avalonia.Desktop.csproj" /> |
||||
|
<ProjectReference Include="..\..\..\src\Windows\Avalonia.Direct2D1\Avalonia.Direct2D1.csproj" /> |
||||
|
<ProjectReference Include="..\..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" /> |
||||
|
<ProjectReference Include="..\..\..\src\Avalonia.X11\Avalonia.X11.csproj" /> |
||||
|
<PackageReference Include="Avalonia.Angle.Windows.Natives" Version="2.1.0.2019013001" /> |
||||
|
|
||||
|
<AvaloniaResource Include="**\*.xaml"> |
||||
|
<SubType>Designer</SubType> |
||||
|
</AvaloniaResource> |
||||
|
<None Remove="nodes.mp4" /> |
||||
|
<Content Include="nodes.mp4"> |
||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
||||
|
</Content> |
||||
|
<Compile Include="..\..\..\src\Avalonia.X11\NativeDialogs\Gtk.cs" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<Import Project="..\..\..\build\SampleApp.props" /> |
||||
|
<Import Project="..\..\..\build\BuildTargets.targets" /> |
||||
|
<Import Project="..\..\..\build\ReferenceCoreLibraries.props" /> |
||||
|
</Project> |
||||
@ -0,0 +1,17 @@ |
|||||
|
using Avalonia; |
||||
|
|
||||
|
namespace NativeEmbedSample |
||||
|
{ |
||||
|
class Program |
||||
|
{ |
||||
|
static int Main(string[] args) => BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); |
||||
|
|
||||
|
public static AppBuilder BuildAvaloniaApp() |
||||
|
=> AppBuilder.Configure<App>() |
||||
|
.With(new AvaloniaNativePlatformOptions() |
||||
|
{ |
||||
|
}) |
||||
|
.UsePlatformDetect(); |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,74 @@ |
|||||
|
using System; |
||||
|
using System.Runtime.InteropServices; |
||||
|
|
||||
|
namespace NativeEmbedSample |
||||
|
{ |
||||
|
public unsafe class WinApi |
||||
|
{ |
||||
|
public enum CommonControls : uint |
||||
|
{ |
||||
|
ICC_LISTVIEW_CLASSES = 0x00000001, // listview, header
|
||||
|
ICC_TREEVIEW_CLASSES = 0x00000002, // treeview, tooltips
|
||||
|
ICC_BAR_CLASSES = 0x00000004, // toolbar, statusbar, trackbar, tooltips
|
||||
|
ICC_TAB_CLASSES = 0x00000008, // tab, tooltips
|
||||
|
ICC_UPDOWN_CLASS = 0x00000010, // updown
|
||||
|
ICC_PROGRESS_CLASS = 0x00000020, // progress
|
||||
|
ICC_HOTKEY_CLASS = 0x00000040, // hotkey
|
||||
|
ICC_ANIMATE_CLASS = 0x00000080, // animate
|
||||
|
ICC_WIN95_CLASSES = 0x000000FF, |
||||
|
ICC_DATE_CLASSES = 0x00000100, // month picker, date picker, time picker, updown
|
||||
|
ICC_USEREX_CLASSES = 0x00000200, // comboex
|
||||
|
ICC_COOL_CLASSES = 0x00000400, // rebar (coolbar) control
|
||||
|
ICC_INTERNET_CLASSES = 0x00000800, |
||||
|
ICC_PAGESCROLLER_CLASS = 0x00001000, // page scroller
|
||||
|
ICC_NATIVEFNTCTL_CLASS = 0x00002000, // native font control
|
||||
|
ICC_STANDARD_CLASSES = 0x00004000, |
||||
|
ICC_LINK_CLASS = 0x00008000 |
||||
|
} |
||||
|
|
||||
|
[StructLayout(LayoutKind.Sequential)] |
||||
|
public struct INITCOMMONCONTROLSEX |
||||
|
{ |
||||
|
public int dwSize; |
||||
|
public uint dwICC; |
||||
|
} |
||||
|
|
||||
|
[DllImport("Comctl32.dll")] |
||||
|
public static extern void InitCommonControlsEx(ref INITCOMMONCONTROLSEX init); |
||||
|
|
||||
|
[DllImport("user32.dll", SetLastError = true)] |
||||
|
public static extern bool DestroyWindow(IntPtr hwnd); |
||||
|
|
||||
|
[DllImport("kernel32.dll")] |
||||
|
public static extern IntPtr LoadLibrary(string lib); |
||||
|
|
||||
|
|
||||
|
[DllImport("kernel32.dll")] |
||||
|
public static extern IntPtr GetModuleHandle(string lpModuleName); |
||||
|
|
||||
|
[DllImport("user32.dll", SetLastError = true)] |
||||
|
public static extern IntPtr CreateWindowEx( |
||||
|
int dwExStyle, |
||||
|
string lpClassName, |
||||
|
string lpWindowName, |
||||
|
uint dwStyle, |
||||
|
int x, |
||||
|
int y, |
||||
|
int nWidth, |
||||
|
int nHeight, |
||||
|
IntPtr hWndParent, |
||||
|
IntPtr hMenu, |
||||
|
IntPtr hInstance, |
||||
|
IntPtr lpParam); |
||||
|
|
||||
|
[StructLayout(LayoutKind.Sequential)] |
||||
|
public struct SETTEXTEX |
||||
|
{ |
||||
|
public uint Flags; |
||||
|
public uint Codepage; |
||||
|
} |
||||
|
|
||||
|
[DllImport("user32.dll", CharSet = CharSet.Unicode, EntryPoint = "SendMessageW")] |
||||
|
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, ref SETTEXTEX wParam, byte[] lParam); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
nodes.mp4 by beeple is licensed under the creative commons license, downloaded from https://vimeo.com/9936271 |
||||
Binary file not shown.
@ -1,9 +1,10 @@ |
|||||
<Project Sdk="Microsoft.NET.Sdk"> |
<Project Sdk="Microsoft.NET.Sdk"> |
||||
<PropertyGroup> |
<PropertyGroup> |
||||
<TargetFramework>netstandard2.0</TargetFramework> |
<TargetFramework>netstandard2.0</TargetFramework> |
||||
</PropertyGroup> |
</PropertyGroup> |
||||
<ItemGroup> |
<ItemGroup> |
||||
<ProjectReference Include="..\Avalonia.Base\Avalonia.Base.csproj" /> |
<ProjectReference Include="..\Avalonia.Base\Avalonia.Base.csproj" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
<Import Project="..\..\build\Rx.props" /> |
<Import Project="..\..\build\Rx.props" /> |
||||
|
<Import Project="..\..\build\ApiDiff.props" /> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -0,0 +1,85 @@ |
|||||
|
namespace Avalonia.Animation.Easings |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Eases a <see cref="double"/> value
|
||||
|
/// using a user-defined cubic bezier curve.
|
||||
|
/// Good for custom easing functions that doesn't quite
|
||||
|
/// fit with the built-in ones.
|
||||
|
/// </summary>
|
||||
|
public class SplineEasing : Easing |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// X coordinate of the first control point
|
||||
|
/// </summary>
|
||||
|
public double X1 |
||||
|
{ |
||||
|
get => _internalKeySpline.ControlPointX1; |
||||
|
set |
||||
|
{ |
||||
|
_internalKeySpline.ControlPointX1 = value; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Y coordinate of the first control point
|
||||
|
/// </summary>
|
||||
|
public double Y1 |
||||
|
{ |
||||
|
get => _internalKeySpline.ControlPointY1; |
||||
|
set |
||||
|
{ |
||||
|
_internalKeySpline.ControlPointY1 = value; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// X coordinate of the second control point
|
||||
|
/// </summary>
|
||||
|
public double X2 |
||||
|
{ |
||||
|
get => _internalKeySpline.ControlPointX2; |
||||
|
set |
||||
|
{ |
||||
|
_internalKeySpline.ControlPointX2 = value; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Y coordinate of the second control point
|
||||
|
/// </summary>
|
||||
|
public double Y2 |
||||
|
{ |
||||
|
get => _internalKeySpline.ControlPointY2; |
||||
|
set |
||||
|
{ |
||||
|
_internalKeySpline.ControlPointY2 = value; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private readonly KeySpline _internalKeySpline; |
||||
|
|
||||
|
public SplineEasing(double x1 = 0d, double y1 = 0d, double x2 = 1d, double y2 = 1d) |
||||
|
{ |
||||
|
_internalKeySpline = new KeySpline(); |
||||
|
|
||||
|
this.X1 = x1; |
||||
|
this.Y1 = y1; |
||||
|
this.X2 = x2; |
||||
|
this.Y1 = y2; |
||||
|
} |
||||
|
|
||||
|
public SplineEasing(KeySpline keySpline) |
||||
|
{ |
||||
|
_internalKeySpline = keySpline; |
||||
|
} |
||||
|
|
||||
|
public SplineEasing() |
||||
|
{ |
||||
|
_internalKeySpline = new KeySpline(); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc/>
|
||||
|
public override double Ease(double progress) => |
||||
|
_internalKeySpline.GetSplineProgress(progress); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel; |
||||
|
using System.Globalization; |
||||
|
|
||||
|
// Ported from WPF open-source code.
|
||||
|
// https://github.com/dotnet/wpf/blob/ae1790531c3b993b56eba8b1f0dd395a3ed7de75/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/KeySpline.cs
|
||||
|
|
||||
|
namespace Avalonia.Animation |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Converts string values to <see cref="KeySpline"/> values
|
||||
|
/// </summary>
|
||||
|
public class KeySplineTypeConverter : TypeConverter |
||||
|
{ |
||||
|
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) |
||||
|
{ |
||||
|
return sourceType == typeof(string); |
||||
|
} |
||||
|
|
||||
|
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) |
||||
|
{ |
||||
|
return KeySpline.Parse((string)value, culture); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue