Skip to content

Commit

Permalink
Use SynchronizationContext.Post method to replace BeginInvoke
Browse files Browse the repository at this point in the history
Use SynchronizationContext.Post method to replace BeginInvoke
  • Loading branch information
Gaoyifei1011 committed Aug 4, 2024
1 parent a0facd5 commit 416c7d1
Show file tree
Hide file tree
Showing 53 changed files with 1,913 additions and 3,972 deletions.
23 changes: 23 additions & 0 deletions WindowsTools/Extensions/DataType/Enums/MenuType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace WindowsTools.Extensions.DataType.Enums
{
/// <summary>
/// 菜单类型
/// </summary>
public enum MenuType
{
/// <summary>
/// 根菜单
/// </summary>
RootMenu = 0,

/// <summary>
/// 一级菜单
/// </summary>
FirstLevelMenu = 1,

/// <summary>
/// 二级菜单
/// </summary>
SecondLevelMenu = 2
}
}
52 changes: 35 additions & 17 deletions WindowsTools/Models/ShellMenuItemModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System.ComponentModel;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using Windows.UI.Xaml.Media;
using WindowsTools.Extensions.DataType.Enums;

namespace WindowsTools.Models
{
Expand All @@ -8,6 +11,32 @@ namespace WindowsTools.Models
/// </summary>
public class ShellMenuItemModel : INotifyPropertyChanged
{
/// <summary>
/// 菜单 Guid 号
/// </summary>
public Guid MenuGuid { get; set; }

/// <summary>
/// 菜单类型
/// </summary>
public MenuType MenuType { get; set; }

private bool _isSelected;

public bool IsSelected
{
get { return _isSelected; }

set
{
if (!Equals(_isSelected, value))
{
_isSelected = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsSelected)));
}
}
}

/// <summary>
/// 菜单项索引
/// </summary>
Expand All @@ -19,7 +48,7 @@ public int MenuIndex

set
{
if (!Equals(value, _menuIndex))
if (!Equals(_menuIndex, value))
{
_menuIndex = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(MenuIndex)));
Expand Down Expand Up @@ -103,21 +132,10 @@ public string ProgramPath
}
}

private string _param;

public string Param
{
get { return _param; }

set
{
if (!Equals(_param, value))
{
_param = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Param)));
}
}
}
/// <summary>
/// 子菜单
/// </summary>
public ObservableCollection<ShellMenuItemModel> SubMenuItemCollection { get; set; } = [];

public event PropertyChangedEventHandler PropertyChanged;
}
Expand Down
7 changes: 5 additions & 2 deletions WindowsTools/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using System.Diagnostics.Tracing;
using System.Globalization;
using System.Threading;
Expand All @@ -10,6 +9,7 @@
using WindowsTools.Services.Root;
using WindowsTools.Services.Shell;
using WindowsTools.Views.Windows;
using WindowsTools.WindowsAPI.ComTypes;

