Sidebar - Refactored category VM to fix all issues with it I could find

Sidebar - Streamlined design
Sidebar - Increase width on wide window sizes
Profile editor - Implement File and Help menus
This commit is contained in:
Robert committed 2022-05-14 22:57:53 +02:00
1 parent 35f83e58e5
commit 78479c0fa2
79 files changed
+1093 -946

No files matched your search

@@ -141,6 +141,20 @@ public interface IProfileEditorService : IArtemisSharedUIService
/// <returns>The rounded time.</returns>
TimeSpan RoundTime(TimeSpan time);
/// <summary>
/// Creates a new folder as a sibling or child of the given target.
/// </summary>
/// <param name="target">The target, if this is a layer the new layer will become a sibling, otherwise a child.</param>
/// <returns>The resulting folder.</returns>
Folder CreateAndAddFolder(ProfileElement target);
/// <summary>
/// Creates a new layer with the default brush and all current LEDs as a sibling or child of the given target.
/// </summary>
/// <param name="target">The target, if this is a layer the new layer will become a sibling, otherwise a child.</param>
/// <returns>The resulting layer.</returns>
Layer CreateAndAddLayer(ProfileElement target);
/// <summary>
/// Executes the provided command and adds it to the history.
/// </summary>
@@ -18,6 +18,8 @@ internal class ProfileEditorService : IProfileEditorService
private readonly BehaviorSubject<ILayerProperty?> _layerPropertySubject = new(null);
private readonly ILogger _logger;
private readonly IModuleService _moduleService;
private readonly IRgbService _rgbService;
private readonly ILayerBrushService _layerBrushService;
private readonly BehaviorSubject<int> _pixelsPerSecondSubject = new(120);
private readonly BehaviorSubject<bool> _playingSubject = new(false);
private readonly BehaviorSubject<ProfileConfiguration?> _profileConfigurationSubject = new(null);
@@ -30,11 +32,18 @@ internal class ProfileEditorService : IProfileEditorService
private readonly IWindowService _windowService;
private ProfileEditorCommandScope? _profileEditorHistoryScope;
public ProfileEditorService(ILogger logger, IProfileService profileService, IModuleService moduleService, IWindowService windowService)
public ProfileEditorService(ILogger logger,
IProfileService profileService,
IModuleService moduleService,
IRgbService rgbService,
ILayerBrushService layerBrushService,
IWindowService windowService)
{
_logger = logger;
_profileService = profileService;
_moduleService = moduleService;
_rgbService = rgbService;
_layerBrushService = layerBrushService;
_windowService = windowService;
ProfileConfiguration = _profileConfigurationSubject.AsObservable();
@@ -293,6 +302,48 @@ internal class ProfileEditorService : IProfileEditorService
return TimeSpan.FromMilliseconds(Math.Round(time.TotalMilliseconds));
}
/// <inheritdoc />
public Folder CreateAndAddFolder(ProfileElement target)
{
if (target is Layer targetLayer)
{
Folder folder = new(targetLayer.Parent, targetLayer.Parent.GetNewFolderName());
ExecuteCommand(new AddProfileElement(folder, targetLayer.Parent, targetLayer.Order));
return folder;
}
else
{
Folder folder = new(target, target.GetNewFolderName());
ExecuteCommand(new AddProfileElement(folder, target, 0));
return folder;
}
}
/// <inheritdoc />
public Layer CreateAndAddLayer(ProfileElement target)
{
if (target is Layer targetLayer)
{
Layer layer = new(targetLayer.Parent, targetLayer.GetNewLayerName());
_layerBrushService.ApplyDefaultBrush(layer);
layer.AddLeds(_rgbService.EnabledDevices.SelectMany(d => d.Leds));
ExecuteCommand(new AddProfileElement(layer, targetLayer.Parent, targetLayer.Order));
return layer;
}
else
{
Layer layer = new(target, target.GetNewLayerName());
_layerBrushService.ApplyDefaultBrush(layer);
layer.AddLeds(_rgbService.EnabledDevices.SelectMany(d => d.Leds));
ExecuteCommand(new AddProfileElement(layer, target, 0));
return layer;
}
}
public void ChangePixelsPerSecond(int pixelsPerSecond)
{
_pixelsPerSecondSubject.OnNext(pixelsPerSecond);