loki.wu 2 жил өмнө
parent
commit
4c680a2589

+ 5 - 1
fis/App.axaml.cs

@@ -1,6 +1,8 @@
 using Avalonia;
 using Avalonia.Controls.ApplicationLifetimes;
 using Avalonia.Markup.Xaml;
+using fis.Win.Dev.Helpers;
+using System.Threading.Tasks;
 
 namespace fis
 {
@@ -13,12 +15,14 @@ namespace fis
 
         public override void OnFrameworkInitializationCompleted()
         {
+            var mainWindow = new MainWindow();
             if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
             {
-                desktop.MainWindow = new MainWindow();
+                desktop.MainWindow = mainWindow;
             }
 
             base.OnFrameworkInitializationCompleted();
+            //SecondaryScreenHelper.window.init("http://" + ShellConfig.Instance.AppHost, new System.Collections.Generic.Dictionary<string, string>());
         }
     }
 }

+ 71 - 0
fis/Helpers/AvaloniaCefBrowserHelper.cs

@@ -0,0 +1,71 @@
+using Avalonia.Controls;
+using fis.Mac;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+using Xilium.CefGlue;
+using Xilium.CefGlue.Avalonia;
+using Xilium.CefGlue.Common.Handlers;
+
+namespace fis.Win.Dev.Helpers
+{
+    internal class AvaloniaCefBrowserHelper
+    {
+        private static AvaloniaCefBrowser? _browser;
+
+        /// <summary>
+        /// 浏览器Title
+        /// </summary>
+        public static TextBlock? title;
+
+        public static AvaloniaCefBrowser browser
+        {
+            get
+            {
+                if (_browser == null)
+                {
+                    var handler = new HostRequestHandler();
+                    var appHandler = new FileSystemHostHandler(ShellConfig.Instance.AppHost, ShellConfig.Instance.AppResourcePath);
+                    var resourceHandler = new FileSystemHostHandler(ShellConfig.Instance.LocalResourceHost, ShellConfig.Instance.LocalResourcePath);
+                    
+                    handler.RegisterHostHandler(appHandler);
+                    handler.RegisterHostHandler(resourceHandler);
+                    IPlatformService platformService;
+                    if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+                    {
+                      
+                        platformService = new WinService();
+                    }
+                    else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+                    {
+                      
+                        platformService = new MacService();
+                    }
+                    else
+                    {
+                        throw new NotSupportedException($"Platform {Environment.OSVersion.Platform} is not suppoorted.");
+                    }
+                        
+                    var platformHandler = new JsonRpcHandler<IPlatformService>(ShellConfig.Instance.LocalApiHost, platformService);
+                    handler.RegisterHostHandler(platformHandler);
+                    _browser = new AvaloniaCefBrowser
+                    {
+                        RequestHandler = handler
+                    };
+                    if (title != null)
+                    {
+                        var scriptObj = new FisBrowserScriptObject(title, platformService);
+                        _browser.RegisterJavascriptObject(scriptObj, "FisShellApi");
+                    }
+                    _browser.Settings.WebSecurity = CefState.Disabled;
+
+                }
+
+                return _browser;
+            }
+        }
+    }
+}

+ 39 - 0
fis/Helpers/SecondaryScreenHelper.cs

@@ -0,0 +1,39 @@
+using Avalonia;
+using Avalonia.Threading;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace fis.Win.Dev.Helpers
+{
+    internal class SecondaryScreenHelper
+    {
+
+        /// <summary>
+        /// 打开测量页
+        /// </summary>
+        /// <returns></returns>
+        public static async Task<bool> OpenSecondaryWindowAsync(string host,Dictionary<string, string> keyValuePairs)
+       {
+            
+            await Dispatcher.UIThread.InvokeAsync(() =>
+            {
+                SlaveWindow window = new SlaveWindow();
+                window.init(host, keyValuePairs);
+                if (window.Screens.ScreenCount > 1)
+                {
+                    var screen = window.Screens.All.FirstOrDefault(x => x.Primary == false);
+                    if (screen != null)
+                    {
+                        window.Position = new PixelPoint(screen.Bounds.X, screen.Bounds.Y);
+                    }
+                }
+                window.Show();
+            });
+              
+            return true;
+       }
+
+
+    }
+}

