BASE 1.2.1

This commit is contained in:
AlastorFox committed 2026-10-02 00:44:14 +03:00
1 parent 85df7949e2
commit 195360dc47
2 files changed
+45 -1

No files matched your search

+13
View File
@@ -45,6 +45,7 @@ public sealed class TabManager : IAsyncDisposable
public bool IsMinimizedMode => _minimizedMode; public bool IsMinimizedMode => _minimizedMode;
public bool ExtensionsAvailable { get; private set; } public bool ExtensionsAvailable { get; private set; }
public bool SessionReady { get; private set; } public bool SessionReady { get; private set; }
public bool IsElementPickerActive { get; private set; }
public CoreWebView2Environment Environment => _environment; public CoreWebView2Environment Environment => _environment;
public WebView2 View => _view; public WebView2 View => _view;
public ExtensionManager? ExtensionManager { get; private set; } public ExtensionManager? ExtensionManager { get; private set; }
@@ -137,6 +138,7 @@ public sealed class TabManager : IAsyncDisposable
try try
{ {
if (ActiveTab is not null) await CaptureActiveStateAsync(); if (ActiveTab is not null) await CaptureActiveStateAsync();
IsElementPickerActive = false;
ActiveTab = tab; ActiveTab = tab;
_audioOnly = tab.IsAudioOnly; _audioOnly = tab.IsAudioOnly;
ActiveTabStateChanged?.Invoke(this, EventArgs.Empty); ActiveTabStateChanged?.Invoke(this, EventArgs.Empty);
@@ -212,6 +214,15 @@ public sealed class TabManager : IAsyncDisposable
public async Task StartElementPickerAsync() public async Task StartElementPickerAsync()
{ {
if (_view.CoreWebView2 is null || ActiveTab is null) return; if (_view.CoreWebView2 is null || ActiveTab is null) return;
if (IsElementPickerActive)
{
await _view.CoreWebView2.ExecuteScriptAsync("window.__foxElementPicker?.();");
IsElementPickerActive = false;
ActiveTabStateChanged?.Invoke(this, EventArgs.Empty);
return;
}
IsElementPickerActive = true;
ActiveTabStateChanged?.Invoke(this, EventArgs.Empty);
await _view.CoreWebView2.ExecuteScriptAsync(""" await _view.CoreWebView2.ExecuteScriptAsync("""
(()=>{ (()=>{
if(window.__foxElementPicker){window.__foxElementPicker();return;} if(window.__foxElementPicker){window.__foxElementPicker();return;}
@@ -369,7 +380,9 @@ public sealed class TabManager : IAsyncDisposable
if (!_blockedElements.TryGetValue(host, out var selectors)) if (!_blockedElements.TryGetValue(host, out var selectors))
_blockedElements[host] = selectors = new List<string>(); _blockedElements[host] = selectors = new List<string>();
if (!selectors.Contains(selector, StringComparer.Ordinal)) selectors.Add(selector); if (!selectors.Contains(selector, StringComparer.Ordinal)) selectors.Add(selector);
IsElementPickerActive = false;
SaveBlockedElements(); SaveBlockedElements();
ActiveTabStateChanged?.Invoke(this, EventArgs.Empty);
_ = ApplyBlockedElementsAsync(); _ = ApplyBlockedElementsAsync();
} }
catch (JsonException) { } catch (JsonException) { }
+32 -1
View File
@@ -147,10 +147,15 @@ public partial class MainWindow : Window
if (startupNotice is not null) if (startupNotice is not null)
System.Windows.MessageBox.Show(this, startupNotice, "FoxBrowser", MessageBoxButton.OK, MessageBoxImage.Information); System.Windows.MessageBox.Show(this, startupNotice, "FoxBrowser", MessageBoxButton.OK, MessageBoxImage.Information);
_tabManager = new TabManager(WebViewHost, environment, !recoveryMode); _tabManager = new TabManager(WebViewHost, environment, !recoveryMode);
_tabManager.ActiveTabStateChanged += (_, _) => Dispatcher.Invoke(RefreshAddressBar); _tabManager.ActiveTabStateChanged += (_, _) => Dispatcher.Invoke(() =>
{
RefreshAddressBar();
RefreshModeIndicators();
});
DataContext = _tabManager; DataContext = _tabManager;
await _tabManager.InitializeAsync(); await _tabManager.InitializeAsync();
TabStrip.SelectedItem = _tabManager.ActiveTab; TabStrip.SelectedItem = _tabManager.ActiveTab;
RefreshModeIndicators();
var iconPath = ResolveAppIconPath(_appSettings); var iconPath = ResolveAppIconPath(_appSettings);
try try
{ {
@@ -202,6 +207,7 @@ public partial class MainWindow : Window
if (_tabManager is null) return; if (_tabManager is null) return;
await _tabManager.ToggleDarkModeAsync(); await _tabManager.ToggleDarkModeAsync();
TabStrip.Items.Refresh(); TabStrip.Items.Refresh();
RefreshModeIndicators();
} }
private void DarkMode_RightClick(object sender, MouseButtonEventArgs e) private void DarkMode_RightClick(object sender, MouseButtonEventArgs e)
@@ -215,6 +221,7 @@ public partial class MainWindow : Window
BlockedElementsPopup.IsOpen = false; BlockedElementsPopup.IsOpen = false;
if (_tabManager is null) return; if (_tabManager is null) return;
await _tabManager.StartElementPickerAsync(); await _tabManager.StartElementPickerAsync();
RefreshModeIndicators();
} }
private void ElementPicker_RightClick(object sender, MouseButtonEventArgs e) private void ElementPicker_RightClick(object sender, MouseButtonEventArgs e)
@@ -336,6 +343,7 @@ public partial class MainWindow : Window
AddressBox.Text = tab.Address; AddressBox.Text = tab.Address;
await _tabManager.SwitchToTabAsync(tab); await _tabManager.SwitchToTabAsync(tab);
RefreshAddressBar(); RefreshAddressBar();
RefreshModeIndicators();
} }
private async void CloseTab_Click(object sender, RoutedEventArgs e) private async void CloseTab_Click(object sender, RoutedEventArgs e)
@@ -398,4 +406,27 @@ public partial class MainWindow : Window
AddressBox.Text = _tabManager.ActiveTab.Address; AddressBox.Text = _tabManager.ActiveTab.Address;
} }
} }
private void RefreshModeIndicators()
{
if (!IsInitialized) return;
var darkActive = _tabManager?.ActiveTab?.IsDarkMode == true;
var pickerActive = _tabManager?.IsElementPickerActive == true;
var activeBackground = (System.Windows.Media.Brush)FindResource("AurBlueSoft");
var activeBorder = (System.Windows.Media.Brush)FindResource("AurBlue");
var inactiveBackground = (System.Windows.Media.Brush)FindResource("CardBg");
var inactiveBorder = (System.Windows.Media.Brush)FindResource("BorderMedium");
DarkModeButton.Background = darkActive ? activeBackground : inactiveBackground;
DarkModeButton.BorderBrush = darkActive ? activeBorder : inactiveBorder;
DarkModeButton.Foreground = darkActive
? (System.Windows.Media.Brush)FindResource("TextPrimary")
: (System.Windows.Media.Brush)FindResource("TextSecondary");
ElementPickerButton.Background = pickerActive ? activeBackground : inactiveBackground;
ElementPickerButton.BorderBrush = pickerActive ? activeBorder : inactiveBorder;
ElementPickerButton.Foreground = pickerActive
? (System.Windows.Media.Brush)FindResource("TextPrimary")
: (System.Windows.Media.Brush)FindResource("TextSecondary");
}
} }