csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
2.0 KiB
62 lines
2.0 KiB
using System;
|
|
using Avalonia.Input;
|
|
using Avalonia.Input.Platform;
|
|
using Avalonia.Metadata;
|
|
using Avalonia.Threading;
|
|
|
|
namespace Avalonia.Platform
|
|
{
|
|
/// <summary>
|
|
/// A default implementation of <see cref="IPlatformSettings"/> for platforms.
|
|
/// </summary>
|
|
[PrivateApi]
|
|
public class DefaultPlatformSettings : IPlatformSettings
|
|
{
|
|
public virtual Size GetTapSize(PointerType type)
|
|
{
|
|
return type switch
|
|
{
|
|
PointerType.Touch or PointerType.Pen => new(10, 10),
|
|
_ => new(4, 4),
|
|
};
|
|
}
|
|
|
|
public virtual Size GetDoubleTapSize(PointerType type)
|
|
{
|
|
return type switch
|
|
{
|
|
PointerType.Touch or PointerType.Pen => new(16, 16),
|
|
_ => new(4, 4),
|
|
};
|
|
}
|
|
|
|
public virtual TimeSpan GetDoubleTapTime(PointerType type) => TimeSpan.FromMilliseconds(500);
|
|
|
|
public virtual TimeSpan HoldWaitDuration => TimeSpan.FromMilliseconds(300);
|
|
|
|
public PlatformHotkeyConfiguration HotkeyConfiguration =>
|
|
AvaloniaLocator.Current.GetRequiredService<PlatformHotkeyConfiguration>();
|
|
|
|
public virtual PlatformColorValues GetColorValues()
|
|
{
|
|
return new PlatformColorValues
|
|
{
|
|
ThemeVariant = PlatformThemeVariant.Light
|
|
};
|
|
}
|
|
|
|
public virtual event EventHandler<PlatformColorValues>? ColorValuesChanged;
|
|
|
|
protected virtual void OnColorValuesChanged(PlatformColorValues colorValues)
|
|
{
|
|
Dispatcher.UIThread.Send(
|
|
_ => ColorValuesChanged?.Invoke(this, colorValues));
|
|
}
|
|
|
|
public event EventHandler<EventArgs>? TextScalingChanged;
|
|
|
|
protected virtual void OnTextScaleChanged() => Dispatcher.UIThread.Send(_ => TextScalingChanged?.Invoke(this, EventArgs.Empty));
|
|
|
|
public virtual double GetScaledFontSize(Visual target, double baseFontSize) => baseFontSize;
|
|
}
|
|
}
|
|
|