+ 12 - 0
fis/IPlatformService.cs

@@ -39,6 +39,18 @@ namespace fis
         /// 获取配置
         string? GetConfig();
 
+        /// <summary>
+        /// 打开报告模板设计器
+        /// </summary>
+        /// <param name="name"></param>
+        /// <returns></returns>
+        bool OpenImageMeasure(string token, string patientCode, string index, string imageIndex);
+
+        /// <summary>
+        /// 打开报告模板设计器
+        /// </summary>
+        /// <returns></returns>
+        bool OpenReportDesigner();
         #endregion
 
         #region File Storage

+ 10 - 19
fis/MainWindow.axaml.cs

@@ -14,6 +14,7 @@ using System.Reflection;
 using System.Threading;
 using System.Runtime.InteropServices;
 using fis.Managers;
+using fis.Win.Dev.Helpers;
 
 namespace fis
 {
@@ -31,7 +32,8 @@ namespace fis
             ExtendClientAreaTitleBarHeightHint = -1;
             MainThreadSyncContext = SynchronizationContext.Current;
 #if DEBUG
-            this.AttachDevTools();
+          //  this.AttachDevTools();
+         
 #endif
         }
 
@@ -39,45 +41,34 @@ namespace fis
         {
             AvaloniaXamlLoader.Load(this);
             var browserContainer = this.FindControl<Border>("BrowserBorder");
-            var appHandler = new FileSystemHostHandler(ShellConfig.Instance.AppHost, ShellConfig.Instance.AppResourcePath);
-            var resourceHandler = new FileSystemHostHandler(ShellConfig.Instance.LocalResourceHost, ShellConfig.Instance.LocalResourcePath);
-            IPlatformService platformService;
+
+
             if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
             {
                 this.FindControl<MacosTitleBar>("MacTitleBar").IsVisible = false;
                 _title = this.FindControl<WindowsTitleBar>("WinTitleBar").FindControl<TextBlock>("WindowsTitle");
-                platformService = new WinService();
+             
             }
             else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
             {
                 this.FindControl<WindowsTitleBar>("WinTitleBar").IsVisible = false;
                 _title = this.FindControl<MacosTitleBar>("MacTitleBar").FindControl<TextBlock>("MacosTitle");
-                platformService = new MacService();
+             
             }
             else
             {
                 throw new NotSupportedException($"Platform {Environment.OSVersion.Platform} is not suppoorted.");
             }
-            var platformHandler = new JsonRpcHandler<IPlatformService>(ShellConfig.Instance.LocalApiHost, platformService);
-            var handler = new HostRequestHandler();
-            handler.RegisterHostHandler(appHandler);
-            handler.RegisterHostHandler(resourceHandler);
-            handler.RegisterHostHandler(platformHandler);
-            _browser = new AvaloniaCefBrowser
-            {
-                RequestHandler = handler
-            };
+            AvaloniaCefBrowserHelper.title = _title;
             //Make cross domain work.
-            _browser.Settings.WebSecurity = CefState.Disabled;
+            _browser = AvaloniaCefBrowserHelper.browser;
             _browser.Address = "http://" + ShellConfig.Instance.AppHost + "/index.html";
             _browser.ContextMenuHandler = new TextContextMenuHandler(_browser);
             _browser.BrowserInitialized += () =>
             {
 #if DEBUG
-                _browser!.ShowDeveloperTools();
+                //_browser!.ShowDeveloperTools();
 #endif
-                var scriptObj = new FisBrowserScriptObject(_title, platformService);
-                _browser.RegisterJavascriptObject(scriptObj, "FisShellApi");
             };
             browserContainer.Child = _browser;
 

+ 0 - 4
fis/Managers/TextFileManager.cs

@@ -1,12 +1,8 @@
 using fis.Log;
-using fis.Managers;
 using fis.Managers.Interfaces;
 using System;
-using System.Collections.Generic;
 using System.IO;
-using System.Linq;
 using System.Text;
-using System.Threading;
 using System.Threading.Tasks;
 
 namespace fis.Managers

+ 28 - 3
fis/PlatformService.cs

@@ -1,12 +1,10 @@
 using fis.Managers;
 using fis.Managers.Interfaces;
 using fis.Models.Vid;
+using fis.Win.Dev.Helpers;
 using fis.Win.Dev.Managers.Interfaces;
 using System;
 using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 
 namespace fis
 {
@@ -30,6 +28,33 @@ namespace fis
 
         public bool SetBytesToExport(string fileData, string fileName) => AppManager.Get<IFileExporterManager>().SetBytesToExport(fileData, fileName);
 
+        /// <summary>
+        /// 打开测量
+        /// </summary>
+        /// <param name="token"></param>
+        /// <param name="patientCode"></param>
+        /// <param name="index"></param>
+        /// <param name="imageIndex"></param>
+        /// <returns></returns>
+        public bool OpenImageMeasure(string token,string patientCode,string index,string imageIndex) {
+            var dictionary = new Dictionary<string, string>();
+            dictionary.Add("token", token);
+            dictionary.Add("patientCode", patientCode);
+            dictionary.Add("index", index);
+            dictionary.Add("imageIndex", imageIndex);
+            return  SecondaryScreenHelper.OpenSecondaryWindowAsync("http://" + ShellConfig.Instance.AppHost + "/#/measure/measure_home",dictionary).Result;
+        }
+
+        /// <summary>
+        /// 打开报告设计器
+        /// </summary>
+        /// <returns></returns>
+        public bool OpenReportDesigner() 
+        {
+            var dictionary = new Dictionary<string, string>();
+            return SecondaryScreenHelper.OpenSecondaryWindowAsync("http://" + ShellConfig.Instance.DistHost + "/index.html", dictionary).Result;
+        }
+
         public LoadVidResult LoadVid(string url)
         {
             var result = new LoadVidResult();

+ 8 - 0
fis/ShellConfig.cs

@@ -11,9 +11,17 @@ namespace fis
         //Gets or sets the app host which is the web App's access url
         public string AppHost { get; set; } = "app.fis.plus";
 
+        /// <summary>
+        /// 报告模板设计器
+        /// </summary>
+        public string DistHost { get; set; } = "dist.fis.plus";
+
         //Gets or sets the App resource path, which stores the web content and its resources.
         public string AppResourcePath { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App", "flyinsono");
 
+        //报告模板设计器地址
+        public string DistResourcePath { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App", "dist");
+
         //Gets or sets the api host for local call, usually provider platform apis.
         public string LocalApiHost { get; set; } = "platform.fis.plus";
 

+ 24 - 0
fis/SlaveWindow.axaml

@@ -0,0 +1,24 @@
+<Window xmlns="https://github.com/avaloniaui"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+		xmlns:titlebars="clr-namespace:fis;assembly=fis"
+        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
+        x:Class="fis.SlaveWindow"
+        Title="FLYINSONO">
+	<Grid>
+		<Border Name="WindowBorder" BorderBrush="#BFBFBF" BorderThickness="1">
+			<Grid>
+				<Grid.RowDefinitions>
+					<RowDefinition Height="32"/>
+					<RowDefinition Height="*"/>
+				</Grid.RowDefinitions>
+				<Grid Grid.Row="0">
+					<titlebars:WindowsTitleBar Name="WinTitleBar" IsSeamless="True"/>
+					<titlebars:MacosTitleBar  Name="MacTitleBar" IsSeamless="False"/>
+				</Grid>
+				<Border Grid.Row="1" BorderThickness="0" x:Name="BrowserBorder"/>
+			</Grid>
+		</Border>
+	</Grid>
+</Window>

+ 145 - 0
fis/SlaveWindow.axaml.cs

@@ -0,0 +1,145 @@
+using System;
+using System.IO;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Markup.Xaml;
+using fis.Mac;
+using fis.Win;
+using Xilium.CefGlue.Avalonia;
+using System.Globalization;
+using System.Reflection;
+using System.Threading;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+using Xilium.CefGlue.Common.Handlers;
+
+namespace fis
+{
+    public partial class SlaveWindow : Window
+    {
+        public static SynchronizationContext? MainThreadSyncContext;
+        private TextBlock? _title;
+        private AvaloniaCefBrowser? _browser;
+        private string _host;
+        private Dictionary<string, string> _parameters;
+
+        public SlaveWindow()
+        {
+            ExtendClientAreaToDecorationsHint = true;
+            ExtendClientAreaChromeHints = Avalonia.Platform.ExtendClientAreaChromeHints.NoChrome;
+            ExtendClientAreaTitleBarHeightHint = -1;
+            MainThreadSyncContext = SynchronizationContext.Current;
+#if DEBUG
+             this.AttachDevTools();
+#endif
+        }
+
+        public void init(string host, Dictionary<string, string> dictionary) 
+        {
+            _parameters = dictionary;
+            _host = host;
+            InitializeComponent();
+
+        }
+
+        private void InitializeComponent()
+        {
+            AvaloniaXamlLoader.Load(this);
+            var browserContainer = this.FindControl<Border>("BrowserBorder");
+         
+            IPlatformService platformService;
+            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+            {
+                this.FindControl<MacosTitleBar>("MacTitleBar").IsVisible = false;
+                _title = this.FindControl<WindowsTitleBar>("WinTitleBar").FindControl<TextBlock>("WindowsTitle");
+                platformService = new WinService();
+            }
+            else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+            {
+                this.FindControl<WindowsTitleBar>("WinTitleBar").IsVisible = false;
+                _title = this.FindControl<MacosTitleBar>("MacTitleBar").FindControl<TextBlock>("MacosTitle");
+                platformService = new MacService();
+            }
+            else
+            {
+                throw new NotSupportedException($"Platform {Environment.OSVersion.Platform} is not suppoorted.");
+            }
+            if (_host.Contains(ShellConfig.Instance.DistHost))
+            {
+                var appHandler = new FileSystemHostHandler(ShellConfig.Instance.DistHost, ShellConfig.Instance.DistResourcePath);
+                var handler = new HostRequestHandler();
+                handler.RegisterHostHandler(appHandler);
+                _browser = new AvaloniaCefBrowser
+                {
+                    RequestHandler = handler
+                };
+            }
+            else 
+            {
+                _browser = new AvaloniaCefBrowser();
+            }
+   
+            var parameter = "";
+            var index = 0;
+            foreach (var p in _parameters) 
+            {
+                
+                parameter += p.Key + "=" + p.Value;
+                if (index < _parameters.Count - 1) {
+                    parameter += "&";
+                }
+                index++;
+            }
+            //Make cross domain work.
+            if (parameter.Length > 0)
+            {
+                _browser.Address = _host + "?" + parameter;
+            }
+            else
+            {
+                _browser.Address = _host;
+            }
+            _browser.BrowserInitialized += () =>
+            {
+#if DEBUG
+               _browser!.ShowDeveloperTools();
+#endif
+            };
+            browserContainer.Child = _browser;
+            WindowStartupLocation = WindowStartupLocation.Manual;
+            Position = new PixelPoint();
+            WindowState = WindowState.Maximized;
+            MinWidth = 1366;
+            MinHeight = 768;
+            var language = CultureInfo.CurrentCulture.Name;
+            if (_title != null)
+            {
+                if (language == "zh-CN")
+                {
+                    _title.Text = "杏聆荟";
+                }
+                else
+                {
+                    _title.Text = "FLYINSONO";
+                }
+            }
+            var assembly = Assembly.GetExecutingAssembly();
+            Stream? resourceStream = null;
+            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+            {
+                resourceStream = assembly.GetManifestResourceStream("fis.Win.flyinsono.ico");
+            }
+            else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+            {
+                resourceStream = assembly.GetManifestResourceStream("fis.Mac.flyinsono.ico");
+            }
+            if (resourceStream != null)
+            {
+                Icon = new WindowIcon(resourceStream);
+            }
+
+        }
+    }
+
+  
+}

+ 5 - 0
fis/fis.Win.Dev.csproj

@@ -25,6 +25,11 @@
   <ItemGroup>
     <ProjectReference Include="..\fis.Vid\fis.Vid.csproj" />
   </ItemGroup>
+  <ItemGroup>
+    <Compile Update="SlaveWindow.axaml.cs">
+      <DependentUpon>SlaveWindow.axaml</DependentUpon>
+    </Compile>
+  </ItemGroup>
   <Target Name="BuildAppWin" AfterTargets="AfterBuild">
 	  <Exec Command="xcopy $(ProjectDir)..\third_party\SmartPublisherDev\*.*  $(ProjectDir)bin\Debug\net6.0\*.* /Y" />
   </Target>