mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Core - Reworked profile render override for the editor and new previewer
This commit is contained in:
parent
c6a318b6e3
commit
d2b8123a30
@ -17,7 +17,6 @@ public sealed class Profile : ProfileElement
|
|||||||
private readonly ObservableCollection<ScriptConfiguration> _scriptConfigurations;
|
private readonly ObservableCollection<ScriptConfiguration> _scriptConfigurations;
|
||||||
private readonly ObservableCollection<ProfileScript> _scripts;
|
private readonly ObservableCollection<ProfileScript> _scripts;
|
||||||
private bool _isFreshImport;
|
private bool _isFreshImport;
|
||||||
private ProfileElement? _lastSelectedProfileElement;
|
|
||||||
|
|
||||||
internal Profile(ProfileConfiguration configuration, ProfileEntity profileEntity) : base(null!)
|
internal Profile(ProfileConfiguration configuration, ProfileEntity profileEntity) : base(null!)
|
||||||
{
|
{
|
||||||
@ -67,15 +66,6 @@ public sealed class Profile : ProfileElement
|
|||||||
set => SetAndNotify(ref _isFreshImport, value);
|
set => SetAndNotify(ref _isFreshImport, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the last selected profile element of this profile
|
|
||||||
/// </summary>
|
|
||||||
public ProfileElement? LastSelectedProfileElement
|
|
||||||
{
|
|
||||||
get => _lastSelectedProfileElement;
|
|
||||||
set => SetAndNotify(ref _lastSelectedProfileElement, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the profile entity this profile uses for persistent storage
|
/// Gets the profile entity this profile uses for persistent storage
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -130,7 +120,7 @@ public sealed class Profile : ProfileElement
|
|||||||
if (applyOpacityLayer)
|
if (applyOpacityLayer)
|
||||||
{
|
{
|
||||||
opacityPaint = new SKPaint();
|
opacityPaint = new SKPaint();
|
||||||
opacityPaint.Color = new SKColor(0, 0, 0, (byte)(255d * Easings.CubicEaseInOut(Opacity)));
|
opacityPaint.Color = new SKColor(0, 0, 0, (byte) (255d * Easings.CubicEaseInOut(Opacity)));
|
||||||
canvas.SaveLayer(opacityPaint);
|
canvas.SaveLayer(opacityPaint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,20 +232,13 @@ public sealed class Profile : ProfileElement
|
|||||||
AddChild(new Folder(this, this, rootFolder));
|
AddChild(new Folder(this, this, rootFolder));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<RenderProfileElement> renderElements = GetAllRenderElements();
|
|
||||||
|
|
||||||
if (ProfileEntity.LastSelectedProfileElement != Guid.Empty)
|
|
||||||
LastSelectedProfileElement = renderElements.FirstOrDefault(f => f.EntityId == ProfileEntity.LastSelectedProfileElement);
|
|
||||||
else
|
|
||||||
LastSelectedProfileElement = null;
|
|
||||||
|
|
||||||
while (_scriptConfigurations.Any())
|
while (_scriptConfigurations.Any())
|
||||||
RemoveScriptConfiguration(_scriptConfigurations[0]);
|
RemoveScriptConfiguration(_scriptConfigurations[0]);
|
||||||
foreach (ScriptConfiguration scriptConfiguration in ProfileEntity.ScriptConfigurations.Select(e => new ScriptConfiguration(e)))
|
foreach (ScriptConfiguration scriptConfiguration in ProfileEntity.ScriptConfigurations.Select(e => new ScriptConfiguration(e)))
|
||||||
AddScriptConfiguration(scriptConfiguration);
|
AddScriptConfiguration(scriptConfiguration);
|
||||||
|
|
||||||
// Load node scripts last since they may rely on the profile structure being in place
|
// Load node scripts last since they may rely on the profile structure being in place
|
||||||
foreach (RenderProfileElement renderProfileElement in renderElements)
|
foreach (RenderProfileElement renderProfileElement in GetAllRenderElements())
|
||||||
renderProfileElement.LoadNodeScript();
|
renderProfileElement.LoadNodeScript();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,7 +295,6 @@ public sealed class Profile : ProfileElement
|
|||||||
ProfileEntity.Id = EntityId;
|
ProfileEntity.Id = EntityId;
|
||||||
ProfileEntity.Name = Configuration.Name;
|
ProfileEntity.Name = Configuration.Name;
|
||||||
ProfileEntity.IsFreshImport = IsFreshImport;
|
ProfileEntity.IsFreshImport = IsFreshImport;
|
||||||
ProfileEntity.LastSelectedProfileElement = LastSelectedProfileElement?.EntityId ?? Guid.Empty;
|
|
||||||
|
|
||||||
foreach (ProfileElement profileElement in Children)
|
foreach (ProfileElement profileElement in Children)
|
||||||
profileElement.Save();
|
profileElement.Save();
|
||||||
|
|||||||
@ -148,15 +148,6 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable
|
|||||||
private set => SetAndNotify(ref _activationConditionMet, value);
|
private set => SetAndNotify(ref _activationConditionMet, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a boolean indicating whether this profile configuration is being edited
|
|
||||||
/// </summary>
|
|
||||||
public bool IsBeingEdited
|
|
||||||
{
|
|
||||||
get => _isBeingEdited;
|
|
||||||
set => SetAndNotify(ref _isBeingEdited, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the profile of this profile configuration
|
/// Gets the profile of this profile configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -243,8 +234,6 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable
|
|||||||
{
|
{
|
||||||
if (_disposed)
|
if (_disposed)
|
||||||
throw new ObjectDisposedException("ProfileConfiguration");
|
throw new ObjectDisposedException("ProfileConfiguration");
|
||||||
if (IsBeingEdited)
|
|
||||||
return true;
|
|
||||||
if (Category.IsSuspended || IsSuspended || IsMissingModule)
|
if (Category.IsSuspended || IsSuspended || IsMissingModule)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@ -26,19 +26,26 @@ public interface IProfileService : IArtemisService
|
|||||||
ReadOnlyCollection<ProfileConfiguration> ProfileConfigurations { get; }
|
ReadOnlyCollection<ProfileConfiguration> ProfileConfigurations { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a boolean indicating whether hotkeys are enabled.
|
/// Gets or sets the focused profile configuration which is rendered exclusively.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool HotkeysEnabled { get; set; }
|
ProfileConfiguration? FocusProfile { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a boolean indicating whether rendering should only be done for profiles being edited.
|
/// Gets or sets the profile element which is rendered exclusively.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool RenderForEditor { get; set; }
|
ProfileElement? FocusProfileElement { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the profile element to focus on while rendering for the editor.
|
/// Gets or sets a value indicating whether the currently focused profile should receive updates.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ProfileElement? EditorFocus { get; set; }
|
bool UpdateFocusProfile { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a copy of the provided profile configuration.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="profileConfiguration">The profile configuration to clone.</param>
|
||||||
|
/// <returns>The resulting clone.</returns>
|
||||||
|
ProfileConfiguration CloneProfileConfiguration(ProfileConfiguration profileConfiguration);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Activates the profile of the given <see cref="ProfileConfiguration" /> with the currently active surface.
|
/// Activates the profile of the given <see cref="ProfileConfiguration" /> with the currently active surface.
|
||||||
|
|||||||
@ -15,14 +15,14 @@ namespace Artemis.Core.Services;
|
|||||||
internal class ProfileService : IProfileService
|
internal class ProfileService : IProfileService
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
private readonly IRgbService _rgbService;
|
||||||
|
private readonly IProfileCategoryRepository _profileCategoryRepository;
|
||||||
|
private readonly IPluginManagementService _pluginManagementService;
|
||||||
|
|
||||||
private readonly List<ArtemisKeyboardKeyEventArgs> _pendingKeyboardEvents = new();
|
private readonly List<ArtemisKeyboardKeyEventArgs> _pendingKeyboardEvents = new();
|
||||||
private readonly IPluginManagementService _pluginManagementService;
|
|
||||||
private readonly List<ProfileCategory> _profileCategories;
|
private readonly List<ProfileCategory> _profileCategories;
|
||||||
private readonly IProfileCategoryRepository _profileCategoryRepository;
|
|
||||||
private readonly IProfileRepository _profileRepository;
|
private readonly IProfileRepository _profileRepository;
|
||||||
private readonly List<Exception> _renderExceptions = new();
|
private readonly List<Exception> _renderExceptions = new();
|
||||||
private readonly IRgbService _rgbService;
|
|
||||||
private readonly List<Exception> _updateExceptions = new();
|
private readonly List<Exception> _updateExceptions = new();
|
||||||
private DateTime _lastRenderExceptionLog;
|
private DateTime _lastRenderExceptionLog;
|
||||||
private DateTime _lastUpdateExceptionLog;
|
private DateTime _lastUpdateExceptionLog;
|
||||||
@ -45,7 +45,6 @@ internal class ProfileService : IProfileService
|
|||||||
_pluginManagementService.PluginFeatureEnabled += PluginManagementServiceOnPluginFeatureToggled;
|
_pluginManagementService.PluginFeatureEnabled += PluginManagementServiceOnPluginFeatureToggled;
|
||||||
_pluginManagementService.PluginFeatureDisabled += PluginManagementServiceOnPluginFeatureToggled;
|
_pluginManagementService.PluginFeatureDisabled += PluginManagementServiceOnPluginFeatureToggled;
|
||||||
|
|
||||||
HotkeysEnabled = true;
|
|
||||||
inputService.KeyboardKeyUp += InputServiceOnKeyboardKeyUp;
|
inputService.KeyboardKeyUp += InputServiceOnKeyboardKeyUp;
|
||||||
|
|
||||||
if (!_profileCategories.Any())
|
if (!_profileCategories.Any())
|
||||||
@ -53,11 +52,416 @@ internal class ProfileService : IProfileService
|
|||||||
UpdateModules();
|
UpdateModules();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InputServiceOnKeyboardKeyUp(object? sender, ArtemisKeyboardKeyEventArgs e)
|
public ProfileConfiguration? FocusProfile { get; set; }
|
||||||
|
public ProfileElement? FocusProfileElement { get; set; }
|
||||||
|
public bool UpdateFocusProfile { get; set; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void UpdateProfiles(double deltaTime)
|
||||||
{
|
{
|
||||||
if (!HotkeysEnabled)
|
// If there is a focus profile update only that, and only if UpdateFocusProfile is true
|
||||||
|
if (FocusProfile != null)
|
||||||
|
{
|
||||||
|
if (UpdateFocusProfile)
|
||||||
|
FocusProfile.Profile?.Update(deltaTime);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lock (_profileCategories)
|
||||||
|
{
|
||||||
|
// Iterate the children in reverse because the first category must be rendered last to end up on top
|
||||||
|
for (int i = _profileCategories.Count - 1; i > -1; i--)
|
||||||
|
{
|
||||||
|
ProfileCategory profileCategory = _profileCategories[i];
|
||||||
|
for (int j = profileCategory.ProfileConfigurations.Count - 1; j > -1; j--)
|
||||||
|
{
|
||||||
|
ProfileConfiguration profileConfiguration = profileCategory.ProfileConfigurations[j];
|
||||||
|
|
||||||
|
// Process hotkeys that where pressed since this profile last updated
|
||||||
|
ProcessPendingKeyEvents(profileConfiguration);
|
||||||
|
|
||||||
|
bool shouldBeActive = profileConfiguration.ShouldBeActive(false);
|
||||||
|
if (shouldBeActive)
|
||||||
|
{
|
||||||
|
profileConfiguration.Update();
|
||||||
|
shouldBeActive = profileConfiguration.ActivationConditionMet;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Make sure the profile is active or inactive according to the parameters above
|
||||||
|
if (shouldBeActive && profileConfiguration.Profile == null && profileConfiguration.BrokenState != "Failed to activate profile")
|
||||||
|
profileConfiguration.TryOrBreak(() => ActivateProfile(profileConfiguration), "Failed to activate profile");
|
||||||
|
if (shouldBeActive && profileConfiguration.Profile != null && !profileConfiguration.Profile.ShouldDisplay)
|
||||||
|
profileConfiguration.Profile.ShouldDisplay = true;
|
||||||
|
else if (!shouldBeActive && profileConfiguration.Profile != null)
|
||||||
|
{
|
||||||
|
if (!profileConfiguration.FadeInAndOut)
|
||||||
|
DeactivateProfile(profileConfiguration);
|
||||||
|
else if (!profileConfiguration.Profile.ShouldDisplay && profileConfiguration.Profile.Opacity <= 0)
|
||||||
|
DeactivateProfile(profileConfiguration);
|
||||||
|
else if (profileConfiguration.Profile.Opacity > 0)
|
||||||
|
RequestDeactivation(profileConfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
|
profileConfiguration.Profile?.Update(deltaTime);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_updateExceptions.Add(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LogProfileUpdateExceptions();
|
||||||
|
_pendingKeyboardEvents.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void RenderProfiles(SKCanvas canvas)
|
||||||
|
{
|
||||||
|
// If there is a focus profile, render only that
|
||||||
|
if (FocusProfile != null)
|
||||||
|
{
|
||||||
|
FocusProfile.Profile?.Render(canvas, SKPointI.Empty, FocusProfileElement);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lock (_profileCategories)
|
||||||
|
{
|
||||||
|
// Iterate the children in reverse because the first category must be rendered last to end up on top
|
||||||
|
for (int i = _profileCategories.Count - 1; i > -1; i--)
|
||||||
|
{
|
||||||
|
ProfileCategory profileCategory = _profileCategories[i];
|
||||||
|
for (int j = profileCategory.ProfileConfigurations.Count - 1; j > -1; j--)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ProfileConfiguration profileConfiguration = profileCategory.ProfileConfigurations[j];
|
||||||
|
// Ensure all criteria are met before rendering
|
||||||
|
bool fadingOut = profileConfiguration.Profile?.ShouldDisplay == false && profileConfiguration.Profile?.Opacity > 0;
|
||||||
|
if (!profileConfiguration.IsSuspended && !profileConfiguration.IsMissingModule && (profileConfiguration.ActivationConditionMet || fadingOut))
|
||||||
|
profileConfiguration.Profile?.Render(canvas, SKPointI.Empty, null);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_renderExceptions.Add(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LogProfileRenderExceptions();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public ReadOnlyCollection<ProfileCategory> ProfileCategories
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (_profileRepository)
|
||||||
|
{
|
||||||
|
return _profileCategories.AsReadOnly();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public ReadOnlyCollection<ProfileConfiguration> ProfileConfigurations
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock (_profileRepository)
|
||||||
|
{
|
||||||
|
return _profileCategories.SelectMany(c => c.ProfileConfigurations).ToList().AsReadOnly();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void LoadProfileConfigurationIcon(ProfileConfiguration profileConfiguration)
|
||||||
|
{
|
||||||
|
if (profileConfiguration.Icon.IconType == ProfileConfigurationIconType.MaterialIcon)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
using Stream? stream = _profileCategoryRepository.GetProfileIconStream(profileConfiguration.Entity.FileIconId);
|
||||||
|
if (stream != null)
|
||||||
|
profileConfiguration.Icon.SetIconByStream(profileConfiguration.Entity.IconOriginalFileName, stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void SaveProfileConfigurationIcon(ProfileConfiguration profileConfiguration)
|
||||||
|
{
|
||||||
|
if (profileConfiguration.Icon.IconType == ProfileConfigurationIconType.MaterialIcon)
|
||||||
|
return;
|
||||||
|
|
||||||
|
using Stream? stream = profileConfiguration.Icon.GetIconStream();
|
||||||
|
if (stream != null && profileConfiguration.Icon.OriginalFileName != null)
|
||||||
|
{
|
||||||
|
profileConfiguration.Entity.IconOriginalFileName = profileConfiguration.Icon.OriginalFileName;
|
||||||
|
_profileCategoryRepository.SaveProfileIconStream(profileConfiguration.Entity, stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public ProfileConfiguration CloneProfileConfiguration(ProfileConfiguration profileConfiguration)
|
||||||
|
{
|
||||||
|
return new ProfileConfiguration(profileConfiguration.Category, profileConfiguration.Entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public Profile ActivateProfile(ProfileConfiguration profileConfiguration)
|
||||||
|
{
|
||||||
|
if (profileConfiguration.Profile != null)
|
||||||
|
{
|
||||||
|
profileConfiguration.Profile.ShouldDisplay = true;
|
||||||
|
return profileConfiguration.Profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProfileEntity profileEntity;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
profileEntity = _profileRepository.Get(profileConfiguration.Entity.ProfileId);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
profileConfiguration.SetBrokenState("Failed to activate profile", e);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (profileEntity == null)
|
||||||
|
throw new ArtemisCoreException($"Cannot find profile named: {profileConfiguration.Name} ID: {profileConfiguration.Entity.ProfileId}");
|
||||||
|
|
||||||
|
Profile profile = new(profileConfiguration, profileEntity);
|
||||||
|
profile.PopulateLeds(_rgbService.EnabledDevices);
|
||||||
|
|
||||||
|
if (profile.IsFreshImport)
|
||||||
|
{
|
||||||
|
_logger.Debug("Profile is a fresh import, adapting to surface - {profile}", profile);
|
||||||
|
AdaptProfile(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
profileConfiguration.Profile = profile;
|
||||||
|
|
||||||
|
OnProfileActivated(new ProfileConfigurationEventArgs(profileConfiguration));
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void DeactivateProfile(ProfileConfiguration profileConfiguration)
|
||||||
|
{
|
||||||
|
if (FocusProfile == profileConfiguration)
|
||||||
|
throw new ArtemisCoreException("Cannot disable a profile that is being edited, that's rude");
|
||||||
|
if (profileConfiguration.Profile == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Profile profile = profileConfiguration.Profile;
|
||||||
|
profileConfiguration.Profile = null;
|
||||||
|
profile.Dispose();
|
||||||
|
|
||||||
|
OnProfileDeactivated(new ProfileConfigurationEventArgs(profileConfiguration));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void RequestDeactivation(ProfileConfiguration profileConfiguration)
|
||||||
|
{
|
||||||
|
if (FocusProfile == profileConfiguration)
|
||||||
|
throw new ArtemisCoreException("Cannot disable a profile that is being edited, that's rude");
|
||||||
|
if (profileConfiguration.Profile == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
profileConfiguration.Profile.ShouldDisplay = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void DeleteProfile(ProfileConfiguration profileConfiguration)
|
||||||
|
{
|
||||||
|
DeactivateProfile(profileConfiguration);
|
||||||
|
|
||||||
|
ProfileEntity profileEntity = _profileRepository.Get(profileConfiguration.Entity.ProfileId);
|
||||||
|
if (profileEntity == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
profileConfiguration.Category.RemoveProfileConfiguration(profileConfiguration);
|
||||||
|
_profileRepository.Remove(profileEntity);
|
||||||
|
SaveProfileCategory(profileConfiguration.Category);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public ProfileCategory CreateProfileCategory(string name)
|
||||||
|
{
|
||||||
|
ProfileCategory profileCategory;
|
||||||
|
lock (_profileRepository)
|
||||||
|
{
|
||||||
|
profileCategory = new ProfileCategory(name, _profileCategories.Count + 1);
|
||||||
|
_profileCategories.Add(profileCategory);
|
||||||
|
SaveProfileCategory(profileCategory);
|
||||||
|
}
|
||||||
|
|
||||||
|
OnProfileCategoryAdded(new ProfileCategoryEventArgs(profileCategory));
|
||||||
|
return profileCategory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void DeleteProfileCategory(ProfileCategory profileCategory)
|
||||||
|
{
|
||||||
|
List<ProfileConfiguration> profileConfigurations = profileCategory.ProfileConfigurations.ToList();
|
||||||
|
foreach (ProfileConfiguration profileConfiguration in profileConfigurations)
|
||||||
|
RemoveProfileConfiguration(profileConfiguration);
|
||||||
|
|
||||||
|
lock (_profileRepository)
|
||||||
|
{
|
||||||
|
_profileCategories.Remove(profileCategory);
|
||||||
|
_profileCategoryRepository.Remove(profileCategory.Entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
OnProfileCategoryRemoved(new ProfileCategoryEventArgs(profileCategory));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public ProfileConfiguration CreateProfileConfiguration(ProfileCategory category, string name, string icon)
|
||||||
|
{
|
||||||
|
ProfileConfiguration configuration = new(category, name, icon);
|
||||||
|
ProfileEntity entity = new();
|
||||||
|
_profileRepository.Add(entity);
|
||||||
|
|
||||||
|
configuration.Entity.ProfileId = entity.Id;
|
||||||
|
category.AddProfileConfiguration(configuration, 0);
|
||||||
|
return configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void RemoveProfileConfiguration(ProfileConfiguration profileConfiguration)
|
||||||
|
{
|
||||||
|
profileConfiguration.Category.RemoveProfileConfiguration(profileConfiguration);
|
||||||
|
|
||||||
|
DeactivateProfile(profileConfiguration);
|
||||||
|
SaveProfileCategory(profileConfiguration.Category);
|
||||||
|
ProfileEntity profileEntity = _profileRepository.Get(profileConfiguration.Entity.ProfileId);
|
||||||
|
if (profileEntity != null)
|
||||||
|
_profileRepository.Remove(profileEntity);
|
||||||
|
|
||||||
|
profileConfiguration.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void SaveProfileCategory(ProfileCategory profileCategory)
|
||||||
|
{
|
||||||
|
profileCategory.Save();
|
||||||
|
_profileCategoryRepository.Save(profileCategory.Entity);
|
||||||
|
|
||||||
|
lock (_profileCategories)
|
||||||
|
{
|
||||||
|
_profileCategories.Sort((a, b) => a.Order - b.Order);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void SaveProfile(Profile profile, bool includeChildren)
|
||||||
|
{
|
||||||
|
_logger.Debug("Updating profile - Saving {Profile}", profile);
|
||||||
|
profile.Save();
|
||||||
|
if (includeChildren)
|
||||||
|
foreach (RenderProfileElement child in profile.GetAllRenderElements())
|
||||||
|
child.Save();
|
||||||
|
|
||||||
|
// At this point the user made actual changes, save that
|
||||||
|
profile.IsFreshImport = false;
|
||||||
|
profile.ProfileEntity.IsFreshImport = false;
|
||||||
|
|
||||||
|
_profileRepository.Save(profile.ProfileEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public ProfileConfigurationExportModel ExportProfile(ProfileConfiguration profileConfiguration)
|
||||||
|
{
|
||||||
|
// The profile may not be active and in that case lets activate it real quick
|
||||||
|
Profile profile = profileConfiguration.Profile ?? ActivateProfile(profileConfiguration);
|
||||||
|
|
||||||
|
return new ProfileConfigurationExportModel
|
||||||
|
{
|
||||||
|
ProfileConfigurationEntity = profileConfiguration.Entity,
|
||||||
|
ProfileEntity = profile.ProfileEntity,
|
||||||
|
ProfileImage = profileConfiguration.Icon.GetIconStream()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public ProfileConfiguration ImportProfile(ProfileCategory category, ProfileConfigurationExportModel exportModel,
|
||||||
|
bool makeUnique, bool markAsFreshImport, string? nameAffix)
|
||||||
|
{
|
||||||
|
if (exportModel.ProfileEntity == null)
|
||||||
|
throw new ArtemisCoreException("Cannot import a profile without any data");
|
||||||
|
|
||||||
|
// Create a copy of the entity because we'll be using it from now on
|
||||||
|
ProfileEntity profileEntity = JsonConvert.DeserializeObject<ProfileEntity>(
|
||||||
|
JsonConvert.SerializeObject(exportModel.ProfileEntity, IProfileService.ExportSettings),
|
||||||
|
IProfileService.ExportSettings
|
||||||
|
)!;
|
||||||
|
|
||||||
|
// Assign a new GUID to make sure it is unique in case of a previous import of the same content
|
||||||
|
if (makeUnique)
|
||||||
|
profileEntity.UpdateGuid(Guid.NewGuid());
|
||||||
|
|
||||||
|
if (nameAffix != null)
|
||||||
|
profileEntity.Name = $"{profileEntity.Name} - {nameAffix}";
|
||||||
|
if (markAsFreshImport)
|
||||||
|
profileEntity.IsFreshImport = true;
|
||||||
|
|
||||||
|
if (_profileRepository.Get(profileEntity.Id) == null)
|
||||||
|
_profileRepository.Add(profileEntity);
|
||||||
|
else
|
||||||
|
throw new ArtemisCoreException($"Cannot import this profile without {nameof(makeUnique)} being true");
|
||||||
|
|
||||||
|
ProfileConfiguration profileConfiguration;
|
||||||
|
if (exportModel.ProfileConfigurationEntity != null)
|
||||||
|
{
|
||||||
|
ProfileConfigurationEntity profileConfigurationEntity = JsonConvert.DeserializeObject<ProfileConfigurationEntity>(
|
||||||
|
JsonConvert.SerializeObject(exportModel.ProfileConfigurationEntity, IProfileService.ExportSettings), IProfileService.ExportSettings
|
||||||
|
)!;
|
||||||
|
// A new GUID will be given on save
|
||||||
|
profileConfigurationEntity.FileIconId = Guid.Empty;
|
||||||
|
profileConfiguration = new ProfileConfiguration(category, profileConfigurationEntity);
|
||||||
|
if (nameAffix != null)
|
||||||
|
profileConfiguration.Name = $"{profileConfiguration.Name} - {nameAffix}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
profileConfiguration = new ProfileConfiguration(category, profileEntity.Name, "Import");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exportModel.ProfileImage != null && exportModel.ProfileConfigurationEntity?.IconOriginalFileName != null)
|
||||||
|
profileConfiguration.Icon.SetIconByStream(exportModel.ProfileConfigurationEntity.IconOriginalFileName, exportModel.ProfileImage);
|
||||||
|
|
||||||
|
profileConfiguration.Entity.ProfileId = profileEntity.Id;
|
||||||
|
category.AddProfileConfiguration(profileConfiguration, 0);
|
||||||
|
|
||||||
|
List<Module> modules = _pluginManagementService.GetFeaturesOfType<Module>();
|
||||||
|
profileConfiguration.LoadModules(modules);
|
||||||
|
SaveProfileCategory(category);
|
||||||
|
|
||||||
|
return profileConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void AdaptProfile(Profile profile)
|
||||||
|
{
|
||||||
|
List<ArtemisDevice> devices = _rgbService.EnabledDevices.ToList();
|
||||||
|
foreach (Layer layer in profile.GetAllLayers())
|
||||||
|
layer.Adapter.Adapt(devices);
|
||||||
|
|
||||||
|
profile.Save();
|
||||||
|
|
||||||
|
foreach (RenderProfileElement renderProfileElement in profile.GetAllRenderElements())
|
||||||
|
renderProfileElement.Save();
|
||||||
|
|
||||||
|
_logger.Debug("Adapt profile - Saving " + profile);
|
||||||
|
_profileRepository.Save(profile.ProfileEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InputServiceOnKeyboardKeyUp(object? sender, ArtemisKeyboardKeyEventArgs e)
|
||||||
|
{
|
||||||
lock (_profileCategories)
|
lock (_profileCategories)
|
||||||
{
|
{
|
||||||
_pendingKeyboardEvents.Add(e);
|
_pendingKeyboardEvents.Add(e);
|
||||||
@ -181,390 +585,6 @@ internal class ProfileService : IProfileService
|
|||||||
_renderExceptions.Clear();
|
_renderExceptions.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HotkeysEnabled { get; set; }
|
|
||||||
public bool RenderForEditor { get; set; }
|
|
||||||
public ProfileElement? EditorFocus { get; set; }
|
|
||||||
|
|
||||||
public void UpdateProfiles(double deltaTime)
|
|
||||||
{
|
|
||||||
lock (_profileCategories)
|
|
||||||
{
|
|
||||||
// Iterate the children in reverse because the first category must be rendered last to end up on top
|
|
||||||
for (int i = _profileCategories.Count - 1; i > -1; i--)
|
|
||||||
{
|
|
||||||
ProfileCategory profileCategory = _profileCategories[i];
|
|
||||||
for (int j = profileCategory.ProfileConfigurations.Count - 1; j > -1; j--)
|
|
||||||
{
|
|
||||||
ProfileConfiguration profileConfiguration = profileCategory.ProfileConfigurations[j];
|
|
||||||
|
|
||||||
// Process hotkeys that where pressed since this profile last updated
|
|
||||||
ProcessPendingKeyEvents(profileConfiguration);
|
|
||||||
|
|
||||||
// Profiles being edited are updated at their own leisure
|
|
||||||
if (profileConfiguration.IsBeingEdited && RenderForEditor)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
bool shouldBeActive = profileConfiguration.ShouldBeActive(false);
|
|
||||||
if (shouldBeActive)
|
|
||||||
{
|
|
||||||
profileConfiguration.Update();
|
|
||||||
if (!profileConfiguration.IsBeingEdited)
|
|
||||||
shouldBeActive = profileConfiguration.ActivationConditionMet;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Make sure the profile is active or inactive according to the parameters above
|
|
||||||
if (shouldBeActive && profileConfiguration.Profile == null && profileConfiguration.BrokenState != "Failed to activate profile")
|
|
||||||
profileConfiguration.TryOrBreak(() => ActivateProfile(profileConfiguration), "Failed to activate profile");
|
|
||||||
if (shouldBeActive && profileConfiguration.Profile != null && !profileConfiguration.Profile.ShouldDisplay)
|
|
||||||
profileConfiguration.Profile.ShouldDisplay = true;
|
|
||||||
else if (!shouldBeActive && profileConfiguration.Profile != null)
|
|
||||||
{
|
|
||||||
if (!profileConfiguration.FadeInAndOut)
|
|
||||||
DeactivateProfile(profileConfiguration);
|
|
||||||
else if (!profileConfiguration.Profile.ShouldDisplay && profileConfiguration.Profile.Opacity <= 0)
|
|
||||||
DeactivateProfile(profileConfiguration);
|
|
||||||
else if (profileConfiguration.Profile.Opacity > 0)
|
|
||||||
RequestDeactivation(profileConfiguration);
|
|
||||||
}
|
|
||||||
|
|
||||||
profileConfiguration.Profile?.Update(deltaTime);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
_updateExceptions.Add(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LogProfileUpdateExceptions();
|
|
||||||
_pendingKeyboardEvents.Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RenderProfiles(SKCanvas canvas)
|
|
||||||
{
|
|
||||||
lock (_profileCategories)
|
|
||||||
{
|
|
||||||
ProfileConfiguration? editedProfileConfiguration = _profileCategories.SelectMany(c => c.ProfileConfigurations).FirstOrDefault(p => p.IsBeingEdited);
|
|
||||||
if (editedProfileConfiguration != null)
|
|
||||||
{
|
|
||||||
editedProfileConfiguration.Profile?.Render(canvas, SKPointI.Empty, RenderForEditor ? EditorFocus : null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RenderForEditor)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Iterate the children in reverse because the first category must be rendered last to end up on top
|
|
||||||
for (int i = _profileCategories.Count - 1; i > -1; i--)
|
|
||||||
{
|
|
||||||
ProfileCategory profileCategory = _profileCategories[i];
|
|
||||||
for (int j = profileCategory.ProfileConfigurations.Count - 1; j > -1; j--)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ProfileConfiguration profileConfiguration = profileCategory.ProfileConfigurations[j];
|
|
||||||
// Ensure all criteria are met before rendering
|
|
||||||
bool fadingOut = profileConfiguration.Profile?.ShouldDisplay == false && profileConfiguration.Profile?.Opacity > 0;
|
|
||||||
if (!profileConfiguration.IsSuspended && !profileConfiguration.IsMissingModule && (profileConfiguration.ActivationConditionMet || fadingOut))
|
|
||||||
profileConfiguration.Profile?.Render(canvas, SKPointI.Empty, null);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
_renderExceptions.Add(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LogProfileRenderExceptions();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReadOnlyCollection<ProfileCategory> ProfileCategories
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
lock (_profileRepository)
|
|
||||||
{
|
|
||||||
return _profileCategories.AsReadOnly();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReadOnlyCollection<ProfileConfiguration> ProfileConfigurations
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
lock (_profileRepository)
|
|
||||||
{
|
|
||||||
return _profileCategories.SelectMany(c => c.ProfileConfigurations).ToList().AsReadOnly();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadProfileConfigurationIcon(ProfileConfiguration profileConfiguration)
|
|
||||||
{
|
|
||||||
if (profileConfiguration.Icon.IconType == ProfileConfigurationIconType.MaterialIcon)
|
|
||||||
return;
|
|
||||||
|
|
||||||
using Stream? stream = _profileCategoryRepository.GetProfileIconStream(profileConfiguration.Entity.FileIconId);
|
|
||||||
if (stream != null)
|
|
||||||
profileConfiguration.Icon.SetIconByStream(profileConfiguration.Entity.IconOriginalFileName, stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SaveProfileConfigurationIcon(ProfileConfiguration profileConfiguration)
|
|
||||||
{
|
|
||||||
if (profileConfiguration.Icon.IconType == ProfileConfigurationIconType.MaterialIcon)
|
|
||||||
return;
|
|
||||||
|
|
||||||
using Stream? stream = profileConfiguration.Icon.GetIconStream();
|
|
||||||
if (stream != null && profileConfiguration.Icon.OriginalFileName != null)
|
|
||||||
{
|
|
||||||
profileConfiguration.Entity.IconOriginalFileName = profileConfiguration.Icon.OriginalFileName;
|
|
||||||
_profileCategoryRepository.SaveProfileIconStream(profileConfiguration.Entity, stream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Profile ActivateProfile(ProfileConfiguration profileConfiguration)
|
|
||||||
{
|
|
||||||
if (profileConfiguration.Profile != null)
|
|
||||||
{
|
|
||||||
profileConfiguration.Profile.ShouldDisplay = true;
|
|
||||||
return profileConfiguration.Profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProfileEntity profileEntity;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
profileEntity = _profileRepository.Get(profileConfiguration.Entity.ProfileId);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
profileConfiguration.SetBrokenState("Failed to activate profile", e);
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (profileEntity == null)
|
|
||||||
throw new ArtemisCoreException($"Cannot find profile named: {profileConfiguration.Name} ID: {profileConfiguration.Entity.ProfileId}");
|
|
||||||
|
|
||||||
Profile profile = new(profileConfiguration, profileEntity);
|
|
||||||
profile.PopulateLeds(_rgbService.EnabledDevices);
|
|
||||||
|
|
||||||
if (profile.IsFreshImport)
|
|
||||||
{
|
|
||||||
_logger.Debug("Profile is a fresh import, adapting to surface - {profile}", profile);
|
|
||||||
AdaptProfile(profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
profileConfiguration.Profile = profile;
|
|
||||||
|
|
||||||
OnProfileActivated(new ProfileConfigurationEventArgs(profileConfiguration));
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeactivateProfile(ProfileConfiguration profileConfiguration)
|
|
||||||
{
|
|
||||||
if (profileConfiguration.IsBeingEdited)
|
|
||||||
throw new ArtemisCoreException("Cannot disable a profile that is being edited, that's rude");
|
|
||||||
if (profileConfiguration.Profile == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Profile profile = profileConfiguration.Profile;
|
|
||||||
profileConfiguration.Profile = null;
|
|
||||||
profile.Dispose();
|
|
||||||
|
|
||||||
OnProfileDeactivated(new ProfileConfigurationEventArgs(profileConfiguration));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RequestDeactivation(ProfileConfiguration profileConfiguration)
|
|
||||||
{
|
|
||||||
if (profileConfiguration.IsBeingEdited)
|
|
||||||
throw new ArtemisCoreException("Cannot disable a profile that is being edited, that's rude");
|
|
||||||
if (profileConfiguration.Profile == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
profileConfiguration.Profile.ShouldDisplay = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteProfile(ProfileConfiguration profileConfiguration)
|
|
||||||
{
|
|
||||||
DeactivateProfile(profileConfiguration);
|
|
||||||
|
|
||||||
ProfileEntity profileEntity = _profileRepository.Get(profileConfiguration.Entity.ProfileId);
|
|
||||||
if (profileEntity == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
profileConfiguration.Category.RemoveProfileConfiguration(profileConfiguration);
|
|
||||||
_profileRepository.Remove(profileEntity);
|
|
||||||
SaveProfileCategory(profileConfiguration.Category);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProfileCategory CreateProfileCategory(string name)
|
|
||||||
{
|
|
||||||
ProfileCategory profileCategory;
|
|
||||||
lock (_profileRepository)
|
|
||||||
{
|
|
||||||
profileCategory = new ProfileCategory(name, _profileCategories.Count + 1);
|
|
||||||
_profileCategories.Add(profileCategory);
|
|
||||||
SaveProfileCategory(profileCategory);
|
|
||||||
}
|
|
||||||
|
|
||||||
OnProfileCategoryAdded(new ProfileCategoryEventArgs(profileCategory));
|
|
||||||
return profileCategory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteProfileCategory(ProfileCategory profileCategory)
|
|
||||||
{
|
|
||||||
List<ProfileConfiguration> profileConfigurations = profileCategory.ProfileConfigurations.ToList();
|
|
||||||
foreach (ProfileConfiguration profileConfiguration in profileConfigurations)
|
|
||||||
RemoveProfileConfiguration(profileConfiguration);
|
|
||||||
|
|
||||||
lock (_profileRepository)
|
|
||||||
{
|
|
||||||
_profileCategories.Remove(profileCategory);
|
|
||||||
_profileCategoryRepository.Remove(profileCategory.Entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
OnProfileCategoryRemoved(new ProfileCategoryEventArgs(profileCategory));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProfileConfiguration CreateProfileConfiguration(ProfileCategory category, string name, string icon)
|
|
||||||
{
|
|
||||||
ProfileConfiguration configuration = new(category, name, icon);
|
|
||||||
ProfileEntity entity = new();
|
|
||||||
_profileRepository.Add(entity);
|
|
||||||
|
|
||||||
configuration.Entity.ProfileId = entity.Id;
|
|
||||||
category.AddProfileConfiguration(configuration, 0);
|
|
||||||
return configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveProfileConfiguration(ProfileConfiguration profileConfiguration)
|
|
||||||
{
|
|
||||||
profileConfiguration.Category.RemoveProfileConfiguration(profileConfiguration);
|
|
||||||
|
|
||||||
DeactivateProfile(profileConfiguration);
|
|
||||||
SaveProfileCategory(profileConfiguration.Category);
|
|
||||||
ProfileEntity profileEntity = _profileRepository.Get(profileConfiguration.Entity.ProfileId);
|
|
||||||
if (profileEntity != null)
|
|
||||||
_profileRepository.Remove(profileEntity);
|
|
||||||
|
|
||||||
profileConfiguration.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SaveProfileCategory(ProfileCategory profileCategory)
|
|
||||||
{
|
|
||||||
profileCategory.Save();
|
|
||||||
_profileCategoryRepository.Save(profileCategory.Entity);
|
|
||||||
|
|
||||||
lock (_profileCategories)
|
|
||||||
{
|
|
||||||
_profileCategories.Sort((a, b) => a.Order - b.Order);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SaveProfile(Profile profile, bool includeChildren)
|
|
||||||
{
|
|
||||||
_logger.Debug("Updating profile - Saving {Profile}", profile);
|
|
||||||
profile.Save();
|
|
||||||
if (includeChildren)
|
|
||||||
foreach (RenderProfileElement child in profile.GetAllRenderElements())
|
|
||||||
child.Save();
|
|
||||||
|
|
||||||
// At this point the user made actual changes, save that
|
|
||||||
profile.IsFreshImport = false;
|
|
||||||
profile.ProfileEntity.IsFreshImport = false;
|
|
||||||
|
|
||||||
_profileRepository.Save(profile.ProfileEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProfileConfigurationExportModel ExportProfile(ProfileConfiguration profileConfiguration)
|
|
||||||
{
|
|
||||||
// The profile may not be active and in that case lets activate it real quick
|
|
||||||
Profile profile = profileConfiguration.Profile ?? ActivateProfile(profileConfiguration);
|
|
||||||
|
|
||||||
return new ProfileConfigurationExportModel
|
|
||||||
{
|
|
||||||
ProfileConfigurationEntity = profileConfiguration.Entity,
|
|
||||||
ProfileEntity = profile.ProfileEntity,
|
|
||||||
ProfileImage = profileConfiguration.Icon.GetIconStream()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProfileConfiguration ImportProfile(ProfileCategory category, ProfileConfigurationExportModel exportModel,
|
|
||||||
bool makeUnique, bool markAsFreshImport, string? nameAffix)
|
|
||||||
{
|
|
||||||
if (exportModel.ProfileEntity == null)
|
|
||||||
throw new ArtemisCoreException("Cannot import a profile without any data");
|
|
||||||
|
|
||||||
// Create a copy of the entity because we'll be using it from now on
|
|
||||||
ProfileEntity profileEntity = JsonConvert.DeserializeObject<ProfileEntity>(
|
|
||||||
JsonConvert.SerializeObject(exportModel.ProfileEntity, IProfileService.ExportSettings),
|
|
||||||
IProfileService.ExportSettings
|
|
||||||
)!;
|
|
||||||
|
|
||||||
// Assign a new GUID to make sure it is unique in case of a previous import of the same content
|
|
||||||
if (makeUnique)
|
|
||||||
profileEntity.UpdateGuid(Guid.NewGuid());
|
|
||||||
|
|
||||||
if (nameAffix != null)
|
|
||||||
profileEntity.Name = $"{profileEntity.Name} - {nameAffix}";
|
|
||||||
if (markAsFreshImport)
|
|
||||||
profileEntity.IsFreshImport = true;
|
|
||||||
|
|
||||||
if (_profileRepository.Get(profileEntity.Id) == null)
|
|
||||||
_profileRepository.Add(profileEntity);
|
|
||||||
else
|
|
||||||
throw new ArtemisCoreException($"Cannot import this profile without {nameof(makeUnique)} being true");
|
|
||||||
|
|
||||||
ProfileConfiguration profileConfiguration;
|
|
||||||
if (exportModel.ProfileConfigurationEntity != null)
|
|
||||||
{
|
|
||||||
ProfileConfigurationEntity profileConfigurationEntity = JsonConvert.DeserializeObject<ProfileConfigurationEntity>(
|
|
||||||
JsonConvert.SerializeObject(exportModel.ProfileConfigurationEntity, IProfileService.ExportSettings), IProfileService.ExportSettings
|
|
||||||
)!;
|
|
||||||
// A new GUID will be given on save
|
|
||||||
profileConfigurationEntity.FileIconId = Guid.Empty;
|
|
||||||
profileConfiguration = new ProfileConfiguration(category, profileConfigurationEntity);
|
|
||||||
if (nameAffix != null)
|
|
||||||
profileConfiguration.Name = $"{profileConfiguration.Name} - {nameAffix}";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
profileConfiguration = new ProfileConfiguration(category, profileEntity.Name, "Import");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exportModel.ProfileImage != null && exportModel.ProfileConfigurationEntity?.IconOriginalFileName != null)
|
|
||||||
profileConfiguration.Icon.SetIconByStream(exportModel.ProfileConfigurationEntity.IconOriginalFileName, exportModel.ProfileImage);
|
|
||||||
|
|
||||||
profileConfiguration.Entity.ProfileId = profileEntity.Id;
|
|
||||||
category.AddProfileConfiguration(profileConfiguration, 0);
|
|
||||||
|
|
||||||
List<Module> modules = _pluginManagementService.GetFeaturesOfType<Module>();
|
|
||||||
profileConfiguration.LoadModules(modules);
|
|
||||||
SaveProfileCategory(category);
|
|
||||||
|
|
||||||
return profileConfiguration;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public void AdaptProfile(Profile profile)
|
|
||||||
{
|
|
||||||
List<ArtemisDevice> devices = _rgbService.EnabledDevices.ToList();
|
|
||||||
foreach (Layer layer in profile.GetAllLayers())
|
|
||||||
layer.Adapter.Adapt(devices);
|
|
||||||
|
|
||||||
profile.Save();
|
|
||||||
|
|
||||||
foreach (RenderProfileElement renderProfileElement in profile.GetAllRenderElements())
|
|
||||||
renderProfileElement.Save();
|
|
||||||
|
|
||||||
_logger.Debug("Adapt profile - Saving " + profile);
|
|
||||||
_profileRepository.Save(profile.ProfileEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Events
|
#region Events
|
||||||
|
|
||||||
public event EventHandler<ProfileConfigurationEventArgs>? ProfileActivated;
|
public event EventHandler<ProfileConfigurationEventArgs>? ProfileActivated;
|
||||||
|
|||||||
@ -18,7 +18,6 @@ public class ProfileEntity
|
|||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public bool IsFreshImport { get; set; }
|
public bool IsFreshImport { get; set; }
|
||||||
public Guid LastSelectedProfileElement { get; set; }
|
|
||||||
|
|
||||||
public List<FolderEntity> Folders { get; set; }
|
public List<FolderEntity> Folders { get; set; }
|
||||||
public List<LayerEntity> Layers { get; set; }
|
public List<LayerEntity> Layers { get; set; }
|
||||||
|
|||||||
@ -10,7 +10,6 @@ using Artemis.Core;
|
|||||||
using Artemis.Core.Services;
|
using Artemis.Core.Services;
|
||||||
using Artemis.UI.Shared.Services.MainWindow;
|
using Artemis.UI.Shared.Services.MainWindow;
|
||||||
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
|
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
|
||||||
using Avalonia.Threading;
|
|
||||||
using DynamicData;
|
using DynamicData;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
@ -140,14 +139,14 @@ internal class ProfileEditorService : IProfileEditorService
|
|||||||
private void ApplyFocusMode()
|
private void ApplyFocusMode()
|
||||||
{
|
{
|
||||||
if (_suspendedEditingSubject.Value)
|
if (_suspendedEditingSubject.Value)
|
||||||
_profileService.EditorFocus = null;
|
_profileService.FocusProfileElement = null;
|
||||||
|
|
||||||
_profileService.EditorFocus = _focusModeSubject.Value switch
|
_profileService.FocusProfileElement = _focusModeSubject.Value switch
|
||||||
{
|
{
|
||||||
ProfileEditorFocusMode.None => null,
|
ProfileEditorFocusMode.None => null,
|
||||||
ProfileEditorFocusMode.Folder => _profileElementSubject.Value?.Parent,
|
ProfileEditorFocusMode.Folder => _profileElementSubject.Value?.Parent,
|
||||||
ProfileEditorFocusMode.Selection => _profileElementSubject.Value,
|
ProfileEditorFocusMode.Selection => _profileElementSubject.Value,
|
||||||
_ => _profileService.EditorFocus
|
_ => _profileService.FocusProfileElement
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,52 +163,38 @@ internal class ProfileEditorService : IProfileEditorService
|
|||||||
|
|
||||||
public async Task ChangeCurrentProfileConfiguration(ProfileConfiguration? profileConfiguration)
|
public async Task ChangeCurrentProfileConfiguration(ProfileConfiguration? profileConfiguration)
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(_profileConfigurationSubject.Value, profileConfiguration))
|
ProfileConfiguration? previous = _profileConfigurationSubject.Value;
|
||||||
|
if (ReferenceEquals(previous, profileConfiguration))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_logger.Verbose("ChangeCurrentProfileConfiguration {profile}", profileConfiguration);
|
_logger.Verbose("ChangeCurrentProfileConfiguration {profile}", profileConfiguration);
|
||||||
|
|
||||||
// Stop playing and save the current profile
|
// Stop playing and save the current profile
|
||||||
Pause();
|
Pause();
|
||||||
if (_profileConfigurationSubject.Value?.Profile != null)
|
|
||||||
{
|
|
||||||
_profileConfigurationSubject.Value.Profile.Reset();
|
|
||||||
_profileConfigurationSubject.Value.Profile.LastSelectedProfileElement = _profileElementSubject.Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
await SaveProfileAsync();
|
await SaveProfileAsync();
|
||||||
|
|
||||||
// No need to deactivate the profile, if needed it will be deactivated next update
|
|
||||||
if (_profileConfigurationSubject.Value != null)
|
|
||||||
_profileConfigurationSubject.Value.IsBeingEdited = false;
|
|
||||||
|
|
||||||
// Deselect whatever profile element was active
|
// Deselect whatever profile element was active
|
||||||
ChangeCurrentProfileElement(null);
|
ChangeCurrentProfileElement(null);
|
||||||
|
ChangeSuspendedEditing(false);
|
||||||
|
|
||||||
// Close the command scope if one was open
|
// Close the command scope if one was open
|
||||||
_profileEditorHistoryScope?.Dispose();
|
_profileEditorHistoryScope?.Dispose();
|
||||||
|
|
||||||
// The new profile may need activation
|
// Activate the profile and it's mode off of the UI thread
|
||||||
if (profileConfiguration != null)
|
await Task.Run(() =>
|
||||||
{
|
{
|
||||||
await Task.Run(() =>
|
// Activate the profile if one was provided
|
||||||
{
|
if (profileConfiguration != null)
|
||||||
profileConfiguration.IsBeingEdited = true;
|
|
||||||
_moduleService.SetActivationOverride(profileConfiguration.Module);
|
|
||||||
_profileService.ActivateProfile(profileConfiguration);
|
_profileService.ActivateProfile(profileConfiguration);
|
||||||
_profileService.RenderForEditor = true;
|
// If there is no profile configuration or module, deliberately set the override to null
|
||||||
});
|
_moduleService.SetActivationOverride(profileConfiguration?.Module);
|
||||||
if (profileConfiguration.Profile?.LastSelectedProfileElement is RenderProfileElement renderProfileElement)
|
});
|
||||||
ChangeCurrentProfileElement(renderProfileElement);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_moduleService.SetActivationOverride(null);
|
|
||||||
_profileService.RenderForEditor = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
_profileService.FocusProfile = profileConfiguration;
|
||||||
_profileConfigurationSubject.OnNext(profileConfiguration);
|
_profileConfigurationSubject.OnNext(profileConfiguration);
|
||||||
|
|
||||||
ChangeTime(TimeSpan.Zero);
|
ChangeTime(TimeSpan.Zero);
|
||||||
|
previous?.Profile?.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeCurrentProfileElement(RenderProfileElement? renderProfileElement)
|
public void ChangeCurrentProfileElement(RenderProfileElement? renderProfileElement)
|
||||||
@ -238,20 +223,20 @@ internal class ProfileEditorService : IProfileEditorService
|
|||||||
if (_suspendedEditingSubject.Value == suspend)
|
if (_suspendedEditingSubject.Value == suspend)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_suspendedEditingSubject.OnNext(suspend);
|
|
||||||
if (suspend)
|
if (suspend)
|
||||||
{
|
{
|
||||||
Pause();
|
Pause();
|
||||||
_profileService.RenderForEditor = false;
|
_profileService.UpdateFocusProfile = true;
|
||||||
_profileConfigurationSubject.Value?.Profile?.Reset();
|
_profileConfigurationSubject.Value?.Profile?.Reset();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_profileConfigurationSubject.Value != null)
|
if (_profileConfigurationSubject.Value != null)
|
||||||
_profileService.RenderForEditor = true;
|
_profileService.UpdateFocusProfile = false;
|
||||||
Tick(_timeSubject.Value);
|
Tick(_timeSubject.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_suspendedEditingSubject.OnNext(suspend);
|
||||||
ApplyFocusMode();
|
ApplyFocusMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,10 +396,8 @@ internal class ProfileEditorService : IProfileEditorService
|
|||||||
public void SaveProfile()
|
public void SaveProfile()
|
||||||
{
|
{
|
||||||
Profile? profile = _profileConfigurationSubject.Value?.Profile;
|
Profile? profile = _profileConfigurationSubject.Value?.Profile;
|
||||||
if (profile == null)
|
if (profile != null)
|
||||||
return;
|
_profileService.SaveProfile(profile, true);
|
||||||
|
|
||||||
_profileService.SaveProfile(profile, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@ -10,15 +10,10 @@
|
|||||||
<TextBlock Classes="h5">This is heading 5</TextBlock>
|
<TextBlock Classes="h5">This is heading 5</TextBlock>
|
||||||
<TextBlock Classes="h6">This is heading 6</TextBlock>
|
<TextBlock Classes="h6">This is heading 6</TextBlock>
|
||||||
<TextBlock Classes="subtitle">This is a subtitle</TextBlock>
|
<TextBlock Classes="subtitle">This is a subtitle</TextBlock>
|
||||||
<TextBlock>
|
<TextBlock Classes="danger">Danger</TextBlock>
|
||||||
<Run Classes="h1">This is heading 1</Run>
|
<TextBlock Classes="warning">Warning</TextBlock>
|
||||||
<Run Classes="h2">This is heading 2</Run>
|
<TextBlock Classes="success">Success</TextBlock>
|
||||||
<Run Classes="h3">This is heading 3</Run>
|
<TextBlock Classes="info">Info</TextBlock>
|
||||||
<Run Classes="h4">This is heading 4</Run>
|
|
||||||
<Run Classes="h5">This is heading 5</Run>
|
|
||||||
<Run Classes="h6">This is heading 6</Run>
|
|
||||||
<Run Classes="subtitle">This is a subtitle</Run>
|
|
||||||
</TextBlock>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
</Design.PreviewWith>
|
</Design.PreviewWith>
|
||||||
@ -81,4 +76,30 @@
|
|||||||
<Style Selector="Run.subtitle">
|
<Style Selector="Run.subtitle">
|
||||||
<Setter Property="Foreground" Value="{DynamicResource TextFillColorTertiaryBrush}" />
|
<Setter Property="Foreground" Value="{DynamicResource TextFillColorTertiaryBrush}" />
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="TextBlock.danger">
|
||||||
|
<Setter Property="Foreground" Value="#FF5C5C"></Setter>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="TextBlock.warning">
|
||||||
|
<Setter Property="Foreground" Value="#DAA520"></Setter>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="TextBlock.success">
|
||||||
|
<Setter Property="Foreground" Value="#12B775"></Setter>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="TextBlock.info">
|
||||||
|
<Setter Property="Foreground" Value="{DynamicResource AccentButtonBackground}"></Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
<Style Selector="Run.danger">
|
||||||
|
<Setter Property="Foreground" Value="#FF5C5C"></Setter>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Run.warning">
|
||||||
|
<Setter Property="Foreground" Value="#DAA520"></Setter>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Run.success">
|
||||||
|
<Setter Property="Foreground" Value="#12B775"></Setter>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Run.info">
|
||||||
|
<Setter Property="Foreground" Value="{DynamicResource AccentButtonBackground}"></Setter>
|
||||||
|
</Style>
|
||||||
</Styles>
|
</Styles>
|
||||||
|
|||||||
@ -39,9 +39,17 @@
|
|||||||
<PackageReference Include="RGB.NET.Layout" Version="$(RGBDotNetVersion)" />
|
<PackageReference Include="RGB.NET.Layout" Version="$(RGBDotNetVersion)" />
|
||||||
<PackageReference Include="SkiaSharp" Version="$(SkiaSharpVersion)" />
|
<PackageReference Include="SkiaSharp" Version="$(SkiaSharpVersion)" />
|
||||||
<PackageReference Include="Splat.DryIoc" Version="14.6.8" />
|
<PackageReference Include="Splat.DryIoc" Version="14.6.8" />
|
||||||
|
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AvaloniaResource Include="Assets\**" />
|
<AvaloniaResource Include="Assets\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="Screens\Workshop\SubmissionWizard\Steps\Profile\ProfileSelectionStepView.axaml.cs">
|
||||||
|
<DependentUpon>ProfileSelectionStepView.axaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@ -16,7 +16,6 @@ using Artemis.UI.Shared.Services;
|
|||||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using Serilog;
|
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.ProfileEditor.MenuBar;
|
namespace Artemis.UI.Screens.ProfileEditor.MenuBar;
|
||||||
|
|
||||||
@ -182,7 +181,7 @@ public class MenuBarViewModel : ActivatableViewModelBase
|
|||||||
if (!await _windowService.ShowConfirmContentDialog("Delete profile", "Are you sure you want to permanently delete this profile?"))
|
if (!await _windowService.ShowConfirmContentDialog("Delete profile", "Are you sure you want to permanently delete this profile?"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ProfileConfiguration.IsBeingEdited)
|
if (_profileService.FocusProfile == ProfileConfiguration)
|
||||||
await _router.Navigate("home");
|
await _router.Navigate("home");
|
||||||
_profileService.RemoveProfileConfiguration(ProfileConfiguration);
|
_profileService.RemoveProfileConfiguration(ProfileConfiguration);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
|
using System.Reactive.Linq;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls.PanAndZoom;
|
using Avalonia.Controls.PanAndZoom;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
@ -31,11 +31,7 @@ public partial class VisualEditorView : ReactiveUserControl<VisualEditorViewMode
|
|||||||
Disposable.Create(() => ViewModel.AutoFitRequested -= ViewModelOnAutoFitRequested).DisposeWith(d);
|
Disposable.Create(() => ViewModel.AutoFitRequested -= ViewModelOnAutoFitRequested).DisposeWith(d);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.WhenAnyValue(v => v.Bounds).Subscribe(_ =>
|
this.WhenAnyValue(v => v.Bounds).Where(_ => !_movedByUser).Subscribe(_ => AutoFit(true));
|
||||||
{
|
|
||||||
if (!_movedByUser)
|
|
||||||
AutoFit(true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ZoomBorderOnPointerWheelChanged(object? sender, PointerWheelEventArgs e)
|
private void ZoomBorderOnPointerWheelChanged(object? sender, PointerWheelEventArgs e)
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Settings.Updating;
|
namespace Artemis.UI.Screens.Settings.Updating;
|
||||||
|
|
||||||
@ -10,9 +8,4 @@ public partial class ReleaseView : UserControl
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -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?"))
|
if (!await _windowService.ShowConfirmContentDialog("Delete profile", "Are you sure you want to permanently delete this profile?"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_profileConfiguration.IsBeingEdited)
|
if (_profileService.FocusProfile == _profileConfiguration)
|
||||||
await _profileEditorService.ChangeCurrentProfileConfiguration(null);
|
await _profileEditorService.ChangeCurrentProfileConfiguration(null);
|
||||||
_profileService.RemoveProfileConfiguration(_profileConfiguration);
|
_profileService.RemoveProfileConfiguration(_profileConfiguration);
|
||||||
Close(_profileConfiguration);
|
Close(_profileConfiguration);
|
||||||
|
|||||||
@ -24,9 +24,9 @@ namespace Artemis.UI.Screens.Sidebar;
|
|||||||
public class SidebarCategoryViewModel : ActivatableViewModelBase
|
public class SidebarCategoryViewModel : ActivatableViewModelBase
|
||||||
{
|
{
|
||||||
private readonly IProfileService _profileService;
|
private readonly IProfileService _profileService;
|
||||||
private readonly IWindowService _windowService;
|
|
||||||
private readonly ISidebarVmFactory _vmFactory;
|
|
||||||
private readonly IRouter _router;
|
private readonly IRouter _router;
|
||||||
|
private readonly ISidebarVmFactory _vmFactory;
|
||||||
|
private readonly IWindowService _windowService;
|
||||||
private ObservableAsPropertyHelper<bool>? _isCollapsed;
|
private ObservableAsPropertyHelper<bool>? _isCollapsed;
|
||||||
private ObservableAsPropertyHelper<bool>? _isSuspended;
|
private ObservableAsPropertyHelper<bool>? _isSuspended;
|
||||||
private SidebarProfileConfigurationViewModel? _selectedProfileConfiguration;
|
private SidebarProfileConfigurationViewModel? _selectedProfileConfiguration;
|
||||||
@ -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 (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");
|
await _router.Navigate("home");
|
||||||
_profileService.DeleteProfileCategory(ProfileCategory);
|
_profileService.DeleteProfileCategory(ProfileCategory);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,7 +98,7 @@ public class SidebarProfileConfigurationViewModel : ActivatableViewModelBase
|
|||||||
if (!await _windowService.ShowConfirmContentDialog("Delete profile", "Are you sure you want to permanently delete this profile?"))
|
if (!await _windowService.ShowConfirmContentDialog("Delete profile", "Are you sure you want to permanently delete this profile?"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ProfileConfiguration.IsBeingEdited)
|
if (_profileService.FocusProfile == ProfileConfiguration)
|
||||||
await _router.Navigate("home");
|
await _router.Navigate("home");
|
||||||
_profileService.RemoveProfileConfiguration(ProfileConfiguration);
|
_profileService.RemoveProfileConfiguration(ProfileConfiguration);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.Categories;
|
namespace Artemis.UI.Screens.Workshop.Categories;
|
||||||
@ -12,10 +11,6 @@ public partial class CategoriesView : ReactiveUserControl<CategoriesViewModel>
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InputElement_OnPointerReleased(object? sender, PointerReleasedEventArgs e)
|
private void InputElement_OnPointerReleased(object? sender, PointerReleasedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.CurrentUser;
|
namespace Artemis.UI.Screens.Workshop.CurrentUser;
|
||||||
@ -9,9 +8,4 @@ public partial class WorkshopLoginView : ReactiveUserControl<WorkshopLoginViewMo
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,6 +1,3 @@
|
|||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Input;
|
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.Entries;
|
namespace Artemis.UI.Screens.Workshop.Entries;
|
||||||
@ -11,9 +8,4 @@ public partial class EntryListView : ReactiveUserControl<EntryListViewModel>
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,6 +1,3 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.Home;
|
namespace Artemis.UI.Screens.Workshop.Home;
|
||||||
@ -11,9 +8,4 @@ public partial class WorkshopHomeView : ReactiveUserControl<WorkshopHomeViewMode
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,3 @@
|
|||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.Layout;
|
namespace Artemis.UI.Screens.Workshop.Layout;
|
||||||
@ -9,9 +8,4 @@ public partial class LayoutDetailsView : ReactiveUserControl<LayoutDetailsViewMo
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,3 @@
|
|||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.Layout;
|
namespace Artemis.UI.Screens.Workshop.Layout;
|
||||||
@ -9,9 +8,4 @@ public partial class LayoutListView : ReactiveUserControl<LayoutListViewModel>
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,3 @@
|
|||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.Profile;
|
namespace Artemis.UI.Screens.Workshop.Profile;
|
||||||
@ -9,9 +8,4 @@ public partial class ProfileDetailsView : ReactiveUserControl<ProfileDetailsView
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,3 @@
|
|||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.Profile;
|
namespace Artemis.UI.Screens.Workshop.Profile;
|
||||||
@ -9,9 +8,4 @@ public partial class ProfileListView : ReactiveUserControl<ProfileListViewModel>
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -0,0 +1,58 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:profile="clr-namespace:Artemis.UI.Screens.Workshop.Profile"
|
||||||
|
xmlns:core="clr-namespace:Artemis.Core;assembly=Artemis.Core"
|
||||||
|
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="Artemis.UI.Screens.Workshop.Profile.ProfilePreviewView"
|
||||||
|
x:DataType="profile:ProfilePreviewViewModel">
|
||||||
|
<UserControl.Resources>
|
||||||
|
<VisualBrush x:Key="LargeCheckerboardBrush" TileMode="Tile" Stretch="Uniform" SourceRect="0,0,20,20">
|
||||||
|
<VisualBrush.Visual>
|
||||||
|
<Canvas Width="20" Height="20">
|
||||||
|
<Rectangle Width="10" Height="10" Fill="Black" Opacity="0.15" />
|
||||||
|
<Rectangle Width="10" Height="10" Canvas.Left="10" />
|
||||||
|
<Rectangle Width="10" Height="10" Canvas.Top="10" />
|
||||||
|
<Rectangle Width="10" Height="10" Canvas.Left="10" Canvas.Top="10" Fill="Black" Opacity="0.15" />
|
||||||
|
</Canvas>
|
||||||
|
</VisualBrush.Visual>
|
||||||
|
</VisualBrush>
|
||||||
|
</UserControl.Resources>
|
||||||
|
<ZoomBorder Name="ZoomBorder"
|
||||||
|
Stretch="None"
|
||||||
|
ClipToBounds="True"
|
||||||
|
Focusable="True"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Background="{StaticResource LargeCheckerboardBrush}"
|
||||||
|
ZoomChanged="ZoomBorder_OnZoomChanged">
|
||||||
|
<Grid Name="ContainerGrid" Background="Transparent">
|
||||||
|
<Grid.Transitions>
|
||||||
|
<Transitions>
|
||||||
|
<TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.2" Easing="CubicEaseOut" />
|
||||||
|
</Transitions>
|
||||||
|
</Grid.Transitions>
|
||||||
|
|
||||||
|
<ItemsControl Name="DevicesContainer" ItemsSource="{CompiledBinding Devices}" ClipToBounds="False">
|
||||||
|
<ItemsControl.Styles>
|
||||||
|
<Style Selector="ContentPresenter" x:DataType="core:ArtemisDevice">
|
||||||
|
<Setter Property="Canvas.Left" Value="{CompiledBinding X}" />
|
||||||
|
<Setter Property="Canvas.Top" Value="{CompiledBinding Y}" />
|
||||||
|
</Style>
|
||||||
|
</ItemsControl.Styles>
|
||||||
|
<ItemsControl.ItemsPanel>
|
||||||
|
<ItemsPanelTemplate>
|
||||||
|
<Canvas />
|
||||||
|
</ItemsPanelTemplate>
|
||||||
|
</ItemsControl.ItemsPanel>
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate DataType="core:ArtemisDevice">
|
||||||
|
<shared:DeviceVisualizer Device="{CompiledBinding}" ShowColors="True" RenderOptions.BitmapInterpolationMode="MediumQuality" />
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
</ItemsControl>
|
||||||
|
</Grid>
|
||||||
|
</ZoomBorder>
|
||||||
|
</UserControl>
|
||||||
@ -0,0 +1,79 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reactive.Linq;
|
||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls.PanAndZoom;
|
||||||
|
using Avalonia.Input;
|
||||||
|
using Avalonia.Media;
|
||||||
|
using Avalonia.ReactiveUI;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Screens.Workshop.Profile;
|
||||||
|
|
||||||
|
public partial class ProfilePreviewView : ReactiveUserControl<ProfilePreviewViewModel>
|
||||||
|
{
|
||||||
|
private bool _movedByUser;
|
||||||
|
|
||||||
|
public ProfilePreviewView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
ZoomBorder.PropertyChanged += ZoomBorderOnPropertyChanged;
|
||||||
|
ZoomBorder.PointerMoved += ZoomBorderOnPointerMoved;
|
||||||
|
ZoomBorder.PointerWheelChanged += ZoomBorderOnPointerWheelChanged;
|
||||||
|
UpdateZoomBorderBackground();
|
||||||
|
|
||||||
|
this.WhenAnyValue(v => v.Bounds).Where(_ => !_movedByUser).Subscribe(_ => AutoFit());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ZoomBorderOnPointerWheelChanged(object? sender, PointerWheelEventArgs e)
|
||||||
|
{
|
||||||
|
_movedByUser = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ZoomBorderOnPointerMoved(object? sender, PointerEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.GetCurrentPoint(ZoomBorder).Properties.IsMiddleButtonPressed)
|
||||||
|
_movedByUser = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ZoomBorderOnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Property.Name == nameof(ZoomBorder.Background))
|
||||||
|
UpdateZoomBorderBackground();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateZoomBorderBackground()
|
||||||
|
{
|
||||||
|
if (ZoomBorder.Background is VisualBrush visualBrush)
|
||||||
|
visualBrush.DestinationRect = new RelativeRect(ZoomBorder.OffsetX * -1, ZoomBorder.OffsetY * -1, 20, 20, RelativeUnit.Absolute);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ZoomBorder_OnZoomChanged(object sender, ZoomChangedEventArgs e)
|
||||||
|
{
|
||||||
|
UpdateZoomBorderBackground();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AutoFit()
|
||||||
|
{
|
||||||
|
if (ViewModel == null || !ViewModel.Devices.Any())
|
||||||
|
return;
|
||||||
|
|
||||||
|
double left = ViewModel.Devices.Select(d => d.Rectangle.Left).Min();
|
||||||
|
double top = ViewModel.Devices.Select(d => d.Rectangle.Top).Min();
|
||||||
|
double bottom = ViewModel.Devices.Select(d => d.Rectangle.Bottom).Max();
|
||||||
|
double right = ViewModel.Devices.Select(d => d.Rectangle.Right).Max();
|
||||||
|
|
||||||
|
// Add a 10 pixel margin around the rect
|
||||||
|
Rect scriptRect = new(new Point(left - 10, top - 10), new Point(right + 10, bottom + 10));
|
||||||
|
|
||||||
|
// The scale depends on the available space
|
||||||
|
double scale = Math.Min(3, Math.Min(Bounds.Width / scriptRect.Width, Bounds.Height / scriptRect.Height));
|
||||||
|
|
||||||
|
// Pan and zoom to make the script fit
|
||||||
|
ZoomBorder.Zoom(scale, 0, 0, true);
|
||||||
|
ZoomBorder.Pan(Bounds.Center.X - scriptRect.Center.X * scale, Bounds.Center.Y - scriptRect.Center.Y * scale, true);
|
||||||
|
|
||||||
|
_movedByUser = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reactive.Disposables;
|
||||||
|
using Artemis.Core;
|
||||||
|
using Artemis.Core.Services;
|
||||||
|
using Artemis.UI.Shared;
|
||||||
|
using Artemis.UI.Shared.Services;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Screens.Workshop.Profile;
|
||||||
|
|
||||||
|
public class ProfilePreviewViewModel : ActivatableViewModelBase
|
||||||
|
{
|
||||||
|
private readonly IProfileService _profileService;
|
||||||
|
private readonly IWindowService _windowService;
|
||||||
|
private ProfileConfiguration? _profileConfiguration;
|
||||||
|
|
||||||
|
public ProfilePreviewViewModel(IProfileService profileService, IRgbService rgbService, IWindowService windowService)
|
||||||
|
{
|
||||||
|
_profileService = profileService;
|
||||||
|
_windowService = windowService;
|
||||||
|
|
||||||
|
Devices = new ObservableCollection<ArtemisDevice>(rgbService.EnabledDevices.OrderBy(d => d.ZIndex));
|
||||||
|
|
||||||
|
this.WhenAnyValue(vm => vm.ProfileConfiguration).Subscribe(_ => Update());
|
||||||
|
this.WhenActivated(d => Disposable.Create(() => PreviewProfile(null)).DisposeWith(d));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<ArtemisDevice> Devices { get; }
|
||||||
|
|
||||||
|
public ProfileConfiguration? ProfileConfiguration
|
||||||
|
{
|
||||||
|
get => _profileConfiguration;
|
||||||
|
set => RaiseAndSetIfChanged(ref _profileConfiguration, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PreviewProfile(ProfileConfiguration);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_windowService.ShowExceptionDialog("Failed to load preview", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PreviewProfile(ProfileConfiguration? profileConfiguration)
|
||||||
|
{
|
||||||
|
_profileService.FocusProfile = profileConfiguration;
|
||||||
|
_profileService.UpdateFocusProfile = profileConfiguration != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,6 +1,4 @@
|
|||||||
using System;
|
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.Search;
|
namespace Artemis.UI.Screens.Workshop.Search;
|
||||||
|
|
||||||
@ -10,9 +8,4 @@ public partial class SearchView : UserControl
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,3 @@
|
|||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps;
|
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps;
|
||||||
@ -9,9 +8,4 @@ public partial class EntryTypeView : ReactiveUserControl<EntryTypeViewModel>
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
using System;
|
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
|
using Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Profile;
|
||||||
using Artemis.WebClient.Workshop;
|
using Artemis.WebClient.Workshop;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps;
|
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps;
|
||||||
@ -9,9 +8,4 @@ public partial class LoginStepView : ReactiveUserControl<LoginStepView>
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
using System.Reactive;
|
||||||
|
using System.Reactive.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Artemis.Core;
|
||||||
|
using Artemis.Core.Services;
|
||||||
|
using Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs;
|
||||||
|
using Artemis.UI.Shared;
|
||||||
|
using Artemis.UI.Shared.Services;
|
||||||
|
using FluentAvalonia.Core;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Profile;
|
||||||
|
|
||||||
|
public class ProfileAdaptionHintsLayerViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
private readonly IWindowService _windowService;
|
||||||
|
private readonly IProfileService _profileService;
|
||||||
|
private readonly ObservableAsPropertyHelper<string> _adaptionHintText;
|
||||||
|
private int _adaptionHintCount;
|
||||||
|
|
||||||
|
public Layer Layer { get; }
|
||||||
|
|
||||||
|
public ProfileAdaptionHintsLayerViewModel(Layer layer, IWindowService windowService, IProfileService profileService)
|
||||||
|
{
|
||||||
|
_windowService = windowService;
|
||||||
|
_profileService = profileService;
|
||||||
|
_adaptionHintText = this.WhenAnyValue(vm => vm.AdaptionHintCount).Select(c => c == 1 ? "1 adaption hint" : $"{c} adaption hints").ToProperty(this, vm => vm.AdaptionHintText);
|
||||||
|
|
||||||
|
Layer = layer;
|
||||||
|
EditAdaptionHints = ReactiveCommand.CreateFromTask(ExecuteEditAdaptionHints);
|
||||||
|
AdaptionHintCount = layer.Adapter.AdaptionHints.Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReactiveCommand<Unit, Unit> EditAdaptionHints { get; }
|
||||||
|
|
||||||
|
public int AdaptionHintCount
|
||||||
|
{
|
||||||
|
get => _adaptionHintCount;
|
||||||
|
private set => RaiseAndSetIfChanged(ref _adaptionHintCount, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string AdaptionHintText => _adaptionHintText.Value;
|
||||||
|
|
||||||
|
private async Task ExecuteEditAdaptionHints()
|
||||||
|
{
|
||||||
|
await _windowService.ShowDialogAsync<LayerHintsDialogViewModel, bool>(Layer);
|
||||||
|
_profileService.SaveProfile(Layer.Profile, true);
|
||||||
|
|
||||||
|
AdaptionHintCount = Layer.Adapter.AdaptionHints.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
|
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
|
||||||
|
xmlns:profile="clr-namespace:Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Profile"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Profile.ProfileAdaptionHintsStepView"
|
||||||
|
x:DataType="profile:ProfileAdaptionHintsStepViewModel">
|
||||||
|
<Grid ColumnDefinitions="*,Auto" RowDefinitions="Auto,Auto, *">
|
||||||
|
<Grid.Styles>
|
||||||
|
<Styles>
|
||||||
|
<Style Selector="TextBlock">
|
||||||
|
<Setter Property="TextWrapping" Value="Wrap"></Setter>
|
||||||
|
</Style>
|
||||||
|
</Styles>
|
||||||
|
</Grid.Styles>
|
||||||
|
<TextBlock Grid.Row="0" Theme="{StaticResource TitleTextBlockStyle}" TextWrapping="Wrap">
|
||||||
|
Set up profile adaption hints
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" TextWrapping="Wrap">
|
||||||
|
Add hints below to help decide where to place this each layer when the profile is imported by another user.
|
||||||
|
</TextBlock>
|
||||||
|
|
||||||
|
|
||||||
|
<controls:HyperlinkButton Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
NavigateUri="https://wiki.artemis-rgb.com/guides/user/profiles/layers/adaption-hints?mtm_campaign=artemis&mtm_kwd=workshop-wizard">
|
||||||
|
Learn more about adaption hints
|
||||||
|
</controls:HyperlinkButton>
|
||||||
|
|
||||||
|
<ItemsRepeater ItemsSource="{CompiledBinding Layers}" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="0 10 0 0">
|
||||||
|
<ItemsRepeater.ItemTemplate>
|
||||||
|
<DataTemplate DataType="profile:ProfileAdaptionHintsLayerViewModel">
|
||||||
|
<StackPanel>
|
||||||
|
<Border Classes="card-separator" />
|
||||||
|
<Grid ColumnDefinitions="Auto,*,Auto" RowDefinitions="*,*">
|
||||||
|
<avalonia:MaterialIcon Grid.Column="0"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.RowSpan="2"
|
||||||
|
Width="25"
|
||||||
|
Height="25"
|
||||||
|
Margin="5 0 10 0"
|
||||||
|
Kind="{CompiledBinding Layer.LayerBrush.Descriptor.Icon, FallbackValue=QuestionMark}" />
|
||||||
|
<TextBlock Grid.Column="1" Grid.Row="0" Text="{CompiledBinding Layer.Name}" />
|
||||||
|
<TextBlock Grid.Column="1"
|
||||||
|
Grid.Row="1"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Classes="subtitle"
|
||||||
|
Classes.danger="{CompiledBinding !AdaptionHintCount}"
|
||||||
|
Text="{CompiledBinding AdaptionHintText}">
|
||||||
|
</TextBlock>
|
||||||
|
<Button Grid.Column="2"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.RowSpan="2"
|
||||||
|
Command="{Binding EditAdaptionHints}">
|
||||||
|
Edit hints
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsRepeater.ItemTemplate>
|
||||||
|
</ItemsRepeater>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Profile;
|
||||||
|
|
||||||
|
public partial class ProfileAdaptionHintsStepView : ReactiveUserControl<ProfileAdaptionHintsStepViewModel>
|
||||||
|
{
|
||||||
|
public ProfileAdaptionHintsStepView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reactive;
|
||||||
|
using System.Reactive.Disposables;
|
||||||
|
using System.Reactive.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Artemis.Core;
|
||||||
|
using Artemis.Core.Services;
|
||||||
|
using Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs;
|
||||||
|
using Artemis.UI.Shared.Services;
|
||||||
|
using DynamicData;
|
||||||
|
using ReactiveUI;
|
||||||
|
using DynamicData.Aggregation;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Profile;
|
||||||
|
|
||||||
|
public class ProfileAdaptionHintsStepViewModel : SubmissionViewModel
|
||||||
|
{
|
||||||
|
private readonly IWindowService _windowService;
|
||||||
|
private readonly IProfileService _profileService;
|
||||||
|
private readonly SourceList<ProfileAdaptionHintsLayerViewModel> _layers;
|
||||||
|
|
||||||
|
public ProfileAdaptionHintsStepViewModel(IWindowService windowService, IProfileService profileService, Func<Layer, ProfileAdaptionHintsLayerViewModel> getLayerViewModel)
|
||||||
|
{
|
||||||
|
_windowService = windowService;
|
||||||
|
_profileService = profileService;
|
||||||
|
_layers = new SourceList<ProfileAdaptionHintsLayerViewModel>();
|
||||||
|
_layers.Connect().Bind(out ReadOnlyObservableCollection<ProfileAdaptionHintsLayerViewModel> layers).Subscribe();
|
||||||
|
|
||||||
|
GoBack = ReactiveCommand.Create(() => State.ChangeScreen<ProfileSelectionStepViewModel>());
|
||||||
|
Continue = ReactiveCommand.Create(ExecuteContinue, _layers.Connect().AutoRefresh(l => l.AdaptionHintCount).Filter(l => l.AdaptionHintCount == 0).IsEmpty());
|
||||||
|
EditAdaptionHints = ReactiveCommand.CreateFromTask<Layer>(ExecuteEditAdaptionHints);
|
||||||
|
Layers = layers;
|
||||||
|
|
||||||
|
this.WhenActivated((CompositeDisposable _) =>
|
||||||
|
{
|
||||||
|
if (State.EntrySource is ProfileConfiguration profileConfiguration && profileConfiguration.Profile != null)
|
||||||
|
{
|
||||||
|
_layers.Edit(l =>
|
||||||
|
{
|
||||||
|
l.Clear();
|
||||||
|
l.AddRange(profileConfiguration.Profile.GetAllLayers().Select(getLayerViewModel));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public override ReactiveCommand<Unit, Unit> Continue { get; }
|
||||||
|
public override ReactiveCommand<Unit, Unit> GoBack { get; }
|
||||||
|
public ReactiveCommand<Layer, Unit> EditAdaptionHints { get; }
|
||||||
|
public ReadOnlyObservableCollection<ProfileAdaptionHintsLayerViewModel> Layers { get; }
|
||||||
|
|
||||||
|
private async Task ExecuteEditAdaptionHints(Layer layer)
|
||||||
|
{
|
||||||
|
await _windowService.ShowDialogAsync<LayerHintsDialogViewModel, bool>(layer);
|
||||||
|
_profileService.SaveProfile(layer.Profile, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExecuteContinue()
|
||||||
|
{
|
||||||
|
if (Layers.Any(l => l.AdaptionHintCount == 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:core="clr-namespace:Artemis.Core;assembly=Artemis.Core"
|
||||||
|
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
||||||
|
xmlns:profile="clr-namespace:Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Profile"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Profile.ProfileSelectionStepView"
|
||||||
|
x:DataType="profile:ProfileSelectionStepViewModel">
|
||||||
|
<Grid RowDefinitions="Auto,*">
|
||||||
|
<StackPanel>
|
||||||
|
<StackPanel.Styles>
|
||||||
|
<Styles>
|
||||||
|
<Style Selector="TextBlock">
|
||||||
|
<Setter Property="TextWrapping" Value="Wrap"></Setter>
|
||||||
|
</Style>
|
||||||
|
</Styles>
|
||||||
|
</StackPanel.Styles>
|
||||||
|
<TextBlock Theme="{StaticResource TitleTextBlockStyle}" TextWrapping="Wrap">
|
||||||
|
Profile selection
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock TextWrapping="Wrap">
|
||||||
|
Please select the profile you want to share, a preview will be shown below.
|
||||||
|
</TextBlock>
|
||||||
|
|
||||||
|
<ComboBox ItemsSource="{CompiledBinding Profiles}" SelectedItem="{CompiledBinding SelectedProfile}"
|
||||||
|
Width="460"
|
||||||
|
VerticalContentAlignment="Center"
|
||||||
|
Height="50"
|
||||||
|
Margin="0 15"
|
||||||
|
PlaceholderText="Select a profile">
|
||||||
|
<ComboBox.ItemTemplate>
|
||||||
|
<DataTemplate DataType="core:ProfileConfiguration">
|
||||||
|
<Grid RowDefinitions="Auto,*" ColumnDefinitions="Auto,*">
|
||||||
|
<shared:ProfileConfigurationIcon Grid.Row="0"
|
||||||
|
Grid.RowSpan="2"
|
||||||
|
Grid.Column="0"
|
||||||
|
ConfigurationIcon="{CompiledBinding Icon}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Width="22"
|
||||||
|
Height="22"
|
||||||
|
Margin="0 0 10 0" />
|
||||||
|
<TextBlock Grid.Row="0" Grid.Column="1" Text="{CompiledBinding Name}" TextTrimming="CharacterEllipsis"></TextBlock>
|
||||||
|
<TextBlock Grid.Row="1" Grid.Column="1" Text="{CompiledBinding Category.Name}" TextTrimming="CharacterEllipsis" Classes="subtitle"></TextBlock>
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</ComboBox.ItemTemplate>
|
||||||
|
</ComboBox>
|
||||||
|
</StackPanel>
|
||||||
|
<Border Grid.Row="1" Classes="card" Padding="0" ClipToBounds="True" IsVisible="{CompiledBinding SelectedProfile, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||||
|
<ContentControl Content="{CompiledBinding ProfilePreview}"></ContentControl>
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
</UserControl>
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Profile;
|
||||||
|
|
||||||
|
public partial class ProfileSelectionStepView : ReactiveUserControl<ProfileSelectionStepViewModel>
|
||||||
|
{
|
||||||
|
public ProfileSelectionStepView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,83 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reactive;
|
||||||
|
using System.Reactive.Disposables;
|
||||||
|
using System.Reactive.Linq;
|
||||||
|
using Artemis.Core;
|
||||||
|
using Artemis.Core.Services;
|
||||||
|
using Artemis.Storage.Entities.Profile;
|
||||||
|
using Artemis.Storage.Repositories.Interfaces;
|
||||||
|
using Artemis.UI.Screens.Workshop.Profile;
|
||||||
|
using ReactiveUI;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.Profile;
|
||||||
|
|
||||||
|
public class ProfileSelectionStepViewModel : SubmissionViewModel
|
||||||
|
{
|
||||||
|
private readonly IProfileService _profileService;
|
||||||
|
private readonly IProfileCategoryRepository _profileCategoryRepository;
|
||||||
|
private ProfileConfiguration? _selectedProfile;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public ProfileSelectionStepViewModel(IProfileService profileService, ProfilePreviewViewModel profilePreviewViewModel)
|
||||||
|
{
|
||||||
|
_profileService = profileService;
|
||||||
|
|
||||||
|
// Use copies of the profiles, the originals are used by the core and could be disposed
|
||||||
|
Profiles = new ObservableCollection<ProfileConfiguration>(_profileService.ProfileConfigurations.Select(_profileService.CloneProfileConfiguration));
|
||||||
|
ProfilePreview = profilePreviewViewModel;
|
||||||
|
|
||||||
|
GoBack = ReactiveCommand.Create(() => State.ChangeScreen<EntryTypeViewModel>());
|
||||||
|
Continue = ReactiveCommand.Create(ExecuteContinue, this.WhenAnyValue(vm => vm.SelectedProfile).Select(p => p != null));
|
||||||
|
|
||||||
|
this.WhenAnyValue(vm => vm.SelectedProfile).Subscribe(p => Update(p));
|
||||||
|
this.WhenActivated((CompositeDisposable _) =>
|
||||||
|
{
|
||||||
|
if (State.EntrySource is ProfileConfiguration profileConfiguration)
|
||||||
|
SelectedProfile = Profiles.FirstOrDefault(p => p.ProfileId == profileConfiguration.ProfileId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update(ProfileConfiguration? profileConfiguration)
|
||||||
|
{
|
||||||
|
ProfilePreview.ProfileConfiguration = null;
|
||||||
|
|
||||||
|
foreach (ProfileConfiguration configuration in Profiles)
|
||||||
|
{
|
||||||
|
if (configuration == profileConfiguration)
|
||||||
|
_profileService.ActivateProfile(configuration);
|
||||||
|
else
|
||||||
|
_profileService.DeactivateProfile(configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
ProfilePreview.ProfileConfiguration = profileConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<ProfileConfiguration> Profiles { get; }
|
||||||
|
public ProfilePreviewViewModel ProfilePreview { get; }
|
||||||
|
|
||||||
|
public ProfileConfiguration? SelectedProfile
|
||||||
|
{
|
||||||
|
get => _selectedProfile;
|
||||||
|
set => RaiseAndSetIfChanged(ref _selectedProfile, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override ReactiveCommand<Unit, Unit> Continue { get; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override ReactiveCommand<Unit, Unit> GoBack { get; }
|
||||||
|
|
||||||
|
private void ExecuteContinue()
|
||||||
|
{
|
||||||
|
if (SelectedProfile == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
State.EntrySource = SelectedProfile;
|
||||||
|
State.Name = SelectedProfile.Name;
|
||||||
|
State.Icon = SelectedProfile.Icon.GetIconStream();
|
||||||
|
|
||||||
|
State.ChangeScreen<ProfileAdaptionHintsStepViewModel>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,10 +0,0 @@
|
|||||||
<UserControl xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:steps="clr-namespace:Artemis.UI.Screens.Workshop.SubmissionWizard.Steps"
|
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
|
||||||
x:Class="Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.ProfileSelectionStepView"
|
|
||||||
x:DataType="steps:ProfileSelectionStepViewModel">
|
|
||||||
Welcome to Avalonia!
|
|
||||||
</UserControl>
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps;
|
|
||||||
|
|
||||||
public partial class ProfileSelectionStepView : UserControl
|
|
||||||
{
|
|
||||||
public ProfileSelectionStepView()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
using System.Reactive;
|
|
||||||
using ReactiveUI;
|
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps;
|
|
||||||
|
|
||||||
public class ProfileSelectionStepViewModel : SubmissionViewModel
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override ReactiveCommand<Unit, Unit> Continue { get; }
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override ReactiveCommand<Unit, Unit> GoBack { get; }
|
|
||||||
}
|
|
||||||
@ -1,4 +1,3 @@
|
|||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps;
|
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps;
|
||||||
@ -9,9 +8,4 @@ public partial class ValidateEmailStepView : ReactiveUserControl<ValidateEmailSt
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,4 +1,3 @@
|
|||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps;
|
namespace Artemis.UI.Screens.Workshop.SubmissionWizard.Steps;
|
||||||
@ -9,9 +8,4 @@ public partial class WelcomeStepView : ReactiveUserControl<WelcomeStepViewModel>
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
AvaloniaXamlLoader.Load(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -7,8 +7,8 @@ namespace Artemis.UI.Screens.Workshop.SubmissionWizard;
|
|||||||
|
|
||||||
public class SubmissionWizardState
|
public class SubmissionWizardState
|
||||||
{
|
{
|
||||||
private readonly SubmissionWizardViewModel _wizardViewModel;
|
|
||||||
private readonly IContainer _container;
|
private readonly IContainer _container;
|
||||||
|
private readonly SubmissionWizardViewModel _wizardViewModel;
|
||||||
|
|
||||||
public SubmissionWizardState(SubmissionWizardViewModel wizardViewModel, IContainer container)
|
public SubmissionWizardState(SubmissionWizardViewModel wizardViewModel, IContainer container)
|
||||||
{
|
{
|
||||||
@ -27,6 +27,8 @@ public class SubmissionWizardState
|
|||||||
public List<int> Tags { get; set; } = new();
|
public List<int> Tags { get; set; } = new();
|
||||||
public List<Stream> Images { get; set; } = new();
|
public List<Stream> Images { get; set; } = new();
|
||||||
|
|
||||||
|
public object? EntrySource { get; set; }
|
||||||
|
|
||||||
public void ChangeScreen<TSubmissionViewModel>() where TSubmissionViewModel : SubmissionViewModel
|
public void ChangeScreen<TSubmissionViewModel>() where TSubmissionViewModel : SubmissionViewModel
|
||||||
{
|
{
|
||||||
_wizardViewModel.Screen = _container.Resolve<TSubmissionViewModel>();
|
_wizardViewModel.Screen = _container.Resolve<TSubmissionViewModel>();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user