This commit is contained in:
AlastorFox committed 2026-10-01 04:38:11 +03:00
1 parent 54a3e81109
commit e1ef325b3a
11 files changed
+505 -7

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
<Window x:Class="FoxBrowser.UI.BlockedElementsWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Вирізані елементи" Width="620" Height="430" MinWidth="480" MinHeight="300"
WindowStartupLocation="CenterOwner"
Background="{StaticResource HeaderBg}" Foreground="{StaticResource TextPrimary}">
<DockPanel Margin="16">
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,12,0,0">
<Button Content="Видалити вибране правило" Click="RemoveSelected_Click" Padding="10,6" />
<Button Content="Очистити сайт" Click="ClearSite_Click" Padding="10,6" Margin="8,0,0,0" />
<Button Content="Закрити" Click="Close_Click" Padding="10,6" Margin="8,0,0,0" />
</StackPanel>
<TextBlock DockPanel.Dock="Top" Text="Заблоковані елементи" FontSize="16" FontWeight="SemiBold" />
<TextBlock DockPanel.Dock="Top" Text="Вибери конкретне правило, щоб повернути один елемент. Правила діють лише для поточного сайту." Foreground="{StaticResource TextSecondary}" TextWrapping="Wrap" Margin="0,4,0,10" />
<ListBox x:Name="SelectorList" Background="{StaticResource CardBg}" BorderBrush="{StaticResource BorderMedium}" Foreground="{StaticResource TextPrimary}" />
</DockPanel>
</Window>
+36
View File
@@ -0,0 +1,36 @@
using System.Windows;
using FoxBrowser.Core;
namespace FoxBrowser.UI;
public partial class BlockedElementsWindow : Window
{
private readonly TabManager _tabManager;
public BlockedElementsWindow(TabManager tabManager)
{
InitializeComponent();
_tabManager = tabManager;
RefreshList();
}
private void RefreshList()
{
SelectorList.ItemsSource = _tabManager.GetBlockedSelectors();
}
private async void RemoveSelected_Click(object sender, RoutedEventArgs e)
{
if (SelectorList.SelectedItem is not string selector) return;
await _tabManager.RemoveBlockedSelectorAsync(selector);
RefreshList();
}
private async void ClearSite_Click(object sender, RoutedEventArgs e)
{
await _tabManager.ClearBlockedForCurrentHostAsync();
RefreshList();
}
private void Close_Click(object sender, RoutedEventArgs e) => Close();
}
+8
View File
@@ -1,9 +1,17 @@
<Window x:Class="FoxBrowser.UI.ExtensionPopupWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:shell="clr-namespace:System.Windows.Shell;assembly=PresentationFramework"
WindowStyle="None" ResizeMode="NoResize" ShowInTaskbar="False"
Width="360" Height="520" MaxHeight="600"
Background="#202328" AllowsTransparency="False">
<shell:WindowChrome.WindowChrome>
<shell:WindowChrome
GlassFrameThickness="0"
CaptionHeight="0"
ResizeBorderThickness="0"
UseAeroCaptionButtons="False" />
</shell:WindowChrome.WindowChrome>
<Border BorderBrush="#59616D" BorderThickness="1" Background="#202328">
<Grid x:Name="PopupHost" />
</Border>
+24 -3
View File
@@ -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();
}