|
@@ -1,21 +1,20 @@
|
|
|
-using System;
|
|
|
-using System.IO;
|
|
|
using Avalonia;
|
|
|
using Avalonia.Controls;
|
|
|
using Avalonia.Markup.Xaml;
|
|
|
+using Avalonia.Threading;
|
|
|
using fis.Mac;
|
|
|
+using fis.Managers;
|
|
|
+using fis.Utilities;
|
|
|
using fis.Win;
|
|
|
-using Xilium.CefGlue.Avalonia;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
using System.Globalization;
|
|
|
+using System.IO;
|
|
|
using System.Reflection;
|
|
|
-using System.Threading;
|
|
|
using System.Runtime.InteropServices;
|
|
|
-using System.Collections.Generic;
|
|
|
-using Xilium.CefGlue.Common.Handlers;
|
|
|
-using fis.Utilities;
|
|
|
+using System.Threading;
|
|
|
using System.Threading.Tasks;
|
|
|
-using Avalonia.Threading;
|
|
|
-using fis.Managers;
|
|
|
+using Xilium.CefGlue.Avalonia;
|
|
|
|
|
|
namespace fis
|
|
|
{
|
|
@@ -23,7 +22,7 @@ namespace fis
|
|
|
{
|
|
|
public static SynchronizationContext? MainThreadSyncContext;
|
|
|
private TextBlock? _title;
|
|
|
- private AvaloniaCefBrowser? _browser;
|
|
|
+ private AvaloniaCefBrowser _browser;
|
|
|
private string _host;
|
|
|
private WindowType _windowType;
|
|
|
|
|
@@ -37,8 +36,9 @@ namespace fis
|
|
|
ExtendClientAreaChromeHints = Avalonia.Platform.ExtendClientAreaChromeHints.NoChrome;
|
|
|
ExtendClientAreaTitleBarHeightHint = -1;
|
|
|
MainThreadSyncContext = SynchronizationContext.Current;
|
|
|
+ _browser = BrowserManager.SlaveBrowser;
|
|
|
#if DEBUG
|
|
|
- this.AttachDevTools();
|
|
|
+ this.AttachDevTools();
|
|
|
#endif
|
|
|
Closing += SlaveWindow_Closing;
|
|
|
}
|
|
@@ -63,9 +63,10 @@ namespace fis
|
|
|
/// <param name="keyValuePairs"></param>
|
|
|
internal async Task ChangeContentViewAsync(string host, Dictionary<string, string> keyValuePairs, WindowType windowType)
|
|
|
{
|
|
|
+ TargetMethodName targetMethodName;
|
|
|
if (windowType == WindowType.TemplateDesigner) {
|
|
|
- _browser.Address = host;
|
|
|
- return;
|
|
|
+ //_browser.Address = host;
|
|
|
+ //return;
|
|
|
}
|
|
|
_host = host;
|
|
|
_parameters = keyValuePairs;
|
|
@@ -88,9 +89,10 @@ namespace fis
|
|
|
Show();
|
|
|
});
|
|
|
Thread.Sleep(600);
|
|
|
-
|
|
|
- TargetMethodName targetMethodName;
|
|
|
- if (windowType == WindowType.Measure)
|
|
|
+ if (windowType == WindowType.TemplateDesigner) {
|
|
|
+ targetMethodName = TargetMethodName.OpenReportDesignerPage;
|
|
|
+ }
|
|
|
+ else if (windowType == WindowType.Measure)
|
|
|
{
|
|
|
targetMethodName = TargetMethodName.OpenMeasurePage;
|
|
|
}
|
|
@@ -103,55 +105,19 @@ namespace fis
|
|
|
targetMethodName = TargetMethodName.OpenReportEditPage;
|
|
|
}
|
|
|
}
|
|
|
- ExecuteJS("externalNotification", targetMethodName, arguments);
|
|
|
-
|
|
|
+ BrowserManager.ExecuteJS(BrowserManager.NotificationName, targetMethodName, arguments, false);
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 执行Js方法
|
|
|
- /// </summary>
|
|
|
- /// <param name="methodName"></param>
|
|
|
- /// <param name="targetMethodName"></param>
|
|
|
- /// <param name="arguments"></param>
|
|
|
- /// ?page=measure&token=F680C7A0ADEF45D28D291DFD290000AC&patientCode=PatientInfoDO_20220725094305QTFMzU&index=0&imageIndex=0
|
|
|
- private void ExecuteJS(string methodName, TargetMethodName targetMethodName, List<string> arguments)
|
|
|
- {
|
|
|
- string callString = methodName + "(";
|
|
|
- if (arguments != null)
|
|
|
- {
|
|
|
- string comma = ", ";
|
|
|
- var argumentsStr = "";
|
|
|
- int index = 0;
|
|
|
- foreach (var e in arguments)
|
|
|
- {
|
|
|
- if (index == arguments.Count - 1)
|
|
|
- {
|
|
|
- argumentsStr += e;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- argumentsStr += e + "&";
|
|
|
- }
|
|
|
- index++;
|
|
|
- }
|
|
|
- var escaped = System.Web.HttpUtility.JavaScriptStringEncode(argumentsStr, true);
|
|
|
- callString += (int)targetMethodName + comma + escaped;
|
|
|
- }
|
|
|
- callString += ");";
|
|
|
- _browser?.ExecuteJavaScript(callString, null, 0);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
private void SlaveWindow_Closing(object? sender, System.ComponentModel.CancelEventArgs e)
|
|
|
{
|
|
|
if (!ForceClose)
|
|
|
{
|
|
|
e.Cancel = true;
|
|
|
- WindowState = WindowState.Minimized;
|
|
|
- //ShowInTaskbar = false;
|
|
|
- ShowActivated = false;
|
|
|
- Hide();
|
|
|
+ Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
+ {
|
|
|
+ ShowActivated = false;
|
|
|
+ Hide();
|
|
|
+ });
|
|
|
GC.Collect();
|
|
|
}
|
|
|
}
|
|
@@ -160,7 +126,6 @@ namespace fis
|
|
|
{
|
|
|
AvaloniaXamlLoader.Load(this);
|
|
|
var browserContainer = this.FindControl<Border>("BrowserBorder");
|
|
|
-
|
|
|
IPlatformService platformService;
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
|
{
|
|
@@ -179,47 +144,6 @@ namespace fis
|
|
|
{
|
|
|
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
|
|
|
- {
|
|
|
- var appHandler = new FileSystemHostHandler(ShellConfig.Instance.AppHost, ShellConfig.Instance.AppResourcePath);
|
|
|
- var localHost = "";
|
|
|
-
|
|
|
-
|
|
|
- var resourceHandler = new FileSystemHostHandler(localHost, ShellConfig.Instance.LocalResourcePath);
|
|
|
- var handler = new HostRequestHandler();
|
|
|
- handler.RegisterHostHandler(resourceHandler);
|
|
|
- if (_windowType == WindowType.Measure)
|
|
|
- {
|
|
|
- localHost = ShellConfig.Instance.MeasureApiHost;
|
|
|
- var platformHandler = new JsonRpcHandler<IMeasureService>(localHost, new MeasureService());
|
|
|
- handler.RegisterHostHandler(platformHandler);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- localHost = ShellConfig.Instance.ReportApiHost;
|
|
|
- var platformHandler = new JsonRpcHandler<IReportService>(localHost, new ReportService());
|
|
|
- handler.RegisterHostHandler(platformHandler);
|
|
|
- }
|
|
|
-
|
|
|
- handler.RegisterHostHandler(appHandler);
|
|
|
- _browser = new AvaloniaCefBrowser
|
|
|
- {
|
|
|
- RequestHandler = handler
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
var parameter = "";
|
|
|
var index = 0;
|
|
|
foreach (var p in _parameters)
|
|
@@ -257,14 +181,6 @@ namespace fis
|
|
|
{
|
|
|
_title.Text = "FLYINSONO";
|
|
|
}
|
|
|
- }
|
|
|
- if (_title != null && _host.Contains(ShellConfig.Instance.DistHost))
|
|
|
- {
|
|
|
- var scriptObj = new FisBrowserScriptObject(_title, platformService);
|
|
|
- _browser.RegisterJavascriptObject(scriptObj, "FisShellApi");
|
|
|
- }
|
|
|
- else if(_title != null)
|
|
|
- {
|
|
|
var scriptObj = new FisBrowserScriptObject(_title, platformService);
|
|
|
_browser.RegisterJavascriptObject(scriptObj, "FisShellApi");
|
|
|
}
|
|
@@ -274,7 +190,6 @@ namespace fis
|
|
|
WindowState = WindowState.Maximized;
|
|
|
MinWidth = 1366;
|
|
|
MinHeight = 768;
|
|
|
-
|
|
|
var assembly = Assembly.GetExecutingAssembly();
|
|
|
Stream? resourceStream = null;
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
@@ -289,7 +204,6 @@ namespace fis
|
|
|
{
|
|
|
Icon = new WindowIcon(resourceStream);
|
|
|
}
|
|
|
-
|
|
|
if (_windowType == WindowType.Measure)
|
|
|
{
|
|
|
BrowserManager.MeasureWindowBrowser = _browser;
|
|
@@ -301,43 +215,4 @@ namespace fis
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- interface IMeasureService
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- interface IReportService
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public class MeasureService: PlatformService, IPlatformService, IMeasureService
|
|
|
- {
|
|
|
- public override string GetPlatformName() => "Win-X86";
|
|
|
-
|
|
|
- public override Microphone[] GetMicrophones()
|
|
|
- {
|
|
|
- return new Microphone[] { };
|
|
|
- }
|
|
|
-
|
|
|
- public override Speaker[] GetSpeakers()
|
|
|
- {
|
|
|
- return new Speaker[] { };
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public class ReportService: PlatformService, IPlatformService, IReportService
|
|
|
- {
|
|
|
- public override string GetPlatformName() => "Win-X86";
|
|
|
-
|
|
|
- public override Microphone[] GetMicrophones()
|
|
|
- {
|
|
|
- return new Microphone[] { };
|
|
|
- }
|
|
|
-
|
|
|
- public override Speaker[] GetSpeakers()
|
|
|
- {
|
|
|
- return new Speaker[] { };
|
|
|
- }
|
|
|
- }
|
|
|
}
|