diff --git a/SvgToXaml.sln b/SvgToXaml.sln index 3587468..3d21cbf 100644 --- a/SvgToXaml.sln +++ b/SvgToXaml.sln @@ -45,7 +45,6 @@ ProjectSection(SolutionItems) = preProject build\Avalonia.Desktop.props = build\Avalonia.Desktop.props build\Avalonia.Diagnostics.props = build\Avalonia.Diagnostics.props build\Avalonia.props = build\Avalonia.props - build\Avalonia.ReactiveUI.props = build\Avalonia.ReactiveUI.props build\Avalonia.Skia.props = build\Avalonia.Skia.props build\Base.props = build\Base.props build\ReferenceAssemblies.props = build\ReferenceAssemblies.props @@ -62,6 +61,8 @@ ProjectSection(SolutionItems) = preProject build\System.Text.Json.props = build\System.Text.Json.props build\Avalonia.Web.Blazor.props = build\Avalonia.Web.Blazor.props build\Avalonia.Themes.Fluent.props = build\Avalonia.Themes.Fluent.props + build\CommunityToolkit.Mvvm.props = build\CommunityToolkit.Mvvm.props + build\ReactiveMarbles.PropertyChanged.props = build\ReactiveMarbles.PropertyChanged.props EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_build", "build\build\_build.csproj", "{E9A88CB0-B853-44C3-8A7E-F67DAD2A7F9B}" diff --git a/build/Avalonia.ReactiveUI.props b/build/CommunityToolkit.Mvvm.props similarity index 68% rename from build/Avalonia.ReactiveUI.props rename to build/CommunityToolkit.Mvvm.props index 41fa7c6..22ca9a8 100644 --- a/build/Avalonia.ReactiveUI.props +++ b/build/CommunityToolkit.Mvvm.props @@ -1,6 +1,6 @@  - + diff --git a/build/ReactiveMarbles.PropertyChanged.props b/build/ReactiveMarbles.PropertyChanged.props new file mode 100644 index 0000000..5f671e7 --- /dev/null +++ b/build/ReactiveMarbles.PropertyChanged.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/SvgToXaml.Base/SvgToXaml.Base.csproj b/src/SvgToXaml.Base/SvgToXaml.Base.csproj index 5c6ea18..8fa18b4 100644 --- a/src/SvgToXaml.Base/SvgToXaml.Base.csproj +++ b/src/SvgToXaml.Base/SvgToXaml.Base.csproj @@ -26,7 +26,6 @@ - @@ -34,6 +33,8 @@ + + diff --git a/src/SvgToXaml.Base/ViewModels/FileItemViewModel.cs b/src/SvgToXaml.Base/ViewModels/FileItemViewModel.cs index 53eb284..93700cd 100644 --- a/src/SvgToXaml.Base/ViewModels/FileItemViewModel.cs +++ b/src/SvgToXaml.Base/ViewModels/FileItemViewModel.cs @@ -2,7 +2,7 @@ using System.Text.Json.Serialization; using System.Threading.Tasks; using System.Windows.Input; -using ReactiveUI; +using CommunityToolkit.Mvvm.Input; using Svg.Model; namespace SvgToXaml.ViewModels; @@ -19,28 +19,28 @@ public class FileItemViewModel : ViewModelBase public string Name { get => _name; - private set => this.RaiseAndSetIfChanged(ref _name, value); + private set => SetProperty(ref _name, value); } [JsonInclude] public string Path { get => _path; - private set => this.RaiseAndSetIfChanged(ref _path, value); + private set => SetProperty(ref _path, value); } [JsonIgnore] public SvgViewModel? Svg { get => _svg; - private set => this.RaiseAndSetIfChanged(ref _svg, value); + private set => SetProperty(ref _svg, value); } [JsonIgnore] public SkiaSharp.SKPicture? Picture { get => _picture; - private set => this.RaiseAndSetIfChanged(ref _picture, value); + private set => SetProperty(ref _picture, value); } [JsonIgnore] @@ -64,9 +64,9 @@ public class FileItemViewModel : ViewModelBase public void Initialize(Func preview, Func remove) { - PreviewCommand = ReactiveCommand.CreateFromTask(async () => await preview(this)); + PreviewCommand = new AsyncRelayCommand(async () => await preview(this)); - RemoveCommand = ReactiveCommand.Create(async () => await remove(this)); + RemoveCommand = new AsyncRelayCommand(async () => await remove(this)); } public async Task Load(DrawAttributes ignoreAttribute) @@ -100,4 +100,4 @@ public class FileItemViewModel : ViewModelBase Svg = null; } } -} \ No newline at end of file +} diff --git a/src/SvgToXaml.Base/ViewModels/MainWindowViewModel.cs b/src/SvgToXaml.Base/ViewModels/MainWindowViewModel.cs index 0e206da..375e8f3 100644 --- a/src/SvgToXaml.Base/ViewModels/MainWindowViewModel.cs +++ b/src/SvgToXaml.Base/ViewModels/MainWindowViewModel.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using System.Reactive.Linq; using System.Text; using System.Text.Json; using System.Text.Json.Serialization; @@ -14,7 +15,8 @@ using Avalonia.Controls.ApplicationLifetimes; using Avalonia.Markup.Xaml; using Avalonia.Platform.Storage; using Avalonia.Threading; -using ReactiveUI; +using CommunityToolkit.Mvvm.Input; +using ReactiveMarbles.PropertyChanged; using SvgToXaml.Views; using ResourceDictionary = SvgToXamlConverter.Model.Resources.ResourceDictionary; @@ -28,7 +30,7 @@ public class MainWindowViewModel : ViewModelBase public ProjectViewModel Project { get => _project; - set => this.RaiseAndSetIfChanged(ref _project, value); + set => SetProperty(ref _project, value); } [JsonIgnore] @@ -63,26 +65,26 @@ public class MainWindowViewModel : ViewModelBase { _project = new ProjectViewModel(); - ClearCommand = ReactiveCommand.Create(Clear); + ClearCommand = new RelayCommand(Clear); - OpenCommand = ReactiveCommand.CreateFromTask(async () => await Open()); + OpenCommand = new AsyncRelayCommand(async () => await Open()); - SaveCommand = ReactiveCommand.CreateFromTask(async () => await Save()); + SaveCommand = new AsyncRelayCommand(async () => await Save()); - AddCommand = ReactiveCommand.CreateFromTask(async () => await Add()); + AddCommand = new AsyncRelayCommand(async () => await Add()); - CopySelectedCommand = ReactiveCommand.CreateFromTask(async format => await CopySelected(format)); + CopySelectedCommand = new AsyncRelayCommand(async format => await CopySelected(format)); - CopyAllCommand = ReactiveCommand.CreateFromTask(async format => await CopyAll(format)); + CopyAllCommand = new AsyncRelayCommand(async format => await CopyAll(format)); - ExportSelectedCommand = ReactiveCommand.CreateFromTask(async format => await ExportSelected(format)); + ExportSelectedCommand = new AsyncRelayCommand(async format => await ExportSelected(format)); - ExportAllCommand = ReactiveCommand.CreateFromTask(async format => await ExportAll(format)); + ExportAllCommand = new AsyncRelayCommand(async format => await ExportAll(format)); - ClipboardCommand = ReactiveCommand.CreateFromTask(async format => await Clipboard(format)); + ClipboardCommand = new AsyncRelayCommand(async format => await Clipboard(format)); // ReSharper disable once AsyncVoidLambda - this.WhenAnyValue(x => x.Project.SelectedItem).Subscribe(async x => + this.WhenChanged(x => x.Project.SelectedItem).DistinctUntilChanged().Subscribe(async x => { if (x is { }) { @@ -91,31 +93,31 @@ public class MainWindowViewModel : ViewModelBase }); // ReSharper disable once AsyncVoidLambda - this.WhenAnyValue(x => x.Project.Settings.UseCompatMode).Subscribe(async _ => + this.WhenChanged(x => x.Project.Settings.UseCompatMode).DistinctUntilChanged().Subscribe(async _ => { await Reload(); }); // ReSharper disable once AsyncVoidLambda - this.WhenAnyValue(x => x.Project.Settings.IgnoreOpacity).Subscribe(async _ => + this.WhenChanged(x => x.Project.Settings.IgnoreOpacity).DistinctUntilChanged().Subscribe(async _ => { await Reload(); }); // ReSharper disable once AsyncVoidLambda - this.WhenAnyValue(x => x.Project.Settings.IgnoreFilter).Subscribe(async _ => + this.WhenChanged(x => x.Project.Settings.IgnoreFilter).DistinctUntilChanged().Subscribe(async _ => { await Reload(); }); // ReSharper disable once AsyncVoidLambda - this.WhenAnyValue(x => x.Project.Settings.IgnoreClipPath).Subscribe(async _ => + this.WhenChanged(x => x.Project.Settings.IgnoreClipPath).DistinctUntilChanged().Subscribe(async _ => { await Reload(); }); // ReSharper disable once AsyncVoidLambda - this.WhenAnyValue(x => x.Project.Settings.IgnoreMask).Subscribe(async _ => + this.WhenChanged(x => x.Project.Settings.IgnoreMask).DistinctUntilChanged().Subscribe(async _ => { await Reload(); }); diff --git a/src/SvgToXaml.Base/ViewModels/ProjectViewModel.cs b/src/SvgToXaml.Base/ViewModels/ProjectViewModel.cs index a020bbe..9a1107e 100644 --- a/src/SvgToXaml.Base/ViewModels/ProjectViewModel.cs +++ b/src/SvgToXaml.Base/ViewModels/ProjectViewModel.cs @@ -1,6 +1,5 @@ using System.Collections.ObjectModel; using System.Text.Json.Serialization; -using ReactiveUI; using Svg.Model; namespace SvgToXaml.ViewModels; @@ -15,21 +14,21 @@ public class ProjectViewModel : ViewModelBase public FileItemViewModel? SelectedItem { get => _selectedItem; - set => this.RaiseAndSetIfChanged(ref _selectedItem, value); + set => SetProperty(ref _selectedItem, value); } [JsonInclude] public ObservableCollection Items { get => _items; - set => this.RaiseAndSetIfChanged(ref _items, value); + set => SetProperty(ref _items, value); } [JsonInclude] public SettingsViewModel Settings { get => _settings; - set => this.RaiseAndSetIfChanged(ref _settings, value); + set => SetProperty(ref _settings, value); } [JsonConstructor] diff --git a/src/SvgToXaml.Base/ViewModels/SettingsViewModel.cs b/src/SvgToXaml.Base/ViewModels/SettingsViewModel.cs index 42052fc..6d57334 100644 --- a/src/SvgToXaml.Base/ViewModels/SettingsViewModel.cs +++ b/src/SvgToXaml.Base/ViewModels/SettingsViewModel.cs @@ -1,5 +1,4 @@ using System.Text.Json.Serialization; -using ReactiveUI; namespace SvgToXaml.ViewModels; @@ -20,70 +19,70 @@ public class SettingsViewModel : ViewModelBase public bool EnableGenerateImage { get => _enableGenerateImage; - set => this.RaiseAndSetIfChanged(ref _enableGenerateImage, value); + set => SetProperty(ref _enableGenerateImage, value); } [JsonInclude] public bool EnableGeneratePreview { get => _enableGeneratePreview; - set => this.RaiseAndSetIfChanged(ref _enableGeneratePreview, value); + set => SetProperty(ref _enableGeneratePreview, value); } [JsonInclude] public bool UseResources { get => _useResources; - set => this.RaiseAndSetIfChanged(ref _useResources, value); + set => SetProperty(ref _useResources, value); } [JsonInclude] public bool ReuseExistingResources { get => _reuseExistingResources; - set => this.RaiseAndSetIfChanged(ref _reuseExistingResources, value); + set => SetProperty(ref _reuseExistingResources, value); } [JsonInclude] public bool UseCompatMode { get => _useCompatMode; - set => this.RaiseAndSetIfChanged(ref _useCompatMode, value); + set => SetProperty(ref _useCompatMode, value); } [JsonInclude] public bool AddTransparentBackground { get => _addTransparentBackground; - set => this.RaiseAndSetIfChanged(ref _addTransparentBackground, value); + set => SetProperty(ref _addTransparentBackground, value); } [JsonInclude] public bool IgnoreOpacity { get => _ignoreOpacity; - set => this.RaiseAndSetIfChanged(ref _ignoreOpacity, value); + set => SetProperty(ref _ignoreOpacity, value); } [JsonInclude] public bool IgnoreFilter { get => _ignoreFilter; - set => this.RaiseAndSetIfChanged(ref _ignoreFilter, value); + set => SetProperty(ref _ignoreFilter, value); } [JsonInclude] public bool IgnoreClipPath { get => _ignoreClipPath; - set => this.RaiseAndSetIfChanged(ref _ignoreClipPath, value); + set => SetProperty(ref _ignoreClipPath, value); } [JsonInclude] public bool IgnoreMask { get => _ignoreMask; - set => this.RaiseAndSetIfChanged(ref _ignoreMask, value); + set => SetProperty(ref _ignoreMask, value); } [JsonConstructor] diff --git a/src/SvgToXaml.Base/ViewModels/ViewModelBase.cs b/src/SvgToXaml.Base/ViewModels/ViewModelBase.cs index b25e265..19a1101 100644 --- a/src/SvgToXaml.Base/ViewModels/ViewModelBase.cs +++ b/src/SvgToXaml.Base/ViewModels/ViewModelBase.cs @@ -1,7 +1,7 @@ -using ReactiveUI; +using CommunityToolkit.Mvvm.ComponentModel; namespace SvgToXaml.ViewModels; -public class ViewModelBase : ReactiveObject +public class ViewModelBase : ObservableObject { -} \ No newline at end of file +} diff --git a/src/SvgToXaml.Desktop/Program.cs b/src/SvgToXaml.Desktop/Program.cs index 04d1bdb..f1e3bb6 100644 --- a/src/SvgToXaml.Desktop/Program.cs +++ b/src/SvgToXaml.Desktop/Program.cs @@ -1,7 +1,6 @@ using System; using Avalonia; using Avalonia.Controls.Skia; -using Avalonia.ReactiveUI; using Avalonia.Xaml.Interactions.Core; using Avalonia.Xaml.Interactivity; @@ -25,21 +24,14 @@ class Program .UsePlatformDetect() .LogToTrace() .UseSkia() - //.UseDirect2D1() .With(new Win32PlatformOptions() { - UseDeferredRendering = true, - AllowEglInitialization = true, - UseWindowsUIComposition = true }) .With(new X11PlatformOptions() { - UseDeferredRendering = true }) .With(new AvaloniaNativePlatformOptions() { - UseDeferredRendering = true - }) - .UseReactiveUI(); + }); } } diff --git a/src/SvgToXaml.Desktop/SvgToXaml.Desktop.csproj b/src/SvgToXaml.Desktop/SvgToXaml.Desktop.csproj index 088bc3f..c84dc20 100644 --- a/src/SvgToXaml.Desktop/SvgToXaml.Desktop.csproj +++ b/src/SvgToXaml.Desktop/SvgToXaml.Desktop.csproj @@ -25,7 +25,6 @@ - diff --git a/src/SvgToXaml.Web/App.razor.cs b/src/SvgToXaml.Web/App.razor.cs index 6603b00..4390bf9 100644 --- a/src/SvgToXaml.Web/App.razor.cs +++ b/src/SvgToXaml.Web/App.razor.cs @@ -1,4 +1,3 @@ -using Avalonia.ReactiveUI; using Avalonia.Web.Blazor; namespace SvgToXaml.Web; @@ -10,7 +9,6 @@ public partial class App base.OnParametersSet(); WebAppBuilder.Configure() - .UseReactiveUI() .SetupWithSingleViewLifetime(); } }