Browse Source

fix support for zooming in on previewer and hidpi preview.

Dan Walmsley 7 years ago
parent
commit
50a3b95f87

+ 1 - 1
src/Avalonia.Controls/Remote/Server/RemoteServerTopLevelImpl.cs

@@ -85,7 +85,7 @@ namespace Avalonia.Controls.Remote.Server
             }
         }
 
-        protected void SetDpi(Vector dpi)
+        public void SetDpi(Vector dpi)
         {
             _dpi = dpi;
             RenderIfNeeded();

+ 5 - 1
src/Avalonia.DesignerSupport/DesignWindowLoader.cs

@@ -5,6 +5,7 @@ using System.Reflection;
 using System.Text;
 using Avalonia.Controls;
 using Avalonia.Controls.Platform;
+using Avalonia.Controls.Remote.Server;
 using Avalonia.Markup.Xaml;
 using Avalonia.Styling;
 
@@ -12,7 +13,7 @@ namespace Avalonia.DesignerSupport
 {
     public class DesignWindowLoader
     {
-        public static Window LoadDesignerWindow(string xaml, string assemblyPath)
+        public static Window LoadDesignerWindow(string xaml, string assemblyPath, Vector dpi)
         {
             Window window;
             Control control;
@@ -69,6 +70,9 @@ namespace Avalonia.DesignerSupport
                 if (!window.IsSet(Window.SizeToContentProperty))
                     window.SizeToContent = SizeToContent.WidthAndHeight;
             }
+            
+            (window.PlatformImpl as RemoteServerTopLevelImpl).SetDpi(dpi);
+
             window.Show();
             Design.ApplyDesignModeProperties(window, control);
             return window;

+ 3 - 2
src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.Collections.Generic;
 using System.Net;
 using System.Reflection;
@@ -191,7 +191,8 @@ namespace Avalonia.DesignerSupport.Remote
                 s_currentWindow = null;
                 try
                 {
-                    s_currentWindow = DesignWindowLoader.LoadDesignerWindow(xaml.Xaml, xaml.AssemblyPath);
+                    var dpi = s_viewportAllocatedMessage != null ? new Vector(s_viewportAllocatedMessage.DpiX, s_viewportAllocatedMessage.DpiY) : new Vector(96, 96);
+                    s_currentWindow = DesignWindowLoader.LoadDesignerWindow(xaml.Xaml, xaml.AssemblyPath, dpi);
                     s_transport.Send(new UpdateXamlResultMessage(){Handle = s_currentWindow.PlatformImpl?.Handle?.Handle.ToString()});
                 }
                 catch (Exception e)