?分享一個WPF 實現 Windows 軟件快捷小工具
Windows 軟件快捷小工具
作者:WPFDevelopersOrg
原文鏈接:https://github.com/WPFDevelopersOrg/SoftwareHelper
框架使用
.NET40
;Visual Studio 2019
;項目使用 MIT 開源許可協議;
項目使用
MVVM
模式來實現詳細學習和理解WPF
;項目中技術使用到
WindowsAPI
、Style
、CustomControl
、Json 序列化和反序列化
、換膚 Dark|Light
、動畫
、Hook 按鍵與鼠標
、顏色拾取
、截屏
、DPI縮放
、開機啟動
、NLog
、轉換器
、禁止程序多開并喚醒之前程序
等;歡迎下載項目進行魔改;
更多效果可以通過GitHub[1]|碼云[2]下載代碼;
預覽
啟動頁

嵌入桌面

懸浮桌面

顏色拾取

預覽原文
啟動頁


搜索定位功能 LeftAlt+(應用首字的首字母)

托盤、換膚、透明度

移動應用順序

移除應用

自動更新(失效)

1)開機啟動
private?void?appShortcutToStartup(){var?startupDir?=?Environment.GetFolderPath(Environment.SpecialFolder.Startup);if?(!Directory.Exists(startupDir))?return;var?path?=?startupDir?+?"\\"?+?"SoftwareHelperStart"?+?".url";if?(!File.Exists(path))using?(var?writer?=?new?StreamWriter(path)){var?app?=?Assembly.GetExecutingAssembly().Location;writer.WriteLine("[InternetShortcut]");writer.WriteLine("URL=file:///"?+?app);writer.WriteLine("IconIndex=0");var?icon?=?app.Replace('\\',?'/');writer.WriteLine("IconFile="?+?icon);}}}
2) 換膚 Dark|Light
using?System;
using?System.Configuration;
using?System.Linq;
using?System.Windows;namespace?SoftwareHelper.Helpers
{///?<summary>///?Themes?幫助類///?</summary>public?partial?class?ThemesHelper{///?<summary>///?切換Themes///?</summary>///?<param?name="isDark">true:Dark?false:light</param>public?static?void?SetLightDark(bool?isDark){try{var?existingResourceDictionary?=?Application.Current.Resources.MergedDictionaries.Where(rd?=>?rd.Source?!=?null).SingleOrDefault(rd?=>?rd.Source.OriginalString.Contains("Light")?||?rd.Source.OriginalString.Contains("Dark"));var?source?=?$"pack://application:,,,/SoftwareHelper;component/Themes/{(isDark???"Dark"?:?"Light")}.xaml";var?newResourceDictionary?=?new?ResourceDictionary()?{?Source?=?new?Uri(source)?};App.Current.Resources.MergedDictionaries.Remove(existingResourceDictionary);App.Current.Resources.MergedDictionaries.Add(newResourceDictionary);//節點Configuration?config?=?ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);config.AppSettings.Settings["Dark"].Value?=?isDark.ToString();config.Save(ConfigurationSaveMode.Modified);ConfigurationManager.RefreshSection("appSettings");}catch?(Exception?ex){Log.Error($"MainView.SetLightDark Error:{ex.Message}");}}public?static?bool?GetLightDark(){bool?dark;if?(!bool.TryParse(string.IsNullOrWhiteSpace(ConfigurationManager.AppSettings["Dark"])???"false"?:?ConfigurationManager.AppSettings["Dark"],?out?dark)){dark?=?false;}else{dark?=?Convert.ToBoolean(string.IsNullOrWhiteSpace(ConfigurationManager.AppSettings["Dark"])???"false"?:?ConfigurationManager.AppSettings["Dark"]);}return?dark;}}
}
Hook 按鍵[3]Hook 鼠標[4]顏色拾取[5]
參考資料
[1]
GitHub: https://github.com/WPFDevelopersOrg/SoftwareHelper
[2]碼云: https://gitee.com/WPFDevelopersOrg/SoftwareHelper
[3]Hook 按鍵: https://gitee.com/WPFDevelopersOrg/SoftwareHelper/blob/master/SoftwareHelper/Helpers/KeyboardHook.cs
[4]Hook 鼠標: https://gitee.com/WPFDevelopersOrg/SoftwareHelper/blob/master/SoftwareHelper/Helpers/MouseHelper/MouseHook.cs
[5]顏色拾取: https://gitee.com/WPFDevelopersOrg/SoftwareHelper/blob/master/SoftwareHelper/Views/WindowColor.xaml