diff --git a/src/Artemis.Core/Models/Profile/Profile.cs b/src/Artemis.Core/Models/Profile/Profile.cs index ef9dfed2d..072881ea5 100644 --- a/src/Artemis.Core/Models/Profile/Profile.cs +++ b/src/Artemis.Core/Models/Profile/Profile.cs @@ -47,7 +47,6 @@ namespace Artemis.Core /// public List ScriptConfigurations { get; } - /// /// Gets or sets a boolean indicating whether this profile is freshly imported i.e. no changes have been made to it /// since import diff --git a/src/Artemis.Core/Models/Profile/ProfileElement.cs b/src/Artemis.Core/Models/Profile/ProfileElement.cs index 01c8f5ab8..e30b5d355 100644 --- a/src/Artemis.Core/Models/Profile/ProfileElement.cs +++ b/src/Artemis.Core/Models/Profile/ProfileElement.cs @@ -130,6 +130,16 @@ namespace Artemis.Core /// public event EventHandler? ChildRemoved; + /// + /// Occurs when a child was added to the list of this element or any of it's descendents. + /// + public event EventHandler? DescendentAdded; + + /// + /// Occurs when a child was removed from the list of this element or any of it's descendents. + /// + public event EventHandler? DescendentRemoved; + /// /// Invokes the event /// @@ -146,6 +156,24 @@ namespace Artemis.Core ChildRemoved?.Invoke(this, new ProfileElementEventArgs(child)); } + /// + /// Invokes the event + /// + protected virtual void OnDescendentAdded(ProfileElement child) + { + DescendentAdded?.Invoke(this, new ProfileElementEventArgs(child)); + Parent?.OnDescendentAdded(child); + } + + /// + /// Invokes the event + /// + protected virtual void OnDescendentRemoved(ProfileElement child) + { + DescendentRemoved?.Invoke(this, new ProfileElementEventArgs(child)); + Parent?.OnDescendentRemoved(child); + } + /// /// Disposes the profile element /// @@ -200,6 +228,7 @@ namespace Artemis.Core } OnChildAdded(child); + OnDescendentAdded(child); } /// @@ -220,6 +249,7 @@ namespace Artemis.Core } OnChildRemoved(child); + OnDescendentRemoved(child); } private void StreamlineOrder() diff --git a/src/Avalonia/Artemis.UI.Linux/packages.lock.json b/src/Avalonia/Artemis.UI.Linux/packages.lock.json index 024c40a50..9cda5ffc1 100644 --- a/src/Avalonia/Artemis.UI.Linux/packages.lock.json +++ b/src/Avalonia/Artemis.UI.Linux/packages.lock.json @@ -222,12 +222,14 @@ }, "FluentAvaloniaUI": { "type": "Transitive", - "resolved": "1.1.8", - "contentHash": "pWxi0zvl4+602rffgZgRIS2srUr/bKFCH/duiV72UodmMp291vaWLC3Lzbp3j5TzSuPHYAlcUBIFvEMlnu8WLQ==", + "resolved": "1.2.1", + "contentHash": "IH9eei7CrOUkUdxL2E/HZYKFgNupSVO+ju74CnVqmV7u7iolyz3g1cTHELqVgatEb+IqXw7KyeLr2459nUxYSw==", "dependencies": { - "Avalonia": "0.10.11", - "Avalonia.Desktop": "0.10.11", - "Avalonia.Diagnostics": "0.10.11" + "Avalonia": "0.10.12", + "Avalonia.Desktop": "0.10.12", + "Avalonia.Diagnostics": "0.10.12", + "MicroCom.CodeGenerator.MSBuild": "0.10.4", + "MicroCom.Runtime": "0.10.4" } }, "Flurl": { @@ -335,6 +337,16 @@ "Microsoft.Extensions.DependencyModel": "5.0.0" } }, + "MicroCom.CodeGenerator.MSBuild": { + "type": "Transitive", + "resolved": "0.10.4", + "contentHash": "aG1kLtkgX6lC8qpxVon4OFSCdWYEbQubIg+2/ychWTIFTrDHWFkhcC4YTn0IfGiVCLwh0Yj7eSc8nk5f3UoMKg==" + }, + "MicroCom.Runtime": { + "type": "Transitive", + "resolved": "0.10.4", + "contentHash": "enc2U+/1UnF3rtocxb5ofcg7cJSmJI4adbYPr8DZa5bQzvhqA/VbjlcalxoqjI3CR2RvM5WWpjKT0p3BriFJjw==" + }, "Microsoft.CodeAnalysis.Analyzers": { "type": "Transitive", "resolved": "2.9.6", @@ -1753,7 +1765,7 @@ "Avalonia.ReactiveUI": "0.10.12", "Avalonia.Svg.Skia": "0.10.12", "DynamicData": "7.4.9", - "FluentAvaloniaUI": "1.1.8", + "FluentAvaloniaUI": "1.2.1", "Flurl.Http": "3.2.0", "Live.Avalonia": "1.3.1", "Material.Icons.Avalonia": "1.0.2", @@ -1776,7 +1788,7 @@ "Avalonia.Xaml.Interactions": "0.10.12", "Avalonia.Xaml.Interactivity": "0.10.12", "DynamicData": "7.4.9", - "FluentAvaloniaUI": "1.1.8", + "FluentAvaloniaUI": "1.2.1", "Material.Icons.Avalonia": "1.0.2", "RGB.NET.Core": "1.0.0-prerelease7", "ReactiveUI": "17.1.17", diff --git a/src/Avalonia/Artemis.UI.MacOS/packages.lock.json b/src/Avalonia/Artemis.UI.MacOS/packages.lock.json index 024c40a50..9cda5ffc1 100644 --- a/src/Avalonia/Artemis.UI.MacOS/packages.lock.json +++ b/src/Avalonia/Artemis.UI.MacOS/packages.lock.json @@ -222,12 +222,14 @@ }, "FluentAvaloniaUI": { "type": "Transitive", - "resolved": "1.1.8", - "contentHash": "pWxi0zvl4+602rffgZgRIS2srUr/bKFCH/duiV72UodmMp291vaWLC3Lzbp3j5TzSuPHYAlcUBIFvEMlnu8WLQ==", + "resolved": "1.2.1", + "contentHash": "IH9eei7CrOUkUdxL2E/HZYKFgNupSVO+ju74CnVqmV7u7iolyz3g1cTHELqVgatEb+IqXw7KyeLr2459nUxYSw==", "dependencies": { - "Avalonia": "0.10.11", - "Avalonia.Desktop": "0.10.11", - "Avalonia.Diagnostics": "0.10.11" + "Avalonia": "0.10.12", + "Avalonia.Desktop": "0.10.12", + "Avalonia.Diagnostics": "0.10.12", + "MicroCom.CodeGenerator.MSBuild": "0.10.4", + "MicroCom.Runtime": "0.10.4" } }, "Flurl": { @@ -335,6 +337,16 @@ "Microsoft.Extensions.DependencyModel": "5.0.0" } }, + "MicroCom.CodeGenerator.MSBuild": { + "type": "Transitive", + "resolved": "0.10.4", + "contentHash": "aG1kLtkgX6lC8qpxVon4OFSCdWYEbQubIg+2/ychWTIFTrDHWFkhcC4YTn0IfGiVCLwh0Yj7eSc8nk5f3UoMKg==" + }, + "MicroCom.Runtime": { + "type": "Transitive", + "resolved": "0.10.4", + "contentHash": "enc2U+/1UnF3rtocxb5ofcg7cJSmJI4adbYPr8DZa5bQzvhqA/VbjlcalxoqjI3CR2RvM5WWpjKT0p3BriFJjw==" + }, "Microsoft.CodeAnalysis.Analyzers": { "type": "Transitive", "resolved": "2.9.6", @@ -1753,7 +1765,7 @@ "Avalonia.ReactiveUI": "0.10.12", "Avalonia.Svg.Skia": "0.10.12", "DynamicData": "7.4.9", - "FluentAvaloniaUI": "1.1.8", + "FluentAvaloniaUI": "1.2.1", "Flurl.Http": "3.2.0", "Live.Avalonia": "1.3.1", "Material.Icons.Avalonia": "1.0.2", @@ -1776,7 +1788,7 @@ "Avalonia.Xaml.Interactions": "0.10.12", "Avalonia.Xaml.Interactivity": "0.10.12", "DynamicData": "7.4.9", - "FluentAvaloniaUI": "1.1.8", + "FluentAvaloniaUI": "1.2.1", "Material.Icons.Avalonia": "1.0.2", "RGB.NET.Core": "1.0.0-prerelease7", "ReactiveUI": "17.1.17", diff --git a/src/Avalonia/Artemis.UI.Shared/Artemis.UI.Shared.csproj b/src/Avalonia/Artemis.UI.Shared/Artemis.UI.Shared.csproj index 596f5d20a..c47029bb7 100644 --- a/src/Avalonia/Artemis.UI.Shared/Artemis.UI.Shared.csproj +++ b/src/Avalonia/Artemis.UI.Shared/Artemis.UI.Shared.csproj @@ -24,7 +24,7 @@ - + diff --git a/src/Avalonia/Artemis.UI.Shared/Styles/Border.axaml b/src/Avalonia/Artemis.UI.Shared/Styles/Border.axaml index 27e3bf784..54e2cecf1 100644 --- a/src/Avalonia/Artemis.UI.Shared/Styles/Border.axaml +++ b/src/Avalonia/Artemis.UI.Shared/Styles/Border.axaml @@ -22,13 +22,15 @@ + - + + diff --git a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/ProfileTreeViewModel.cs b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/ProfileTreeViewModel.cs index fa6ffe96d..a088691aa 100644 --- a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/ProfileTreeViewModel.cs +++ b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/ProfileTreeViewModel.cs @@ -15,11 +15,13 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree { public class ProfileTreeViewModel : TreeItemViewModel { + private readonly IProfileEditorService _profileEditorService; private TreeItemViewModel? _selectedChild; public ProfileTreeViewModel(IWindowService windowService, IProfileEditorService profileEditorService, IProfileEditorVmFactory profileEditorVmFactory, IRgbService rgbService) : base(null, null, windowService, profileEditorService, rgbService, profileEditorVmFactory) { + _profileEditorService = profileEditorService; this.WhenActivated(d => { profileEditorService.ProfileConfiguration.WhereNotNull().Subscribe(configuration => @@ -43,8 +45,12 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree if (model?.ProfileElement is RenderProfileElement renderProfileElement) profileEditorService.ChangeCurrentProfileElement(renderProfileElement); }); + + ClearSelection = ReactiveCommand.Create(() => _profileEditorService.ChangeCurrentProfileElement(null)); } - + + public ReactiveCommand ClearSelection { get; } + public TreeItemViewModel? SelectedChild { get => _selectedChild; diff --git a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorViewModel.cs b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorViewModel.cs index 489305eb8..d195b186e 100644 --- a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorViewModel.cs +++ b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorViewModel.cs @@ -1,11 +1,13 @@ using System; using System.Collections.Generic; 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.UI.Ninject.Factories; -using Artemis.UI.Screens.ProfileEditor.VisualEditor.Tools; using Artemis.UI.Screens.ProfileEditor.VisualEditor.Visualizers; using Artemis.UI.Shared; using Artemis.UI.Shared.Services.ProfileEditor; @@ -17,9 +19,9 @@ namespace Artemis.UI.Screens.ProfileEditor.VisualEditor; public class VisualEditorViewModel : ActivatableViewModelBase { + private readonly SourceList _visualizers; private readonly IProfileEditorVmFactory _vmFactory; private ObservableAsPropertyHelper? _profileConfiguration; - private readonly SourceList _visualizers; private ReadOnlyObservableCollection _tools; public VisualEditorViewModel(IProfileEditorService profileEditorService, IRgbService rgbService, IProfileEditorVmFactory vmFactory) @@ -36,10 +38,33 @@ public class VisualEditorViewModel : ActivatableViewModelBase this.WhenActivated(d => { - _profileConfiguration = profileEditorService.ProfileConfiguration.ToProperty(this, vm => vm.ProfileConfiguration).DisposeWith(d); - profileEditorService.ProfileConfiguration.Subscribe(CreateVisualizers).DisposeWith(d); - profileEditorService.Tools.Connect().AutoRefreshOnObservable(t => t.WhenAnyValue(vm => vm.IsSelected)).Filter(t => t.IsSelected).Bind(out ReadOnlyObservableCollection tools).Subscribe().DisposeWith(d); + _profileConfiguration = profileEditorService.ProfileConfiguration + .ToProperty(this, vm => vm.ProfileConfiguration) + .DisposeWith(d); + profileEditorService.ProfileConfiguration + .Subscribe(CreateVisualizers) + .DisposeWith(d); + profileEditorService.Tools + .Connect() + .AutoRefreshOnObservable(t => t.WhenAnyValue(vm => vm.IsSelected)).Filter(t => t.IsSelected).Bind(out ReadOnlyObservableCollection tools) + .Subscribe() + .DisposeWith(d); Tools = tools; + + this.WhenAnyValue(vm => vm.ProfileConfiguration) + .Select(p => p?.Profile != null + ? Observable.FromEventPattern(x => p.Profile.DescendentAdded += x, x => p.Profile.DescendentAdded -= x) + : Observable.Never>()) + .Switch() + .Subscribe(AddElement) + .DisposeWith(d); + this.WhenAnyValue(vm => vm.ProfileConfiguration) + .Select(p => p?.Profile != null + ? Observable.FromEventPattern(x => p.Profile.DescendentRemoved += x, x => p.Profile.DescendentRemoved -= x) + : Observable.Never>()) + .Switch() + .Subscribe(RemoveElement) + .DisposeWith(d); }); } @@ -54,9 +79,21 @@ public class VisualEditorViewModel : ActivatableViewModelBase set => RaiseAndSetIfChanged(ref _tools, value); } + private void RemoveElement(EventPattern eventPattern) + { + List visualizers = Visualizers.Where(v => v.ProfileElement == eventPattern.EventArgs.ProfileElement).ToList(); + if (visualizers.Any()) + _visualizers.RemoveMany(visualizers); + } + + private void AddElement(EventPattern eventPattern) + { + if (eventPattern.EventArgs.ProfileElement is Layer layer) + _visualizers.Edit(list => CreateVisualizer(list, layer)); + } + private void CreateVisualizers(ProfileConfiguration? profileConfiguration) { - // TODO: Monitor and respond to new layers/folders and deletions _visualizers.Edit(list => { list.Clear(); diff --git a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/IVisualizerViewModel.cs b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/IVisualizerViewModel.cs index c0134b102..357f99e7e 100644 --- a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/IVisualizerViewModel.cs +++ b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/IVisualizerViewModel.cs @@ -1,7 +1,10 @@ -namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Visualizers; +using Artemis.Core; + +namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Visualizers; public interface IVisualizerViewModel { + ProfileElement? ProfileElement { get; } double X { get; } double Y { get; } int Order { get; } diff --git a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/LayerShapeVisualizerView.axaml b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/LayerShapeVisualizerView.axaml index 703ec1b30..2e53a14e4 100644 --- a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/LayerShapeVisualizerView.axaml +++ b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/LayerShapeVisualizerView.axaml @@ -14,6 +14,7 @@ + diff --git a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/LayerShapeVisualizerView.axaml.cs b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/LayerShapeVisualizerView.axaml.cs index c2e8936c0..426b0a521 100644 --- a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/LayerShapeVisualizerView.axaml.cs +++ b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/LayerShapeVisualizerView.axaml.cs @@ -2,60 +2,79 @@ using System; using System.Linq; using Avalonia; using Avalonia.Controls; +using Avalonia.Controls.Mixins; using Avalonia.Controls.PanAndZoom; using Avalonia.Controls.Shapes; using Avalonia.LogicalTree; using Avalonia.Markup.Xaml; using Avalonia.ReactiveUI; +using ReactiveUI; -namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Visualizers +namespace Artemis.UI.Screens.ProfileEditor.VisualEditor.Visualizers; + +public partial class LayerShapeVisualizerView : ReactiveUserControl { - public partial class LayerShapeVisualizerView : ReactiveUserControl + private ZoomBorder? _zoomBorder; + private readonly Path _layerVisualizerUnbound; + private readonly Path _layerVisualizer; + + public LayerShapeVisualizerView() { - private ZoomBorder? _zoomBorder; - private readonly Path _layerVisualizerUnbound; - private readonly Path _layerVisualizer; + InitializeComponent(); + _layerVisualizer = this.Get("LayerVisualizer"); + _layerVisualizerUnbound = this.Get("LayerVisualizerUnbound"); - public LayerShapeVisualizerView() - { - InitializeComponent(); - _layerVisualizer = this.Get("LayerVisualizer"); - _layerVisualizerUnbound = this.Get("LayerVisualizerUnbound"); - } - - private void InitializeComponent() - { - AvaloniaXamlLoader.Load(this); - } - - #region Overrides of TemplatedControl - - /// - protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) - { - _zoomBorder = (ZoomBorder?) this.GetLogicalAncestors().FirstOrDefault(l => l is ZoomBorder); - if (_zoomBorder != null) - _zoomBorder.PropertyChanged += ZoomBorderOnPropertyChanged; - base.OnAttachedToLogicalTree(e); - } - - /// - protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) - { - if (_zoomBorder != null) - _zoomBorder.PropertyChanged -= ZoomBorderOnPropertyChanged; - base.OnDetachedFromLogicalTree(e); - } - - private void ZoomBorderOnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e) - { - if (e.Property != ZoomBorder.ZoomXProperty || _zoomBorder == null) - return; - - _layerVisualizer.StrokeThickness = Math.Max(1, 4 / _zoomBorder.ZoomX); - _layerVisualizerUnbound.StrokeThickness = _layerVisualizer.StrokeThickness; - } - - #endregion + this.WhenActivated(d => ViewModel.WhenAnyValue(vm => vm.Selected).Subscribe(_ => UpdateStrokeThickness()).DisposeWith(d)); } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + + #region Overrides of TemplatedControl + + /// + protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) + { + _zoomBorder = (ZoomBorder?) this.GetLogicalAncestors().FirstOrDefault(l => l is ZoomBorder); + if (_zoomBorder != null) + _zoomBorder.PropertyChanged += ZoomBorderOnPropertyChanged; + base.OnAttachedToLogicalTree(e); + } + + /// + protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) + { + if (_zoomBorder != null) + _zoomBorder.PropertyChanged -= ZoomBorderOnPropertyChanged; + base.OnDetachedFromLogicalTree(e); + } + + private void ZoomBorderOnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e) + { + if (e.Property != ZoomBorder.ZoomXProperty || _zoomBorder == null) + return; + + UpdateStrokeThickness(); + } + + private void UpdateStrokeThickness() + { + if (_zoomBorder == null) + return; + + if (ViewModel != null && ViewModel.Selected) + { + _layerVisualizer.StrokeThickness = Math.Max(1, 4 / _zoomBorder.ZoomX); + _layerVisualizerUnbound.StrokeThickness = Math.Max(1, 4 / _zoomBorder.ZoomX); + } + else + { + _layerVisualizer.StrokeThickness = Math.Max(1, 4 / _zoomBorder.ZoomX) / 2; + _layerVisualizerUnbound.StrokeThickness = Math.Max(1, 4 / _zoomBorder.ZoomX) / 2; + } + } + + #endregion } \ No newline at end of file diff --git a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/LayerShapeVisualizerViewModel.cs b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/LayerShapeVisualizerViewModel.cs index 31315ae25..dc60211d3 100644 --- a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/LayerShapeVisualizerViewModel.cs +++ b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/LayerShapeVisualizerViewModel.cs @@ -49,6 +49,7 @@ public class LayerShapeVisualizerViewModel : ActivatableViewModelBase, IVisualiz } public Layer Layer { get; } + public ProfileElement ProfileElement => Layer; public bool Selected => _selected?.Value ?? false; public Rect LayerBounds @@ -56,7 +57,7 @@ public class LayerShapeVisualizerViewModel : ActivatableViewModelBase, IVisualiz get => _layerBounds; private set => RaiseAndSetIfChanged(ref _layerBounds, value); } - + public double X { get => _x; diff --git a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/LayerVisualizerView.axaml b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/LayerVisualizerView.axaml index b5cc6011c..f5040de54 100644 --- a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/LayerVisualizerView.axaml +++ b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Visualizers/LayerVisualizerView.axaml @@ -9,10 +9,19 @@ ClipToBounds="False"> Layer; public bool Selected => _selected?.Value ?? false; public Rect LayerBounds @@ -43,7 +44,7 @@ public class LayerVisualizerViewModel : ActivatableViewModelBase, IVisualizerVie get => _layerBounds; private set => RaiseAndSetIfChanged(ref _layerBounds, value); } - + public double X { get => _x; diff --git a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorTitleBarView.axaml b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorTitleBarView.axaml index 62afce2c8..38c5c633d 100644 --- a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorTitleBarView.axaml +++ b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorTitleBarView.axaml @@ -10,8 +10,8 @@ - - diff --git a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorView.axaml b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorView.axaml index 68803a6db..17cd88467 100644 --- a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorView.axaml +++ b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorView.axaml @@ -38,9 +38,6 @@ - @@ -52,7 +49,6 @@ - diff --git a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs index a28bf40de..bba6fe5c9 100644 --- a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs +++ b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs @@ -3,85 +3,75 @@ using System.Collections.ObjectModel; using System.Reactive.Disposables; using Artemis.Core; using Artemis.Core.Services; -using Artemis.UI.Screens.ProfileEditor.MenuBar; using Artemis.UI.Screens.ProfileEditor.ProfileTree; using Artemis.UI.Screens.ProfileEditor.Properties; using Artemis.UI.Screens.ProfileEditor.StatusBar; using Artemis.UI.Screens.ProfileEditor.VisualEditor; -using Artemis.UI.Screens.ProfileEditor.VisualEditor.Visualizers; using Artemis.UI.Shared.Services.ProfileEditor; using DynamicData; using DynamicData.Binding; -using Ninject; using ReactiveUI; -namespace Artemis.UI.Screens.ProfileEditor +namespace Artemis.UI.Screens.ProfileEditor; + +public class ProfileEditorViewModel : MainScreenViewModel { - public class ProfileEditorViewModel : MainScreenViewModel + private readonly ISettingsService _settingsService; + private ObservableAsPropertyHelper? _history; + private ObservableAsPropertyHelper? _profileConfiguration; + private ReadOnlyObservableCollection? _tools; + + /// + public ProfileEditorViewModel(IScreen hostScreen, + IProfileEditorService profileEditorService, + ISettingsService settingsService, + VisualEditorViewModel visualEditorViewModel, + ProfileTreeViewModel profileTreeViewModel, + ProfileEditorTitleBarViewModel profileEditorTitleBarViewModel, + PropertiesViewModel propertiesViewModel, + StatusBarViewModel statusBarViewModel) + : base(hostScreen, "profile-editor") { - private readonly ISettingsService _settingsService; - private ObservableAsPropertyHelper? _profileConfiguration; - private ObservableAsPropertyHelper? _history; - private ReadOnlyObservableCollection _tools; + _settingsService = settingsService; + VisualEditorViewModel = visualEditorViewModel; + ProfileTreeViewModel = profileTreeViewModel; + PropertiesViewModel = propertiesViewModel; + StatusBarViewModel = statusBarViewModel; + TitleBarViewModel = profileEditorTitleBarViewModel; - /// - public ProfileEditorViewModel(IScreen hostScreen, - IProfileEditorService profileEditorService, - ISettingsService settingsService, - VisualEditorViewModel visualEditorViewModel, - ProfileTreeViewModel profileTreeViewModel, - ProfileEditorTitleBarViewModel profileEditorTitleBarViewModel, - MenuBarViewModel menuBarViewModel, - PropertiesViewModel propertiesViewModel, - StatusBarViewModel statusBarViewModel) - : base(hostScreen, "profile-editor") + this.WhenActivated(d => { - _settingsService = settingsService; - VisualEditorViewModel = visualEditorViewModel; - ProfileTreeViewModel = profileTreeViewModel; - PropertiesViewModel = propertiesViewModel; - StatusBarViewModel = statusBarViewModel; + _profileConfiguration = profileEditorService.ProfileConfiguration.ToProperty(this, vm => vm.ProfileConfiguration).DisposeWith(d); + _history = profileEditorService.History.ToProperty(this, vm => vm.History).DisposeWith(d); + profileEditorService.Tools.Connect() + .Filter(t => t.ShowInToolbar) + .Sort(SortExpressionComparer.Ascending(vm => vm.Order)) + .Bind(out ReadOnlyObservableCollection tools) + .Subscribe() + .DisposeWith(d); + Tools = tools; + }); + } - if (OperatingSystem.IsWindows()) - TitleBarViewModel = profileEditorTitleBarViewModel; - else - MenuBarViewModel = menuBarViewModel; + public VisualEditorViewModel VisualEditorViewModel { get; } + public ProfileTreeViewModel ProfileTreeViewModel { get; } + public PropertiesViewModel PropertiesViewModel { get; } + public StatusBarViewModel StatusBarViewModel { get; } - this.WhenActivated(d => - { - _profileConfiguration = profileEditorService.ProfileConfiguration.ToProperty(this, vm => vm.ProfileConfiguration).DisposeWith(d); - _history = profileEditorService.History.ToProperty(this, vm => vm.History).DisposeWith(d); - profileEditorService.Tools.Connect() - .Filter(t => t.ShowInToolbar) - .Sort(SortExpressionComparer.Ascending(vm => vm.Order)) - .Bind(out ReadOnlyObservableCollection tools) - .Subscribe() - .DisposeWith(d); - Tools = tools; - }); - } + public ReadOnlyObservableCollection? Tools + { + get => _tools; + set => RaiseAndSetIfChanged(ref _tools, value); + } - public VisualEditorViewModel VisualEditorViewModel { get; } - public ProfileTreeViewModel ProfileTreeViewModel { get; } - public MenuBarViewModel? MenuBarViewModel { get; } - public PropertiesViewModel PropertiesViewModel { get; } - public StatusBarViewModel StatusBarViewModel { get; } + public ProfileConfiguration? ProfileConfiguration => _profileConfiguration?.Value; + public ProfileEditorHistory? History => _history?.Value; + public PluginSetting TreeWidth => _settingsService.GetSetting("ProfileEditor.TreeWidth", 350.0); + public PluginSetting ConditionsHeight => _settingsService.GetSetting("ProfileEditor.ConditionsHeight", 300.0); + public PluginSetting PropertiesHeight => _settingsService.GetSetting("ProfileEditor.PropertiesHeight", 300.0); - public ReadOnlyObservableCollection Tools - { - get => _tools; - set => RaiseAndSetIfChanged(ref _tools, value); - } - - public ProfileConfiguration? ProfileConfiguration => _profileConfiguration?.Value; - public ProfileEditorHistory? History => _history?.Value; - public PluginSetting TreeWidth => _settingsService.GetSetting("ProfileEditor.TreeWidth", 350.0); - public PluginSetting ConditionsHeight => _settingsService.GetSetting("ProfileEditor.ConditionsHeight", 300.0); - public PluginSetting PropertiesHeight => _settingsService.GetSetting("ProfileEditor.PropertiesHeight", 300.0); - - public void OpenUrl(string url) - { - Utilities.OpenUrl(url); - } + public void OpenUrl(string url) + { + Utilities.OpenUrl(url); } } \ No newline at end of file diff --git a/src/Avalonia/Artemis.UI/Screens/Root/DefaultTitleBarView.axaml b/src/Avalonia/Artemis.UI/Screens/Root/DefaultTitleBarView.axaml index 3c98dac8b..1bfa0720c 100644 --- a/src/Avalonia/Artemis.UI/Screens/Root/DefaultTitleBarView.axaml +++ b/src/Avalonia/Artemis.UI/Screens/Root/DefaultTitleBarView.axaml @@ -5,7 +5,7 @@ xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Artemis.UI.Screens.Root.DefaultTitleBarView"> - \ No newline at end of file diff --git a/src/Avalonia/Artemis.UI/Screens/Root/RootView.axaml b/src/Avalonia/Artemis.UI/Screens/Root/RootView.axaml index 991a035dd..c3fcadfac 100644 --- a/src/Avalonia/Artemis.UI/Screens/Root/RootView.axaml +++ b/src/Avalonia/Artemis.UI/Screens/Root/RootView.axaml @@ -5,17 +5,9 @@ xmlns:reactiveUi="http://reactiveui.net" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Artemis.UI.Screens.Root.RootView"> - - - - - - - - - - - - - + + + + + \ No newline at end of file diff --git a/src/Avalonia/Artemis.UI/Styles/Artemis.axaml b/src/Avalonia/Artemis.UI/Styles/Artemis.axaml index de19a9df5..1adb77b24 100644 --- a/src/Avalonia/Artemis.UI/Styles/Artemis.axaml +++ b/src/Avalonia/Artemis.UI/Styles/Artemis.axaml @@ -9,7 +9,7 @@ - + diff --git a/src/Avalonia/Artemis.UI/packages.lock.json b/src/Avalonia/Artemis.UI/packages.lock.json index 7e0c573de..2f3bb876c 100644 --- a/src/Avalonia/Artemis.UI/packages.lock.json +++ b/src/Avalonia/Artemis.UI/packages.lock.json @@ -85,13 +85,15 @@ }, "FluentAvaloniaUI": { "type": "Direct", - "requested": "[1.1.8, )", - "resolved": "1.1.8", - "contentHash": "pWxi0zvl4+602rffgZgRIS2srUr/bKFCH/duiV72UodmMp291vaWLC3Lzbp3j5TzSuPHYAlcUBIFvEMlnu8WLQ==", + "requested": "[1.2.1, )", + "resolved": "1.2.1", + "contentHash": "IH9eei7CrOUkUdxL2E/HZYKFgNupSVO+ju74CnVqmV7u7iolyz3g1cTHELqVgatEb+IqXw7KyeLr2459nUxYSw==", "dependencies": { - "Avalonia": "0.10.11", - "Avalonia.Desktop": "0.10.11", - "Avalonia.Diagnostics": "0.10.11" + "Avalonia": "0.10.12", + "Avalonia.Desktop": "0.10.12", + "Avalonia.Diagnostics": "0.10.12", + "MicroCom.CodeGenerator.MSBuild": "0.10.4", + "MicroCom.Runtime": "0.10.4" } }, "Flurl.Http": { @@ -387,6 +389,16 @@ "Microsoft.Extensions.DependencyModel": "5.0.0" } }, + "MicroCom.CodeGenerator.MSBuild": { + "type": "Transitive", + "resolved": "0.10.4", + "contentHash": "aG1kLtkgX6lC8qpxVon4OFSCdWYEbQubIg+2/ychWTIFTrDHWFkhcC4YTn0IfGiVCLwh0Yj7eSc8nk5f3UoMKg==" + }, + "MicroCom.Runtime": { + "type": "Transitive", + "resolved": "0.10.4", + "contentHash": "enc2U+/1UnF3rtocxb5ofcg7cJSmJI4adbYPr8DZa5bQzvhqA/VbjlcalxoqjI3CR2RvM5WWpjKT0p3BriFJjw==" + }, "Microsoft.CodeAnalysis.Analyzers": { "type": "Transitive", "resolved": "2.9.6", @@ -1764,7 +1776,7 @@ "Avalonia.Xaml.Interactions": "0.10.12", "Avalonia.Xaml.Interactivity": "0.10.12", "DynamicData": "7.4.9", - "FluentAvaloniaUI": "1.1.8", + "FluentAvaloniaUI": "1.2.1", "Material.Icons.Avalonia": "1.0.2", "RGB.NET.Core": "1.0.0-prerelease7", "ReactiveUI": "17.1.17",