Migrate to CommunityToolkit.Mvvm and ReactiveMarbles.PropertyChanged
This commit is contained in:
Родитель
deb383c050
Коммит
d30242234e
|
@ -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}"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview1" />
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ReactiveMarbles.PropertyChanged" Version="2.0.27" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -26,7 +26,6 @@
|
|||
<Import Project="..\..\build\Avalonia.props" />
|
||||
<Import Project="..\..\build\Avalonia.Themes.Fluent.props" />
|
||||
<Import Project="..\..\build\Avalonia.Diagnostics.props" />
|
||||
<Import Project="..\..\build\Avalonia.ReactiveUI.props" />
|
||||
<Import Project="..\..\build\Avalonia.Markup.Xaml.Loader.props" />
|
||||
<Import Project="..\..\build\Avalonia.Xaml.Behaviors.props" />
|
||||
<Import Project="..\..\build\Avalonia.Controls.Skia.props" />
|
||||
|
@ -34,6 +33,8 @@
|
|||
<Import Project="..\..\build\SkiaSharp.Linux.props" />
|
||||
<Import Project="..\..\build\Svg.Skia.props" />
|
||||
<Import Project="..\..\build\System.Text.Json.props" />
|
||||
<Import Project="..\..\build\CommunityToolkit.Mvvm.props" />
|
||||
<Import Project="..\..\build\ReactiveMarbles.PropertyChanged.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SvgToXamlConverter\SvgToXamlConverter.csproj" />
|
||||
|
|
|
@ -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<FileItemViewModel, Task> preview, Func<FileItemViewModel, Task> 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)
|
||||
|
|
|
@ -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<string>(async format => await CopySelected(format));
|
||||
CopySelectedCommand = new AsyncRelayCommand<string>(async format => await CopySelected(format));
|
||||
|
||||
CopyAllCommand = ReactiveCommand.CreateFromTask<string>(async format => await CopyAll(format));
|
||||
CopyAllCommand = new AsyncRelayCommand<string>(async format => await CopyAll(format));
|
||||
|
||||
ExportSelectedCommand = ReactiveCommand.CreateFromTask<string>(async format => await ExportSelected(format));
|
||||
ExportSelectedCommand = new AsyncRelayCommand<string>(async format => await ExportSelected(format));
|
||||
|
||||
ExportAllCommand = ReactiveCommand.CreateFromTask<string>(async format => await ExportAll(format));
|
||||
ExportAllCommand = new AsyncRelayCommand<string>(async format => await ExportAll(format));
|
||||
|
||||
ClipboardCommand = ReactiveCommand.CreateFromTask<string>(async format => await Clipboard(format));
|
||||
ClipboardCommand = new AsyncRelayCommand<string>(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();
|
||||
});
|
||||
|
|
|
@ -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<FileItemViewModel> 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]
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using ReactiveUI;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace SvgToXaml.ViewModels;
|
||||
|
||||
public class ViewModelBase : ReactiveObject
|
||||
public class ViewModelBase : ObservableObject
|
||||
{
|
||||
}
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
<Import Project="..\..\build\Avalonia.props" />
|
||||
<Import Project="..\..\build\Avalonia.Desktop.props" />
|
||||
<Import Project="..\..\build\Avalonia.Diagnostics.props" />
|
||||
<Import Project="..\..\build\Avalonia.ReactiveUI.props" />
|
||||
<Import Project="..\..\build\Avalonia.Markup.Xaml.Loader.props" />
|
||||
<Import Project="..\..\build\Avalonia.Xaml.Behaviors.props" />
|
||||
<Import Project="..\..\build\Avalonia.Controls.Skia.props" />
|
||||
|
|
|
@ -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<SvgToXaml.App>()
|
||||
.UseReactiveUI()
|
||||
.SetupWithSingleViewLifetime();
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче