Skip to content

Commit

Permalink
修复 右键菜单无法使用的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Hakoyu authored and Hakoyu committed May 16, 2023
1 parent 6a0b442 commit 66c16c6
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 25 deletions.
6 changes: 3 additions & 3 deletions App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
OKButtonContent="{x:Static I18n:MessageBoxXI18nRes.OK}"
YesButtonContent="{x:Static I18n:MessageBoxXI18nRes.YES}">
<pu:MessageBoxXSettings.WindowXStyle>
<Style BasedOn="{StaticResource {ComponentResourceKey ResourceId=WindowXStyle, TypeInTargetAssembly={x:Type pu:MessageBoxX}}}" TargetType="pu:WindowX">
<Style BasedOn="{StaticResource {x:Static pu:MessageBoxX.WindowXStyleKey}}" TargetType="pu:WindowX">
<Setter Property="Topmost" Value="True" />
<Setter Property="Width" Value="NaN" />
<Setter Property="Height" Value="NaN" />
Expand Down Expand Up @@ -111,7 +111,7 @@
</pu:MessageBoxXSettings>
<pu:PendingBoxSettings x:Key="pendingSettings">
<pu:PendingBoxSettings.WindowStyle>
<Style BasedOn="{StaticResource {x:Static pu:PendingBox.WindowStyle}}" TargetType="Window">
<Style BasedOn="{StaticResource {x:Static pu:PendingBox.WindowStyleKey}}" TargetType="Window">
<Setter Property="Width" Value="NaN" />
<Setter Property="Height" Value="NaN" />
<Setter Property="MinWidth" Value="300" />
Expand All @@ -125,7 +125,7 @@
</Style>
</pu:PendingBoxSettings.WindowStyle>
<pu:PendingBoxSettings.SpinStyle>
<Style BasedOn="{StaticResource {x:Static pu:PendingBox.SpinStyle}}" TargetType="pu:Spin">
<Style BasedOn="{StaticResource {x:Static pu:PendingBox.SpinStyleKey}}" TargetType="pu:Spin">
<Setter Property="SpinStyle" Value="Ring2" />
<Setter Property="Width" Value="50" />
<Setter Property="Height" Value="50" />
Expand Down
8 changes: 6 additions & 2 deletions Libs/HKW/ViewModels/Controls/ItemsCollectionVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ public partial class ItemsCollectionVM<T> : ControlVMBase, IList<T>, IEnumerable
private ObservableCollection<T> _itemsSource = null!;

/// <inheritdoc/>
public T this[int index] { get => ItemsSource[index]; set => ItemsSource[index] = value; }
public T this[int index]
{
get => ItemsSource[index];
set => ItemsSource[index] = value;
}

/// <inheritdoc/>
public int Count => ItemsSource.Count;
Expand Down Expand Up @@ -56,4 +60,4 @@ public partial class ItemsCollectionVM<T> : ControlVMBase, IList<T>, IEnumerable

/// <inheritdoc/>
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}
26 changes: 13 additions & 13 deletions Libs/HKW/ViewModels/Controls/MenuItemVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public partial class MenuItemVM : HeaderedItemsControlVM<MenuItemVM>
[ObservableProperty]
private bool _isVisible;

[ObservableProperty]
//[ObservableProperty]
//[NotifyCanExecuteChangedFor(nameof(MenuItemCommand))]
//[NotifyCanExecuteChangedFor(nameof(MenuItemAsyncCommand))]
private bool _canExecute;
//private bool _canExecute;

/// <summary>
/// 初始化
Expand All @@ -40,8 +40,8 @@ public MenuItemVM(CommandHandler? handler = null)
// CommandEventAsync += handlerAsync;
//}

//[RelayCommand(CanExecute = nameof(CanExecute))]
//private void MenuItem(object parameter) => CommandEvent?.Invoke(parameter);
[RelayCommand]
private void MenuItem(object parameter) => CommandEvent?.Invoke(parameter);

//[RelayCommand(CanExecute = nameof(CanExecute))]
//private async Task MenuItemAsync(object parameter)
Expand All @@ -62,14 +62,14 @@ public MenuItemVM(CommandHandler? handler = null)
/// </summary>
public event CommandHandler? CommandEvent;

/// <summary>
/// 异步委托
/// </summary>
/// <param name="parameter">参数</param>
public delegate Task CommandHandlerAsync(object parameter);
///// <summary>
///// 异步委托
///// </summary>
///// <param name="parameter">参数</param>
//public delegate Task CommandHandlerAsync(object parameter);

/// <summary>
/// 异步事件
/// </summary>
public event CommandHandlerAsync? CommandEventAsync;
///// <summary>
///// 异步事件
///// </summary>
//public event CommandHandlerAsync? CommandEventAsync;
}
6 changes: 2 additions & 4 deletions StarsectorToolbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.17763.0</TargetFramework>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -32,7 +32,6 @@
<IncludeSymbols>False</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -44,9 +43,8 @@
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="Emoji.Wpf" Version="0.3.4" />
<PackageReference Include="HKW.TOML" Version="1.1.7" />
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Include="Panuon.WPF.UI" Version="1.1.9.4" />
<PackageReference Include="Panuon.WPF.UI" Version="1.1.10" />
<PackageReference Include="SharpCompress" Version="0.33.0" />
<PackageReference Include="System.Management" Version="7.0.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
Expand Down
2 changes: 1 addition & 1 deletion ThemeResources/ControlStyles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
</Style>
<Style
x:Key="MenuItemBaseStyle"
BasedOn="{StaticResource {x:Static pu:ContextMenuHelper.MenuItemStyle}}"
BasedOn="{StaticResource {x:Static pu:ContextMenuHelper.MenuItemStyleKey}}"
TargetType="MenuItem">
<Setter Property="Background" Value="{DynamicResource ColorBG}" />
<Setter Property="BorderBrush" Value="{DynamicResource ColorLight3}" />
Expand Down
2 changes: 1 addition & 1 deletion Views/CrashReporter/CrashReporterWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<pu:WindowXCaption.CloseButtonStyle>
<Style BasedOn="{StaticResource {x:Static pu:WindowXCaption.CloseButtonStyle}}" TargetType="Button">
<Style BasedOn="{StaticResource {x:Static pu:WindowXCaption.CloseButtonStyleKey}}" TargetType="Button">
<Setter Property="Command" Value="{Binding DataContext.CloseCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=pu:WindowX}}" />
</Style>
</pu:WindowXCaption.CloseButtonStyle>
Expand Down
1 change: 0 additions & 1 deletion Views/Main/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Windows.Media;
using HKW.Libs.Log4Cs;
using HKW.ViewModels.Dialogs;
using Microsoft.Toolkit.Uwp.Notifications;
using Panuon.WPF.UI;
using StarsectorToolbox.ViewModels.Main;
using StarsectorToolbox.Views.CrashReporter;
Expand Down

0 comments on commit 66c16c6

Please sign in to comment.