From 95e5aa995599b9e1e85f8fa8c254594803a6ef38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E6=80=A1=E9=A3=9E?= <363301617@qq.com> Date: Sat, 13 Apr 2024 23:02:41 +0800 Subject: [PATCH] Add SystemTrayService 1.Add SystemTrayService to manage shell notifyicon 2.Update Readme.md --- Description/README_EN-US.md | 1 - Description/README_ZH-CN.md | 1 - README.md | 1 - WindowsTools/App.xaml.cs | 10 +- WindowsTools/Assets/ControlIcon/ShellMenu.png | Bin 2553 -> 9253 bytes .../LoafWallpaper.jpg} | Bin WindowsTools/Program.cs | 9 - WindowsTools/Properties/AssemblyInfo.cs | 6 +- .../Services/Root/SystemTrayService.cs | 63 ++++++ WindowsTools/Strings/ShellMenu.Designer.cs | 90 +++++++++ WindowsTools/Strings/ShellMenu.en-us.resx | 30 +++ WindowsTools/Strings/ShellMenu.resx | 30 +++ WindowsTools/Strings/ShellMenu.zh-hans.resx | 30 +++ WindowsTools/Strings/SystemTray.Designer.cs | 81 ++++++++ WindowsTools/Strings/SystemTray.en-us.resx | 126 ++++++++++++ WindowsTools/Strings/SystemTray.resx | 126 ++++++++++++ WindowsTools/Strings/SystemTray.zh-hans.resx | 126 ++++++++++++ WindowsTools/Views/Pages/CodeScannerPage.xaml | 2 +- WindowsTools/Views/Pages/LoafPage.xaml | 2 +- WindowsTools/Views/Pages/LoafPage.xaml.cs | 11 +- WindowsTools/Views/Pages/ShellMenuPage.xaml | 184 ++++++++++++++++++ .../Views/Pages/ShellMenuPage.xaml.cs | 83 +++++++- .../Views/Pages/SimulateUpdatePage.xaml.cs | 4 + WindowsTools/Views/Pages/SystemTrayPage.xaml | 38 ++++ .../Views/Pages/SystemTrayPage.xaml.cs | 45 +++++ WindowsTools/Views/Windows/LoafWindow.cs | 11 +- WindowsTools/Views/Windows/MainWindow.cs | 53 ++++- .../Views/Windows/SystemTrayWindow.cs | 77 ++++++++ .../PInvoke/User32/WindowLongIndexFlags.cs | 63 ++++++ WindowsTools/WindowsTools.csproj | 20 +- .../Commands/EnumExplorerCommand.cs | 85 ++++++++ ...tItemCommand.cs => RootExplorerCommand.cs} | 19 +- .../Commands/SubExplorerCommand.cs | 51 +++++ WindowsToolsShellExtension/Program.cs | 2 +- .../Properties/AssemblyInfo.cs | 6 +- .../Controls/Settings/FileShellMenuService.cs | 2 +- .../Services/Root/LocalSettingsService.cs | 4 +- 37 files changed, 1441 insertions(+), 51 deletions(-) rename WindowsTools/Assets/{Wallpapers/LoafLocalImage.jpg => Images/LoafWallpaper.jpg} (100%) create mode 100644 WindowsTools/Services/Root/SystemTrayService.cs create mode 100644 WindowsTools/Strings/SystemTray.Designer.cs create mode 100644 WindowsTools/Strings/SystemTray.en-us.resx create mode 100644 WindowsTools/Strings/SystemTray.resx create mode 100644 WindowsTools/Strings/SystemTray.zh-hans.resx create mode 100644 WindowsTools/Views/Pages/SystemTrayPage.xaml create mode 100644 WindowsTools/Views/Pages/SystemTrayPage.xaml.cs create mode 100644 WindowsTools/Views/Windows/SystemTrayWindow.cs create mode 100644 WindowsTools/WindowsAPI/PInvoke/User32/WindowLongIndexFlags.cs create mode 100644 WindowsToolsShellExtension/Commands/EnumExplorerCommand.cs rename WindowsToolsShellExtension/Commands/{RootItemCommand.cs => RootExplorerCommand.cs} (85%) create mode 100644 WindowsToolsShellExtension/Commands/SubExplorerCommand.cs diff --git a/Description/README_EN-US.md b/Description/README_EN-US.md index 2476dfd..d34f15d 100644 --- a/Description/README_EN-US.md +++ b/Description/README_EN-US.md @@ -144,6 +144,5 @@ Unpackaged version ### Other content -> * The project began on March 20, 2023, and ended on July 29, 2023, lasting a total of 4 months and 9 days. > * This project is an open source project licensed under the MIT license, and you may modify, distribute, or merge copies with new copies. If you use the project, please do not use it for illegal purposes, and the developer will not be held responsible. > * [Tool prototype](https://github.com/Gaoyifei1011/WindowsToolbox/blob/main/Description/RawApplicationDescription.md)  diff --git a/Description/README_ZH-CN.md b/Description/README_ZH-CN.md index 872efcf..aa5d8bc 100644 --- a/Description/README_ZH-CN.md +++ b/Description/README_ZH-CN.md @@ -144,6 +144,5 @@ ### 其他内容 -> * 该项目自2023年3月20日起,到2023年7月29日结束,共历时4个月零9天。 > * 该项目是基于MIT协议许可的开源项目,您可以修改、分发该项目或将副本与新副本合并。如果您使用了该项目,请勿用于非法用途,本开发者不会承担任何责任。 > * [工具原型](https://github.com/Gaoyifei1011/WindowsToolbox/blob/main/Description/RawApplicationDescription.md)  diff --git a/README.md b/README.md index 04f1ef0..6033a3c 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,6 @@ ### 其他内容 -> * 该项目自2023年3月20日起,到2023年7月29日结束,共历时4个月零9天。 > * 该项目是基于MIT协议许可的开源项目,您可以修改、分发该项目或将副本与新副本合并。如果您使用了该项目,请勿用于非法用途,本开发者不会承担任何责任。 > * [工具原型](https://github.com/Gaoyifei1011/WindowsToolbox/blob/main/Description/RawApplicationDescription.md)  diff --git a/WindowsTools/App.xaml.cs b/WindowsTools/App.xaml.cs index 6c3177e..b43d152 100644 --- a/WindowsTools/App.xaml.cs +++ b/WindowsTools/App.xaml.cs @@ -1,8 +1,7 @@ -using Mile.Xaml.Interop; +using Mile.Xaml; using System; using System.Diagnostics.Tracing; using Windows.UI.Xaml; -using Windows.UI.Xaml.Hosting; using WindowsTools.Services.Root; using WindowsTools.Views.Windows; @@ -17,8 +16,7 @@ public partial class App : Application, IDisposable public App() { - WindowsXamlManager.InitializeForCurrentThread(); - Window.Current.GetInterop().TransparentBackground = true; + this.ThreadInitialize(); InitializeComponent(); UnhandledException += OnUnhandledException; } @@ -55,7 +53,9 @@ protected virtual void Dispose(bool disposing) { if (disposing) { - MainWindow.Current.Close(); + this.ThreadUninitialize(); + MainWindow.Current?.Close(); + //SystemTrayService.CloseSystemTray(); System.Windows.Forms.Application.Exit(); } diff --git a/WindowsTools/Assets/ControlIcon/ShellMenu.png b/WindowsTools/Assets/ControlIcon/ShellMenu.png index c4c9094d46d49456c6542baf667e7e6a1fb383b5..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GHbOFw#(GLjuHmz#Nix_PGa>jrb6+bwbmcedD{M z8m3FaZOQs<;BNn>01xe8FxZndJP_GPCBanG%{+@kjjf0}W(}LgWtF{PF7SPfj>sMj zew={Q^Eo$&wAzZe#4Pt#8!{kIcjJ!4Lp)UB36%tk4enJ={ho4ZL+nTk=cwqAMs5XW zK0t-`w<-_oeA!UbH9kJUGX@QK-qIknW``!An^mo4p{Dxuo#i2gXzcuSzjD*ULbNC8 z0Z~_1eSx<3T~+fQC-;Rd_2&+}d?T7KXij&cpgT0UFDoOSiY6BiX{C0SDyPKbGPcMe zjEmR#XJ<9gm@vMu{l@{1E&nKQ0DI?nZmg|a!EF(w#mRDd%-N;NCCpHScAkhBEu_$9 zejd9&sH>*74Q$=wQhUBnQRAo9Q|2GLmz9?CaccUR((mO9`MfD-v7X2N_Er0Bx}tK>&ctW0h!2%s8Hy~P^-moStIVLcJ=!s{ zokJXCOH*9?_?{M0F)f?Tb~t@KkchowuxR7h^zA}pxBpB>LhP&PG?ISnUYql4=|tR- ewEJa`*qB>Q51h_Tr;@?nHOSk`-?Q2yD*M0x!ENsV diff --git a/WindowsTools/Assets/Wallpapers/LoafLocalImage.jpg b/WindowsTools/Assets/Images/LoafWallpaper.jpg similarity index 100% rename from WindowsTools/Assets/Wallpapers/LoafLocalImage.jpg rename to WindowsTools/Assets/Images/LoafWallpaper.jpg diff --git a/WindowsTools/Program.cs b/WindowsTools/Program.cs index eddac21..ce5e675 100644 --- a/WindowsTools/Program.cs +++ b/WindowsTools/Program.cs @@ -42,7 +42,6 @@ public static void Main(string[] args) Application.SetCompatibleTextRenderingDefault(false); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); - Application.ApplicationExit += OnApplicationExit; Application.ThreadException += OnThreadException; AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; @@ -50,14 +49,6 @@ public static void Main(string[] args) Application.Run(new MainWindow()); } - /// - /// 在应用程序即将关闭时发生 - /// - private static void OnApplicationExit(object sender, EventArgs args) - { - (Windows.UI.Xaml.Application.Current as App).Dispose(); - } - /// /// 处理 Windows 窗体 UI 线程异常 /// diff --git a/WindowsTools/Properties/AssemblyInfo.cs b/WindowsTools/Properties/AssemblyInfo.cs index adc1948..441c0b1 100644 --- a/WindowsTools/Properties/AssemblyInfo.cs +++ b/WindowsTools/Properties/AssemblyInfo.cs @@ -5,11 +5,11 @@ [assembly: AssemblyCompany("高怡飞")] [assembly: AssemblyCopyright("Copyright ©2024 高怡飞, All Rights Reserved.")] [assembly: AssemblyDescription("Windows 工具箱")] -[assembly: AssemblyFileVersion("2.2.410.0")] -[assembly: AssemblyInformationalVersion("2.2.410.0")] +[assembly: AssemblyFileVersion("2.3.413.0")] +[assembly: AssemblyInformationalVersion("2.3.413.0")] [assembly: AssemblyProduct("Windows 工具箱")] [assembly: AssemblyTitle("Windows 工具箱")] -[assembly: AssemblyVersion("2.2.410.0")] +[assembly: AssemblyVersion("2.3.413.0")] // 设置程序集对 COM 组件的访问权限 [assembly: ComVisible(false)] diff --git a/WindowsTools/Services/Root/SystemTrayService.cs b/WindowsTools/Services/Root/SystemTrayService.cs new file mode 100644 index 0000000..e6fee34 --- /dev/null +++ b/WindowsTools/Services/Root/SystemTrayService.cs @@ -0,0 +1,63 @@ +using System.Drawing; +using System.Windows.Forms; + +namespace WindowsTools.Services.Root +{ + /// + /// 系统托盘菜单服务 + /// + public static class SystemTrayService + { + private static NotifyIcon notifyIcon; + + public static event MouseEventHandler MouseClick; + + public static event MouseEventHandler MouseDoubleClick; + + /// + /// 初始化系统托盘 + /// + public static void InitializeSystemTray(string content, string iconPath) + { + if (notifyIcon is null) + { + notifyIcon = new NotifyIcon(); + notifyIcon.Text = content; + notifyIcon.Icon = Icon.ExtractAssociatedIcon(iconPath); + notifyIcon.Visible = true; + notifyIcon.MouseClick += OnMouseClick; + notifyIcon.MouseDoubleClick += OnMouseDoubleClick; + } + } + + /// + /// 关闭托盘菜单 + /// + public static void CloseSystemTray() + { + if (notifyIcon is not null) + { + notifyIcon.Visible = false; + notifyIcon.MouseClick -= OnMouseClick; + notifyIcon.Dispose(); + notifyIcon = null; + } + } + + /// + /// 处理托盘菜单鼠标点击事件 + /// + private static void OnMouseClick(object sender, MouseEventArgs args) + { + MouseClick?.Invoke(sender, args); + } + + /// + /// 处理托盘菜单鼠标双击事件 + /// + private static void OnMouseDoubleClick(object sender, MouseEventArgs args) + { + MouseDoubleClick?.Invoke(sender, args); + } + } +} diff --git a/WindowsTools/Strings/ShellMenu.Designer.cs b/WindowsTools/Strings/ShellMenu.Designer.cs index 48fe989..4dcec1c 100644 --- a/WindowsTools/Strings/ShellMenu.Designer.cs +++ b/WindowsTools/Strings/ShellMenu.Designer.cs @@ -60,6 +60,96 @@ internal ShellMenu() { } } + /// + /// 查找类似 Add menu 的本地化字符串。 + /// + public static string AddMenu { + get { + return ResourceManager.GetString("AddMenu", resourceCulture); + } + } + + /// + /// 查找类似 Apply 的本地化字符串。 + /// + public static string Apply { + get { + return ResourceManager.GetString("Apply", resourceCulture); + } + } + + /// + /// 查找类似 Apply modify 的本地化字符串。 + /// + public static string ApplyModify { + get { + return ResourceManager.GetString("ApplyModify", resourceCulture); + } + } + + /// + /// 查找类似 Menu list 的本地化字符串。 + /// + public static string MenuList { + get { + return ResourceManager.GetString("MenuList", resourceCulture); + } + } + + /// + /// 查找类似 Modify 的本地化字符串。 + /// + public static string Modify { + get { + return ResourceManager.GetString("Modify", resourceCulture); + } + } + + /// + /// 查找类似 Refresh 的本地化字符串。 + /// + public static string Refresh { + get { + return ResourceManager.GetString("Refresh", resourceCulture); + } + } + + /// + /// 查找类似 Return default 的本地化字符串。 + /// + public static string ReturnDefault { + get { + return ResourceManager.GetString("ReturnDefault", resourceCulture); + } + } + + /// + /// 查找类似 Root menu icon 的本地化字符串。 + /// + public static string RootMenuIcon { + get { + return ResourceManager.GetString("RootMenuIcon", resourceCulture); + } + } + + /// + /// 查找类似 Root menu name 的本地化字符串。 + /// + public static string RootMenuName { + get { + return ResourceManager.GetString("RootMenuName", resourceCulture); + } + } + + /// + /// 查找类似 Root menu settings 的本地化字符串。 + /// + public static string RootMenuSettings { + get { + return ResourceManager.GetString("RootMenuSettings", resourceCulture); + } + } + /// /// 查找类似 Custom shell menu 的本地化字符串。 /// diff --git a/WindowsTools/Strings/ShellMenu.en-us.resx b/WindowsTools/Strings/ShellMenu.en-us.resx index 3018c27..2f31d6a 100644 --- a/WindowsTools/Strings/ShellMenu.en-us.resx +++ b/WindowsTools/Strings/ShellMenu.en-us.resx @@ -117,6 +117,36 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Add menu + + + Apply + + + Apply modify + + + Menu list + + + Modify + + + Refresh + + + Return default + + + Root menu icon + + + Root menu name + + + Root menu settings + Custom shell menu diff --git a/WindowsTools/Strings/ShellMenu.resx b/WindowsTools/Strings/ShellMenu.resx index 3018c27..2f31d6a 100644 --- a/WindowsTools/Strings/ShellMenu.resx +++ b/WindowsTools/Strings/ShellMenu.resx @@ -117,6 +117,36 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Add menu + + + Apply + + + Apply modify + + + Menu list + + + Modify + + + Refresh + + + Return default + + + Root menu icon + + + Root menu name + + + Root menu settings + Custom shell menu diff --git a/WindowsTools/Strings/ShellMenu.zh-hans.resx b/WindowsTools/Strings/ShellMenu.zh-hans.resx index 4ba5f85..ea85966 100644 --- a/WindowsTools/Strings/ShellMenu.zh-hans.resx +++ b/WindowsTools/Strings/ShellMenu.zh-hans.resx @@ -117,6 +117,36 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 添加菜单 + + + 应用 + + + 应用更改 + + + 菜单列表 + + + 修改 + + + 刷新 + + + 还原默认 + + + 根菜单图标 + + + 根菜单名称 + + + 根菜单设置 + 自定义扩展菜单 diff --git a/WindowsTools/Strings/SystemTray.Designer.cs b/WindowsTools/Strings/SystemTray.Designer.cs new file mode 100644 index 0000000..13feb0d --- /dev/null +++ b/WindowsTools/Strings/SystemTray.Designer.cs @@ -0,0 +1,81 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace WindowsTools.Strings { + using System; + + + /// + /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class SystemTray { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal SystemTray() { + } + + /// + /// 返回此类使用的缓存的 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WindowsTools.Strings.SystemTray", typeof(SystemTray).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// 查找类似 Exit 的本地化字符串。 + /// + public static string Exit { + get { + return ResourceManager.GetString("Exit", resourceCulture); + } + } + + /// + /// 查找类似 Show/hide window 的本地化字符串。 + /// + public static string ShowOrHideWindow { + get { + return ResourceManager.GetString("ShowOrHideWindow", resourceCulture); + } + } + } +} diff --git a/WindowsTools/Strings/SystemTray.en-us.resx b/WindowsTools/Strings/SystemTray.en-us.resx new file mode 100644 index 0000000..c87eaa7 --- /dev/null +++ b/WindowsTools/Strings/SystemTray.en-us.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Exit + + + Show/hide window + + \ No newline at end of file diff --git a/WindowsTools/Strings/SystemTray.resx b/WindowsTools/Strings/SystemTray.resx new file mode 100644 index 0000000..c87eaa7 --- /dev/null +++ b/WindowsTools/Strings/SystemTray.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Exit + + + Show/hide window + + \ No newline at end of file diff --git a/WindowsTools/Strings/SystemTray.zh-hans.resx b/WindowsTools/Strings/SystemTray.zh-hans.resx new file mode 100644 index 0000000..030153a --- /dev/null +++ b/WindowsTools/Strings/SystemTray.zh-hans.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 退出 + + + 显示/隐藏窗口 + + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/CodeScannerPage.xaml b/WindowsTools/Views/Pages/CodeScannerPage.xaml index c2fa691..a479fa9 100644 --- a/WindowsTools/Views/Pages/CodeScannerPage.xaml +++ b/WindowsTools/Views/Pages/CodeScannerPage.xaml @@ -148,7 +148,7 @@ Grid.Column="0" Margin="0,0,12,0" FontSize="16" - Glyph="" /> + Glyph="" /> + Glyph="" /> /// 加载每日必应壁纸图片 /// @@ -181,7 +183,7 @@ private void OnLoaded(object sender, RoutedEventArgs args) } catch (Exception e) { - LoafImage = new BitmapImage(new Uri("ms-appx:///Assets/Wallpapers/LoafLocalImage.jpg")); + LoafImage = new BitmapImage(new Uri("ms-appx:///Assets/Images/LoafWallpaper.jpg")); LoadImageCompleted = true; LogService.WriteLog(EventLevel.Error, "Load bing wallpaper image failed", e); } @@ -191,7 +193,7 @@ private void OnLoaded(object sender, RoutedEventArgs args) { MainWindow.Current.BeginInvoke(() => { - LoafImage = new BitmapImage(new Uri("ms-appx:///Assets/Wallpapers/LoafLocalImage.jpg")); + LoafImage = new BitmapImage(new Uri("ms-appx:///Assets/Images/LoafWallpaper.jpg")); LoadImageCompleted = true; }); } @@ -201,7 +203,7 @@ private void OnLoaded(object sender, RoutedEventArgs args) LogService.WriteLog(EventLevel.Error, "Load bing wallpaper image failed", e); MainWindow.Current.BeginInvoke(() => { - LoafImage = new BitmapImage(new Uri("ms-appx:///Assets/Wallpapers/LoafLocalImage.jpg")); + LoafImage = new BitmapImage(new Uri("ms-appx:///Assets/Images/LoafWallpaper.jpg")); LoadImageCompleted = true; }); } @@ -224,7 +226,6 @@ private void OnStartLoafClicked(object sender, RoutedEventArgs args) private void OnClosed(object sender, FormClosedEventArgs args) { LoafWindow.Current.FormClosed -= OnClosed; - LoafWindow.Current = null; IsLoafing = false; } @@ -275,5 +276,7 @@ private void OnLockScreenAutomaticlyToggled(object sender, RoutedEventArgs args) LockScreenAutomaticly = toggleSwitch.IsOn; } } + + #endregion 第一部分:摸鱼页面——挂载的事件 } } diff --git a/WindowsTools/Views/Pages/ShellMenuPage.xaml b/WindowsTools/Views/Pages/ShellMenuPage.xaml index fc5e90f..ba8e38f 100644 --- a/WindowsTools/Views/Pages/ShellMenuPage.xaml +++ b/WindowsTools/Views/Pages/ShellMenuPage.xaml @@ -4,6 +4,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:muxc="using:Microsoft.UI.Xaml.Controls" xmlns:string="using:WindowsTools.Strings" NavigationCacheMode="Enabled" mc:Ignorable="d"> @@ -11,6 +12,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +