重构Win32Natives
This commit is contained in:
@@ -43,6 +43,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpineRuntime35", "SpineRunt
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpineRuntime34", "SpineRuntimes\SpineRuntime34\SpineRuntime34.csproj", "{348605F7-3FF4-1DE0-4B91-7AEFE7BC5C55}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpineRuntime34", "SpineRuntimes\SpineRuntime34\SpineRuntime34.csproj", "{348605F7-3FF4-1DE0-4B91-7AEFE7BC5C55}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Win32Natives", "Win32Natives\Win32Natives.csproj", "{48864874-7307-950E-A667-62BB66357C62}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|x64 = Debug|x64
|
Debug|x64 = Debug|x64
|
||||||
@@ -105,6 +107,10 @@ Global
|
|||||||
{348605F7-3FF4-1DE0-4B91-7AEFE7BC5C55}.Debug|x64.Build.0 = Debug|x64
|
{348605F7-3FF4-1DE0-4B91-7AEFE7BC5C55}.Debug|x64.Build.0 = Debug|x64
|
||||||
{348605F7-3FF4-1DE0-4B91-7AEFE7BC5C55}.Release|x64.ActiveCfg = Release|x64
|
{348605F7-3FF4-1DE0-4B91-7AEFE7BC5C55}.Release|x64.ActiveCfg = Release|x64
|
||||||
{348605F7-3FF4-1DE0-4B91-7AEFE7BC5C55}.Release|x64.Build.0 = Release|x64
|
{348605F7-3FF4-1DE0-4B91-7AEFE7BC5C55}.Release|x64.Build.0 = Release|x64
|
||||||
|
{48864874-7307-950E-A667-62BB66357C62}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{48864874-7307-950E-A667-62BB66357C62}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{48864874-7307-950E-A667-62BB66357C62}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{48864874-7307-950E-A667-62BB66357C62}.Release|x64.Build.0 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using NLog;
|
using NLog;
|
||||||
using SpineViewer.Natives;
|
using Win32Natives;
|
||||||
using SpineViewer.Resources;
|
using SpineViewer.Resources;
|
||||||
using SpineViewer.Services;
|
using SpineViewer.Services;
|
||||||
using SpineViewer.ViewModels.MainWindow;
|
using SpineViewer.ViewModels.MainWindow;
|
||||||
@@ -15,6 +15,7 @@ using System.IO.Pipes;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Interop;
|
using System.Windows.Interop;
|
||||||
|
using SpineViewer.Extensions;
|
||||||
|
|
||||||
namespace SpineViewer
|
namespace SpineViewer
|
||||||
{
|
{
|
||||||
@@ -365,9 +366,8 @@ namespace SpineViewer
|
|||||||
{
|
{
|
||||||
Resources.MergedDictionaries.Add(new() { Source = new(uri, UriKind.Relative) });
|
Resources.MergedDictionaries.Add(new() { Source = new(uri, UriKind.Relative) });
|
||||||
Resources.MergedDictionaries.Add(new() { Source = new("Resources/Theme.xaml", UriKind.Relative) });
|
Resources.MergedDictionaries.Add(new() { Source = new("Resources/Theme.xaml", UriKind.Relative) });
|
||||||
var hwnd = new WindowInteropHelper(Current.MainWindow).Handle;
|
Current.MainWindow.SetWindowTextColor(AppResource.Color_PrimaryText);
|
||||||
Dwmapi.SetWindowTextColor(hwnd, AppResource.Color_PrimaryText);
|
Current.MainWindow.SetWindowCaptionColor(AppResource.Color_Region);
|
||||||
Dwmapi.SetWindowCaptionColor(hwnd, AppResource.Color_Region);
|
|
||||||
_skin = value;
|
_skin = value;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using SFML.Graphics;
|
using SkiaSharp;
|
||||||
using SFML.System;
|
|
||||||
using SkiaSharp;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -9,29 +7,31 @@ using System.Runtime.InteropServices;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Interop;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
using Win32Natives;
|
||||||
|
|
||||||
namespace SpineViewer.Extensions
|
namespace SpineViewer.Extensions
|
||||||
{
|
{
|
||||||
public static class WpfExtension
|
public static class WpfExtension
|
||||||
{
|
{
|
||||||
public static FloatRect ToFloatRect(this Rect self)
|
public static SFML.Graphics.FloatRect ToFloatRect(this Rect self)
|
||||||
{
|
{
|
||||||
return new((float)self.X, (float)self.Y, (float)self.Width, (float)self.Height);
|
return new((float)self.X, (float)self.Y, (float)self.Width, (float)self.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2f ToVector2f(this Size self)
|
public static SFML.System.Vector2f ToVector2f(this Size self)
|
||||||
{
|
{
|
||||||
return new((float)self.Width, (float)self.Height);
|
return new((float)self.Width, (float)self.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2u ToVector2u(this Size self)
|
public static SFML.System.Vector2u ToVector2u(this Size self)
|
||||||
{
|
{
|
||||||
return new((uint)self.Width, (uint)self.Height);
|
return new((uint)self.Width, (uint)self.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2i ToVector2i(this Size self)
|
public static SFML.System.Vector2i ToVector2i(this Size self)
|
||||||
{
|
{
|
||||||
return new((int)self.Width, (int)self.Height);
|
return new((int)self.Width, (int)self.Height);
|
||||||
}
|
}
|
||||||
@@ -60,6 +60,18 @@ namespace SpineViewer.Extensions
|
|||||||
return wb;
|
return wb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SetWindowTextColor(this Window self, Color color)
|
||||||
|
{
|
||||||
|
var hwnd = new WindowInteropHelper(self).Handle;
|
||||||
|
Dwmapi.SetWindowTextColor(hwnd, color.R, color.G, color.B);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetWindowCaptionColor(this Window self, Color color)
|
||||||
|
{
|
||||||
|
var hwnd = new WindowInteropHelper(self).Handle;
|
||||||
|
Dwmapi.SetWindowCaptionColor(hwnd, color.R, color.G, color.B);
|
||||||
|
}
|
||||||
|
|
||||||
//public static void SaveToFile(this BitmapSource bitmap, string path)
|
//public static void SaveToFile(this BitmapSource bitmap, string path)
|
||||||
//{
|
//{
|
||||||
// var ext = Path.GetExtension(path)?.ToLowerInvariant();
|
// var ext = Path.GetExtension(path)?.ToLowerInvariant();
|
||||||
|
|||||||
@@ -41,5 +41,6 @@
|
|||||||
<ProjectReference Include="..\NLog.Windows.Wpf\NLog.Windows.Wpf.csproj" />
|
<ProjectReference Include="..\NLog.Windows.Wpf\NLog.Windows.Wpf.csproj" />
|
||||||
<ProjectReference Include="..\SFMLRenderer\SFMLRenderer.csproj" />
|
<ProjectReference Include="..\SFMLRenderer\SFMLRenderer.csproj" />
|
||||||
<ProjectReference Include="..\Spine\Spine.csproj" />
|
<ProjectReference Include="..\Spine\Spine.csproj" />
|
||||||
|
<ProjectReference Include="..\Win32Natives\Win32Natives.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using NLog;
|
|||||||
using Spine;
|
using Spine;
|
||||||
using Spine.Implementations;
|
using Spine.Implementations;
|
||||||
using SpineViewer.Models;
|
using SpineViewer.Models;
|
||||||
using SpineViewer.Natives;
|
|
||||||
using SpineViewer.Services;
|
using SpineViewer.Services;
|
||||||
using SpineViewer.Utils;
|
using SpineViewer.Utils;
|
||||||
using System;
|
using System;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using SpineViewer.Natives;
|
using SpineViewer.Extensions;
|
||||||
using SpineViewer.Resources;
|
using SpineViewer.Resources;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -14,6 +14,7 @@ using System.Windows.Interop;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using Win32Natives;
|
||||||
|
|
||||||
namespace SpineViewer.Views
|
namespace SpineViewer.Views
|
||||||
{
|
{
|
||||||
@@ -30,9 +31,8 @@ namespace SpineViewer.Views
|
|||||||
|
|
||||||
private void AboutDialog_SourceInitialized(object? sender, EventArgs e)
|
private void AboutDialog_SourceInitialized(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var hwnd = new WindowInteropHelper(this).Handle;
|
this.SetWindowTextColor(AppResource.Color_PrimaryText);
|
||||||
Dwmapi.SetWindowTextColor(hwnd, AppResource.Color_PrimaryText);
|
this.SetWindowCaptionColor(AppResource.Color_Region);
|
||||||
Dwmapi.SetWindowCaptionColor(hwnd, AppResource.Color_Region);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using SpineViewer.Natives;
|
using SpineViewer.Extensions;
|
||||||
using SpineViewer.Resources;
|
using SpineViewer.Resources;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -14,6 +14,7 @@ using System.Windows.Interop;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using Win32Natives;
|
||||||
|
|
||||||
namespace SpineViewer.Views
|
namespace SpineViewer.Views
|
||||||
{
|
{
|
||||||
@@ -30,9 +31,8 @@ namespace SpineViewer.Views
|
|||||||
|
|
||||||
private void DiagnosticsDialog_SourceInitialized(object? sender, EventArgs e)
|
private void DiagnosticsDialog_SourceInitialized(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var hwnd = new WindowInteropHelper(this).Handle;
|
this.SetWindowTextColor(AppResource.Color_PrimaryText);
|
||||||
Dwmapi.SetWindowTextColor(hwnd, AppResource.Color_PrimaryText);
|
this.SetWindowCaptionColor(AppResource.Color_Region);
|
||||||
Dwmapi.SetWindowCaptionColor(hwnd, AppResource.Color_Region);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using SpineViewer.Natives;
|
using Win32Natives;
|
||||||
using SpineViewer.Resources;
|
using SpineViewer.Resources;
|
||||||
using SpineViewer.Services;
|
using SpineViewer.Services;
|
||||||
using SpineViewer.ViewModels.Exporters;
|
using SpineViewer.ViewModels.Exporters;
|
||||||
@@ -16,6 +16,7 @@ using System.Windows.Interop;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using SpineViewer.Extensions;
|
||||||
|
|
||||||
namespace SpineViewer.Views.ExporterDialogs
|
namespace SpineViewer.Views.ExporterDialogs
|
||||||
{
|
{
|
||||||
@@ -32,9 +33,8 @@ namespace SpineViewer.Views.ExporterDialogs
|
|||||||
|
|
||||||
private void CustomFFmpegExporterDialog_SourceInitialized(object? sender, EventArgs e)
|
private void CustomFFmpegExporterDialog_SourceInitialized(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var hwnd = new WindowInteropHelper(this).Handle;
|
this.SetWindowTextColor(AppResource.Color_PrimaryText);
|
||||||
Dwmapi.SetWindowTextColor(hwnd, AppResource.Color_PrimaryText);
|
this.SetWindowCaptionColor(AppResource.Color_Region);
|
||||||
Dwmapi.SetWindowCaptionColor(hwnd, AppResource.Color_Region);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonOK_Click(object sender, RoutedEventArgs e)
|
private void ButtonOK_Click(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using SpineViewer.Natives;
|
using SpineViewer.Extensions;
|
||||||
using SpineViewer.Resources;
|
using SpineViewer.Resources;
|
||||||
using SpineViewer.Services;
|
using SpineViewer.Services;
|
||||||
using SpineViewer.ViewModels.Exporters;
|
using SpineViewer.ViewModels.Exporters;
|
||||||
@@ -16,6 +16,7 @@ using System.Windows.Interop;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using Win32Natives;
|
||||||
|
|
||||||
namespace SpineViewer.Views.ExporterDialogs
|
namespace SpineViewer.Views.ExporterDialogs
|
||||||
{
|
{
|
||||||
@@ -32,9 +33,8 @@ namespace SpineViewer.Views.ExporterDialogs
|
|||||||
|
|
||||||
private void FFmpegVideoExporterDialog_SourceInitialized(object? sender, EventArgs e)
|
private void FFmpegVideoExporterDialog_SourceInitialized(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var hwnd = new WindowInteropHelper(this).Handle;
|
this.SetWindowTextColor(AppResource.Color_PrimaryText);
|
||||||
Dwmapi.SetWindowTextColor(hwnd, AppResource.Color_PrimaryText);
|
this.SetWindowCaptionColor(AppResource.Color_Region);
|
||||||
Dwmapi.SetWindowCaptionColor(hwnd, AppResource.Color_Region);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonOK_Click(object sender, RoutedEventArgs e)
|
private void ButtonOK_Click(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using SpineViewer.Natives;
|
using SpineViewer.Extensions;
|
||||||
using SpineViewer.Resources;
|
using SpineViewer.Resources;
|
||||||
using SpineViewer.Services;
|
using SpineViewer.Services;
|
||||||
using SpineViewer.ViewModels.Exporters;
|
using SpineViewer.ViewModels.Exporters;
|
||||||
@@ -16,6 +16,7 @@ using System.Windows.Interop;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using Win32Natives;
|
||||||
|
|
||||||
namespace SpineViewer.Views.ExporterDialogs
|
namespace SpineViewer.Views.ExporterDialogs
|
||||||
{
|
{
|
||||||
@@ -32,9 +33,8 @@ namespace SpineViewer.Views.ExporterDialogs
|
|||||||
|
|
||||||
private void FrameExporterDialog_SourceInitialized(object? sender, EventArgs e)
|
private void FrameExporterDialog_SourceInitialized(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var hwnd = new WindowInteropHelper(this).Handle;
|
this.SetWindowTextColor(AppResource.Color_PrimaryText);
|
||||||
Dwmapi.SetWindowTextColor(hwnd, AppResource.Color_PrimaryText);
|
this.SetWindowCaptionColor(AppResource.Color_Region);
|
||||||
Dwmapi.SetWindowCaptionColor(hwnd, AppResource.Color_Region);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonOK_Click(object sender, RoutedEventArgs e)
|
private void ButtonOK_Click(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using SpineViewer.Natives;
|
using SpineViewer.Extensions;
|
||||||
using SpineViewer.Resources;
|
using SpineViewer.Resources;
|
||||||
using SpineViewer.Services;
|
using SpineViewer.Services;
|
||||||
using SpineViewer.ViewModels.Exporters;
|
using SpineViewer.ViewModels.Exporters;
|
||||||
@@ -16,6 +16,7 @@ using System.Windows.Interop;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using Win32Natives;
|
||||||
|
|
||||||
namespace SpineViewer.Views.ExporterDialogs
|
namespace SpineViewer.Views.ExporterDialogs
|
||||||
{
|
{
|
||||||
@@ -32,9 +33,8 @@ namespace SpineViewer.Views.ExporterDialogs
|
|||||||
|
|
||||||
private void FrameSequenceExporterDialog_SourceInitialized(object? sender, EventArgs e)
|
private void FrameSequenceExporterDialog_SourceInitialized(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var hwnd = new WindowInteropHelper(this).Handle;
|
this.SetWindowTextColor(AppResource.Color_PrimaryText);
|
||||||
Dwmapi.SetWindowTextColor(hwnd, AppResource.Color_PrimaryText);
|
this.SetWindowCaptionColor(AppResource.Color_Region);
|
||||||
Dwmapi.SetWindowCaptionColor(hwnd, AppResource.Color_Region);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonOK_Click(object sender, RoutedEventArgs e)
|
private void ButtonOK_Click(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using NLog;
|
using NLog;
|
||||||
using SFMLRenderer;
|
using SFMLRenderer;
|
||||||
using Spine;
|
using Spine;
|
||||||
|
using SpineViewer.Extensions;
|
||||||
using SpineViewer.Models;
|
using SpineViewer.Models;
|
||||||
using SpineViewer.Natives;
|
|
||||||
using SpineViewer.Resources;
|
using SpineViewer.Resources;
|
||||||
using SpineViewer.Services;
|
using SpineViewer.Services;
|
||||||
using SpineViewer.Utils;
|
using SpineViewer.Utils;
|
||||||
@@ -24,6 +24,7 @@ using System.Windows.Input;
|
|||||||
using System.Windows.Interop;
|
using System.Windows.Interop;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
|
using Win32Natives;
|
||||||
|
|
||||||
namespace SpineViewer.Views;
|
namespace SpineViewer.Views;
|
||||||
|
|
||||||
@@ -98,13 +99,13 @@ public partial class MainWindow : Window
|
|||||||
|
|
||||||
// Initialize Wallpaper RenderWindow
|
// Initialize Wallpaper RenderWindow
|
||||||
_wallpaperRenderWindow = new(new(1, 1), "SpineViewerWallpaper", SFML.Window.Styles.None);
|
_wallpaperRenderWindow = new(new(1, 1), "SpineViewerWallpaper", SFML.Window.Styles.None);
|
||||||
_wallpaperRenderWindow.SetVisible(false);
|
_wallpaperRenderWindow.MaxFps = 30;
|
||||||
|
|
||||||
var handle = _wallpaperRenderWindow.SystemHandle;
|
var handle = _wallpaperRenderWindow.SystemHandle;
|
||||||
var style = User32.GetWindowLong(handle, User32.GWL_STYLE) | User32.WS_POPUP;
|
var style = User32.GetWindowLong(handle, User32.GWL_STYLE) | User32.WS_POPUP;
|
||||||
var exStyle = User32.GetWindowLong(handle, User32.GWL_EXSTYLE) | User32.WS_EX_LAYERED | User32.WS_EX_TOOLWINDOW;
|
var exStyle = User32.GetWindowLong(handle, User32.GWL_EXSTYLE) | User32.WS_EX_TOOLWINDOW;
|
||||||
User32.SetWindowLong(handle, User32.GWL_STYLE, style);
|
User32.SetWindowLong(handle, User32.GWL_STYLE, style);
|
||||||
User32.SetWindowLong(handle, User32.GWL_EXSTYLE, exStyle);
|
User32.SetWindowLong(handle, User32.GWL_EXSTYLE, exStyle);
|
||||||
User32.SetLayeredWindowAttributes(handle, 0, byte.MaxValue, User32.LWA_ALPHA);
|
|
||||||
|
|
||||||
DataContext = _vm = new(_renderPanel, _wallpaperRenderWindow);
|
DataContext = _vm = new(_renderPanel, _wallpaperRenderWindow);
|
||||||
|
|
||||||
@@ -153,9 +154,8 @@ public partial class MainWindow : Window
|
|||||||
|
|
||||||
private void MainWindow_SourceInitialized(object? sender, EventArgs e)
|
private void MainWindow_SourceInitialized(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var hwnd = new WindowInteropHelper(this).Handle;
|
this.SetWindowTextColor(AppResource.Color_PrimaryText);
|
||||||
Dwmapi.SetWindowTextColor(hwnd, AppResource.Color_PrimaryText);
|
this.SetWindowCaptionColor(AppResource.Color_Region);
|
||||||
Dwmapi.SetWindowCaptionColor(hwnd, AppResource.Color_Region);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
|
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using SpineViewer.Natives;
|
using SpineViewer.Extensions;
|
||||||
using SpineViewer.Resources;
|
using SpineViewer.Resources;
|
||||||
using SpineViewer.Services;
|
using SpineViewer.Services;
|
||||||
using SpineViewer.ViewModels.Exporters;
|
using SpineViewer.ViewModels.Exporters;
|
||||||
@@ -16,6 +16,7 @@ using System.Windows.Interop;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using Win32Natives;
|
||||||
|
|
||||||
namespace SpineViewer.Views
|
namespace SpineViewer.Views
|
||||||
{
|
{
|
||||||
@@ -32,9 +33,8 @@ namespace SpineViewer.Views
|
|||||||
|
|
||||||
private void PreferenceDialog_SourceInitialized(object? sender, EventArgs e)
|
private void PreferenceDialog_SourceInitialized(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var hwnd = new WindowInteropHelper(this).Handle;
|
this.SetWindowTextColor(AppResource.Color_PrimaryText);
|
||||||
Dwmapi.SetWindowTextColor(hwnd, AppResource.Color_PrimaryText);
|
this.SetWindowCaptionColor(AppResource.Color_Region);
|
||||||
Dwmapi.SetWindowCaptionColor(hwnd, AppResource.Color_Region);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonOK_Click(object sender, RoutedEventArgs e)
|
private void ButtonOK_Click(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using SpineViewer.Natives;
|
using SpineViewer.Extensions;
|
||||||
using SpineViewer.Resources;
|
using SpineViewer.Resources;
|
||||||
using SpineViewer.ViewModels;
|
using SpineViewer.ViewModels;
|
||||||
using System;
|
using System;
|
||||||
@@ -16,6 +16,7 @@ using System.Windows.Interop;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using Win32Natives;
|
||||||
|
|
||||||
namespace SpineViewer.Views
|
namespace SpineViewer.Views
|
||||||
{
|
{
|
||||||
@@ -33,9 +34,8 @@ namespace SpineViewer.Views
|
|||||||
|
|
||||||
private void ProgressDialog_SourceInitialized(object? sender, EventArgs e)
|
private void ProgressDialog_SourceInitialized(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var hwnd = new WindowInteropHelper(this).Handle;
|
this.SetWindowTextColor(AppResource.Color_PrimaryText);
|
||||||
Dwmapi.SetWindowTextColor(hwnd, AppResource.Color_PrimaryText);
|
this.SetWindowCaptionColor(AppResource.Color_Region);
|
||||||
Dwmapi.SetWindowCaptionColor(hwnd, AppResource.Color_Region);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProgressWindow_Loaded(object sender, RoutedEventArgs e)
|
private void ProgressWindow_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ using System.Linq;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Media;
|
|
||||||
|
|
||||||
namespace SpineViewer.Natives
|
namespace Win32Natives
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// dwmapi.dll 包装类
|
/// dwmapi.dll 包装类
|
||||||
@@ -24,15 +23,15 @@ namespace SpineViewer.Natives
|
|||||||
[DllImport("dwmapi.dll")]
|
[DllImport("dwmapi.dll")]
|
||||||
private static extern int DwmSetWindowAttribute(IntPtr hwnd, uint dwAttribute, ref uint pvAttribute, int cbAttribute);
|
private static extern int DwmSetWindowAttribute(IntPtr hwnd, uint dwAttribute, ref uint pvAttribute, int cbAttribute);
|
||||||
|
|
||||||
public static bool SetWindowCaptionColor(IntPtr hwnd, Color color)
|
public static bool SetWindowCaptionColor(IntPtr hwnd, byte r, byte g, byte b)
|
||||||
{
|
{
|
||||||
int c = color.R | (color.G << 8) | (color.B << 16);
|
int c = r | (g << 8) | (b << 16);
|
||||||
return 0 == DwmSetWindowAttribute(hwnd, DWMWA_CAPTION_COLOR, ref c, sizeof(uint));
|
return 0 == DwmSetWindowAttribute(hwnd, DWMWA_CAPTION_COLOR, ref c, sizeof(uint));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool SetWindowTextColor(IntPtr hwnd, Color color)
|
public static bool SetWindowTextColor(IntPtr hwnd, byte r, byte g, byte b)
|
||||||
{
|
{
|
||||||
int c = color.R | (color.G << 8) | (color.B << 16);
|
int c = r | (g << 8) | (b << 16);
|
||||||
return 0 == DwmSetWindowAttribute(hwnd, DWMWA_TEXT_COLOR, ref c, sizeof(uint));
|
return 0 == DwmSetWindowAttribute(hwnd, DWMWA_TEXT_COLOR, ref c, sizeof(uint));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace SpineViewer.Natives
|
namespace Win32Natives
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// gdi32.dll 包装类
|
/// gdi32.dll 包装类
|
||||||
@@ -7,7 +7,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace SpineViewer.Natives
|
namespace Win32Natives
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// shell32.dll 包装类
|
/// shell32.dll 包装类
|
||||||
@@ -7,7 +7,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace SpineViewer.Natives
|
namespace Win32Natives
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// user32.dll 包装类
|
/// user32.dll 包装类
|
||||||
14
Win32Natives/Win32Natives.csproj
Normal file
14
Win32Natives/Win32Natives.csproj
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<Platforms>x64</Platforms>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<BaseOutputPath>$(SolutionDir)out</BaseOutputPath>
|
||||||
|
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
||||||
|
<Version>0.0.1</Version>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
Reference in New Issue
Block a user