diff --git a/ConfuserEx/BoolToVisibilityConverter.cs b/ConfuserEx/BoolToVisibilityConverter.cs index 2d5afb72d..dfd35fc89 100644 --- a/ConfuserEx/BoolToVisibilityConverter.cs +++ b/ConfuserEx/BoolToVisibilityConverter.cs @@ -11,7 +11,7 @@ internal class BoolToVisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Debug.Assert(value is bool); - Debug.Assert(targetType == typeof(Visibility)); + Debug.Assert(targetType == typeof(Visibility) || targetType == typeof(Visibility?), $"Expected Visibility or Nullable, but {targetType} given."); return (bool)value ? Visibility.Visible : Visibility.Collapsed; } @@ -19,4 +19,4 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu throw new NotSupportedException(); } } -} \ No newline at end of file +} diff --git a/ConfuserEx/ConfuserEx.csproj b/ConfuserEx/ConfuserEx.csproj index c22d9e822..bfe5247d7 100644 --- a/ConfuserEx/ConfuserEx.csproj +++ b/ConfuserEx/ConfuserEx.csproj @@ -15,8 +15,9 @@ - - + + + diff --git a/ConfuserEx/FileDragDrop.cs b/ConfuserEx/FileDragDrop.cs index c58a5a10a..e0200fdc0 100644 --- a/ConfuserEx/FileDragDrop.cs +++ b/ConfuserEx/FileDragDrop.cs @@ -5,9 +5,14 @@ using System.Linq; using System.Windows; using System.Windows.Controls; -using System.Windows.Input; +using System.Windows.Input; +#if NET +using CommunityToolkit.Mvvm.Input; +using DragDropCommand = CommunityToolkit.Mvvm.Input.RelayCommand>; +#else +using GalaSoft.MvvmLight.CommandWpf; +#endif using ConfuserEx.ViewModel; -using GalaSoft.MvvmLight.CommandWpf; namespace ConfuserEx { public class FileDragDrop { @@ -108,12 +113,13 @@ static void OnDrop(object sender, DragEventArgs e) { cmd.Execute(e.Data); } e.Handled = true; - } - - + } + +#if NETFRAMEWORK class DragDropCommand : RelayCommand> { public DragDropCommand(Action> execute, Func, bool> canExecute) : base(execute, canExecute) { } - } + } +#endif } -} \ No newline at end of file +} diff --git a/ConfuserEx/ViewModel/UI/AboutTabVM.cs b/ConfuserEx/ViewModel/UI/AboutTabVM.cs index 113b452af..b91bedbec 100644 --- a/ConfuserEx/ViewModel/UI/AboutTabVM.cs +++ b/ConfuserEx/ViewModel/UI/AboutTabVM.cs @@ -2,9 +2,13 @@ using System.Diagnostics; using System.Linq; using System.Windows.Input; -using System.Windows.Media.Imaging; -using GalaSoft.MvvmLight.CommandWpf; - +using System.Windows.Media.Imaging; +#if NET +using CommunityToolkit.Mvvm.Input; +#else +using GalaSoft.MvvmLight.CommandWpf; +#endif + namespace ConfuserEx.ViewModel { internal class AboutTabVM : TabViewModel { public AboutTabVM(AppVM app) @@ -20,4 +24,4 @@ public ICommand LaunchBrowser { public BitmapSource Icon { get; private set; } } -} \ No newline at end of file +} diff --git a/ConfuserEx/ViewModel/UI/AppVM.cs b/ConfuserEx/ViewModel/UI/AppVM.cs index b058b239c..2bd80fbc7 100644 --- a/ConfuserEx/ViewModel/UI/AppVM.cs +++ b/ConfuserEx/ViewModel/UI/AppVM.cs @@ -7,8 +7,12 @@ using System.Windows.Input; using System.Xml; using Confuser.Core; -using Confuser.Core.Project; -using GalaSoft.MvvmLight.CommandWpf; +using Confuser.Core.Project; +#if NET +using CommunityToolkit.Mvvm.Input; +#else +using GalaSoft.MvvmLight.CommandWpf; +#endif using Ookii.Dialogs.Wpf; namespace ConfuserEx.ViewModel { diff --git a/ConfuserEx/ViewModel/UI/ProjectTabVM.cs b/ConfuserEx/ViewModel/UI/ProjectTabVM.cs index 899dd5f9f..829add60c 100644 --- a/ConfuserEx/ViewModel/UI/ProjectTabVM.cs +++ b/ConfuserEx/ViewModel/UI/ProjectTabVM.cs @@ -5,8 +5,12 @@ using System.Windows; using System.Windows.Input; using Confuser.Core.Project; -using ConfuserEx.Views; -using GalaSoft.MvvmLight.CommandWpf; +using ConfuserEx.Views; +#if NET +using CommunityToolkit.Mvvm.Input; +#else +using GalaSoft.MvvmLight.CommandWpf; +#endif using Ookii.Dialogs.Wpf; namespace ConfuserEx.ViewModel { diff --git a/ConfuserEx/ViewModel/UI/ProtectTabVM.cs b/ConfuserEx/ViewModel/UI/ProtectTabVM.cs index 7e2f1686e..c98524cc2 100644 --- a/ConfuserEx/ViewModel/UI/ProtectTabVM.cs +++ b/ConfuserEx/ViewModel/UI/ProtectTabVM.cs @@ -6,9 +6,13 @@ using System.Windows.Input; using System.Windows.Media; using Confuser.Core; -using Confuser.Core.Project; -using GalaSoft.MvvmLight.CommandWpf; - +using Confuser.Core.Project; +#if NET +using CommunityToolkit.Mvvm.Input; +#else +using GalaSoft.MvvmLight.CommandWpf; +#endif + namespace ConfuserEx.ViewModel { internal class ProtectTabVM : TabViewModel, ILogger { readonly Paragraph documentContent; diff --git a/ConfuserEx/ViewModel/UI/SettingsTabVM.cs b/ConfuserEx/ViewModel/UI/SettingsTabVM.cs index 5641d0886..a7ed79391 100644 --- a/ConfuserEx/ViewModel/UI/SettingsTabVM.cs +++ b/ConfuserEx/ViewModel/UI/SettingsTabVM.cs @@ -7,9 +7,13 @@ using System.Windows.Input; using Confuser.Core; using Confuser.Core.Project; -using ConfuserEx.Views; -using GalaSoft.MvvmLight.CommandWpf; - +using ConfuserEx.Views; +#if NET +using CommunityToolkit.Mvvm.Input; +#else +using GalaSoft.MvvmLight.CommandWpf; +#endif + namespace ConfuserEx.ViewModel { internal class SettingsTabVM : TabViewModel { bool hasPacker; diff --git a/ConfuserEx/Views/ProjectRuleView.xaml.cs b/ConfuserEx/Views/ProjectRuleView.xaml.cs index 6d8a15348..6e3c1b76b 100644 --- a/ConfuserEx/Views/ProjectRuleView.xaml.cs +++ b/ConfuserEx/Views/ProjectRuleView.xaml.cs @@ -5,9 +5,13 @@ using System.Windows.Media; using Confuser.Core; using Confuser.Core.Project; -using ConfuserEx.ViewModel; -using GalaSoft.MvvmLight.CommandWpf; - +using ConfuserEx.ViewModel; +#if NET +using CommunityToolkit.Mvvm.Input; +#else +using GalaSoft.MvvmLight.CommandWpf; +#endif + namespace ConfuserEx.Views { public partial class ProjectRuleView : Window { readonly ProjectVM proj; @@ -43,7 +47,12 @@ public override void OnApplyTemplate() { prots.SelectedIndex = selIndex >= rule.Protections.Count ? rule.Protections.Count - 1 : selIndex; }, () => prots.SelectedIndex != -1); - prots.SelectionChanged += (sender, args) => (RemoveBtn.Command as RelayCommand)?.RaiseCanExecuteChanged(); + prots.SelectionChanged += (sender, args) => (RemoveBtn.Command as RelayCommand)? +#if NETFRAMEWORK + .RaiseCanExecuteChanged(); +#else + .NotifyCanExecuteChanged(); +#endif } public void Cleanup() { diff --git a/ConfuserEx/Views/ProjectTabAdvancedView.xaml.cs b/ConfuserEx/Views/ProjectTabAdvancedView.xaml.cs index fe6bbd244..f6b779e85 100644 --- a/ConfuserEx/Views/ProjectTabAdvancedView.xaml.cs +++ b/ConfuserEx/Views/ProjectTabAdvancedView.xaml.cs @@ -1,8 +1,12 @@ using System; using System.Diagnostics; using System.Windows; -using ConfuserEx.ViewModel; -using GalaSoft.MvvmLight.CommandWpf; +using ConfuserEx.ViewModel; +#if NET +using CommunityToolkit.Mvvm.Input; +#else +using GalaSoft.MvvmLight.CommandWpf; +#endif using Ookii.Dialogs.Wpf; namespace ConfuserEx.Views { @@ -61,4 +65,4 @@ public override void OnApplyTemplate() { }, () => ProbePaths.SelectedIndex != -1); } } -} \ No newline at end of file +}