Преглед на файлове

[FIX] Added missing IPlatformIconLoader in LinuxFramebufferPlatform.cs
[FIX] --fbdev parameter check before attach DevTools

Vladimir Florov преди 2 години
родител
ревизия
bceacedae3
променени са 2 файла, в които са добавени 36 реда и са изтрити 7 реда
  1. 16 6
      samples/ControlCatalog.NetCore/Program.cs
  2. 20 1
      src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs

+ 16 - 6
samples/ControlCatalog.NetCore/Program.cs

@@ -18,9 +18,16 @@ namespace ControlCatalog.NetCore
 {
     static class Program
     {
+        private static bool s_useFramebuffer;
+        
         [STAThread]
         static int Main(string[] args)
         {
+            if (args.Contains("--fbdev"))
+            {
+                s_useFramebuffer = true;
+            }
+
             if (args.Contains("--wait-for-attach"))
             {
                 Console.WriteLine("Attach debugger and use 'Set next statement'");
@@ -42,10 +49,10 @@ namespace ControlCatalog.NetCore
                     return scaling;
                 return 1;
             }
-            if (args.Contains("--fbdev"))
+            if (s_useFramebuffer)
             {
-                SilenceConsole();
-                return builder.StartLinuxFbDev(args, scaling: GetScaling());
+                 SilenceConsole(); 
+                 return builder.StartLinuxFbDev(args, scaling: GetScaling());
             }
             else if (args.Contains("--vnc"))
             {
@@ -128,10 +135,13 @@ namespace ControlCatalog.NetCore
                 .WithInterFont()
                 .AfterSetup(builder =>
                 {
-                    builder.Instance!.AttachDevTools(new Avalonia.Diagnostics.DevToolsOptions()
+                    if (!s_useFramebuffer)
                     {
-                        StartupScreenIndex = 1,
-                    });
+                        builder.Instance!.AttachDevTools(new Avalonia.Diagnostics.DevToolsOptions()
+                        {
+                            StartupScreenIndex = 1,
+                        });
+                    }
 
                     EmbedSample.Implementation = OperatingSystem.IsWindows() ? (INativeDemoControl)new EmbedSampleWin()
                         : OperatingSystem.IsMacOS() ? new EmbedSampleMac()

+ 20 - 1
src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebufferPlatform.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Diagnostics;
+using System.IO;
 using System.Threading;
 using Avalonia;
 using Avalonia.Controls;
@@ -22,13 +23,30 @@ using Avalonia.Threading;
 
 namespace Avalonia.LinuxFramebuffer
 {
+    internal class LinuxFramebufferIconLoaderStub : IPlatformIconLoader
+    {
+        private class IconStub : IWindowIconImpl
+        {
+            public void Save(Stream outputStream)
+            {
+
+            }
+        }
+
+        public IWindowIconImpl LoadIcon(string fileName) => new IconStub();
+
+        public IWindowIconImpl LoadIcon(Stream stream) => new IconStub();
+
+        public IWindowIconImpl LoadIcon(IBitmapImpl bitmap) => new IconStub();
+    }
+    
     class LinuxFramebufferPlatform
     {
         IOutputBackend _fb;
         public static ManualRawEventGrouperDispatchQueue EventGrouperDispatchQueue = new();
 
         internal static Compositor Compositor { get; private set; } = null!;
-        
+       
         
         LinuxFramebufferPlatform(IOutputBackend backend)
         {
@@ -47,6 +65,7 @@ namespace Avalonia.LinuxFramebuffer
                 .Bind<IRenderTimer>().ToConstant(new DefaultRenderTimer(opts.Fps))
                 .Bind<ICursorFactory>().ToTransient<CursorFactoryStub>()
                 .Bind<IKeyboardDevice>().ToConstant(new KeyboardDevice())
+                .Bind<IPlatformIconLoader>().ToSingleton<LinuxFramebufferIconLoaderStub>()
                 .Bind<IPlatformSettings>().ToSingleton<DefaultPlatformSettings>()
                 .Bind<PlatformHotkeyConfiguration>().ToSingleton<PlatformHotkeyConfiguration>();