mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Core - Reworked profile render override for the editor and new previewer
This commit is contained in:
1 parent
c6a318b6e3
commit
d2b8123a30
42 files changed
+812
-399
No files matched your search
@@ -52,9 +52,9 @@ public class ProfileConfigurationEditViewModel : DialogViewModelBase<ProfileConf
|
||||
_windowService = windowService;
|
||||
_profileService = profileService;
|
||||
_profileEditorService = profileEditorService;
|
||||
|
||||
_profileConfiguration = profileConfiguration == ProfileConfiguration.Empty
|
||||
? profileService.CreateProfileConfiguration(profileCategory, "New profile", Enum.GetValues<MaterialIconKind>().First().ToString())
|
||||
|
||||
_profileConfiguration = profileConfiguration == ProfileConfiguration.Empty
|
||||
? profileService.CreateProfileConfiguration(profileCategory, "New profile", Enum.GetValues<MaterialIconKind>().First().ToString())
|
||||
: profileConfiguration;
|
||||
_profileName = _profileConfiguration.Name;
|
||||
_iconType = _profileConfiguration.Icon.IconType;
|
||||
@@ -140,7 +140,7 @@ public class ProfileConfigurationEditViewModel : DialogViewModelBase<ProfileConf
|
||||
public ReactiveCommand<Unit, Unit> Confirm { get; }
|
||||
public ReactiveCommand<Unit, Unit> Delete { get; }
|
||||
public ReactiveCommand<Unit, Unit> Cancel { get; }
|
||||
|
||||
|
||||
private async Task ExecuteDelete()
|
||||
{
|
||||
if (IsNew)
|
||||
@@ -148,7 +148,7 @@ public class ProfileConfigurationEditViewModel : DialogViewModelBase<ProfileConf
|
||||
if (!await _windowService.ShowConfirmContentDialog("Delete profile", "Are you sure you want to permanently delete this profile?"))
|
||||
return;
|
||||
|
||||
if (_profileConfiguration.IsBeingEdited)
|
||||
if (_profileService.FocusProfile == _profileConfiguration)
|
||||
await _profileEditorService.ChangeCurrentProfileConfiguration(null);
|
||||
_profileService.RemoveProfileConfiguration(_profileConfiguration);
|
||||
Close(_profileConfiguration);
|
||||
@@ -184,7 +184,7 @@ public class ProfileConfigurationEditViewModel : DialogViewModelBase<ProfileConf
|
||||
get => _iconType;
|
||||
set => RaiseAndSetIfChanged(ref _iconType, value);
|
||||
}
|
||||
|
||||
|
||||
public ProfileIconViewModel? SelectedMaterialIcon
|
||||
{
|
||||
get => _selectedMaterialIcon;
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace Artemis.UI.Screens.Sidebar;
|
||||
public class SidebarCategoryViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly IWindowService _windowService;
|
||||
private readonly ISidebarVmFactory _vmFactory;
|
||||
private readonly IRouter _router;
|
||||
private readonly ISidebarVmFactory _vmFactory;
|
||||
private readonly IWindowService _windowService;
|
||||
private ObservableAsPropertyHelper<bool>? _isCollapsed;
|
||||
private ObservableAsPropertyHelper<bool>? _isSuspended;
|
||||
private SidebarProfileConfigurationViewModel? _selectedProfileConfiguration;
|
||||
@@ -67,9 +67,9 @@ public class SidebarCategoryViewModel : ActivatableViewModelBase
|
||||
.WhereNotNull()
|
||||
.Subscribe(s => _router.Navigate($"profile-editor/{s.ProfileConfiguration.ProfileId}", new RouterNavigationOptions {IgnoreOnPartialMatch = true, RecycleScreens = false}))
|
||||
.DisposeWith(d);
|
||||
|
||||
|
||||
_router.CurrentPath.WhereNotNull().Subscribe(r => SelectedProfileConfiguration = ProfileConfigurations.FirstOrDefault(c => c.Matches(r))).DisposeWith(d);
|
||||
|
||||
|
||||
// Update the list of profiles whenever the category fires events
|
||||
Observable.FromEventPattern<ProfileConfigurationEventArgs>(x => profileCategory.ProfileConfigurationAdded += x, x => profileCategory.ProfileConfigurationAdded -= x)
|
||||
.Subscribe(e => profileConfigurations.Add(e.EventArgs.ProfileConfiguration))
|
||||
@@ -77,7 +77,7 @@ public class SidebarCategoryViewModel : ActivatableViewModelBase
|
||||
Observable.FromEventPattern<ProfileConfigurationEventArgs>(x => profileCategory.ProfileConfigurationRemoved += x, x => profileCategory.ProfileConfigurationRemoved -= x)
|
||||
.Subscribe(e => profileConfigurations.RemoveMany(profileConfigurations.Items.Where(c => c == e.EventArgs.ProfileConfiguration)))
|
||||
.DisposeWith(d);
|
||||
|
||||
|
||||
_isCollapsed = ProfileCategory.WhenAnyValue(vm => vm.IsCollapsed).ToProperty(this, vm => vm.IsCollapsed).DisposeWith(d);
|
||||
_isSuspended = ProfileCategory.WhenAnyValue(vm => vm.IsSuspended).ToProperty(this, vm => vm.IsSuspended).DisposeWith(d);
|
||||
});
|
||||
@@ -136,7 +136,7 @@ public class SidebarCategoryViewModel : ActivatableViewModelBase
|
||||
{
|
||||
if (await _windowService.ShowConfirmContentDialog($"Delete {ProfileCategory.Name}", "Do you want to delete this category and all its profiles?"))
|
||||
{
|
||||
if (ProfileCategory.ProfileConfigurations.Any(c => c.IsBeingEdited))
|
||||
if (ProfileCategory.ProfileConfigurations.Any(c => _profileService.FocusProfile == c))
|
||||
await _router.Navigate("home");
|
||||
_profileService.DeleteProfileCategory(ProfileCategory);
|
||||
}
|
||||
@@ -153,7 +153,7 @@ public class SidebarCategoryViewModel : ActivatableViewModelBase
|
||||
}
|
||||
|
||||
private async Task ExecuteImportProfile()
|
||||
{
|
||||
{
|
||||
string[]? result = await _windowService.CreateOpenFileDialog()
|
||||
.HavingFilter(f => f.WithExtension("json").WithName("Artemis profile"))
|
||||
.ShowAsync();
|
||||
|
||||
@@ -98,7 +98,7 @@ public class SidebarProfileConfigurationViewModel : ActivatableViewModelBase
|
||||
if (!await _windowService.ShowConfirmContentDialog("Delete profile", "Are you sure you want to permanently delete this profile?"))
|
||||
return;
|
||||
|
||||
if (ProfileConfiguration.IsBeingEdited)
|
||||
if (_profileService.FocusProfile == ProfileConfiguration)
|
||||
await _router.Navigate("home");
|
||||
_profileService.RemoveProfileConfiguration(ProfileConfiguration);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user