mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Sidebar - Added category reordering
Sidebar - Fix disabled profiles not fading Sidebar - Fix module missing when editing existing profile configs Profile - Remove old undo/redo code
This commit is contained in:
1 parent
5873df250d
commit
b6e0c0fb66
8 files changed
+71
-216
No files matched your search
@@ -68,6 +68,7 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
pluginManagementService.GetFeaturesOfType<Module>().Where(m => !m.IsAlwaysAvailable).Select(m => new ProfileModuleViewModel(m))
|
||||
);
|
||||
Modules.Insert(0, null);
|
||||
_selectedModule = Modules.FirstOrDefault(m => m?.Module == _profileConfiguration.Module);
|
||||
|
||||
VisualEditorViewModel = nodeVmFactory.NodeScriptViewModel(_profileConfiguration.ActivationCondition, true);
|
||||
|
||||
|
||||
@@ -89,7 +89,32 @@
|
||||
</Setter>
|
||||
</Style>
|
||||
</UserControl.Styles>
|
||||
<Grid x:Name="ContainerGrid" Margin="0 8 0 0" RowDefinitions="Auto,*">
|
||||
<Grid x:Name="ContainerGrid" Margin="0 8 0 0" RowDefinitions="Auto,*" >
|
||||
<Grid.ContextFlyout>
|
||||
<MenuFlyout>
|
||||
<MenuItem Header="View properties" Command="{CompiledBinding EditCategory}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Cog" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Suspend" Command="{CompiledBinding ToggleSuspended}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="Check" IsVisible="{CompiledBinding IsSuspended}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="-" />
|
||||
<MenuItem Header="Move up" Command="{CompiledBinding MoveUp}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="ArrowUp" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Move down" Command="{CompiledBinding MoveDown}">
|
||||
<MenuItem.Icon>
|
||||
<avalonia:MaterialIcon Kind="ArrowDown" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</MenuFlyout>
|
||||
</Grid.ContextFlyout>
|
||||
<Grid Grid.Row="0" Background="Transparent" Margin="0 0 6 0" ColumnDefinitions="Auto,*,Auto,Auto,Auto,Auto">
|
||||
<avalonia:MaterialIcon Classes.chevron-collapsed="{CompiledBinding !IsCollapsed}"
|
||||
Kind="ChevronUp"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
@@ -54,6 +55,8 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
ToggleSuspended = ReactiveCommand.Create(ExecuteToggleSuspended);
|
||||
AddProfile = ReactiveCommand.CreateFromTask(ExecuteAddProfile);
|
||||
EditCategory = ReactiveCommand.CreateFromTask(ExecuteEditCategory);
|
||||
MoveUp = ReactiveCommand.Create(ExecuteMoveUp);
|
||||
MoveDown = ReactiveCommand.Create(ExecuteMoveDown);
|
||||
|
||||
this.WhenActivated(d =>
|
||||
{
|
||||
@@ -86,6 +89,9 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
public ReactiveCommand<Unit, Unit> ToggleSuspended { get; }
|
||||
public ReactiveCommand<Unit, Unit> AddProfile { get; }
|
||||
public ReactiveCommand<Unit, Unit> EditCategory { get; }
|
||||
public ReactiveCommand<Unit, Unit> MoveUp { get; }
|
||||
public ReactiveCommand<Unit, Unit> MoveDown { get; }
|
||||
|
||||
public ProfileCategory ProfileCategory { get; }
|
||||
public ReadOnlyObservableCollection<SidebarProfileConfigurationViewModel> ProfileConfigurations { get; }
|
||||
|
||||
@@ -137,6 +143,36 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
_profileService.SaveProfileCategory(ProfileCategory);
|
||||
}
|
||||
|
||||
private void ExecuteMoveUp()
|
||||
{
|
||||
List<ProfileCategory> categories = _profileService.ProfileCategories.OrderBy(p => p.Order).ToList();
|
||||
int index = categories.IndexOf(ProfileCategory);
|
||||
if (index <= 0)
|
||||
return;
|
||||
|
||||
categories[index - 1].Order++;
|
||||
ProfileCategory.Order--;
|
||||
_profileService.SaveProfileCategory(categories[index - 1]);
|
||||
_profileService.SaveProfileCategory(ProfileCategory);
|
||||
|
||||
_sidebarViewModel.UpdateProfileCategories();
|
||||
}
|
||||
|
||||
private void ExecuteMoveDown()
|
||||
{
|
||||
List<ProfileCategory> categories = _profileService.ProfileCategories.OrderBy(p => p.Order).ToList();
|
||||
int index = categories.IndexOf(ProfileCategory);
|
||||
if (index >= categories.Count - 1)
|
||||
return;
|
||||
|
||||
categories[index + 1].Order--;
|
||||
ProfileCategory.Order++;
|
||||
_profileService.SaveProfileCategory(categories[index + 1]);
|
||||
_profileService.SaveProfileCategory(ProfileCategory);
|
||||
|
||||
_sidebarViewModel.UpdateProfileCategories();
|
||||
}
|
||||
|
||||
public void AddProfileConfiguration(ProfileConfiguration profileConfiguration, int? index)
|
||||
{
|
||||
ProfileCategory oldCategory = profileConfiguration.Category;
|
||||
|
||||
@@ -43,7 +43,8 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
ExportProfile = ReactiveCommand.CreateFromTask(ExecuteExportProfile);
|
||||
DuplicateProfile = ReactiveCommand.Create(ExecuteDuplicateProfile);
|
||||
|
||||
this.WhenActivated(d => _isDisabled = ProfileConfiguration.WhenAnyValue(c => c.IsSuspended, c => c.ActivationConditionMet, (suspended, met) => suspended || !met)
|
||||
this.WhenActivated(d => _isDisabled = ProfileConfiguration.WhenAnyValue(c => c.Profile)
|
||||
.Select(p => p == null)
|
||||
.ToProperty(this, vm => vm.IsDisabled)
|
||||
.DisposeWith(d));
|
||||
_profileService.LoadProfileConfigurationIcon(ProfileConfiguration);
|
||||
|
||||
Reference in new issue
Block a user