Skip to content

Commit

Permalink
2024.9.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SLT-World committed Sep 5, 2024
1 parent d4e041f commit 9152de6
Show file tree
Hide file tree
Showing 44 changed files with 2,831 additions and 3,070 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ CefSharp is a .NET wrapper for the Chromium Embedded Framework (CEF), providing
To install SLBr, follow these steps:
1. Download the [latest release](https://github.com/SLT-World/SLBr/releases/latest).
2. Ensure the following requirements are installed:
- [Microsoft Visual C++ 2019 Redistributable](https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170)
- [.NET 6.0](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)
- [Segoe Fluent Icons](https://aka.ms/SegoeFluentIcons)
- [Microsoft Visual C++ Redistributable](https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170) - [Direct Download x64](https://aka.ms/vs/17/release/vc_redist.x64.exe)
- [.NET 6.0](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) - (Launching SLBr without .NET 6.0 will automatically prompt a redirect to a direct download.)
- [Segoe Fluent Icons](https://learn.microsoft.com/en-us/windows/apps/design/downloads/#fonts) - [Direct Download](https://aka.ms/SegoeFluentIcons)
- Windows 10 & above
## Thanks

Expand Down
2 changes: 1 addition & 1 deletion SLBr.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.34916.146
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLBr", "SLBr\SLBr.csproj", "{F2F8E91C-C30E-438C-B921-18B11CC0A7E2}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SLBr", "SLBr\SLBr.csproj", "{F2F8E91C-C30E-438C-B921-18B11CC0A7E2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
1,698 changes: 789 additions & 909 deletions SLBr/App.xaml.cs

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions SLBr/Controls/CredentialsDialogWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
<Border.Effect>
<DropShadowEffect Direction="-75" ShadowDepth="1" Opacity="0.5" BlurRadius="15" Color="Gray"/>
</Border.Effect>
<Border Background="{DynamicResource PrimaryBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" CornerRadius="5" Margin="10">
<Border Background="{StaticResource PrimaryBrush}" BorderBrush="{StaticResource BorderBrush}" BorderThickness="1" CornerRadius="5" Margin="10">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<DockPanel Margin="0,0,0,10" Grid.Row="0" Height="Auto">
<TextBlock x:Name="QuestionIcon" FontSize="18" FontFamily="Segoe Fluent Icons" Margin="0,0,5,0">&#xe946;</TextBlock>
<Label Name="QuestionText" Margin="0,0,0,0" Padding="0" FontWeight="Medium" FontSize="14">Question</Label>
Expand All @@ -35,7 +34,6 @@
<TextBlock VerticalAlignment="Center" Margin="0,0,10,0" Width="55">Password</TextBlock>
<PasswordBox Name="PasswordTextBox" Grid.Row="1" MinWidth="250" Width="Auto"></PasswordBox>
</DockPanel>

<WrapPanel Grid.Row="3" HorizontalAlignment="Right" Margin="0">
<Button IsDefault="True" Name="btnDialogOk" Click="DialogOk_Click" MinWidth="60">Sign In</Button>
<Button IsCancel="True" MinWidth="60" Margin="10,0,0,0">Cancel</Button>
Expand Down
4 changes: 2 additions & 2 deletions SLBr/Controls/CredentialsDialogWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public CredentialsDialogWindow(string Question, string Icon = "")
public void ApplyTheme(Theme _Theme)
{
Resources["PrimaryBrushColor"] = _Theme.PrimaryColor;
Resources["FontBrushColor"] = _Theme.FontColor;
Resources["BorderBrushColor"] = _Theme.BorderColor;
Resources["SecondaryBrushColor"] = _Theme.SecondaryColor;
Resources["BorderBrushColor"] = _Theme.BorderColor;
Resources["GrayBrushColor"] = _Theme.GrayColor;
Resources["FontBrushColor"] = _Theme.FontColor;
Resources["IndicatorBrushColor"] = _Theme.IndicatorColor;
}
private async void DialogOk_Click(object sender, RoutedEventArgs e)
Expand Down
71 changes: 12 additions & 59 deletions SLBr/Controls/HwndHoster.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Interop;
using System.Windows;

Expand All @@ -27,29 +22,14 @@ private static extern IntPtr CreateWindowEx(int dwExStyle,
[DllImport("user32.dll", EntryPoint = "DestroyWindow", CharSet = CharSet.Unicode)]
private static extern bool DestroyWindow(IntPtr hwnd);

[DllImport("user32.dll", EntryPoint = "GetWindowLong")]
private static extern IntPtr GetWindowLongPtr(IntPtr hWnd, int index);

[DllImport("user32.dll", EntryPoint = "SetWindowLong")]
private static extern int SetWindowLong32(HandleRef hWnd, int index, int dwNewLong);

[DllImport("user32.dll", EntryPoint = "SetWindowLongPtr")]
private static extern IntPtr SetWindowLongPtr64(HandleRef hWnd, int index, IntPtr dwNewLong);

private const int WS_CHILD = 0x40000000,
WS_VISIBLE = 0x10000000,
LBS_NOTIFY = 0x00000001,
HOST_ID = 0x00000002,
LISTBOX_ID = 0x00000001,
WS_VSCROLL = 0x00200000,
WS_BORDER = 0x00800000,
WS_CLIPCHILDREN = 0x02000000,
WM_SIZE = 0x0005,
SWP_NOMOVE = 0x0002,
SWP_NOZORDER = 0x0004;

private const uint WS_EX_NOACTIVATE = 0x08000000;
private const int GWL_EXSTYLE = -20;

private IntPtr hwndHost;
private static bool DesignMode;
Expand All @@ -62,10 +42,6 @@ public bool IsDisposed
}
}

static HwndHoster()
{
}

public HwndHoster()
{
DesignMode = System.ComponentModel.DesignerProperties.GetIsInDesignMode(this);
Expand All @@ -80,6 +56,7 @@ private void NoInliningConstructor()
FocusVisualStyle = null;
PresentationSource.AddSourceChangedHandler(this, PresentationSourceChangedHandler);
UseLayoutRounding = true;
SnapsToDevicePixels = true;

//managedCefBrowserAdapter = ManagedCefBrowserAdapter.Create(this, false);
SizeChanged += OnSizeChanged;
Expand All @@ -93,31 +70,27 @@ private void HwndHoster_Loaded(object sender, RoutedEventArgs e)
SetWindowPos(firstChildHwnd, IntPtr.Zero, 0, 0, (int)ActualWidth, (int)ActualHeight, SWP_NOZORDER | SWP_NOMOVE);
}

Window sourceWindow;
//Window sourceWindow;

private void PresentationSourceChangedHandler(object sender, SourceChangedEventArgs args)
{
if (args.NewSource != null)
{
var source = (HwndSource)args.NewSource;
var matrix = source.CompositionTarget.TransformToDevice;
var window = source.RootVisual as Window;
var window = ((HwndSource)args.NewSource).RootVisual as Window;
if (window != null)
{
sourceWindow = window;

//sourceWindow = window;
if (CleanupElement == null)
CleanupElement = window;
else if (CleanupElement is Window parent && parent != window)
CleanupElement = window;
}
}
else if (args.OldSource != null)
/*else if (args.OldSource != null)
{
var window = args.OldSource.RootVisual as Window;
if (window != null)
if ((args.OldSource.RootVisual as Window) != null)
sourceWindow = null;
}
}*/
}

protected override HandleRef BuildWindowCore(HandleRef hwndParent)
Expand Down Expand Up @@ -153,9 +126,7 @@ protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lP
{
case WM_SETFOCUS:
case WM_MOUSEACTIVATE:
{
return IntPtr.Zero;
}
return IntPtr.Zero;
}
return base.WndProc(hwnd, msg, wParam, lParam, ref handled);
}
Expand All @@ -178,7 +149,7 @@ private void InternalDispose(bool disposing)
SizeChanged -= OnSizeChanged;
Loaded -= HwndHoster_Loaded;
PresentationSource.RemoveSourceChangedHandler(this, PresentationSourceChangedHandler);
sourceWindow = null;
//sourceWindow = null;
if (CleanupElement != null)
CleanupElement.Unloaded -= OnCleanupElementUnloaded;
}
Expand All @@ -195,11 +166,7 @@ public FrameworkElement CleanupElement

private static void OnCleanupElementChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
{
var owner = (HwndHoster)sender;
var oldValue = (FrameworkElement)args.OldValue;
var newValue = (FrameworkElement)args.NewValue;

owner.OnCleanupElementChanged(oldValue, newValue);
((HwndHoster)sender).OnCleanupElementChanged((FrameworkElement)args.OldValue, (FrameworkElement)args.NewValue);
}

protected virtual void OnCleanupElementChanged(FrameworkElement oldValue, FrameworkElement newValue)
Expand All @@ -215,7 +182,6 @@ private void OnCleanupElementUnloaded(object sender, RoutedEventArgs e)
Dispose();
}

//RECT rect;
private void OnSizeChanged(object sender, SizeChangedEventArgs e)
{
EnumChildWindows(hwndHost, new EnumWindowsProc(EnumChildProc), IntPtr.Zero);
Expand All @@ -225,8 +191,7 @@ private void OnSizeChanged(object sender, SizeChangedEventArgs e)

private void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs args)
{
var isVisible = (bool)args.NewValue;
if (isVisible)
if ((bool)args.NewValue)
SetWindowPos(hwndHost, IntPtr.Zero, 0, 0, (int)ActualWidth, (int)ActualHeight, SWP_NOZORDER | SWP_NOMOVE);
else
SetWindowPos(hwndHost, IntPtr.Zero, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE);
Expand All @@ -241,14 +206,6 @@ public struct RECT
public int Bottom;
}

[DllImport("user32.dll", SetLastError = true)]
public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);

