5 changed files with 14 additions and 192 deletions
@ -1,33 +0,0 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>WinExe</OutputType> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> |
|||
<IlcTrimMetadata>true</IlcTrimMetadata> |
|||
<RestoreAdditionalProjectSources>https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json</RestoreAdditionalProjectSources> |
|||
<NativeAotCompilerVersion>7.0.0-*</NativeAotCompilerVersion> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Avalonia.Headless.Vnc\Avalonia.Headless.Vnc.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.Dialogs\Avalonia.Dialogs.csproj" /> |
|||
<ProjectReference Include="..\..\src\Linux\Avalonia.LinuxFramebuffer\Avalonia.LinuxFramebuffer.csproj" /> |
|||
<ProjectReference Include="..\ControlCatalog\ControlCatalog.csproj" /> |
|||
<ProjectReference Include="..\..\src\Avalonia.X11\Avalonia.X11.csproj" /> |
|||
<PackageReference Include="Avalonia.Angle.Windows.Natives" Version="2.1.0.2020091801" /> |
|||
<PackageReference Include="Microsoft.DotNet.ILCompiler" Version="$(NativeAotCompilerVersion)" /> |
|||
<!-- Cross-compilation for Windows x64-arm64 and Linux x64-arm64 --> |
|||
<PackageReference Condition="'$(RuntimeIdentifier)'=='win-arm64'" Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="$(NativeAotCompilerVersion)" /> |
|||
<PackageReference Condition="'$(RuntimeIdentifier)'=='linux-arm64'" Include="runtime.linux-x64.Microsoft.DotNet.ILCompiler" Version="$(NativeAotCompilerVersion)" /> |
|||
<RdXmlFile Include="rd.xml" /> |
|||
</ItemGroup> |
|||
|
|||
<PropertyGroup> |
|||
<!-- For Microsoft.CodeAnalysis --> |
|||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages> |
|||
</PropertyGroup> |
|||
|
|||
<Import Project="..\..\build\SampleApp.props" /> |
|||
<Import Project="..\..\build\ReferenceCoreLibraries.props" /> |
|||
</Project> |
|||
@ -1,132 +0,0 @@ |
|||
using System; |
|||
using System.Diagnostics; |
|||
using System.Globalization; |
|||
using System.Linq; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.ApplicationLifetimes; |
|||
using Avalonia.Headless; |
|||
using Avalonia.LogicalTree; |
|||
using Avalonia.Threading; |
|||
|
|||
namespace ControlCatalog.NetCore.Native |
|||
{ |
|||
static class Program |
|||
{ |
|||
[STAThread] |
|||
static int Main(string[] args) |
|||
{ |
|||
if (args.Contains("--wait-for-attach")) |
|||
{ |
|||
Console.WriteLine("Attach debugger and use 'Set next statement'"); |
|||
while (true) |
|||
{ |
|||
Thread.Sleep(100); |
|||
if (Debugger.IsAttached) |
|||
break; |
|||
} |
|||
} |
|||
|
|||
var builder = BuildAvaloniaApp(); |
|||
|
|||
double GetScaling() |
|||
{ |
|||
var idx = Array.IndexOf(args, "--scaling"); |
|||
if (idx != 0 && args.Length > idx + 1 && |
|||
double.TryParse(args[idx + 1], NumberStyles.Any, CultureInfo.InvariantCulture, out var scaling)) |
|||
return scaling; |
|||
return 1; |
|||
} |
|||
if (args.Contains("--fbdev")) |
|||
{ |
|||
SilenceConsole(); |
|||
return builder.StartLinuxFbDev(args, scaling: GetScaling()); |
|||
} |
|||
else if (args.Contains("--vnc")) |
|||
{ |
|||
return builder.StartWithHeadlessVncPlatform(null, 5901, args, ShutdownMode.OnMainWindowClose); |
|||
} |
|||
else if (args.Contains("--full-headless")) |
|||
{ |
|||
return builder |
|||
.UseHeadless(true) |
|||
.AfterSetup(_ => |
|||
{ |
|||
DispatcherTimer.RunOnce(async () => |
|||
{ |
|||
var window = ((IClassicDesktopStyleApplicationLifetime)Application.Current.ApplicationLifetime) |
|||
.MainWindow; |
|||
var tc = window.GetLogicalDescendants().OfType<TabControl>().First(); |
|||
foreach (var page in tc.Items.Cast<TabItem>().ToList()) |
|||
{ |
|||
// Skip DatePicker because of some layout bug in grid
|
|||
if (page.Header.ToString() == "DatePicker") |
|||
continue; |
|||
Console.WriteLine("Selecting " + page.Header); |
|||
tc.SelectedItem = page; |
|||
await Task.Delay(500); |
|||
} |
|||
Console.WriteLine("Selecting the first page"); |
|||
tc.SelectedItem = tc.Items.OfType<object>().First(); |
|||
await Task.Delay(500); |
|||
Console.WriteLine("Clicked through all pages, triggering GC"); |
|||
for (var c = 0; c < 3; c++) |
|||
{ |
|||
GC.Collect(2, GCCollectionMode.Forced); |
|||
await Task.Delay(500); |
|||
} |
|||
|
|||
void FormatMem(string metric, long bytes) |
|||
{ |
|||
Console.WriteLine(metric + ": " + bytes / 1024 / 1024 + "MB"); |
|||
} |
|||
|
|||
FormatMem("GC allocated bytes", GC.GetTotalMemory(true)); |
|||
FormatMem("WorkingSet64", Process.GetCurrentProcess().WorkingSet64); |
|||
|
|||
}, TimeSpan.FromSeconds(1)); |
|||
}) |
|||
.StartWithClassicDesktopLifetime(args); |
|||
} |
|||
else if (args.Contains("--drm")) |
|||
{ |
|||
SilenceConsole(); |
|||
return builder.StartLinuxDrm(args, scaling: GetScaling()); |
|||
} |
|||
else |
|||
return builder.StartWithClassicDesktopLifetime(args); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// This method is needed for IDE previewer infrastructure
|
|||
/// </summary>
|
|||
public static AppBuilder BuildAvaloniaApp() |
|||
=> AppBuilder.Configure<App>() |
|||
.UsePlatformDetect() |
|||
.With(new X11PlatformOptions |
|||
{ |
|||
EnableMultiTouch = true, |
|||
UseDBusMenu = true, |
|||
EnableIme = true, |
|||
}) |
|||
.With(new Win32PlatformOptions |
|||
{ |
|||
EnableMultitouch = true |
|||
}) |
|||
.UseSkia() |
|||
.LogToTrace(); |
|||
|
|||
static void SilenceConsole() |
|||
{ |
|||
new Thread(() => |
|||
{ |
|||
Console.CursorVisible = false; |
|||
while (true) |
|||
Console.ReadKey(true); |
|||
}) |
|||
{ IsBackground = true }.Start(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue