2024-11-13 17:09:15 +08:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using Avalonia;
|
|
|
|
|
using Avalonia.Controls;
|
|
|
|
|
using Avalonia.Markup.Xaml;
|
|
|
|
|
using Avalonia.Platform;
|
2024-11-14 17:11:43 +08:00
|
|
|
|
using Avalonia.ReactiveUI;
|
2024-11-13 17:09:15 +08:00
|
|
|
|
using Avalonia.Threading;
|
|
|
|
|
using Avalonia.VisualTree;
|
|
|
|
|
using detect.gui.ViewModels;
|
|
|
|
|
using ReactiveUI;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitializeComponent()
|
|
|
|
|
{
|
|
|
|
|
AvaloniaXamlLoader.Load(this);
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-14 17:11:43 +08:00
|
|
|
|
// public void InitUI(int? index = null)
|
|
|
|
|
// {
|
|
|
|
|
// if (ParentContent == null) return;
|
|
|
|
|
// var timer = new Timer(_ =>
|
|
|
|
|
// {
|
|
|
|
|
// Dispatcher.UIThread.InvokeAsync(() =>
|
|
|
|
|
// {
|
|
|
|
|
// if (!ParentContent.IsAttachedToVisualTree()) return;
|
|
|
|
|
// Width = ParentContent.Get<Border>("WebView").Bounds.Width;
|
|
|
|
|
// Height = ParentContent.Get<Border>("WebView").Bounds.Height;
|
|
|
|
|
// Position = ParentContent.Get<Border>("WebView").PointToScreen(new Point(0, 0));
|
|
|
|
|
// if (index != null)
|
|
|
|
|
// SetAddress(index.Value);
|
|
|
|
|
// if (!IsVisible)
|
|
|
|
|
// Show();
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
// timer.Change(100, 0);
|
|
|
|
|
// }
|
2024-11-13 17:09:15 +08:00
|
|
|
|
|
|
|
|
|
public void SetAddress(int index)
|
|
|
|
|
{
|
|
|
|
|
(DataContext as WebViewModel)!.SetAddress(index);
|
|
|
|
|
}
|
|
|
|
|
}
|