mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Plugins - Ignore version when loading shared assemblies
Sidebar - Improved category reordering code
This commit is contained in:
parent
937fe1fb74
commit
9c4bc3d9c6
@ -5,6 +5,7 @@ using System.IO;
|
|||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Runtime.Loader;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Artemis.Core.DeviceProviders;
|
using Artemis.Core.DeviceProviders;
|
||||||
using Artemis.Core.Ninject;
|
using Artemis.Core.Ninject;
|
||||||
@ -334,13 +335,16 @@ internal class PluginManagementService : IPluginManagementService
|
|||||||
throw new ArtemisPluginException(plugin, "Plugin main entry casing mismatch at " + plugin.Info.Main);
|
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
|
// 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.IsUnloadable = true;
|
||||||
configure.LoadInMemory = true;
|
configure.LoadInMemory = true;
|
||||||
configure.PreferSharedTypes = 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
|
try
|
||||||
{
|
{
|
||||||
plugin.Assembly = plugin.PluginLoader.LoadDefaultAssembly();
|
plugin.Assembly = plugin.PluginLoader.LoadDefaultAssembly();
|
||||||
@ -402,7 +406,7 @@ internal class PluginManagementService : IPluginManagementService
|
|||||||
OnPluginLoaded(new PluginEventArgs(plugin));
|
OnPluginLoaded(new PluginEventArgs(plugin));
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EnablePlugin(Plugin plugin, bool saveState, bool ignorePluginLock)
|
public void EnablePlugin(Plugin plugin, bool saveState, bool ignorePluginLock)
|
||||||
{
|
{
|
||||||
if (!plugin.Info.IsCompatible)
|
if (!plugin.Info.IsCompatible)
|
||||||
|
|||||||
@ -26,18 +26,20 @@ public class SidebarCategoryViewModel : ActivatableViewModelBase
|
|||||||
private readonly IProfileService _profileService;
|
private readonly IProfileService _profileService;
|
||||||
private readonly ISidebarVmFactory _vmFactory;
|
private readonly ISidebarVmFactory _vmFactory;
|
||||||
private readonly IWindowService _windowService;
|
private readonly IWindowService _windowService;
|
||||||
|
private readonly IProfileEditorService _profileEditorService;
|
||||||
private ObservableAsPropertyHelper<bool>? _isCollapsed;
|
private ObservableAsPropertyHelper<bool>? _isCollapsed;
|
||||||
private ObservableAsPropertyHelper<bool>? _isSuspended;
|
private ObservableAsPropertyHelper<bool>? _isSuspended;
|
||||||
private SidebarProfileConfigurationViewModel? _selectedProfileConfiguration;
|
private SidebarProfileConfigurationViewModel? _selectedProfileConfiguration;
|
||||||
|
|
||||||
public SidebarCategoryViewModel(ProfileCategory profileCategory,
|
public SidebarCategoryViewModel(ProfileCategory profileCategory,
|
||||||
IProfileService profileService,
|
IProfileService profileService,
|
||||||
IWindowService windowService,
|
IWindowService windowService,
|
||||||
IProfileEditorService profileEditorService,
|
IProfileEditorService profileEditorService,
|
||||||
ISidebarVmFactory vmFactory)
|
ISidebarVmFactory vmFactory)
|
||||||
{
|
{
|
||||||
_profileService = profileService;
|
_profileService = profileService;
|
||||||
_windowService = windowService;
|
_windowService = windowService;
|
||||||
|
_profileEditorService = profileEditorService;
|
||||||
_vmFactory = vmFactory;
|
_vmFactory = vmFactory;
|
||||||
|
|
||||||
ProfileCategory = profileCategory;
|
ProfileCategory = profileCategory;
|
||||||
@ -154,7 +156,11 @@ public class SidebarCategoryViewModel : ActivatableViewModelBase
|
|||||||
private async Task ExecuteDeleteCategory()
|
private async Task ExecuteDeleteCategory()
|
||||||
{
|
{
|
||||||
if (await _windowService.ShowConfirmContentDialog($"Delete {ProfileCategory.Name}", "Do you want to delete this category and all its profiles?"))
|
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);
|
_profileService.DeleteProfileCategory(ProfileCategory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ExecuteAddProfile()
|
private async Task ExecuteAddProfile()
|
||||||
@ -171,7 +177,7 @@ public class SidebarCategoryViewModel : ActivatableViewModelBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async Task ExecuteImportProfile()
|
private async Task ExecuteImportProfile()
|
||||||
{
|
{
|
||||||
string[]? result = await _windowService.CreateOpenFileDialog()
|
string[]? result = await _windowService.CreateOpenFileDialog()
|
||||||
.HavingFilter(f => f.WithExtension("json").WithName("Artemis profile"))
|
.HavingFilter(f => f.WithExtension("json").WithName("Artemis profile"))
|
||||||
.ShowAsync();
|
.ShowAsync();
|
||||||
@ -225,10 +231,9 @@ public class SidebarCategoryViewModel : ActivatableViewModelBase
|
|||||||
if (index <= 0)
|
if (index <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
categories[index - 1].Order++;
|
categories.Remove(ProfileCategory);
|
||||||
ProfileCategory.Order--;
|
categories.Insert(index - 1, ProfileCategory);
|
||||||
_profileService.SaveProfileCategory(categories[index - 1]);
|
ApplyCategoryOrder(categories);
|
||||||
_profileService.SaveProfileCategory(ProfileCategory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecuteMoveDown()
|
private void ExecuteMoveDown()
|
||||||
@ -238,9 +243,19 @@ public class SidebarCategoryViewModel : ActivatableViewModelBase
|
|||||||
if (index >= categories.Count - 1)
|
if (index >= categories.Count - 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
categories[index + 1].Order--;
|
categories.Remove(ProfileCategory);
|
||||||
ProfileCategory.Order++;
|
categories.Insert(index + 1, ProfileCategory);
|
||||||
_profileService.SaveProfileCategory(categories[index + 1]);
|
ApplyCategoryOrder(categories);
|
||||||
_profileService.SaveProfileCategory(ProfileCategory);
|
}
|
||||||
|
|
||||||
|
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]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user