-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
3,363 additions
and
504 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<Window x:Class="SLBr.Controls.CredentialsDialogWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:SLBr.Controls" | ||
mc:Ignorable="d" | ||
Title="Credentials" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen" | ||
ContentRendered="Window_ContentRendered" WindowStyle="None" ResizeMode="NoResize" AllowsTransparency="True" Background="Transparent"> | ||
<Window.Resources> | ||
<ResourceDictionary Source="../StyleResourceDictionary.xaml"/> | ||
</Window.Resources> | ||
<Border Background="{DynamicResource PrimaryBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" CornerRadius="5"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="Auto"/> | ||
</Grid.RowDefinitions> | ||
|
||
<Label Name="lblQuestion" Margin="0,5">Question:</Label> | ||
<Grid Margin="5" Grid.Row="1" Height="23"> | ||
<TextBlock VerticalAlignment="Center">Username</TextBlock> | ||
<TextBox Name="UsernameTextBox" Height="23" Margin="60,0,0,0" Grid.Row="1" MinWidth="250"></TextBox> | ||
</Grid> | ||
<Grid Margin="5" Grid.Row="2" Height="23"> | ||
<TextBlock VerticalAlignment="Center">Password</TextBlock> | ||
<TextBox Name="PasswordTextBox" Height="23" Margin="60,0,0,0" Grid.Row="1" MinWidth="250"></TextBox> | ||
</Grid> | ||
|
||
<WrapPanel Grid.Row="3" HorizontalAlignment="Right" Margin="0,5,5,5"> | ||
<Button Height="23" BorderBrush="{DynamicResource BorderBrush}" IsDefault="True" Name="btnDialogOk" Click="DialogOk_Click" MinWidth="60" Margin="0,0,5,0">_Sign in</Button> | ||
<Button Height="23" BorderBrush="{DynamicResource BorderBrush}" IsCancel="True" MinWidth="60">_Cancel</Button> | ||
</WrapPanel> | ||
</Grid> | ||
</Border> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
{ | ||
/// <summary> | ||
/// Interaction logic for CredentialsDialog.xaml | ||
/// </summary> | ||
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; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<Window x:Class="SLBr.Controls.PopupBrowser" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:SLBr.Controls" | ||
mc:Ignorable="d" | ||
Title="SLBr" Height="650" WindowStartupLocation="CenterScreen" Width="600" Loaded="Window_Loaded"> | ||
<Window.Resources> | ||
<ResourceDictionary Source="../StyleResourceDictionary.xaml"/> | ||
</Window.Resources> | ||
<Grid> | ||
<Grid x:Name="WebContent"> | ||
|
||
</Grid> | ||
<Grid IsHitTestVisible="False" Focusable="False" x:Name="StatusBar" Margin="2.5,30" VerticalAlignment="Bottom"> | ||
<Popup SnapsToDevicePixels="True" x:Name="StatusBarPopup" Placement="RelativePoint" IsHitTestVisible="False" Focusable="False" AllowsTransparency="True" IsOpen="True"> | ||
<Border Background="{DynamicResource PrimaryBrush}" IsHitTestVisible="False" Focusable="False" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" CornerRadius="5"> | ||
<Grid IsHitTestVisible="False" Focusable="False" MaxWidth="300" Height="25"> | ||
<TextBlock IsHitTestVisible="False" x:Name="StatusMessage" Margin="5" FontFamily="None" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Foreground="{DynamicResource FontBrush}"/> | ||
</Grid> | ||
</Border> | ||
</Popup> | ||
</Grid> | ||
</Grid> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
{ | ||
/// <summary> | ||
/// Interaction logic for PopupBrowser.xaml | ||
/// </summary> | ||
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.