1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Node picker - Allow searching with ! and !! for starts-with and exact-match respectively

This commit is contained in:
Felipe Urzúa 2022-11-06 06:07:28 -03:00 committed by GitHub
parent 3819a6e3be
commit a66cc26f29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 19 deletions

View File

@ -5,6 +5,7 @@ using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.Loader;
using System.Threading.Tasks;
using Artemis.Core.DeviceProviders;
using Artemis.Core.Ninject;
@ -334,11 +335,14 @@ internal class PluginManagementService : IPluginManagementService
throw new ArtemisPluginException(plugin, "Plugin main entry casing mismatch at " + plugin.Info.Main);
// Load the plugin, all types implementing Plugin and register them with DI
plugin.PluginLoader = PluginLoader.CreateFromAssemblyFile(mainFile!, configure =>
plugin.PluginLoader = PluginLoader.CreateFromAssemblyFile(mainFile, configure =>
{
configure.IsUnloadable = true;
configure.LoadInMemory = true;
configure.PreferSharedTypes = true;
// Resolving failed, try a loaded assembly but ignoring the version
configure.DefaultContext.Resolving += (context, assemblyName) => context.Assemblies.FirstOrDefault(a => a.GetName().Name == assemblyName.Name);
});
try

View File

@ -78,7 +78,14 @@ public class NodeData
/// </returns>
public bool MatchesSearch(string text)
{
text = text.Trim();
string rawText = text.Trim();
text = text.Trim().TrimStart('!');
if (rawText.StartsWith("!!"))
return Name.Equals(text, StringComparison.InvariantCultureIgnoreCase);
else if (rawText.StartsWith("!"))
return Name.StartsWith(text, StringComparison.InvariantCultureIgnoreCase);
else
return Name.Contains(text, StringComparison.InvariantCultureIgnoreCase) ||
Description.Contains(text, StringComparison.InvariantCultureIgnoreCase) ||
Category.Contains(text, StringComparison.InvariantCultureIgnoreCase);

View File

@ -26,6 +26,7 @@ public class SidebarCategoryViewModel : ActivatableViewModelBase
private readonly IProfileService _profileService;
private readonly ISidebarVmFactory _vmFactory;
private readonly IWindowService _windowService;
private readonly IProfileEditorService _profileEditorService;
private ObservableAsPropertyHelper<bool>? _isCollapsed;
private ObservableAsPropertyHelper<bool>? _isSuspended;
private SidebarProfileConfigurationViewModel? _selectedProfileConfiguration;
@ -38,6 +39,7 @@ public class SidebarCategoryViewModel : ActivatableViewModelBase
{
_profileService = profileService;
_windowService = windowService;
_profileEditorService = profileEditorService;
_vmFactory = vmFactory;
ProfileCategory = profileCategory;
@ -154,8 +156,12 @@ public class SidebarCategoryViewModel : ActivatableViewModelBase
private async Task ExecuteDeleteCategory()
{
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))
_profileEditorService.ChangeCurrentProfileConfiguration(null);
_profileService.DeleteProfileCategory(ProfileCategory);
}
}
private async Task ExecuteAddProfile()
{
@ -225,10 +231,9 @@ public class SidebarCategoryViewModel : ActivatableViewModelBase
if (index <= 0)
return;
categories[index - 1].Order++;
ProfileCategory.Order--;
_profileService.SaveProfileCategory(categories[index - 1]);
_profileService.SaveProfileCategory(ProfileCategory);
categories.Remove(ProfileCategory);
categories.Insert(index - 1, ProfileCategory);
ApplyCategoryOrder(categories);
}
private void ExecuteMoveDown()
@ -238,9 +243,19 @@ public class SidebarCategoryViewModel : ActivatableViewModelBase
if (index >= categories.Count - 1)
return;
categories[index + 1].Order--;
ProfileCategory.Order++;
_profileService.SaveProfileCategory(categories[index + 1]);
_profileService.SaveProfileCategory(ProfileCategory);
categories.Remove(ProfileCategory);
categories.Insert(index + 1, ProfileCategory);
ApplyCategoryOrder(categories);
}
private void ApplyCategoryOrder(List<ProfileCategory> categories)
{
for (int i = 0; i < categories.Count; i++)
{
if (categories[i].Order == i + 1)
continue;
categories[i].Order = i + 1;
_profileService.SaveProfileCategory(categories[i]);
}
}
}