diff --git a/SLBr.sln b/SLBr.sln
index a375325..5c2ecad 100644
--- a/SLBr.sln
+++ b/SLBr.sln
@@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SLBr", "SLBr\SLBr.csproj",
EndProject
Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "SLBr Packaging Project", "SLBr Packaging Project\SLBr Packaging Project.wapproj", "{D4FC58AC-26D9-41C6-8F97-D28A935C18F3}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utility Service", "Utility Service\Utility Service.csproj", "{01B6FD23-3E66-40DA-A849-45513AEF573D}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -71,6 +73,26 @@ Global
{D4FC58AC-26D9-41C6-8F97-D28A935C18F3}.Release|x86.ActiveCfg = Release|x86
{D4FC58AC-26D9-41C6-8F97-D28A935C18F3}.Release|x86.Build.0 = Release|x86
{D4FC58AC-26D9-41C6-8F97-D28A935C18F3}.Release|x86.Deploy.0 = Release|x86
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Debug|ARM.ActiveCfg = Debug|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Debug|ARM.Build.0 = Debug|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Debug|ARM64.ActiveCfg = Debug|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Debug|ARM64.Build.0 = Debug|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Debug|x64.Build.0 = Debug|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Debug|x86.Build.0 = Debug|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Release|ARM.ActiveCfg = Release|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Release|ARM.Build.0 = Release|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Release|ARM64.ActiveCfg = Release|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Release|ARM64.Build.0 = Release|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Release|x64.ActiveCfg = Release|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Release|x64.Build.0 = Release|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Release|x86.ActiveCfg = Release|Any CPU
+ {01B6FD23-3E66-40DA-A849-45513AEF573D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/SLBr/App.xaml b/SLBr/App.xaml
index cdee871..0b9bf66 100644
--- a/SLBr/App.xaml
+++ b/SLBr/App.xaml
@@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SLBr"
- StartupUri="MainWindow.xaml" Startup="Application_Startup">
+ StartupUri="SplashScreen.xaml" Startup="Application_Startup">
diff --git a/SLBr/Controls/CredentialsDialog.cs b/SLBr/Controls/CredentialsDialog.cs
new file mode 100644
index 0000000..076802d
--- /dev/null
+++ b/SLBr/Controls/CredentialsDialog.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SLBr.Controls
+{
+ public class CredentialsDialogResult
+ {
+ public bool Accepted;
+ public string Username;
+ public string Password;
+
+ public CredentialsDialogResult(bool? _Accepted, string _Username, string _Password)
+ {
+ Accepted = (bool)_Accepted;
+ Username = _Username;
+ Password = _Password;
+ }
+ }
+ public static class CredentialsDialog
+ {
+ public static CredentialsDialogResult Show(string Question)
+ {
+ CredentialsDialogWindow _CredentialsDialogWindow = new CredentialsDialogWindow(Question);
+ _CredentialsDialogWindow.Topmost = true;
+ return new CredentialsDialogResult(_CredentialsDialogWindow.ShowDialog(), _CredentialsDialogWindow.Username, _CredentialsDialogWindow.Password);
+ }
+ }
+}
diff --git a/SLBr/Controls/CredentialsDialogWindow.xaml b/SLBr/Controls/CredentialsDialogWindow.xaml
new file mode 100644
index 0000000..3b907d2
--- /dev/null
+++ b/SLBr/Controls/CredentialsDialogWindow.xaml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Username
+
+
+
+ Password
+
+
+
+
+
+
+
+
+
+
diff --git a/SLBr/Controls/CredentialsDialogWindow.xaml.cs b/SLBr/Controls/CredentialsDialogWindow.xaml.cs
new file mode 100644
index 0000000..beaa8cf
--- /dev/null
+++ b/SLBr/Controls/CredentialsDialogWindow.xaml.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace SLBr.Controls
+{
+ ///
+ /// Interaction logic for CredentialsDialog.xaml
+ ///
+ public partial class CredentialsDialogWindow : Window
+ {
+ public CredentialsDialogWindow(string Question)
+ {
+ InitializeComponent();
+
+ lblQuestion.Content = Question;
+ ApplyTheme(MainWindow.Instance.GetTheme());
+ }
+
+ public void ApplyTheme(Theme _Theme)
+ {
+ //Resources["PrimaryBrush"] = new SolidColorBrush(_Theme.PrimaryColor);
+ //Resources["FontBrush"] = new SolidColorBrush(_Theme.FontColor);
+ //Resources["BorderBrush"] = new SolidColorBrush(_Theme.BorderColor);
+ //Resources["UnselectedTabBrush"] = new SolidColorBrush(_Theme.UnselectedTabColor);
+ //Resources["ControlFontBrush"] = new SolidColorBrush(_Theme.ControlFontColor);
+
+ Resources["PrimaryBrushColor"] = _Theme.PrimaryColor;
+ Resources["FontBrushColor"] = _Theme.FontColor;
+ Resources["BorderBrushColor"] = _Theme.BorderColor;
+ Resources["UnselectedTabBrushColor"] = _Theme.UnselectedTabColor;
+ Resources["ControlFontBrushColor"] = _Theme.ControlFontColor;
+
+ //Storyboard s = (Storyboard)Resources["ToBorderBrushColor"];
+ //s.SetValue(value)
+
+ //Resources["ToBorderBrushColor"] = new Storyboard(new ColorAnimation()).Color;
+ }
+ private void DialogOk_Click(object sender, RoutedEventArgs e)
+ {
+ DialogResult = true;
+ }
+
+ private void Window_ContentRendered(object sender, EventArgs e)
+ {
+ UsernameTextBox.SelectAll();
+ UsernameTextBox.Focus();
+ }
+
+ public string Username
+ {
+ get { return UsernameTextBox.Text; }
+ }
+ public string Password
+ {
+ get { return PasswordTextBox.Text; }
+ }
+ }
+}
diff --git a/SLBr/Controls/PopupBrowser.xaml b/SLBr/Controls/PopupBrowser.xaml
new file mode 100644
index 0000000..bbb89ec
--- /dev/null
+++ b/SLBr/Controls/PopupBrowser.xaml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SLBr/Controls/PopupBrowser.xaml.cs b/SLBr/Controls/PopupBrowser.xaml.cs
new file mode 100644
index 0000000..f8287fc
--- /dev/null
+++ b/SLBr/Controls/PopupBrowser.xaml.cs
@@ -0,0 +1,116 @@
+using CefSharp;
+using CefSharp.DevTools;
+using CefSharp.Wpf.HwndHost;
+using System;
+using System.Runtime.InteropServices;
+using System.Security.Policy;
+using System.Windows;
+using System.Windows.Interop;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+
+namespace SLBr.Controls
+{
+ ///
+ /// Interaction logic for PopupBrowser.xaml
+ ///
+ public partial class PopupBrowser : Window
+ {
+ [DllImport("dwmapi.dll", PreserveSig = true)]
+ public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
+
+ ChromiumWebBrowser _Browser;
+ Theme CurrentTheme;
+ string InitialAddress;
+ public PopupBrowser(string _Address, int _Width, int _Height)
+ {
+ InitializeComponent();
+ InitialAddress = _Address;
+ if (_Width != -1)
+ Width = _Width;
+ if (_Height != -1)
+ Height = _Height;
+ }
+
+ private void Browser_StatusMessage(object? sender, StatusMessageEventArgs e)
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ //StatusBar.Visibility = string.IsNullOrEmpty(e.Value) ? Visibility.Collapsed : Visibility.Visible;
+ StatusBarPopup.IsOpen = !string.IsNullOrEmpty(e.Value);
+ StatusMessage.Text = e.Value;
+ }));
+ }
+
+ private void Browser_LoadingStateChanged(object? sender, LoadingStateChangedEventArgs e)
+ {
+ if (!_Browser.IsBrowserInitialized)
+ return;
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ Icon = new BitmapImage(new Uri("https://www.google.com/s2/favicons?sz=24&domain=" + Utils.Host(_Browser.Address)));
+ DevToolsClient _DevToolsClient = _Browser.GetDevToolsClient();
+ _DevToolsClient.Emulation.SetAutoDarkModeOverrideAsync(CurrentTheme.DarkWebPage ? bool.Parse(MainWindow.Instance.MainSave.Get("DarkWebPage")) : false);
+ }));
+ }
+
+ public void ApplyTheme(Theme _Theme)
+ {
+ CurrentTheme = _Theme;
+ int SetDarkTitleBar = _Theme.DarkTitleBar ? 1 : 0;
+ DwmSetWindowAttribute(new WindowInteropHelper(this).Handle, (int)DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, ref SetDarkTitleBar, Marshal.SizeOf(true));
+
+ //Resources["PrimaryBrush"] = new SolidColorBrush(_Theme.PrimaryColor);
+ //Resources["FontBrush"] = new SolidColorBrush(_Theme.FontColor);
+ //Resources["BorderBrush"] = new SolidColorBrush(_Theme.BorderColor);
+ //Resources["UnselectedTabBrush"] = new SolidColorBrush(_Theme.UnselectedTabColor);
+ //Resources["ControlFontBrush"] = new SolidColorBrush(_Theme.ControlFontColor);
+
+ Resources["PrimaryBrushColor"] = _Theme.PrimaryColor;
+ Resources["FontBrushColor"] = _Theme.FontColor;
+ Resources["BorderBrushColor"] = _Theme.BorderColor;
+ Resources["UnselectedTabBrushColor"] = _Theme.UnselectedTabColor;
+ Resources["ControlFontBrushColor"] = _Theme.ControlFontColor;
+ }
+
+ private void Browser_TitleChanged(object sender, DependencyPropertyChangedEventArgs e)
+ {
+ Title = $"{e.NewValue} - SLBr";
+ }
+
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ ApplyTheme(MainWindow.Instance.GetTheme());
+ _Browser = new ChromiumWebBrowser();
+ _Browser.Address = InitialAddress;
+
+ _Browser.LifeSpanHandler = MainWindow.Instance._LifeSpanHandler;
+ _Browser.DownloadHandler = MainWindow.Instance._DownloadHandler;
+ _Browser.RequestHandler = MainWindow.Instance._RequestHandler;
+ //_Browser.MenuHandler = MainWindow.Instance._ContextMenuHandler;
+ //_Browser.KeyboardHandler = MainWindow.Instance._KeyboardHandler;
+ //_Browser.JsDialogHandler = MainWindow.Instance._JsDialogHandler;
+
+ _Browser.TitleChanged += Browser_TitleChanged;
+ _Browser.LoadingStateChanged += Browser_LoadingStateChanged;
+ _Browser.ZoomLevelIncrement = 0.5f;
+ _Browser.StatusMessage += Browser_StatusMessage;
+ _Browser.AllowDrop = true;
+ _Browser.IsManipulationEnabled = true;
+
+ _Browser.BrowserSettings = new BrowserSettings
+ {
+ WindowlessFrameRate = MainWindow.Instance.Framerate,
+ Javascript = MainWindow.Instance.Javascript,
+ ImageLoading = MainWindow.Instance.LoadImages,
+ LocalStorage = MainWindow.Instance.LocalStorage,
+ Databases = MainWindow.Instance.Databases,
+ WebGl = MainWindow.Instance.WebGL,
+ BackgroundColor = System.Drawing.Color.Black.ToUInt()
+ };
+
+ WebContent.Children.Add(_Browser);
+ RenderOptions.SetBitmapScalingMode(_Browser, BitmapScalingMode.LowQuality);
+ }
+ }
+}
diff --git a/SLBr/Controls/ToastBox.xaml b/SLBr/Controls/ToastBox.xaml
index bb92123..45ed9e9 100644
--- a/SLBr/Controls/ToastBox.xaml
+++ b/SLBr/Controls/ToastBox.xaml
@@ -5,12 +5,12 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SLBr.Controls"
mc:Ignorable="d"
- Title="Notification Popup" Height="90" Width="300" SizeToContent="Height" WindowStyle="None" ResizeMode="NoResize" Topmost="True" AllowsTransparency="True" Background="Transparent" ShowInTaskbar="False">
+ Title="Notification Popup" HorizontalAlignment="Right" VerticalAlignment="Bottom" Height="90" Width="300" SizeToContent="Height" WindowStyle="None" AllowsTransparency="True" ResizeMode="NoResize" Topmost="True" Background="Transparent" ShowInTaskbar="False">
-
+
diff --git a/SLBr/Controls/ToastBox.xaml.cs b/SLBr/Controls/ToastBox.xaml.cs
index 706f47d..c45e915 100644
--- a/SLBr/Controls/ToastBox.xaml.cs
+++ b/SLBr/Controls/ToastBox.xaml.cs
@@ -1,4 +1,5 @@
-using System;
+using Microsoft.VisualBasic;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -8,6 +9,7 @@
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
+using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
@@ -41,20 +43,35 @@ public ToastBox(string _Title, string _Description, int Delay, Theme _Theme = nu
Description.Text = _Description;
timer.Interval = new TimeSpan(0, 0, Delay);
timer.Start();
- var desktopWorkingArea = SystemParameters.WorkArea;
- Left = desktopWorkingArea.Right - this.Width;
- Top = desktopWorkingArea.Bottom - this.Height;
+ var Monitor = MonitorMethods.MonitorFromWindow(new WindowInteropHelper(MainWindow.Instance).EnsureHandle(), MonitorMethods.MONITOR_DEFAULTTONEAREST);
+
+ if (Monitor != IntPtr.Zero)
+ {
+ var MonitorInfo = new MonitorMethods.NativeMonitorInfo();
+ MonitorMethods.GetMonitorInfo(Monitor, MonitorInfo);
+ //var desktopWorkingArea = SystemParameters.WorkArea;
+ var desktopWorkingArea = MonitorInfo.Monitor;
+ Left = desktopWorkingArea.Right - this.Width - 2.5;
+ Top = desktopWorkingArea.Bottom - this.Height - 37.5;// + 10
+ }
+
if (_Theme == null)
_Theme = MainWindow.Instance.GetTheme();
ApplyTheme(_Theme);
}
public void ApplyTheme(Theme _Theme)
{
- Resources["PrimaryBrush"] = new SolidColorBrush(_Theme.PrimaryColor);
- Resources["FontBrush"] = new SolidColorBrush(_Theme.FontColor);
- Resources["BorderBrush"] = new SolidColorBrush(_Theme.BorderColor);
- Resources["UnselectedTabBrush"] = new SolidColorBrush(_Theme.UnselectedTabColor);
- Resources["ControlFontBrush"] = new SolidColorBrush(_Theme.ControlFontColor);
+ //Resources["PrimaryBrush"] = new SolidColorBrush(_Theme.PrimaryColor);
+ //Resources["FontBrush"] = new SolidColorBrush(_Theme.FontColor);
+ //Resources["BorderBrush"] = new SolidColorBrush(_Theme.BorderColor);
+ //Resources["UnselectedTabBrush"] = new SolidColorBrush(_Theme.UnselectedTabColor);
+ //Resources["ControlFontBrush"] = new SolidColorBrush(_Theme.ControlFontColor);
+
+ Resources["PrimaryBrushColor"] = _Theme.PrimaryColor;
+ Resources["FontBrushColor"] = _Theme.FontColor;
+ Resources["BorderBrushColor"] = _Theme.BorderColor;
+ Resources["UnselectedTabBrushColor"] = _Theme.UnselectedTabColor;
+ Resources["ControlFontBrushColor"] = _Theme.ControlFontColor;
}
private void ToastClose_Click(object sender, RoutedEventArgs e)
{
diff --git a/SLBr/Converters/ColorToSolidConverter.cs b/SLBr/Converters/ColorToSolidConverter.cs
new file mode 100644
index 0000000..115eca5
--- /dev/null
+++ b/SLBr/Converters/ColorToSolidConverter.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Windows.Data;
+using System.Windows.Media;
+
+namespace SLBr.Converters
+{
+ public class ColorToSolidConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ if (value == null)
+ return null;
+
+ if (value is Color)
+ return new SolidColorBrush((Color)value);
+
+ throw new InvalidOperationException("Unsupported type [" + value.GetType().Name + "], ColorToSolidConverter.Convert()");
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ if (value == null)
+ return null;
+
+ if (value is SolidColorBrush)
+ return ((SolidColorBrush)value).Color;
+
+ throw new InvalidOperationException("Unsupported type [" + value.GetType().Name + "], ColorToSolidConverter.ConvertBack()");
+ }
+
+ }
+}
diff --git a/SLBr/Converters/SolidToColorConverter.cs b/SLBr/Converters/SolidToColorConverter.cs
new file mode 100644
index 0000000..ae71d29
--- /dev/null
+++ b/SLBr/Converters/SolidToColorConverter.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+using System.Windows.Media;
+
+namespace SLBr.Converters
+{
+ public class SolidToColorConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ if (value == null)
+ return null;
+
+ if (value is SolidColorBrush)
+ return ((SolidColorBrush)value).Color;
+
+ throw new InvalidOperationException("Unsupported type [" + value.GetType().Name + "], SolidToColorConverter.ConvertBack()");
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ if (value == null)
+ return null;
+
+ if (value is Color)
+ return new SolidColorBrush((Color)value);
+
+ throw new InvalidOperationException("Unsupported type [" + value.GetType().Name + "], SolidToColorConverter.Convert()");
+ }
+ }
+}
diff --git a/SLBr/Handlers/AudioHandler.cs b/SLBr/Handlers/AudioHandler.cs
new file mode 100644
index 0000000..9d690df
--- /dev/null
+++ b/SLBr/Handlers/AudioHandler.cs
@@ -0,0 +1,85 @@
+using CefSharp;
+using CefSharp.Enums;
+using CefSharp.Structs;
+using SLBr.Controls;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Shapes;
+
+namespace SLBr.Handlers
+{
+ public class AudioHandler : IAudioHandler
+ {
+ private bool isDisposed;
+
+ public bool IsDisposed
+ {
+ get { return isDisposed; }
+ }
+
+ bool IAudioHandler.GetAudioParameters(IWebBrowser chromiumWebBrowser, IBrowser browser, ref AudioParameters parameters)
+ {
+ return GetAudioParameters(chromiumWebBrowser, browser, ref parameters);
+ }
+
+ protected virtual bool GetAudioParameters(IWebBrowser chromiumWebBrowser, IBrowser browser, ref AudioParameters parameters)
+ {
+ return false;
+ }
+ void IAudioHandler.OnAudioStreamStarted(IWebBrowser chromiumWebBrowser, IBrowser browser, AudioParameters parameters, int channels)
+ {
+ OnAudioStreamStarted(chromiumWebBrowser, browser, parameters, channels);
+ }
+
+ protected virtual void OnAudioStreamStarted(IWebBrowser chromiumWebBrowser, IBrowser browser, AudioParameters parameters, int channels)
+ {
+ AudioPlaying = true;
+ MessageBox.Show(AudioPlaying.ToString());
+ }
+
+ void IAudioHandler.OnAudioStreamPacket(IWebBrowser chromiumWebBrowser, IBrowser browser, IntPtr data, int noOfFrames, long pts)
+ {
+ OnAudioStreamPacket(chromiumWebBrowser, browser, data, noOfFrames, pts);
+ }
+
+ protected virtual void OnAudioStreamPacket(IWebBrowser chromiumWebBrowser, IBrowser browser, IntPtr data, int noOfFrames, long pts)
+ {
+ }
+
+ void IAudioHandler.OnAudioStreamStopped(IWebBrowser chromiumWebBrowser, IBrowser browser)
+ {
+ OnAudioStreamStopped(chromiumWebBrowser, browser);
+ }
+ protected virtual void OnAudioStreamStopped(IWebBrowser chromiumWebBrowser, IBrowser browser)
+ {
+ AudioPlaying = false;
+ MessageBox.Show(AudioPlaying.ToString());
+ }
+
+ void IAudioHandler.OnAudioStreamError(IWebBrowser chromiumWebBrowser, IBrowser browser, string errorMessage)
+ {
+ OnAudioStreamError(chromiumWebBrowser, browser, errorMessage);
+ }
+
+ protected virtual void OnAudioStreamError(IWebBrowser chromiumWebBrowser, IBrowser browser, string errorMessage)
+ {
+
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ isDisposed = true;
+ }
+ public void Dispose()
+ {
+ Dispose(disposing: true);
+ GC.SuppressFinalize(this);
+ }
+ public bool AudioPlaying;
+ }
+}
diff --git a/SLBr/Handlers/DisplayHandler.cs b/SLBr/Handlers/DisplayHandler.cs
index 0491fa8..eaa4b49 100644
--- a/SLBr/Handlers/DisplayHandler.cs
+++ b/SLBr/Handlers/DisplayHandler.cs
@@ -4,10 +4,14 @@
using SLBr.Pages;
using System;
using System.Collections.Generic;
+using System.Drawing;
+using System.IO;
using System.Linq;
+using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
+using System.Windows.Media.Imaging;
namespace SLBr.Handlers
{
@@ -19,7 +23,6 @@ public DisplayHandler(Browser BrowserView)
_BrowserView = BrowserView;
}
- //Setter HideTabSetter = new Setter(UIElement.VisibilityProperty, Visibility.Collapsed);
public void OnAddressChanged(IWebBrowser chromiumWebBrowser, AddressChangedEventArgs addressChangedArgs)
{
Application.Current.Dispatcher.BeginInvoke(new Action(delegate
@@ -28,7 +31,10 @@ public void OnAddressChanged(IWebBrowser chromiumWebBrowser, AddressChangedEvent
if (_BrowserView.AddressBox.Text != OutputUrl)
{
if (_BrowserView.CanChangeAddressBox())
+ {
_BrowserView.AddressBox.Text = OutputUrl;
+ _BrowserView.AddressBoxPlaceholder.Text = "";
+ }
_BrowserView.AddressBox.Tag = addressChangedArgs.Address;
}
}));
@@ -51,6 +57,13 @@ public bool OnCursorChange(IWebBrowser chromiumWebBrowser, IBrowser browser, Int
public void OnFaviconUrlChange(IWebBrowser chromiumWebBrowser, IBrowser browser, IList urls)
{
+ /*Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ foreach (string x in urls)
+ {
+ _BrowserView.Tab.Icon = new BitmapImage(new Uri(x));
+ }
+ }));*/
}
public void OnFullscreenModeChange(IWebBrowser chromiumWebBrowser, IBrowser browser, bool fullscreen)
diff --git a/SLBr/Handlers/DownloadHandler.cs b/SLBr/Handlers/DownloadHandler.cs
index 96dbe14..b9e0190 100644
--- a/SLBr/Handlers/DownloadHandler.cs
+++ b/SLBr/Handlers/DownloadHandler.cs
@@ -38,8 +38,11 @@ public void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser,
//OnDownloadUpdatedFired?.Invoke(this, downloadItem);
MainWindow.Instance.UpdateDownloadItem(downloadItem);
- if (downloadItem.IsInProgress && MainWindow.Instance.CanceledDownloads.Contains(downloadItem.Id))
- callback.Cancel();
+ if (downloadItem.IsInProgress)
+ {
+ if (MainWindow.Instance.CanceledDownloads.Contains(downloadItem.Id))
+ callback.Cancel();
+ }
}
}
}
diff --git a/SLBr/Handlers/LifeSpanHandler.cs b/SLBr/Handlers/LifeSpanHandler.cs
index 5ef0c2c..9c314de 100644
--- a/SLBr/Handlers/LifeSpanHandler.cs
+++ b/SLBr/Handlers/LifeSpanHandler.cs
@@ -1,4 +1,5 @@
using CefSharp;
+using SLBr.Controls;
using System;
using System.Windows;
@@ -10,11 +11,21 @@ public bool OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame f
WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo,
IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
{
+ int _Width = popupFeatures.Width != null ? (int)popupFeatures.Width : 600;
+ int _Height = popupFeatures.Height != null ? (int)popupFeatures.Height : 650;
newBrowser = null;
- Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ if (targetDisposition == WindowOpenDisposition.CurrentTab)
+ browser.MainFrame.LoadUrl(targetUrl);
+ else
{
- MainWindow.Instance.NewBrowserTab(targetUrl, 0, true, MainWindow.Instance.BrowserTabs.SelectedIndex + 1);
- }));
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ if (targetDisposition == WindowOpenDisposition.NewPopup)
+ new PopupBrowser(targetUrl, _Width, _Height).Show();
+ else
+ MainWindow.Instance.NewBrowserTab(targetUrl, 0, true, MainWindow.Instance.BrowserTabs.SelectedIndex + 1);
+ }));
+ }
return true;
}
diff --git a/SLBr/Handlers/PrivateJsObjectHandler.cs b/SLBr/Handlers/PrivateJsObjectHandler.cs
index 93caaf8..b2a0ef0 100644
--- a/SLBr/Handlers/PrivateJsObjectHandler.cs
+++ b/SLBr/Handlers/PrivateJsObjectHandler.cs
@@ -8,7 +8,7 @@ namespace SLBr.Handlers
{
public class PrivateJsObjectHandler
{
- List UnsplashAPI = new List { //"https://picsum.photos/1920/1080",
+ List UnsplashAPI = new List {
//"https://source.unsplash.com/1920x1080/?space",
"https://source.unsplash.com/1920x1080/?nasa",
"https://source.unsplash.com/1920x1080/?mountain-range",
@@ -40,6 +40,8 @@ public string GetBackground()
doc.LoadXml(MainWindow.Instance.TinyDownloader.DownloadString("http://www.bing.com/hpimagearchive.aspx?format=xml&idx=0&n=1&mbl=1&mkt=en-US"));
Url = @"http://www.bing.com/" + doc.SelectSingleNode(@"/images/image/url").InnerText;
}
+ else if (BackgroundImage == "Lorem Picsum")
+ Url = "https://picsum.photos/1920/1080";
else if (BackgroundImage == "Custom")
Url = MainWindow.Instance.MainSave.Get("CustomBackgroundImage");
}
diff --git a/SLBr/Handlers/RequestHandler.cs b/SLBr/Handlers/RequestHandler.cs
index 911e856..6e1463b 100644
--- a/SLBr/Handlers/RequestHandler.cs
+++ b/SLBr/Handlers/RequestHandler.cs
@@ -1,5 +1,6 @@
using CefSharp;
using CefSharp.Wpf.HwndHost;
+using SLBr.Controls;
using SLBr.Pages;
using System;
using System.Security.Cryptography.X509Certificates;
@@ -17,8 +18,31 @@ public class RequestHandler : IRequestHandler
public bool GetAuthCredentials(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
{
- //callback.Continue(Username, Password);
- return false;
+ bool _Handled = false;
+
+ //Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ //{
+ CredentialsDialogResult _CredentialsDialogResult = CredentialsDialog.Show($@"Sign in to {host}");
+ if (_CredentialsDialogResult.Accepted == true)
+ {
+ callback.Continue(_CredentialsDialogResult.Username, _CredentialsDialogResult.Password);
+ _Handled = true;
+ }
+ //CredentialsDialogResult _CredentialsDialogResult = CredentialsDialog.Show($"Sign in to {host}");
+ //if (_CredentialsDialogResult.Accepted == true)
+ //{
+ // callback.Continue(_CredentialsDialogResult.Username, _CredentialsDialogResult.Password);
+ // _Handled = true;
+ //}
+ //}));
+ //MessageBoxResult dlg = MessageBox.Show("test", "e", MessageBoxButton.OK);
+
+ //if (dlg == MessageBoxResult.OK)
+ //{
+ // _Handled = true;
+ //}
+
+ return _Handled;
}
public bool OnBeforeBrowse(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool userGesture, bool isRedirect)
@@ -43,6 +67,9 @@ public bool OnBeforeBrowse(IWebBrowser chromiumWebBrowser, IBrowser browser, IFr
//if (request.Url.EndsWith(".pdf"))
// frame.LoadUrl(request.Url + "#toolbar=0");
}
+ //MessageBox.Show(request.Url);
+ else if (request.Url.StartsWith("chrome://sandbox"))
+ return true;
return false;
}
public bool OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
@@ -74,16 +101,20 @@ public bool OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string
public void OnRenderProcessTerminated(IWebBrowser browserControl, IBrowser browser, CefTerminationStatus status)
{
- if (Utils.CheckForInternetConnection())
- browser.Reload(true);
- else
+ try
{
- Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ if (Utils.CheckForInternetConnection())
+ browser.Reload(true);
+ else
{
- ChromiumWebBrowser _ChromiumWebBrowser = (ChromiumWebBrowser)browserControl;
- _ChromiumWebBrowser.Address = $"slbr://processcrashed?s={browserControl.Address}";
- }));
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ ChromiumWebBrowser _ChromiumWebBrowser = (ChromiumWebBrowser)browserControl;
+ _ChromiumWebBrowser.Address = $"slbr://processcrashed?s={browserControl.Address}";
+ }));
+ }
}
+ catch { }
}
public void OnRenderViewReady(IWebBrowser browserControl, IBrowser browser)
diff --git a/SLBr/Handlers/ResourceRequestHandler.cs b/SLBr/Handlers/ResourceRequestHandler.cs
index 1ead543..63faee2 100644
--- a/SLBr/Handlers/ResourceRequestHandler.cs
+++ b/SLBr/Handlers/ResourceRequestHandler.cs
@@ -1,9 +1,11 @@
using CefSharp;
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using static System.Net.WebRequestMethods;
namespace SLBr.Handlers
{
@@ -53,7 +55,7 @@ public IResponseFilter GetResourceResponseFilter(IWebBrowser chromiumWebBrowser,
"coin-hive.com", "coin-have.com", "adminer.com", "ad-miner.com", "coinminerz.com", "coinhive-manager.com", "coinhive.com", "prometheus.phoenixcoin.org", "coinhiveproxy.com", "jsecoin.com", "crypto-loot.com", "cryptonight.wasm", "cloudflare.solutions"
};//https://v.firebog.net/hosts/static/w3kbl.txt
FastHashSet Ads = new FastHashSet {
- "pagead2.googlesyndication.com", "tpc.googlesyndication.com", "googletagservices.com", "googletagmanager.com", "ade.googlesyndication.com", "pagead2.googleadservices.com", "adservice.google.com", "googleadservices.com",
+ "ads.google.com", "pagead2.googlesyndication.com", "tpc.googlesyndication.com", "googletagservices.com", "googletagmanager.com", "ade.googlesyndication.com", "pagead2.googleadservices.com", "adservice.google.com", "googleadservices.com",
"googleads2.g.doubleclick.net", "googleads3.g.doubleclick.net", "googleads4.g.doubleclick.net", "googleads5.g.doubleclick.net", "googleads6.g.doubleclick.net", "googleads7.g.doubleclick.net", "googleads8.g.doubleclick.net", "googleads9.g.doubleclick.net",
"doubleclick.net", "stats.g.doubleclick.net", "ad.doubleclick.net", "ads.doubleclick.net", "ad.mo.doubleclick.net", "ad-g.doubleclick.net", "cm.g.doubleclick.net", "static.doubleclick.net", "m.doubleclick.net", "mediavisor.doubleclick.net", "pubads.g.doubleclick.net", "securepubads.g.doubleclick.net", "www3.doubleclick.net",
"secure-ds.serving-sys.com", "s.innovid.com", "innovid.com", "dts.innovid.com",
@@ -61,7 +63,7 @@ public IResponseFilter GetResourceResponseFilter(IWebBrowser chromiumWebBrowser,
"gads.pubmatic.com", "ads.pubmatic.com",// "image6.pubmatic.com",
"ads.facebook.com", "an.facebook.com",
"ad.youtube.com", "ads.youtube.com", "youtube.cleverads.vn"/*, "yt3.ggpht.com"*/,
- "ads.tiktok.com", "ads-sg.tiktok.com",
+ "ads.tiktok.com", "ads-sg.tiktok.com", "ads.adthrive.com",
"ads.reddit.com", "d.reddit.com", "rereddit.com", "events.redditmedia.com",
"ads-twitter.com", "static.ads-twitter.com", "ads-api.twitter.com", "advertising.twitter.com",
"ads.pinterest.com", "ads-dev.pinterest.com",
@@ -69,7 +71,7 @@ public IResponseFilter GetResourceResponseFilter(IWebBrowser chromiumWebBrowser,
"ads.linkedin.com",
"static.media.net", "media.net", "adservetx.media.net",
"media.fastclick.net", "cdn.fastclick.net",
- "global.adserver.yahoo.com", "ads.yahoo.com", "ads.yap.yahoo.com",
+ "global.adserver.yahoo.com", "ads.yahoo.com", "ads.yap.yahoo.com", "adserver.yahoo.com",
"yandexadexchange.net", "adsdk.yandex.ru",
"files.adform.net",
"static.adsafeprotected.com", "pixel.adsafeprotected.com",
@@ -85,18 +87,20 @@ public IResponseFilter GetResourceResponseFilter(IWebBrowser chromiumWebBrowser,
"scdn.cxense.com",
"adserver.juicyads.com",
"a.realsrv.com", "mc.yandex.ru", "a.vdo.ai",
+ "ads.msn.com", "adnxs.com", "adnexus.net", "bingads.microsoft.com",
"dt.adsafeprotected.com",
- "z-na.amazon-adsystem.com", "aax-us-east.amazon-adsystem.com", "fls-na.amazon-adsystem.com", "z-na.amazon-adsystem.com",
+ "amazonaax.com", "z-na.amazon-adsystem.com", "aax-us-east.amazon-adsystem.com", "fls-na.amazon-adsystem.com", "z-na.amazon-adsystem.com",
"ads.betweendigital.com", "rtb.adpone.com", "ads.themoneytizer.com", "bidder.criteo.com", "bidder.criteo.com", "bidder.criteo.com",
"secure-assets.rubiconproject.com", "eus.rubiconproject.com", "fastlane.rubiconproject.com", "pixel.rubiconproject.com", "prebid-server.rubiconproject.com",
"ids.ad.gt", "powerad.ai", "hb.brainlyads.com", "pixel.quantserve.com", "ads.anura.io", "static.getclicky.com",
"ad.turn.com", "rtb.mfadsrvr.com", "ad.mrtnsvr.com", "s.ad.smaato.net", "rtb-csync.smartadserver.com", "ssbsync.smartadserver.com",
"adpush.technoratimedia.com", "pixel.tapad.com", "secure.adnxs.com", "data.adsrvr.org", "px.adhigh.net",
- "epnt.ebay.com", "pixel.moatads.com", "mb.moatads.com", "ad.adsrvr.org", "a.ad.gt", "pixels.ad.gt", "z.moatads.com", "px.moatads.com", "s.pubmine.com", "px.ads.linkedin.com", "p.adsymptotic.com",
+ "epnt.ebay.com", "yt.moatads.com", "pixel.moatads.com", "mb.moatads.com", "ad.adsrvr.org", "a.ad.gt", "pixels.ad.gt", "z.moatads.com", "px.moatads.com", "s.pubmine.com", "px.ads.linkedin.com", "p.adsymptotic.com",
"btloader.com", "ad-delivery.net",
- "services.vlitag.com", "tag.vlitag.com", "assets.vlitag.com"
+ "services.vlitag.com", "tag.vlitag.com", "assets.vlitag.com",
+ "adserver.snapads.com", "euw.adserver.snapads.com", "euc.adserver.snapads.com", "usc.adserver.snapads.com", "ase.adserver.snapads.com"
};
- FastHashSet Analytics = new FastHashSet { "www-google-analytics.l.google.com", "www-googletagmanager.l.google.com", "analytic-google.com", "google-analytics.com", "ssl.google-analytics.com",
+ FastHashSet Analytics = new FastHashSet { "ssl-google-analytics.l.google.com", "www-google-analytics.l.google.com", "www-googletagmanager.l.google.com", "analytic-google.com", "google-analytics.com", "ssl.google-analytics.com",
"stats.wp.com",
"analytics.facebook.com", "pixel.facebook.com",
"analytics.tiktok.com", "analytics-sg.tiktok.com",
@@ -111,6 +115,8 @@ public IResponseFilter GetResourceResponseFilter(IWebBrowser chromiumWebBrowser,
"freshmarketer.com",
"notify.bugsnag.com", "sessions.bugsnag.com", "api.bugsnag.com", "app.bugsnag.com",
"browser.sentry-cdn.com", "app.getsentry.com",
+ "stats.gc.apple.com", "iadsdk.apple.com", "crashlogs.whatsapp.net",
+ "tr.snapchat.com", "sc-analytics.appspot.com", "app-analytics.snapchat.com",
"luckyorange.com", "cdn.luckyorange.com", "w1.luckyorange.com", "upload.luckyorange.net", "cs.luckyorange.net", "settings.luckyorange.net",
@@ -124,6 +130,7 @@ public IResponseFilter GetResourceResponseFilter(IWebBrowser chromiumWebBrowser,
"tracking.india.miui.com",
"tracking.rus.miui.com",
+ "metrics.data.hicloud.com",
"metrics1.data.hicloud.com",
"metrics5.data.hicloud.com",
"logservice.hicloud.com",
@@ -144,17 +151,10 @@ public IResponseFilter GetResourceResponseFilter(IWebBrowser chromiumWebBrowser,
};
public CefReturnValue OnBeforeResourceLoad(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
- var headers = request.Headers;
- //Filter Lists
+ //request.SetHeaderByName("DNT", "1", true);
+ request.SetHeaderByName("Save-Data", "on", true);
+ //request.SetHeaderByName("Device-Memory", "0.25", true);
bool Continue = true;
- //if (bool.Parse(MainWindow.Instance.MainSave.Get("LiteMode")))
- //{
- //headers["Save-Data"] = "on";
- headers.Add("Save-Data", "on");
- headers.Add("Device-Memory", "0.25");
- //headers["Device-Memory"] = "0.25";
- //}
-
if (Utils.IsPossiblyAd(request.ResourceType))
{
if (AdBlock || TrackerBlock)
@@ -189,7 +189,6 @@ public CefReturnValue OnBeforeResourceLoad(IWebBrowser chromiumWebBrowser, IBrow
}
}
}
- request.Headers = headers;
return Continue ? CefReturnValue.Continue : CefReturnValue.Cancel;
}
diff --git a/SLBr/MainWindow.xaml b/SLBr/MainWindow.xaml
index 67da476..44856aa 100644
--- a/SLBr/MainWindow.xaml
+++ b/SLBr/MainWindow.xaml
@@ -5,12 +5,16 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SLBr" xmlns:controls="clr-namespace:SLBr.Controls"
mc:Ignorable="d"
- Title="SLBr" Loaded="Window_Loaded" WindowStartupLocation="CenterScreen" WindowState="Maximized" Height="450" Width="800" Closing="Window_Closing">
+ Title="SLBr" Loaded="Window_Loaded" StateChanged="Window_StateChanged" WindowStartupLocation="CenterScreen" WindowState="Maximized" Height="450" Width="800" Closing="Window_Closing">
+
+
+
+
-
+
diff --git a/SLBr/MainWindow.xaml.cs b/SLBr/MainWindow.xaml.cs
index e97e871..6c02be3 100644
--- a/SLBr/MainWindow.xaml.cs
+++ b/SLBr/MainWindow.xaml.cs
@@ -24,6 +24,9 @@
using CefSharp.SchemeHandler;
using Microsoft.Win32;
using System.Collections.Specialized;
+using System.Windows.Media.Animation;
+using System.Threading;
+using System.Threading.Tasks;
namespace SLBr
{
@@ -50,7 +53,7 @@ public string Header
RaisePropertyChanged("Header");
}
}
- public string _Header;
+ private string _Header;
public BitmapImage Icon
{
get { return _Icon; }
@@ -60,14 +63,34 @@ public BitmapImage Icon
RaisePropertyChanged("Icon");
}
}
- public BitmapImage _Icon;
+ private BitmapImage _Icon;
+ public string Action
+ {
+ get { return _Action; }
+ set
+ {
+ _Action = value;
+ RaisePropertyChanged("Action");
+ }
+ }
+ private string _Action;
public UserControl Content { get; set; }
+ public int Id
+ {
+ get { return _Id; }
+ set
+ {
+ _Id = value;
+ RaisePropertyChanged("Id");
+ }
+ }
+ private int _Id;
}
public partial class MainWindow : Window, INotifyPropertyChanged
{
[DllImport("dwmapi.dll", PreserveSig = true)]
- public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref bool attrValue, int attrSize);
+ public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
[DllImport("shell32.dll", SetLastError = true)]
static extern void SetCurrentProcessExplicitAppUserModelID([MarshalAs(UnmanagedType.LPWStr)] string AppID);
@@ -86,7 +109,7 @@ public partial class MainWindow : Window, INotifyPropertyChanged
"https://search.yahoo.com/search?p={0}",
"https://yandex.com/search/?text={0}",*/
};
- public List SearchEngines;
+ public List SearchEngines = new List();
List Themes = new List();
public Saving GlobalSave;
@@ -123,7 +146,7 @@ public partial class MainWindow : Window, INotifyPropertyChanged
public int AdsBlocked;
bool IsFullscreen;
string[] Args;
- public string ReleaseVersion = "2022.9.5.0";
+ public string ReleaseVersion;
public event PropertyChangedEventHandler PropertyChanged = delegate { };
private void RaisePropertyChanged(string Name)
@@ -171,6 +194,13 @@ public Dictionary Downloads
public void UpdateDownloadItem(DownloadItem item)
{
Downloads[item.Id] = item;
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ {
+ if (item.IsComplete)
+ TaskbarProgress.ProgressValue = 0;
+ else
+ TaskbarProgress.ProgressValue = (double)item.PercentComplete / 100.0;
+ }));
}
HashSet HardwareUnavailableProcessors = new HashSet
{
@@ -185,17 +215,17 @@ public void SetRenderMode(string Mode, bool Notify)
if (Mode == "Hardware")
{
RenderOptions.ProcessRenderMode = RenderMode.Default;
- /*if (Notify)
- {
- var ProcessorID = Utils.GetProcessorID();
- foreach (string Processor in HardwareUnavailableProcessors)
- {
- if (ProcessorID.Contains(Processor))
- {
- Prompt(false, NoHardwareAvailableMessage.Replace("{0}", Processor), false, "", "", "", true, "\xE7BA");
- }
- }
- }*/
+ //if (Notify)
+ //{
+ // var ProcessorID = Utils.GetProcessorID();
+ // foreach (string Processor in HardwareUnavailableProcessors)
+ // {
+ // if (ProcessorID.Contains(Processor))
+ // {
+ // Prompt(false, NoHardwareAvailableMessage.Replace("{0}", Processor), false, "", "", "", true, "\xE7BA");
+ // }
+ // }
+ //}
}
else if (Mode == "Software")
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
@@ -205,10 +235,18 @@ public void SetRenderMode(string Mode, bool Notify)
#region Initialize
private void SetIEEmulation(uint Value = 11001)
{
- using (var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true))
+ SplashScreen.Instance.ReportProgress(16, "Modifying IE Emulation...");
+ try
{
- if (key.GetValue("SLBr.exe") == null)
- key.SetValue("SLBr.exe", Value, RegistryValueKind.DWord);
+ using (var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", true))
+ {
+ if (key.GetValue("SLBr.exe") == null)
+ key.SetValue("SLBr.exe", Value, RegistryValueKind.DWord);
+ }
+ }
+ catch
+ {
+ SplashScreen.Instance.ReportProgress(17, "Failed.");
}
}
private void SetFeatureControlKey(string Feature, uint Value)
@@ -220,6 +258,7 @@ private void SetFeatureControlKey(string Feature, uint Value)
}
private void InitializeIE()
{
+ SplashScreen.Instance.ReportProgress(15, "Initializing Internet Explorer features...");
SetIEEmulation();
/*SetFeatureControlKey("FEATURE_BROWSER_EMULATION", 11001); // Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
SetFeatureControlKey("FEATURE_GPU_RENDERING", 1);
@@ -252,6 +291,7 @@ private void InitializeIE()
}
private void InitializeSaves()
{
+ SplashScreen.Instance.ReportProgress(29, "Fetching data...");
GlobalSave = new Saving("GlobalSave.bin", GlobalApplicationDataPath);
MainSave = new Saving("Save.bin", UserApplicationDataPath);
FavouritesSave = new Saving("Favourites.bin", UserApplicationDataPath);
@@ -262,10 +302,12 @@ private void InitializeSaves()
ExperimentsSave = new Saving("Experiments.bin", UserApplicationDataPath);
IESave = new Saving("InternetExplorer.bin", UserApplicationDataPath);
+ SplashScreen.Instance.ReportProgress(30, "Processing data...");
if (SearchSave.Has("Search_Engine_Count"))
{
- SearchEngines = new List();
- Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ if (int.Parse(SearchSave.Get("Search_Engine_Count")) == 0)
+ SearchEngines = new List(DefaultSearchEngines);
+ else
{
for (int i = 0; i < int.Parse(SearchSave.Get("Search_Engine_Count")); i++)
{
@@ -273,7 +315,7 @@ private void InitializeSaves()
if (!SearchEngines.Contains(Url))
SearchEngines.Add(Url);
}
- }));
+ }
}
else
SearchEngines = new List(DefaultSearchEngines);
@@ -317,6 +359,9 @@ private void InitializeSaves()
if (!MainSave.Has("WebNotifications"))
MainSave.Set("WebNotifications", true);
+ if (!MainSave.Has("ScreenshotFormat"))
+ MainSave.Set("ScreenshotFormat", "Jpeg");
+
if (!IESave.Has("IESuppressErrors"))
IESave.Set("IESuppressErrors", true);
@@ -344,10 +389,15 @@ private void InitializeSaves()
SandboxSave.Set("WebGL", true.ToString());
WebGL = bool.Parse(SandboxSave.Get("WebGL")).ToCefState();
+ if (!ExperimentsSave.Has("DeveloperMode"))
+ ExperimentsSave.Set("DeveloperMode", false);
+ //int renderingTier = RenderCapability.Tier >> 16;
if (!ExperimentsSave.Has("HardwareAcceleration"))
- ExperimentsSave.Set("HardwareAcceleration", true);
+ ExperimentsSave.Set("HardwareAcceleration", true);//renderingTier == 0
+ if (!ExperimentsSave.Has("ChromeRuntime"))
+ ExperimentsSave.Set("ChromeRuntime", false);
if (!ExperimentsSave.Has("LowEndDeviceMode"))
- ExperimentsSave.Set("LowEndDeviceMode", false);
+ ExperimentsSave.Set("LowEndDeviceMode", true);
if (!ExperimentsSave.Has("PDFViewerExtension"))
ExperimentsSave.Set("PDFViewerExtension", true);
if (!ExperimentsSave.Has("AutoplayUserGestureRequired"))
@@ -366,16 +416,21 @@ private void InitializeSaves()
if (!MainSave.Has("DarkWebPage"))
MainSave.Set("DarkWebPage", true);
-
if (!MainSave.Has("BackgroundImage"))
- MainSave.Set("BackgroundImage", "Unsplash");
+ MainSave.Set("BackgroundImage", "Lorem Picsum");
if (!MainSave.Has("CustomBackgroundImage"))
MainSave.Set("CustomBackgroundImage", "");
+
+ if (bool.Parse(ExperimentsSave.Get("DeveloperMode")))
+ DeveloperMode = true;
+
Themes.Add(new Theme("Light", Colors.White, Colors.Black, Colors.Gainsboro, Colors.WhiteSmoke, Colors.Gray));
Themes.Add(new Theme("Dark", (Color)ColorConverter.ConvertFromString("#202225"), Colors.White, (Color)ColorConverter.ConvertFromString("#36393F"), (Color)ColorConverter.ConvertFromString("#2F3136"), Colors.Gainsboro, true, true));
+ SplashScreen.Instance.ReportProgress(31, "Done.");
}
private void InitializeUISaves()
{
+ SplashScreen.Instance.ReportProgress(85, "Processing data...");
if (!MainSave.Has("AdBlock"))
AdBlock(true);
else
@@ -394,11 +449,17 @@ private void InitializeUISaves()
if (ProcessorID.Contains(Processor))
_RenderMode = "Software";
}
+ if (_RenderMode != "Software")
+ {
+ int renderingTier = RenderCapability.Tier >> 16;
+ _RenderMode = renderingTier == 0 ? "Software" : _RenderMode;
+ }
SetRenderMode(_RenderMode, false);
}
else
SetRenderMode(MainSave.Get("RenderMode"), true);
+ SplashScreen.Instance.ReportProgress(81, "Initializing UI...");
if (FavouritesSave.Has("Favourite_Count"))
{
Application.Current.Dispatcher.BeginInvoke(new Action(delegate
@@ -410,68 +471,97 @@ private void InitializeUISaves()
}
}));
}
- if (bool.Parse(MainSave.Get("RestoreTabs")) && TabsSave.Has("Tab_Count") && int.Parse(TabsSave.Get("Tab_Count")) > 0)
+ Application.Current.Dispatcher.BeginInvoke(new Action(delegate
{
- Application.Current.Dispatcher.BeginInvoke(new Action(delegate
+ if (bool.Parse(MainSave.Get("RestoreTabs")) && TabsSave.Has("Tab_Count") && int.Parse(TabsSave.Get("Tab_Count")) > 0)
{
int SelectedIndex = int.Parse(MainSave.Get("SelectedTabIndex"));
for (int i = 0; i < int.Parse(TabsSave.Get("Tab_Count")); i++)
{
string Url = TabsSave.Get($"Tab_{i}").Replace("slbr://processcrashed/?s=", "");
if (Url != "NOTFOUND")
- NewBrowserTab(Url, 0);
+ {
+ if (Url == "slbr://settings")
+ OpenSettings(false);
+ else
+ NewBrowserTab(Url, 0);
+ }
}
BrowserTabs.SelectedIndex = SelectedIndex;
- }));
- }
- else
- {
- NewTabUrl = MainSave.Get("Homepage");
- CreateTabForCommandLineUrl = true;
- }
- if (!MainSave.Has("UsedBefore"))
- {
- if (string.IsNullOrEmpty(NewTabUrl) || NewTabUrl == MainSave.Get("Homepage"))
+ }
+ else
{
- NewTabUrl = "https://github.com/SLT-World/SLBr";
+ if (string.IsNullOrEmpty(NewTabUrl))
+ NewTabUrl = MainSave.Get("Homepage");
CreateTabForCommandLineUrl = true;
}
- MainSave.Set("UsedBefore", true.ToString());
- }
- if (CreateTabForCommandLineUrl)
- NewBrowserTab(NewTabUrl, 0);
+ if (!MainSave.Has("UsedBefore"))
+ {
+ if (string.IsNullOrEmpty(NewTabUrl) || NewTabUrl == MainSave.Get("Homepage"))
+ {
+ NewTabUrl = "https://github.com/SLT-World/SLBr";
+ CreateTabForCommandLineUrl = true;
+ }
+ MainSave.Set("UsedBefore", true.ToString());
+ }
+ if (CreateTabForCommandLineUrl)
+ NewBrowserTab(NewTabUrl, 0, true);
+ }));
+ SplashScreen.Instance.ReportProgress(86, "Done.");
}
private void InitializeCEF()
{
+ SplashScreen.Instance.ReportProgress(43, "Initializing LifeSpan Handler...");
_LifeSpanHandler = new LifeSpanHandler();
+ SplashScreen.Instance.ReportProgress(44, "Initializing Download Handler...");
_DownloadHandler = new DownloadHandler();
+ SplashScreen.Instance.ReportProgress(45, "Initializing Request Handler...");
_RequestHandler = new RequestHandler();
+ SplashScreen.Instance.ReportProgress(46, "Initializing Menu Handler...");
_ContextMenuHandler = new ContextMenuHandler();
+ SplashScreen.Instance.ReportProgress(47, "Initializing Keyboard Handler...");
_KeyboardHandler = new KeyboardHandler();
+ SplashScreen.Instance.ReportProgress(48, "Initializing Javascript Dialog Handler...");
_JsDialogHandler = new JsDialogHandler();
+ SplashScreen.Instance.ReportProgress(49, "Initializing private Javascript Handler...");
_PrivateJsObjectHandler = new PrivateJsObjectHandler();
+ SplashScreen.Instance.ReportProgress(50, "Initializing public Javascript Handler...");
_PublicJsObjectHandler = new PublicJsObjectHandler();
+ SplashScreen.Instance.ReportProgress(51, "Initializing QR Code Handler.");
_QRCodeHandler = new QRCodeHandler();
+ SplashScreen.Instance.ReportProgress(52, "Done.");
+ SplashScreen.Instance.ReportProgress(54, "Applying keyboard shortcuts...");
_KeyboardHandler.AddKey(Screenshot, (int)Key.S, true);
_KeyboardHandler.AddKey(Refresh, (int)Key.F5);
_KeyboardHandler.AddKey(delegate () { Fullscreen(!IsFullscreen); }, (int)Key.F11);
_KeyboardHandler.AddKey(Inspect, (int)Key.F12);
_KeyboardHandler.AddKey(FindUI, (int)Key.F, true);
+ SplashScreen.Instance.ReportProgress(55, "Done.");
+ SplashScreen.Instance.ReportProgress(66, "Initializing SafeBrowsing API...");
_SafeBrowsing = new SafeBrowsing(Environment.GetEnvironmentVariable("GOOGLE_API_KEY"), Environment.GetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_ID"));
+ SplashScreen.Instance.ReportProgress(67, "Done.");
+ SplashScreen.Instance.ReportProgress(68, "Processing...");
CefSharpSettings.SubprocessExitIfParentProcessClosed = true;
CefSharpSettings.ShutdownOnExit = true;
CefSettings settings = new CefSettings();
+ //settings.EnablePrintPreview();
SetCEFFlags(settings);
- using (var currentProcess = Process.GetCurrentProcess())
- settings.BrowserSubprocessPath = currentProcess.MainModule.FileName;
+ if (File.Exists(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Utility Service.exe")))
+ settings.BrowserSubprocessPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Utility Service.exe");
+ //settings.BrowserSubprocessPath = "E:\\Visual Studio\\SLBr\\Utility Service\\bin\\Debug\\net6.0-windows\\Utility Service.exe";
+ else
+ settings.BrowserSubprocessPath = Process.GetCurrentProcess().MainModule.FileName;
+ //using (var currentProcess = Process.GetCurrentProcess())
+ //settings.BrowserSubprocessPath = currentProcess.MainModule.FileName;
//settings.BrowserSubprocessPath = Args[0];
- //settings.ChromeRuntime = true;
+ if (bool.Parse(ExperimentsSave.Get("ChromeRuntime")))
+ settings.ChromeRuntime = true;
- Cef.EnableHighDPISupport();
+ Cef.EnableHighDPISupport();
settings.Locale = "en-US";
settings.MultiThreadedMessageLoop = true;
@@ -483,6 +573,7 @@ private void InitializeCEF()
settings.RemoteDebuggingPort = 8089;
settings.UserDataPath = UserDataPath;
+ SplashScreen.Instance.ReportProgress(81, "Registering network protocols...");
settings.RegisterScheme(new CefCustomScheme
{
SchemeName = "gemini",
@@ -525,6 +616,7 @@ private void InitializeCEF()
new UrlScheme.Scheme { PageName = "Malware", FileName = "Malware.html" },
new UrlScheme.Scheme { PageName = "Deception", FileName = "Deception.html" },
new UrlScheme.Scheme { PageName = "ProcessCrashed", FileName = "ProcessCrashed.html" },
+ new UrlScheme.Scheme { PageName = "Tetris", FileName = "Tetris.html" },
}
};
string SLBrSchemeRootFolder = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), SLBrScheme.RootFolder);
@@ -545,11 +637,15 @@ private void InitializeCEF()
IsCorsEnabled = SLBrScheme.IsCorsEnabled
});
}
+ SplashScreen.Instance.ReportProgress(82, "Done.");
+ SplashScreen.Instance.ReportProgress(83, "Initializing Chromium...");
Cef.Initialize(settings);
+ SplashScreen.Instance.ReportProgress(84, "Chromium initialized.");
}
private void SetCEFFlags(CefSettings settings)
{
+ SplashScreen.Instance.ReportProgress(69, "Applying Chromium optimization features...");
SetDefaultFlags(settings);
SetBackgroundFlags(settings);
SetUIFlags(settings);
@@ -559,14 +655,13 @@ private void SetCEFFlags(CefSettings settings)
SetMediaFlags(settings);
SetFrameworkFlags(settings);
if (DeveloperMode)
- {
SetDeveloperFlags(settings);
- }
SetStreamingFlags(settings);
SetExtensionFlags(settings);
SetListedFlags(settings);
SetChromiumFlags(settings);
+ SplashScreen.Instance.ReportProgress(80, "Done.");
}
private void SetChromiumFlags(CefSettings settings)
{
@@ -600,7 +695,7 @@ private void SetDefaultFlags(CefSettings settings)
settings.CefCommandLineArgs.Add("enable-low-end-device-mode");
settings.CefCommandLineArgs.Add("media-cache-size", "262144000");
- settings.CefCommandLineArgs.Add("disk-cache-size", "104857600");
+ settings.CefCommandLineArgs.Add("disk-cache-size", "104857600");//104857600
if (bool.Parse(ExperimentsSave.Get("AutoplayUserGestureRequired")))
settings.CefCommandLineArgs.Add("autoplay-policy", "user-gesture-required");
@@ -609,6 +704,11 @@ private void SetDefaultFlags(CefSettings settings)
}
private void SetBackgroundFlags(CefSettings settings)
{
+ settings.CefCommandLineArgs.Add("enable-finch-seed-delta-compression");
+
+ settings.CefCommandLineArgs.Add("battery-saver-mode-available");
+ settings.CefCommandLineArgs.Add("high-efficiency-mode-available");
+
settings.CefCommandLineArgs.Add("enable-ipc-flooding-protection");
settings.CefCommandLineArgs.Add("disable-background-mode");
@@ -618,6 +718,7 @@ private void SetBackgroundFlags(CefSettings settings)
//https://bugs.chromium.org/p/chromium/issues/detail?id=153139
settings.CefCommandLineArgs.Add("disable-best-effort-tasks");
+ settings.CefCommandLineArgs.Add("aggressive-cache-discard");
settings.CefCommandLineArgs.Add("enable-simple-cache-backend");
settings.CefCommandLineArgs.Add("v8-cache-options");
settings.CefCommandLineArgs.Add("enable-font-cache-scaling");
@@ -632,9 +733,11 @@ private void SetBackgroundFlags(CefSettings settings)
settings.CefCommandLineArgs.Add("multi-threaded-message-loop");
settings.CefCommandLineArgs.Add("renderer-process-limit", "2");
+ //Failed to identify BrowserWrapper in OnContextCreated BrowserId:1
settings.CefCommandLineArgs.Remove("process-per-tab");
settings.CefCommandLineArgs.Add("process-per-site");
+ settings.CefCommandLineArgs.Add("enable-process-per-site");
settings.CefCommandLineArgs.Add("enable-tile-compression");
@@ -645,6 +748,7 @@ private void SetBackgroundFlags(CefSettings settings)
settings.CefCommandLineArgs.Add("quick-intensive-throttling-after-loading");
settings.CefCommandLineArgs.Add("expensive-background-timer-throttling");
settings.CefCommandLineArgs.Add("intensive-wake-up-throttling");
+ settings.CefCommandLineArgs.Add("align-wakeups");
settings.CefCommandLineArgs.Add("max-tiles-for-interest-area", "64");
settings.CefCommandLineArgs.Add("default-tile-width", "64");
@@ -655,10 +759,18 @@ private void SetBackgroundFlags(CefSettings settings)
settings.CefCommandLineArgs.Add("calculate-native-win-occlusion");
settings.CefCommandLineArgs.Add("enable-winrt-geolocation-implementation");
+
+ settings.CefCommandLineArgs.Add("disable-v8-idle-tasks");
+ settings.CefCommandLineArgs.Add("disable-mipmap-generation");
+
}
private void SetUIFlags(CefSettings settings)
{
- //settings.CefCommandLineArgs.Add("enable-print-preview");
+ settings.CefCommandLineArgs.Add("disable-pinch");
+
+ settings.CefCommandLineArgs.Add("deferred-font-shaping");
+ settings.CefCommandLineArgs.Add("enable-auto-disable-accessibility");
+ settings.CefCommandLineArgs.Add("enable-print-preview");
//settings.CefCommandLineArgs.Add("enable-pixel-canvas-recording");
settings.CefCommandLineArgs.Add("enable-draw-occlusion");
@@ -696,6 +808,7 @@ private void SetGPUFlags(CefSettings settings)
settings.CefCommandLineArgs.Add("ignore-gpu-blocklist");
settings.CefCommandLineArgs.Add("enable-gpu");
settings.CefCommandLineArgs.Add("enable-zero-copy");
+ //settings.CefCommandLineArgs.Add("disable-software-rasterizer");
settings.CefCommandLineArgs.Add("enable-gpu-rasterization");
//settings.CefCommandLineArgs.Add("gpu-rasterization-msaa-sample-count", "0");
settings.CefCommandLineArgs.Add("enable-native-gpu-memory-buffers");
@@ -708,6 +821,7 @@ private void SetGPUFlags(CefSettings settings)
settings.CefCommandLineArgs.Add("disable-direct-composition");
settings.CefCommandLineArgs.Add("disable-gpu-vsync");
settings.CefCommandLineArgs.Add("disable-gpu-shader-disk-cache");
+ settings.CefCommandLineArgs.Add("reduce-gpu-priority-on-background");
}
settings.CefCommandLineArgs.Add("enable-begin-frame-scheduling");
@@ -722,6 +836,8 @@ private void SetNetworkFlags(CefSettings settings)
settings.CefCommandLineArgs.Add("enable-brotli");
settings.CefCommandLineArgs.Add("no-proxy-server");
+ settings.CefCommandLineArgs.Add("no-proxy");
+ //settings.CefCommandLineArgs.Add("winhttp-proxy-resolver");
settings.CefCommandLineArgs.Add("no-pings");
settings.CefCommandLineArgs.Add("dns-over-https");
@@ -741,7 +857,7 @@ private void SetSecurityFlags(CefSettings settings)
settings.CefCommandLineArgs.Add("ignore-certificate-errors");
- settings.CefCommandLineArgs.Add("allow-universal-access-from-files");
+ //settings.CefCommandLineArgs.Add("allow-universal-access-from-files");
//settings.CefCommandLineArgs.Add("allow-file-access-from-files");
settings.CefCommandLineArgs.Add("enable-heavy-ad-intervention");
@@ -753,6 +869,8 @@ private void SetSecurityFlags(CefSettings settings)
}
private void SetMediaFlags(CefSettings settings)
{
+ settings.CefCommandLineArgs.Add("allow-file-access-from-files");
+ settings.CefCommandLineArgs.Add("allow-universal-access-from-files");
settings.CefCommandLineArgs.Add("enable-parallel-downloading");
settings.CefCommandLineArgs.Add("enable-jxl");
@@ -761,7 +879,6 @@ private void SetMediaFlags(CefSettings settings)
settings.CefCommandLineArgs.Add("disable-low-res-tiling");
settings.CefCommandLineArgs.Add("disable-background-video-track");
- settings.CefCommandLineArgs.Add("zero-copy-video-capture");
settings.CefCommandLineArgs.Add("enable-lite-video");
settings.CefCommandLineArgs.Add("lite-video-force-override-decision");
settings.CefCommandLineArgs.Add("enable-av1-decoder");
@@ -772,6 +889,13 @@ private void SetMediaFlags(CefSettings settings)
settings.CefCommandLineArgs.Add("d3d11-video-decoder");
settings.CefCommandLineArgs.Add("enable-accelerated-video-decode");
settings.CefCommandLineArgs.Add("enable-accelerated-mjpeg-decode");
+ settings.CefCommandLineArgs.Add("enable-vp9-kSVC-decode-acceleration");
+ settings.CefCommandLineArgs.Add("enable-vaapi-av1-decode-acceleration");
+ settings.CefCommandLineArgs.Add("enable-vaapi-jpeg-image-decode-acceleration");
+ settings.CefCommandLineArgs.Add("enable-vaapi-webp-image-decode-accelerationn");
+ settings.CefCommandLineArgs.Add("enable-vbr-encode-acceleration");
+ settings.CefCommandLineArgs.Add("zero-copy-tab-capture");
+ settings.CefCommandLineArgs.Add("zero-copy-video-capture");
}
else
{
@@ -784,9 +908,15 @@ private void SetMediaFlags(CefSettings settings)
settings.CefCommandLineArgs.Add("enable-lazy-frame-loading");
settings.CefCommandLineArgs.Add("subframe-shutdown-delay");
+
+ //settings.CefCommandLineArgs.Add("optimization-target-prediction");
+ //settings.CefCommandLineArgs.Add("optimization-guide-model-downloading");
+
+ settings.CefCommandLineArgs.Add("turn-off-streaming-media-caching-on-battery");
}
private void SetFrameworkFlags(CefSettings settings)
{
+ settings.CefCommandLineArgs.Add("use-angle", "opengl");
//settings.CefCommandLineArgs.Add("use-angle", "gl");
//settings.CefCommandLineArgs.Add("use-gl", "desktop");
@@ -812,15 +942,16 @@ private void SetFrameworkFlags(CefSettings settings)
}
private void SetDeveloperFlags(CefSettings settings)
{
+ settings.CefCommandLineArgs.Add("enable-experimental-extension-apis");
settings.CefCommandLineArgs.Add("enable-experimental-webassembly-features");
settings.CefCommandLineArgs.Add("enable-experimental-webassembly-stack-switching");
settings.CefCommandLineArgs.Add("enable-experimental-web-platform-features");
settings.CefCommandLineArgs.Add("enable-experimental-canvas-features");
settings.CefCommandLineArgs.Add("enable-javascript-harmony");
+ settings.CefCommandLineArgs.Add("enable-javascript-experimental-shared-memory");
settings.CefCommandLineArgs.Add("enable-future-v8-vm-features");
settings.CefCommandLineArgs.Add("enable-devtools-experiments");
//settings.CefCommandLineArgs.Add("web-share");
- settings.CefCommandLineArgs.Add("webui-branding-update");
//settings.CefCommandLineArgs.Add("enable-portals");
settings.CefCommandLineArgs.Add("enable-webgl-developer-extensions");
settings.CefCommandLineArgs.Add("webxr-incubations");
@@ -834,8 +965,8 @@ private void SetStreamingFlags(CefSettings settings)
settings.CefCommandLineArgs.Add("enable-media-stream");
settings.CefCommandLineArgs.Add("enable-media-session-service");
- settings.CefCommandLineArgs.Add("use-fake-device-for-media-stream");
- settings.CefCommandLineArgs.Add("use-fake-ui-for-media-stream");
+ //settings.CefCommandLineArgs.Add("use-fake-device-for-media-stream");
+ //settings.CefCommandLineArgs.Add("use-fake-ui-for-media-stream");
settings.CefCommandLineArgs.Add("enable-usermedia-screen-capturing");
settings.CefCommandLineArgs.Add("disable-rtc-smoothness-algorithm");
settings.CefCommandLineArgs.Add("enable-speech-input");
@@ -898,28 +1029,81 @@ private void SetListedFlags(CefSettings settings)
}
#endregion
+ bool Initialized;
+ int WPFFrameRate = 30;
string NewTabUrl = "";
bool CreateTabForCommandLineUrl;
- bool DeveloperMode;
- public MainWindow()
+ public bool DeveloperMode;
+ public string AppUserModelID = "{ab11da56-fbdf-4678-916e-67e165b21f30}";
+
+ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
- Instance = this;
- if (Username != "Default-User")
- SetCurrentProcessExplicitAppUserModelID("{ab11da56-fbdf-4678-916e-67e165b21f30_" + Username + "}");
+ if (msg == MessageHelper.WM_COPYDATA)
+ {
+ COPYDATASTRUCT _dataStruct = Marshal.PtrToStructure(lParam);
+ string _strMsg = Marshal.PtrToStringUni(_dataStruct.lpData, _dataStruct.cbData / 2);
+ NewBrowserTab(_strMsg, 0, true);
+ }
+ return IntPtr.Zero;
+ }
- string RegPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Resources", "SLBr.reg");
- /*if (Utils.IsAdministrator())
+ public BitmapImage GetIcon(string Url)
+ {
+ if (Utils.IsHttpScheme(Url))
+ {
+ string Host = Utils.CleanUrl(Url, true, true, true, false);
+ return new BitmapImage(new Uri("https://www.google.com/s2/favicons?sz=24&domain=" + Host));
+ }
+ /*else if (Url.StartsWith("slbr:"))
{
- string SLBrExecutablePath = Assembly.GetEntryAssembly().Location.Replace(".dll", ".exe");
- File.WriteAllText(RegPath, SLBrRegTemplate.Replace("{SLBr}", SLBrExecutablePath));
+ if (Url.Contains("tetris"))
+ {
+ return Utils.Utf32ToDrawingImage(0xE705).ToBitmapSource().ToBitmapImage();
+ }
}*/
+ return new BitmapImage(new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Resources", (CurrentTheme.DarkTitleBar ? "White Tab Icon.png" : "Black Tab Icon.png"))));
+ }
+
+ public MainWindow()
+ {
+ InitializeWindow();
+ }
+ private async void InitializeWindow()
+ {
+ Instance = this;
+ //ReleaseVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ToString();
+ ReleaseVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
+ SplashScreen.Instance.ReportProgress(0, "Processing...");
+ HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).EnsureHandle());
+ source.AddHook(new HwndSourceHook(WndProc));
Args = Environment.GetCommandLineArgs();
+ Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline), new FrameworkPropertyMetadata { DefaultValue = WPFFrameRate });
+
+ if (Username != "Default-User")
+ {
+ AppUserModelID = "{ab11da56-fbdf-4678-916e-67e165b21f30_" + Username + "}";
+ SetCurrentProcessExplicitAppUserModelID(AppUserModelID);
+ }
+ if (Args.Length > 1)
+ {
+ Process _otherInstance = Utils.GetAlreadyRunningInstance();
+ if (_otherInstance != null)
+ {
+ MessageHelper.SendDataMessage(_otherInstance, Args[1]);
+ Application.Current.Shutdown();
+ return;
+ }
+ }
+
+ //string RegPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Resources", "SLBr.reg");
+
if (Args.Length > 1)
{
foreach (string Flag in Args)
{
+ SplashScreen.Instance.ReportProgress(1, "Processing command line arguments...");
if (Args.ToList().IndexOf(Flag) == 0)
continue;
if (Flag == "--dev")
@@ -932,18 +1116,18 @@ public MainWindow()
{
if (Flag.StartsWith("--"))
continue;
- if (Directory.Exists(Flag) || File.Exists(Flag))
- NewTabUrl = "file:\\\\\\" + Args[1];
- else
- NewTabUrl = Flag;
+ //if (Directory.Exists(Flag) || File.Exists(Flag))
+ // NewTabUrl = "file:\\\\\\" + Args[1];
+ //else
+ NewTabUrl = Flag;
CreateTabForCommandLineUrl = true;
}
}
}
if (!DeveloperMode)
DeveloperMode = Debugger.IsAttached;
- if (!DeveloperMode)
- Application.Current.DispatcherUnhandledException += Window_DispatcherUnhandledException;
+ //if (!DeveloperMode)
+ Application.Current.DispatcherUnhandledException += Window_DispatcherUnhandledException;
GlobalApplicationDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SLBr");
UserApplicationDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SLBr", Username);
CachePath = Path.Combine(UserApplicationDataPath, "Cache");
@@ -951,7 +1135,8 @@ public MainWindow()
LogPath = Path.Combine(UserApplicationDataPath, "Errors.log");
ExecutablePath = Assembly.GetExecutingAssembly().Location.Replace(".dll", ".exe");
- // Set Google API keys, used for Geolocation requests sans GPS. See http://www.chromium.org/developers/how-tos/api-keys
+ SplashScreen.Instance.ReportProgress(2, "Registering client API keys...");
+ // Set Google API keys, used for Geolocation requests sans GPS. See http://www.chromium.org/developers/how-tos/api-keys
Environment.SetEnvironmentVariable("GOOGLE_API_KEY", SECRETS.GOOGLE_API_KEY);
//create cs file named SECRETS, add string variable GOOGLE_API_KEY with value of google api key
Environment.SetEnvironmentVariable("GOOGLE_DEFAULT_CLIENT_ID", SECRETS.GOOGLE_DEFAULT_CLIENT_ID);
@@ -961,89 +1146,107 @@ public MainWindow()
if (Utils.IsAdministrator())
{
- using (var key = Registry.ClassesRoot.CreateSubKey("SLBr", true))
- {
- key.SetValue(null, "SLBr");
- key.SetValue("AppUserModelId", "SLBr");
-
- RegistryKey ApplicationRegistry = key.CreateSubKey("Application", true);
- ApplicationRegistry.SetValue("AppUserModelId", "SLBr");
- ApplicationRegistry.SetValue("ApplicationIcon", $"{ExecutablePath},0");
- ApplicationRegistry.SetValue("ApplicationName", "SLBr");
- ApplicationRegistry.SetValue("ApplicationCompany", "SLT World");
- ApplicationRegistry.SetValue("ApplicationDescription", "Browse the web with a fast, lightweight web browser.");
- ApplicationRegistry.Close();
-
- RegistryKey IconRegistry = key.CreateSubKey("DefaultIcon", true);
- IconRegistry.SetValue(null, $"{ExecutablePath},0");
- ApplicationRegistry.Close();
-
- RegistryKey CommandRegistry = key.CreateSubKey("shell\\open\\command", true);
- CommandRegistry.SetValue(null, $"\"{ExecutablePath}\" \"%1\"");
- CommandRegistry.Close();
- }
- using (var key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Clients\\StartMenuInternet", true).CreateSubKey("SLBr", true))
+ SplashScreen.Instance.ReportProgress(3, "Registering application into registry...");
+ try
{
- if (key.GetValue(null) as string != "SLBr")
- key.SetValue(null, "SLBr");
-
- RegistryKey CapabilitiesRegistry = key.CreateSubKey("Capabilities", true);
- CapabilitiesRegistry.SetValue("ApplicationDescription", "SLBr is a open source browser that prioritizes a faster web");
- CapabilitiesRegistry.SetValue("ApplicationIcon", $"{ExecutablePath},0");
- CapabilitiesRegistry.SetValue("ApplicationName", $"SLBr");
- RegistryKey StartMenuRegistry = CapabilitiesRegistry.CreateSubKey("StartMenu", true);
- StartMenuRegistry.SetValue("StartMenuInternet", "SLBr");
- StartMenuRegistry.Close();
-
- RegistryKey FileAssociationsRegistry = CapabilitiesRegistry.CreateSubKey("FileAssociations", true);
- FileAssociationsRegistry.SetValue(".xhtml", "SLBr");
- FileAssociationsRegistry.SetValue(".xht", "SLBr");
- FileAssociationsRegistry.SetValue(".shtml", "SLBr");
- FileAssociationsRegistry.SetValue(".html", "SLBr");
- FileAssociationsRegistry.SetValue(".htm", "SLBr");
- FileAssociationsRegistry.SetValue(".pdf", "SLBr");
- FileAssociationsRegistry.SetValue(".svg", "SLBr");
- FileAssociationsRegistry.SetValue(".webp", "SLBr");
- FileAssociationsRegistry.Close();
-
- RegistryKey URLAssociationsRegistry = CapabilitiesRegistry.CreateSubKey("URLAssociations", true);
- URLAssociationsRegistry.SetValue("http", "SLBr");
- URLAssociationsRegistry.SetValue("https", "SLBr");
- URLAssociationsRegistry.Close();
-
- CapabilitiesRegistry.Close();
-
- RegistryKey DefaultIconRegistry = key.CreateSubKey("DefaultIcon", true);
- DefaultIconRegistry.SetValue(null, $"{ExecutablePath},0");
- DefaultIconRegistry.Close();
-
- RegistryKey CommandRegistry = key.CreateSubKey("shell\\open\\command", true);
- CommandRegistry.SetValue(null, $"\"{ExecutablePath}\" \"%1\"");
- CommandRegistry.Close();
+ using (var key = Registry.ClassesRoot.CreateSubKey("SLBr", true))
+ {
+ key.SetValue(null, "SLBr Document");
+ key.SetValue("AppUserModelId", "SLBr");
+
+ RegistryKey ApplicationRegistry = key.CreateSubKey("Application", true);
+ ApplicationRegistry.SetValue("AppUserModelId", "SLBr");
+ ApplicationRegistry.SetValue("ApplicationIcon", $"{ExecutablePath},0");
+ ApplicationRegistry.SetValue("ApplicationName", "SLBr");
+ ApplicationRegistry.SetValue("ApplicationCompany", "SLT World");
+ ApplicationRegistry.SetValue("ApplicationDescription", "Browse the web with a fast, lightweight web browser.");
+ ApplicationRegistry.Close();
+
+ RegistryKey IconRegistry = key.CreateSubKey("DefaultIcon", true);
+ IconRegistry.SetValue(null, $"{ExecutablePath},0");
+ ApplicationRegistry.Close();
+
+ RegistryKey CommandRegistry = key.CreateSubKey("shell\\open\\command", true);
+ CommandRegistry.SetValue(null, $"\"{ExecutablePath}\" \"%1\"");
+ CommandRegistry.Close();
+ }
+ using (var key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Clients\\StartMenuInternet", true).CreateSubKey("SLBr", true))
+ {
+ if (key.GetValue(null) as string != "SLBr")
+ key.SetValue(null, "SLBr");
+
+ RegistryKey CapabilitiesRegistry = key.CreateSubKey("Capabilities", true);
+ CapabilitiesRegistry.SetValue("ApplicationDescription", "SLBr is a open source browser that prioritizes a faster web");
+ CapabilitiesRegistry.SetValue("ApplicationIcon", $"{ExecutablePath},0");
+ CapabilitiesRegistry.SetValue("ApplicationName", $"SLBr");
+ RegistryKey StartMenuRegistry = CapabilitiesRegistry.CreateSubKey("StartMenu", true);
+ StartMenuRegistry.SetValue("StartMenuInternet", "SLBr");
+ StartMenuRegistry.Close();
+
+ RegistryKey FileAssociationsRegistry = CapabilitiesRegistry.CreateSubKey("FileAssociations", true);
+ FileAssociationsRegistry.SetValue(".xhtml", "SLBr");
+ FileAssociationsRegistry.SetValue(".xht", "SLBr");
+ FileAssociationsRegistry.SetValue(".shtml", "SLBr");
+ FileAssociationsRegistry.SetValue(".html", "SLBr");
+ FileAssociationsRegistry.SetValue(".htm", "SLBr");
+ FileAssociationsRegistry.SetValue(".pdf", "SLBr");
+ FileAssociationsRegistry.SetValue(".svg", "SLBr");
+ FileAssociationsRegistry.SetValue(".webp", "SLBr");
+ FileAssociationsRegistry.Close();
+
+ RegistryKey URLAssociationsRegistry = CapabilitiesRegistry.CreateSubKey("URLAssociations", true);
+ URLAssociationsRegistry.SetValue("http", "SLBr");
+ URLAssociationsRegistry.SetValue("https", "SLBr");
+ URLAssociationsRegistry.Close();
+
+ CapabilitiesRegistry.Close();
+
+ RegistryKey DefaultIconRegistry = key.CreateSubKey("DefaultIcon", true);
+ DefaultIconRegistry.SetValue(null, $"{ExecutablePath},0");
+ DefaultIconRegistry.Close();
+
+ RegistryKey CommandRegistry = key.CreateSubKey("shell\\open\\command", true);
+ CommandRegistry.SetValue(null, $"\"{ExecutablePath}\" \"%1\"");
+ CommandRegistry.Close();
+ }
+ using (var key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\RegisteredApplications", true))
+ {
+ key.SetValue("SLBr", "Software\\Clients\\StartMenuInternet\\SLBr\\Capabilities");
+ }
}
- using (var key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\RegisteredApplications", true))
+ catch
{
- key.SetValue("SLBr", "Software\\Clients\\StartMenuInternet\\SLBr\\Capabilities");
+ SplashScreen.Instance.ReportProgress(4, "Failed.");
}
//Process regeditProcess = Process.Start("regedit.exe", "/s \"" + RegPath + "\"");
//regeditProcess.WaitForExit();
}
+ //await Task.Delay(500);
InitializeIE();
+ //await Task.Delay(500);
TinyRandom = new Random();
TinyDownloader = new WebClient();
InitializeSaves();
+ //await Task.Delay(500);
InitializeCEF();
- InitializeUISaves();
-
+ //await Task.Delay(500);
InitializeComponent();
+ //await Task.Delay(500);
+ InitializeUISaves();
+ //await Task.Delay(500);
+ SplashScreen.Instance.ReportProgress(87, "Initializing components...");
BrowserTabs.ItemsSource = Tabs;
GCTimer.Tick += GCCollect_Tick;
GCTimer.Start();
+ //await Task.Delay(500);
+ SplashScreen.Instance.ReportProgress(99, "Complete.");
+ //await Task.Delay(1000);
+ SplashScreen.Instance.ReportProgress(100, "Showing window...");
}
public void DiscordWebhookSendInfo(string Content)
@@ -1081,14 +1284,14 @@ private void GCCollect_Tick(object sender, EventArgs e)
if (bool.Parse(MainSave.Get("TabUnloading")))
{
if (UnloadTabsTime >= 150)
- UnloadTabs();
+ UnloadTabs(true);
else
UnloadTabsTime += 30;
}
//GC.WaitForPendingFinalizers();
GC.Collect();
}
- public void UnloadTabs()
+ public void UnloadTabs(bool ChangeIcon)
{
BrowserTabItem SelectedTab = Tabs[BrowserTabs.SelectedIndex];
foreach (BrowserTabItem Tab in Tabs)
@@ -1097,29 +1300,19 @@ public void UnloadTabs()
{
Browser BrowserView = GetBrowserView(Tab);
if (BrowserView != null)
- UnloadTab(BrowserView, true);
+ UnloadTab(ChangeIcon, BrowserView);
}
}
UnloadTabsTime = 0;
}
- private void UnloadTab(Browser BrowserView, bool IgnoreIfSound = true)
+ private void UnloadTab(bool ChangeIcon, Browser BrowserView)
{
- if (IgnoreIfSound)//PROBLEM: This checks if the address is a known music website. I need help on detecting sound.
- {
- string CleanedAddress = Utils.CleanUrl(BrowserView.Address, true, true, true, true);
- if ((CleanedAddress.StartsWith("youtube.com/watch")
- || CleanedAddress.StartsWith("meet.google.com/")
- || CleanedAddress.StartsWith("spotify.com/track/")
- || CleanedAddress.StartsWith("soundcloud.com")
- || CleanedAddress.StartsWith("dailymotion.com/video/")
- || CleanedAddress.StartsWith("vimeo.com")
- || CleanedAddress.StartsWith("twitch.tv/")
- || CleanedAddress.StartsWith("bitchute.com/video/")
- || CleanedAddress.StartsWith("ted.com/talks/")
- ) && !BrowserView.IsAudioMuted)
- return;
- }
- BrowserView.Unload(Framerate, Javascript, LoadImages, LocalStorage, Databases, WebGL);
+ string CleanedAddress = BrowserView.Address;
+ bool IsBlacklistedSite = CleanedAddress.Contains("youtube.com/watch") || CleanedAddress.Contains("meet.google.com/") || CleanedAddress.Contains("spotify.com/track/")
+ || CleanedAddress.Contains("soundcloud.com") || CleanedAddress.Contains("dailymotion.com/video/") || CleanedAddress.Contains("vimeo.com")
+ || CleanedAddress.Contains("twitch.tv/") || CleanedAddress.Contains("bitchute.com/video/") || CleanedAddress.Contains("ted.com/talks/");
+ if (BrowserView.IsAudioMuted || !Utils.IsAudioPlayingInDevice() || !IsBlacklistedSite)
+ BrowserView.Unload(ChangeIcon, Framerate, Javascript, LoadImages, LocalStorage, Databases, WebGL);
}
public void ButtonAction(object sender, RoutedEventArgs e)
@@ -1166,17 +1359,11 @@ private void Action(Actions _Action, object sender = null, string V1 = "", strin
NewBrowserTab(V1, 0, true);
break;
case Actions.CloseTab:
- CloseCurrentBrowserTab();
+ CloseBrowserTab(int.Parse(V1));
break;
case Actions.Inspect:
Inspect();
break;
- /*case Actions.Create_Tab:
- CreateBrowserTab("Empty00000");
- break;
- case Actions.CloseTab:
- CloseTab();
- break;*/
}
}
public void Undo()
@@ -1257,38 +1444,117 @@ public void FindUI()
if (_Browser == null)
return;
Keyboard.Focus(_Browser.FindTextBox);
+ _Browser.FindTextBox.SelectAll();
}
- public void NewBrowserTab(string Url, int BrowserType = 0, bool IsSelected = false, int Index = -1)
+ /*public void NewTab(UserControl Content, string Header, bool IsSelected = false, int Index = -1)
{
- Url = Url.Replace("{Homepage}", MainSave.Get("Homepage"));
- BrowserTabItem _Tab = new BrowserTabItem { Header = Utils.CleanUrl(Url, true, true, true, true) };
- _Tab.Content = new Browser(Url, BrowserType, _Tab);
+ BrowserTabItem _Tab = new BrowserTabItem { Header = Header };
+ _Tab.Content = Content;
+ _Tab.Id = Utils.GenerateRandomId();
+ _Tab.Action = $"5<,>{_Tab.Id}";
if (Index != -1)
Tabs.Insert(Index, _Tab);
else
Tabs.Add(_Tab);
if (IsSelected)
BrowserTabs.SelectedIndex = Tabs.IndexOf(_Tab);
- }
- public void Settings(bool IsSelected = false, int Index = -1)
+ }*/
+ public void NewBrowserTab(string Url, int BrowserType = 0, bool IsSelected = false, int Index = -1)
{
- BrowserTabItem _Tab = new BrowserTabItem { Header = "Settings" };
- _Tab.Content = new Settings();
+ if (WindowState == WindowState.Minimized)
+ WindowState = WindowState.Normal;
+ Url = Url.Replace("{Homepage}", MainSave.Get("Homepage"));
+ BrowserTabItem _Tab = new BrowserTabItem { Header = Utils.CleanUrl(Url, true, true, true, true) };
+ _Tab.Content = new Browser(Url, BrowserType, _Tab);
+ _Tab.Id = Utils.GenerateRandomId();
+ _Tab.Action = $"5<,>{_Tab.Id}";
if (Index != -1)
Tabs.Insert(Index, _Tab);
else
Tabs.Add(_Tab);
if (IsSelected)
BrowserTabs.SelectedIndex = Tabs.IndexOf(_Tab);
+ //TextOptions.SetTextFormattingMode(_Tab.Content, TextFormattingMode.Display);
+ }
+ public void OpenSettings(bool IsSelected = false, int Index = -1)
+ {
+ if (WindowState == WindowState.Minimized)
+ WindowState = WindowState.Normal;
+ if (Settings.Instance != null && Settings.Instance.Tab != null)
+ SwitchToTab(Settings.Instance.Tab);
+ else
+ {
+ BrowserTabItem _Tab = new BrowserTabItem { Header = "Settings" };
+ if (Settings.Instance == null)
+ _Tab.Content = new Settings(_Tab);
+ else
+ {
+ Settings.Instance.Tab = _Tab;
+ _Tab.Content = Settings.Instance;
+ }
+ _Tab.Id = Utils.GenerateRandomId();
+ _Tab.Action = $"5<,>{_Tab.Id}";
+ if (Index != -1)
+ Tabs.Insert(Index, _Tab);
+ else
+ Tabs.Add(_Tab);
+ if (IsSelected)
+ SwitchToTab(_Tab);
+
+ //TextOptions.SetTextFormattingMode(_Tab.Content, TextFormattingMode.Display);
+ //TextOptions.TextHintingModeProperty.OverrideMetadata(typeof(TextHintingMode), new FrameworkPropertyMetadata { DefaultValue = TextHintingMode.Fixed });
+ //TextOptions.TextFormattingModeProperty.OverrideMetadata(typeof(TextFormattingMode), new FrameworkPropertyMetadata { DefaultValue = TextFormattingMode.Display });
+ }
+ }
+ public void SwitchToTab(BrowserTabItem _Tab)
+ {
+ BrowserTabs.SelectedIndex = Tabs.IndexOf(_Tab);
+ }
+ public BrowserTabItem GetBrowserTabWithId(int Id)
+ {
+ foreach (BrowserTabItem _Tab in Tabs)
+ {
+ if (_Tab.Id == Id)
+ return _Tab;
+ }
+ return null;
}
- public void CloseCurrentBrowserTab()
+ public void CloseBrowserTab(int Id)
{
+ //if (Id == -1)
+ // Id = Tabs[BrowserTabs.SelectedIndex].Id;
+ BrowserTabItem _Tab = null;
+ if (Id == -1)
+ _Tab = Tabs[BrowserTabs.SelectedIndex];
+ else
+ _Tab = GetBrowserTabWithId(Id);
if (Tabs.Count > 1)
{
- Browser BrowserView = GetBrowserView(Tabs[BrowserTabs.SelectedIndex]);
+ bool IsSelected = Id != -1 ? _Tab == Tabs[BrowserTabs.SelectedIndex] : true;
+ //MessageBox.Show(Id.ToString());
+ Browser BrowserView = GetBrowserView(_Tab);
if (BrowserView != null)
BrowserView.DisposeCore();
- Tabs.RemoveAt(BrowserTabs.SelectedIndex);
+ else
+ {
+ if (Settings.Instance.Tab == _Tab)
+ Settings.Instance.DisposeCore();
+ }
+ if (IsSelected)
+ {
+ if (BrowserTabs.SelectedIndex > 0)
+ BrowserTabs.SelectedIndex = BrowserTabs.SelectedIndex - 1;
+ else
+ BrowserTabs.SelectedIndex = BrowserTabs.SelectedIndex + 1;
+ }
+ Tabs.Remove(_Tab);
+ if (IsSelected)
+ {
+ if (BrowserTabs.SelectedIndex > Tabs.Count - 1)
+ BrowserTabs.SelectedIndex = Tabs.Count - 1;
+ }
+
+ //Tabs.RemoveAt(Tabs.IndexOf(_Tab));
}
else
{
@@ -1337,14 +1603,24 @@ public Browser GetBrowserView(BrowserTabItem Tab = null)
}
public void ApplyTheme(Theme _Theme)
{
- bool SetDarkTitleBar = _Theme.DarkTitleBar;
- DwmSetWindowAttribute(new WindowInteropHelper(this).Handle, 20, ref SetDarkTitleBar, Marshal.SizeOf(true));
+ int SetDarkTitleBar = _Theme.DarkTitleBar ? 1 : 0;
+ DwmSetWindowAttribute(new WindowInteropHelper(this).Handle, (int)DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, ref SetDarkTitleBar, Marshal.SizeOf(true));
+
+ //int trueValue = 2;
+ //DwmSetWindowAttribute(new WindowInteropHelper(this).Handle, (int)DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, ref trueValue, Marshal.SizeOf(typeof(int)));
+ //DwmSetWindowAttribute(new WindowInteropHelper(this).Handle, (int)DWMWINDOWATTRIBUTE.DWMWA_MICA_EFFECT, ref trueValue, Marshal.SizeOf(typeof(int)));
- Resources["PrimaryBrush"] = new SolidColorBrush(_Theme.PrimaryColor);
- Resources["FontBrush"] = new SolidColorBrush(_Theme.FontColor);
- Resources["BorderBrush"] = new SolidColorBrush(_Theme.BorderColor);
- Resources["UnselectedTabBrush"] = new SolidColorBrush(_Theme.UnselectedTabColor);
- Resources["ControlFontBrush"] = new SolidColorBrush(_Theme.ControlFontColor);
+ //Resources["PrimaryBrush"] = new SolidColorBrush(_Theme.PrimaryColor);
+ //Resources["FontBrush"] = new SolidColorBrush(_Theme.FontColor);
+ //Resources["BorderBrush"] = new SolidColorBrush(_Theme.BorderColor);
+ //Resources["UnselectedTabBrush"] = new SolidColorBrush(_Theme.UnselectedTabColor);
+ //Resources["ControlFontBrush"] = new SolidColorBrush(_Theme.ControlFontColor);
+
+ Resources["PrimaryBrushColor"] = _Theme.PrimaryColor;
+ Resources["FontBrushColor"] = _Theme.FontColor;
+ Resources["BorderBrushColor"] = _Theme.BorderColor;
+ Resources["UnselectedTabBrushColor"] = _Theme.UnselectedTabColor;
+ Resources["ControlFontBrushColor"] = _Theme.ControlFontColor;
//WindowState = WindowState.Normal;
foreach (BrowserTabItem Tab in Tabs)
@@ -1355,11 +1631,18 @@ public void ApplyTheme(Theme _Theme)
//WindowState = WindowState.Maximized;
WindowStyle = WindowStyle.ThreeDBorderWindow;
WindowStyle = WindowStyle.SingleBorderWindow;
+
+ CurrentTheme = _Theme;
}
public Theme GetTheme(string Name = "")
{
if (string.IsNullOrEmpty(Name))
- Name = MainSave.Get("Theme");
+ {
+ if (CurrentTheme != null)
+ return CurrentTheme;
+ else
+ Name = MainSave.Get("Theme");
+ }
foreach (Theme _Theme in Themes)
{
if (_Theme.Name == Name)
@@ -1367,6 +1650,7 @@ public Theme GetTheme(string Name = "")
}
return Themes[0];
}
+ Theme CurrentTheme;
public void AdBlock(bool Boolean)
{
MainSave.Set("AdBlock", Boolean.ToString());
@@ -1403,7 +1687,7 @@ public void SetSandbox(int _Framerate, CefState JSState, CefState LIState, CefSt
{
Browser BrowserView = GetBrowserView(Tab);
if (BrowserView != null)
- BrowserView.Unload(Framerate, JSState, LIState, LSState, DBState, WebGLState);
+ BrowserView.Unload(false, Framerate, JSState, LIState, LSState, DBState, WebGLState);
}
UnloadTabsTime = 0;
}
@@ -1418,39 +1702,52 @@ public void CloseSLBr()
if (GCTimer != null)
GCTimer.Stop();
- StatisticsSave.Set("BlockedTrackers", TrackersBlocked.ToString());
- StatisticsSave.Set("BlockedAds", AdsBlocked.ToString());
-
- FavouritesSave.Clear();
- FavouritesSave.Set("Favourite_Count", Favourites.Count.ToString(), false);
- for (int i = 0; i < Favourites.Count; i++)
- FavouritesSave.Set($"Favourite_{i}", Favourites[i].Tooltip, Favourites[i].Name, false);
- FavouritesSave.Save();
-
- SearchSave.Set("Search_Engine_Count", SearchEngines.Count.ToString(), false);
- for (int i = 0; i < SearchEngines.Count; i++)
- SearchSave.Set($"Search_Engine_{i}", SearchEngines[i], false);
- SearchSave.Save();
-
- TabsSave.Clear();
- if (bool.Parse(MainSave.Get("RestoreTabs")))
+ if (Initialized)
{
- int Count = 0;
- int SelectedIndex = 0;
- for (int i = 0; i < Tabs.Count; i++)
+ StatisticsSave.Set("BlockedTrackers", TrackersBlocked.ToString());
+ StatisticsSave.Set("BlockedAds", AdsBlocked.ToString());
+
+ FavouritesSave.Clear();
+ FavouritesSave.Set("Favourite_Count", Favourites.Count.ToString(), false);
+ for (int i = 0; i < Favourites.Count; i++)
+ FavouritesSave.Set($"Favourite_{i}", Favourites[i].Tooltip, Favourites[i].Name, false);
+ FavouritesSave.Save();
+
+ SearchSave.Set("Search_Engine_Count", SearchEngines.Count.ToString(), false);
+ for (int i = 0; i < SearchEngines.Count; i++)
+ SearchSave.Set($"Search_Engine_{i}", SearchEngines[i], false);
+ SearchSave.Save();
+
+ TabsSave.Clear();
+ if (bool.Parse(MainSave.Get("RestoreTabs")))
{
- BrowserTabItem Tab = Tabs[i];
- Browser BrowserView = GetBrowserView(Tab);
- if (BrowserView != null)
+ int Count = 0;
+ int SelectedIndex = 0;
+ for (int i = 0; i < Tabs.Count; i++)
{
- TabsSave.Set($"Tab_{Count}", ((Browser)Tab.Content).Address, false);
- if (i == BrowserTabs.SelectedIndex)
- SelectedIndex = Count;
- Count++;
+ BrowserTabItem Tab = Tabs[i];
+ Browser BrowserView = GetBrowserView(Tab);
+ if (BrowserView != null)
+ {
+ TabsSave.Set($"Tab_{Count}", BrowserView.Address, false);
+ if (i == BrowserTabs.SelectedIndex)
+ SelectedIndex = Count;
+ Count++;
+ }
+ else
+ {
+ if (Settings.Instance.Tab == Tab)
+ {
+ TabsSave.Set($"Tab_{Count}", "slbr://settings", false);
+ if (i == BrowserTabs.SelectedIndex)
+ SelectedIndex = Count;
+ Count++;
+ }
+ }
}
+ TabsSave.Set("Tab_Count", Count.ToString());
+ MainSave.Set("SelectedTabIndex", SelectedIndex.ToString());
}
- TabsSave.Set("Tab_Count", Count.ToString());
- MainSave.Set("SelectedTabIndex", SelectedIndex.ToString());
}
Cef.Shutdown();
}
@@ -1458,6 +1755,61 @@ public void CloseSLBr()
private void Window_Loaded(object sender, RoutedEventArgs e)
{
ApplyTheme(GetTheme());
+
+ if (!DeveloperMode)
+ {
+ if (Utils.CheckForInternetConnection())
+ {
+ try
+ {
+ string VersionInfo = TinyDownloader.DownloadString("https://raw.githubusercontent.com/SLT-World/SLBr/main/Version.txt").Replace("\n", "");
+ if (!VersionInfo.StartsWith(ReleaseVersion))
+ ToastBox.Show(VersionInfo, $"SLBr {VersionInfo} is now available, please update SLBr to keep up with the progress.", 10);
+ //Prompt(false, string.Format(NewUpdateString, VersionInfo), true, "Download", $"24<,>https://github.com/SLT-World/SLBr/releases/tag/{VersionInfo}", $"https://github.com/SLT-World/SLBr/releases/tag/{VersionInfo}", true, "\xE896");//SLBr is up to date
+ }
+ catch { }
+ }
+ }
+
+ SplashScreen.Instance.Close();
+ Initialized = true;
+ }
+ private void Window_StateChanged(object sender, EventArgs e)
+ {
+ //Timeline.SetDesiredFrameRate(, 1);
+ /*Dispatcher.Invoke(new Action(() =>
+ {
+ switch (WindowState)
+ {
+ case WindowState.Maximized:
+ ChangeWPFFrameRate(WPFFrameRate);
+ break;
+ case WindowState.Minimized:
+ ChangeWPFFrameRate(1);
+ break;
+ case WindowState.Normal:
+ ChangeWPFFrameRate(WPFFrameRate);
+ break;
+ }
+ }));*/
}
+
+ private void BrowserTabs_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ //Icon = new BitmapImage(new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Resources", (CurrentTheme.DarkTitleBar ? "White Tab Icon.png" : "Black Tab Icon.png"))));
+ BrowserTabItem _CurrentTab = Tabs[BrowserTabs.SelectedIndex];
+ Title = _CurrentTab.Header + " - SLBr";
+ /*Browser _Browser = GetBrowserView(_CurrentTab);
+ if (_Browser != null)
+ Title = _Browser.Title + " - SLBr";
+ else if (_CurrentTab.Content is Settings)
+ Title = "Settings - SLBr";*/
+ }
+
+ /*static void ChangeWPFFrameRate(int FrameRate)
+ {
+ //Timeline.DesiredFrameRateProperty.DefaultMetadata.DefaultValue = FrameRate;
+ Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline), new FrameworkPropertyMetadata { DefaultValue = FrameRate });
+ }*/
}
}
diff --git a/SLBr/Pages/Browser.xaml b/SLBr/Pages/Browser.xaml
index 2c2d41f..136e7a2 100644
--- a/SLBr/Pages/Browser.xaml
+++ b/SLBr/Pages/Browser.xaml
@@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:controls="clr-namespace:SLBr.Controls"
mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" FontFamily="Segoe MDL2 Assets">
+
@@ -25,7 +26,7 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SLBr/Pages/Browser.xaml.cs b/SLBr/Pages/Browser.xaml.cs
index 49727f2..0f1b9e7 100644
--- a/SLBr/Pages/Browser.xaml.cs
+++ b/SLBr/Pages/Browser.xaml.cs
@@ -1,5 +1,8 @@
using CefSharp;
using CefSharp.DevTools;
+using CefSharp.DevTools.CacheStorage;
+using CefSharp.DevTools.Debugger;
+using CefSharp.DevTools.Page;
using CefSharp.Wpf.HwndHost;
using HtmlAgilityPack;
using Newtonsoft.Json;
@@ -40,7 +43,7 @@ private class InspectorObject
Saving MainSave;
IdnMapping _IdnMapping;
- BrowserTabItem Tab;
+ public BrowserTabItem Tab;
BrowserSettings _BrowserSettings;
@@ -79,16 +82,19 @@ void CreateChromium(string Url, BrowserSettings CefBrowserSettings = null)
Chromium.Address = Url;
Chromium.JavascriptObjectRepository.Register("internal", MainWindow.Instance._PrivateJsObjectHandler, BindingOptions.DefaultBinder);
Chromium.JavascriptObjectRepository.Register("slbr", MainWindow.Instance._PublicJsObjectHandler, BindingOptions.DefaultBinder);
- Chromium.IsManipulationEnabled = true;
Chromium.LifeSpanHandler = MainWindow.Instance._LifeSpanHandler;
+ //Chromium.DownloadHandler = new CefSharp.Handler.DownloadHandler();
+ //Chromium.DownloadHandler = new NewDownloadHandler();
+ //Chromium.DownloadHandler = new DownloadHandler();
Chromium.DownloadHandler = MainWindow.Instance._DownloadHandler;
Chromium.RequestHandler = MainWindow.Instance._RequestHandler;
Chromium.MenuHandler = MainWindow.Instance._ContextMenuHandler;
Chromium.KeyboardHandler = MainWindow.Instance._KeyboardHandler;
Chromium.JsDialogHandler = MainWindow.Instance._JsDialogHandler;
Chromium.DisplayHandler = new DisplayHandler(this);
- Chromium.JavascriptMessageReceived += Chromium_JavascriptMessageReceived;
+ //Chromium.AudioHandler = new AudioHandler();
Chromium.AllowDrop = true;
+ Chromium.IsManipulationEnabled = true;
if (CefBrowserSettings != null)
_BrowserSettings = CefBrowserSettings;
else
@@ -101,14 +107,15 @@ void CreateChromium(string Url, BrowserSettings CefBrowserSettings = null)
LocalStorage = MainWindow.Instance.LocalStorage,
Databases = MainWindow.Instance.Databases,
WebGl = MainWindow.Instance.WebGL,
- BackgroundColor = Utils.ColorToUInt(System.Drawing.Color.Black)
+ BackgroundColor = System.Drawing.Color.Black.ToUInt()
};
}
Chromium.BrowserSettings = _BrowserSettings;
- Chromium.TitleChanged += Chromium_TitleChanged;
+ Chromium.JavascriptMessageReceived += Chromium_JavascriptMessageReceived;
Chromium.LoadingStateChanged += Chromium_LoadingStateChanged;
Chromium.ZoomLevelIncrement = 0.5f;
Chromium.FrameLoadEnd += Chromium_FrameLoadEnd;
+ Chromium.TitleChanged += Chromium_TitleChanged;
Chromium.StatusMessage += Chromium_StatusMessage;
CoreContainer.Children.Add(Chromium);
@@ -118,7 +125,7 @@ void CreateChromium(string Url, BrowserSettings CefBrowserSettings = null)
{
WebGl = CefState.Disabled,
WindowlessFrameRate = 20,
- BackgroundColor = Utils.ColorToUInt(System.Drawing.Color.Black)
+ BackgroundColor = System.Drawing.Color.Black.ToUInt()
};
ChromiumInspector.AllowDrop = true;
ChromiumInspector.FrameLoadEnd += (sender, args) =>
@@ -143,7 +150,10 @@ void CreateChromium(string Url, BrowserSettings CefBrowserSettings = null)
{
if (_InspectorObject.type == "page" && _InspectorObject.url == Chromium.Address)
{
- ChromiumInspector.Address = "http://localhost:8089" + _InspectorObject.devtoolsFrontendUrl;
+ ChromiumInspector.Address = "http://localhost:8089" + _InspectorObject.devtoolsFrontendUrl.Replace("inspector.html", "devtools_app.html");
+ //ChromiumInspector.Address = "http://localhost:8089" + (MainWindow.Instance.DeveloperMode ? _InspectorObject.devtoolsFrontendUrl : _InspectorObject.devtoolsFrontendUrl.Replace("inspector.html", "devtools_app.html"));
+ //devtools_app.html?can_dock=true
+ //ChromiumInspector.Address = "http://localhost:8089" + _InspectorObject.devtoolsFrontendUrl;
break;
}
}
@@ -164,7 +174,7 @@ void CreateChromium(string Url, BrowserSettings CefBrowserSettings = null)
ChromiumInspector.KeyboardHandler = MainWindow.Instance._KeyboardHandler;
ChromiumInspector.JsDialogHandler = MainWindow.Instance._JsDialogHandler;
//ChromiumInspector.StatusMessage += OnWebBrowserStatusMessage;
- InspectorContainer.Children.Add(ChromiumInspector);
+ InspectorCoreContainer.Children.Add(ChromiumInspector);
RenderOptions.SetBitmapScalingMode(Chromium, BitmapScalingMode.LowQuality);
RenderOptions.SetBitmapScalingMode(ChromiumInspector, BitmapScalingMode.LowQuality);
@@ -188,8 +198,8 @@ void CreateIE(string Url)
IE.BrowserCore.Navigated += IE_Navigated;
CoreContainer.Children.Add(IE.BrowserCore);
- IEInspector = new IEWebBrowser("about:blank");
- InspectorContainer.Children.Add(IEInspector.BrowserCore);
+ //IEInspector = new IEWebBrowser("about:blank");
+ //InspectorContainer.Children.Add(IEInspector.BrowserCore);
}
private void IE_Loaded(object sender, RoutedEventArgs e)
@@ -241,18 +251,24 @@ static requestPermission() {
};
window.Notification = Notification;
})();");
+ //Chromium.ExecuteScriptAsync(@"Object.defineProperty(navigator.connection, ""saveData"", { get: function() { return true; } });");
+
//Chromium.ExecuteScriptAsync("window.navigator.vendor = \"SLT World\"");
//Chromium.ExecuteScriptAsync("window.navigator.deviceMemory = 0.25");
//if (e.Frame.IsValid && e.Frame.IsMain)
}
- public void Unload(BrowserSettings _BrowserSettings = null)
+ public void Unload(bool ChangeIcon, BrowserSettings _BrowserSettings = null)
{
if (BrowserType == 0)
{
string Url = Chromium.Address;
+
+ if (ChangeIcon && Tab.Icon != null)
+ Tab.Icon = new BitmapImage(new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Resources", "Green Sustainable Icon.png")));
+ //Tab.Icon = new BitmapImage(new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Resources", (MainWindow.Instance.GetTheme().DarkTitleBar ? "White Sustainable Icon.png" : "Black Sustainable Icon.png"))));
CoreContainer.Children.Clear();
- InspectorContainer.Children.Clear();
+ InspectorCoreContainer.Children.Clear();
Chromium.Dispose();
ChromiumInspector.Dispose();
CreateChromium(Url, _BrowserSettings);
@@ -260,15 +276,18 @@ public void Unload(BrowserSettings _BrowserSettings = null)
else
{
string Url = IE.BrowserCore.Source.AbsoluteUri;
+ if (ChangeIcon && Tab.Icon != null)
+ Tab.Icon = new BitmapImage(new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Resources", "Green Sustainable Icon.png")));
+ //Tab.Icon = new BitmapImage(new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Resources", (MainWindow.Instance.GetTheme().DarkTitleBar ? "White Sustainable Icon.png" : "Black Sustainable Icon.png"))));
CoreContainer.Children.Clear();
- InspectorContainer.Children.Clear();
+ InspectorCoreContainer.Children.Clear();
IE.Dispose();
- IEInspector.Dispose();
+ //IEInspector.Dispose();
CreateIE(Url);
}
GC.Collect();
}
- public void Unload(int _Framerate, CefState JSState, CefState LIState, CefState LSState, CefState DBState, CefState WebGLState)
+ public void Unload(bool ChangeIcon, int _Framerate, CefState JSState, CefState LIState, CefState LSState, CefState DBState, CefState WebGLState)
{
if (BrowserType == 0)
{
@@ -280,9 +299,9 @@ public void Unload(int _Framerate, CefState JSState, CefState LIState, CefState
LocalStorage = LSState,
Databases = DBState,
WebGl = WebGLState,
- BackgroundColor = Utils.ColorToUInt(System.Drawing.Color.Black)
+ BackgroundColor = System.Drawing.Color.Black.ToUInt()
};
- Unload(_BrowserSettings);
+ Unload(ChangeIcon, _BrowserSettings);
}
}
/*private void Chromium_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
@@ -305,7 +324,7 @@ private void IE_Navigated(object sender, System.Windows.Navigation.NavigationEve
dynamic document = IE.BrowserCore.Document;
dynamic script = document.createElement("script");
script.type = @"text/javascript";
- script.src = @"https://lupatec.eu/getfirebug/firebug-lite-compressed.js#startOpened=false,disableWhenFirebugActive=false";
+ script.src = @"https://lupatec.eu/getfirebug/firebug-lite-compressed.js#startOpened=true,disableWhenFirebugActive=false";
document.head.appendChild(script); // Dynamic property head does not exist.
}
catch { };
@@ -324,7 +343,10 @@ private void IE_Navigated(object sender, System.Windows.Navigation.NavigationEve
if (AddressBox.Text != OutputUrl)
{
if (CanChangeAddressBox())
+ {
AddressBox.Text = OutputUrl;
+ AddressBoxPlaceholder.Text = "";
+ }
AddressBox.Tag = e.Uri.AbsoluteUri;
}
}));
@@ -346,7 +368,13 @@ void BrowserLoadChanged(string Address)
QRCodePopup.IsOpen = false;
MainWindow.Instance.AddHistory(Address);
string Host = Utils.Host(Address);
- Tab.Icon = new BitmapImage(new Uri("https://www.google.com/s2/favicons?sz=24&domain=" + Host));
+ //if (Tab.Icon == null)
+ //Tab.Icon = new BitmapImage(new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Resources", (MainWindow.Instance.GetTheme().DarkTitleBar ? "White Tab Icon.png" : "Black Tab Icon.png"))));
+ //new BitmapImage(new Uri("https://www.google.com/s2/favicons?sz=24&domain=" + Host));
+ //if (Tab.Icon == null)
+ Tab.Icon = MainWindow.Instance.GetIcon(Address);//new BitmapImage(new Uri("https://www.google.com/s2/favicons?sz=24&domain=" + Host));
+
+
if (Address.StartsWith("https:"))
{
SSLSymbol.Text = "\xE72E";
@@ -396,6 +424,8 @@ void BrowserLoadChanged(string Address)
private void Chromium_TitleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
Tab.Header = Title;
+ if (Tab == MainWindow.Instance.Tabs[MainWindow.Instance.BrowserTabs.SelectedIndex])
+ MainWindow.Instance.Title = Title + " - SLBr";
}
private void Chromium_LoadingStateChanged(object? sender, LoadingStateChangedEventArgs e)
{
@@ -405,23 +435,18 @@ private void Chromium_LoadingStateChanged(object? sender, LoadingStateChangedEve
return;
BrowserLoadChanged(Chromium.Address);
- DevToolsClient _DevToolsClient = Chromium.GetDevToolsClient();
- _DevToolsClient.Emulation.SetAutoDarkModeOverrideAsync(MainWindow.Instance.GetTheme().DarkWebPage ? bool.Parse(MainWindow.Instance.MainSave.Get("DarkWebPage")) : false);
- ReloadButton.Content = e.IsLoading ? "\xE711" : "\xE72C";
- //WebsiteLoadingProgressBar.IsEnabled = e.IsLoading;
- //WebsiteLoadingProgressBar.IsIndeterminate = e.IsLoading;
if (!Chromium.IsLoading)
{
- if (IsUtilityContainerOpen && !ChromiumInspector.Address.StartsWith("http://localhost:8089/devtools/"))
+ if (IsUtilityContainerOpen && !ChromiumInspector.Address.StartsWith("http://localhost:8089/"))
ChromiumInspector.Address = "localhost:8089/json/list";
- if (Chromium.Address == "https://github.com/SLT-World/SLBr" || Chromium.Address == "https://github.com/SLT-World/SLBr/")
+ //if (IsUtilityContainerOpen && !ChromiumInspector.Address.StartsWith("http://localhost:8089/devtools/"))
+ if (Chromium.Address.EndsWith("github.com/SLT-World/SLBr"))
ToastBox.Show("", "Please support SLBr by giving a star to the project.", 10);
}
else
{
- if (Chromium.Address.StartsWith("slbr:"))
- Chromium.ExecuteScriptAsync("CefSharp.BindObjectAsync(\"internal\");");
- Chromium.ExecuteScriptAsync("CefSharp.BindObjectAsync(\"slbr\");");
+ if (IsUtilityContainerOpen && !ChromiumInspector.Address.StartsWith("http://localhost:8089/"))
+ ChromiumInspector.Address = "localhost:8089/json/list";
Chromium.ExecuteScriptAsync(@"function addStyle(styleString) {
const style = document.createElement('style');
style.textContent = styleString;
@@ -429,23 +454,59 @@ private void Chromium_LoadingStateChanged(object? sender, LoadingStateChangedEve
}
addStyle(`
- ::-webkit-scrollbar{width: 17.5px;}
- `);
-
- addStyle(`
- ::-webkit-scrollbar-thumb{background:gainsboro;}
- `);
+ ::-webkit-scrollbar {
+ width: 16px;
+ }
- addStyle(`
- ::-webkit-scrollbar-thumb:hover{background:lightgray;}
- `);
+ ::-webkit-scrollbar-thumb {
+ height: 56px;
+ border-radius: 8px;
+ border: 4px solid transparent;
+ background-clip: content-box;
+ background-color: transparent;
+ }
+ body::-webkit-scrollbar-thumb {
+ height: 56px;
+ border-radius: 8px;
+ border: 4px solid transparent;
+ background-clip: content-box;
+ background-color: hsl(0,0%,67%);
+ }
- addStyle(`
- ::-webkit-scrollbar-track{background:whitesmoke;}
+ ::-webkit-scrollbar-corner {background-color: transparent;}
`);");
+ //Chromium.ExecuteScriptAsync(@"function addStyle(styleString) {
+ // const style = document.createElement('style');
+ // style.textContent = styleString;
+ // document.head.append(style);
+ //}
+
+ //addStyle(`
+ // ::-webkit-scrollbar{width: 17.5px;}
+ //`);
+
+ //addStyle(`
+ // ::-webkit-scrollbar-thumb{background:gainsboro;}
+ //`);
+
+ //addStyle(`
+ // ::-webkit-scrollbar-thumb:hover{background:lightgray;}
+ //`);
+
+ //addStyle(`
+ // ::-webkit-scrollbar-track{background:whitesmoke;}
+ //`);");
+ if (Chromium.Address.StartsWith("slbr:"))
+ Chromium.ExecuteScriptAsync("CefSharp.BindObjectAsync(\"internal\");");
+ Chromium.ExecuteScriptAsync("CefSharp.BindObjectAsync(\"slbr\");");
}
+ ReloadButton.Content = e.IsLoading ? "\xE711" : "\xE72C";
+ //WebsiteLoadingProgressBar.IsEnabled = e.IsLoading;
+ //WebsiteLoadingProgressBar.IsIndeterminate = e.IsLoading;
BackButton.IsEnabled = e.CanGoBack;
ForwardButton.IsEnabled = e.CanGoForward;
+ DevToolsClient _DevToolsClient = Chromium.GetDevToolsClient();
+ _DevToolsClient.Emulation.SetAutoDarkModeOverrideAsync(MainWindow.Instance.GetTheme().DarkWebPage ? bool.Parse(MainWindow.Instance.MainSave.Get("DarkWebPage")) : false);
}));
}
@@ -453,7 +514,7 @@ private void Chromium_LoadingStateChanged(object? sender, LoadingStateChangedEve
ChromiumWebBrowser Chromium;
IEWebBrowser IE;
ChromiumWebBrowser ChromiumInspector;
- IEWebBrowser IEInspector;
+ //IEWebBrowser IEInspector;
public void ButtonAction(object sender, RoutedEventArgs e)
{
@@ -487,10 +548,14 @@ public enum Actions
SwitchBrowser = 11,
OpenFileExplorer = 12,
QRCode = 13,
+ SetInspectorDock = 14,
+ OpenAsPopupBrowser = 15,
+ SizeEmulator = 16,
}
private void Action(Actions _Action, object sender = null, string V1 = "", string V2 = "", string V3 = "")
{
V1 = V1.Replace("{CurrentUrl}", Address);
+ V1 = V1.Replace("{CurrentInspectorUrl}", ChromiumInspector.Address);
V1 = V1.Replace("{Homepage}", MainSave.Get("Homepage"));
switch (_Action)
{
@@ -510,7 +575,7 @@ private void Action(Actions _Action, object sender = null, string V1 = "", strin
MainWindow.Instance.NewBrowserTab(V1, 0, true);
break;
case Actions.CloseTab:
- MainWindow.Instance.CloseCurrentBrowserTab();
+ MainWindow.Instance.CloseBrowserTab(int.Parse(V1));
break;
case Actions.Inspect:
Inspect();
@@ -522,10 +587,10 @@ private void Action(Actions _Action, object sender = null, string V1 = "", strin
SetAudio(!IsAudioMuted);
break;
case Actions.Settings:
- MainWindow.Instance.Settings(true, MainWindow.Instance.BrowserTabs.SelectedIndex + 1);
+ MainWindow.Instance.OpenSettings(true, MainWindow.Instance.BrowserTabs.SelectedIndex + 1);
break;
case Actions.UnloadTabs:
- MainWindow.Instance.UnloadTabs();
+ MainWindow.Instance.UnloadTabs(true);
break;
case Actions.SwitchBrowser:
SwitchBrowser(V1);
@@ -536,9 +601,69 @@ private void Action(Actions _Action, object sender = null, string V1 = "", strin
case Actions.QRCode:
QRCode(V1);
break;
+ case Actions.SetInspectorDock:
+ SetInspectorDock(int.Parse(V1));
+ break;
+ case Actions.OpenAsPopupBrowser:
+ OpenAsPopupBrowser(V1);
+ break;
+ case Actions.SizeEmulator:
+ SizeEmulator();
+ break;
}
}
+ bool ActiveSizeEmulation;
+ private void SizeEmulator()
+ {
+ SizeEmulatorColumn1.Width = new GridLength(0);
+ SizeEmulatorColumn2.Width = new GridLength(0);
+ SizeEmulatorRow1.Height = new GridLength(0);
+ SizeEmulatorRow2.Height = new GridLength(0);
+ SizeEmulatorColumnSplitter1.Visibility = ActiveSizeEmulation ? Visibility.Collapsed : Visibility.Visible;
+ SizeEmulatorColumnSplitter2.Visibility = ActiveSizeEmulation ? Visibility.Collapsed : Visibility.Visible;
+ SizeEmulatorRowSplitter1.Visibility = ActiveSizeEmulation ? Visibility.Collapsed : Visibility.Visible;
+ SizeEmulatorRowSplitter2.Visibility = ActiveSizeEmulation ? Visibility.Collapsed : Visibility.Visible;
+ ActiveSizeEmulation = !ActiveSizeEmulation;
+ }
+ private void OpenAsPopupBrowser(string Url)
+ {
+ new PopupBrowser(Url, -1, -1).Show();
+ }
+ private void SetInspectorDock(int DockID)
+ {
+ switch (DockID)
+ {
+ case 0:
+ Grid.SetColumn(InspectorContainer, 2);
+ Grid.SetRow(InspectorContainer, 1);
+ InspectorContainer.Height = Double.NaN;
+ InspectorContainer.Width = 600;
+ InspectorContainer.BorderThickness = new Thickness(1, 0, 0, 0);
+ break;
+ case 1:
+ Grid.SetColumn(InspectorContainer, 0);
+ Grid.SetRow(InspectorContainer, 1);
+ InspectorContainer.Height = Double.NaN;
+ InspectorContainer.Width = 600;
+ InspectorContainer.BorderThickness = new Thickness(0, 0, 1, 0);
+ break;
+ case 2:
+ Grid.SetColumn(InspectorContainer, 1);
+ Grid.SetRow(InspectorContainer, 2);
+ InspectorContainer.Height = 300;
+ InspectorContainer.Width = Double.NaN;
+ InspectorContainer.BorderThickness = new Thickness(0, 1, 0, 0);
+ break;
+ case 3:
+ Grid.SetColumn(InspectorContainer, 1);
+ Grid.SetRow(InspectorContainer, 0);
+ InspectorContainer.Height = 300;
+ InspectorContainer.Width = Double.NaN;
+ InspectorContainer.BorderThickness = new Thickness(0, 0, 0, 1);
+ break;
+ }
+ }
public void SwitchBrowser(string NewBrowserName)
{
int NewBrowserType = 0;
@@ -551,9 +676,9 @@ public void SwitchBrowser(string NewBrowserName)
{
string Url = IE.BrowserCore.Source.AbsoluteUri;
CoreContainer.Children.Clear();
- InspectorContainer.Children.Clear();
+ InspectorCoreContainer.Children.Clear();
IE.Dispose();
- IEInspector.Dispose();
+ //IEInspector.Dispose();
CreateChromium(Url);
SwitchBrowserButton.Tag = "11<,>IE";
SwitchBrowserButton.ToolTip = "Internet Explorer mode";
@@ -563,7 +688,7 @@ public void SwitchBrowser(string NewBrowserName)
{
string Url = Chromium.Address;
CoreContainer.Children.Clear();
- InspectorContainer.Children.Clear();
+ InspectorCoreContainer.Children.Clear();
Chromium.Dispose();
ChromiumInspector.Dispose();
CreateIE(Url);
@@ -715,6 +840,9 @@ public void Inspect()
ChromiumInspector.Address = "localhost:8089/json/list";
InspectorContainer.Visibility = IsUtilityContainerOpen ? Visibility.Collapsed : Visibility.Visible;
IsUtilityContainerOpen = !IsUtilityContainerOpen;
+
+ if (ActiveSizeEmulation)
+ SizeEmulator();
}
else
{
@@ -726,21 +854,21 @@ public void Inspect()
}
public void Favourite()
{
- string Url;
+ /*string Url;
string Title;
bool IsLoaded;
Url = Address;
Title = this.Title;
- IsLoaded = !IsLoading;
- int FavouriteExistIndex = FavouriteExists(Url);
+ IsLoaded = !IsLoading;*/
+ int FavouriteExistIndex = FavouriteExists(Address);
if (FavouriteExistIndex != -1)
{
MainWindow.Instance.Favourites.RemoveAt(FavouriteExistIndex);
FavouriteButton.Content = "\xEB51";
}
- else if (IsLoaded)
+ else if (!IsLoading)
{
- MainWindow.Instance.Favourites.Add(new ActionStorage(Title, $"3<,>{Url}", Url));
+ MainWindow.Instance.Favourites.Add(new ActionStorage(this.Title, $"3<,>{Address}", Address));
FavouriteButton.Content = "\xEB52";
}
if (MainWindow.Instance.Favourites.Count == 0)
@@ -805,25 +933,43 @@ public void Zoom(int Delta)
}
public async void Screenshot()
{
- if (BrowserType == 0)
+ try
{
- string ScreenshotPath = MainSave.Get("ScreenshotPath");
- if (!Directory.Exists(ScreenshotPath))
- Directory.CreateDirectory(ScreenshotPath);
- using (var _DevToolsClient = Chromium.GetDevToolsClient())
+ if (BrowserType == 0)
{
+ string ScreenshotPath = MainSave.Get("ScreenshotPath");
+ if (!Directory.Exists(ScreenshotPath))
+ Directory.CreateDirectory(ScreenshotPath);
+ string _ScreenshotFormat = MainWindow.Instance.MainSave.Get("ScreenshotFormat");
+ string FileExtension = "jpg";
+ CaptureScreenshotFormat ScreenshotFormat = CaptureScreenshotFormat.Jpeg;
+ if (_ScreenshotFormat == "Png")
+ {
+ FileExtension = "png";
+ ScreenshotFormat = CaptureScreenshotFormat.Png;
+ }
+ else if (_ScreenshotFormat == "WebP")
+ {
+ FileExtension = "webp";
+ ScreenshotFormat = CaptureScreenshotFormat.Webp;
+ }
DateTime CurrentTime = DateTime.Now;
- string Url = $"{Path.Combine(ScreenshotPath, Regex.Replace($"{Chromium.Title} {CurrentTime.Day}-{CurrentTime.Month}-{CurrentTime.Year} {string.Format("{0:hh:mm tt}", DateTime.Now)}.jpg", "[^a-zA-Z0-9._ -]", ""))}";
- var result = await _DevToolsClient.Page.CaptureScreenshotAsync(CefSharp.DevTools.Page.CaptureScreenshotFormat.Jpeg, null, null, null, false);
- File.WriteAllBytes(Url, result.Data);
- //Navigate(true, "file:///////" + Url);
+ string Url = $"{Path.Combine(ScreenshotPath, Regex.Replace($"{Chromium.Title} {CurrentTime.Day}-{CurrentTime.Month}-{CurrentTime.Year} {string.Format("{0:hh:mm tt}", DateTime.Now)}.{FileExtension}", "[^a-zA-Z0-9._ -]", ""))}";
+ using (var _DevToolsClient = Chromium.GetDevToolsClient())
+ {
+ var result = await _DevToolsClient.Page.CaptureScreenshotAsync(ScreenshotFormat, null, null, null, false);
+ File.WriteAllBytes(Url, result.Data);
+ //File.SetAttributes(Url, FileAttributes.Normal);
+ //Navigate(true, "file:///////" + Url);
+ }
}
}
+ catch { }
}
public void QRCode(string Url)
{
if (!QRCodePopup.IsOpen)
- QRCodeImage.Source = Utils.BitmapToImageSource(MainWindow.Instance._QRCodeHandler.GenerateQRCode(Url));
+ QRCodeImage.Source = MainWindow.Instance._QRCodeHandler.GenerateQRCode(Url).ToImageSource();
QRCodePopup.IsOpen = !QRCodePopup.IsOpen;
}
public bool IsAudioMuted;
@@ -836,11 +982,17 @@ private void FavouriteScrollViewer_PreviewMouseWheel(object sender, MouseWheelEv
public void ApplyTheme(Theme _Theme)
{
- Resources["PrimaryBrush"] = new SolidColorBrush(_Theme.PrimaryColor);
- Resources["FontBrush"] = new SolidColorBrush(_Theme.FontColor);
- Resources["BorderBrush"] = new SolidColorBrush(_Theme.BorderColor);
- Resources["UnselectedTabBrush"] = new SolidColorBrush(_Theme.UnselectedTabColor);
- Resources["ControlFontBrush"] = new SolidColorBrush(_Theme.ControlFontColor);
+ //Resources["PrimaryBrush"] = new SolidColorBrush(_Theme.PrimaryColor);
+ //Resources["FontBrush"] = new SolidColorBrush(_Theme.FontColor);
+ //Resources["BorderBrush"] = new SolidColorBrush(_Theme.BorderColor);
+ //Resources["UnselectedTabBrush"] = new SolidColorBrush(_Theme.UnselectedTabColor);
+ //Resources["ControlFontBrush"] = new SolidColorBrush(_Theme.ControlFontColor);
+
+ Resources["PrimaryBrushColor"] = _Theme.PrimaryColor;
+ Resources["FontBrushColor"] = _Theme.FontColor;
+ Resources["BorderBrushColor"] = _Theme.BorderColor;
+ Resources["UnselectedTabBrushColor"] = _Theme.UnselectedTabColor;
+ Resources["ControlFontBrushColor"] = _Theme.ControlFontColor;
}
bool AddressBoxFocused;
@@ -890,6 +1042,7 @@ private void AddressBox_PreviewKeyDown(object sender, KeyEventArgs e)
AddressBoxPlaceholder.Text = "";
}*/
}
+ AddressBoxPlaceholder.Text = "";
}
else
{
@@ -949,6 +1102,7 @@ private void AddressBox_LostFocus(object sender, RoutedEventArgs e)
{
try
{
+ AddressBoxPlaceholder.Text = "";
if (Utils.CleanUrl(AddressBox.Text) == Utils.CleanUrl(AddressBox.Tag.ToString()))
AddressBox.Text = Utils.ConvertUrlToReadableUrl(MainWindow.Instance._IdnMapping, bool.Parse(MainSave.Get("FullAddress")) ? AddressBox.Tag.ToString() : Utils.CleanUrl(AddressBox.Tag.ToString()));
}
@@ -976,6 +1130,7 @@ private void AddressBox_MouseLeave(object sender, MouseEventArgs e)
{
try
{
+ AddressBoxPlaceholder.Text = "";
if (Utils.CleanUrl(AddressBox.Text) == Utils.CleanUrl(AddressBox.Tag.ToString()))
AddressBox.Text = Utils.ConvertUrlToReadableUrl(MainWindow.Instance._IdnMapping, bool.Parse(MainSave.Get("FullAddress")) ? AddressBox.Tag.ToString() : Utils.CleanUrl(AddressBox.Tag.ToString()));
}
@@ -998,7 +1153,7 @@ private void FindTextBox_KeyDown(object sender, KeyEventArgs e)
public void DisposeCore()
{
CoreContainer.Children.Clear();
- InspectorContainer.Children.Clear();
+ InspectorCoreContainer.Children.Clear();
if (BrowserType == 0)
{
Chromium.Dispose();
@@ -1007,11 +1162,47 @@ public void DisposeCore()
else// if (BrowserType == 2)
{
IE.BrowserCore.Dispose();
- IEInspector.BrowserCore.Dispose();
+ //IEInspector.BrowserCore.Dispose();
}
GC.SuppressFinalize(this);
}
+ Size MaximizedSize = Size.Empty;
+ Size PreviousSize = Size.Empty;
+ private void CoreContainer_SizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ Size NewSize = new Size(CoreContainerSizeEmulator.ActualWidth, CoreContainerSizeEmulator.ActualHeight);
+ if (MaximizedSize == Size.Empty)
+ MaximizedSize = NewSize;
+ Size Percentage = new Size(NewSize.Width / MaximizedSize.Width, NewSize.Height / MaximizedSize.Height);
+
+ SizeEmulatorColumn1.MaxWidth = 900 * Percentage.Width;
+ SizeEmulatorColumn2.MaxWidth = 900 * Percentage.Width;
+ SizeEmulatorRow1.MaxHeight = 400 * Percentage.Height;
+ SizeEmulatorRow2.MaxHeight = 400 * Percentage.Height;
+
+ //if (PreviousSize == NewSize)
+ //{
+ SizeEmulatorColumn1.Width = new GridLength(0);
+ SizeEmulatorColumn2.Width = new GridLength(0);
+ SizeEmulatorRow1.Height = new GridLength(0);
+ SizeEmulatorRow2.Height = new GridLength(0);
+ //}
+
+ PreviousSize = NewSize;
+ //ToastBox.Show("", NewSize.ToString() + $" {Percentage}", 10);
+
+ //if (SizeEmulatorColumn1.Width.Value > SizeEmulatorColumn1.MaxWidth)
+ // SizeEmulatorColumn1.Width = new GridLength(SizeEmulatorColumn1.MaxWidth);
+ //if (SizeEmulatorColumn2.Width.Value > SizeEmulatorColumn2.MaxWidth)
+ // SizeEmulatorColumn2.Width = new GridLength(SizeEmulatorColumn2.MaxWidth);
+ //if (SizeEmulatorRow1.Height.Value > SizeEmulatorRow1.MaxHeight)
+ // SizeEmulatorRow1.Height = new GridLength(SizeEmulatorRow1.MaxHeight);
+ //if (SizeEmulatorRow2.Height.Value > SizeEmulatorRow2.MaxHeight)
+ // SizeEmulatorRow2.Height = new GridLength(SizeEmulatorRow2.MaxHeight);
+ //MessageBox.Show(NewSize.ToString() + $" {Percentage}");
+ }
+
/*private void CoreContainer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if ((Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.Control)
diff --git a/SLBr/Pages/Settings.xaml b/SLBr/Pages/Settings.xaml
index dd127b2..e3fd591 100644
--- a/SLBr/Pages/Settings.xaml
+++ b/SLBr/Pages/Settings.xaml
@@ -80,7 +80,8 @@
Service improvement
-
+
+
@@ -117,6 +118,8 @@
+
+
@@ -143,6 +146,7 @@
Optimize performance
+
@@ -179,7 +183,9 @@
-
+
+
+
@@ -215,8 +221,8 @@
repository
.
-
-
+
+
@@ -74,62 +76,62 @@
diff --git a/SLBr/Resources/Tetris.html b/SLBr/Resources/Tetris.html
new file mode 100644
index 0000000..d22b796
--- /dev/null
+++ b/SLBr/Resources/Tetris.html
@@ -0,0 +1,43 @@
+
+
+
+ SLBr Tetris
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
\ No newline at end of file
diff --git a/SLBr/Resources/Tetris.js b/SLBr/Resources/Tetris.js
new file mode 100644
index 0000000..f80c9a5
--- /dev/null
+++ b/SLBr/Resources/Tetris.js
@@ -0,0 +1,267 @@
+const canvas = document.querySelector('canvas')
+const ctx = canvas.getContext('2d')
+
+let config = {
+ map_width: canvas.width,
+ map_height: canvas.height,
+ rows: 20,
+ cols: 10,
+ stroke: '#808080',
+ bg: '#fff',
+ border_size: 0.5
+}
+config.size = config.map_width / config.cols
+canvas.style.outline = `${config.border_size}px solid ${config.stroke}`
+canvas.style.borderRadius = `10px`
+let prev_time = 0,
+ prev_pos = { x: 0, y: 0 },
+ prev_block = [[]],
+ move_down = 500,
+ fps = 100,
+ frame_count = 0,
+ score = 0
+
+const colors = [
+ 'limegreen',
+ 'darkorange',
+ 'mediumorchid',
+ 'dodgerblue',
+ 'orangered',
+ 'cornflowerblue',
+ 'tomato'
+]
+
+const types = {
+ 'z': [
+ [1, 1, 0],
+ [0, 1, 1],
+ [0, 0, 0]
+ ],
+ 's': [
+ [0, 2, 2],
+ [2, 2, 0],
+ [0, 0, 0]
+ ],
+ 'i': [
+ [0, 3, 0, 0],
+ [0, 3, 0, 0],
+ [0, 3, 0, 0],
+ [0, 3, 0, 0]
+ ],
+ 'l': [
+ [4, 0, 0],
+ [4, 0, 0],
+ [4, 4, 0]
+ ],
+ 'j': [
+ [0, 0, 5],
+ [0, 0, 5],
+ [0, 5, 5]
+ ],
+ 'o': [
+ [6, 6],
+ [6, 6]
+ ],
+ 't': [
+ [0, 7, 0],
+ [7, 7, 7],
+ [0, 0, 0]
+ ]
+}
+
+class Block {
+ constructor(cells, x, y) {
+ this.prevent = true
+ this.cells = cells
+ this.position = { x, y }
+ this.alive = true
+ }
+ collision(field) {
+ const { x, y } = this.position
+ this.cells.forEach((row, i) => {
+ row.forEach((cell, j) => {
+ if (cell && ((y + i >= config.rows) || field[y + i][x + j])) {
+ this.alive = false
+ return
+ }
+ })
+ })
+ }
+ move(e) {
+ switch (e.key) {
+ case 'a':
+ case 'ArrowLeft':
+ this.position.x--
+ break
+
+ case 'd':
+ case 'ArrowRight':
+ this.position.x++
+ break
+
+ case 's':
+ case 'ArrowDown':
+ if (this.position.y + this.cells.length < config.rows) this.position.y++
+ break
+
+ case 'w':
+ case 'ArrowUp':
+ this.rotate()
+ break
+ }
+ }
+ rotate() {
+ let altered = []
+ for (let i = 0; i < this.cells.length; i++) {
+ altered[i] = []
+ for (let j = 0; j < this.cells.length; j++) {
+ altered[i][j] = this.cells[this.cells.length - 1 - j][i]
+ }
+ }
+ this.cells = altered
+ }
+}
+
+const checkMove = (block, field) => {
+ const { cells, position } = block
+ const { x, y } = position
+ return !cells.some((rows, i) => {
+ return rows.some((cell, j) => {
+ if (
+ (cell && x + j < 0) ||
+ (cell && x + j >= config.cols) ||
+ (cell && field[y + i][x + j])
+ ) return true
+ })
+ })
+}
+
+const draw = (field, ctx) => {
+ const { size } = config
+ field.forEach((row, i) => {
+ row.forEach((cell, j) => {
+ ctx.fillStyle = cell ? colors[cell - 1] : config.bg
+ ctx.strokeStyle = config.stroke
+ ctx.lineWidth = config.border_size
+
+ const args = [
+ j * size,
+ i * size,
+ size,
+ size
+ ]
+ ctx.fillRect(...args)
+ ctx.strokeRect(...args)
+
+ })
+ })
+}
+
+const render = (game, block, time) => {
+ if (!block) {
+ const arr_types = Object.values(types)
+ const type = arr_types[arr_types.length * Math.random() | 0]
+ const x = ((config.cols - type.length) / 2) | 0
+ block = new Block(type, x, 0)
+ prev_pos = { x, y: 0 }
+
+ addEventListener('keydown', e =>
+ block.move.bind(block)(e)
+ )
+ }
+ const { ctx, field } = game
+ const { position } = block
+
+ if (time - prev_time > 1000 / fps) {
+ frame_count++
+ if (frame_count == Math.floor((fps * move_down) / 1000)) {
+ frame_count = 0
+ if (block && block.alive) position.y++
+ else block = null
+ }
+ }
+
+ prev_time = time
+
+ insert(prev_block, field, prev_pos.y, prev_pos.x, true)
+
+ if (!checkMove(block, field)) {
+ position.x = prev_pos.x
+ block.cells = prev_block
+ }
+
+ if (position.y > prev_pos.y) {
+ position.y = prev_pos.y + 1
+ }
+
+ block.collision(field)
+
+ if (block.alive) {
+ insert(block.cells, field, position.y, position.x)
+ draw(field, ctx)
+ prev_pos = Object.assign({}, position)
+ prev_block = [].concat(block.cells)
+ }
+ else if (prev_pos.y > block.cells.length - 1) {
+ insert(block.cells, field, prev_pos.y, prev_pos.x)
+ game.field = findFilled(field)
+ draw(game.field, ctx)
+ block = null
+ }
+ else {
+ insert(prev_block, field, prev_pos.y, prev_pos.x)
+
+ let last = block.cells.filter((row) => !row.every((cell) => !cell)).slice(-prev_pos.y)
+ insert(last, field, 0, position.x)
+
+ game.field = generate_field(config.rows + 4, config.cols)
+ update_score(0)
+ draw(game.field, ctx)
+
+ block = null
+ }
+
+ window.requestAnimationFrame((time) => {
+ render(game, block, time)
+ })
+}
+
+const insert = (child, parent, row, col, clear) => {
+ for (let i = 0; i < child.length; i++) {
+ for (let j = 0; j < child.length; j++) {
+ parent[row + i][col + j] = !clear
+ ? child[i][j]
+ ? child[i][j] : parent[row + i][col + j]
+ : child[i][j]
+ ? 0 : parent[row + i][col + j]
+ }
+ }
+}
+
+const update_score = amount => {
+ score = amount
+ document.getElementById('score').innerHTML = amount
+}
+
+const findFilled = field => {
+ const filteredField = field.filter((row) => row.some((cell) => (cell === 0)))
+
+ const diff = field.length - filteredField.length
+ score += diff * 10
+ update_score(score)
+
+ let filled = generate_field(diff, config.cols)
+
+ return [...filled, ...filteredField]
+}
+
+const generate_field = (rows, cols) => {
+ return Array.from({ length: rows }, () => Array.from({ length: cols }, () => 0))
+}
+
+let game = {
+ ctx,
+ field: generate_field(config.rows + 4, config.cols)
+}
+
+render(game)
diff --git a/SLBr/Resources/White Settings Icon.png b/SLBr/Resources/White Settings Icon.png
new file mode 100644
index 0000000..3296028
Binary files /dev/null and b/SLBr/Resources/White Settings Icon.png differ
diff --git a/SLBr/Resources/White Tab Icon.png b/SLBr/Resources/White Tab Icon.png
new file mode 100644
index 0000000..f6c9a7a
Binary files /dev/null and b/SLBr/Resources/White Tab Icon.png differ
diff --git a/SLBr/Resources/style.css b/SLBr/Resources/style.css
index 8fe0d62..5daf39d 100644
--- a/SLBr/Resources/style.css
+++ b/SLBr/Resources/style.css
@@ -1,4 +1,24 @@
-html {
+[data-title]:hover:after {
+ opacity: 1;
+ transition: all 0.2s ease 0.6s;
+ visibility: visible;
+ font-family: 'Segoe UI Light', Tahoma, sans-serif;
+ font-size: 15px;
+}
+
+[data-title]:after {
+ content: attr(data-title);
+ position: absolute;
+ padding: 2.5px 5px;
+ color: black;
+ border-radius: 5px;
+ background: white;
+ visibility: hidden;
+ border: 1px solid gainsboro;
+ white-space: nowrap;
+}
+
+html {
background: white;
}
diff --git a/SLBr/SLBr.csproj b/SLBr/SLBr.csproj
index 724d9a9..4b3aa91 100644
--- a/SLBr/SLBr.csproj
+++ b/SLBr/SLBr.csproj
@@ -2,15 +2,27 @@
WinExe
- net6.0-windows
+ net6.0-windows7.0
enable
true
7.0
SLBr.Program
Resources\SLBr.ico
+ False
+ true
+ False
+ Copyright SLT World. All rights reserved.
+ https://github.com/SLT-World/SLBr
+ False
+ False
+ 2022.10.10.0
+ 2022.10.10.0
+ 2022.10.10.0
+ SLT World
+
@@ -21,8 +33,9 @@
-
-
+
+
+
@@ -35,6 +48,12 @@
+
+ PreserveNewest
+
+
+ Never
+
PreserveNewest
@@ -44,6 +63,9 @@
PreserveNewest
+
+ PreserveNewest
+
PreserveNewest
@@ -65,24 +87,54 @@
PreserveNewest
-
+
Never
PreserveNewest
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ Never
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
-
+
-
+
-
+
diff --git a/SLBr/SplashScreen.xaml b/SLBr/SplashScreen.xaml
new file mode 100644
index 0000000..b7dc629
--- /dev/null
+++ b/SLBr/SplashScreen.xaml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SLBr/SplashScreen.xaml.cs b/SLBr/SplashScreen.xaml.cs
new file mode 100644
index 0000000..a9c40e1
--- /dev/null
+++ b/SLBr/SplashScreen.xaml.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Media.Imaging;
+using System.Windows.Threading;
+
+namespace SLBr
+{
+ ///
+ /// Interaction logic for SplashScreen.xaml
+ ///
+ public partial class SplashScreen : Window
+ {
+ public static SplashScreen Instance;
+
+ MainWindow _Window;
+ //BackgroundWorker ProgressWorker;
+
+ public SplashScreen()
+ {
+ Instance = this;
+ InitializeComponent();
+ Icon.Source = new BitmapImage(new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Resources", "SLBr.ico")));
+
+ /*ProgressWorker = new BackgroundWorker();
+ ProgressWorker.WorkerReportsProgress = true;
+ ProgressWorker.DoWork += ProgressWorker_DoWork;
+ ProgressWorker.ProgressChanged += ProgressWorker_ProgressChanged;
+ ProgressWorker.RunWorkerCompleted += ProgressWorker_RunWorkerCompleted;
+ ProgressWorker.RunWorkerAsync();*/
+
+ new MainWindow();
+ /*_Window = new MainWindow(ProgressWorker);
+ var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) };
+ timer.Start();
+ timer.Tick += (sender, args) =>
+ {
+ timer.Stop();
+ };*/
+ }
+
+ public void ReportProgress(int ProgressPercentage, string UserState)
+ {
+ LoadingProgress.Value = ProgressPercentage;
+ ProgressStatus.Text = UserState;
+
+ if (ProgressPercentage == 100)
+ MainWindow.Instance.Show();
+ }
+
+ /*private void ProgressWorker_RunWorkerCompleted(object? sender, RunWorkerCompletedEventArgs e)
+ {
+ _Window.Show();
+ }
+
+ private void ProgressWorker_ProgressChanged(object? sender, ProgressChangedEventArgs e)
+ {
+ LoadingProgress.Value = e.ProgressPercentage;
+ //Thread.Sleep(1000);
+ ProgressStatus.Text = (string)e.UserState;
+ }
+
+ private void ProgressWorker_DoWork(object? sender, DoWorkEventArgs e)
+ {
+ //ProgressWorker.ReportProgress(0, "Processing...");
+ for (int i = 0; i < 1000; i++)
+ {
+ //ProgressWorker.ReportProgress(i, $"Processing interation {i}...");
+ //Thread.Sleep(i);
+ }
+ //ProgressWorker.ReportProgress(100, "Done processing.");
+ }*/
+ }
+}
diff --git a/SLBr/StyleResourceDictionary.xaml b/SLBr/StyleResourceDictionary.xaml
index f861ed0..46db5db 100644
--- a/SLBr/StyleResourceDictionary.xaml
+++ b/SLBr/StyleResourceDictionary.xaml
@@ -1,17 +1,31 @@
-
+
+
+
+
+
+
+
+
+
+ Gainsboro
+ White
+ WhiteSmoke
+ Black
+ Gray
+ #0092FF
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
@@ -125,13 +256,14 @@
-
-
+
+
+
-
-
+
+
@@ -139,6 +271,9 @@
+
+
+
diff --git a/SLBr/StyleResourceDictionaryCode.cs b/SLBr/StyleResourceDictionaryCode.cs
index 9a69183..0ee01c1 100644
--- a/SLBr/StyleResourceDictionaryCode.cs
+++ b/SLBr/StyleResourceDictionaryCode.cs
@@ -1,11 +1,14 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
+using System.Windows.Media.Imaging;
namespace SLBr
{
@@ -13,7 +16,10 @@ public partial class StyleResourceDictionaryCode
{
private void Image_ImageFailed(object sender, ExceptionRoutedEventArgs e)
{
- ((Image)sender).Visibility = Visibility.Collapsed;
+ int TabId = int.Parse(((Image)sender).Tag.ToString());
+ //((Image)sender).Source = new BitmapImage(new Uri("https://example.com/abc.png"));
+ MainWindow.Instance.GetBrowserTabWithId(TabId).Icon = new BitmapImage(new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Resources", (MainWindow.Instance.GetTheme().DarkTitleBar ? "White Tab Icon.png" : "Black Tab Icon.png"))));
+ //((Image)sender).Visibility = Visibility.Collapsed;
}
public void ButtonAction(object sender, RoutedEventArgs e)
@@ -36,14 +42,18 @@ private void TabItem_PreviewMouseMove(object sender, MouseEventArgs e)
private void TabItem_Drop(object sender, DragEventArgs e)
{
+ //MessageBox.Show(e.Source.GetType().ToString());
if (e.Source is TabItem tabItemTarget && e.Data.GetData(typeof(TabItem)) is TabItem tabItemSource && !tabItemTarget.Equals(tabItemSource) && tabItemTarget.Parent is TabControl tabControl)
//Remove the last check if multi tabcontrols
{
int targetIndex = tabControl.Items.IndexOf(tabItemTarget);
- tabControl.Items.Remove(tabItemSource);
- tabControl.Items.Insert(targetIndex, tabItemSource);
- tabItemSource.IsSelected = true;
+ //int targetIndex = MainWindow.Instance.Tabs[tabControl.Items.IndexOf(tabItemTarget)];
+ BrowserTabItem _TabItemSource = MainWindow.Instance.Tabs[targetIndex];
+ MainWindow.Instance.Tabs.Remove(_TabItemSource);
+ MainWindow.Instance.Tabs.Insert(targetIndex, _TabItemSource);
+ tabControl.SelectedIndex = targetIndex;
+ //tabItemSource.IsSelected = true;
}
}
}
diff --git a/SLBr/Unused Resources/Black Sustainable Icon.png b/SLBr/Unused Resources/Black Sustainable Icon.png
new file mode 100644
index 0000000..d603c26
Binary files /dev/null and b/SLBr/Unused Resources/Black Sustainable Icon.png differ
diff --git a/SLBr/Unused Resources/Green Sustainable Icon 2.png b/SLBr/Unused Resources/Green Sustainable Icon 2.png
new file mode 100644
index 0000000..4aa339e
Binary files /dev/null and b/SLBr/Unused Resources/Green Sustainable Icon 2.png differ
diff --git a/SLBr/Unused Resources/SLBr.reg b/SLBr/Unused Resources/SLBr.reg
new file mode 100644
index 0000000..fca6f23
--- /dev/null
+++ b/SLBr/Unused Resources/SLBr.reg
@@ -0,0 +1,122 @@
+Windows Registry Editor Version 5.00
+
+[HKEY_CLASSES_ROOT\SLBr]
+@="SLBr"
+"AppUserModelId"="SLBr"
+
+[HKEY_CLASSES_ROOT\SLBr\Application]
+"AppUserModelId" = "SLBr"
+"ApplicationIcon"="E:\Visual Studio\SLBr\SLBr\bin\Debug\net6.0-windows\SLBr.exe,0"
+"ApplicationName"="SLBr"
+"ApplicationCompany"="SLT World"
+"ApplicationDescription"="Browse the web with a fast, lightweight web browser."
+
+[HKEY_CLASSES_ROOT\SLBr\DefaultIcon]
+@="E:\Visual Studio\SLBr\SLBr\bin\Debug\net6.0-windows\SLBr.exe,0"
+
+[HKEY_CLASSES_ROOT\SLBr\shell]
+
+[HKEY_CLASSES_ROOT\SLBr\shell\open]
+
+[HKEY_CLASSES_ROOT\SLBr\shell\open\command]
+@="\"E:\Visual Studio\SLBr\SLBr\bin\Debug\net6.0-windows\SLBr.exe\" % 1"
+
+[HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\SLBr]
+@="SLBr"
+
+[HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\SLBr\Capabilities]
+"ApplicationName"="SLBr"
+"ApplicationIcon"="E:\Visual Studio\SLBr\SLBr\bin\Debug\net6.0-windows\SLBr.exe,0"
+"ApplicationDescription"="SLBr, the browser that prioritizes a faster web"
+
+[HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\SLBr\Capabilities\FileAssociations]=
+".xhtml"="SLBr"
+".xht"="SLBr"
+".shtml"="SLBr"
+".html"="SLBr"
+".htm"="SLBr"
+".pdf"="SLBr"
+".svg"="SLBr"
+".webp"="SLBr"
+
+[HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\SLBr\Capabilities\StartMenu]
+"StartMenuInternet"="SLBr"
+
+[HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\SLBr\Capabilities\URLAssociations]
+"https"="SLBr"
+"http"="SLBr"
+
+[HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\SLBr\DefaultIcon]
+@="E:\Visual Studio\SLBr\SLBr\bin\Debug\net6.0-windows\SLBr.exe,0"
+
+[HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\SLBr\InstallInfo]
+"IconsVisible"=dword:00000001
+"ShowIconsCommand"="\"E:\Visual Studio\SLBr\SLBr\bin\Debug\net6.0-windows\SLBr.exe\"--show-icons"
+"HideIconsCommand"="\"E:\Visual Studio\SLBr\SLBr\bin\Debug\net6.0-windows\SLBr.exe\" --hide-icons"
+"ReinstallCommand"="\"E:\Visual Studio\SLBr\SLBr\bin\Debug\net6.0-windows\SLBr.exe\" --make-default-browser"
+
+[HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\SLBr\shell]
+
+[HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\SLBr\shell\open]
+
+[HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\SLBr\shell\open\command]
+@="\"E:\Visual Studio\SLBr\SLBr\bin\Debug\net6.0-windows\SLBr.exe\""
+
+[HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\SLBr]
+@="SLBr"
+
+[HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\SLBr\Capabilities]
+"ApplicationName"="SLBr"
+"ApplicationIcon"="E:\Visual Studio\SLBr\SLBr\bin\Debug\net6.0-windows\SLBr.exe,0"
+"ApplicationDescription"="SLBr, the browser that prioritizes a faster web"
+
+[HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\SLBr\Capabilities\FileAssociations]=
+".xhtml"="SLBr"
+".xht"="SLBr"
+".shtml"="SLBr"
+".html"="SLBr"
+".htm"="SLBr"
+".pdf"="SLBr"
+".svg"="SLBr"
+".webp"="SLBr"
+
+[HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\SLBr\Capabilities\StartMenu]
+"StartMenuInternet"="SLBr"
+
+[HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\SLBr\Capabilities\URLAssociations]
+"https"="SLBr"
+"http"="SLBr"
+
+[HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\SLBr\DefaultIcon]
+@="E:\Visual Studio\SLBr\SLBr\bin\Debug\net6.0-windows\SLBr.exe,0"
+
+[HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\SLBr\InstallInfo]
+"IconsVisible"=dword:00000001
+"ShowIconsCommand"="\"E:\Visual Studio\SLBr\SLBr\bin\Debug\net6.0-windows\SLBr.exe\"--show-icons"
+"HideIconsCommand"="\"E:\Visual Studio\SLBr\SLBr\bin\Debug\net6.0-windows\SLBr.exe\" --hide-icons"
+"ReinstallCommand"="\"E:\Visual Studio\SLBr\SLBr\bin\Debug\net6.0-windows\SLBr.exe\" --make-default-browser"
+
+[HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\SLBr\shell]
+
+[HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\SLBr\shell\open]
+
+[HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\SLBr\shell\open\command]
+@="\"E:\Visual Studio\SLBr\SLBr\bin\Debug\net6.0-windows\SLBr.exe\""
+
+[HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations]
+
+[HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http]
+
+[HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice]
+"ProgId"="SLBr"
+
+[HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https]
+
+[HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice]
+"ProgId"="SLBr"
+
+[HKEY_CURRENT_USER\Software\RegisteredApplications]
+"SLBr"="Software\Clients\StartMenuInternet\SLBr\Capabilities"
+
+[HKEY_LOCAL_MACHINE\Software\RegisteredApplications]
+"SLBr"="Software\Clients\StartMenuInternet\SLBr\Capabilities"
\ No newline at end of file
diff --git a/SLBr/Unused Resources/White Sustainable Icon.png b/SLBr/Unused Resources/White Sustainable Icon.png
new file mode 100644
index 0000000..9d64628
Binary files /dev/null and b/SLBr/Unused Resources/White Sustainable Icon.png differ
diff --git a/SLBr/Utility Service.deps.json b/SLBr/Utility Service.deps.json
new file mode 100644
index 0000000..c325bbb
--- /dev/null
+++ b/SLBr/Utility Service.deps.json
@@ -0,0 +1,424 @@
+{
+ "runtimeTarget": {
+ "name": ".NETCoreApp,Version=v6.0",
+ "signature": ""
+ },
+ "compilationOptions": {},
+ "targets": {
+ ".NETCoreApp,Version=v6.0": {
+ "Utility Service/1.0.0": {
+ "dependencies": {
+ "CefSharp.Common.NETCore": "106.0.260",
+ "chromiumembeddedframework.runtime.win-arm64": "106.0.26",
+ "chromiumembeddedframework.runtime.win-x64": "106.0.26",
+ "chromiumembeddedframework.runtime.win-x86": "106.0.26"
+ },
+ "runtime": {
+ "Utility Service.dll": {}
+ }
+ },
+ "CefSharp.Common.NETCore/106.0.260": {
+ "dependencies": {
+ "chromiumembeddedframework.runtime": "106.0.26"
+ },
+ "runtimeTargets": {
+ "runtimes/win-arm64/lib/netcoreapp3.1/CefSharp.Core.Runtime.dll": {
+ "rid": "win-arm64",
+ "assetType": "runtime",
+ "assemblyVersion": "106.0.260.0",
+ "fileVersion": "106.0.260.0"
+ },
+ "runtimes/win-arm64/lib/netcoreapp3.1/CefSharp.Core.dll": {
+ "rid": "win-arm64",
+ "assetType": "runtime",
+ "assemblyVersion": "106.0.260.0",
+ "fileVersion": "106.0.260.0"
+ },
+ "runtimes/win-arm64/lib/netcoreapp3.1/CefSharp.dll": {
+ "rid": "win-arm64",
+ "assetType": "runtime",
+ "assemblyVersion": "106.0.260.0",
+ "fileVersion": "106.0.260.0"
+ },
+ "runtimes/win-arm64/lib/netcoreapp3.1/Ijwhost.dll": {
+ "rid": "win-arm64",
+ "assetType": "runtime",
+ "fileVersion": "3.100.2822.36306"
+ },
+ "runtimes/win-x64/lib/netcoreapp3.1/CefSharp.Core.Runtime.dll": {
+ "rid": "win-x64",
+ "assetType": "runtime",
+ "assemblyVersion": "106.0.260.0",
+ "fileVersion": "106.0.260.0"
+ },
+ "runtimes/win-x64/lib/netcoreapp3.1/CefSharp.Core.dll": {
+ "rid": "win-x64",
+ "assetType": "runtime",
+ "assemblyVersion": "106.0.260.0",
+ "fileVersion": "106.0.260.0"
+ },
+ "runtimes/win-x64/lib/netcoreapp3.1/CefSharp.dll": {
+ "rid": "win-x64",
+ "assetType": "runtime",
+ "assemblyVersion": "106.0.260.0",
+ "fileVersion": "106.0.260.0"
+ },
+ "runtimes/win-x64/lib/netcoreapp3.1/Ijwhost.dll": {
+ "rid": "win-x64",
+ "assetType": "runtime",
+ "fileVersion": "3.100.2822.36306"
+ },
+ "runtimes/win-x86/lib/netcoreapp3.1/CefSharp.Core.Runtime.dll": {
+ "rid": "win-x86",
+ "assetType": "runtime",
+ "assemblyVersion": "106.0.260.0",
+ "fileVersion": "106.0.260.0"
+ },
+ "runtimes/win-x86/lib/netcoreapp3.1/CefSharp.Core.dll": {
+ "rid": "win-x86",
+ "assetType": "runtime",
+ "assemblyVersion": "106.0.260.0",
+ "fileVersion": "106.0.260.0"
+ },
+ "runtimes/win-x86/lib/netcoreapp3.1/CefSharp.dll": {
+ "rid": "win-x86",
+ "assetType": "runtime",
+ "assemblyVersion": "106.0.260.0",
+ "fileVersion": "106.0.260.0"
+ },
+ "runtimes/win-x86/lib/netcoreapp3.1/Ijwhost.dll": {
+ "rid": "win-x86",
+ "assetType": "runtime",
+ "fileVersion": "3.100.2822.36306"
+ },
+ "runtimes/win-arm64/native/CefSharp.BrowserSubprocess.Core.dll": {
+ "rid": "win-arm64",
+ "assetType": "native",
+ "assemblyVersion": "106.0.260.0",
+ "fileVersion": "106.0.260.0"
+ },
+ "runtimes/win-arm64/native/CefSharp.BrowserSubprocess.dll": {
+ "rid": "win-arm64",
+ "assetType": "native",
+ "assemblyVersion": "106.0.260.0",
+ "fileVersion": "106.0.260.0"
+ },
+ "runtimes/win-arm64/native/CefSharp.BrowserSubprocess.exe": {
+ "rid": "win-arm64",
+ "assetType": "native",
+ "fileVersion": "106.0.260.0"
+ },
+ "runtimes/win-arm64/native/CefSharp.BrowserSubprocess.runtimeconfig.json": {
+ "rid": "win-arm64",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-x64/native/CefSharp.BrowserSubprocess.Core.dll": {
+ "rid": "win-x64",
+ "assetType": "native",
+ "assemblyVersion": "106.0.260.0",
+ "fileVersion": "106.0.260.0"
+ },
+ "runtimes/win-x64/native/CefSharp.BrowserSubprocess.dll": {
+ "rid": "win-x64",
+ "assetType": "native",
+ "assemblyVersion": "106.0.260.0",
+ "fileVersion": "106.0.260.0"
+ },
+ "runtimes/win-x64/native/CefSharp.BrowserSubprocess.exe": {
+ "rid": "win-x64",
+ "assetType": "native",
+ "fileVersion": "106.0.260.0"
+ },
+ "runtimes/win-x64/native/CefSharp.BrowserSubprocess.runtimeconfig.json": {
+ "rid": "win-x64",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-x86/native/CefSharp.BrowserSubprocess.Core.dll": {
+ "rid": "win-x86",
+ "assetType": "native",
+ "assemblyVersion": "106.0.260.0",
+ "fileVersion": "106.0.260.0"
+ },
+ "runtimes/win-x86/native/CefSharp.BrowserSubprocess.dll": {
+ "rid": "win-x86",
+ "assetType": "native",
+ "assemblyVersion": "106.0.260.0",
+ "fileVersion": "106.0.260.0"
+ },
+ "runtimes/win-x86/native/CefSharp.BrowserSubprocess.exe": {
+ "rid": "win-x86",
+ "assetType": "native",
+ "fileVersion": "106.0.260.0"
+ },
+ "runtimes/win-x86/native/CefSharp.BrowserSubprocess.runtimeconfig.json": {
+ "rid": "win-x86",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ }
+ }
+ },
+ "chromiumembeddedframework.runtime/106.0.26": {},
+ "chromiumembeddedframework.runtime.win-arm64/106.0.26": {
+ "runtimeTargets": {
+ "runtimes/win-arm64/native/chrome_100_percent.pak": {
+ "rid": "win-arm64",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-arm64/native/chrome_200_percent.pak": {
+ "rid": "win-arm64",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-arm64/native/chrome_elf.dll": {
+ "rid": "win-arm64",
+ "assetType": "native",
+ "fileVersion": "106.0.5249.91"
+ },
+ "runtimes/win-arm64/native/icudtl.dat": {
+ "rid": "win-arm64",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-arm64/native/libEGL.dll": {
+ "rid": "win-arm64",
+ "assetType": "native",
+ "fileVersion": "2.1.19296.0"
+ },
+ "runtimes/win-arm64/native/libGLESv2.dll": {
+ "rid": "win-arm64",
+ "assetType": "native",
+ "fileVersion": "2.1.19296.0"
+ },
+ "runtimes/win-arm64/native/libcef.dll": {
+ "rid": "win-arm64",
+ "assetType": "native",
+ "fileVersion": "106.0.26.0"
+ },
+ "runtimes/win-arm64/native/resources.pak": {
+ "rid": "win-arm64",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-arm64/native/snapshot_blob.bin": {
+ "rid": "win-arm64",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-arm64/native/v8_context_snapshot.bin": {
+ "rid": "win-arm64",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-arm64/native/vk_swiftshader.dll": {
+ "rid": "win-arm64",
+ "assetType": "native",
+ "fileVersion": "5.0.0.1"
+ },
+ "runtimes/win-arm64/native/vk_swiftshader_icd.json": {
+ "rid": "win-arm64",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-arm64/native/vulkan-1.dll": {
+ "rid": "win-arm64",
+ "assetType": "native",
+ "fileVersion": "1.0.1111.2222"
+ }
+ }
+ },
+ "chromiumembeddedframework.runtime.win-x64/106.0.26": {
+ "runtimeTargets": {
+ "runtimes/win-x64/native/chrome_100_percent.pak": {
+ "rid": "win-x64",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-x64/native/chrome_200_percent.pak": {
+ "rid": "win-x64",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-x64/native/chrome_elf.dll": {
+ "rid": "win-x64",
+ "assetType": "native",
+ "fileVersion": "106.0.5249.91"
+ },
+ "runtimes/win-x64/native/d3dcompiler_47.dll": {
+ "rid": "win-x64",
+ "assetType": "native",
+ "fileVersion": "10.0.20348.1"
+ },
+ "runtimes/win-x64/native/icudtl.dat": {
+ "rid": "win-x64",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-x64/native/libEGL.dll": {
+ "rid": "win-x64",
+ "assetType": "native",
+ "fileVersion": "2.1.19296.0"
+ },
+ "runtimes/win-x64/native/libGLESv2.dll": {
+ "rid": "win-x64",
+ "assetType": "native",
+ "fileVersion": "2.1.19296.0"
+ },
+ "runtimes/win-x64/native/libcef.dll": {
+ "rid": "win-x64",
+ "assetType": "native",
+ "fileVersion": "106.0.26.0"
+ },
+ "runtimes/win-x64/native/resources.pak": {
+ "rid": "win-x64",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-x64/native/snapshot_blob.bin": {
+ "rid": "win-x64",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-x64/native/v8_context_snapshot.bin": {
+ "rid": "win-x64",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-x64/native/vk_swiftshader.dll": {
+ "rid": "win-x64",
+ "assetType": "native",
+ "fileVersion": "5.0.0.1"
+ },
+ "runtimes/win-x64/native/vk_swiftshader_icd.json": {
+ "rid": "win-x64",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-x64/native/vulkan-1.dll": {
+ "rid": "win-x64",
+ "assetType": "native",
+ "fileVersion": "1.0.1111.2222"
+ }
+ }
+ },
+ "chromiumembeddedframework.runtime.win-x86/106.0.26": {
+ "runtimeTargets": {
+ "runtimes/win-x86/native/chrome_100_percent.pak": {
+ "rid": "win-x86",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-x86/native/chrome_200_percent.pak": {
+ "rid": "win-x86",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-x86/native/chrome_elf.dll": {
+ "rid": "win-x86",
+ "assetType": "native",
+ "fileVersion": "106.0.5249.91"
+ },
+ "runtimes/win-x86/native/d3dcompiler_47.dll": {
+ "rid": "win-x86",
+ "assetType": "native",
+ "fileVersion": "10.0.20348.1"
+ },
+ "runtimes/win-x86/native/icudtl.dat": {
+ "rid": "win-x86",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-x86/native/libEGL.dll": {
+ "rid": "win-x86",
+ "assetType": "native",
+ "fileVersion": "2.1.19296.0"
+ },
+ "runtimes/win-x86/native/libGLESv2.dll": {
+ "rid": "win-x86",
+ "assetType": "native",
+ "fileVersion": "2.1.19296.0"
+ },
+ "runtimes/win-x86/native/libcef.dll": {
+ "rid": "win-x86",
+ "assetType": "native",
+ "fileVersion": "106.0.26.0"
+ },
+ "runtimes/win-x86/native/resources.pak": {
+ "rid": "win-x86",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-x86/native/snapshot_blob.bin": {
+ "rid": "win-x86",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-x86/native/v8_context_snapshot.bin": {
+ "rid": "win-x86",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-x86/native/vk_swiftshader.dll": {
+ "rid": "win-x86",
+ "assetType": "native",
+ "fileVersion": "5.0.0.1"
+ },
+ "runtimes/win-x86/native/vk_swiftshader_icd.json": {
+ "rid": "win-x86",
+ "assetType": "native",
+ "fileVersion": "0.0.0.0"
+ },
+ "runtimes/win-x86/native/vulkan-1.dll": {
+ "rid": "win-x86",
+ "assetType": "native",
+ "fileVersion": "1.0.1111.2222"
+ }
+ }
+ }
+ }
+ },
+ "libraries": {
+ "Utility Service/1.0.0": {
+ "type": "project",
+ "serviceable": false,
+ "sha512": ""
+ },
+ "CefSharp.Common.NETCore/106.0.260": {
+ "type": "package",
+ "serviceable": true,
+ "sha512": "sha512-+6FZ1qplBxGJigwjCXYHGxjb0q5lIXcBVr+24WW31OQL1vVkpgrwiZJQqbKffNF0dz9trKYedIrKlYZOfDttvA==",
+ "path": "cefsharp.common.netcore/106.0.260",
+ "hashPath": "cefsharp.common.netcore.106.0.260.nupkg.sha512"
+ },
+ "chromiumembeddedframework.runtime/106.0.26": {
+ "type": "package",
+ "serviceable": true,
+ "sha512": "sha512-2UqN6IbJexRD0Q+pzzQArXUU/oNdp0lh/2L1wbFllOoTaa4jeRRAi0CVrJBaCJL0geWIDHTpftPKqupu5P7pJQ==",
+ "path": "chromiumembeddedframework.runtime/106.0.26",
+ "hashPath": "chromiumembeddedframework.runtime.106.0.26.nupkg.sha512"
+ },
+ "chromiumembeddedframework.runtime.win-arm64/106.0.26": {
+ "type": "package",
+ "serviceable": true,
+ "sha512": "sha512-bS1WLSGl5Ttpb2eg6RFvOeutWWVHSzXEpMVFMosqCYcNVZtGCt4P+zonh8+G92fnsfxZ0T2M6ONFvX/iVUwaGg==",
+ "path": "chromiumembeddedframework.runtime.win-arm64/106.0.26",
+ "hashPath": "chromiumembeddedframework.runtime.win-arm64.106.0.26.nupkg.sha512"
+ },
+ "chromiumembeddedframework.runtime.win-x64/106.0.26": {
+ "type": "package",
+ "serviceable": true,
+ "sha512": "sha512-hCxR1S4Brp+5g6rM9B344p+hseU4UHfsLUC+sB654/IimwX+4jFDJOkeL1VWNGufh9EEi/cp9rsz8wvkuKtsiA==",
+ "path": "chromiumembeddedframework.runtime.win-x64/106.0.26",
+ "hashPath": "chromiumembeddedframework.runtime.win-x64.106.0.26.nupkg.sha512"
+ },
+ "chromiumembeddedframework.runtime.win-x86/106.0.26": {
+ "type": "package",
+ "serviceable": true,
+ "sha512": "sha512-v/qNwqwtIdXNVA8W0q+AIcmeRhRHAjIC0Rx9vM065HsqwCmQVINzZ8URU6mNULDiVMtUT5r/2GZ98ck3I4UMEA==",
+ "path": "chromiumembeddedframework.runtime.win-x86/106.0.26",
+ "hashPath": "chromiumembeddedframework.runtime.win-x86.106.0.26.nupkg.sha512"
+ }
+ }
+}
\ No newline at end of file
diff --git a/SLBr/Utility Service.dll b/SLBr/Utility Service.dll
new file mode 100644
index 0000000..2f83ea6
Binary files /dev/null and b/SLBr/Utility Service.dll differ
diff --git a/SLBr/Utility Service.exe b/SLBr/Utility Service.exe
new file mode 100644
index 0000000..3a2fb81
Binary files /dev/null and b/SLBr/Utility Service.exe differ
diff --git a/SLBr/Utility Service.runtimeconfig.json b/SLBr/Utility Service.runtimeconfig.json
new file mode 100644
index 0000000..f9988b2
--- /dev/null
+++ b/SLBr/Utility Service.runtimeconfig.json
@@ -0,0 +1,15 @@
+{
+ "runtimeOptions": {
+ "tfm": "net6.0",
+ "frameworks": [
+ {
+ "name": "Microsoft.NETCore.App",
+ "version": "6.0.0"
+ },
+ {
+ "name": "Microsoft.WindowsDesktop.App",
+ "version": "6.0.0"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/SLBr/Utils.cs b/SLBr/Utils.cs
index 72b500e..bdf261a 100644
--- a/SLBr/Utils.cs
+++ b/SLBr/Utils.cs
@@ -1,4 +1,5 @@
using CefSharp;
+using CSCore.CoreAudioAPI;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
@@ -13,10 +14,82 @@
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Text;
+using System.Threading;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
using System.Windows.Media.Imaging;
+using static System.Net.WebRequestMethods;
namespace SLBr
{
+ public enum DWMWINDOWATTRIBUTE
+ {
+ DWMWA_NCRENDERING_ENABLED = 1, // [get] Is non-client rendering enabled/disabled
+ DWMWA_USE_HOSTBACKDROPBRUSH, // [set] BOOL, Allows the use of host backdrop brushes for the window.
+ DWMWA_USE_IMMERSIVE_DARK_MODE = 20, // [set] BOOL, Allows a window to either use the accent color, or dark, according to the user Color Mode preferences.
+ DWMWA_WINDOW_CORNER_PREFERENCE = 33, // [set] WINDOW_CORNER_PREFERENCE, Controls the policy that rounds top-level window corners
+ DWMWA_BORDER_COLOR, // [set] COLORREF, The color of the thin border around a top-level window
+ DWMWA_CAPTION_COLOR, // [set] COLORREF, The color of the caption
+ DWMWA_TEXT_COLOR, // [set] COLORREF, The color of the caption text
+ DWMWA_VISIBLE_FRAME_BORDER_THICKNESS, // [get] UINT, width of the visible border around a thick frame window
+ DWMWA_MICA_EFFECT = 1029, // [set] BOOL, undocumented
+ DWMWA_SYSTEMBACKDROP_TYPE = 38, // [set] INT, undocumented
+ DWMWA_LAST
+ };
+
+ enum DWM_SYSTEMBACKDROP_TYPE
+ {
+ DWMSBT_AUTO = 0,
+ DWMSBT_DISABLE = 1, // None
+ DWMSBT_MAINWINDOW = 2, // Mica
+ DWMSBT_TRANSIENTWINDOW = 3, // Acrylic
+ DWMSBT_TABBEDWINDOW = 4 // Tabbed
+ }
+
+ public static class MonitorMethods
+ {
+ public const Int32 MONITOR_DEFAULTTOPRIMERTY = 0x00000001;
+ public const Int32 MONITOR_DEFAULTTONEAREST = 0x00000002;
+
+
+ [DllImport("user32.dll")]
+ public static extern IntPtr MonitorFromWindow(IntPtr handle, Int32 flags);
+
+
+ [DllImport("user32.dll")]
+ public static extern Boolean GetMonitorInfo(IntPtr hMonitor, NativeMonitorInfo lpmi);
+
+
+ [Serializable, StructLayout(LayoutKind.Sequential)]
+ public struct NativeRectangle
+ {
+ public Int32 Left;
+ public Int32 Top;
+ public Int32 Right;
+ public Int32 Bottom;
+
+
+ public NativeRectangle(Int32 left, Int32 top, Int32 right, Int32 bottom)
+ {
+ this.Left = left;
+ this.Top = top;
+ this.Right = right;
+ this.Bottom = bottom;
+ }
+ }
+
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ public sealed class NativeMonitorInfo
+ {
+ public Int32 Size = Marshal.SizeOf(typeof(NativeMonitorInfo));
+ public NativeRectangle Monitor;
+ public NativeRectangle Work;
+ public Int32 Flags;
+ }
+ }
+
public static class ClassExtensions
{
public static CefState ToCefState(this bool self) =>
@@ -31,6 +104,64 @@ public static T DeepCopy(this T self)
}
public static FastHashSet ToFastHashSet(this IEnumerable collection) =>
new FastHashSet(collection);
+ public static BitmapSource ToBitmapSource(this DrawingImage source)
+ {
+ DrawingVisual drawingVisual = new DrawingVisual();
+ DrawingContext drawingContext = drawingVisual.RenderOpen();
+ drawingContext.DrawImage(source, new Rect(new System.Windows.Point(0, 0), new System.Windows.Size(source.Width, source.Height)));
+ drawingContext.Close();
+
+ RenderTargetBitmap bmp = new RenderTargetBitmap((int)source.Width, (int)source.Height, 96, 96, PixelFormats.Pbgra32);
+ bmp.Render(drawingVisual);
+ return bmp;
+ }
+ public static Bitmap ToBitmap(this BitmapSource bitmapsource)
+ {
+ Bitmap bitmap;
+ using (MemoryStream outStream = new MemoryStream())
+ {
+ BitmapEncoder enc = new BmpBitmapEncoder();
+ enc.Frames.Add(BitmapFrame.Create(bitmapsource));
+ enc.Save(outStream);
+ bitmap = new Bitmap(outStream);
+ }
+ return bitmap;
+ }
+ public static BitmapImage ToImageSource(this Bitmap bitmap)
+ {
+ using (MemoryStream memory = new MemoryStream())
+ {
+ bitmap.Save(memory, System.Drawing.Imaging.ImageFormat.Bmp);
+ memory.Position = 0;
+ BitmapImage bitmapimage = new BitmapImage();
+ bitmapimage.BeginInit();
+ bitmapimage.StreamSource = memory;
+ bitmapimage.CacheOption = BitmapCacheOption.OnLoad;
+ bitmapimage.EndInit();
+
+ return bitmapimage;
+ }
+ }
+ public static BitmapImage ToBitmapImage(this BitmapSource bitmapsource)
+ {
+ JpegBitmapEncoder encoder = new JpegBitmapEncoder();
+ MemoryStream memoryStream = new MemoryStream();
+ BitmapImage bImg = new BitmapImage();
+
+ encoder.Frames.Add(BitmapFrame.Create(bitmapsource));
+ encoder.Save(memoryStream);
+
+ memoryStream.Position = 0;
+ bImg.BeginInit();
+ bImg.StreamSource = memoryStream;
+ bImg.EndInit();
+
+ memoryStream.Close();
+
+ return bImg;
+ }
+ public static uint ToUInt(this System.Drawing.Color color) =>
+ (uint)((color.A << 24) | (color.R << 16) | (color.G << 8) | (color.B << 0));
/*public static string[] Split(this string value, string[] seperator)
{
return value.Split(seperator, StringSplitOptions.None);
@@ -39,6 +170,55 @@ public static FastHashSet ToFastHashSet(this IEnumerable 0.0000001 && meter.PeakValue < 1;
+ }
+
+ }
+ public static Process GetAlreadyRunningInstance()
+ {
+ Process _currentProc = Process.GetCurrentProcess();
+ Process[] _allProcs = Process.GetProcessesByName(_currentProc.ProcessName);
+
+ for (int i = 0; i < _allProcs.Length; i++)
+ {
+ if (_allProcs[i].Id != _currentProc.Id)
+ return _allProcs[i];
+ }
+ return null;
+ }
+ public static bool CheckInstancesUsingMutex()
+ {
+ Mutex _appMutex = new Mutex(false, MainWindow.Instance.AppUserModelID);
+ if (!_appMutex.WaitOne(1000))
+ return true;
+ return false;
+ }
+ public static bool CheckInstancesFromRunningProcesses()
+ {
+ Process[] _Processes = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName);
+ return _Processes.Length > 1;
+ }
+
+ public static int GenerateRandomId()
+ {
+ Random rnd1 = new Random();
+ return rnd1.Next();
+ }
+
public enum FolderGuids
{
Downloads,
@@ -88,21 +268,32 @@ public static string GetFolderPath(FolderGuids FolderGuid)
}
}
- public static BitmapImage BitmapToImageSource(Bitmap bitmap)
+ public static DrawingImage Utf32ToDrawingImage(int SymbolCode, double SymbolSize = 16, System.Windows.Media.FontFamily _FontFamily = null)
{
- using (MemoryStream memory = new MemoryStream())
+ if (_FontFamily == null)
+ _FontFamily = new System.Windows.Media.FontFamily("Segoe MDL2 Assets");
+ var textBlock = new TextBlock
{
- bitmap.Save(memory, System.Drawing.Imaging.ImageFormat.Bmp);
- memory.Position = 0;
- BitmapImage bitmapimage = new BitmapImage();
- bitmapimage.BeginInit();
- bitmapimage.StreamSource = memory;
- bitmapimage.CacheOption = BitmapCacheOption.OnLoad;
- bitmapimage.EndInit();
+ FontFamily = _FontFamily,
+ Text = char.ConvertFromUtf32(SymbolCode)
+ };
- return bitmapimage;
- }
+ var brush = new VisualBrush
+ {
+ Visual = textBlock,
+ Stretch = Stretch.Uniform
+ };
+
+ var drawing = new GeometryDrawing
+ {
+ Brush = brush,
+ Geometry = new RectangleGeometry(
+ new Rect(0, 0, SymbolSize, SymbolSize))
+ };
+
+ return new DrawingImage(drawing);
}
+
public static bool IsAdministrator() =>
new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
public static string GetProcessorID()
@@ -124,8 +315,6 @@ public static string Between(string Value, string FirstString, string LastString
FinalString = Value.Substring(Pos1);
return FinalString;
}
- public static uint ColorToUInt(Color color) =>
- (uint)((color.A << 24) | (color.R << 16) | (color.G << 8) | (color.B << 0));
public static string ToMobileWiki(string Url)
{
@@ -239,9 +428,9 @@ public static string FilterUrlForBrowser(string Url, string SearchEngineUrl)
string SubstringUrl = Url.Substring(7);
if (IsProtocolNotHttp(SubstringUrl))
{
- if (IsAboutUrl(SubstringUrl))
- Url = FixUrl(SubstringUrl.Replace("about://", "slbr://").Replace("about:", "slbr://"));
- else
+ //if (IsAboutUrl(SubstringUrl))
+ // Url = FixUrl(SubstringUrl.Replace("about://", "slbr://").Replace("about:", "slbr://"));
+ //else
Url = FixUrl(SubstringUrl);
}
else if (IsHttpScheme(SubstringUrl))
@@ -251,6 +440,9 @@ public static string FilterUrlForBrowser(string Url, string SearchEngineUrl)
}
if (ContinueCheck && Url.StartsWith("search:"))
Url = FixUrl(string.Format(SearchEngineUrl, Url.Substring(7)));
+
+ if (Url.EndsWith("youtube.com/watch?v="))
+ Url = "https://www.youtube.com/watch?v=KMU0tzLwhbE";
}
return Url;
}
@@ -554,22 +746,21 @@ public void Save()
if (!Directory.Exists(SaveFolderPath))
Directory.CreateDirectory(SaveFolderPath);
- if (!File.Exists(SaveFilePath))
- File.Create(SaveFilePath).Close();
+ if (!System.IO.File.Exists(SaveFilePath))
+ System.IO.File.Create(SaveFilePath).Close();
FastHashSet Contents = new FastHashSet();
foreach (KeyValuePair KVP in Data)
Contents.Add(KVP.Key + KeyValueSeparator + KVP.Value);
- File.WriteAllText(SaveFilePath, string.Join(KeySeparator, Contents));
+ System.IO.File.WriteAllText(SaveFilePath, string.Join(KeySeparator, Contents));
}
public void Load()
{
if (!Directory.Exists(SaveFolderPath))
Directory.CreateDirectory(SaveFolderPath);
- if (!File.Exists(SaveFilePath))
- File.Create(SaveFilePath).Close();
+ if (!System.IO.File.Exists(SaveFilePath))
+ System.IO.File.Create(SaveFilePath).Close();
- //FastHashSet Contents = new FastHashSet(File.ReadAllText(SaveFilePath).Split(new string[] { KeySeparator }, StringSplitOptions.None));
- FastHashSet Contents = File.ReadAllText(SaveFilePath).Split(new string[] { KeySeparator }, StringSplitOptions.None).ToFastHashSet();
+ FastHashSet Contents = System.IO.File.ReadAllText(SaveFilePath).Split(new string[] { KeySeparator }, StringSplitOptions.None).ToFastHashSet();
foreach (string Content in Contents)
{
if (string.IsNullOrWhiteSpace(Content))
diff --git a/Utility Service/AssemblyInfo.cs b/Utility Service/AssemblyInfo.cs
new file mode 100644
index 0000000..8b5504e
--- /dev/null
+++ b/Utility Service/AssemblyInfo.cs
@@ -0,0 +1,10 @@
+using System.Windows;
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
diff --git a/Utility Service/Icon.ico b/Utility Service/Icon.ico
new file mode 100644
index 0000000..f1aba6a
Binary files /dev/null and b/Utility Service/Icon.ico differ
diff --git a/Utility Service/Icon.png b/Utility Service/Icon.png
new file mode 100644
index 0000000..5b5ade6
Binary files /dev/null and b/Utility Service/Icon.png differ
diff --git a/Utility Service/Program.cs b/Utility Service/Program.cs
new file mode 100644
index 0000000..4a1e4e8
--- /dev/null
+++ b/Utility Service/Program.cs
@@ -0,0 +1,92 @@
+using CefSharp;
+using CefSharp.BrowserSubprocess;
+using System;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+using System.Threading;
+using System.Windows;
+
+namespace Utility_Service
+{
+ public class Program
+ {
+ [DllImport("kernel32.dll")]
+ static extern IntPtr GetConsoleWindow();
+
+ [DllImport("user32.dll")]
+ static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
+
+ const int SW_HIDE = 0;
+ const int SW_SHOW = 5;
+
+ [DllImport("user32.dll")]
+ static extern bool SetWindowText(IntPtr hWnd, string text);
+
+ [STAThread]
+ private static int Main(string[] args)
+ {
+ Environment.SetEnvironmentVariable("DOTNET_gcServer", "1");
+ Environment.SetEnvironmentVariable("DOTNET_GCHeapCount", "16");
+ Environment.SetEnvironmentVariable("DOTNET_GCConserveMemory", "5");
+ Cef.EnableHighDPISupport();
+
+ //var handle = GetConsoleWindow();
+ //ShowWindow(handle, SW_HIDE);
+
+ //MessageBox.Show(string.Join(",", args));
+ if (args.Length > 0 && args[0].StartsWith("--type=", StringComparison.Ordinal))
+ {
+ string WindowText = "Browser";
+ string _Type = args[0].Replace("--type=", "");
+ if (_Type == "gpu-process")
+ WindowText = "GPU Process";
+ //SetWindowText(Process.GetCurrentProcess().MainWindowHandle, "GPU Process");
+ if (_Type == "renderer")
+ WindowText = "Renderer";
+ //SetWindowText(Process.GetCurrentProcess().MainWindowHandle, "Renderer");
+ else if (_Type == "utility")
+ {
+ string _UtilitySubType = args[1].Replace("--utility-sub-type=", "");
+ if (_UtilitySubType.EndsWith("NetworkService"))
+ WindowText = "Utility: Network Service";
+ //SetWindowText(Process.GetCurrentProcess().MainWindowHandle, "Utility: Network Service");
+ else if (_UtilitySubType.EndsWith("StorageService"))
+ WindowText = "Utility: Storage Service";
+ //SetWindowText(Process.GetCurrentProcess().MainWindowHandle, "Utility: Storage Service");
+ else if (_UtilitySubType.EndsWith("AudioService"))
+ WindowText = "Utility: Audio Service";
+ //SetWindowText(Process.GetCurrentProcess().MainWindowHandle, "Utility: Audio Service");
+ }
+ SetWindowText(Process.GetCurrentProcess().MainWindowHandle, WindowText);
+ //var window = new Window()
+ //{
+ // Width = 0,
+ // Height = 0,
+ // //AllowsTransparency = true,
+ // //Opacity = 0.0,
+ // WindowStyle = WindowStyle.None,
+ // ShowInTaskbar = false,
+ // //ShowActivated = false,
+ // //Visibility = Visibility.Hidden,
+ // Title = WindowText
+ //};
+ //window.Show();
+
+ //--type
+ //[utility]
+ //--utility-sub-type
+ //storage.mojom.StorageService
+ //network.mojom.NetworkService
+ //audio.mojom.AudioService
+
+ //gpu-process
+ //utility
+ //renderer
+ //MessageBox.Show(args[0]);
+ return SelfHost.Main(args);
+ }
+ else
+ return Environment.ExitCode;
+ }
+ }
+}
diff --git a/Utility Service/Utility Service.csproj b/Utility Service/Utility Service.csproj
new file mode 100644
index 0000000..2c0deba
--- /dev/null
+++ b/Utility Service/Utility Service.csproj
@@ -0,0 +1,21 @@
+
+
+
+ WinExe
+ net6.0-windows
+ Utility_Service
+ enable
+ true
+ Utility_Service.Program
+ Icon.ico
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Version.txt b/Version.txt
index 9416767..b5a2d4d 100644
--- a/Version.txt
+++ b/Version.txt
@@ -1 +1 @@
-2022.9.5.0
+2022.10.10.0