ToB企服应用市场:ToB评测及商务社交产业平台

标题: 分享一个WPF 实现 Windows 软件快捷小工具 [打印本页]

作者: 笑看天下无敌手    时间: 2022-9-2 10:15
标题: 分享一个WPF 实现 Windows 软件快捷小工具
分享一个WPF 实现 Windows 软件快捷小工具
Windows 软件快捷小工具
作者:WPFDevelopersOrg
原文链接:https://github.com/WPFDevelopersOrg/SoftwareHelper

预览

启动页


嵌入桌面


悬浮桌面


颜色拾取


预览原文

启动页



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


托盘、换肤、透明度


移动应用顺序


移除应用


自动更新(失效)


1)开机启动
  1.         private void appShortcutToStartup()
  2.         {
  3.             var startupDir = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
  4.             if (!Directory.Exists(startupDir)) return;
  5.             var path = startupDir + "\" + "SoftwareHelperStart" + ".url";
  6.             if (!File.Exists(path))
  7.                 using (var writer = new StreamWriter(path))
  8.                 {
  9.                     var app = Assembly.GetExecutingAssembly().Location;
  10.                     writer.WriteLine("[InternetShortcut]");
  11.                     writer.WriteLine("URL=file:///" + app);
  12.                     writer.WriteLine("IconIndex=0");
  13.                     var icon = app.Replace('\\', '/');
  14.                     writer.WriteLine("IconFile=" + icon);
  15.                 }
  16.         }
  17.     }
复制代码
2) 换肤 Dark|Light
  1. using System;
  2. using System.Configuration;
  3. using System.Linq;
  4. using System.Windows;
  5. namespace SoftwareHelper.Helpers
  6. {
  7.     /// <summary>
  8.     /// Themes 帮助类
  9.     /// </summary>
  10.     public partial class ThemesHelper
  11.     {
  12.         /// <summary>
  13.         /// 切换Themes
  14.         /// </summary>
  15.         /// <param name="isDark">true:Dark false:light</param>
  16.         public static void SetLightDark(bool isDark)
  17.         {
  18.             try
  19.             {
  20.                 var existingResourceDictionary = Application.Current.Resources.MergedDictionaries
  21.                                                     .Where(rd => rd.Source != null)
  22.                                                     .SingleOrDefault(rd => rd.Source.OriginalString.Contains("Light") || rd.Source.OriginalString.Contains("Dark"));
  23.                 var source = $"pack://application:,,,/SoftwareHelper;component/Themes/{(isDark ? "Dark" : "Light")}.xaml";
  24.                 var newResourceDictionary = new ResourceDictionary() { Source = new Uri(source) };
  25.                 App.Current.Resources.MergedDictionaries.Remove(existingResourceDictionary);
  26.                 App.Current.Resources.MergedDictionaries.Add(newResourceDictionary);
  27.                 //节点
  28.                 Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
  29.                 config.AppSettings.Settings["Dark"].Value = isDark.ToString();
  30.                 config.Save(ConfigurationSaveMode.Modified);
  31.                 ConfigurationManager.RefreshSection("appSettings");
  32.             }
  33.             catch (Exception ex)
  34.             {
  35.                 Log.Error($"MainView.SetLightDark Error:{ex.Message}");
  36.             }
  37.         }
  38.         public static bool GetLightDark()
  39.         {
  40.             bool dark;
  41.             if (!bool.TryParse(string.IsNullOrWhiteSpace(ConfigurationManager.AppSettings["Dark"]) ? "false" : ConfigurationManager.AppSettings["Dark"], out dark))
  42.             {
  43.                 dark = false;
  44.             }
  45.             else
  46.             {
  47.                 dark = Convert.ToBoolean(string.IsNullOrWhiteSpace(ConfigurationManager.AppSettings["Dark"]) ? "false" : ConfigurationManager.AppSettings["Dark"]);
  48.             }
  49.             return dark;
  50.         }
  51.       
  52.     }
  53. }
复制代码
Hook 按键
Hook 鼠标
颜色拾取

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4