committed by
GitHub
233 changed files with 2258 additions and 5661 deletions
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<EnableNETAnalyzers>true</EnableNETAnalyzers> |
|||
</PropertyGroup> |
|||
</Project> |
|||
@ -0,0 +1,17 @@ |
|||
using Avalonia; |
|||
using Avalonia.Web.Blazor; |
|||
|
|||
namespace ControlCatalog.Blazor.Web; |
|||
|
|||
public partial class App |
|||
{ |
|||
protected override void OnParametersSet() |
|||
{ |
|||
AppBuilder.Configure<ControlCatalog.App>() |
|||
.UseBlazor() |
|||
// .With(new SkiaOptions { CustomGpuFactory = null }) // uncomment to disable GPU/GL rendering
|
|||
.SetupWithSingleViewLifetime(); |
|||
|
|||
base.OnParametersSet(); |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> |
|||
<PropertyGroup> |
|||
<TargetFramework>net7.0</TargetFramework> |
|||
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier> |
|||
<Nullable>enable</Nullable> |
|||
<EmccTotalMemory>16777216</EmccTotalMemory> |
|||
<BlazorEnableTimeZoneSupport>false</BlazorEnableTimeZoneSupport> |
|||
<BlazorWebAssemblyPreserveCollationData>false</BlazorWebAssemblyPreserveCollationData> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.0-rc.1.22427.2" /> |
|||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.0-rc.1.22427.2" PrivateAssets="all" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Skia\Avalonia.Skia\Avalonia.Skia.csproj" /> |
|||
<ProjectReference Include="..\..\src\Web\Avalonia.Web.Blazor\Avalonia.Web.Blazor.csproj" /> |
|||
<ProjectReference Include="..\ControlCatalog\ControlCatalog.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<Import Project="..\..\build\ReferenceCoreLibraries.props" /> |
|||
<Import Project="..\..\build\BuildTargets.targets" /> |
|||
|
|||
<Import Project="..\..\src\Web\Avalonia.Web\Avalonia.Web.props" /> |
|||
<Import Project="..\..\src\Web\Avalonia.Web\Avalonia.Web.targets" /> |
|||
|
|||
</Project> |
|||
|
|||
@ -0,0 +1,29 @@ |
|||
using System; |
|||
using System.Net.Http; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using ControlCatalog.Blazor.Web; |
|||
|
|||
public class Program |
|||
{ |
|||
public static async Task Main(string[] args) |
|||
{ |
|||
await CreateHostBuilder(args).Build().RunAsync(); |
|||
} |
|||
|
|||
public static WebAssemblyHostBuilder CreateHostBuilder(string[] args) |
|||
{ |
|||
var builder = WebAssemblyHostBuilder.CreateDefault(args); |
|||
|
|||
builder.RootComponents.Add<App>("#app"); |
|||
|
|||
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); |
|||
|
|||
return builder; |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
Before Width: | Height: | Size: 172 KiB After Width: | Height: | Size: 172 KiB |
@ -1,20 +0,0 @@ |
|||
using Avalonia; |
|||
using Avalonia.Web.Blazor; |
|||
|
|||
namespace ControlCatalog.Web; |
|||
|
|||
public partial class App |
|||
{ |
|||
protected override void OnParametersSet() |
|||
{ |
|||
WebAppBuilder.Configure<ControlCatalog.App>() |
|||
.AfterSetup(_ => |
|||
{ |
|||
ControlCatalog.Pages.EmbedSample.Implementation = new EmbedSampleWeb(); |
|||
}) |
|||
.With(new SkiaOptions { CustomGpuFactory = null }) // uncomment to disable GPU/GL rendering
|
|||
.SetupWithSingleViewLifetime(); |
|||
|
|||
base.OnParametersSet(); |
|||
} |
|||
} |
|||
@ -1,34 +1,42 @@ |
|||
using System; |
|||
|
|||
using Avalonia; |
|||
using System.Runtime.InteropServices.JavaScript; |
|||
using Avalonia.Platform; |
|||
using Avalonia.Web.Blazor; |
|||
using Avalonia.Web; |
|||
|
|||
using ControlCatalog.Pages; |
|||
|
|||
using Microsoft.JSInterop; |
|||
|
|||
namespace ControlCatalog.Web; |
|||
|
|||
public class EmbedSampleWeb : INativeDemoControl |
|||
{ |
|||
public IPlatformHandle CreateControl(bool isSecond, IPlatformHandle parent, Func<IPlatformHandle> createDefault) |
|||
{ |
|||
var runtime = AvaloniaLocator.Current.GetRequiredService<IJSInProcessRuntime>(); |
|||
|
|||
if (isSecond) |
|||
{ |
|||
var iframe = runtime.Invoke<IJSInProcessObjectReference>("document.createElement", "iframe"); |
|||
iframe.InvokeVoid("setAttribute", "src", "https://www.youtube.com/embed/kZCIporjJ70"); |
|||
var iframe = EmbedInterop.CreateElement("iframe"); |
|||
iframe.SetProperty("src", "https://www.youtube.com/embed/kZCIporjJ70"); |
|||
|
|||
return new JSObjectControlHandle(iframe); |
|||
} |
|||
else |
|||
{ |
|||
// window.createAppButton source is defined in "app.js" file.
|
|||
var button = runtime.Invoke<IJSInProcessObjectReference>("window.createAppButton"); |
|||
var defaultHandle = (JSObjectControlHandle)createDefault(); |
|||
|
|||
_ = JSHost.ImportAsync("embed.js", "./embed.js").ContinueWith(_ => |
|||
{ |
|||
EmbedInterop.AddAppButton(defaultHandle.Object); |
|||
}); |
|||
|
|||
return new JSObjectControlHandle(button); |
|||
return defaultHandle; |
|||
} |
|||
} |
|||
} |
|||
|
|||
internal static partial class EmbedInterop |
|||
{ |
|||
[JSImport("globalThis.document.createElement")] |
|||
public static partial JSObject CreateElement(string tagName); |
|||
|
|||
[JSImport("addAppButton", "embed.js")] |
|||
public static partial void AddAppButton(JSObject parentObject); |
|||
} |
|||
|
|||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
@ -0,0 +1,6 @@ |
|||
<linker> |
|||
<assembly fullname="ControlCatalog" preserve="All" /> |
|||
<assembly fullname="ControlCatalog.Web" preserve="All" /> |
|||
<assembly fullname="Avalonia.Themes.Fluent" preserve="All" /> |
|||
<assembly fullname="Avalonia.Themes.Simple" preserve="All" /> |
|||
</linker> |
|||
|
Before Width: | Height: | Size: 172 KiB After Width: | Height: | Size: 172 KiB |
@ -1,105 +0,0 @@ |
|||
using Android.OS; |
|||
using AndroidX.AppCompat.App; |
|||
using Android.Content.Res; |
|||
using AndroidX.Lifecycle; |
|||
using Avalonia.Controls.ApplicationLifetimes; |
|||
using Avalonia.Controls; |
|||
using Android.Runtime; |
|||
using Android.App; |
|||
using Android.Content; |
|||
using System; |
|||
|
|||
namespace Avalonia.Android |
|||
{ |
|||
public abstract class AvaloniaActivity : AppCompatActivity |
|||
{ |
|||
internal class SingleViewLifetime : ISingleViewApplicationLifetime |
|||
{ |
|||
public AvaloniaView View { get; internal set; } |
|||
|
|||
public Control MainView |
|||
{ |
|||
get => (Control)View.Content; |
|||
set => View.Content = value; |
|||
} |
|||
} |
|||
|
|||
internal Action<int, Result, Intent> ActivityResult; |
|||
internal AvaloniaView View; |
|||
internal AvaloniaViewModel _viewModel; |
|||
|
|||
protected abstract AppBuilder CreateAppBuilder(); |
|||
|
|||
protected override void OnCreate(Bundle savedInstanceState) |
|||
{ |
|||
var builder = CreateAppBuilder(); |
|||
|
|||
|
|||
var lifetime = new SingleViewLifetime(); |
|||
|
|||
builder.AfterSetup(x => |
|||
{ |
|||
_viewModel = new ViewModelProvider(this).Get(Java.Lang.Class.FromType(typeof(AvaloniaViewModel))) as AvaloniaViewModel; |
|||
|
|||
View = new AvaloniaView(this); |
|||
if (_viewModel.Content != null) |
|||
{ |
|||
View.Content = _viewModel.Content; |
|||
} |
|||
|
|||
SetContentView(View); |
|||
lifetime.View = View; |
|||
|
|||
View.Prepare(); |
|||
}); |
|||
|
|||
builder.SetupWithLifetime(lifetime); |
|||
|
|||
base.OnCreate(savedInstanceState); |
|||
} |
|||
public object Content |
|||
{ |
|||
get |
|||
{ |
|||
return _viewModel.Content; |
|||
} |
|||
set |
|||
{ |
|||
_viewModel.Content = value; |
|||
if (View != null) |
|||
View.Content = value; |
|||
} |
|||
} |
|||
|
|||
public override void OnConfigurationChanged(Configuration newConfig) |
|||
{ |
|||
base.OnConfigurationChanged(newConfig); |
|||
} |
|||
|
|||
protected override void OnDestroy() |
|||
{ |
|||
View.Content = null; |
|||
|
|||
base.OnDestroy(); |
|||
} |
|||
|
|||
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) |
|||
{ |
|||
base.OnActivityResult(requestCode, resultCode, data); |
|||
|
|||
ActivityResult?.Invoke(requestCode, resultCode, data); |
|||
} |
|||
} |
|||
|
|||
public abstract class AvaloniaActivity<TApp> : AvaloniaActivity where TApp : Application, new() |
|||
{ |
|||
protected virtual AppBuilder CustomizeAppBuilder(AppBuilder builder) => builder.UseAndroid(); |
|||
|
|||
protected override AppBuilder CreateAppBuilder() |
|||
{ |
|||
var builder = AppBuilder.Configure<TApp>(); |
|||
|
|||
return CustomizeAppBuilder(builder); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,70 @@ |
|||
using System; |
|||
using Android.App; |
|||
using Android.Content; |
|||
using Android.Content.Res; |
|||
using Android.OS; |
|||
using Android.Runtime; |
|||
using AndroidX.AppCompat.App; |
|||
using AndroidX.Lifecycle; |
|||
|
|||
namespace Avalonia.Android |
|||
{ |
|||
public abstract class AvaloniaMainActivity : AppCompatActivity, IActivityResultHandler |
|||
{ |
|||
internal static object ViewContent; |
|||
|
|||
public Action<int, Result, Intent> ActivityResult { get; set; } |
|||
internal AvaloniaView View; |
|||
|
|||
protected override void OnCreate(Bundle savedInstanceState) |
|||
{ |
|||
View = new AvaloniaView(this); |
|||
if (ViewContent != null) |
|||
{ |
|||
View.Content = ViewContent; |
|||
} |
|||
|
|||
if (Avalonia.Application.Current.ApplicationLifetime is SingleViewLifetime lifetime) |
|||
{ |
|||
lifetime.View = View; |
|||
} |
|||
|
|||
base.OnCreate(savedInstanceState); |
|||
|
|||
SetContentView(View); |
|||
} |
|||
|
|||
public object Content |
|||
{ |
|||
get |
|||
{ |
|||
return ViewContent; |
|||
} |
|||
set |
|||
{ |
|||
ViewContent = value; |
|||
if (View != null) |
|||
View.Content = value; |
|||
} |
|||
} |
|||
|
|||
public override void OnConfigurationChanged(Configuration newConfig) |
|||
{ |
|||
base.OnConfigurationChanged(newConfig); |
|||
} |
|||
|
|||
protected override void OnDestroy() |
|||
{ |
|||
View.Content = null; |
|||
|
|||
base.OnDestroy(); |
|||
} |
|||
|
|||
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) |
|||
{ |
|||
base.OnActivityResult(requestCode, resultCode, data); |
|||
|
|||
ActivityResult?.Invoke(requestCode, resultCode, data); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
using Android.OS; |
|||
using AndroidX.AppCompat.App; |
|||
using AndroidX.Lifecycle; |
|||
|
|||
namespace Avalonia.Android |
|||
{ |
|||
public abstract class AvaloniaSplashActivity : AppCompatActivity |
|||
{ |
|||
protected abstract AppBuilder CreateAppBuilder(); |
|||
|
|||
protected override void OnCreate(Bundle? savedInstanceState) |
|||
{ |
|||
base.OnCreate(savedInstanceState); |
|||
|
|||
var builder = CreateAppBuilder(); |
|||
|
|||
var lifetime = new SingleViewLifetime(); |
|||
|
|||
builder.SetupWithLifetime(lifetime); |
|||
} |
|||
} |
|||
|
|||
public abstract class AvaloniaSplashActivity<TApp> : AvaloniaSplashActivity where TApp : Application, new() |
|||
{ |
|||
protected virtual AppBuilder CustomizeAppBuilder(AppBuilder builder) => builder.UseAndroid(); |
|||
|
|||
protected override AppBuilder CreateAppBuilder() |
|||
{ |
|||
var builder = AppBuilder.Configure<TApp>(); |
|||
|
|||
return CustomizeAppBuilder(builder); |
|||
} |
|||
} |
|||
} |
|||
@ -1,11 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Avalonia.Android |
|||
{ |
|||
internal class AvaloniaViewModel : AndroidX.Lifecycle.ViewModel |
|||
{ |
|||
public object Content { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using Android.App; |
|||
using Android.Content; |
|||
|
|||
namespace Avalonia.Android |
|||
{ |
|||
public interface IActivityResultHandler |
|||
{ |
|||
public Action<int, Result, Intent> ActivityResult { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.ApplicationLifetimes; |
|||
|
|||
namespace Avalonia.Android |
|||
{ |
|||
internal class SingleViewLifetime : ISingleViewApplicationLifetime |
|||
{ |
|||
private AvaloniaView _view; |
|||
|
|||
public AvaloniaView View |
|||
{ |
|||
get => _view; internal set |
|||
{ |
|||
if (_view != null) |
|||
{ |
|||
_view.Content = null; |
|||
_view.Dispose(); |
|||
} |
|||
_view = value; |
|||
_view.Content = MainView; |
|||
} |
|||
} |
|||
|
|||
public Control MainView { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
namespace Avalonia.Media |
|||
{ |
|||
/// <summary>
|
|||
/// The font metrics is holding information about a font's ascent, descent, etc. in design em units.
|
|||
/// </summary>
|
|||
public readonly struct FontMetrics |
|||
{ |
|||
/// <summary>
|
|||
/// Gets the font design units per em.
|
|||
/// </summary>
|
|||
public short DesignEmHeight { get; init; } |
|||
|
|||
/// <summary>
|
|||
/// A <see cref="bool"/> value indicating whether all glyphs in the font have the same advancement.
|
|||
/// </summary>
|
|||
public bool IsFixedPitch { get; init; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the recommended distance above the baseline in design em size.
|
|||
/// </summary>
|
|||
public int Ascent { get; init; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the recommended distance under the baseline in design em size.
|
|||
/// </summary>
|
|||
public int Descent { get; init; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the recommended additional space between two lines of text in design em size.
|
|||
/// </summary>
|
|||
public int LineGap { get; init; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the recommended line spacing of a formed text line.
|
|||
/// </summary>
|
|||
public int LineSpacing => Descent - Ascent + LineGap; |
|||
|
|||
/// <summary>
|
|||
/// Gets a value that indicates the distance of the underline from the baseline in design em size.
|
|||
/// </summary>
|
|||
public int UnderlinePosition { get; init; } |
|||
|
|||
/// <summary>
|
|||
/// Gets a value that indicates the thickness of the underline in design em size.
|
|||
/// </summary>
|
|||
public int UnderlineThickness { get; init; } |
|||
|
|||
/// <summary>
|
|||
/// Gets a value that indicates the distance of the strikethrough from the baseline in design em size.
|
|||
/// </summary>
|
|||
public int StrikethroughPosition { get; init; } |
|||
|
|||
/// <summary>
|
|||
/// Gets a value that indicates the thickness of the underline in design em size.
|
|||
/// </summary>
|
|||
public int StrikethroughThickness { get; init; } |
|||
} |
|||
} |
|||
@ -1,125 +0,0 @@ |
|||
using System; |
|||
using Avalonia.Platform; |
|||
|
|||
namespace Avalonia.Media |
|||
{ |
|||
public sealed class GlyphTypeface : IDisposable |
|||
{ |
|||
public GlyphTypeface(Typeface typeface) |
|||
: this(FontManager.Current.PlatformImpl.CreateGlyphTypeface(typeface)) |
|||
{ |
|||
} |
|||
|
|||
public GlyphTypeface(IGlyphTypefaceImpl platformImpl) |
|||
{ |
|||
PlatformImpl = platformImpl; |
|||
} |
|||
|
|||
public IGlyphTypefaceImpl PlatformImpl { get; } |
|||
|
|||
/// <summary>
|
|||
/// Gets the font design units per em.
|
|||
/// </summary>
|
|||
public short DesignEmHeight => PlatformImpl.DesignEmHeight; |
|||
|
|||
/// <summary>
|
|||
/// Gets the recommended distance above the baseline in design em size.
|
|||
/// </summary>
|
|||
public int Ascent => PlatformImpl.Ascent; |
|||
|
|||
/// <summary>
|
|||
/// Gets the recommended distance under the baseline in design em size.
|
|||
/// </summary>
|
|||
public int Descent => PlatformImpl.Descent; |
|||
|
|||
/// <summary>
|
|||
/// Gets the recommended additional space between two lines of text in design em size.
|
|||
/// </summary>
|
|||
public int LineGap => PlatformImpl.LineGap; |
|||
|
|||
/// <summary>
|
|||
/// Gets the recommended line height.
|
|||
/// </summary>
|
|||
public int LineHeight => Descent - Ascent + LineGap; |
|||
|
|||
/// <summary>
|
|||
/// Gets a value that indicates the distance of the underline from the baseline in design em size.
|
|||
/// </summary>
|
|||
public int UnderlinePosition => PlatformImpl.UnderlinePosition; |
|||
|
|||
/// <summary>
|
|||
/// Gets a value that indicates the thickness of the underline in design em size.
|
|||
/// </summary>
|
|||
public int UnderlineThickness => PlatformImpl.UnderlineThickness; |
|||
|
|||
/// <summary>
|
|||
/// Gets a value that indicates the distance of the strikethrough from the baseline in design em size.
|
|||
/// </summary>
|
|||
public int StrikethroughPosition => PlatformImpl.StrikethroughPosition; |
|||
|
|||
/// <summary>
|
|||
/// Gets a value that indicates the thickness of the underline in design em size.
|
|||
/// </summary>
|
|||
public int StrikethroughThickness => PlatformImpl.StrikethroughThickness; |
|||
|
|||
/// <summary>
|
|||
/// A <see cref="bool"/> value indicating whether all glyphs in the font have the same advancement.
|
|||
/// </summary>
|
|||
public bool IsFixedPitch => PlatformImpl.IsFixedPitch; |
|||
|
|||
/// <summary>
|
|||
/// Returns an glyph index for the specified codepoint.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// Returns a replacement glyph if a glyph isn't found.
|
|||
/// </remarks>
|
|||
/// <param name="codepoint">The codepoint.</param>
|
|||
/// <returns>
|
|||
/// A glyph index.
|
|||
/// </returns>
|
|||
public ushort GetGlyph(uint codepoint) => PlatformImpl.GetGlyph(codepoint); |
|||
|
|||
/// <summary>
|
|||
/// Tries to get an glyph index for specified codepoint.
|
|||
/// </summary>
|
|||
/// <param name="codepoint">The codepoint.</param>
|
|||
/// <param name="glyph">A glyph index.</param>
|
|||
/// <returns>
|
|||
/// <c>true</c> if an glyph index was found, <c>false</c> otherwise.
|
|||
/// </returns>
|
|||
public bool TryGetGlyph(uint codepoint, out ushort glyph) |
|||
{ |
|||
glyph = PlatformImpl.GetGlyph(codepoint); |
|||
|
|||
return glyph != 0; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Returns an array of glyph indices. Codepoints that are not represented by the font are returned as <code>0</code>.
|
|||
/// </summary>
|
|||
/// <param name="codepoints">The codepoints to map.</param>
|
|||
/// <returns></returns>
|
|||
public ushort[] GetGlyphs(ReadOnlySpan<uint> codepoints) => PlatformImpl.GetGlyphs(codepoints); |
|||
|
|||
/// <summary>
|
|||
/// Returns the glyph advance for the specified glyph.
|
|||
/// </summary>
|
|||
/// <param name="glyph">The glyph.</param>
|
|||
/// <returns>
|
|||
/// The advance.
|
|||
/// </returns>
|
|||
public int GetGlyphAdvance(ushort glyph) => PlatformImpl.GetGlyphAdvance(glyph); |
|||
|
|||
/// <summary>
|
|||
/// Returns an array of glyph advances in design em size.
|
|||
/// </summary>
|
|||
/// <param name="glyphs">The glyph indices.</param>
|
|||
/// <returns></returns>
|
|||
public int[] GetGlyphAdvances(ReadOnlySpan<ushort> glyphs) => PlatformImpl.GetGlyphAdvances(glyphs); |
|||
|
|||
void IDisposable.Dispose() |
|||
{ |
|||
PlatformImpl?.Dispose(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,33 +1,33 @@ |
|||
namespace Avalonia.Media.TextFormatting |
|||
{ |
|||
/// <summary>
|
|||
/// A metric that holds information about font specific measurements.
|
|||
/// A metric that holds information about text specific measurements.
|
|||
/// </summary>
|
|||
public readonly struct FontMetrics |
|||
public readonly struct TextMetrics |
|||
{ |
|||
public FontMetrics(Typeface typeface, double fontRenderingEmSize) |
|||
public TextMetrics(Typeface typeface, double fontRenderingEmSize) |
|||
{ |
|||
var glyphTypeface = typeface.GlyphTypeface; |
|||
var fontMetrics = typeface.GlyphTypeface.Metrics; |
|||
|
|||
var scale = fontRenderingEmSize / glyphTypeface.DesignEmHeight; |
|||
var scale = fontRenderingEmSize / fontMetrics.DesignEmHeight; |
|||
|
|||
FontRenderingEmSize = fontRenderingEmSize; |
|||
|
|||
Ascent = glyphTypeface.Ascent * scale; |
|||
Ascent = fontMetrics.Ascent * scale; |
|||
|
|||
Descent = glyphTypeface.Descent * scale; |
|||
Descent = fontMetrics.Descent * scale; |
|||
|
|||
LineGap = glyphTypeface.LineGap * scale; |
|||
LineGap = fontMetrics.LineGap * scale; |
|||
|
|||
LineHeight = Descent - Ascent + LineGap; |
|||
|
|||
UnderlineThickness = glyphTypeface.UnderlineThickness * scale; |
|||
UnderlineThickness = fontMetrics.UnderlineThickness * scale; |
|||
|
|||
UnderlinePosition = glyphTypeface.UnderlinePosition * scale; |
|||
UnderlinePosition = fontMetrics.UnderlinePosition * scale; |
|||
|
|||
StrikethroughThickness = glyphTypeface.StrikethroughThickness * scale; |
|||
StrikethroughThickness = fontMetrics.StrikethroughThickness * scale; |
|||
|
|||
StrikethroughPosition = glyphTypeface.StrikethroughPosition * scale; |
|||
StrikethroughPosition = fontMetrics.StrikethroughPosition * scale; |
|||
} |
|||
|
|||
/// <summary>
|
|||
@ -0,0 +1,22 @@ |
|||
using System; |
|||
using System.Drawing; |
|||
|
|||
namespace Avalonia.Platform |
|||
{ |
|||
public interface IGlyphRunBuffer |
|||
{ |
|||
Span<ushort> GlyphIndices { get; } |
|||
|
|||
IGlyphRunImpl Build(); |
|||
} |
|||
|
|||
public interface IHorizontalGlyphRunBuffer : IGlyphRunBuffer |
|||
{ |
|||
Span<float> GlyphPositions { get; } |
|||
} |
|||
|
|||
public interface IPositionedGlyphRunBuffer : IGlyphRunBuffer |
|||
{ |
|||
Span<PointF> GlyphPositions { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,463 @@ |
|||
// (c) Copyright Microsoft Corporation.
|
|||
// This source is subject to the Microsoft Public License (Ms-PL).
|
|||
// Please see https://go.microsoft.com/fwlink/?LinkID=131993 for details.
|
|||
// All other rights reserved.
|
|||
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Avalonia.Controls.Templates; |
|||
using Avalonia.Data; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
public partial class AutoCompleteBox |
|||
{ |
|||
public static readonly StyledProperty<string?> WatermarkProperty = |
|||
TextBox.WatermarkProperty.AddOwner<AutoCompleteBox>(); |
|||
|
|||
/// <summary>
|
|||
/// Identifies the <see cref="MinimumPrefixLength" /> property.
|
|||
/// </summary>
|
|||
/// <value>The identifier for the <see cref="MinimumPrefixLength" /> property.</value>
|
|||
public static readonly StyledProperty<int> MinimumPrefixLengthProperty = |
|||
AvaloniaProperty.Register<AutoCompleteBox, int>( |
|||
nameof(MinimumPrefixLength), 1, |
|||
validate: IsValidMinimumPrefixLength); |
|||
|
|||
/// <summary>
|
|||
/// Identifies the <see cref="MinimumPopulateDelay" /> property.
|
|||
/// </summary>
|
|||
/// <value>The identifier for the <see cref="MinimumPopulateDelay" /> property.</value>
|
|||
public static readonly StyledProperty<TimeSpan> MinimumPopulateDelayProperty = |
|||
AvaloniaProperty.Register<AutoCompleteBox, TimeSpan>( |
|||
nameof(MinimumPopulateDelay), |
|||
TimeSpan.Zero, |
|||
validate: IsValidMinimumPopulateDelay); |
|||
|
|||
/// <summary>
|
|||
/// Identifies the <see cref="MaxDropDownHeight" /> property.
|
|||
/// </summary>
|
|||
/// <value>The identifier for the <see cref="MaxDropDownHeight" /> property.</value>
|
|||
public static readonly StyledProperty<double> MaxDropDownHeightProperty = |
|||
AvaloniaProperty.Register<AutoCompleteBox, double>( |
|||
nameof(MaxDropDownHeight), |
|||
double.PositiveInfinity, |
|||
validate: IsValidMaxDropDownHeight); |
|||
|
|||
/// <summary>
|
|||
/// Identifies the <see cref="IsTextCompletionEnabled" /> property.
|
|||
/// </summary>
|
|||
/// <value>The identifier for the <see cref="IsTextCompletionEnabled" /> property.</value>
|
|||
public static readonly StyledProperty<bool> IsTextCompletionEnabledProperty = |
|||
AvaloniaProperty.Register<AutoCompleteBox, bool>(nameof(IsTextCompletionEnabled)); |
|||
|
|||
/// <summary>
|
|||
/// Identifies the <see cref="ItemTemplate" /> property.
|
|||
/// </summary>
|
|||
/// <value>The identifier for the <see cref="ItemTemplate" /> property.</value>
|
|||
public static readonly StyledProperty<IDataTemplate> ItemTemplateProperty = |
|||
AvaloniaProperty.Register<AutoCompleteBox, IDataTemplate>(nameof(ItemTemplate)); |
|||
|
|||
/// <summary>
|
|||
/// Identifies the <see cref="IsDropDownOpen" /> property.
|
|||
/// </summary>
|
|||
/// <value>The identifier for the <see cref="IsDropDownOpen" /> property.</value>
|
|||
public static readonly DirectProperty<AutoCompleteBox, bool> IsDropDownOpenProperty = |
|||
AvaloniaProperty.RegisterDirect<AutoCompleteBox, bool>( |
|||
nameof(IsDropDownOpen), |
|||
o => o.IsDropDownOpen, |
|||
(o, v) => o.IsDropDownOpen = v); |
|||
|
|||
/// <summary>
|
|||
/// Identifies the <see cref="SelectedItem" /> property.
|
|||
/// </summary>
|
|||
/// <value>The identifier the <see cref="SelectedItem" /> property.</value>
|
|||
public static readonly DirectProperty<AutoCompleteBox, object?> SelectedItemProperty = |
|||
AvaloniaProperty.RegisterDirect<AutoCompleteBox, object?>( |
|||
nameof(SelectedItem), |
|||
o => o.SelectedItem, |
|||
(o, v) => o.SelectedItem = v, |
|||
defaultBindingMode: BindingMode.TwoWay, |
|||
enableDataValidation: true); |
|||
|
|||
/// <summary>
|
|||
/// Identifies the <see cref="Text" /> property.
|
|||
/// </summary>
|
|||
/// <value>The identifier for the <see cref="Text" /> property.</value>
|
|||
public static readonly DirectProperty<AutoCompleteBox, string?> TextProperty = |
|||
TextBlock.TextProperty.AddOwnerWithDataValidation<AutoCompleteBox>( |
|||
o => o.Text, |
|||
(o, v) => o.Text = v, |
|||
defaultBindingMode: BindingMode.TwoWay, |
|||
enableDataValidation: true); |
|||
|
|||
/// <summary>
|
|||
/// Identifies the <see cref="SearchText" /> property.
|
|||
/// </summary>
|
|||
/// <value>The identifier for the <see cref="SearchText" /> property.</value>
|
|||
public static readonly DirectProperty<AutoCompleteBox, string?> SearchTextProperty = |
|||
AvaloniaProperty.RegisterDirect<AutoCompleteBox, string?>( |
|||
nameof(SearchText), |
|||
o => o.SearchText, |
|||
unsetValue: string.Empty); |
|||
|
|||
/// <summary>
|
|||
/// Gets the identifier for the <see cref="FilterMode" /> property.
|
|||
/// </summary>
|
|||
public static readonly StyledProperty<AutoCompleteFilterMode> FilterModeProperty = |
|||
AvaloniaProperty.Register<AutoCompleteBox, AutoCompleteFilterMode>( |
|||
nameof(FilterMode), |
|||
defaultValue: AutoCompleteFilterMode.StartsWith, |
|||
validate: IsValidFilterMode); |
|||
|
|||
/// <summary>
|
|||
/// Identifies the <see cref="ItemFilter" /> property.
|
|||
/// </summary>
|
|||
/// <value>The identifier for the <see cref="ItemFilter" /> property.</value>
|
|||
public static readonly DirectProperty<AutoCompleteBox, AutoCompleteFilterPredicate<object?>?> ItemFilterProperty = |
|||
AvaloniaProperty.RegisterDirect<AutoCompleteBox, AutoCompleteFilterPredicate<object?>?>( |
|||
nameof(ItemFilter), |
|||
o => o.ItemFilter, |
|||
(o, v) => o.ItemFilter = v); |
|||
|
|||
/// <summary>
|
|||
/// Identifies the <see cref="TextFilter" /> property.
|
|||
/// </summary>
|
|||
/// <value>The identifier for the <see cref="TextFilter" /> property.</value>
|
|||
public static readonly DirectProperty<AutoCompleteBox, AutoCompleteFilterPredicate<string?>?> TextFilterProperty = |
|||
AvaloniaProperty.RegisterDirect<AutoCompleteBox, AutoCompleteFilterPredicate<string?>?>( |
|||
nameof(TextFilter), |
|||
o => o.TextFilter, |
|||
(o, v) => o.TextFilter = v, |
|||
unsetValue: AutoCompleteSearch.GetFilter(AutoCompleteFilterMode.StartsWith)); |
|||
|
|||
/// <summary>
|
|||
/// Identifies the <see cref="ItemSelector" /> property.
|
|||
/// </summary>
|
|||
/// <value>The identifier for the <see cref="ItemSelector" /> property.</value>
|
|||
public static readonly DirectProperty<AutoCompleteBox, AutoCompleteSelector<object>?> ItemSelectorProperty = |
|||
AvaloniaProperty.RegisterDirect<AutoCompleteBox, AutoCompleteSelector<object>?>( |
|||
nameof(ItemSelector), |
|||
o => o.ItemSelector, |
|||
(o, v) => o.ItemSelector = v); |
|||
|
|||
/// <summary>
|
|||
/// Identifies the <see cref="TextSelector" /> property.
|
|||
/// </summary>
|
|||
/// <value>The identifier for the <see cref="TextSelector" /> property.</value>
|
|||
public static readonly DirectProperty<AutoCompleteBox, AutoCompleteSelector<string?>?> TextSelectorProperty = |
|||
AvaloniaProperty.RegisterDirect<AutoCompleteBox, AutoCompleteSelector<string?>?>( |
|||
nameof(TextSelector), |
|||
o => o.TextSelector, |
|||
(o, v) => o.TextSelector = v); |
|||
|
|||
/// <summary>
|
|||
/// Identifies the <see cref="Items" /> property.
|
|||
/// </summary>
|
|||
/// <value>The identifier for the <see cref="Items" /> property.</value>
|
|||
public static readonly DirectProperty<AutoCompleteBox, IEnumerable?> ItemsProperty = |
|||
AvaloniaProperty.RegisterDirect<AutoCompleteBox, IEnumerable?>( |
|||
nameof(Items), |
|||
o => o.Items, |
|||
(o, v) => o.Items = v); |
|||
|
|||
public static readonly DirectProperty<AutoCompleteBox, Func<string?, CancellationToken, Task<IEnumerable<object>>>?> AsyncPopulatorProperty = |
|||
AvaloniaProperty.RegisterDirect<AutoCompleteBox, Func<string?, CancellationToken, Task<IEnumerable<object>>>?>( |
|||
nameof(AsyncPopulator), |
|||
o => o.AsyncPopulator, |
|||
(o, v) => o.AsyncPopulator = v); |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the minimum number of characters required to be entered
|
|||
/// in the text box before the <see cref="AutoCompleteBox" /> displays possible matches.
|
|||
/// </summary>
|
|||
/// <value>
|
|||
/// The minimum number of characters to be entered in the text box
|
|||
/// before the <see cref="AutoCompleteBox" />
|
|||
/// displays possible matches. The default is 1.
|
|||
/// </value>
|
|||
/// <remarks>
|
|||
/// If you set MinimumPrefixLength to -1, the AutoCompleteBox will
|
|||
/// not provide possible matches. There is no maximum value, but
|
|||
/// setting MinimumPrefixLength to value that is too large will
|
|||
/// prevent the AutoCompleteBox from providing possible matches as well.
|
|||
/// </remarks>
|
|||
public int MinimumPrefixLength |
|||
{ |
|||
get => GetValue(MinimumPrefixLengthProperty); |
|||
set => SetValue(MinimumPrefixLengthProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets a value indicating whether the first possible match
|
|||
/// found during the filtering process will be displayed automatically
|
|||
/// in the text box.
|
|||
/// </summary>
|
|||
/// <value>
|
|||
/// True if the first possible match found will be displayed
|
|||
/// automatically in the text box; otherwise, false. The default is
|
|||
/// false.
|
|||
/// </value>
|
|||
public bool IsTextCompletionEnabled |
|||
{ |
|||
get => GetValue(IsTextCompletionEnabledProperty); |
|||
set => SetValue(IsTextCompletionEnabledProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the <see cref="T:Avalonia.DataTemplate" /> used
|
|||
/// to display each item in the drop-down portion of the control.
|
|||
/// </summary>
|
|||
/// <value>The <see cref="T:Avalonia.DataTemplate" /> used to
|
|||
/// display each item in the drop-down. The default is null.</value>
|
|||
/// <remarks>
|
|||
/// You use the ItemTemplate property to specify the visualization
|
|||
/// of the data objects in the drop-down portion of the AutoCompleteBox
|
|||
/// control. If your AutoCompleteBox is bound to a collection and you
|
|||
/// do not provide specific display instructions by using a
|
|||
/// DataTemplate, the resulting UI of each item is a string
|
|||
/// representation of each object in the underlying collection.
|
|||
/// </remarks>
|
|||
public IDataTemplate ItemTemplate |
|||
{ |
|||
get => GetValue(ItemTemplateProperty); |
|||
set => SetValue(ItemTemplateProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the minimum delay, after text is typed
|
|||
/// in the text box before the
|
|||
/// <see cref="AutoCompleteBox" /> control
|
|||
/// populates the list of possible matches in the drop-down.
|
|||
/// </summary>
|
|||
/// <value>The minimum delay, after text is typed in
|
|||
/// the text box, but before the
|
|||
/// <see cref="AutoCompleteBox" /> populates
|
|||
/// the list of possible matches in the drop-down. The default is 0.</value>
|
|||
public TimeSpan MinimumPopulateDelay |
|||
{ |
|||
get => GetValue(MinimumPopulateDelayProperty); |
|||
set => SetValue(MinimumPopulateDelayProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the maximum height of the drop-down portion of the
|
|||
/// <see cref="AutoCompleteBox" /> control.
|
|||
/// </summary>
|
|||
/// <value>The maximum height of the drop-down portion of the
|
|||
/// <see cref="AutoCompleteBox" /> control.
|
|||
/// The default is <see cref="F:System.Double.PositiveInfinity" />.</value>
|
|||
/// <exception cref="T:System.ArgumentException">The specified value is less than 0.</exception>
|
|||
public double MaxDropDownHeight |
|||
{ |
|||
get => GetValue(MaxDropDownHeightProperty); |
|||
set => SetValue(MaxDropDownHeightProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets a value indicating whether the drop-down portion of
|
|||
/// the control is open.
|
|||
/// </summary>
|
|||
/// <value>
|
|||
/// True if the drop-down is open; otherwise, false. The default is
|
|||
/// false.
|
|||
/// </value>
|
|||
public bool IsDropDownOpen |
|||
{ |
|||
get => _isDropDownOpen; |
|||
set => SetAndRaise(IsDropDownOpenProperty, ref _isDropDownOpen, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the <see cref="T:Avalonia.Data.Binding" /> that
|
|||
/// is used to get the values for display in the text portion of
|
|||
/// the <see cref="AutoCompleteBox" />
|
|||
/// control.
|
|||
/// </summary>
|
|||
/// <value>The <see cref="T:Avalonia.Data.IBinding" /> object used
|
|||
/// when binding to a collection property.</value>
|
|||
[AssignBinding] |
|||
public IBinding? ValueMemberBinding |
|||
{ |
|||
get => _valueBindingEvaluator?.ValueBinding; |
|||
set |
|||
{ |
|||
if (ValueMemberBinding != value) |
|||
{ |
|||
_valueBindingEvaluator = new BindingEvaluator<string>(value); |
|||
OnValueMemberBindingChanged(value); |
|||
} |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the selected item in the drop-down.
|
|||
/// </summary>
|
|||
/// <value>The selected item in the drop-down.</value>
|
|||
/// <remarks>
|
|||
/// If the IsTextCompletionEnabled property is true and text typed by
|
|||
/// the user matches an item in the ItemsSource collection, which is
|
|||
/// then displayed in the text box, the SelectedItem property will be
|
|||
/// a null reference.
|
|||
/// </remarks>
|
|||
public object? SelectedItem |
|||
{ |
|||
get => _selectedItem; |
|||
set => SetAndRaise(SelectedItemProperty, ref _selectedItem, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the text in the text box portion of the
|
|||
/// <see cref="AutoCompleteBox" /> control.
|
|||
/// </summary>
|
|||
/// <value>The text in the text box portion of the
|
|||
/// <see cref="AutoCompleteBox" /> control.</value>
|
|||
public string? Text |
|||
{ |
|||
get => _text; |
|||
set => SetAndRaise(TextProperty, ref _text, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the text that is used to filter items in the
|
|||
/// <see cref="Items" /> item collection.
|
|||
/// </summary>
|
|||
/// <value>The text that is used to filter items in the
|
|||
/// <see cref="Items" /> item collection.</value>
|
|||
/// <remarks>
|
|||
/// The SearchText value is typically the same as the
|
|||
/// Text property, but is set after the TextChanged event occurs
|
|||
/// and before the Populating event.
|
|||
/// </remarks>
|
|||
public string? SearchText |
|||
{ |
|||
get => _searchText; |
|||
private set |
|||
{ |
|||
try |
|||
{ |
|||
_allowWrite = true; |
|||
SetAndRaise(SearchTextProperty, ref _searchText, value); |
|||
} |
|||
finally |
|||
{ |
|||
_allowWrite = false; |
|||
} |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets how the text in the text box is used to filter items
|
|||
/// specified by the <see cref="Items" />
|
|||
/// property for display in the drop-down.
|
|||
/// </summary>
|
|||
/// <value>One of the <see cref="AutoCompleteFilterMode" />
|
|||
/// values The default is <see cref="AutoCompleteFilterMode.StartsWith" />.</value>
|
|||
/// <exception cref="T:System.ArgumentException">The specified value is not a valid
|
|||
/// <see cref="AutoCompleteFilterMode" />.</exception>
|
|||
/// <remarks>
|
|||
/// Use the FilterMode property to specify how possible matches are
|
|||
/// filtered. For example, possible matches can be filtered in a
|
|||
/// predefined or custom way. The search mode is automatically set to
|
|||
/// Custom if you set the ItemFilter property.
|
|||
/// </remarks>
|
|||
public AutoCompleteFilterMode FilterMode |
|||
{ |
|||
get => GetValue(FilterModeProperty); |
|||
set => SetValue(FilterModeProperty, value); |
|||
} |
|||
|
|||
public string? Watermark |
|||
{ |
|||
get => GetValue(WatermarkProperty); |
|||
set => SetValue(WatermarkProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the custom method that uses user-entered text to filter
|
|||
/// the items specified by the <see cref="Items" />
|
|||
/// property for display in the drop-down.
|
|||
/// </summary>
|
|||
/// <value>The custom method that uses the user-entered text to filter
|
|||
/// the items specified by the <see cref="Items" />
|
|||
/// property. The default is null.</value>
|
|||
/// <remarks>
|
|||
/// The filter mode is automatically set to Custom if you set the
|
|||
/// ItemFilter property.
|
|||
/// </remarks>
|
|||
public AutoCompleteFilterPredicate<object?>? ItemFilter |
|||
{ |
|||
get => _itemFilter; |
|||
set => SetAndRaise(ItemFilterProperty, ref _itemFilter, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the custom method that uses the user-entered text to
|
|||
/// filter items specified by the <see cref="Items" />
|
|||
/// property in a text-based way for display in the drop-down.
|
|||
/// </summary>
|
|||
/// <value>The custom method that uses the user-entered text to filter
|
|||
/// items specified by the <see cref="Items" />
|
|||
/// property in a text-based way for display in the drop-down.</value>
|
|||
/// <remarks>
|
|||
/// The search mode is automatically set to Custom if you set the
|
|||
/// TextFilter property.
|
|||
/// </remarks>
|
|||
public AutoCompleteFilterPredicate<string?>? TextFilter |
|||
{ |
|||
get => _textFilter; |
|||
set => SetAndRaise(TextFilterProperty, ref _textFilter, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the custom method that combines the user-entered
|
|||
/// text and one of the items specified by the <see cref="Items" />.
|
|||
/// </summary>
|
|||
/// <value>
|
|||
/// The custom method that combines the user-entered
|
|||
/// text and one of the items specified by the <see cref="Items" />.
|
|||
/// </value>
|
|||
public AutoCompleteSelector<object>? ItemSelector |
|||
{ |
|||
get => _itemSelector; |
|||
set => SetAndRaise(ItemSelectorProperty, ref _itemSelector, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the custom method that combines the user-entered
|
|||
/// text and one of the items specified by the
|
|||
/// <see cref="Items" /> in a text-based way.
|
|||
/// </summary>
|
|||
/// <value>
|
|||
/// The custom method that combines the user-entered
|
|||
/// text and one of the items specified by the <see cref="Items" />
|
|||
/// in a text-based way.
|
|||
/// </value>
|
|||
public AutoCompleteSelector<string?>? TextSelector |
|||
{ |
|||
get => _textSelector; |
|||
set => SetAndRaise(TextSelectorProperty, ref _textSelector, value); |
|||
} |
|||
|
|||
public Func<string?, CancellationToken, Task<IEnumerable<object>>>? AsyncPopulator |
|||
{ |
|||
get => _asyncPopulator; |
|||
set => SetAndRaise(AsyncPopulatorProperty, ref _asyncPopulator, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets a collection that is used to generate the items for the
|
|||
/// drop-down portion of the <see cref="AutoCompleteBox" /> control.
|
|||
/// </summary>
|
|||
/// <value>The collection that is used to generate the items of the
|
|||
/// drop-down portion of the <see cref="AutoCompleteBox" /> control.</value>
|
|||
public IEnumerable? Items |
|||
{ |
|||
get => _itemsEnumerable; |
|||
set => SetAndRaise(ItemsProperty, ref _itemsEnumerable, value); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,131 @@ |
|||
// (c) Copyright Microsoft Corporation.
|
|||
// This source is subject to the Microsoft Public License (Ms-PL).
|
|||
// Please see https://go.microsoft.com/fwlink/?LinkID=131993 for details.
|
|||
// All other rights reserved.
|
|||
|
|||
using System; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// Specifies how text in the text box portion of the <see cref="AutoCompleteBox" />
|
|||
/// control is used to filter items specified by the <see cref="AutoCompleteBox.Items" />
|
|||
/// property for display in the drop-down.
|
|||
/// </summary>
|
|||
public enum AutoCompleteFilterMode |
|||
{ |
|||
/// <summary>
|
|||
/// Specifies that no filter is used. All items are returned.
|
|||
/// </summary>
|
|||
None = 0, |
|||
|
|||
/// <summary>
|
|||
/// Specifies a culture-sensitive, case-insensitive filter where the
|
|||
/// returned items start with the specified text. The filter uses the
|
|||
/// <see cref="String.StartsWith(String,StringComparison)" />
|
|||
/// method, specifying
|
|||
/// <see cref="StringComparer.CurrentCultureIgnoreCase" /> as
|
|||
/// the string comparison criteria.
|
|||
/// </summary>
|
|||
StartsWith = 1, |
|||
|
|||
/// <summary>
|
|||
/// Specifies a culture-sensitive, case-sensitive filter where the
|
|||
/// returned items start with the specified text. The filter uses the
|
|||
/// <see cref="String.StartsWith(String,StringComparison)" />
|
|||
/// method, specifying
|
|||
/// <see cref="StringComparer.CurrentCulture" /> as the string
|
|||
/// comparison criteria.
|
|||
/// </summary>
|
|||
StartsWithCaseSensitive = 2, |
|||
|
|||
/// <summary>
|
|||
/// Specifies an ordinal, case-insensitive filter where the returned
|
|||
/// items start with the specified text. The filter uses the
|
|||
/// <see cref="String.StartsWith(String,StringComparison)" />
|
|||
/// method, specifying
|
|||
/// <see cref="StringComparer.OrdinalIgnoreCase" /> as the
|
|||
/// string comparison criteria.
|
|||
/// </summary>
|
|||
StartsWithOrdinal = 3, |
|||
|
|||
/// <summary>
|
|||
/// Specifies an ordinal, case-sensitive filter where the returned items
|
|||
/// start with the specified text. The filter uses the
|
|||
/// <see cref="String.StartsWith(String,StringComparison)" />
|
|||
/// method, specifying <see cref="StringComparer.Ordinal" /> as
|
|||
/// the string comparison criteria.
|
|||
/// </summary>
|
|||
StartsWithOrdinalCaseSensitive = 4, |
|||
|
|||
/// <summary>
|
|||
/// Specifies a culture-sensitive, case-insensitive filter where the
|
|||
/// returned items contain the specified text.
|
|||
/// </summary>
|
|||
Contains = 5, |
|||
|
|||
/// <summary>
|
|||
/// Specifies a culture-sensitive, case-sensitive filter where the
|
|||
/// returned items contain the specified text.
|
|||
/// </summary>
|
|||
ContainsCaseSensitive = 6, |
|||
|
|||
/// <summary>
|
|||
/// Specifies an ordinal, case-insensitive filter where the returned
|
|||
/// items contain the specified text.
|
|||
/// </summary>
|
|||
ContainsOrdinal = 7, |
|||
|
|||
/// <summary>
|
|||
/// Specifies an ordinal, case-sensitive filter where the returned items
|
|||
/// contain the specified text.
|
|||
/// </summary>
|
|||
ContainsOrdinalCaseSensitive = 8, |
|||
|
|||
/// <summary>
|
|||
/// Specifies a culture-sensitive, case-insensitive filter where the
|
|||
/// returned items equal the specified text. The filter uses the
|
|||
/// <see cref="String.Equals(String,StringComparison)" />
|
|||
/// method, specifying
|
|||
/// <see cref="StringComparer.CurrentCultureIgnoreCase" /> as
|
|||
/// the search comparison criteria.
|
|||
/// </summary>
|
|||
Equals = 9, |
|||
|
|||
/// <summary>
|
|||
/// Specifies a culture-sensitive, case-sensitive filter where the
|
|||
/// returned items equal the specified text. The filter uses the
|
|||
/// <see cref="String.Equals(String,StringComparison)" />
|
|||
/// method, specifying
|
|||
/// <see cref="StringComparer.CurrentCulture" /> as the string
|
|||
/// comparison criteria.
|
|||
/// </summary>
|
|||
EqualsCaseSensitive = 10, |
|||
|
|||
/// <summary>
|
|||
/// Specifies an ordinal, case-insensitive filter where the returned
|
|||
/// items equal the specified text. The filter uses the
|
|||
/// <see cref="String.Equals(String,StringComparison)" />
|
|||
/// method, specifying
|
|||
/// <see cref="StringComparer.OrdinalIgnoreCase" /> as the
|
|||
/// string comparison criteria.
|
|||
/// </summary>
|
|||
EqualsOrdinal = 11, |
|||
|
|||
/// <summary>
|
|||
/// Specifies an ordinal, case-sensitive filter where the returned items
|
|||
/// equal the specified text. The filter uses the
|
|||
/// <see cref="String.Equals(String,StringComparison)" />
|
|||
/// method, specifying <see cref="StringComparer.Ordinal" /> as
|
|||
/// the string comparison criteria.
|
|||
/// </summary>
|
|||
EqualsOrdinalCaseSensitive = 12, |
|||
|
|||
/// <summary>
|
|||
/// Specifies that a custom filter is used. This mode is used when the
|
|||
/// <see cref="AutoCompleteBox.TextFilter" /> or <see cref="AutoCompleteBox.ItemFilter" />
|
|||
/// properties are set.
|
|||
/// </summary>
|
|||
Custom = 13, |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
// (c) Copyright Microsoft Corporation.
|
|||
// This source is subject to the Microsoft Public License (Ms-PL).
|
|||
// Please see https://go.microsoft.com/fwlink/?LinkID=131993 for details.
|
|||
// All other rights reserved.
|
|||
|
|||
using System; |
|||
using System.Collections; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// Provides data for the
|
|||
/// <see cref="E:Avalonia.Controls.AutoCompleteBox.Populated" />
|
|||
/// event.
|
|||
/// </summary>
|
|||
public class PopulatedEventArgs : EventArgs |
|||
{ |
|||
/// <summary>
|
|||
/// Gets the list of possible matches added to the drop-down portion of
|
|||
/// the <see cref="T:Avalonia.Controls.AutoCompleteBox" />
|
|||
/// control.
|
|||
/// </summary>
|
|||
/// <value>The list of possible matches added to the
|
|||
/// <see cref="T:Avalonia.Controls.AutoCompleteBox" />.</value>
|
|||
public IEnumerable Data { get; private set; } |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the
|
|||
/// <see cref="T:Avalonia.Controls.PopulatedEventArgs" />.
|
|||
/// </summary>
|
|||
/// <param name="data">The list of possible matches added to the
|
|||
/// drop-down portion of the
|
|||
/// <see cref="T:Avalonia.Controls.AutoCompleteBox" /> control.</param>
|
|||
public PopulatedEventArgs(IEnumerable data) |
|||
{ |
|||
Data = data; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
// (c) Copyright Microsoft Corporation.
|
|||
// This source is subject to the Microsoft Public License (Ms-PL).
|
|||
// Please see https://go.microsoft.com/fwlink/?LinkID=131993 for details.
|
|||
// All other rights reserved.
|
|||
|
|||
using System.ComponentModel; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// Provides data for the
|
|||
/// <see cref="E:Avalonia.Controls.AutoCompleteBox.Populating" />
|
|||
/// event.
|
|||
/// </summary>
|
|||
public class PopulatingEventArgs : CancelEventArgs |
|||
{ |
|||
/// <summary>
|
|||
/// Gets the text that is used to determine which items to display in
|
|||
/// the <see cref="T:Avalonia.Controls.AutoCompleteBox" />
|
|||
/// control.
|
|||
/// </summary>
|
|||
/// <value>The text that is used to determine which items to display in
|
|||
/// the <see cref="T:Avalonia.Controls.AutoCompleteBox" />.</value>
|
|||
public string? Parameter { get; private set; } |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the
|
|||
/// <see cref="T:Avalonia.Controls.PopulatingEventArgs" />.
|
|||
/// </summary>
|
|||
/// <param name="parameter">The value of the
|
|||
/// <see cref="P:Avalonia.Controls.AutoCompleteBox.SearchText" />
|
|||
/// property, which is used to filter items for the
|
|||
/// <see cref="T:Avalonia.Controls.AutoCompleteBox" /> control.</param>
|
|||
public PopulatingEventArgs(string? parameter) |
|||
{ |
|||
Parameter = parameter; |
|||
} |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue