2024-11-15 15:01:03 +08:00
|
|
|
|
using System;
|
|
|
|
|
using Avalonia.Controls;
|
2024-11-13 17:09:15 +08:00
|
|
|
|
using Avalonia.Markup.Xaml;
|
|
|
|
|
using Avalonia.Platform;
|
2024-11-15 14:49:29 +08:00
|
|
|
|
using detect.gui.Services;
|
2024-11-13 17:09:15 +08:00
|
|
|
|
using detect.gui.ViewModels;
|
2024-11-15 14:49:29 +08:00
|
|
|
|
using Serilog;
|
|
|
|
|
using Splat;
|
2024-11-15 15:58:09 +08:00
|
|
|
|
using WebViewControl;
|
2024-11-13 17:09:15 +08:00
|
|
|
|
|
|
|
|
|
namespace detect.gui.Views;
|
|
|
|
|
|
|
|
|
|
public partial class WebBrowserWindow : Window
|
|
|
|
|
{
|
2024-11-14 17:11:43 +08:00
|
|
|
|
public UserControl? ParentContent { get; set; }
|
|
|
|
|
|
2024-11-13 17:09:15 +08:00
|
|
|
|
public WebBrowserWindow()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
DataContext = new WebViewModel();
|
|
|
|
|
|
|
|
|
|
ExtendClientAreaToDecorationsHint = true;
|
|
|
|
|
ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.NoChrome;
|
|
|
|
|
ExtendClientAreaTitleBarHeightHint = -1;
|
|
|
|
|
SystemDecorations = SystemDecorations.None;
|
|
|
|
|
ShowInTaskbar = false;
|
|
|
|
|
Topmost = true;
|
|
|
|
|
CanResize = false;
|
2024-11-15 14:49:29 +08:00
|
|
|
|
|
2024-11-15 15:58:09 +08:00
|
|
|
|
var webview = this.Get<WebView>("WebView");
|
2024-11-15 15:01:03 +08:00
|
|
|
|
var service = Locator.Current.GetService<DeviceClientService>();
|
2024-11-15 15:58:09 +08:00
|
|
|
|
webview.RegisterJavascriptObject("DeviceClientService", service);
|
|
|
|
|
Log.Information("WebView Initialized.");
|
2024-11-13 17:09:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitializeComponent()
|
|
|
|
|
{
|
|
|
|
|
AvaloniaXamlLoader.Load(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetAddress(int index)
|
|
|
|
|
{
|
|
|
|
|
(DataContext as WebViewModel)!.SetAddress(index);
|
|
|
|
|
}
|
|
|
|
|
}
|