namespace WindowsTools
{
Expand All @@ -18,6 +18,8 @@ namespace WindowsTools
/// </summary>
public class Program
{
private static Guid applicationActivationManagerCLSID = new("45BA127D-10A8-46EA-8AB7-56EA9078943C");

/// <summary>
/// 应用程序的主入口点
/// </summary>
Expand All @@ -26,7 +28,8 @@ public static void Main()
{
if (!RuntimeHelper.IsMSIX)
{
Process.Start("explorer.exe", "shell:AppsFolder\\055B5CA4.WindowsTools_zp2hc899bs298!WindowsTools");
IApplicationActivationManager applicationActivationManager = (IApplicationActivationManager)Activator.CreateInstance(Type.GetTypeFromCLSID(applicationActivationManagerCLSID));
applicationActivationManager.ActivateApplication("Gaoyifei1011.WindowsTools_pystbwmrmew8c!WindowsTools", string.Empty, ACTIVATEOPTIONS.AO_NONE, out uint _);
return;
}

Expand Down
6 changes: 3 additions & 3 deletions WindowsTools/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
[assembly: AssemblyCompany("高怡飞")]
[assembly: AssemblyCopyright("Copyright ©2024 高怡飞, All Rights Reserved.")]
[assembly: AssemblyDescription("Windows 工具箱")]
[assembly: AssemblyFileVersion("2.7.801.0")]
[assembly: AssemblyInformationalVersion("2.7.801.0")]
[assembly: AssemblyFileVersion("2.7.804.0")]
[assembly: AssemblyInformationalVersion("2.7.804.0")]
[assembly: AssemblyProduct("Windows 工具箱")]
[assembly: AssemblyTitle("Windows 工具箱")]
[assembly: AssemblyVersion("2.7.801.0")]
[assembly: AssemblyVersion("2.7.804.0")]
96 changes: 3 additions & 93 deletions WindowsTools/Strings/ShellMenu.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 2 additions & 32 deletions WindowsTools/Strings/ShellMenu.en-us.resx
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,12 @@
<data name="Drive" xml:space="preserve">
<value>Drive</value>
</data>
<data name="Edit" xml:space="preserve">
<value>Edit</value>
</data>
<data name="EmptyDescription" xml:space="preserve">
<value>There's no menu items</value>
</data>
<data name="EmptySecondLevelMenu" xml:space="preserve">
<value>The content of the secondary menu is empty</value>
<data name="EditMenu" xml:space="preserve">
<value>Edit menu</value>
</data>
<data name="Extension" xml:space="preserve">
<value>Extension name</value>
</data>
<data name="FirstLevelMenu" xml:space="preserve">
<value>First level menu</value>
</data>
<data name="IconFilterCondition" xml:space="preserve">
<value>Icon file(*.ico)|*.ico</value>
</data>
Expand Down Expand Up @@ -204,9 +195,6 @@
<data name="MenuList" xml:space="preserve">
<value>Menu list</value>
</data>
<data name="MenuOrder" xml:space="preserve">
<value>Menu order</value>
</data>
<data name="MenuParameter" xml:space="preserve">
<value>Menu parameter</value>
</data>
Expand All @@ -219,9 +207,6 @@
<data name="MenuProgramPathPHText" xml:space="preserve">
<value>The application path is not set</value>
</data>
<data name="MenuProgramPathToolTip" xml:space="preserve">
<value>Menu program path: </value>
</data>
<data name="MenuSettings" xml:space="preserve">
<value>Menu settings</value>
</data>
Expand Down Expand Up @@ -252,9 +237,6 @@
<data name="None" xml:space="preserve">
<value>None</value>
</data>
<data name="Operation" xml:space="preserve">
<value>Operation</value>
</data>
<data name="Precautions" xml:space="preserve">
<value>Precautions</value>
</data>
Expand Down Expand Up @@ -288,9 +270,6 @@
<data name="Save" xml:space="preserve">
<value>Save</value>
</data>
<data name="SecondLevelMenu" xml:space="preserve">
<value>Second level menu</value>
</data>
<data name="SelectIcon" xml:space="preserve">
<value>Select icon</value>
</data>
Expand Down Expand Up @@ -318,15 +297,6 @@
<data name="ShouldUseProgramIconOnContent" xml:space="preserve">
<value>Yes</value>
</data>
<data name="ShouldUseSecondLevelMenu" xml:space="preserve">
<value>Should use second level menu</value>
</data>
<data name="ShouldUseSecondLevelMenuOffContent" xml:space="preserve">
<value>No</value>
</data>
<data name="ShouldUseSecondLevelMenuOnContent" xml:space="preserve">
<value>Yes</value>
</data>
<data name="Title" xml:space="preserve">
<value>Custom shell menu</value>
</data>
Expand Down
Loading

0 comments on commit 416c7d1

Please sign in to comment.