|
@@ -1,25 +1,18 @@
|
|
using System;
|
|
using System;
|
|
-using System.IO;
|
|
|
|
-using Avalonia;
|
|
|
|
using Avalonia.Controls;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Markup.Xaml;
|
|
using Avalonia.Markup.Xaml;
|
|
using fis.Win;
|
|
using fis.Win;
|
|
-using System.Globalization;
|
|
|
|
-using System.Reflection;
|
|
|
|
-using System.Threading;
|
|
|
|
-using System.Runtime.InteropServices;
|
|
|
|
using fis.Managers;
|
|
using fis.Managers;
|
|
using fis.Managers.Interfaces;
|
|
using fis.Managers.Interfaces;
|
|
using Avalonia.Threading;
|
|
using Avalonia.Threading;
|
|
using fis.Utilities;
|
|
using fis.Utilities;
|
|
using fis.Win.Utilities;
|
|
using fis.Win.Utilities;
|
|
-using System.Linq;
|
|
|
|
|
|
+using System.Collections.Generic;
|
|
|
|
|
|
namespace fis
|
|
namespace fis
|
|
{
|
|
{
|
|
public partial class MainWindow : BaseWindow
|
|
public partial class MainWindow : BaseWindow
|
|
{
|
|
{
|
|
- private const string ThisWindowName = "Main";
|
|
|
|
private WindowState _windowState = WindowState.Normal;
|
|
private WindowState _windowState = WindowState.Normal;
|
|
|
|
|
|
|
|
|
|
@@ -31,16 +24,22 @@ namespace fis
|
|
InitializeMainComponent();
|
|
InitializeMainComponent();
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- protected override void HandleWindowStateChanged(WindowState state)
|
|
|
|
|
|
+
|
|
|
|
+ protected override void HandleWindowStateChanged(WindowState state)
|
|
{
|
|
{
|
|
_windowState = state;
|
|
_windowState = state;
|
|
- string[] list = { ((int)state).ToString() };
|
|
|
|
- BrowserManager.ExecuteJS(TargetMethodName.OnWindowStateChange, list.ToList());
|
|
|
|
|
|
+ BrowserManager.MainBrowser.ExcuteJS(TargetMethodName.OnWindowStateChange, new List<string> { ((int)state).ToString() });
|
|
}
|
|
}
|
|
|
|
|
|
private void InitializeMainComponent()
|
|
private void InitializeMainComponent()
|
|
{
|
|
{
|
|
|
|
+ BrowserManager.MainBrowser.RegisterJavascriptObject(ScriptObj, JSObjectName);
|
|
|
|
+ BrowserManager.MainBrowser.BrowserInitialized += () =>
|
|
|
|
+ {
|
|
|
|
+#if DEBUG
|
|
|
|
+ BrowserManager.MainBrowser!.ShowDeveloperTools();
|
|
|
|
+#endif
|
|
|
|
+ };
|
|
//Make cross domain work.
|
|
//Make cross domain work.
|
|
BrowserManager.MainBrowser.Address = "http://" + ShellConfig.Instance.AppHost + "/index.html";
|
|
BrowserManager.MainBrowser.Address = "http://" + ShellConfig.Instance.AppHost + "/index.html";
|
|
BrowserManager.MainBrowser.ContextMenuHandler = new TextContextMenuHandler(BrowserManager.MainBrowser);
|
|
BrowserManager.MainBrowser.ContextMenuHandler = new TextContextMenuHandler(BrowserManager.MainBrowser);
|
|
@@ -48,10 +47,10 @@ namespace fis
|
|
{
|
|
{
|
|
WindowDragingHelper.StartMouseMonitor();
|
|
WindowDragingHelper.StartMouseMonitor();
|
|
//Register the main window.
|
|
//Register the main window.
|
|
- WindowDragingHelper.RegisterWindow(ThisWindowName, PlatformImpl.Handle.Handle);
|
|
|
|
|
|
+ WindowDragingHelper.RegisterWindow(WindowName, PlatformImpl.Handle.Handle);
|
|
winFisBrowser.WindowDragBegan += (sender, e) =>
|
|
winFisBrowser.WindowDragBegan += (sender, e) =>
|
|
{
|
|
{
|
|
- if (e == ThisWindowName)
|
|
|
|
|
|
+ if (e == WindowName)
|
|
{
|
|
{
|
|
_windowState = WindowState.Normal;
|
|
_windowState = WindowState.Normal;
|
|
WindowDragingHelper.BeginWindowDrag(e);
|
|
WindowDragingHelper.BeginWindowDrag(e);
|
|
@@ -59,15 +58,15 @@ namespace fis
|
|
};
|
|
};
|
|
winFisBrowser.WindowDragEnded += (sender, e) =>
|
|
winFisBrowser.WindowDragEnded += (sender, e) =>
|
|
{
|
|
{
|
|
- if (e == ThisWindowName)
|
|
|
|
|
|
+ if (e == WindowName)
|
|
{
|
|
{
|
|
WindowDragingHelper.EndWindowDrag(e);
|
|
WindowDragingHelper.EndWindowDrag(e);
|
|
}
|
|
}
|
|
|
|
|
|
};
|
|
};
|
|
- winFisBrowser.WindowMaximized += (sender, e) =>
|
|
|
|
|
|
+ winFisBrowser.WindowMaximized += (sender, e) =>
|
|
{
|
|
{
|
|
- if (e == ThisWindowName)
|
|
|
|
|
|
+ if (e == WindowName)
|
|
{
|
|
{
|
|
if (_windowState == WindowState.Maximized)
|
|
if (_windowState == WindowState.Maximized)
|
|
{
|
|
{
|
|
@@ -78,17 +77,17 @@ namespace fis
|
|
WindowDragingHelper.MaximizeWindow(e);
|
|
WindowDragingHelper.MaximizeWindow(e);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
- winFisBrowser.WindowMinimized += (sender, e) =>
|
|
|
|
|
|
+ winFisBrowser.WindowMinimized += (sender, e) =>
|
|
{
|
|
{
|
|
- if (e == ThisWindowName)
|
|
|
|
|
|
+ if (e == WindowName)
|
|
{
|
|
{
|
|
_windowState = WindowState.Minimized;
|
|
_windowState = WindowState.Minimized;
|
|
WindowDragingHelper.MinimizeWindow(e);
|
|
WindowDragingHelper.MinimizeWindow(e);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
- winFisBrowser.WindowRestored += (sender, e) =>
|
|
|
|
|
|
+ winFisBrowser.WindowRestored += (sender, e) =>
|
|
{
|
|
{
|
|
- if (e == ThisWindowName)
|
|
|
|
|
|
+ if (e == WindowName)
|
|
{
|
|
{
|
|
_windowState = WindowState.Normal;
|
|
_windowState = WindowState.Normal;
|
|
WindowDragingHelper.RestoreWindow(e);
|
|
WindowDragingHelper.RestoreWindow(e);
|
|
@@ -98,15 +97,17 @@ namespace fis
|
|
}
|
|
}
|
|
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
|
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
|
WindowState = WindowState.Maximized;
|
|
WindowState = WindowState.Maximized;
|
|
- AppManager.ParentWindow = this;
|
|
|
|
|
|
+ AppManager.MainWindow = this;
|
|
Closed += OnMainWindowClosed;
|
|
Closed += OnMainWindowClosed;
|
|
|
|
+ var browserContainer = this.FindControl<Border>("BrowserBorder");
|
|
|
|
+ browserContainer.Child = BrowserManager.MainBrowser;
|
|
}
|
|
}
|
|
|
|
|
|
private void OnBrowserCloseTheWindow(object? sender, string e)
|
|
private void OnBrowserCloseTheWindow(object? sender, string e)
|
|
{
|
|
{
|
|
- if (e == ThisWindowName)
|
|
|
|
|
|
+ if (e == WindowName)
|
|
{
|
|
{
|
|
- Dispatcher.UIThread.Post(new Action(() => Close()));
|
|
|
|
|
|
+ Dispatcher.UIThread.Post(new Action(() => Close()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -116,7 +117,7 @@ namespace fis
|
|
{
|
|
{
|
|
WindowDragingHelper.StopMouseMonitor();
|
|
WindowDragingHelper.StopMouseMonitor();
|
|
//UnRegister the main window.
|
|
//UnRegister the main window.
|
|
- WindowDragingHelper.UnRegisterWindow(ThisWindowName);
|
|
|
|
|
|
+ WindowDragingHelper.UnRegisterWindow(WindowName);
|
|
}
|
|
}
|
|
var manager = AppManager.Get<ISecondaryScreenManager>();
|
|
var manager = AppManager.Get<ISecondaryScreenManager>();
|
|
manager.Dispose();
|
|
manager.Dispose();
|