1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Yeah I can't remember looks like I fixed a bunch of warnings

This commit is contained in:
Robert 2022-07-02 14:01:27 +02:00
parent 65837e671a
commit a735568c8f
17 changed files with 35 additions and 43 deletions

View File

@ -10,6 +10,9 @@ public class NodeEditorService : INodeEditorService
{ {
private readonly IWindowService _windowService; private readonly IWindowService _windowService;
/// <summary>
/// Creates a new instance of the <see cref="NodeEditorService"/> class.
/// </summary>
public NodeEditorService(IWindowService windowService) public NodeEditorService(IWindowService windowService)
{ {
_windowService = windowService; _windowService = windowService;

View File

@ -4,6 +4,9 @@ using Artemis.Core;
namespace Artemis.UI.Shared.Services.PropertyInput; namespace Artemis.UI.Shared.Services.PropertyInput;
/// <summary>
/// Represents a service that can be used to register property editors.
/// </summary>
public interface IPropertyInputService : IArtemisSharedUIService public interface IPropertyInputService : IArtemisSharedUIService
{ {
/// <summary> /// <summary>

View File

@ -10,7 +10,7 @@ public class PropertyTreeMarginConverter : IValueConverter
{ {
public double Length { get; set; } 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) if (value is TreeGroupViewModel treeGroupViewModel)
return new Thickness(Length * treeGroupViewModel.GetDepth(), 0, 0, 0); return new Thickness(Length * treeGroupViewModel.GetDepth(), 0, 0, 0);
@ -20,7 +20,7 @@ public class PropertyTreeMarginConverter : IValueConverter
return new Thickness(0); 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(); throw new NotImplementedException();
} }

View File

@ -8,7 +8,7 @@ namespace Artemis.UI.DefaultTypes.PropertyInput;
public class ColorGradientPropertyInputViewModel : PropertyInputViewModel<ColorGradient> public class ColorGradientPropertyInputViewModel : PropertyInputViewModel<ColorGradient>
{ {
private ColorGradient _colorGradient; private ColorGradient _colorGradient = null!;
private ColorGradient? _originalGradient; private ColorGradient? _originalGradient;
public ColorGradientPropertyInputViewModel(LayerProperty<ColorGradient> layerProperty, IProfileEditorService profileEditorService, IPropertyInputService propertyInputService) public ColorGradientPropertyInputViewModel(LayerProperty<ColorGradient> layerProperty, IProfileEditorService profileEditorService, IPropertyInputService propertyInputService)

View File

@ -203,10 +203,10 @@ namespace Artemis.UI.Screens.Device
public async Task SelectPhysicalLayout() public async Task SelectPhysicalLayout()
{ {
// await _windowService.CreateContentDialog() await _windowService.CreateContentDialog()
// .WithTitle("Select layout") .WithTitle("Select layout")
// .WithViewModel<DeviceLayoutDialogViewModel>(("device", Device)) .WithViewModel<DeviceLayoutDialogViewModel>(("device", Device))
// .ShowAsync(); .ShowAsync();
} }
public async Task Apply() public async Task Apply()

View File

@ -23,6 +23,8 @@ public class ProfileTreeView : ReactiveUserControl<ProfileTreeViewModel>
public ProfileTreeView() public ProfileTreeView()
{ {
InitializeComponent(); InitializeComponent();
_treeView = this.Get<TreeView>("ProfileTreeView");
AddHandler(DragDrop.DragEnterEvent, HandleDragEnterEvent, RoutingStrategies.Direct | RoutingStrategies.Tunnel | RoutingStrategies.Bubble, true); AddHandler(DragDrop.DragEnterEvent, HandleDragEnterEvent, RoutingStrategies.Direct | RoutingStrategies.Tunnel | RoutingStrategies.Bubble, true);
AddHandler(DragDrop.DragOverEvent, HandleDragOver, 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); AddHandler(PointerEnterEvent, HandlePointerEnter, RoutingStrategies.Direct | RoutingStrategies.Tunnel | RoutingStrategies.Bubble, true);
@ -116,7 +118,6 @@ public class ProfileTreeView : ReactiveUserControl<ProfileTreeViewModel>
private void InitializeComponent() private void InitializeComponent()
{ {
AvaloniaXamlLoader.Load(this); AvaloniaXamlLoader.Load(this);
_treeView = this.Get<TreeView>("ProfileTreeView");
} }
private void ProfileTreeView_OnSelectionChanged(object? sender, SelectionChangedEventArgs e) private void ProfileTreeView_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)

View File

@ -10,25 +10,17 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments;
public class EndSegmentViewModel : TimelineSegmentViewModel public class EndSegmentViewModel : TimelineSegmentViewModel
{ {
private readonly IProfileEditorService _profileEditorService;
private readonly ObservableAsPropertyHelper<double> _width; private readonly ObservableAsPropertyHelper<double> _width;
private ObservableAsPropertyHelper<double>? _end; private ObservableAsPropertyHelper<double>? _end;
private ObservableAsPropertyHelper<string?>? _endTimestamp; private ObservableAsPropertyHelper<string?>? _endTimestamp;
private TimeSpan _initialLength;
private int _pixelsPerSecond;
private RenderProfileElement? _profileElement; private RenderProfileElement? _profileElement;
private ObservableAsPropertyHelper<double>? _start; private ObservableAsPropertyHelper<double>? _start;
private TimeSpan _time;
public EndSegmentViewModel(IProfileEditorService profileEditorService) : base(profileEditorService) public EndSegmentViewModel(IProfileEditorService profileEditorService) : base(profileEditorService)
{ {
_profileEditorService = profileEditorService;
this.WhenActivated(d => this.WhenActivated(d =>
{ {
profileEditorService.ProfileElement.Subscribe(p => _profileElement = p).DisposeWith(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 _start = profileEditorService.ProfileElement
.Select(p => p?.WhenAnyValue(element => element.Timeline.EndSegmentStartPosition) ?? Observable.Never<TimeSpan>()) .Select(p => p?.WhenAnyValue(element => element.Timeline.EndSegmentStartPosition) ?? Observable.Never<TimeSpan>())

View File

@ -10,23 +10,16 @@ namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments;
public class StartSegmentViewModel : TimelineSegmentViewModel public class StartSegmentViewModel : TimelineSegmentViewModel
{ {
private readonly IProfileEditorService _profileEditorService;
private readonly ObservableAsPropertyHelper<double> _width; private readonly ObservableAsPropertyHelper<double> _width;
private ObservableAsPropertyHelper<double>? _end; private ObservableAsPropertyHelper<double>? _end;
private ObservableAsPropertyHelper<string?>? _endTimestamp; private ObservableAsPropertyHelper<string?>? _endTimestamp;
private TimeSpan _initialLength;
private int _pixelsPerSecond;
private RenderProfileElement? _profileElement; private RenderProfileElement? _profileElement;
private TimeSpan _time;
public StartSegmentViewModel(IProfileEditorService profileEditorService) : base(profileEditorService) public StartSegmentViewModel(IProfileEditorService profileEditorService) : base(profileEditorService)
{ {
_profileEditorService = profileEditorService;
this.WhenActivated(d => this.WhenActivated(d =>
{ {
profileEditorService.ProfileElement.Subscribe(p => _profileElement = p).DisposeWith(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 _end = profileEditorService.ProfileElement
.Select(p => p?.WhenAnyValue(element => element.Timeline.StartSegmentEndPosition) ?? Observable.Never<TimeSpan>()) .Select(p => p?.WhenAnyValue(element => element.Timeline.StartSegmentEndPosition) ?? Observable.Never<TimeSpan>())

View File

@ -23,7 +23,7 @@ public class TimelineViewModel : ActivatableViewModelBase
{ {
private readonly IProfileEditorService _profileEditorService; private readonly IProfileEditorService _profileEditorService;
private ObservableAsPropertyHelper<double>? _caretPosition; private ObservableAsPropertyHelper<double>? _caretPosition;
private ObservableAsPropertyHelper<double> _minWidth; private ObservableAsPropertyHelper<double>? _minWidth;
private List<ITimelineKeyframeViewModel>? _moveKeyframes; private List<ITimelineKeyframeViewModel>? _moveKeyframes;
private ObservableAsPropertyHelper<int>? _pixelsPerSecond; private ObservableAsPropertyHelper<int>? _pixelsPerSecond;
private RenderProfileElement? _profileElement; private RenderProfileElement? _profileElement;

View File

@ -192,7 +192,8 @@ public class TransformToolView : ReactiveUserControl<TransformToolViewModel>
SKPoint position = e.GetCurrentPoint(this).Position.ToSKPoint() - _dragOffset; SKPoint position = e.GetCurrentPoint(this).Position.ToSKPoint() - _dragOffset;
ViewModel.UpdateMovement(position, e.KeyModifiers.HasFlag(KeyModifiers.Shift), e.KeyModifiers.HasFlag(KeyModifiers.Control)); 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; e.Handled = true;
} }
@ -236,7 +237,8 @@ public class TransformToolView : ReactiveUserControl<TransformToolViewModel>
SKPoint position = e.GetCurrentPoint(this).Position.ToSKPoint() - _dragOffset; SKPoint position = e.GetCurrentPoint(this).Position.ToSKPoint() - _dragOffset;
ViewModel.UpdateAnchorMovement(position, e.KeyModifiers.HasFlag(KeyModifiers.Shift), e.KeyModifiers.HasFlag(KeyModifiers.Control)); 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; e.Handled = true;
} }
@ -366,7 +368,7 @@ public class TransformToolView : ReactiveUserControl<TransformToolViewModel>
private void RotationOnPointerMoved(object? sender, PointerEventArgs e) 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; return;
float angle = CalculateAngleToAnchor(e); float angle = CalculateAngleToAnchor(e);
@ -374,8 +376,8 @@ public class TransformToolView : ReactiveUserControl<TransformToolViewModel>
if (angle < 0) if (angle < 0)
angle += 360; angle += 360;
ViewModel?.UpdateRotation(angle, e.KeyModifiers.HasFlag(KeyModifiers.Control)); ViewModel.UpdateRotation(angle, e.KeyModifiers.HasFlag(KeyModifiers.Control));
ToolTip.SetTip((Control) sender, $"{ViewModel.Layer.Transform.Rotation.CurrentValue:F3}°"); ToolTip.SetTip((Control) sender, $"{ViewModel.Layer?.Transform.Rotation.CurrentValue:F3}°");
e.Handled = true; e.Handled = true;
} }

View File

@ -23,7 +23,7 @@ public class VisualEditorViewModel : ActivatableViewModelBase
private readonly IProfileEditorVmFactory _vmFactory; private readonly IProfileEditorVmFactory _vmFactory;
private ObservableAsPropertyHelper<ProfileConfiguration?>? _profileConfiguration; private ObservableAsPropertyHelper<ProfileConfiguration?>? _profileConfiguration;
private ObservableAsPropertyHelper<bool>? _suspendedEditing; private ObservableAsPropertyHelper<bool>? _suspendedEditing;
private ReadOnlyObservableCollection<IToolViewModel> _tools; private ReadOnlyObservableCollection<IToolViewModel>? _tools;
public VisualEditorViewModel(IProfileEditorService profileEditorService, IRgbService rgbService, IProfileEditorVmFactory vmFactory) public VisualEditorViewModel(IProfileEditorService profileEditorService, IRgbService rgbService, IProfileEditorVmFactory vmFactory)
{ {
@ -77,7 +77,7 @@ public class VisualEditorViewModel : ActivatableViewModelBase
public ObservableCollection<ArtemisDevice> Devices { get; } public ObservableCollection<ArtemisDevice> Devices { get; }
public ReadOnlyObservableCollection<IVisualizerViewModel> Visualizers { get; } public ReadOnlyObservableCollection<IVisualizerViewModel> Visualizers { get; }
public ReadOnlyObservableCollection<IToolViewModel> Tools public ReadOnlyObservableCollection<IToolViewModel>? Tools
{ {
get => _tools; get => _tools;
set => RaiseAndSetIfChanged(ref _tools, value); set => RaiseAndSetIfChanged(ref _tools, value);

View File

@ -32,7 +32,7 @@ namespace Artemis.UI.Screens.Settings
DisplayName = "General"; DisplayName = "General";
_settingsService = settingsService; _settingsService = settingsService;
_debugService = debugService; _debugService = debugService;
_fluentAvaloniaTheme = AvaloniaLocator.Current.GetService<FluentAvaloniaTheme>(); _fluentAvaloniaTheme = AvaloniaLocator.Current.GetService<FluentAvaloniaTheme>() ?? throw new Exception($"Could not get required service of type {nameof(FluentAvaloniaTheme)}.");
List<LayerBrushProvider> layerBrushProviders = pluginManagementService.GetFeaturesOfType<LayerBrushProvider>(); List<LayerBrushProvider> layerBrushProviders = pluginManagementService.GetFeaturesOfType<LayerBrushProvider>();
LayerBrushDescriptors = new ObservableCollection<LayerBrushDescriptor>(layerBrushProviders.SelectMany(l => l.LayerBrushDescriptors)); LayerBrushDescriptors = new ObservableCollection<LayerBrushDescriptor>(layerBrushProviders.SelectMany(l => l.LayerBrushDescriptors));

View File

@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Reactive; using System.Reactive;
@ -25,9 +24,7 @@ namespace Artemis.UI.Screens.Settings
{ {
private readonly INotificationService _notificationService; private readonly INotificationService _notificationService;
private readonly IPluginManagementService _pluginManagementService; private readonly IPluginManagementService _pluginManagementService;
private readonly ISettingsVmFactory _settingsVmFactory;
private readonly IWindowService _windowService; private readonly IWindowService _windowService;
private List<PluginSettingsViewModel>? _instances;
private string? _searchPluginInput; private string? _searchPluginInput;
public PluginsTabViewModel(IPluginManagementService pluginManagementService, INotificationService notificationService, IWindowService windowService, ISettingsVmFactory settingsVmFactory) public PluginsTabViewModel(IPluginManagementService pluginManagementService, INotificationService notificationService, IWindowService windowService, ISettingsVmFactory settingsVmFactory)
@ -35,7 +32,6 @@ namespace Artemis.UI.Screens.Settings
_pluginManagementService = pluginManagementService; _pluginManagementService = pluginManagementService;
_notificationService = notificationService; _notificationService = notificationService;
_windowService = windowService; _windowService = windowService;
_settingsVmFactory = settingsVmFactory;
DisplayName = "Plugins"; DisplayName = "Plugins";
@ -45,7 +41,7 @@ namespace Artemis.UI.Screens.Settings
plugins.Connect() plugins.Connect()
.Filter(pluginFilter) .Filter(pluginFilter)
.Sort(SortExpressionComparer<Plugin>.Ascending(p => p.Info.Name)) .Sort(SortExpressionComparer<Plugin>.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<PluginSettingsViewModel> pluginViewModels) .Bind(out ReadOnlyObservableCollection<PluginSettingsViewModel> pluginViewModels)
.Subscribe(); .Subscribe();
Plugins = pluginViewModels; Plugins = pluginViewModels;

View File

@ -45,8 +45,8 @@ public class NodeScriptView : ReactiveUserControl<NodeScriptViewModel>
_zoomBorder.AddHandler(PointerWheelChangedEvent, ZoomOnPointerWheelChanged, RoutingStrategies.Direct | RoutingStrategies.Tunnel | RoutingStrategies.Bubble, true); _zoomBorder.AddHandler(PointerWheelChangedEvent, ZoomOnPointerWheelChanged, RoutingStrategies.Direct | RoutingStrategies.Tunnel | RoutingStrategies.Bubble, true);
this.WhenActivated(d => this.WhenActivated(d =>
{ {
ViewModel.AutoFitRequested += ViewModelOnAutoFitRequested; ViewModel!.AutoFitRequested += ViewModelOnAutoFitRequested;
ViewModel!.PickerPositionSubject.Subscribe(ShowPickerAt).DisposeWith(d); ViewModel.PickerPositionSubject.Subscribe(ShowPickerAt).DisposeWith(d);
if (ViewModel.IsPreview) if (ViewModel.IsPreview)
{ {
BoundsProperty.Changed.Subscribe(BoundsPropertyChanged).DisposeWith(d); BoundsProperty.Changed.Subscribe(BoundsPropertyChanged).DisposeWith(d);

View File

@ -45,7 +45,9 @@ namespace Artemis.VisualScripting.Ninject
private void InjectUserDefinedFunctions() 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)); NoStringFunctionsInitializer.InitializeFunctions(functionReader, typeof(NoStringNinjectModule));
} }
} }

View File

@ -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); Numeric.TryParse(input?.ToString(), out Numeric value);
return value; return value;

View File

@ -24,7 +24,7 @@ public class PinsVariablesContainer : IVariablesContainer
/// <inheritdoc /> /// <inheritdoc />
public EvaluatorValue GetValue(string name) 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) if (pin?.PinValue is Numeric numeric)
return new EvaluatorValue(numeric); return new EvaluatorValue(numeric);
return new EvaluatorValue(0); return new EvaluatorValue(0);
@ -33,7 +33,7 @@ public class PinsVariablesContainer : IVariablesContainer
/// <inheritdoc /> /// <inheritdoc />
public bool TryGetValue(string name, out EvaluatorValue value) 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) if (pin?.PinValue is Numeric numeric)
{ {
value = new EvaluatorValue(numeric); value = new EvaluatorValue(numeric);