diff --git a/Loaf/MainWindow.xaml.cs b/Loaf/MainWindow.xaml.cs
index 4b81f1b..872f43b 100644
--- a/Loaf/MainWindow.xaml.cs
+++ b/Loaf/MainWindow.xaml.cs
@@ -80,8 +80,9 @@ public void Loaf()
}
Frame.Navigate(typeof(Windows11UpdateView));
+
_appWindow.SetPresenter(AppWindowPresenterKind.FullScreen);
-
+ ScreenHelper.SetScreenMode(1);
while (ShowCursor(true) < 0)
{
ShowCursor(true); //显示光标
@@ -99,6 +100,7 @@ public void Unloaf()
{
_isLoafing = false;
_appWindow.SetPresenter(AppWindowPresenterKind.Default);
+ ScreenHelper.SetScreenMode(2);
var parent = VisualTreeHelper.GetParent(Root);
while (parent != null)
{
diff --git a/Loaf/ScreenHelper.cs b/Loaf/ScreenHelper.cs
new file mode 100644
index 0000000..67f7054
--- /dev/null
+++ b/Loaf/ScreenHelper.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Loaf
+{
+ public static class ScreenHelper
+ {
+ private const uint SDC_APPLY = 0x00000080;
+
+ private const uint SDC_TOPOLOGY_INTERNAL = 0x00000001;
+
+ private const uint SDC_TOPOLOGY_CLONE = 0x00000002;
+
+ ///
+ /// 扩展模式
+ ///
+ private const uint SDC_TOPOLOGY_EXTEND = 0x00000004;
+
+ [DllImport("user32.dll", CharSet = CharSet.Unicode)]
+ private static extern long SetDisplayConfig(uint numPathArrayElements, IntPtr pathArray, uint numModeArrayElements,
+ IntPtr modeArray, uint flags);
+ ///
+ /// 设置屏幕的显示模式
+ ///
+ ///
+ ///
+ private static bool SetScreen(uint displayModel)
+ {
+ return SetDisplayConfig(0, IntPtr.Zero, 0, IntPtr.Zero, SDC_APPLY | displayModel) == 0;
+ }
+
+ ///
+ /// 设置屏幕的显示模式
+ ///
+ /// 模式(0 - 主屏 1 - 双屏复制 2 - 双屏扩展
+ ///
+ public static bool SetScreenMode(int type)
+ {
+ uint smode;
+
+ switch (type)
+ {
+ case 0:
+ smode = SDC_APPLY | SDC_TOPOLOGY_INTERNAL;
+ break;
+ case 1:
+ smode = SDC_APPLY | SDC_TOPOLOGY_CLONE;
+ break;
+ case 2:
+ smode = SDC_APPLY | SDC_TOPOLOGY_EXTEND;
+ break;
+ default:
+ smode = SDC_APPLY | SDC_TOPOLOGY_INTERNAL;
+ break;
+ }
+
+ return SetDisplayConfig(0, IntPtr.Zero, 0, IntPtr.Zero, smode) == 0;
+ }
+ }
+}