mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Merge branch 'development'
This commit is contained in:
commit
ebb4aaa46c
@ -53,7 +53,7 @@ steps:
|
||||
command: 'publish'
|
||||
publishWebProjects: false
|
||||
projects: '$(artemisSolution)'
|
||||
arguments: '--runtime win-x64 --self-contained false --output $(Build.ArtifactStagingDirectory)/build /nowarn:cs1591'
|
||||
arguments: '--runtime win-x64 --self-contained false --configuration Release --output $(Build.ArtifactStagingDirectory)/build /nowarn:cs1591'
|
||||
zipAfterPublish: false
|
||||
modifyOutputPath: false
|
||||
|
||||
@ -73,12 +73,13 @@ steps:
|
||||
fileType: 'json'
|
||||
targetFiles: '**/buildinfo.json'
|
||||
|
||||
# Copy Artemis binaries to where plugin projects expect them
|
||||
- task: CopyFiles@2
|
||||
displayName: 'Plugins - Prepare Artemis binaries'
|
||||
inputs:
|
||||
SourceFolder: '$(Build.ArtifactStagingDirectory)/build'
|
||||
Contents: '**'
|
||||
TargetFolder: 'Artemis/src/Artemis.UI/bin/x64/Debug/net5.0-windows'
|
||||
TargetFolder: 'Artemis/src/Artemis.UI/bin/net5.0-windows'
|
||||
|
||||
- task: PowerShell@2
|
||||
displayName: 'Plugins - Insert build number into plugin.json'
|
||||
@ -99,7 +100,7 @@ steps:
|
||||
inputs:
|
||||
command: 'publish'
|
||||
publishWebProjects: false
|
||||
arguments: '--runtime win-x64 --self-contained false --output $(Build.ArtifactStagingDirectory)/build/Plugins'
|
||||
arguments: '--runtime win-x64 --configuration Release --self-contained false --output $(Build.ArtifactStagingDirectory)/build/Plugins'
|
||||
projects: '$(pluginProjects)'
|
||||
zipAfterPublish: true
|
||||
|
||||
|
||||
@ -6,12 +6,12 @@
|
||||
<AssemblyTitle>Artemis.Core</AssemblyTitle>
|
||||
<Product>Artemis Core</Product>
|
||||
<Copyright>Copyright © Robert Beekman - 2020</Copyright>
|
||||
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<Platforms>x64</Platforms>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<DocumentationFile>bin\x64\Debug\Artemis.Core.xml</DocumentationFile>
|
||||
<DocumentationFile>bin\Artemis.Core.xml</DocumentationFile>
|
||||
<NoWarn></NoWarn>
|
||||
<WarningLevel>5</WarningLevel>
|
||||
</PropertyGroup>
|
||||
@ -30,7 +30,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<DocumentationFile>bin\x64\Release\Artemis.Core.xml</DocumentationFile>
|
||||
<DocumentationFile>bin\Artemis.Core.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Artemis.Storage\Artemis.Storage.csproj">
|
||||
|
||||
@ -40,17 +40,24 @@ namespace Artemis.Core
|
||||
/// Gets all the colors in the color gradient
|
||||
/// </summary>
|
||||
/// <param name="timesToRepeat">The amount of times to repeat the colors</param>
|
||||
/// <returns></returns>
|
||||
public SKColor[] GetColorsArray(int timesToRepeat = 0)
|
||||
/// <param name="seamless">
|
||||
/// A boolean indicating whether to make the gradient seamless by adding the first color behind the
|
||||
/// last color
|
||||
/// </param>
|
||||
/// <returns>An array containing each color in the gradient</returns>
|
||||
public SKColor[] GetColorsArray(int timesToRepeat = 0, bool seamless = false)
|
||||
{
|
||||
if (timesToRepeat == 0)
|
||||
return Stops.Select(c => c.Color).ToArray();
|
||||
|
||||
List<SKColor> colors = Stops.Select(c => c.Color).ToList();
|
||||
List<SKColor> result = new();
|
||||
|
||||
for (int i = 0; i <= timesToRepeat; i++)
|
||||
result.AddRange(colors);
|
||||
if (timesToRepeat == 0)
|
||||
result = Stops.Select(c => c.Color).ToList();
|
||||
else
|
||||
{
|
||||
List<SKColor> colors = Stops.Select(c => c.Color).ToList();
|
||||
for (int i = 0; i <= timesToRepeat; i++)
|
||||
result.AddRange(colors);
|
||||
}
|
||||
if (seamless && !IsSeamless())
|
||||
result.Add(result[0]);
|
||||
|
||||
return result.ToArray();
|
||||
}
|
||||
@ -59,24 +66,39 @@ namespace Artemis.Core
|
||||
/// Gets all the positions in the color gradient
|
||||
/// </summary>
|
||||
/// <param name="timesToRepeat">
|
||||
/// The amount of times to repeat the positions, positions will get squished together and
|
||||
/// always stay between 0.0 and 1.0
|
||||
/// The amount of times to repeat the positions
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
public float[] GetPositionsArray(int timesToRepeat = 0)
|
||||
/// <param name="seamless">
|
||||
/// A boolean indicating whether to make the gradient seamless by adding the first color behind the
|
||||
/// last color
|
||||
/// </param>
|
||||
/// <returns>An array containing a position for each color between 0.0 and 1.0</returns>
|
||||
public float[] GetPositionsArray(int timesToRepeat = 0, bool seamless = false)
|
||||
{
|
||||
if (timesToRepeat == 0)
|
||||
return Stops.Select(c => c.Position).ToArray();
|
||||
|
||||
// Create stops and a list of divided stops
|
||||
List<float> stops = Stops.Select(c => c.Position / (timesToRepeat + 1)).ToList();
|
||||
List<float> result = new();
|
||||
|
||||
// For each repeat cycle, add the base stops to the end result
|
||||
for (int i = 0; i <= timesToRepeat; i++)
|
||||
if (timesToRepeat == 0)
|
||||
result = Stops.Select(c => c.Position).ToList();
|
||||
else
|
||||
{
|
||||
List<float> localStops = stops.Select(s => s + result.LastOrDefault()).ToList();
|
||||
result.AddRange(localStops);
|
||||
// Create stops and a list of divided stops
|
||||
List<float> stops = Stops.Select(c => c.Position / (timesToRepeat + 1)).ToList();
|
||||
|
||||
// For each repeat cycle, add the base stops to the end result
|
||||
for (int i = 0; i <= timesToRepeat; i++)
|
||||
{
|
||||
float lastStop = result.LastOrDefault();
|
||||
result.AddRange(stops.Select(s => s + lastStop));
|
||||
}
|
||||
}
|
||||
|
||||
if (seamless && !IsSeamless())
|
||||
{
|
||||
// Compress current points evenly
|
||||
float compression = 1f - 1f / result.Count;
|
||||
for (int index = 0; index < result.Count; index++)
|
||||
result[index] = result[index] * compression;
|
||||
// Add one extra point at the end
|
||||
result.Add(1f);
|
||||
}
|
||||
|
||||
return result.ToArray();
|
||||
@ -140,8 +162,17 @@ namespace Artemis.Core
|
||||
float position = 1f / (FastLedRainbow.Length - 1f) * index;
|
||||
gradient.Stops.Add(new ColorGradientStop(skColor, position));
|
||||
}
|
||||
|
||||
|
||||
return gradient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the gradient is seamless
|
||||
/// </summary>
|
||||
/// <returns><see langword="true" /> if the gradient is seamless; <see langword="false" /> otherwise</returns>
|
||||
public bool IsSeamless()
|
||||
{
|
||||
return Stops.Count == 0 || Stops.First().Color.Equals(Stops.Last().Color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,7 @@
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Storage;
|
||||
using Artemis.Storage.Migrations.Interfaces;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Ninject.Activation;
|
||||
using Serilog;
|
||||
using Serilog.Core;
|
||||
|
||||
@ -88,6 +88,11 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
internal PluginEntity Entity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Populated when plugin settings are first loaded
|
||||
/// </summary>
|
||||
internal PluginSettings? Settings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the relative path provided in the <paramref name="path" /> parameter to an absolute path
|
||||
/// </summary>
|
||||
@ -101,7 +106,6 @@ namespace Artemis.Core
|
||||
|
||||
/// <summary>
|
||||
/// Looks up the instance of the feature of type <typeparamref name="T" />
|
||||
/// <para>Note: This method only returns instances of enabled features</para>
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of feature to find</typeparam>
|
||||
/// <returns>If found, the instance of the feature</returns>
|
||||
@ -116,6 +120,83 @@ namespace Artemis.Core
|
||||
return Info.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the plugin is enabled
|
||||
/// </summary>
|
||||
public event EventHandler? Enabled;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the plugin is disabled
|
||||
/// </summary>
|
||||
public event EventHandler? Disabled;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when an feature is loaded and added to the plugin
|
||||
/// </summary>
|
||||
public event EventHandler<PluginFeatureInfoEventArgs>? FeatureAdded;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when an feature is disabled and removed from the plugin
|
||||
/// </summary>
|
||||
public event EventHandler<PluginFeatureInfoEventArgs>? FeatureRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// Releases the unmanaged resources used by the object and optionally releases the managed resources.
|
||||
/// </summary>
|
||||
/// <param name="disposing">
|
||||
/// <see langword="true" /> to release both managed and unmanaged resources;
|
||||
/// <see langword="false" /> to release only unmanaged resources.
|
||||
/// </param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
foreach (PluginFeatureInfo feature in Features)
|
||||
feature.Instance?.Dispose();
|
||||
SetEnabled(false);
|
||||
|
||||
Kernel?.Dispose();
|
||||
PluginLoader?.Dispose();
|
||||
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
|
||||
_features.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the Enabled event
|
||||
/// </summary>
|
||||
protected virtual void OnEnabled()
|
||||
{
|
||||
Enabled?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the Disabled event
|
||||
/// </summary>
|
||||
protected virtual void OnDisabled()
|
||||
{
|
||||
Disabled?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the FeatureAdded event
|
||||
/// </summary>
|
||||
protected virtual void OnFeatureAdded(PluginFeatureInfoEventArgs e)
|
||||
{
|
||||
FeatureAdded?.Invoke(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the FeatureRemoved event
|
||||
/// </summary>
|
||||
protected virtual void OnFeatureRemoved(PluginFeatureInfoEventArgs e)
|
||||
{
|
||||
FeatureRemoved?.Invoke(this, e);
|
||||
}
|
||||
|
||||
internal void ApplyToEntity()
|
||||
{
|
||||
Entity.Id = Guid;
|
||||
@ -169,96 +250,11 @@ namespace Artemis.Core
|
||||
return Entity.Features.Any(f => f.IsEnabled) || Features.Any(f => f.AlwaysEnabled);
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Releases the unmanaged resources used by the object and optionally releases the managed resources.
|
||||
/// </summary>
|
||||
/// <param name="disposing">
|
||||
/// <see langword="true" /> to release both managed and unmanaged resources;
|
||||
/// <see langword="false" /> to release only unmanaged resources.
|
||||
/// </param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
foreach (PluginFeatureInfo feature in Features)
|
||||
feature.Instance?.Dispose();
|
||||
SetEnabled(false);
|
||||
|
||||
Kernel?.Dispose();
|
||||
PluginLoader?.Dispose();
|
||||
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
|
||||
_features.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the plugin is enabled
|
||||
/// </summary>
|
||||
public event EventHandler? Enabled;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the plugin is disabled
|
||||
/// </summary>
|
||||
public event EventHandler? Disabled;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when an feature is loaded and added to the plugin
|
||||
/// </summary>
|
||||
public event EventHandler<PluginFeatureInfoEventArgs>? FeatureAdded;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when an feature is disabled and removed from the plugin
|
||||
/// </summary>
|
||||
public event EventHandler<PluginFeatureInfoEventArgs>? FeatureRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the Enabled event
|
||||
/// </summary>
|
||||
protected virtual void OnEnabled()
|
||||
{
|
||||
Enabled?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the Disabled event
|
||||
/// </summary>
|
||||
protected virtual void OnDisabled()
|
||||
{
|
||||
Disabled?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the FeatureAdded event
|
||||
/// </summary>
|
||||
protected virtual void OnFeatureAdded(PluginFeatureInfoEventArgs e)
|
||||
{
|
||||
FeatureAdded?.Invoke(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the FeatureRemoved event
|
||||
/// </summary>
|
||||
protected virtual void OnFeatureRemoved(PluginFeatureInfoEventArgs e)
|
||||
{
|
||||
FeatureRemoved?.Invoke(this, e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -17,6 +17,8 @@ namespace Artemis.Core
|
||||
internal PluginSettings(Plugin plugin, IPluginRepository pluginRepository)
|
||||
{
|
||||
Plugin = plugin;
|
||||
Plugin.Settings = this;
|
||||
|
||||
_pluginRepository = pluginRepository;
|
||||
_settingEntities = new Dictionary<string, object>();
|
||||
}
|
||||
@ -65,5 +67,10 @@ namespace Artemis.Core
|
||||
return pluginSetting;
|
||||
}
|
||||
}
|
||||
|
||||
internal void ClearSettings()
|
||||
{
|
||||
_settingEntities.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -74,7 +74,14 @@ namespace Artemis.Core.Services
|
||||
/// Unloads and permanently removes the provided plugin
|
||||
/// </summary>
|
||||
/// <param name="plugin">The plugin to remove</param>
|
||||
void RemovePlugin(Plugin plugin);
|
||||
/// <param name="removeSettings"></param>
|
||||
void RemovePlugin(Plugin plugin, bool removeSettings);
|
||||
|
||||
/// <summary>
|
||||
/// Removes the settings of a disabled plugin
|
||||
/// </summary>
|
||||
/// <param name="plugin">The plugin whose settings to remove</param>
|
||||
void RemovePluginSettings(Plugin plugin);
|
||||
|
||||
/// <summary>
|
||||
/// Enables the provided plugin feature
|
||||
@ -134,8 +141,6 @@ namespace Artemis.Core.Services
|
||||
/// <param name="pluginAction">The action to take</param>
|
||||
void QueuePluginAction(Plugin plugin, PluginManagementAction pluginAction);
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when built-in plugins are being loaded
|
||||
/// </summary>
|
||||
@ -190,7 +195,5 @@ namespace Artemis.Core.Services
|
||||
/// Occurs when a plugin feature has been disabled
|
||||
/// </summary>
|
||||
public event EventHandler<PluginFeatureEventArgs> PluginFeatureDisabled;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -479,7 +479,7 @@ namespace Artemis.Core.Services
|
||||
if (existing != null)
|
||||
try
|
||||
{
|
||||
RemovePlugin(existing);
|
||||
RemovePlugin(existing, false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -519,7 +519,7 @@ namespace Artemis.Core.Services
|
||||
return LoadPlugin(directoryInfo);
|
||||
}
|
||||
|
||||
public void RemovePlugin(Plugin plugin)
|
||||
public void RemovePlugin(Plugin plugin, bool removeSettings)
|
||||
{
|
||||
DirectoryInfo directory = plugin.Directory;
|
||||
lock (_plugins)
|
||||
@ -529,6 +529,16 @@ namespace Artemis.Core.Services
|
||||
}
|
||||
|
||||
directory.Delete(true);
|
||||
if (removeSettings)
|
||||
RemovePluginSettings(plugin);
|
||||
}
|
||||
|
||||
public void RemovePluginSettings(Plugin plugin)
|
||||
{
|
||||
if (plugin.IsEnabled)
|
||||
throw new ArtemisCoreException("Cannot remove the settings of an enabled plugin");
|
||||
_pluginRepository.RemoveSettings(plugin.Guid);
|
||||
plugin.Settings?.ClearSettings();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -14,7 +14,8 @@ namespace Artemis.Storage.Repositories.Interfaces
|
||||
PluginSettingEntity GetSettingByGuid(Guid pluginGuid);
|
||||
PluginSettingEntity GetSettingByNameAndGuid(string name, Guid pluginGuid);
|
||||
void SaveSetting(PluginSettingEntity pluginSettingEntity);
|
||||
|
||||
void RemoveSettings(Guid pluginGuid);
|
||||
|
||||
void AddQueuedAction(PluginQueuedActionEntity pluginQueuedActionEntity);
|
||||
List<PluginQueuedActionEntity> GetQueuedActions();
|
||||
List<PluginQueuedActionEntity> GetQueuedActions(Guid pluginGuid);
|
||||
|
||||
@ -54,6 +54,12 @@ namespace Artemis.Storage.Repositories
|
||||
_repository.Upsert(pluginSettingEntity);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void RemoveSettings(Guid pluginGuid)
|
||||
{
|
||||
_repository.DeleteMany<PluginSettingEntity>(s => s.PluginGuid == pluginGuid);
|
||||
}
|
||||
|
||||
public List<PluginQueuedActionEntity> GetQueuedActions()
|
||||
{
|
||||
return _repository.Query<PluginQueuedActionEntity>().ToList();
|
||||
|
||||
@ -8,13 +8,13 @@
|
||||
<Company>Artemis.UI.Shared</Company>
|
||||
<Product>Artemis.UI.Shared</Product>
|
||||
<Copyright>Copyright © Robert Beekman - 2020</Copyright>
|
||||
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<UseWPF>true</UseWPF>
|
||||
<Platforms>x64</Platforms>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<DocumentationFile>bin\x64\Debug\Artemis.UI.Shared.xml</DocumentationFile>
|
||||
<DocumentationFile>bin\Artemis.UI.Shared.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
@ -30,7 +30,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<DocumentationFile>bin\x64\Release\Artemis.UI.Shared.xml</DocumentationFile>
|
||||
<DocumentationFile>bin\Artemis.UI.Shared.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AvalonEdit" Version="6.0.1" />
|
||||
|
||||
@ -10,6 +10,7 @@ using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Utilities;
|
||||
using Ninject;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI
|
||||
@ -19,13 +20,16 @@ namespace Artemis.UI
|
||||
// ReSharper disable once NotAccessedField.Local - Kept in scope to ensure it does not get released
|
||||
private Mutex _artemisMutex;
|
||||
|
||||
public ApplicationStateManager(string[] startupArguments)
|
||||
public ApplicationStateManager(IKernel kernel, string[] startupArguments)
|
||||
{
|
||||
StartupArguments = startupArguments;
|
||||
IsElevated = new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
|
||||
|
||||
Core.Utilities.ShutdownRequested += UtilitiesOnShutdownRequested;
|
||||
Core.Utilities.RestartRequested += UtilitiesOnRestartRequested;
|
||||
|
||||
// On Windows shutdown dispose the kernel just so device providers get a chance to clean up
|
||||
Application.Current.SessionEnding += (_, _) => kernel.Dispose();
|
||||
}
|
||||
|
||||
public string[] StartupArguments { get; }
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
<Description>Provides advanced unified lighting across many different brands RGB peripherals</Description>
|
||||
<Copyright>Copyright © Robert Beekman - 2021</Copyright>
|
||||
<FileVersion>2.0.0.0</FileVersion>
|
||||
<OutputPath>bin\$(Platform)\$(Configuration)\</OutputPath>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<UseWPF>true</UseWPF>
|
||||
<Platforms>x64</Platforms>
|
||||
<SupportedPlatform>windows</SupportedPlatform>
|
||||
|
||||
@ -6,7 +6,6 @@ using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Threading;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Ninject;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Ninject;
|
||||
@ -14,11 +13,9 @@ using Artemis.UI.Screens;
|
||||
using Artemis.UI.Services;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.SkiaSharp;
|
||||
using Artemis.UI.Stylet;
|
||||
using Ninject;
|
||||
using Serilog;
|
||||
using SkiaSharp;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI
|
||||
@ -39,7 +36,7 @@ namespace Artemis.UI
|
||||
|
||||
protected override void Launch()
|
||||
{
|
||||
_applicationStateManager = new ApplicationStateManager(Args);
|
||||
_applicationStateManager = new ApplicationStateManager(Kernel, Args);
|
||||
Core.Utilities.PrepareFirstLaunch();
|
||||
|
||||
ILogger logger = Kernel.Get<ILogger>();
|
||||
@ -94,10 +91,7 @@ namespace Artemis.UI
|
||||
registrationService.RegisterInputProvider();
|
||||
registrationService.RegisterControllers();
|
||||
|
||||
Execute.OnUIThreadSync(() =>
|
||||
{
|
||||
registrationService.ApplyPreferredGraphicsContext();
|
||||
});
|
||||
Execute.OnUIThreadSync(() => { registrationService.ApplyPreferredGraphicsContext(); });
|
||||
|
||||
// Initialize background services
|
||||
Kernel.Get<IDeviceLayoutService>();
|
||||
|
||||
@ -36,6 +36,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio
|
||||
base.OnInitialActivate();
|
||||
ActiveItem = _dataModelConditionsVmFactory.DataModelConditionGroupViewModel(DataBindingCondition.Condition, ConditionGroupType.General);
|
||||
ActiveItem.IsRootGroup = true;
|
||||
|
||||
ActiveItem.Update();
|
||||
ActiveItem.Updated += ActiveItemOnUpdated;
|
||||
|
||||
|
||||
@ -3,7 +3,6 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Shared.Services;
|
||||
@ -15,25 +14,28 @@ namespace Artemis.UI.Screens.Settings.Device
|
||||
{
|
||||
private readonly IRgbService _rgbService;
|
||||
private bool _selectPhysicalLayout;
|
||||
private RegionInfoAutocompleteSource _autocompleteSource;
|
||||
private RegionInfo _selectedRegion;
|
||||
|
||||
public DeviceLayoutDialogViewModel(ArtemisDevice device, IRgbService rgbService)
|
||||
public DeviceLayoutDialogViewModel(ArtemisDevice device, IRgbService rgbService, IDialogService dialogService)
|
||||
{
|
||||
_rgbService = rgbService;
|
||||
Device = device;
|
||||
SelectPhysicalLayout = !device.DeviceProvider.CanDetectPhysicalLayout;
|
||||
|
||||
Task.Run(() => AutocompleteSource = new RegionInfoAutocompleteSource());
|
||||
try
|
||||
{
|
||||
AutocompleteSource = new RegionInfoAutocompleteSource();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dialogService.ShowExceptionDialog("Failed to get region information for keyboard layout selection", e);
|
||||
Session?.Close(false);
|
||||
}
|
||||
}
|
||||
|
||||
public ArtemisDevice Device { get; }
|
||||
|
||||
public RegionInfoAutocompleteSource AutocompleteSource
|
||||
{
|
||||
get => _autocompleteSource;
|
||||
set => SetAndNotify(ref _autocompleteSource, value);
|
||||
}
|
||||
public RegionInfoAutocompleteSource AutocompleteSource { get; }
|
||||
|
||||
public RegionInfo SelectedRegion
|
||||
{
|
||||
@ -83,11 +85,17 @@ namespace Artemis.UI.Screens.Settings.Device
|
||||
|
||||
public class RegionInfoAutocompleteSource : IAutocompleteSource<RegionInfo>
|
||||
{
|
||||
private const int LOCALE_NEUTRAL = 0x0000;
|
||||
private const int LOCALE_CUSTOM_DEFAULT = 0x0c00;
|
||||
private const int LOCALE_INVARIANT = 0x007F;
|
||||
|
||||
public List<RegionInfo> Regions { get; set; }
|
||||
|
||||
public RegionInfoAutocompleteSource()
|
||||
{
|
||||
Regions = CultureInfo.GetCultures(CultureTypes.SpecificCultures).ToList()
|
||||
// RegionInfo does not support some LCIDs and they show up with certain locale settings
|
||||
Regions = CultureInfo.GetCultures(CultureTypes.SpecificCultures)
|
||||
.Where(c => c.LCID != LOCALE_INVARIANT && c.LCID != LOCALE_NEUTRAL && c.LCID != LOCALE_CUSTOM_DEFAULT)
|
||||
.Select(c => new RegionInfo(c.LCID))
|
||||
.GroupBy(r => r.EnglishName)
|
||||
.Select(g => g.First())
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
IsReadOnly="True"
|
||||
CanUserAddRows="False"
|
||||
AutoGenerateColumns="False"
|
||||
materialDesign:DataGridAssist.CellPadding="13 8 8 8"
|
||||
materialDesign:DataGridAssist.ColumnHeaderPadding="8"
|
||||
materialDesign:DataGridAssist.CellPadding="5"
|
||||
materialDesign:DataGridAssist.ColumnHeaderPadding="5"
|
||||
SelectedItem="{Binding Parent.SelectedLed}"
|
||||
CanUserResizeRows="False"
|
||||
Margin="10">
|
||||
@ -31,6 +31,7 @@
|
||||
<materialDesign:DataGridTextColumn Binding="{Binding Layout.Image, Converter={StaticResource UriToFileNameConverter}, Mode=OneWay}" Header="Image file" />
|
||||
<materialDesign:DataGridTextColumn Binding="{Binding RgbLed.Shape}" Header="Shape" />
|
||||
<materialDesign:DataGridTextColumn Binding="{Binding RgbLed.Size}" Header="Size" Width="Auto" />
|
||||
<materialDesign:DataGridTextColumn Binding="{Binding RgbLed.CustomData}" Header="LED data" Width="Auto" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
|
||||
@ -17,8 +17,8 @@
|
||||
<Grid Margin="-3 -8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Icon column -->
|
||||
@ -42,15 +42,20 @@
|
||||
</Button>
|
||||
|
||||
<!-- Display name column -->
|
||||
<TextBlock Grid.Column="1" Text="{Binding FeatureInfo.Name}" Style="{StaticResource MaterialDesignTextBlock}" VerticalAlignment="Center" ToolTip="{Binding FeatureInfo.Description}" />
|
||||
<TextBlock Grid.Column="1"
|
||||
Text="{Binding FeatureInfo.Name}"
|
||||
Style="{StaticResource MaterialDesignTextBlock}"
|
||||
VerticalAlignment="Center"
|
||||
TextWrapping="Wrap"
|
||||
ToolTip="{Binding FeatureInfo.Description}" />
|
||||
|
||||
<!-- Enable toggle column -->
|
||||
<StackPanel Grid.Column="2"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
Margin="8"
|
||||
Visibility="{Binding Enabling, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay, FallbackValue=Collapsed}"
|
||||
Orientation="Horizontal"
|
||||
VerticalAlignment="Top"
|
||||
ToolTip="This feature cannot be disabled without disabling the whole plugin"
|
||||
ToolTipService.IsEnabled="{Binding FeatureInfo.AlwaysEnabled}">
|
||||
<materialDesign:PackIcon Kind="ShieldHalfFull"
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Margin="0 15" Width="810">
|
||||
<Grid Margin="0 15" Width="910">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
d:DataContext="{d:DesignInstance devices:PluginSettingsViewModel}"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<materialDesign:Card Width="800">
|
||||
<materialDesign:Card Width="900">
|
||||
<Grid Margin="8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
@ -47,7 +47,7 @@
|
||||
behaviors:HighlightTermBehavior.TermToBeHighlighted="{Binding Parent.SearchPluginInput}"
|
||||
behaviors:HighlightTermBehavior.Text="{Binding Plugin.Info.Name}"
|
||||
behaviors:HighlightTermBehavior.HighlightForeground="{StaticResource Primary600Foreground}"
|
||||
behaviors:HighlightTermBehavior.HighlightBackground="{StaticResource Primary600}"/>
|
||||
behaviors:HighlightTermBehavior.HighlightBackground="{StaticResource Primary600}" />
|
||||
|
||||
<TextBlock Grid.Column="1"
|
||||
Grid.Row="1"
|
||||
@ -67,12 +67,20 @@
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
VerticalAlignment="Bottom"
|
||||
Style="{StaticResource MaterialDesignOutlinedButton}"
|
||||
Style="{StaticResource MaterialDesignRaisedButton}"
|
||||
ToolTip="Open the plugins settings window"
|
||||
Margin="4"
|
||||
Command="{s:Action OpenSettings}">
|
||||
SETTINGS
|
||||
</Button>
|
||||
<Button
|
||||
VerticalAlignment="Bottom"
|
||||
Style="{StaticResource MaterialDesignOutlinedButton}"
|
||||
ToolTip="Clear plugin settings"
|
||||
Margin="4"
|
||||
Command="{s:Action RemoveSettings}">
|
||||
<materialDesign:PackIcon Kind="DatabaseRemove" />
|
||||
</Button>
|
||||
<Button
|
||||
VerticalAlignment="Bottom"
|
||||
Style="{StaticResource MaterialDesignOutlinedButton}"
|
||||
|
||||
@ -85,6 +85,25 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
}
|
||||
}
|
||||
|
||||
public async Task RemoveSettings()
|
||||
{
|
||||
bool confirmed = await _dialogService.ShowConfirmDialog("Clear plugin settings", "Are you sure you want to clear the settings of this plugin?");
|
||||
if (!confirmed)
|
||||
return;
|
||||
|
||||
bool wasEnabled = IsEnabled;
|
||||
|
||||
if (IsEnabled)
|
||||
await UpdateEnabled(false);
|
||||
|
||||
_pluginManagementService.RemovePluginSettings(Plugin);
|
||||
|
||||
if (wasEnabled)
|
||||
await UpdateEnabled(true);
|
||||
|
||||
_messageService.ShowMessage("Cleared plugin settings.");
|
||||
}
|
||||
|
||||
public async Task Remove()
|
||||
{
|
||||
bool confirmed = await _dialogService.ShowConfirmDialog("Delete plugin", "Are you sure you want to delete this plugin?");
|
||||
@ -93,7 +112,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
|
||||
try
|
||||
{
|
||||
_pluginManagementService.RemovePlugin(Plugin);
|
||||
_pluginManagementService.RemovePlugin(Plugin, false);
|
||||
((PluginSettingsTabViewModel) Parent).GetPluginInstances();
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -101,6 +120,8 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
_dialogService.ShowExceptionDialog("Failed to remove plugin", e);
|
||||
throw;
|
||||
}
|
||||
|
||||
_messageService.ShowMessage("Removed plugin.");
|
||||
}
|
||||
|
||||
public void ShowLogsFolder()
|
||||
|
||||
@ -142,8 +142,12 @@ namespace Artemis.UI.Screens
|
||||
|
||||
private void RootViewModelOnClosed(object sender, CloseEventArgs e)
|
||||
{
|
||||
_rootViewModel.Closed -= RootViewModelOnClosed;
|
||||
_rootViewModel = null;
|
||||
if (_rootViewModel != null)
|
||||
{
|
||||
_rootViewModel.Closed -= RootViewModelOnClosed;
|
||||
_rootViewModel = null;
|
||||
}
|
||||
|
||||
OnMainWindowClosed();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user