mirror of
http://git.xinwangdao.com/cnnc-embedded-parts-detect/detect.git
synced 2025-06-24 13:34:13 +08:00
46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
using Avalonia.Controls;
|
|
using Avalonia.Markup.Xaml;
|
|
using Avalonia.Platform;
|
|
using detect.gui.Services;
|
|
using detect.gui.ViewModels;
|
|
using Serilog;
|
|
using Splat;
|
|
using WebViewControl;
|
|
|
|
namespace detect.gui.Views;
|
|
|
|
public partial class WebBrowserWindow : Window
|
|
{
|
|
public UserControl? ParentContent { get; set; }
|
|
|
|
public WebBrowserWindow()
|
|
{
|
|
InitializeComponent();
|
|
|
|
DataContext = new WebViewModel();
|
|
|
|
ExtendClientAreaToDecorationsHint = true;
|
|
ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.NoChrome;
|
|
ExtendClientAreaTitleBarHeightHint = -1;
|
|
SystemDecorations = SystemDecorations.None;
|
|
// ShowInTaskbar = false;
|
|
// Topmost = true;
|
|
CanResize = false;
|
|
|
|
var webview = this.Get<WebView>("WebView");
|
|
var service = Locator.Current.GetService<DeviceClientService>();
|
|
webview.RegisterJavascriptObject("DeviceClientService", service);
|
|
webview.RegisterJavascriptObject("WebViewService", new WebViewService(this));
|
|
Log.Information("WebView Initialized.");
|
|
}
|
|
|
|
private void InitializeComponent()
|
|
{
|
|
AvaloniaXamlLoader.Load(this);
|
|
}
|
|
|
|
public void SetAddress(int index)
|
|
{
|
|
(DataContext as WebViewModel)!.SetAddress(index);
|
|
}
|
|
} |