public const int WM_SETTEXT = 0x000C;

[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam);

private IntPtr firstChildHwnd = IntPtr.Zero;
private bool EnumChildProc(IntPtr hWnd, IntPtr lParam)
{
Expand All @@ -257,16 +214,12 @@ private bool EnumChildProc(IntPtr hWnd, IntPtr lParam)
return true;
}

// Delegate for EnumChildWindows callback
private delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);

[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool EnumChildWindows(IntPtr hWndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam);

[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);

[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
Expand Down
8 changes: 3 additions & 5 deletions SLBr/Controls/InformationDialogWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
<Border.Effect>
<DropShadowEffect Direction="-75" ShadowDepth="1" Opacity="0.5" BlurRadius="15" Color="Gray"/>
</Border.Effect>
<Border Background="{DynamicResource PrimaryBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1" CornerRadius="5" Margin="10">
<Border Background="{StaticResource PrimaryBrush}" BorderBrush="{StaticResource BorderBrush}" BorderThickness="1" CornerRadius="5" Margin="10">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<DockPanel Margin="0,0,0,10" Grid.Row="0" Height="Auto">
<TextBlock x:Name="QuestionIcon" FontSize="18" FontFamily="Segoe Fluent Icons" Margin="0,0,5,0">&#xe946;</TextBlock>
<Label Name="QuestionText" Margin="0,0,0,0" Padding="0" FontWeight="Medium" FontSize="14">Question</Label>
Expand All @@ -30,10 +29,9 @@
<TextBlock x:Name="Icon" FontSize="18" FontFamily="Segoe Fluent Icons" Margin="0,0,5,0">&#xE80F;</TextBlock>
<TextBlock x:Name="DescriptionText" VerticalAlignment="Center">Description</TextBlock>
</DockPanel>

<StackPanel Orientation="Horizontal" Grid.Row="2" HorizontalAlignment="Right">
<Button BorderBrush="{DynamicResource BorderBrush}" IsDefault="True" Name="PositiveButton" Click="DialogOk_Click" MinWidth="60">Yes</Button>
<Button BorderBrush="{DynamicResource BorderBrush}" IsCancel="True" Name="NegativeButton" MinWidth="60" Margin="10,0,0,0">No</Button>
<Button BorderBrush="{StaticResource BorderBrush}" IsDefault="True" Name="PositiveButton" Click="DialogOk_Click" MinWidth="60">Yes</Button>
<Button BorderBrush="{StaticResource BorderBrush}" IsCancel="True" Name="NegativeButton" MinWidth="60" Margin="10,0,0,0">No</Button>
</StackPanel>
</Grid>
</Border>
Expand Down
4 changes: 2 additions & 2 deletions SLBr/Controls/InformationDialogWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public InformationDialogWindow(string _Title, string Question, string Descriptio
public void ApplyTheme(Theme _Theme)
{
Resources["PrimaryBrushColor"] = _Theme.PrimaryColor;
Resources["FontBrushColor"] = _Theme.FontColor;
Resources["BorderBrushColor"] = _Theme.BorderColor;
Resources["SecondaryBrushColor"] = _Theme.SecondaryColor;
Resources["BorderBrushColor"] = _Theme.BorderColor;
Resources["GrayBrushColor"] = _Theme.GrayColor;
Resources["FontBrushColor"] = _Theme.FontColor;
Resources["IndicatorBrushColor"] = _Theme.IndicatorColor;
}

Expand Down
6 changes: 3 additions & 3 deletions SLBr/Controls/PopupBrowser.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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">
Title="SLBr" Height="650" WindowStartupLocation="CenterScreen" Width="600">
<Window.Resources>
<ResourceDictionary Source="../WinUIStyleDictionary.xaml"/>
</Window.Resources>
Expand All @@ -15,9 +15,9 @@
</Grid>
<Grid IsHitTestVisible="False" Focusable="False" x:Name="StatusBar" Margin="5,37.5" VerticalAlignment="Bottom">
<Popup SnapsToDevicePixels="True" x:Name="StatusBarPopup" Placement="RelativePoint" IsHitTestVisible="False" Focusable="False" AllowsTransparency="True" IsOpen="False" PopupAnimation="Fade">
<Border Background="{DynamicResource PrimaryBrush}" IsHitTestVisible="False" Focusable="False" BorderThickness="1" BorderBrush="{DynamicResource BorderBrush}" CornerRadius="5">
<Border Background="{StaticResource PrimaryBrush}" IsHitTestVisible="False" Focusable="False" BorderThickness="1" BorderBrush="{StaticResource BorderBrush}" CornerRadius="5">
<Grid IsHitTestVisible="False" Focusable="False" MaxWidth="300">
<TextBlock IsHitTestVisible="False" x:Name="StatusMessage" Margin="7.5" FontFamily="None" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Foreground="{DynamicResource FontBrush}"/>
<TextBlock IsHitTestVisible="False" x:Name="StatusMessage" Margin="7.5" FontFamily="None" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Foreground="{StaticResource FontBrush}"/>
</Grid>
</Border>
</Popup>
Expand Down
Loading

0 comments on commit 9152de6

Please sign in to comment.