forked from Scighost/Starward
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
show recently updated content when startup
- Loading branch information
Showing
13 changed files
with
531 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,114 @@ | ||
using Microsoft.UI.Composition; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Media; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using Vanara.PInvoke; | ||
|
||
namespace Starward.Helpers; | ||
|
||
public partial class TransparentBackdrop : SystemBackdrop | ||
{ | ||
|
||
private readonly WindowsSystemDispatcherQueueHelper dispatcherQueueHelper = new(); | ||
|
||
private readonly nuint _subclassId = (nuint)Random.Shared.Next(100000, 999999); | ||
|
||
ComCtl32.SUBCLASSPROC _wndProcHandler; | ||
|
||
private nint _hwnd; | ||
|
||
|
||
protected override void OnTargetConnected(ICompositionSupportsSystemBackdrop connectedTarget, XamlRoot xamlRoot) | ||
{ | ||
base.OnTargetConnected(connectedTarget, xamlRoot); | ||
|
||
dispatcherQueueHelper.EnsureWindowsSystemDispatcherQueueController(); | ||
var com = new Windows.UI.Composition.Compositor(); | ||
connectedTarget.SystemBackdrop = com.CreateColorBrush(Windows.UI.Color.FromArgb(0, 255, 255, 255)); | ||
|
||
_hwnd = (nint)xamlRoot.ContentIslandEnvironment.AppWindowId.Value; | ||
_wndProcHandler = new ComCtl32.SUBCLASSPROC(WndProc); | ||
ComCtl32.SetWindowSubclass(_hwnd, _wndProcHandler, _subclassId, IntPtr.Zero); | ||
|
||
using var rgn = Gdi32.CreateRectRgn(-2, -2, -1, -1); | ||
DwmApi.DwmEnableBlurBehindWindow(_hwnd, new DwmApi.DWM_BLURBEHIND() | ||
{ | ||
dwFlags = DwmApi.DWM_BLURBEHIND_Mask.DWM_BB_ENABLE | DwmApi.DWM_BLURBEHIND_Mask.DWM_BB_BLURREGION, | ||
fEnable = true, | ||
hRgnBlur = rgn, | ||
}); | ||
} | ||
|
||
|
||
protected override void OnDefaultSystemBackdropConfigurationChanged(ICompositionSupportsSystemBackdrop target, XamlRoot xamlRoot) | ||
{ | ||
|
||
} | ||
|
||
|
||
protected override void OnTargetDisconnected(ICompositionSupportsSystemBackdrop disconnectedTarget) | ||
{ | ||
base.OnTargetDisconnected(disconnectedTarget); | ||
disconnectedTarget.SystemBackdrop = null; | ||
ComCtl32.RemoveWindowSubclass(_hwnd, _wndProcHandler, _subclassId); | ||
DwmApi.DwmEnableBlurBehindWindow(_hwnd, new DwmApi.DWM_BLURBEHIND() | ||
{ | ||
dwFlags = DwmApi.DWM_BLURBEHIND_Mask.DWM_BB_ENABLE | DwmApi.DWM_BLURBEHIND_Mask.DWM_BB_BLURREGION, | ||
fEnable = false, | ||
}); | ||
} | ||
|
||
|
||
private unsafe IntPtr WndProc(HWND hWnd, uint uMsg, IntPtr wParam, IntPtr lParam, nuint uIdSubclass, IntPtr dwRefData) | ||
{ | ||
if (uMsg == (uint)User32.WindowMessage.WM_PAINT) | ||
{ | ||
var hdc = User32.BeginPaint(hWnd, out var ps); | ||
if (hdc.IsNull) return new IntPtr(0); | ||
|
||
var brush = Gdi32.GetStockObject(Gdi32.StockObjectType.BLACK_BRUSH); | ||
User32.FillRect(hdc, ps.rcPaint, brush); | ||
return new IntPtr(1); | ||
} | ||
|
||
return ComCtl32.DefSubclassProc(hWnd, uMsg, wParam, lParam); | ||
} | ||
|
||
|
||
public partial class WindowsSystemDispatcherQueueHelper | ||
{ | ||
[StructLayout(LayoutKind.Sequential)] | ||
struct DispatcherQueueOptions | ||
{ | ||
internal int dwSize; | ||
internal int threadType; | ||
internal int apartmentType; | ||
} | ||
|
||
[LibraryImport("CoreMessaging.dll")] | ||
private static partial int CreateDispatcherQueueController(in DispatcherQueueOptions options, out nint dispatcherQueueController); | ||
|
||
nint m_dispatcherQueueController; | ||
public void EnsureWindowsSystemDispatcherQueueController() | ||
{ | ||
if (Windows.System.DispatcherQueue.GetForCurrentThread() != null) | ||
{ | ||
// one already exists, so we'll just use it. | ||
return; | ||
} | ||
|
||
if (m_dispatcherQueueController == 0) | ||
{ | ||
DispatcherQueueOptions options; | ||
options.dwSize = Marshal.SizeOf(typeof(DispatcherQueueOptions)); | ||
options.threadType = 2; // DQTYPE_THREAD_CURRENT | ||
options.apartmentType = 2; // DQTAT_COM_STA | ||
|
||
_ = CreateDispatcherQueueController(options, out m_dispatcherQueueController); | ||
} | ||
} | ||
} | ||
|
||
|
||
} |
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
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,62 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<local:WindowEx x:Class="Starward.MyWindows.UpdateContentWindow" | ||
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:lang="using:Starward.Language" | ||
xmlns:local="using:Starward.MyWindows" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
|
||
<Grid x:Name="RootGrid" Loaded="RootGrid_Loaded"> | ||
|
||
<StackPanel x:Name="StackPanel_Loading" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
Spacing="24"> | ||
<TextBlock HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
FontSize="16" | ||
Foreground="{ThemeResource TextFillColorSecondaryBrush}" | ||
Text="{x:Bind lang:Lang.UpdateContentWindow_RecentlyUpdatedContent}" /> | ||
<ProgressRing Width="32" | ||
Height="32" | ||
IsActive="True" /> | ||
</StackPanel> | ||
|
||
|
||
<StackPanel x:Name="StackPanel_Error" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
Spacing="16" | ||
Visibility="Collapsed"> | ||
<TextBlock HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
FontSize="16" | ||
Foreground="{ThemeResource TextFillColorSecondaryBrush}" | ||
Text="{x:Bind lang:Lang.DownloadGamePage_SomethingError}" /> | ||
<Button x:Name="Button_Retry" | ||
Width="40" | ||
Height="40" | ||
Padding="0" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
Click="Button_Retry_Click" | ||
Style="{ThemeResource DateTimePickerFlyoutButtonStyle}"> | ||
<FontIcon Foreground="{ThemeResource TextFillColorSecondaryBrush}" Glyph="" /> | ||
</Button> | ||
</StackPanel> | ||
|
||
|
||
<WebView2 x:Name="webview" | ||
Margin="0,32,0,0" | ||
DefaultBackgroundColor="Transparent" | ||
Visibility="Collapsed"> | ||
<WebView2.Resources> | ||
<SolidColorBrush x:Key="BrushForThemeBackgroundColor" Color="Transparent" /> | ||
</WebView2.Resources> | ||
</WebView2> | ||
|
||
</Grid> | ||
|
||
</local:WindowEx> |
Oops, something went wrong.