|
@@ -22,6 +22,8 @@ namespace fis
|
|
|
private TextBlock? _title;
|
|
|
private AvaloniaCefBrowser? _browser;
|
|
|
private string _host;
|
|
|
+ private WindowType _windowType;
|
|
|
+
|
|
|
private Dictionary<string, string> _parameters;
|
|
|
|
|
|
public bool ForceClose { get; set; } = false;
|
|
@@ -33,7 +35,7 @@ namespace fis
|
|
|
ExtendClientAreaTitleBarHeightHint = -1;
|
|
|
MainThreadSyncContext = SynchronizationContext.Current;
|
|
|
#if DEBUG
|
|
|
- this.AttachDevTools();
|
|
|
+ // this.AttachDevTools();
|
|
|
#endif
|
|
|
Closing += SlaveWindow_Closing;
|
|
|
}
|
|
@@ -43,8 +45,9 @@ namespace fis
|
|
|
/// </summary>
|
|
|
/// <param name="host"></param>
|
|
|
/// <param name="dictionary"></param>
|
|
|
- public void init(string host, Dictionary<string, string> dictionary)
|
|
|
+ public void init(string host, Dictionary<string, string> dictionary, WindowType windowType)
|
|
|
{
|
|
|
+ _windowType = windowType;
|
|
|
_parameters = dictionary;
|
|
|
_host = host;
|
|
|
InitializeComponent();
|
|
@@ -55,7 +58,7 @@ namespace fis
|
|
|
/// </summary>
|
|
|
/// <param name="host"></param>
|
|
|
/// <param name="keyValuePairs"></param>
|
|
|
- internal void ChangeContentView(string host, Dictionary<string, string> keyValuePairs,WindowType windowType)
|
|
|
+ internal void ChangeContentView(string host, Dictionary<string, string> keyValuePairs, WindowType windowType)
|
|
|
{
|
|
|
_host = host;
|
|
|
_parameters = keyValuePairs;
|
|
@@ -141,12 +144,12 @@ namespace fis
|
|
|
{
|
|
|
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();
|
|
|
}
|
|
@@ -154,7 +157,7 @@ namespace fis
|
|
|
{
|
|
|
this.FindControl<WindowsTitleBar>("WinTitleBar").IsVisible = false;
|
|
|
_title = this.FindControl<MacosTitleBar>("MacTitleBar").FindControl<TextBlock>("MacosTitle");
|
|
|
- platformService = new MacService();
|
|
|
+ platformService = new MacService();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -162,32 +165,48 @@ namespace fis
|
|
|
}
|
|
|
if (_host.Contains(ShellConfig.Instance.DistHost))
|
|
|
{
|
|
|
- var appHandler = new FileSystemHostHandler(ShellConfig.Instance.DistHost , ShellConfig.Instance.DistResourcePath);
|
|
|
-
|
|
|
+ var appHandler = new FileSystemHostHandler(ShellConfig.Instance.DistHost, ShellConfig.Instance.DistResourcePath);
|
|
|
+
|
|
|
var handler = new HostRequestHandler();
|
|
|
handler.RegisterHostHandler(appHandler);
|
|
|
-
|
|
|
+
|
|
|
_browser = new AvaloniaCefBrowser
|
|
|
{
|
|
|
RequestHandler = handler
|
|
|
};
|
|
|
}
|
|
|
- else
|
|
|
+ else
|
|
|
{
|
|
|
var appHandler = new FileSystemHostHandler(ShellConfig.Instance.AppHost, ShellConfig.Instance.AppResourcePath);
|
|
|
- var resourceHandler = new FileSystemHostHandler(ShellConfig.Instance.LocalResourceHost, ShellConfig.Instance.LocalResourcePath);
|
|
|
+ var localHost = "";
|
|
|
+
|
|
|
+
|
|
|
+ var resourceHandler = new FileSystemHostHandler(localHost, ShellConfig.Instance.LocalResourcePath);
|
|
|
var handler = new HostRequestHandler();
|
|
|
- // handler.RegisterHostHandler(resourceHandler);
|
|
|
+ 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)
|
|
|
+ foreach (var p in _parameters)
|
|
|
{
|
|
|
parameter += p.Key + "=" + p.Value;
|
|
|
if (index < _parameters.Count - 1) {
|
|
@@ -208,7 +227,7 @@ namespace fis
|
|
|
_browser.BrowserInitialized += () =>
|
|
|
{
|
|
|
#if DEBUG
|
|
|
- _browser!.ShowDeveloperTools();
|
|
|
+ // _browser!.ShowDeveloperTools();
|
|
|
#endif
|
|
|
};
|
|
|
var language = CultureInfo.CurrentCulture.Name;
|
|
@@ -230,7 +249,7 @@ namespace fis
|
|
|
}
|
|
|
else {
|
|
|
var scriptObj = new FisBrowserScriptObject(_title, platformService);
|
|
|
- _browser.RegisterJavascriptObject(scriptObj, "FisShellNotify");
|
|
|
+ _browser.RegisterJavascriptObject(scriptObj, "FisShellApi");
|
|
|
}
|
|
|
browserContainer.Child = _browser;
|
|
|
WindowStartupLocation = WindowStartupLocation.Manual;
|
|
@@ -238,7 +257,7 @@ namespace fis
|
|
|
WindowState = WindowState.Maximized;
|
|
|
MinWidth = 1366;
|
|
|
MinHeight = 768;
|
|
|
-
|
|
|
+
|
|
|
var assembly = Assembly.GetExecutingAssembly();
|
|
|
Stream? resourceStream = null;
|
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
@@ -256,6 +275,43 @@ 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[] { };
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|