Profile editor - Finished most of the refactor except databindings

This commit is contained in:
SpoinkyNL committed 2020-09-14 01:24:07 +02:00
1 parent 5b321b25c9
commit d49b574bda
56 files changed
+866 -459

No files matched your search

@@ -5,16 +5,17 @@ using Artemis.Core.LayerBrushes;
using Artemis.Core.Services;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Services;
using Stylet;
namespace Artemis.UI.PropertyInput
{
public class BrushPropertyInputViewModel : PropertyInputViewModel<LayerBrushReference>
{
private readonly IPluginService _pluginService;
private List<LayerBrushDescriptor> _descriptors;
private BindableCollection<LayerBrushDescriptor> _descriptors;
public BrushPropertyInputViewModel(LayerProperty<LayerBrushReference> layerProperty,
IProfileEditorService profileEditorService,
IProfileEditorService profileEditorService,
IPluginService pluginService) : base(layerProperty, profileEditorService)
{
_pluginService = pluginService;
@@ -24,7 +25,7 @@ namespace Artemis.UI.PropertyInput
UpdateEnumValues();
}
public List<LayerBrushDescriptor> Descriptors
public BindableCollection<LayerBrushDescriptor> Descriptors
{
get => _descriptors;
set => SetAndNotify(ref _descriptors, value);
@@ -32,14 +33,14 @@ namespace Artemis.UI.PropertyInput
public LayerBrushDescriptor SelectedDescriptor
{
get => Descriptors.FirstOrDefault(d => d.LayerBrushProvider.PluginInfo.Guid == InputValue?.BrushPluginGuid && d.LayerBrushType.Name == InputValue?.BrushType);
get => Descriptors.FirstOrDefault(d => d.MatchesLayerBrushReference(InputValue));
set => SetBrushByDescriptor(value);
}
public void UpdateEnumValues()
{
var layerBrushProviders = _pluginService.GetPluginsOfType<LayerBrushProvider>();
Descriptors = layerBrushProviders.SelectMany(l => l.LayerBrushDescriptors).ToList();
Descriptors = new BindableCollection<LayerBrushDescriptor>(layerBrushProviders.SelectMany(l => l.LayerBrushDescriptors));
NotifyOfPropertyChange(nameof(SelectedDescriptor));
}
@@ -53,13 +54,13 @@ namespace Artemis.UI.PropertyInput
protected override void OnInputValueApplied()
{
if (LayerProperty.ProfileElement is Layer layer)
if (LayerProperty.ProfileElement is Layer layer)
layer.ChangeLayerBrush(SelectedDescriptor);
}
private void SetBrushByDescriptor(LayerBrushDescriptor value)
{
InputValue = new LayerBrushReference {BrushPluginGuid = value.LayerBrushProvider.PluginInfo.Guid, BrushType = value.LayerBrushType.Name};
InputValue = new LayerBrushReference(value);
}
private void PluginServiceOnPluginLoaded(object sender, PluginEventArgs e)