diff --git a/AutomaticUpdateVersionControl.txt b/AutomaticUpdateVersionControl.txt index 80c8c54c..cca5748a 100644 --- a/AutomaticUpdateVersionControl.txt +++ b/AutomaticUpdateVersionControl.txt @@ -1 +1 @@ -1.7.16.0 +1.7.17.0 diff --git a/Ink Canvas/AssemblyInfo.cs b/Ink Canvas/AssemblyInfo.cs index 25087510..93561d41 100644 --- a/Ink Canvas/AssemblyInfo.cs +++ b/Ink Canvas/AssemblyInfo.cs @@ -49,5 +49,5 @@ using System.Windows; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.7.16.0")] -[assembly: AssemblyFileVersion("1.7.16.0")] +[assembly: AssemblyVersion("1.7.17.0")] +[assembly: AssemblyFileVersion("1.7.17.0")] diff --git a/Ink Canvas/Converters/PositionConverters.cs b/Ink Canvas/Converters/PositionConverters.cs deleted file mode 100644 index d97093e4..00000000 --- a/Ink Canvas/Converters/PositionConverters.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Globalization; -using System.Windows.Data; - -namespace Ink_Canvas.Converters -{ - /// - /// 位置计算转换器 - /// - public class PositionConverters - { - /// - /// 减法转换器 - /// - public class SubtractConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - if (value is double baseValue && parameter is string paramStr) - { - if (double.TryParse(paramStr, out double subtractValue)) - { - return baseValue - subtractValue; - } - } - return value; - } - - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } - } - } -} diff --git a/Ink Canvas/InkCanvasForClass.csproj b/Ink Canvas/InkCanvasForClass.csproj index 1c25b961..921824a8 100644 --- a/Ink Canvas/InkCanvasForClass.csproj +++ b/Ink Canvas/InkCanvasForClass.csproj @@ -421,6 +421,7 @@ + diff --git a/Ink Canvas/MainWindow.xaml b/Ink Canvas/MainWindow.xaml index c9d0d120..32a65bc6 100644 --- a/Ink Canvas/MainWindow.xaml +++ b/Ink Canvas/MainWindow.xaml @@ -2824,17 +2824,11 @@ TextWrapping="Wrap" Foreground="#a1a1aa" Margin="0,0,0,8" /> - - - - + + + + + + + + + @@ -406,29 +449,6 @@ - - diff --git a/Ink Canvas/Windows/QuickDrawFloatingButton.cs b/Ink Canvas/Windows/QuickDrawFloatingButton.cs index 50d96931..6c5360bd 100644 --- a/Ink Canvas/Windows/QuickDrawFloatingButton.cs +++ b/Ink Canvas/Windows/QuickDrawFloatingButton.cs @@ -31,6 +31,13 @@ namespace Ink_Canvas // 应用置顶 ApplyFloatingButtonTopmost(); + + // 如果主窗口在无焦点模式下,启动置顶维护 + if (MainWindow.Settings?.Advanced?.IsNoFocusMode == true && + MainWindow.Settings?.Advanced?.EnableUIAccessTopMost != true) + { + StartTopmostMaintenance(); + } } private void SetPositionToBottomRight() @@ -78,15 +85,39 @@ namespace Ink_Canvas [DllImport("user32.dll")] private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); + [DllImport("user32.dll")] + private static extern bool IsWindow(IntPtr hWnd); + + [DllImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + private static extern bool IsWindowVisible(IntPtr hWnd); + + [DllImport("user32.dll")] + private static extern bool IsIconic(IntPtr hWnd); + + [DllImport("user32.dll")] + private static extern IntPtr GetForegroundWindow(); + + [DllImport("user32.dll")] + private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId); + + [DllImport("kernel32.dll")] + private static extern uint GetCurrentProcessId(); + private const int GWL_EXSTYLE = -20; private const int WS_EX_TOPMOST = 0x00000008; private static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); + private static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2); private const uint SWP_NOMOVE = 0x0002; private const uint SWP_NOSIZE = 0x0001; private const uint SWP_NOACTIVATE = 0x0010; private const uint SWP_SHOWWINDOW = 0x0040; private const uint SWP_NOOWNERZORDER = 0x0200; + // 添加定时器来维护置顶状态 + private DispatcherTimer topmostMaintenanceTimer; + private bool isTopmostMaintenanceEnabled; + /// /// 应用悬浮按钮置顶 /// @@ -96,11 +127,6 @@ namespace Ink_Canvas { var hwnd = new WindowInteropHelper(this).Handle; if (hwnd == IntPtr.Zero) return; - - // 强制激活窗口 - Activate(); - Focus(); - // 设置WPF的Topmost属性 Topmost = true; @@ -113,13 +139,116 @@ namespace Ink_Canvas SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOOWNERZORDER); - LogHelper.WriteLogToFile("快抽悬浮按钮已应用置顶", LogHelper.LogType.Trace); } catch (Exception ex) { LogHelper.WriteLogToFile($"应用快抽悬浮按钮置顶失败: {ex.Message}", LogHelper.LogType.Error); } } + + /// + /// 启动置顶维护定时器 + /// + private void StartTopmostMaintenance() + { + if (MainWindow.Settings?.Advanced?.EnableUIAccessTopMost == true) + { + return; + } + + if (isTopmostMaintenanceEnabled) return; + + if (topmostMaintenanceTimer == null) + { + topmostMaintenanceTimer = new DispatcherTimer(); + topmostMaintenanceTimer.Interval = TimeSpan.FromMilliseconds(500); // 每500ms检查一次 + topmostMaintenanceTimer.Tick += TopmostMaintenanceTimer_Tick; + } + + topmostMaintenanceTimer.Start(); + isTopmostMaintenanceEnabled = true; + } + + /// + /// 停止置顶维护定时器 + /// + private void StopTopmostMaintenance() + { + if (topmostMaintenanceTimer != null && isTopmostMaintenanceEnabled) + { + topmostMaintenanceTimer.Stop(); + isTopmostMaintenanceEnabled = false; + } + } + + /// + /// 置顶维护定时器事件 + /// + private void TopmostMaintenanceTimer_Tick(object sender, EventArgs e) + { + try + { + if (MainWindow.Settings?.Advanced?.EnableUIAccessTopMost == true) + { + StopTopmostMaintenance(); + return; + } + + if (MainWindow.Settings?.Advanced?.IsNoFocusMode != true) + { + StopTopmostMaintenance(); + return; + } + + var hwnd = new WindowInteropHelper(this).Handle; + if (hwnd == IntPtr.Zero) return; + + // 检查窗口是否仍然可见且不是最小化状态 + if (!IsWindow(hwnd) || !IsWindowVisible(hwnd) || IsIconic(hwnd)) + { + return; + } + + // 检查是否有子窗口在前景 + var foregroundWindow = GetForegroundWindow(); + if (foregroundWindow != hwnd) + { + // 检查前景窗口是否是当前应用程序的子窗口 + var foregroundWindowProcessId = GetWindowThreadProcessId(foregroundWindow, out uint processId); + var currentProcessId = GetCurrentProcessId(); + + if (processId == currentProcessId) + { + // 如果有子窗口在前景,暂停置顶维护 + return; + } + + // 如果窗口不在最顶层且没有子窗口,重新设置置顶 + SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOOWNERZORDER); + + // 确保窗口样式正确 + int exStyle = GetWindowLong(hwnd, GWL_EXSTYLE); + if ((exStyle & WS_EX_TOPMOST) == 0) + { + SetWindowLong(hwnd, GWL_EXSTYLE, exStyle | WS_EX_TOPMOST); + } + } + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"快抽悬浮按钮置顶维护定时器出错: {ex.Message}", LogHelper.LogType.Error); + } + } + + /// + /// 窗口关闭时停止置顶维护定时器 + /// + protected override void OnClosed(EventArgs e) + { + StopTopmostMaintenance(); + base.OnClosed(e); + } #endregion } } diff --git a/Ink Canvas/Windows/SplashScreen.xaml.cs b/Ink Canvas/Windows/SplashScreen.xaml.cs index 3d68d5ff..b87a5c52 100644 --- a/Ink Canvas/Windows/SplashScreen.xaml.cs +++ b/Ink Canvas/Windows/SplashScreen.xaml.cs @@ -393,9 +393,9 @@ namespace Ink_Canvas.Windows case 1: // 跟随四季 var month = DateTime.Now.Month; - if (month >= 3 && month <= 5) return GetImageNameByStyle(2); // 春季 - if (month >= 6 && month <= 8) return GetImageNameByStyle(3); // 夏季 - if (month >= 9 && month <= 11) return GetImageNameByStyle(4); // 秋季 + if (month >= 2 && month <= 4) return GetImageNameByStyle(2); // 春季 + if (month >= 5 && month <= 7) return GetImageNameByStyle(3); // 夏季 + if (month >= 8 && month <= 10) return GetImageNameByStyle(4); // 秋季 return GetImageNameByStyle(5); // 冬季 case 2: // 春季 diff --git a/README.md b/README.md index 71ab7b17..c79835aa 100644 --- a/README.md +++ b/README.md @@ -20,21 +20,17 @@ -## 🤔 发生了什么? +## 💫 软件说明 - -由于众所周知的原因,[DotteringDoge471](https://github.com/DotteringDoge471) 不再积极负责 InkCanvasForClass 旧时代版本的开发与维护工作,而刚好 [CJKmkp](https://github.com/CJKmkp) 又维护了这个社区版本的 icc,经过沟通后就顺理成章地成为了 icc 的官方版本。该分支版本 **目前还在开发之中** ,可能会有潜在的问题/ Bug 出现,请在出现 Bug 后与开发者或与 [DotteringDoge471](https://github.com/DotteringDoge471) 上报,方便我们迅速诊断并解决问题。 - -> ⚠️ 请注意:[DotteringDoge471](https://github.com/DotteringDoge471) 不积极负责 **本社区版本** 的开发与维护工作,仅会在有空的时候对本项目开发新功能或修复 Bug。因此,任何问题反馈/Bug反馈/建议等,请优先找本项目主要维护者 [CJKmkp](https://github.com/CJKmkp) 反馈或在 GitHub 仓库内提出 Issue! - -使用该版本 InkCanvasForClass,意味着您同意自行承担任何可能存在的问题与风险。建议不要在公众场合(例如公开课,录播课,线上直播课,大型会议)使用未经广泛测试和优化的 Beta 版本,对使用 Beta 版本而带来的任何问题和风险(例如:被班主任批斗,被校长处罚,崩溃而导致的场面混乱,全球海平面上升等),**将由使用者自行承担**,[CJKmkp](https://github.com/CJKmkp) 和 [DotteringDoge471](https://github.com/DotteringDoge471) 及其项目的所有维护者不提供任何担保。 +使用该版本 InkCanvasForClass,意味着您同意自行承担任何可能存在的问题与风险。建议不要在公众场合(例如公开课,录播课,线上直播课,大型会议)使用未经广泛测试和优化的 Beta 版本,对使用 Beta 版本而带来的任何问题和风险(例如:被班主任批斗,被校长处罚,崩溃而导致的场面混乱,全球海平面上升等),**将由使用者自行承担**,[CJKmkp](https://github.com/CJKmkp) 及其项目的所有维护者不提供任何担保。 ♥️ **本项目版权归 [CJKmkp](https://github.com/CJKmkp) 所有。[CJKmkp](https://github.com/CJKmkp) 拥有最终解释权。** **智教联盟 InkCanvasForClass Community Edition 板块:** [forum.smart-teach.cn/t/icc-ce](https://forum.smart-teach.cn/t/icc-ce) ,我们会在此处发布版本更新日志,同时,您也可以在遵守论坛对应管理规则与InkCanvasForClass Community Edition 板块管理条约的情况下,在该板块内提问或发表自己的使用体验。 ## ⚠️ 使用须知 -在使用和分发本软件前,请务必了解相关开源协议。本软件基于 https://github.com/Awesome-Iwb/icc-0610fix 修改而来,而 icc-0610fix 基于 https://github.com/ChangSakura/Ink-Canvas 修改,ica 则基于 https://github.com/WXRIW/Ink-Canvas 修改,增加了包括但不限于隐藏到侧边栏等功能,更改了相关UI和软件操作逻辑。对于墨迹书写功能以及 ica 独有功能的相关问题反馈,建议优先查阅 https://github.com/WXRIW/Ink-Canvas/issues 。**使用前建议戴上大脑使用。** + +在使用和分发本软件前,请务必了解相关开源协议。本软件基于 修改而来,而 icc-20240610-stable 基于 修改,ica 则基于 修改,增加了包括但不限于隐藏到侧边栏等功能,更改了相关UI和软件操作逻辑。对于墨迹书写功能以及 ica 独有功能的相关问题反馈,建议优先查阅 。**使用前建议戴上大脑使用。** # 💬 提示 - 对于新功能的有效意见和合理建议,开发者会适时回复并进行开发。本软件并非商业性质软件或由营利性机构驱动,请不要催促开发者,耐心等待能让功能少些Bug,更加稳定。 @@ -62,13 +58,8 @@ 如果仍无法运行,请[安装 `Microsoft Office`](https://www.coolhub.top/archives/11)。 -### 程序能在 Wine 环境中运行吗? -不能,但是你可以期待 icc-gtk4,是正在开发的仅支持 Linux 平台的 icc 移植版本。 - ## ✏️ 贡献指南 -请前往 InkCanvasForClass/dubious-notes - **请注意,在贡献代码时,_务必_ 将所有代码提交到 _beta_ 分支,以保证beta版本总是新于main版本。** ## TODO LIST @@ -105,13 +96,12 @@ ## 🤝 感谢 -感谢 [DotteringDoge471](https://github.com/DotteringDoge471) 创造了 `InkCanvasForClass`! + 感谢 [yuwenhui2020](https://github.com/yuwenhui2020) 为 `Ink Canvas 使用说明` 做出的贡献! -感谢 [CN-Ironegg](https://github.com/CN-Ironegg)、[jiajiaxd](https://github.com/jiajiaxd)、[Kengwang](https://github.com/kengwang)、[Raspberry Kan](https://github.com/Raspberry-Monster)、[clover-yan](https://github.com/clover-yan)、[STBBRD](https://github.com/STBBRD)、[ChangSakura](https://github.com/WuChanging)、[DotteringDoge471](https://github.com/DotteringDoge471) 为本项目贡献代码! +感谢 [CN-Ironegg](https://github.com/CN-Ironegg)、[jiajiaxd](https://github.com/jiajiaxd)、[Kengwang](https://github.com/kengwang)、[Raspberry Kan](https://github.com/Raspberry-Monster)、[clover-yan](https://github.com/clover-yan)、[STBBRD](https://github.com/STBBRD)、[ChangSakura](https://github.com/WuChanging) 为本项目贡献代码! ## License GPLv3 ## 项目引用 [Alan-CRL/DesktopDrawpadBlocker](https://github.com/Alan-CRL/DesktopDrawpadBlocker) -[Awesome-Iwb/iwbicons-gallery](https://github.com/awesome-iwb/awesome-iwb/wiki/iwbicons-gallery)「本项目部分图标来自 Awesome Iwb 的 IwbIcons 图标库,由 Douxiba 制作。」 diff --git a/UpdateLog.md b/UpdateLog.md index f899504d..102bf5da 100644 --- a/UpdateLog.md +++ b/UpdateLog.md @@ -102,3 +102,4 @@ ICC CE 1.7.X.X更新日志 101. 新增UIA窗口置顶 102. 新增新点名窗口 103. 新增点名快抽 +104. 新增墨迹自动保存