diff --git a/src/Artemis.UI.Shared/Services/NodeEditor/NodeEditorService.cs b/src/Artemis.UI.Shared/Services/NodeEditor/NodeEditorService.cs
index 1cbf3e3e2..1fe15dc8f 100644
--- a/src/Artemis.UI.Shared/Services/NodeEditor/NodeEditorService.cs
+++ b/src/Artemis.UI.Shared/Services/NodeEditor/NodeEditorService.cs
@@ -10,6 +10,9 @@ public class NodeEditorService : INodeEditorService
{
private readonly IWindowService _windowService;
+ ///
+ /// Creates a new instance of the class.
+ ///
public NodeEditorService(IWindowService windowService)
{
_windowService = windowService;
diff --git a/src/Artemis.UI.Shared/Services/PropertyInput/IPropertyInputService.cs b/src/Artemis.UI.Shared/Services/PropertyInput/IPropertyInputService.cs
index fc965b2ed..3691bf9ce 100644
--- a/src/Artemis.UI.Shared/Services/PropertyInput/IPropertyInputService.cs
+++ b/src/Artemis.UI.Shared/Services/PropertyInput/IPropertyInputService.cs
@@ -4,6 +4,9 @@ using Artemis.Core;
namespace Artemis.UI.Shared.Services.PropertyInput;
+///
+/// Represents a service that can be used to register property editors.
+///
public interface IPropertyInputService : IArtemisSharedUIService
{
///
diff --git a/src/Artemis.UI/Converters/PropertyTreeMarginConverter.cs b/src/Artemis.UI/Converters/PropertyTreeMarginConverter.cs
index d1a290b01..aa7cfc232 100644
--- a/src/Artemis.UI/Converters/PropertyTreeMarginConverter.cs
+++ b/src/Artemis.UI/Converters/PropertyTreeMarginConverter.cs
@@ -10,7 +10,7 @@ public class PropertyTreeMarginConverter : IValueConverter
{
public double Length { get; set; }
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is TreeGroupViewModel treeGroupViewModel)
return new Thickness(Length * treeGroupViewModel.GetDepth(), 0, 0, 0);
@@ -20,7 +20,7 @@ public class PropertyTreeMarginConverter : IValueConverter
return new Thickness(0);
}
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputViewModel.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputViewModel.cs
index fbde8d7a9..f14e50b7b 100644
--- a/src/Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputViewModel.cs
+++ b/src/Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputViewModel.cs
@@ -8,7 +8,7 @@ namespace Artemis.UI.DefaultTypes.PropertyInput;
public class ColorGradientPropertyInputViewModel : PropertyInputViewModel
{
- private ColorGradient _colorGradient;
+ private ColorGradient _colorGradient = null!;
private ColorGradient? _originalGradient;
public ColorGradientPropertyInputViewModel(LayerProperty layerProperty, IProfileEditorService profileEditorService, IPropertyInputService propertyInputService)
diff --git a/src/Artemis.UI/Screens/Device/Tabs/DevicePropertiesTabViewModel.cs b/src/Artemis.UI/Screens/Device/Tabs/DevicePropertiesTabViewModel.cs
index 6f8a3e781..af45e942d 100644
--- a/src/Artemis.UI/Screens/Device/Tabs/DevicePropertiesTabViewModel.cs
+++ b/src/Artemis.UI/Screens/Device/Tabs/DevicePropertiesTabViewModel.cs
@@ -203,10 +203,10 @@ namespace Artemis.UI.Screens.Device
public async Task SelectPhysicalLayout()
{
- // await _windowService.CreateContentDialog()
- // .WithTitle("Select layout")
- // .WithViewModel(("device", Device))
- // .ShowAsync();
+ await _windowService.CreateContentDialog()
+ .WithTitle("Select layout")
+ .WithViewModel(("device", Device))
+ .ShowAsync();
}
public async Task Apply()
diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/ProfileTreeView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/ProfileTreeView.axaml.cs
index 02069da6b..e3e353083 100644
--- a/src/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/ProfileTreeView.axaml.cs
+++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/ProfileTreeView.axaml.cs
@@ -23,6 +23,8 @@ public class ProfileTreeView : ReactiveUserControl
public ProfileTreeView()
{
InitializeComponent();
+ _treeView = this.Get("ProfileTreeView");
+
AddHandler(DragDrop.DragEnterEvent, HandleDragEnterEvent, RoutingStrategies.Direct | RoutingStrategies.Tunnel | RoutingStrategies.Bubble, true);
AddHandler(DragDrop.DragOverEvent, HandleDragOver, RoutingStrategies.Direct | RoutingStrategies.Tunnel | RoutingStrategies.Bubble, true);
AddHandler(PointerEnterEvent, HandlePointerEnter, RoutingStrategies.Direct | RoutingStrategies.Tunnel | RoutingStrategies.Bubble, true);
@@ -116,7 +118,6 @@ public class ProfileTreeView : ReactiveUserControl
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
- _treeView = this.Get("ProfileTreeView");
}
private void ProfileTreeView_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/Segments/EndSegmentViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/Segments/EndSegmentViewModel.cs
index 16817896d..ab48333a6 100644
--- a/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/Segments/EndSegmentViewModel.cs
+++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/Segments/EndSegmentViewModel.cs
@@ -10,25 +10,17 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments;
public class EndSegmentViewModel : TimelineSegmentViewModel
{
- private readonly IProfileEditorService _profileEditorService;
private readonly ObservableAsPropertyHelper _width;
private ObservableAsPropertyHelper? _end;
private ObservableAsPropertyHelper? _endTimestamp;
- private TimeSpan _initialLength;
- private int _pixelsPerSecond;
private RenderProfileElement? _profileElement;
private ObservableAsPropertyHelper? _start;
- private TimeSpan _time;
-
public EndSegmentViewModel(IProfileEditorService profileEditorService) : base(profileEditorService)
{
- _profileEditorService = profileEditorService;
this.WhenActivated(d =>
{
profileEditorService.ProfileElement.Subscribe(p => _profileElement = p).DisposeWith(d);
- profileEditorService.Time.Subscribe(t => _time = t).DisposeWith(d);
- profileEditorService.PixelsPerSecond.Subscribe(p => _pixelsPerSecond = p).DisposeWith(d);
_start = profileEditorService.ProfileElement
.Select(p => p?.WhenAnyValue(element => element.Timeline.EndSegmentStartPosition) ?? Observable.Never())
diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/Segments/StartSegmentViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/Segments/StartSegmentViewModel.cs
index 58329f454..92f283ce4 100644
--- a/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/Segments/StartSegmentViewModel.cs
+++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/Segments/StartSegmentViewModel.cs
@@ -10,23 +10,16 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments;
public class StartSegmentViewModel : TimelineSegmentViewModel
{
- private readonly IProfileEditorService _profileEditorService;
private readonly ObservableAsPropertyHelper _width;
private ObservableAsPropertyHelper? _end;
private ObservableAsPropertyHelper? _endTimestamp;
- private TimeSpan _initialLength;
- private int _pixelsPerSecond;
private RenderProfileElement? _profileElement;
- private TimeSpan _time;
public StartSegmentViewModel(IProfileEditorService profileEditorService) : base(profileEditorService)
{
- _profileEditorService = profileEditorService;
this.WhenActivated(d =>
{
profileEditorService.ProfileElement.Subscribe(p => _profileElement = p).DisposeWith(d);
- profileEditorService.Time.Subscribe(t => _time = t).DisposeWith(d);
- profileEditorService.PixelsPerSecond.Subscribe(p => _pixelsPerSecond = p).DisposeWith(d);
_end = profileEditorService.ProfileElement
.Select(p => p?.WhenAnyValue(element => element.Timeline.StartSegmentEndPosition) ?? Observable.Never())
diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/TimelineViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/TimelineViewModel.cs
index 2e9b24cb9..cc7e0dd4d 100644
--- a/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/TimelineViewModel.cs
+++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/TimelineViewModel.cs
@@ -23,7 +23,7 @@ public class TimelineViewModel : ActivatableViewModelBase
{
private readonly IProfileEditorService _profileEditorService;
private ObservableAsPropertyHelper? _caretPosition;
- private ObservableAsPropertyHelper _minWidth;
+ private ObservableAsPropertyHelper? _minWidth;
private List? _moveKeyframes;
private ObservableAsPropertyHelper? _pixelsPerSecond;
private RenderProfileElement? _profileElement;
diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Tools/TransformToolView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Tools/TransformToolView.axaml.cs
index 29c7ed68e..26bf273cc 100644
--- a/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Tools/TransformToolView.axaml.cs
+++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/Tools/TransformToolView.axaml.cs
@@ -192,7 +192,8 @@ public class TransformToolView : ReactiveUserControl
SKPoint position = e.GetCurrentPoint(this).Position.ToSKPoint() - _dragOffset;
ViewModel.UpdateMovement(position, e.KeyModifiers.HasFlag(KeyModifiers.Shift), e.KeyModifiers.HasFlag(KeyModifiers.Control));
- ToolTip.SetTip((Control) sender, $"X: {ViewModel.Layer.Transform.Position.CurrentValue.X:F3}% Y: {ViewModel.Layer.Transform.Position.CurrentValue.Y:F3}%");
+ if (sender is Control control)
+ ToolTip.SetTip(control, $"X: {ViewModel.Layer.Transform.Position.CurrentValue.X:F3}% Y: {ViewModel.Layer.Transform.Position.CurrentValue.Y:F3}%");
e.Handled = true;
}
@@ -236,7 +237,8 @@ public class TransformToolView : ReactiveUserControl
SKPoint position = e.GetCurrentPoint(this).Position.ToSKPoint() - _dragOffset;
ViewModel.UpdateAnchorMovement(position, e.KeyModifiers.HasFlag(KeyModifiers.Shift), e.KeyModifiers.HasFlag(KeyModifiers.Control));
- ToolTip.SetTip((Control) sender, $"X: {ViewModel.Layer.Transform.AnchorPoint.CurrentValue.X:F3}% Y: {ViewModel.Layer.Transform.AnchorPoint.CurrentValue.Y:F3}%");
+ if (sender is Control control)
+ ToolTip.SetTip(control, $"X: {ViewModel.Layer.Transform.AnchorPoint.CurrentValue.X:F3}% Y: {ViewModel.Layer.Transform.AnchorPoint.CurrentValue.Y:F3}%");
e.Handled = true;
}
@@ -366,7 +368,7 @@ public class TransformToolView : ReactiveUserControl
private void RotationOnPointerMoved(object? sender, PointerEventArgs e)
{
- if (sender == null || !ReferenceEquals(e.Pointer.Captured, sender) || !e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
+ if (sender == null || ViewModel == null || !ReferenceEquals(e.Pointer.Captured, sender) || !e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
return;
float angle = CalculateAngleToAnchor(e);
@@ -374,8 +376,8 @@ public class TransformToolView : ReactiveUserControl
if (angle < 0)
angle += 360;
- ViewModel?.UpdateRotation(angle, e.KeyModifiers.HasFlag(KeyModifiers.Control));
- ToolTip.SetTip((Control) sender, $"{ViewModel.Layer.Transform.Rotation.CurrentValue:F3}°");
+ ViewModel.UpdateRotation(angle, e.KeyModifiers.HasFlag(KeyModifiers.Control));
+ ToolTip.SetTip((Control) sender, $"{ViewModel.Layer?.Transform.Rotation.CurrentValue:F3}°");
e.Handled = true;
}
diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorViewModel.cs
index 02ac561f2..bf6747f8f 100644
--- a/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorViewModel.cs
+++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorViewModel.cs
@@ -23,7 +23,7 @@ public class VisualEditorViewModel : ActivatableViewModelBase
private readonly IProfileEditorVmFactory _vmFactory;
private ObservableAsPropertyHelper? _profileConfiguration;
private ObservableAsPropertyHelper? _suspendedEditing;
- private ReadOnlyObservableCollection _tools;
+ private ReadOnlyObservableCollection? _tools;
public VisualEditorViewModel(IProfileEditorService profileEditorService, IRgbService rgbService, IProfileEditorVmFactory vmFactory)
{
@@ -77,7 +77,7 @@ public class VisualEditorViewModel : ActivatableViewModelBase
public ObservableCollection Devices { get; }
public ReadOnlyObservableCollection Visualizers { get; }
- public ReadOnlyObservableCollection Tools
+ public ReadOnlyObservableCollection? Tools
{
get => _tools;
set => RaiseAndSetIfChanged(ref _tools, value);
diff --git a/src/Artemis.UI/Screens/Settings/Tabs/GeneralTabViewModel.cs b/src/Artemis.UI/Screens/Settings/Tabs/GeneralTabViewModel.cs
index e4bf4e961..998c825d3 100644
--- a/src/Artemis.UI/Screens/Settings/Tabs/GeneralTabViewModel.cs
+++ b/src/Artemis.UI/Screens/Settings/Tabs/GeneralTabViewModel.cs
@@ -32,7 +32,7 @@ namespace Artemis.UI.Screens.Settings
DisplayName = "General";
_settingsService = settingsService;
_debugService = debugService;
- _fluentAvaloniaTheme = AvaloniaLocator.Current.GetService();
+ _fluentAvaloniaTheme = AvaloniaLocator.Current.GetService() ?? throw new Exception($"Could not get required service of type {nameof(FluentAvaloniaTheme)}.");
List layerBrushProviders = pluginManagementService.GetFeaturesOfType();
LayerBrushDescriptors = new ObservableCollection(layerBrushProviders.SelectMany(l => l.LayerBrushDescriptors));
diff --git a/src/Artemis.UI/Screens/Settings/Tabs/PluginsTabViewModel.cs b/src/Artemis.UI/Screens/Settings/Tabs/PluginsTabViewModel.cs
index d1916013b..1be16315b 100644
--- a/src/Artemis.UI/Screens/Settings/Tabs/PluginsTabViewModel.cs
+++ b/src/Artemis.UI/Screens/Settings/Tabs/PluginsTabViewModel.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reactive;
@@ -25,9 +24,7 @@ namespace Artemis.UI.Screens.Settings
{
private readonly INotificationService _notificationService;
private readonly IPluginManagementService _pluginManagementService;
- private readonly ISettingsVmFactory _settingsVmFactory;
private readonly IWindowService _windowService;
- private List? _instances;
private string? _searchPluginInput;
public PluginsTabViewModel(IPluginManagementService pluginManagementService, INotificationService notificationService, IWindowService windowService, ISettingsVmFactory settingsVmFactory)
@@ -35,7 +32,6 @@ namespace Artemis.UI.Screens.Settings
_pluginManagementService = pluginManagementService;
_notificationService = notificationService;
_windowService = windowService;
- _settingsVmFactory = settingsVmFactory;
DisplayName = "Plugins";
@@ -45,7 +41,7 @@ namespace Artemis.UI.Screens.Settings
plugins.Connect()
.Filter(pluginFilter)
.Sort(SortExpressionComparer.Ascending(p => p.Info.Name))
- .TransformAsync(p => Dispatcher.UIThread.InvokeAsync(() => _settingsVmFactory.CreatePluginSettingsViewModel(p), DispatcherPriority.Background))
+ .TransformAsync(p => Dispatcher.UIThread.InvokeAsync(() => settingsVmFactory.CreatePluginSettingsViewModel(p), DispatcherPriority.Background))
.Bind(out ReadOnlyObservableCollection pluginViewModels)
.Subscribe();
Plugins = pluginViewModels;
diff --git a/src/Artemis.UI/Screens/VisualScripting/NodeScriptView.axaml.cs b/src/Artemis.UI/Screens/VisualScripting/NodeScriptView.axaml.cs
index f87985bc2..93cb3608e 100644
--- a/src/Artemis.UI/Screens/VisualScripting/NodeScriptView.axaml.cs
+++ b/src/Artemis.UI/Screens/VisualScripting/NodeScriptView.axaml.cs
@@ -45,8 +45,8 @@ public class NodeScriptView : ReactiveUserControl
_zoomBorder.AddHandler(PointerWheelChangedEvent, ZoomOnPointerWheelChanged, RoutingStrategies.Direct | RoutingStrategies.Tunnel | RoutingStrategies.Bubble, true);
this.WhenActivated(d =>
{
- ViewModel.AutoFitRequested += ViewModelOnAutoFitRequested;
- ViewModel!.PickerPositionSubject.Subscribe(ShowPickerAt).DisposeWith(d);
+ ViewModel!.AutoFitRequested += ViewModelOnAutoFitRequested;
+ ViewModel.PickerPositionSubject.Subscribe(ShowPickerAt).DisposeWith(d);
if (ViewModel.IsPreview)
{
BoundsProperty.Changed.Subscribe(BoundsPropertyChanged).DisposeWith(d);
diff --git a/src/Artemis.VisualScripting/Ninject/NoStringNinjectModule.cs b/src/Artemis.VisualScripting/Ninject/NoStringNinjectModule.cs
index 3bf75bd56..b6178101a 100644
--- a/src/Artemis.VisualScripting/Ninject/NoStringNinjectModule.cs
+++ b/src/Artemis.VisualScripting/Ninject/NoStringNinjectModule.cs
@@ -45,7 +45,9 @@ namespace Artemis.VisualScripting.Ninject
private void InjectUserDefinedFunctions()
{
- IFunctionReader functionReader = (IFunctionReader) Kernel!.GetService(typeof(IFunctionReader));
+ IFunctionReader? functionReader = (IFunctionReader?) Kernel?.GetService(typeof(IFunctionReader));
+ if (functionReader == null)
+ throw new Exception($"Could not get service of type {nameof(IFunctionReader)}.");
NoStringFunctionsInitializer.InitializeFunctions(functionReader, typeof(NoStringNinjectModule));
}
}
diff --git a/src/Artemis.VisualScripting/Nodes/Conversion/ConvertToNumericNode.cs b/src/Artemis.VisualScripting/Nodes/Conversion/ConvertToNumericNode.cs
index a68349843..b82a85f1f 100644
--- a/src/Artemis.VisualScripting/Nodes/Conversion/ConvertToNumericNode.cs
+++ b/src/Artemis.VisualScripting/Nodes/Conversion/ConvertToNumericNode.cs
@@ -38,7 +38,7 @@ public class ConvertToNumericNode : Node
};
}
- private Numeric TryParse(object input)
+ private Numeric TryParse(object? input)
{
Numeric.TryParse(input?.ToString(), out Numeric value);
return value;
diff --git a/src/Artemis.VisualScripting/Nodes/Mathematics/PinsVariablesContainer.cs b/src/Artemis.VisualScripting/Nodes/Mathematics/PinsVariablesContainer.cs
index ecfe903e7..6faf28044 100644
--- a/src/Artemis.VisualScripting/Nodes/Mathematics/PinsVariablesContainer.cs
+++ b/src/Artemis.VisualScripting/Nodes/Mathematics/PinsVariablesContainer.cs
@@ -24,7 +24,7 @@ public class PinsVariablesContainer : IVariablesContainer
///
public EvaluatorValue GetValue(string name)
{
- IPin pin = _values.FirstOrDefault(v => v.Name == name);
+ IPin? pin = _values.FirstOrDefault(v => v.Name == name);
if (pin?.PinValue is Numeric numeric)
return new EvaluatorValue(numeric);
return new EvaluatorValue(0);
@@ -33,7 +33,7 @@ public class PinsVariablesContainer : IVariablesContainer
///
public bool TryGetValue(string name, out EvaluatorValue value)
{
- IPin pin = _values.FirstOrDefault(v => v.Name == name);
+ IPin? pin = _values.FirstOrDefault(v => v.Name == name);
if (pin?.PinValue is Numeric numeric)
{
value = new EvaluatorValue(numeric);