Enable nullability in all samples (#20379)
This commit is contained in:
committed by
GitHub
parent
cf5b12e700
commit
3e41310917
@@ -2,7 +2,6 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace BindingDemo;
|
|||||||
|
|
||||||
internal class GenericMarkupExtension<T> : MarkupExtension
|
internal class GenericMarkupExtension<T> : MarkupExtension
|
||||||
{
|
{
|
||||||
public T Value { get; set; }
|
public T? Value { get; set; }
|
||||||
|
|
||||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace BindingDemo.ViewModels
|
|||||||
{
|
{
|
||||||
[Phone]
|
[Phone]
|
||||||
[MaxLength(10)]
|
[MaxLength(10)]
|
||||||
public string PhoneNumber { get; set; }
|
public string? PhoneNumber { get; set; }
|
||||||
|
|
||||||
[Range(0, 9)]
|
[Range(0, 9)]
|
||||||
public int LessThan10 { get; set; }
|
public int LessThan10 { get; set; }
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace BindingDemo.ViewModels
|
|||||||
{
|
{
|
||||||
private int _maximum = 10;
|
private int _maximum = 10;
|
||||||
private int _value;
|
private int _value;
|
||||||
private string _valueError;
|
private string? _valueError;
|
||||||
|
|
||||||
public IndeiErrorViewModel()
|
public IndeiErrorViewModel()
|
||||||
{
|
{
|
||||||
@@ -34,16 +34,16 @@ namespace BindingDemo.ViewModels
|
|||||||
set { this.RaiseAndSetIfChanged(ref _value, value); }
|
set { this.RaiseAndSetIfChanged(ref _value, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged;
|
public event EventHandler<DataErrorsChangedEventArgs>? ErrorsChanged;
|
||||||
|
|
||||||
public IEnumerable GetErrors(string propertyName)
|
public IEnumerable GetErrors(string? propertyName)
|
||||||
{
|
{
|
||||||
switch (propertyName)
|
switch (propertyName)
|
||||||
{
|
{
|
||||||
case nameof(Value):
|
case nameof(Value):
|
||||||
return new[] { _valueError };
|
return new[] { _valueError };
|
||||||
default:
|
default:
|
||||||
return null;
|
return Array.Empty<string>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ namespace BindingDemo.ViewModels
|
|||||||
{
|
{
|
||||||
private string _booleanString = "True";
|
private string _booleanString = "True";
|
||||||
private double _doubleValue = 5.0;
|
private double _doubleValue = 5.0;
|
||||||
private string _stringValue = "Simple Binding";
|
private string? _stringValue = "Simple Binding";
|
||||||
private bool _booleanFlag = false;
|
private bool _booleanFlag = false;
|
||||||
private string _currentTime;
|
private string? _currentTime;
|
||||||
private NestedCommandViewModel _nested;
|
private NestedCommandViewModel? _nested;
|
||||||
|
|
||||||
public MainWindowViewModel()
|
public MainWindowViewModel()
|
||||||
{
|
{
|
||||||
@@ -74,7 +74,7 @@ namespace BindingDemo.ViewModels
|
|||||||
set { this.RaiseAndSetIfChanged(ref _doubleValue, value); }
|
set { this.RaiseAndSetIfChanged(ref _doubleValue, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string StringValue
|
public string? StringValue
|
||||||
{
|
{
|
||||||
get { return _stringValue; }
|
get { return _stringValue; }
|
||||||
set { this.RaiseAndSetIfChanged(ref _stringValue, value); }
|
set { this.RaiseAndSetIfChanged(ref _stringValue, value); }
|
||||||
@@ -86,7 +86,7 @@ namespace BindingDemo.ViewModels
|
|||||||
set { this.RaiseAndSetIfChanged(ref _booleanFlag, value); }
|
set { this.RaiseAndSetIfChanged(ref _booleanFlag, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string CurrentTime
|
public string? CurrentTime
|
||||||
{
|
{
|
||||||
get { return _currentTime; }
|
get { return _currentTime; }
|
||||||
private set { this.RaiseAndSetIfChanged(ref _currentTime, value); }
|
private set { this.RaiseAndSetIfChanged(ref _currentTime, value); }
|
||||||
@@ -99,7 +99,7 @@ namespace BindingDemo.ViewModels
|
|||||||
public ExceptionErrorViewModel ExceptionDataValidation { get; } = new ExceptionErrorViewModel();
|
public ExceptionErrorViewModel ExceptionDataValidation { get; } = new ExceptionErrorViewModel();
|
||||||
public IndeiErrorViewModel IndeiDataValidation { get; } = new IndeiErrorViewModel();
|
public IndeiErrorViewModel IndeiDataValidation { get; } = new IndeiErrorViewModel();
|
||||||
|
|
||||||
public NestedCommandViewModel NestedModel
|
public NestedCommandViewModel? NestedModel
|
||||||
{
|
{
|
||||||
get { return _nested; }
|
get { return _nested; }
|
||||||
private set { this.RaiseAndSetIfChanged(ref _nested, value); }
|
private set { this.RaiseAndSetIfChanged(ref _nested, value); }
|
||||||
@@ -119,16 +119,16 @@ namespace BindingDemo.ViewModels
|
|||||||
// Nested class, jsut so we can test it in XAML
|
// Nested class, jsut so we can test it in XAML
|
||||||
public class TestItem<T> : ViewModelBase
|
public class TestItem<T> : ViewModelBase
|
||||||
{
|
{
|
||||||
private T _value;
|
private T? _value;
|
||||||
private string _detail;
|
private string? _detail;
|
||||||
|
|
||||||
public T Value
|
public T? Value
|
||||||
{
|
{
|
||||||
get { return _value; }
|
get { return _value; }
|
||||||
set { this.RaiseAndSetIfChanged(ref this._value, value); }
|
set { this.RaiseAndSetIfChanged(ref this._value, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Detail
|
public string? Detail
|
||||||
{
|
{
|
||||||
get { return _detail; }
|
get { return _detail; }
|
||||||
set { this.RaiseAndSetIfChanged(ref this._detail, value); }
|
set { this.RaiseAndSetIfChanged(ref this._detail, value); }
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
<TargetFramework>$(AvsCurrentAndroidTargetFramework)</TargetFramework>
|
<TargetFramework>$(AvsCurrentAndroidTargetFramework)</TargetFramework>
|
||||||
<SupportedOSPlatformVersion>$(AvsMinSupportedAndroidVersion)</SupportedOSPlatformVersion>
|
<SupportedOSPlatformVersion>$(AvsMinSupportedAndroidVersion)</SupportedOSPlatformVersion>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<ApplicationId>com.Avalonia.ControlCatalog</ApplicationId>
|
<ApplicationId>com.Avalonia.ControlCatalog</ApplicationId>
|
||||||
<ApplicationVersion>1</ApplicationVersion>
|
<ApplicationVersion>1</ApplicationVersion>
|
||||||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
|
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace ControlCatalog.Desktop;
|
|||||||
|
|
||||||
public class EmbedSampleGtk : INativeDemoControl
|
public class EmbedSampleGtk : INativeDemoControl
|
||||||
{
|
{
|
||||||
private Process _mplayer;
|
private Process? _mplayer;
|
||||||
|
|
||||||
public IPlatformHandle CreateControl(bool isSecond, IPlatformHandle parent, Func<IPlatformHandle> createDefault)
|
public IPlatformHandle CreateControl(bool isSecond, IPlatformHandle parent, Func<IPlatformHandle> createDefault)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ internal class MacHelper
|
|||||||
|
|
||||||
internal class MacOSViewHandle : INativeControlHostDestroyableControlHandle
|
internal class MacOSViewHandle : INativeControlHostDestroyableControlHandle
|
||||||
{
|
{
|
||||||
private NSView _view;
|
private NSView? _view;
|
||||||
|
|
||||||
public MacOSViewHandle(NSView view)
|
public MacOSViewHandle(NSView view)
|
||||||
{
|
{
|
||||||
@@ -32,7 +32,7 @@ internal class MacOSViewHandle : INativeControlHostDestroyableControlHandle
|
|||||||
|
|
||||||
public void Destroy()
|
public void Destroy()
|
||||||
{
|
{
|
||||||
_view.Dispose();
|
_view?.Dispose();
|
||||||
_view = null;
|
_view = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ internal unsafe class WinApi
|
|||||||
|
|
||||||
|
|
||||||
[DllImport("kernel32.dll")]
|
[DllImport("kernel32.dll")]
|
||||||
public static extern IntPtr GetModuleHandle(string lpModuleName);
|
public static extern IntPtr GetModuleHandle(string? lpModuleName);
|
||||||
|
|
||||||
[DllImport("user32.dll", SetLastError = true)]
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
public static extern IntPtr CreateWindowEx(
|
public static extern IntPtr CreateWindowEx(
|
||||||
|
|||||||
@@ -74,12 +74,12 @@ namespace ControlCatalog.Desktop
|
|||||||
{
|
{
|
||||||
DispatcherTimer.RunOnce(async () =>
|
DispatcherTimer.RunOnce(async () =>
|
||||||
{
|
{
|
||||||
var window = ((IClassicDesktopStyleApplicationLifetime)Application.Current.ApplicationLifetime)
|
var window = ((IClassicDesktopStyleApplicationLifetime)Application.Current!.ApplicationLifetime!)
|
||||||
.MainWindow;
|
.MainWindow!;
|
||||||
var tc = window.GetLogicalDescendants().OfType<TabControl>().First();
|
var tc = window.GetLogicalDescendants().OfType<TabControl>().First();
|
||||||
foreach (var page in tc.Items.Cast<TabItem>().ToList())
|
foreach (var page in tc.Items.Cast<TabItem>().ToList())
|
||||||
{
|
{
|
||||||
if (page.Header.ToString() == "DatePicker" || page.Header.ToString() == "TreeView")
|
if (page.Header?.ToString() is "DatePicker" or "TreeView")
|
||||||
continue;
|
continue;
|
||||||
Console.WriteLine("Selecting " + page.Header);
|
Console.WriteLine("Selecting " + page.Header);
|
||||||
tc.SelectedItem = page;
|
tc.SelectedItem = page;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>$(AvsCurrentTargetFramework)</TargetFrameworks>
|
<TargetFrameworks>$(AvsCurrentTargetFramework)</TargetFrameworks>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<IncludeAvaloniaGenerators>true</IncludeAvaloniaGenerators>
|
<IncludeAvaloniaGenerators>true</IncludeAvaloniaGenerators>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<EnableNETAnalyzers>false</EnableNETAnalyzers>
|
<EnableNETAnalyzers>false</EnableNETAnalyzers>
|
||||||
<GenerateDocumentationFile>false</GenerateDocumentationFile>
|
<GenerateDocumentationFile>false</GenerateDocumentationFile>
|
||||||
<LangVersion>14.0</LangVersion>
|
<LangVersion>14.0</LangVersion>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
<NoWarn>$(NoWarn);CS8002</NoWarn> <!-- ignore signing warnings for samples -->
|
<NoWarn>$(NoWarn);CS8002</NoWarn> <!-- ignore signing warnings for samples -->
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
||||||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<UseD3DCompiler>true</UseD3DCompiler>
|
<UseD3DCompiler>true</UseD3DCompiler>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<NoWarn>$(NoWarn);AVP1012;AVLN3001</NoWarn>
|
<NoWarn>$(NoWarn);AVP1012;AVLN3001</NoWarn>
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
<IncludeAvaloniaGenerators>true</IncludeAvaloniaGenerators>
|
<IncludeAvaloniaGenerators>true</IncludeAvaloniaGenerators>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ namespace PlatformSanityChecks
|
|||||||
{
|
{
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
static Thread UiThread;
|
static Thread UiThread = null!;
|
||||||
|
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
UiThread = Thread.CurrentThread;
|
UiThread = Thread.CurrentThread;
|
||||||
AppBuilder.Configure<App>().RuntimePlatformServicesInitializer();
|
AppBuilder.Configure<App>().RuntimePlatformServicesInitializer!();
|
||||||
var app = new App();
|
var app = new App();
|
||||||
|
|
||||||
AvaloniaX11PlatformExtensions.InitializeX11Platform();
|
AvaloniaX11PlatformExtensions.InitializeX11Platform();
|
||||||
@@ -41,13 +41,13 @@ namespace PlatformSanityChecks
|
|||||||
throw new Exception(error);
|
throw new Exception(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static IDisposable Enter([CallerMemberName] string caller = null)
|
static IDisposable Enter([CallerMemberName] string? caller = null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Entering " + caller);
|
Console.WriteLine("Entering " + caller);
|
||||||
return Disposable.Create(() => { Console.WriteLine("Leaving " + caller); });
|
return Disposable.Create(() => { Console.WriteLine("Leaving " + caller); });
|
||||||
}
|
}
|
||||||
|
|
||||||
static void EnterLoop(Action<CancellationTokenSource> cb, [CallerMemberName] string caller = null)
|
static void EnterLoop(Action<CancellationTokenSource> cb, [CallerMemberName] string? caller = null)
|
||||||
{
|
{
|
||||||
using (Enter(caller))
|
using (Enter(caller))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,22 +17,22 @@ namespace Previewer
|
|||||||
<TextBlock>Hello world!</TextBlock>
|
<TextBlock>Hello world!</TextBlock>
|
||||||
|
|
||||||
</Window>";
|
</Window>";
|
||||||
private IAvaloniaRemoteTransportConnection _connection;
|
private IAvaloniaRemoteTransportConnection? _connection;
|
||||||
private Control _errorsContainer;
|
private Control _errorsContainer;
|
||||||
private TextBlock _errors;
|
private TextBlock _errors;
|
||||||
private RemoteWidget _remote;
|
private RemoteWidget? _remote;
|
||||||
|
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
this.InitializeComponent();
|
this.InitializeComponent();
|
||||||
var tb = this.FindControl<TextBox>("Xaml");
|
var tb = this.GetControl<TextBox>("Xaml");
|
||||||
tb.Text = InitialXaml;
|
tb.Text = InitialXaml;
|
||||||
var scroll = this.FindControl<ScrollViewer>("Remote");
|
var scroll = this.GetControl<ScrollViewer>("Remote");
|
||||||
var rem = new Center();
|
var rem = new Center();
|
||||||
scroll.Content = rem;
|
scroll.Content = rem;
|
||||||
_errorsContainer = this.FindControl<Control>("ErrorsContainer");
|
_errorsContainer = this.GetControl<Control>("ErrorsContainer");
|
||||||
_errors = this.FindControl<TextBlock>("Errors");
|
_errors = this.GetControl<TextBlock>("Errors");
|
||||||
tb.GetObservable(TextBox.TextProperty).Subscribe(text => _connection?.Send(new UpdateXamlMessage
|
tb.GetObservable(TextBox.TextProperty).Subscribe(text => _connection?.Send(new UpdateXamlMessage
|
||||||
{
|
{
|
||||||
Xaml = text
|
Xaml = text
|
||||||
@@ -70,7 +70,7 @@ namespace Previewer
|
|||||||
_errorsContainer.IsVisible = result.Error != null;
|
_errorsContainer.IsVisible = result.Error != null;
|
||||||
_errors.Text = result.Error ?? "";
|
_errors.Text = result.Error ?? "";
|
||||||
}
|
}
|
||||||
if (obj is RequestViewportResizeMessage resize)
|
if (obj is RequestViewportResizeMessage resize && _remote is not null)
|
||||||
{
|
{
|
||||||
_remote.Width = Math.Min(4096, Math.Max(resize.Width, 1));
|
_remote.Width = Math.Min(4096, Math.Max(resize.Width, 1));
|
||||||
_remote.Height = Math.Min(4096, Math.Max(resize.Height, 1));
|
_remote.Height = Math.Min(4096, Math.Max(resize.Height, 1));
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace RenderDemo.Pages
|
|||||||
|
|
||||||
public CustomDrawOp(Rect bounds, GlyphRun noSkia)
|
public CustomDrawOp(Rect bounds, GlyphRun noSkia)
|
||||||
{
|
{
|
||||||
_noSkia = noSkia.TryCreateImmutableGlyphRunReference();
|
_noSkia = noSkia.TryCreateImmutableGlyphRunReference()!;
|
||||||
Bounds = bounds;
|
Bounds = bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ namespace RenderDemo.Pages
|
|||||||
|
|
||||||
public Rect Bounds { get; }
|
public Rect Bounds { get; }
|
||||||
public bool HitTest(Point p) => false;
|
public bool HitTest(Point p) => false;
|
||||||
public bool Equals(ICustomDrawOperation other) => false;
|
public bool Equals(ICustomDrawOperation? other) => false;
|
||||||
static Stopwatch St = Stopwatch.StartNew();
|
static Stopwatch St = Stopwatch.StartNew();
|
||||||
public void Render(ImmediateDrawingContext context)
|
public void Render(ImmediateDrawingContext context)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,11 +57,11 @@ namespace RenderDemo.Pages
|
|||||||
|
|
||||||
context.DrawText(formattedText, new Point(10, 0));
|
context.DrawText(formattedText, new Point(10, 0));
|
||||||
|
|
||||||
var geometry = formattedText.BuildGeometry(new Point(10 + formattedText.Width + 10, 0));
|
var geometry = formattedText.BuildGeometry(new Point(10 + formattedText.Width + 10, 0))!;
|
||||||
|
|
||||||
context.DrawGeometry(gradient, null, geometry);
|
context.DrawGeometry(gradient, null, geometry);
|
||||||
|
|
||||||
var highlightGeometry = formattedText.BuildHighlightGeometry(new Point(10 + formattedText.Width + 10, 0));
|
var highlightGeometry = formattedText.BuildHighlightGeometry(new Point(10 + formattedText.Width + 10, 0))!;
|
||||||
|
|
||||||
context.DrawGeometry(null, new ImmutablePen(gradient.ToImmutable(), 2), highlightGeometry);
|
context.DrawGeometry(null, new ImmutablePen(gradient.ToImmutable(), 2), highlightGeometry);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace RenderDemo.Pages
|
|||||||
private float _fontSize = 20;
|
private float _fontSize = 20;
|
||||||
private int _direction = 10;
|
private int _direction = 10;
|
||||||
|
|
||||||
private DispatcherTimer _timer;
|
private DispatcherTimer? _timer;
|
||||||
|
|
||||||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -48,7 +48,7 @@ namespace RenderDemo.Pages
|
|||||||
|
|
||||||
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
|
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
|
||||||
{
|
{
|
||||||
_timer.Stop();
|
_timer?.Stop();
|
||||||
|
|
||||||
_timer = null;
|
_timer = null;
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ namespace RenderDemo.Pages
|
|||||||
private float _fontSize = 20;
|
private float _fontSize = 20;
|
||||||
private int _direction = 10;
|
private int _direction = 10;
|
||||||
|
|
||||||
private DispatcherTimer _timer;
|
private DispatcherTimer? _timer;
|
||||||
|
|
||||||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -107,7 +107,7 @@ namespace RenderDemo.Pages
|
|||||||
|
|
||||||
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
|
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
|
||||||
{
|
{
|
||||||
_timer.Stop();
|
_timer?.Stop();
|
||||||
|
|
||||||
_timer = null;
|
_timer = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace RenderDemo.Pages
|
|||||||
AffectsRender<PathMeasurementPage>(BoundsProperty);
|
AffectsRender<PathMeasurementPage>(BoundsProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RenderTargetBitmap _bitmap;
|
private RenderTargetBitmap? _bitmap;
|
||||||
|
|
||||||
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
|
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -24,7 +24,7 @@ namespace RenderDemo.Pages
|
|||||||
|
|
||||||
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
|
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
|
||||||
{
|
{
|
||||||
_bitmap.Dispose();
|
_bitmap?.Dispose();
|
||||||
_bitmap = null;
|
_bitmap = null;
|
||||||
base.OnDetachedFromLogicalTree(e);
|
base.OnDetachedFromLogicalTree(e);
|
||||||
}
|
}
|
||||||
@@ -37,6 +37,9 @@ namespace RenderDemo.Pages
|
|||||||
|
|
||||||
public override void Render(DrawingContext context)
|
public override void Render(DrawingContext context)
|
||||||
{
|
{
|
||||||
|
if (_bitmap is null)
|
||||||
|
return;
|
||||||
|
|
||||||
using (var bitmapCtx = _bitmap.CreateDrawingContext())
|
using (var bitmapCtx = _bitmap.CreateDrawingContext())
|
||||||
{
|
{
|
||||||
var basePath = new PathGeometry();
|
var basePath = new PathGeometry();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace RenderDemo.Pages
|
|||||||
{
|
{
|
||||||
public class RenderTargetBitmapPage : Control
|
public class RenderTargetBitmapPage : Control
|
||||||
{
|
{
|
||||||
private RenderTargetBitmap _bitmap;
|
private RenderTargetBitmap? _bitmap;
|
||||||
|
|
||||||
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
|
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -20,7 +20,7 @@ namespace RenderDemo.Pages
|
|||||||
|
|
||||||
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
|
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
|
||||||
{
|
{
|
||||||
_bitmap.Dispose();
|
_bitmap?.Dispose();
|
||||||
_bitmap = null;
|
_bitmap = null;
|
||||||
base.OnDetachedFromLogicalTree(e);
|
base.OnDetachedFromLogicalTree(e);
|
||||||
}
|
}
|
||||||
@@ -28,6 +28,9 @@ namespace RenderDemo.Pages
|
|||||||
readonly Stopwatch _st = Stopwatch.StartNew();
|
readonly Stopwatch _st = Stopwatch.StartNew();
|
||||||
public override void Render(DrawingContext context)
|
public override void Render(DrawingContext context)
|
||||||
{
|
{
|
||||||
|
if (_bitmap is null)
|
||||||
|
return;
|
||||||
|
|
||||||
using (var ctx = _bitmap.CreateDrawingContext())
|
using (var ctx = _bitmap.CreateDrawingContext())
|
||||||
using (ctx.PushTransform(Matrix.CreateTranslation(-100, -100)
|
using (ctx.PushTransform(Matrix.CreateTranslation(-100, -100)
|
||||||
* Matrix.CreateRotation(_st.Elapsed.TotalSeconds)
|
* Matrix.CreateRotation(_st.Elapsed.TotalSeconds)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace RenderDemo.Pages
|
|||||||
{
|
{
|
||||||
public class TextFormatterPage : UserControl
|
public class TextFormatterPage : UserControl
|
||||||
{
|
{
|
||||||
private TextLine _textLine;
|
private TextLine? _textLine;
|
||||||
|
|
||||||
public TextFormatterPage()
|
public TextFormatterPage()
|
||||||
{
|
{
|
||||||
@@ -50,7 +50,7 @@ namespace RenderDemo.Pages
|
|||||||
{
|
{
|
||||||
var currentX = 0d;
|
var currentX = 0d;
|
||||||
|
|
||||||
foreach (var textRun in _textLine.TextRuns)
|
foreach (var textRun in _textLine?.TextRuns ?? [])
|
||||||
{
|
{
|
||||||
if (textRun is ControlRun controlRun)
|
if (textRun is ControlRun controlRun)
|
||||||
{
|
{
|
||||||
@@ -78,7 +78,7 @@ namespace RenderDemo.Pages
|
|||||||
_defaultProperties = defaultProperties;
|
_defaultProperties = defaultProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextRun GetTextRun(int textSourceIndex)
|
public TextRun? GetTextRun(int textSourceIndex)
|
||||||
{
|
{
|
||||||
if (textSourceIndex >= _text.Length * 2 + TextRun.DefaultTextSourceLength)
|
if (textSourceIndex >= _text.Length * 2 + TextRun.DefaultTextSourceLength)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ namespace RenderDemo.Pages
|
|||||||
{
|
{
|
||||||
public class WriteableBitmapPage : Control
|
public class WriteableBitmapPage : Control
|
||||||
{
|
{
|
||||||
private WriteableBitmap _unpremulBitmap;
|
private WriteableBitmap? _unpremulBitmap;
|
||||||
private WriteableBitmap _premulBitmap;
|
private WriteableBitmap? _premulBitmap;
|
||||||
private readonly Stopwatch _st = Stopwatch.StartNew();
|
private readonly Stopwatch _st = Stopwatch.StartNew();
|
||||||
|
|
||||||
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
|
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
|
||||||
@@ -38,6 +38,9 @@ namespace RenderDemo.Pages
|
|||||||
|
|
||||||
public override void Render(DrawingContext context)
|
public override void Render(DrawingContext context)
|
||||||
{
|
{
|
||||||
|
if (_unpremulBitmap is null || _premulBitmap is null)
|
||||||
|
return;
|
||||||
|
|
||||||
void FillPixels(WriteableBitmap bitmap, byte fillAlpha, bool premul)
|
void FillPixels(WriteableBitmap bitmap, byte fillAlpha, bool premul)
|
||||||
{
|
{
|
||||||
using (var fb = bitmap.Lock())
|
using (var fb = bitmap.Lock())
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>$(AvsCurrentAndroidTargetFramework)</TargetFramework>
|
<TargetFramework>$(AvsCurrentAndroidTargetFramework)</TargetFramework>
|
||||||
<SupportedOSPlatformVersion>$(AvsMinSupportedAndroidVersion)</SupportedOSPlatformVersion>
|
<SupportedOSPlatformVersion>$(AvsMinSupportedAndroidVersion)</SupportedOSPlatformVersion>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<ApplicationId>com.avalonia.safeareademo</ApplicationId>
|
<ApplicationId>com.avalonia.safeareademo</ApplicationId>
|
||||||
<ApplicationVersion>1</ApplicationVersion>
|
<ApplicationVersion>1</ApplicationVersion>
|
||||||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
|
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
<TargetFramework>$(AvsCurrentIOSTargetFramework)</TargetFramework>
|
<TargetFramework>$(AvsCurrentIOSTargetFramework)</TargetFramework>
|
||||||
<SupportedOSPlatformVersion>$(AvsMinSupportedIOSVersion)</SupportedOSPlatformVersion>
|
<SupportedOSPlatformVersion>$(AvsMinSupportedIOSVersion)</SupportedOSPlatformVersion>
|
||||||
<ProvisioningType>manual</ProvisioningType>
|
<ProvisioningType>manual</ProvisioningType>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
<TargetFrameworks Condition="'$(IncludeMacTargetSamples)' == 'true'">$(TargetFrameworks);$(AvsCurrentMacOSTargetFramework)</TargetFrameworks>
|
<TargetFrameworks Condition="'$(IncludeMacTargetSamples)' == 'true'">$(TargetFrameworks);$(AvsCurrentMacOSTargetFramework)</TargetFrameworks>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<IncludeAvaloniaGenerators>true</IncludeAvaloniaGenerators>
|
<IncludeAvaloniaGenerators>true</IncludeAvaloniaGenerators>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
<IncludeAvaloniaGenerators>true</IncludeAvaloniaGenerators>
|
<IncludeAvaloniaGenerators>true</IncludeAvaloniaGenerators>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
-1
@@ -3,7 +3,6 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
|
|||||||
-1
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
|
||||||
|
|||||||
@@ -4,16 +4,8 @@
|
|||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>$(AvsCurrentTargetFramework)</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="GtkSharp" Version="3.24.24.95"/>
|
<PackageReference Include="GtkSharp" Version="3.24.24.95"/>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Avalonia
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static int StartWithHeadlessVncPlatform(
|
public static int StartWithHeadlessVncPlatform(
|
||||||
this AppBuilder builder,
|
this AppBuilder builder,
|
||||||
string host, int port,
|
string? host, int port,
|
||||||
string[] args,
|
string[] args,
|
||||||
ShutdownMode shutdownMode = ShutdownMode.OnLastWindowClose)
|
ShutdownMode shutdownMode = ShutdownMode.OnLastWindowClose)
|
||||||
{
|
{
|
||||||
@@ -46,7 +46,7 @@ namespace Avalonia
|
|||||||
/// <exception cref="InvalidOperationException"></exception>
|
/// <exception cref="InvalidOperationException"></exception>
|
||||||
public static int StartWithHeadlessVncPlatform(
|
public static int StartWithHeadlessVncPlatform(
|
||||||
this AppBuilder builder,
|
this AppBuilder builder,
|
||||||
string host, int port,
|
string? host, int port,
|
||||||
string? password,
|
string? password,
|
||||||
string[] args,
|
string[] args,
|
||||||
ShutdownMode shutdownMode = ShutdownMode.OnLastWindowClose)
|
ShutdownMode shutdownMode = ShutdownMode.OnLastWindowClose)
|
||||||
|
|||||||
Reference in New Issue
Block a user