BASE 1.1
This commit is contained in:
1 parent
c3e1117b97
commit
9e684ec067
12 files changed
+507
-7
No files matched your search
@@ -1,6 +1,8 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
using Microsoft.Web.WebView2.Core;
|
||||
using Microsoft.Web.WebView2.Wpf;
|
||||
using FoxBrowser.Native;
|
||||
|
||||
namespace FoxBrowser.UI;
|
||||
|
||||
@@ -10,14 +12,33 @@ public partial class ExtensionPopupWindow : Window
|
||||
private readonly string _extensionId;
|
||||
private readonly string _popupPage;
|
||||
|
||||
public ExtensionPopupWindow(CoreWebView2Environment environment, string extensionId, string popupPage, System.Drawing.Point screenPosition)
|
||||
public ExtensionPopupWindow(
|
||||
CoreWebView2Environment environment,
|
||||
string extensionId,
|
||||
string popupPage,
|
||||
System.Windows.Point screenPosition,
|
||||
System.Windows.Rect workingArea)
|
||||
{
|
||||
InitializeComponent();
|
||||
_environment = environment;
|
||||
_extensionId = extensionId;
|
||||
_popupPage = popupPage;
|
||||
Left = screenPosition.X;
|
||||
Top = screenPosition.Y;
|
||||
WindowStartupLocation = WindowStartupLocation.Manual;
|
||||
SourceInitialized += (_, _) => Win32Interop.RemovePopupFrame(new WindowInteropHelper(this).Handle);
|
||||
|
||||
Width = Math.Min(Width, Math.Max(220, workingArea.Width - 8));
|
||||
Height = Math.Min(Height, Math.Max(160, workingArea.Height - 8));
|
||||
|
||||
// Keep the popup on the monitor where the extension button lives.
|
||||
// If there is no room below the toolbar, open it above the button.
|
||||
var left = Math.Min(screenPosition.X, workingArea.Right - Width - 4);
|
||||
left = Math.Max(left, workingArea.Left + 4);
|
||||
var top = screenPosition.Y + 4;
|
||||
if (top + Height > workingArea.Bottom - 4)
|
||||
top = screenPosition.Y - Height - 4;
|
||||
top = Math.Max(top, workingArea.Top + 4);
|
||||
Left = left;
|
||||
Top = top;
|
||||
Deactivated += (_, _) => Close();
|
||||
Loaded += async (_, _) => await InitializeAsync();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user