improve:窗口无焦点
This commit is contained in:
@@ -618,6 +618,13 @@
|
|||||||
FontSize="26" />
|
FontSize="26" />
|
||||||
</GroupBox.Header>
|
</GroupBox.Header>
|
||||||
<ui:SimpleStackPanel Spacing="6">
|
<ui:SimpleStackPanel Spacing="6">
|
||||||
|
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||||
|
<TextBlock Foreground="#fafafa" Text="窗口无焦点模式" VerticalAlignment="Center"
|
||||||
|
FontSize="14" Margin="0,0,16,0" />
|
||||||
|
<ui:ToggleSwitch OnContent="" OffContent="" Name="ToggleSwitchNoFocusMode"
|
||||||
|
IsOn="False" FontFamily="Microsoft YaHei UI" FontWeight="Bold"
|
||||||
|
Toggled="ToggleSwitchNoFocusMode_Toggled" />
|
||||||
|
</ui:SimpleStackPanel>
|
||||||
<ui:ToggleSwitch OnContent="" OffContent=""
|
<ui:ToggleSwitch OnContent="" OffContent=""
|
||||||
Name="ToggleSwitchIsAutoUpdate" Header="自动检查更新"
|
Name="ToggleSwitchIsAutoUpdate" Header="自动检查更新"
|
||||||
FontFamily="Microsoft YaHei UI"
|
FontFamily="Microsoft YaHei UI"
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ using System.Reflection;
|
|||||||
using Brushes = System.Windows.Media.Brushes;
|
using Brushes = System.Windows.Media.Brushes;
|
||||||
using Point = System.Windows.Point;
|
using Point = System.Windows.Point;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using iNKORE.UI.WPF.Modern.Controls;
|
||||||
|
|
||||||
namespace Ink_Canvas {
|
namespace Ink_Canvas {
|
||||||
public partial class MainWindow : Window {
|
public partial class MainWindow : Window {
|
||||||
@@ -167,6 +168,9 @@ namespace Ink_Canvas {
|
|||||||
BlackBoardRightSidePageListScrollViewer.ReleaseTouchCapture(e.TouchDevice);
|
BlackBoardRightSidePageListScrollViewer.ReleaseTouchCapture(e.TouchDevice);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
// 初始化无焦点模式开关
|
||||||
|
ToggleSwitchNoFocusMode.IsOn = Settings.Advanced.IsNoFocusMode;
|
||||||
|
ApplyNoFocusMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -393,6 +397,9 @@ namespace Ink_Canvas {
|
|||||||
|
|
||||||
// 初始化插件系统
|
// 初始化插件系统
|
||||||
InitializePluginSystem();
|
InitializePluginSystem();
|
||||||
|
// 确保开关和设置同步
|
||||||
|
ToggleSwitchNoFocusMode.IsOn = Settings.Advanced.IsNoFocusMode;
|
||||||
|
ApplyNoFocusMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SystemEventsOnDisplaySettingsChanged(object sender, EventArgs e) {
|
private void SystemEventsOnDisplaySettingsChanged(object sender, EventArgs e) {
|
||||||
@@ -1336,5 +1343,35 @@ namespace Ink_Canvas {
|
|||||||
BorderSettings.Visibility = Visibility.Visible;
|
BorderSettings.Visibility = Visibility.Visible;
|
||||||
BorderSettingsMask.Visibility = Visibility.Visible;
|
BorderSettingsMask.Visibility = Visibility.Visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
||||||
|
private const int GWL_EXSTYLE = -20;
|
||||||
|
private const int WS_EX_NOACTIVATE = 0x08000000;
|
||||||
|
|
||||||
|
private void ApplyNoFocusMode()
|
||||||
|
{
|
||||||
|
var hwnd = new WindowInteropHelper(this).Handle;
|
||||||
|
int exStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||||
|
if (Settings.Advanced.IsNoFocusMode)
|
||||||
|
{
|
||||||
|
SetWindowLong(hwnd, GWL_EXSTYLE, exStyle | WS_EX_NOACTIVATE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetWindowLong(hwnd, GWL_EXSTYLE, exStyle & ~WS_EX_NOACTIVATE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ToggleSwitchNoFocusMode_Toggled(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (!isLoaded) return;
|
||||||
|
var toggle = sender as ToggleSwitch;
|
||||||
|
Settings.Advanced.IsNoFocusMode = toggle != null && toggle.IsOn;
|
||||||
|
SaveSettingsToFile();
|
||||||
|
ApplyNoFocusMode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -437,6 +437,9 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
[JsonProperty("isAutoBackupBeforeUpdate")]
|
[JsonProperty("isAutoBackupBeforeUpdate")]
|
||||||
public bool IsAutoBackupBeforeUpdate { get; set; } = true;
|
public bool IsAutoBackupBeforeUpdate { get; set; } = true;
|
||||||
|
|
||||||
|
[JsonProperty("isNoFocusMode")]
|
||||||
|
public bool IsNoFocusMode { get; set; } = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InkToShape
|
public class InkToShape
|
||||||
|
|||||||
Reference in New Issue
Block a user