|
@@ -0,0 +1,59 @@
|
|
|
+using Avalonia;
|
|
|
+using Avalonia.Threading;
|
|
|
+using fis.Win.Dev.Managers.Interfaces;
|
|
|
+using fis.Win.Dev.Utilities;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Threading.Tasks;
|
|
|
+
|
|
|
+namespace fis.Win.Dev.Managers
|
|
|
+{
|
|
|
+ internal class SecondaryScreenManager: ISecondaryScreenManager
|
|
|
+ {
|
|
|
+ Dictionary<WindowType, SlaveWindow> windows = new Dictionary<WindowType, SlaveWindow>();
|
|
|
+
|
|
|
+ public async Task ShowWindowByTypeAsync(WindowType windowType, string host, Dictionary<string, string> keyValuePairs)
|
|
|
+ {
|
|
|
+ await Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
+ {
|
|
|
+ SlaveWindow window;
|
|
|
+ if (windows.Keys.Contains(windowType))
|
|
|
+ {
|
|
|
+ window = windows[windowType];
|
|
|
+ window.ChangeContent(host, keyValuePairs);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ 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.Closed += Window_Closed;
|
|
|
+ windows.Add(windowType, window);
|
|
|
+ window.Show();
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Window_Closed(object? sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (windows.Any(w => w.Value == sender)) {
|
|
|
+ var window = windows.FirstOrDefault(x=>x.Value == sender);
|
|
|
+ windows.Remove(window.Key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void Dispose()
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|