Code style - Use file scoped namespaces

Code style - Ran code cleanup
This commit is contained in:
Robert committed 2022-08-21 11:36:15 +02:00
1 parent e68e16df4d
commit f6090dc296
691 files changed
+37301 -38119

No files matched your search

@@ -1,5 +1,4 @@
using System;
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading.Tasks;
@@ -10,7 +9,6 @@ using Artemis.UI.Ninject.Factories;
using Artemis.UI.Screens.VisualScripting;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Services;
using Artemis.UI.Shared.Services.NodeEditor;
using Artemis.UI.Shared.Services.ProfileEditor;
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
using Avalonia.Threading;
@@ -20,9 +18,9 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.DataBinding;
public class DataBindingViewModel : ActivatableViewModelBase
{
private readonly PluginSetting<bool> _alwaysApplyDataBindings;
private readonly IProfileEditorService _profileEditorService;
private readonly IWindowService _windowService;
private readonly PluginSetting<bool> _alwaysApplyDataBindings;
private ObservableAsPropertyHelper<bool>? _dataBindingEnabled;
private ObservableAsPropertyHelper<ILayerProperty?>? _layerProperty;
private ObservableAsPropertyHelper<NodeScriptViewModel?>? _nodeScriptViewModel;
@@ -1,11 +1,9 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Dialogs;
public partial class TimelineSegmentEditView : ReactiveUserControl<TimelineSegmentEditViewModel>
public class TimelineSegmentEditView : ReactiveUserControl<TimelineSegmentEditViewModel>
{
public TimelineSegmentEditView()
{
@@ -5,16 +5,10 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Dialogs;
public class TimelineSegmentEditViewModel : ContentDialogViewModelBase
{
private double _segmentLength;
public TimelineSegmentEditViewModel(TimeSpan segmentLength)
{
SegmentLength = segmentLength.TotalSeconds;
}
public double SegmentLength
{
get => _segmentLength;
set => _segmentLength = value;
}
public double SegmentLength { get; set; }
}
@@ -37,7 +37,7 @@ public class PropertyGroupViewModel : PropertyViewModelBase, IDisposable
LayerPropertyGroup.VisibilityChanged += LayerPropertyGroupOnVisibilityChanged;
_isVisible = !LayerPropertyGroup.IsHidden;
PopulateChildren();
}
@@ -52,7 +52,7 @@ public class PropertyGroupViewModel : PropertyViewModelBase, IDisposable
LayerPropertyGroup.VisibilityChanged += LayerPropertyGroupOnVisibilityChanged;
_isVisible = !LayerPropertyGroup.IsHidden;
PopulateChildren();
}
@@ -67,7 +67,7 @@ public class PropertyGroupViewModel : PropertyViewModelBase, IDisposable
LayerPropertyGroup.VisibilityChanged += LayerPropertyGroupOnVisibilityChanged;
_isVisible = !LayerPropertyGroup.IsHidden;
PopulateChildren();
}
@@ -115,7 +115,7 @@ public class PropertyGroupViewModel : PropertyViewModelBase, IDisposable
return result;
}
public List<ITimelineKeyframeViewModel> GetAllKeyframeViewModels(bool expandedOnly)
{
List<ITimelineKeyframeViewModel> result = new();
@@ -184,7 +184,7 @@ public class PropertyGroupViewModel : PropertyViewModelBase, IDisposable
if (viewModelBase is IDisposable disposable)
disposable.Dispose();
}
_keyframeSubscription.Dispose();
}
}
@@ -4,17 +4,16 @@ using Artemis.Core;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Screens.ProfileEditor.Properties.Timeline;
using Artemis.UI.Screens.ProfileEditor.Properties.Tree;
using Artemis.UI.Shared;
using DynamicData;
namespace Artemis.UI.Screens.ProfileEditor.Properties;
public class PropertyViewModel : PropertyViewModelBase, IDisposable
{
private readonly SourceList<ILayerPropertyKeyframe> _keyframes;
private bool _isExpanded;
private bool _isHighlighted;
private bool _isVisible;
private readonly SourceList<ILayerPropertyKeyframe> _keyframes;
public PropertyViewModel(ILayerProperty layerProperty, IPropertyVmFactory propertyVmFactory)
{
@@ -3,7 +3,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:timeline="clr-namespace:Artemis.UI.Screens.ProfileEditor.Properties.Timeline"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Keyframes.TimelineKeyframeView"
ClipToBounds="False">
@@ -24,11 +24,11 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Keyframes;
public class TimelineKeyframeViewModel<T> : ActivatableViewModelBase, ITimelineKeyframeViewModel
{
private readonly IProfileEditorService _profileEditorService;
private bool _canPaste;
private bool _isFlyoutOpen;
private ObservableAsPropertyHelper<bool>? _isSelected;
private string _timestamp;
private double _x;
private bool _canPaste;
private bool _isFlyoutOpen;
public TimelineKeyframeViewModel(LayerPropertyKeyframe<T> layerPropertyKeyframe, IProfileEditorService profileEditorService)
{
@@ -58,10 +58,6 @@ public class TimelineKeyframeViewModel<T> : ActivatableViewModelBase, ITimelineK
public LayerPropertyKeyframe<T> LayerPropertyKeyframe { get; }
public ObservableCollection<TimelineEasingViewModel> EasingViewModels { get; }
public ReactiveCommand<Unit, Unit> Duplicate { get; }
public ReactiveCommand<Unit, Unit> Copy { get; }
public ReactiveCommand<Unit, Unit> Paste { get; }
public ReactiveCommand<Unit, Unit> Delete { get; }
public double X
{
@@ -93,6 +89,11 @@ public class TimelineKeyframeViewModel<T> : ActivatableViewModelBase, ITimelineK
Timestamp = $"{Math.Floor(LayerPropertyKeyframe.Position.TotalSeconds):00}.{LayerPropertyKeyframe.Position.Milliseconds:000}";
}
public ReactiveCommand<Unit, Unit> Duplicate { get; }
public ReactiveCommand<Unit, Unit> Copy { get; }
public ReactiveCommand<Unit, Unit> Paste { get; }
public ReactiveCommand<Unit, Unit> Delete { get; }
public bool IsSelected => _isSelected?.Value ?? false;
public TimeSpan Position => LayerPropertyKeyframe.Position;
public ILayerPropertyKeyframe Keyframe => LayerPropertyKeyframe;
@@ -19,16 +19,16 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments;
public abstract class TimelineSegmentViewModel : ActivatableViewModelBase
{
private static readonly TimeSpan NewSegmentLength = TimeSpan.FromSeconds(2);
private readonly Dictionary<ILayerPropertyKeyframe, TimeSpan> _originalKeyframePositions = new();
private readonly IProfileEditorService _profileEditorService;
private readonly IWindowService _windowService;
private TimeSpan _initialLength;
private readonly Dictionary<ILayerPropertyKeyframe, TimeSpan> _originalKeyframePositions = new();
private int _pixelsPerSecond;
private RenderProfileElement? _profileElement;
private ReactiveCommand<Unit, Unit>? _removeSegment;
private ObservableAsPropertyHelper<bool>? _showAddEnd;
private ObservableAsPropertyHelper<bool>? _showAddMain;
private ObservableAsPropertyHelper<bool>? _showAddStart;
private ReactiveCommand<Unit, Unit>? _removeSegment;
protected TimelineSegmentViewModel(IProfileEditorService profileEditorService, IWindowService windowService)
{
@@ -62,28 +62,22 @@ public abstract class TimelineSegmentViewModel : ActivatableViewModelBase
.DisposeWith(d);
if (Type == ResizeTimelineSegment.SegmentType.Start)
{
RemoveSegment = ReactiveCommand.Create(
ExecuteRemoveSegment,
this.WhenAnyValue(vm => vm.ShowAddMain).CombineLatest(this.WhenAnyValue(vm => vm.ShowAddEnd)).Select(tuple => !tuple.First || !tuple.Second)
);
}
if (Type == ResizeTimelineSegment.SegmentType.Main)
{
RemoveSegment = ReactiveCommand.Create(
ExecuteRemoveSegment,
this.WhenAnyValue(vm => vm.ShowAddEnd).CombineLatest(this.WhenAnyValue(vm => vm.ShowAddStart)).Select(tuple => !tuple.First || !tuple.Second)
);
}
if (Type == ResizeTimelineSegment.SegmentType.End)
{
RemoveSegment = ReactiveCommand.Create(
ExecuteRemoveSegment,
this.WhenAnyValue(vm => vm.ShowAddStart).CombineLatest(this.WhenAnyValue(vm => vm.ShowAddMain)).Select(tuple => !tuple.First || !tuple.Second)
);
}
});
}
@@ -167,12 +161,44 @@ public abstract class TimelineSegmentViewModel : ActivatableViewModelBase
TimeSpan time = TimeSpan.FromMilliseconds(Math.Max(GetTimeFromX(x, snap, round).TotalMilliseconds, 100));
if (_initialLength == time)
return;
using ProfileEditorCommandScope scope = _profileEditorService.CreateCommandScope("Resize segment");
ApplyPendingKeyframeMovement();
_profileEditorService.ExecuteCommand(new ResizeTimelineSegment(Type, _profileElement, time, _initialLength));
}
protected TimeSpan GetTimeFromX(double x, bool snap, bool round)
{
TimeSpan time = TimeSpan.FromSeconds(x / _pixelsPerSecond);
if (time < TimeSpan.Zero)
time = TimeSpan.Zero;
if (round)
time = _profileEditorService.RoundTime(time);
if (snap)
time = SnapToTimeline(time);
return time;
}
protected void ShiftKeyframes(IEnumerable<ILayerPropertyKeyframe> keyframes, TimeSpan amount)
{
foreach (ILayerPropertyKeyframe layerPropertyKeyframe in keyframes)
{
if (!_originalKeyframePositions.ContainsKey(layerPropertyKeyframe))
_originalKeyframePositions[layerPropertyKeyframe] = layerPropertyKeyframe.Position;
layerPropertyKeyframe.Position = layerPropertyKeyframe.Position.Add(amount);
}
}
protected void ApplyPendingKeyframeMovement()
{
foreach ((ILayerPropertyKeyframe keyframe, TimeSpan originalPosition) in _originalKeyframePositions)
_profileEditorService.ExecuteCommand(new MoveKeyframe(keyframe, keyframe.Position, originalPosition));
_originalKeyframePositions.Clear();
}
private void ExecuteRemoveSegment()
{
if (_profileElement == null)
@@ -210,38 +236,6 @@ public abstract class TimelineSegmentViewModel : ActivatableViewModelBase
.ShowAsync();
}
protected TimeSpan GetTimeFromX(double x, bool snap, bool round)
{
TimeSpan time = TimeSpan.FromSeconds(x / _pixelsPerSecond);
if (time < TimeSpan.Zero)
time = TimeSpan.Zero;
if (round)
time = _profileEditorService.RoundTime(time);
if (snap)
time = SnapToTimeline(time);
return time;
}
protected void ShiftKeyframes(IEnumerable<ILayerPropertyKeyframe> keyframes, TimeSpan amount)
{
foreach (ILayerPropertyKeyframe layerPropertyKeyframe in keyframes)
{
if (!_originalKeyframePositions.ContainsKey(layerPropertyKeyframe))
_originalKeyframePositions[layerPropertyKeyframe] = layerPropertyKeyframe.Position;
layerPropertyKeyframe.Position = layerPropertyKeyframe.Position.Add(amount);
}
}
protected void ApplyPendingKeyframeMovement()
{
foreach ((ILayerPropertyKeyframe keyframe, TimeSpan originalPosition) in _originalKeyframePositions)
_profileEditorService.ExecuteCommand(new MoveKeyframe(keyframe, keyframe.Position, originalPosition));
_originalKeyframePositions.Clear();
}
private TimeSpan SnapToTimeline(TimeSpan time)
{
TimeSpan tolerance = TimeSpan.FromMilliseconds(1000f / _pixelsPerSecond * 5);
@@ -15,8 +15,8 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline;
public class TimelinePropertyViewModel<T> : ActivatableViewModelBase, ITimelinePropertyViewModel
{
private readonly IProfileEditorService _profileEditorService;
private readonly SourceList<LayerPropertyKeyframe<T>> _keyframes;
private readonly IProfileEditorService _profileEditorService;
private ObservableAsPropertyHelper<bool>? _keyframesEnabled;
public TimelinePropertyViewModel(LayerProperty<T> layerProperty, PropertyViewModel propertyViewModel, IProfileEditorService profileEditorService)
@@ -1,13 +1,12 @@
using Artemis.Core.LayerBrushes;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree.Dialogs;
public partial class LayerBrushPresetView : ReactiveUserControl<LayerBrushPresetViewModel>
public class LayerBrushPresetView : ReactiveUserControl<LayerBrushPresetViewModel>
{
public LayerBrushPresetView()
{
@@ -1,13 +1,8 @@
using System;
using System.Collections.ObjectModel;
using System.Reactive.Linq;
using Artemis.Core;
using Artemis.Core.LayerBrushes;
using Artemis.Core.LayerEffects;
using Artemis.Core.Services;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Services.ProfileEditor;
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
using DynamicData;
using ReactiveUI;
@@ -48,7 +43,7 @@ public class LayerBrushPresetViewModel : ContentDialogViewModelBase
preset.Apply();
ContentDialog?.Hide();
}
private Func<ILayerBrushPreset, bool> CreatePredicate(string? search)
{
if (string.IsNullOrWhiteSpace(search))
@@ -8,7 +8,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Windows;
public class BrushConfigurationWindowView : ReactiveCoreWindow<BrushConfigurationWindowViewModel>
{
private bool _canClose;
public BrushConfigurationWindowView()
{
InitializeComponent();
@@ -27,7 +27,7 @@ public class BrushConfigurationWindowView : ReactiveCoreWindow<BrushConfiguratio
{
if (_canClose)
return;
e.Cancel = true;
if (ViewModel == null || await ViewModel.CanClose())
{
@@ -27,7 +27,7 @@ public class EffectConfigurationWindowView : ReactiveCoreWindow<EffectConfigurat
{
if (_canClose)
return;
e.Cancel = true;
if (ViewModel == null || await ViewModel.CanClose())
{