From ae64db8a1388bb012a1d83788122c62c3fb9846c Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Mon, 5 Oct 2020 22:50:29 +0200 Subject: [PATCH] Darthified code --- .../StringContainsConditionOperator.cs | 4 +- .../StringEndsWithConditionOperator.cs | 4 +- .../StringEqualsConditionOperator.cs | 4 +- .../StringNotContainsConditionOperator.cs | 4 +- .../StringNotEqualConditionOperator.cs | 4 +- .../StringStartsWithConditionOperator.cs | 4 +- .../Converters/FloatDataBindingConverter.cs | 2 +- .../Converters/IntDataBindingConverter.cs | 2 +- .../Colors/SKColorBrightenModifierType.cs | 2 +- .../Colors/SKColorDarkenModifierType.cs | 2 +- .../Modifiers/Numbers/DivideModifierType.cs | 2 +- .../Numbers/PercentageOfModifierType.cs | 2 +- .../Numbers/Rounding/CeilingModifierType.cs | 2 +- .../Numbers/Rounding/FloorModifierType.cs | 2 +- .../Numbers/Rounding/RoundModifierType.cs | 2 +- .../Properties/FloatLayerProperty.cs | 2 +- .../Properties/IntLayerProperty.cs | 2 +- .../Properties/SKPointLayerProperty.cs | 4 +- .../Properties/SKSizeLayerProperty.cs | 4 +- .../Extensions/DirectoryInfoExtensions.cs | 10 +- .../Extensions/IEnumerableExtensions.cs | 4 +- .../Extensions/ProcessExtensions.cs | 6 +- .../Extensions/RgbDeviceExtensions.cs | 2 +- .../Extensions/SKColorExtensions.cs | 8 +- src/Artemis.Core/Extensions/TypeExtensions.cs | 2 +- .../Models/Profile/Colors/ColorGradient.cs | 32 ++-- .../Conditions/DataModelConditionGroup.cs | 6 +- .../Conditions/DataModelConditionList.cs | 21 +-- .../DataModelConditionListPredicate.cs | 57 +++---- .../Conditions/DataModelConditionPredicate.cs | 32 ++-- .../Profile/DataBindings/DataBinding.cs | 10 +- .../DataBindings/DataBindingConverter.cs | 32 ++-- .../DataBindings/DataBindingRegistration.cs | 3 +- .../Modes/ConditionalDataBinding.cs | 14 +- .../DataBindings/Modes/DataBindingModifier.cs | 22 +-- .../DataBindings/Modes/DirectDataBinding.cs | 30 ++-- .../Profile/DataModel/DataModelPathSegment.cs | 18 +-- src/Artemis.Core/Models/Profile/Folder.cs | 54 +++---- src/Artemis.Core/Models/Profile/Layer.cs | 150 +++++++++--------- .../Profile/LayerProperties/LayerProperty.cs | 28 ++-- .../Models/Profile/LayerPropertyGroup.cs | 32 ++-- .../Profile/LayerShapes/EllipseShape.cs | 2 +- .../Profile/LayerShapes/RectangleShape.cs | 2 +- src/Artemis.Core/Models/Profile/Profile.cs | 18 +-- .../Models/Profile/ProfileElement.cs | 12 +- .../Models/Profile/RenderProfileElement.cs | 36 ++--- .../Models/Surface/ArtemisDevice.cs | 6 +- .../Models/Surface/ArtemisSurface.cs | 4 +- src/Artemis.Core/Ninject/LoggerProvider.cs | 5 +- .../Ninject/PluginSettingsProvider.cs | 4 +- .../Ninject/SettingsServiceProvider.cs | 2 +- .../Plugins/DataModelExpansions/DataModel.cs | 36 ++--- .../DataModelExpansions/DataModelExpansion.cs | 5 +- .../Plugins/DeviceProviders/DeviceProvider.cs | 2 +- .../LayerBrushes/LayerBrushDescriptor.cs | 2 +- .../LayerBrushes/LayerBrushProvider.cs | 2 +- .../Plugins/LayerBrushes/PerLedLayerBrush.cs | 18 +-- .../Plugins/LayerBrushes/RgbNetLayerBrush.cs | 5 +- .../LayerEffects/LayerEffectDescriptor.cs | 4 +- .../LayerEffects/LayerEffectProvider.cs | 2 +- .../PlaceholderLayerEffectDescriptor.cs | 2 +- .../ProcessActivationRequirement.cs | 5 +- .../Plugins/Modules/ProfileModule.cs | 6 +- src/Artemis.Core/Plugins/Plugin.cs | 2 +- .../Plugins/PluginUpdateRegistration.cs | 2 +- .../Plugins/Settings/PluginSettings.cs | 4 +- src/Artemis.Core/RGB.NET/BitmapBrush.cs | 42 ++--- src/Artemis.Core/Services/CoreService.cs | 14 +- src/Artemis.Core/Services/DeviceService.cs | 2 +- src/Artemis.Core/Services/ModuleService.cs | 30 ++-- src/Artemis.Core/Services/PluginService.cs | 38 ++--- .../Services/Registration/DataModelService.cs | 4 +- .../Registration/LayerBrushService.cs | 2 +- src/Artemis.Core/Services/RgbService.cs | 2 +- .../Services/Storage/ProfileService.cs | 48 +++--- .../Services/Storage/SurfaceService.cs | 43 ++--- .../Stores/ConditionOperatorStore.cs | 8 +- .../Stores/DataBindingModifierTypeStore.cs | 8 +- .../Utilities/CurrentProcessUtilities.cs | 4 +- src/Artemis.Core/Utilities/Easings.cs | 18 +-- .../Utilities/ExpressionUtilities.cs | 4 +- src/Artemis.Core/Utilities/IntroAnimation.cs | 8 +- .../Utilities/ReflectionUtilities.cs | 6 +- .../Entities/Profile/ProfileEntity.cs | 4 +- .../M2ProfileEntitiesEnabledMigration.cs | 15 +- .../Migrations/M4ProfileSegments.cs | 9 +- .../Migrations/M5DataBindingTypes.cs | 12 +- .../StorageMigrationService.cs | 2 +- src/Artemis.UI.Shared/Bootstrapper.cs | 2 +- .../Controls/ColorPicker.xaml.cs | 10 +- .../Controls/DeviceVisualizer.cs | 40 ++--- .../Controls/DeviceVisualizerLed.cs | 10 +- .../Controls/DraggableFloat.xaml.cs | 18 +-- .../Controls/GradientPicker.xaml.cs | 2 +- .../ColorGradientToGradientStopsConverter.cs | 12 +- .../Converters/ColorToSKColorConverter.cs | 4 +- .../Converters/ColorToSolidColorConverter.cs | 2 +- .../Converters/ColorToStringConverter.cs | 2 +- .../Converters/SKColorToStringConverter.cs | 2 +- .../DataModelInputViewModel.cs | 2 +- .../DataModelListPropertiesViewModel.cs | 2 +- .../Shared/DataModelListViewModel.cs | 14 +- .../Shared/DataModelPropertiesViewModel.cs | 2 +- .../Shared/DataModelVisualizationViewModel.cs | 37 ++--- .../DependencyProperties/SizeObserver.cs | 2 +- .../Screens/Exceptions/ExceptionViewModel.cs | 2 +- .../GradientEditor/ColorStopViewModel.cs | 15 +- .../GradientEditor/GradientEditorViewModel.cs | 16 +- .../Services/ColorPickerService.cs | 2 +- .../Services/DataModelUIService.cs | 38 ++--- .../Services/Dialog/DialogService.cs | 15 +- .../Services/Dialog/DialogViewModelHost.cs | 5 +- .../Services/ProfileEditorService.cs | 30 ++-- .../Utilities/EnumUtilities.cs | 4 +- .../Utilities/HitTestUtilities.cs | 8 +- .../Utilities/ShortcutUtilities.cs | 2 +- .../Utilities/TriggerTracing.cs | 20 +-- .../Utilities/VisualTreeUtilities.cs | 8 +- .../Behaviors/InputBindingBehavior.cs | 14 +- src/Artemis.UI/Behaviors/MouseBehavior.cs | 6 +- .../Behaviors/TreeViewSelectionBehavior.cs | 16 +- src/Artemis.UI/Bootstrapper.cs | 12 +- .../Converters/EnumToCollectionConverter.cs | 4 +- .../ComboBoxTemplateSelector.cs | 4 +- .../Input/DoubleDataModelInputViewModel.cs | 4 +- .../Input/IntDataModelInputViewModel.cs | 2 +- .../BrushPropertyInputViewModel.cs | 2 +- .../BindableCollectionExtensions.cs | 7 +- .../Extensions/RgbColorExtensions.cs | 2 +- .../Extensions/TreeViewItemExtensions.cs | 5 +- .../DataBindingsViewModelInstanceProvider.cs | 2 +- .../LayerPropertyViewModelInstanceProvider.cs | 2 +- .../Screens/Modules/ModuleRootViewModel.cs | 10 +- .../DataModelConditionGroupViewModel.cs | 11 +- ...ataModelConditionListPredicateViewModel.cs | 12 +- .../DataModelConditionListViewModel.cs | 13 +- .../DataModelConditionPredicateViewModel.cs | 6 +- .../Dialogs/ProfileExportViewModel.cs | 2 +- .../Dialogs/ProfileImportViewModel.cs | 5 +- .../ProfileEditor/Dialogs/RenameView.xaml.cs | 2 +- .../ConditionalDataBindingModeViewModel.cs | 17 +- .../DataBindings/DataBindingViewModel.cs | 2 +- .../DataBindings/DataBindingsViewModel.cs | 8 +- .../DataBindingModifierViewModel.cs | 13 +- .../DirectDataBindingModeViewModel.cs | 13 +- .../LayerEffects/EffectsViewModel.cs | 11 +- .../LayerPropertiesViewModel.cs | 67 ++++---- .../LayerPropertyGroupViewModel.cs | 21 +-- .../Controls/PropertyTimelineHeader.cs | 32 ++-- .../Dialogs/TimelineSegmentDialogViewModel.cs | 2 +- .../Timeline/TimelineEasingViewModel.cs | 6 +- .../Timeline/TimelineKeyframeViewModel.cs | 10 +- .../Timeline/TimelinePropertyViewModel.cs | 16 +- .../Timeline/TimelineSegmentViewModel.cs | 22 +-- .../Timeline/TimelineViewModel.cs | 58 +++---- .../Tree/TreeGroupViewModel.cs | 31 ++-- .../Tree/TreePropertyViewModel.cs | 4 +- .../LayerProperties/Tree/TreeViewModel.cs | 4 +- .../ProfileEditor/ProfileEditorViewModel.cs | 32 ++-- .../ProfileTree/ProfileTreeViewModel.cs | 18 +-- .../ProfileTree/TreeItem/TreeItemViewModel.cs | 38 ++--- .../Visualization/ProfileLayerViewModel.cs | 12 +- .../Visualization/ProfileViewModel.cs | 14 +- .../Visualization/Tools/EditToolViewModel.cs | 88 +++++----- .../Tools/SelectionRemoveToolViewModel.cs | 19 +-- .../Tools/SelectionToolViewModel.cs | 18 +-- .../Tools/VisualizationToolViewModel.cs | 2 +- .../UserControls/LayerShapeControl.xaml.cs | 16 +- src/Artemis.UI/Screens/RootViewModel.cs | 14 +- .../Debug/Tabs/RenderDebugViewModel.cs | 6 +- .../Devices/DeviceSettingsTabViewModel.cs | 7 +- .../General/GeneralSettingsTabViewModel.cs | 10 +- .../Tabs/Modules/ModuleOrderTabViewModel.cs | 8 +- .../Plugins/PluginSettingsTabViewModel.cs | 7 +- .../Tabs/Plugins/PluginSettingsViewModel.cs | 18 ++- .../Screens/Shared/PanZoomViewModel.cs | 14 +- .../Screens/Sidebar/SidebarViewModel.cs | 12 +- .../SurfaceEditor/SurfaceEditorViewModel.cs | 70 ++++---- .../Visualization/SurfaceDeviceViewModel.cs | 4 +- src/Artemis.UI/Screens/TrayViewModel.cs | 6 +- src/Artemis.UI/Services/DebugService.cs | 2 +- src/Artemis.UI/Services/LayerEditorService.cs | 42 ++--- .../Services/RegistrationService.cs | 2 +- src/Artemis.UI/Stylet/ArtemisViewManager.cs | 2 +- src/Artemis.UI/Stylet/NinjectBootstrapper.cs | 2 +- src/Artemis.UI/Utilities/ThemeWatcher.cs | 14 +- .../DataModels/PluginDataModel.cs | 2 +- .../ViewModels/DMXConfigurationViewModel.cs | 2 +- .../DebugDeviceProvider.cs | 6 +- .../LogitechDeviceProvider.cs | 5 +- .../WS281XDeviceProvider.cs | 4 +- .../ColorBrush.cs | 8 +- .../PropertyGroups/ColorBrushProperties.cs | 2 +- .../RadialGradientProperties.cs | 2 +- .../NoiseBrush.cs | 26 +-- .../Utilities/OpenSimplexNoise.cs | 138 ++++++++-------- .../GeneralModule.cs | 2 +- .../Utilities/WindowUtilities.cs | 4 +- 198 files changed, 1339 insertions(+), 1305 deletions(-) diff --git a/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringContainsConditionOperator.cs b/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringContainsConditionOperator.cs index 23c7e67f0..66df52bd9 100644 --- a/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringContainsConditionOperator.cs +++ b/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringContainsConditionOperator.cs @@ -12,8 +12,8 @@ namespace Artemis.Core.DefaultTypes public override bool Evaluate(object a, object b) { - var aString = (string) a; - var bString = (string) b; + string aString = (string) a; + string bString = (string) b; return bString != null && aString != null && aString.Contains(bString, StringComparison.InvariantCultureIgnoreCase); } diff --git a/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringEndsWithConditionOperator.cs b/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringEndsWithConditionOperator.cs index c193c9651..8041809f4 100644 --- a/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringEndsWithConditionOperator.cs +++ b/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringEndsWithConditionOperator.cs @@ -12,8 +12,8 @@ namespace Artemis.Core.DefaultTypes public override bool Evaluate(object a, object b) { - var aString = (string) a; - var bString = (string) b; + string aString = (string) a; + string bString = (string) b; return bString != null && aString != null && aString.EndsWith(bString, StringComparison.InvariantCultureIgnoreCase); } diff --git a/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringEqualsConditionOperator.cs b/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringEqualsConditionOperator.cs index bea4e56ec..5857ce81f 100644 --- a/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringEqualsConditionOperator.cs +++ b/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringEqualsConditionOperator.cs @@ -12,8 +12,8 @@ namespace Artemis.Core.DefaultTypes public override bool Evaluate(object a, object b) { - var aString = (string) a; - var bString = (string) b; + string aString = (string) a; + string bString = (string) b; return string.Equals(aString, bString, StringComparison.InvariantCultureIgnoreCase); } diff --git a/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringNotContainsConditionOperator.cs b/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringNotContainsConditionOperator.cs index 00337a44b..9b7f45f8f 100644 --- a/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringNotContainsConditionOperator.cs +++ b/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringNotContainsConditionOperator.cs @@ -12,8 +12,8 @@ namespace Artemis.Core.DefaultTypes public override bool Evaluate(object a, object b) { - var aString = (string) a; - var bString = (string) b; + string aString = (string) a; + string bString = (string) b; return bString != null && aString != null && !aString.Contains(bString, StringComparison.InvariantCultureIgnoreCase); } diff --git a/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringNotEqualConditionOperator.cs b/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringNotEqualConditionOperator.cs index 2ce7a1a64..aef95e7e4 100644 --- a/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringNotEqualConditionOperator.cs +++ b/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringNotEqualConditionOperator.cs @@ -12,8 +12,8 @@ namespace Artemis.Core.DefaultTypes public override bool Evaluate(object a, object b) { - var aString = (string) a; - var bString = (string) b; + string aString = (string) a; + string bString = (string) b; return !string.Equals(aString, bString, StringComparison.InvariantCultureIgnoreCase); } diff --git a/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringStartsWithConditionOperator.cs b/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringStartsWithConditionOperator.cs index ebe63bee8..d6f86eba3 100644 --- a/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringStartsWithConditionOperator.cs +++ b/src/Artemis.Core/DefaultTypes/Conditions/Operators/StringStartsWithConditionOperator.cs @@ -12,8 +12,8 @@ namespace Artemis.Core.DefaultTypes public override bool Evaluate(object a, object b) { - var aString = (string) a; - var bString = (string) b; + string aString = (string) a; + string bString = (string) b; return bString != null && aString != null && aString.StartsWith(bString, StringComparison.InvariantCultureIgnoreCase); } diff --git a/src/Artemis.Core/DefaultTypes/DataBindings/Converters/FloatDataBindingConverter.cs b/src/Artemis.Core/DefaultTypes/DataBindings/Converters/FloatDataBindingConverter.cs index 6e458e161..1a4c09f4e 100644 --- a/src/Artemis.Core/DefaultTypes/DataBindings/Converters/FloatDataBindingConverter.cs +++ b/src/Artemis.Core/DefaultTypes/DataBindings/Converters/FloatDataBindingConverter.cs @@ -29,7 +29,7 @@ namespace Artemis.Core.DefaultTypes /// public override float Interpolate(float a, float b, double progress) { - var diff = b - a; + float diff = b - a; return (float) (a + diff * progress); } diff --git a/src/Artemis.Core/DefaultTypes/DataBindings/Converters/IntDataBindingConverter.cs b/src/Artemis.Core/DefaultTypes/DataBindings/Converters/IntDataBindingConverter.cs index b4931f6ed..879d2884f 100644 --- a/src/Artemis.Core/DefaultTypes/DataBindings/Converters/IntDataBindingConverter.cs +++ b/src/Artemis.Core/DefaultTypes/DataBindings/Converters/IntDataBindingConverter.cs @@ -34,7 +34,7 @@ namespace Artemis.Core.DefaultTypes /// public override int Interpolate(int a, int b, double progress) { - var diff = b - a; + int diff = b - a; return (int) Math.Round(a + diff * progress, InterpolationRoundingMode); } } diff --git a/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Colors/SKColorBrightenModifierType.cs b/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Colors/SKColorBrightenModifierType.cs index ccc8bf85d..4c79778e7 100644 --- a/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Colors/SKColorBrightenModifierType.cs +++ b/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Colors/SKColorBrightenModifierType.cs @@ -15,7 +15,7 @@ namespace Artemis.Core.DefaultTypes public override object Apply(object currentValue, object parameterValue) { - ((SKColor) currentValue).ToHsl(out var h, out var s, out var l); + ((SKColor) currentValue).ToHsl(out float h, out float s, out float l); l *= (Convert.ToSingle(parameterValue) + 100f) / 100f; return SKColor.FromHsl(h, s, l); diff --git a/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Colors/SKColorDarkenModifierType.cs b/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Colors/SKColorDarkenModifierType.cs index f7e6d470d..39f427dd6 100644 --- a/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Colors/SKColorDarkenModifierType.cs +++ b/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Colors/SKColorDarkenModifierType.cs @@ -15,7 +15,7 @@ namespace Artemis.Core.DefaultTypes public override object Apply(object currentValue, object parameterValue) { - ((SKColor) currentValue).ToHsl(out var h, out var s, out var l); + ((SKColor) currentValue).ToHsl(out float h, out float s, out float l); l *= (Convert.ToSingle(parameterValue) * -1 + 100f) / 100f; return SKColor.FromHsl(h, s, l); } diff --git a/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/DivideModifierType.cs b/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/DivideModifierType.cs index 480dff707..2bd4d304c 100644 --- a/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/DivideModifierType.cs +++ b/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/DivideModifierType.cs @@ -13,7 +13,7 @@ namespace Artemis.Core.DefaultTypes public override object Apply(object currentValue, object parameterValue) { - var parameter = Convert.ToSingle(parameterValue); + float parameter = Convert.ToSingle(parameterValue); // Ye ye none of that if (parameter == 0) return 0; diff --git a/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/PercentageOfModifierType.cs b/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/PercentageOfModifierType.cs index 6f7ec4bcd..09ba43359 100644 --- a/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/PercentageOfModifierType.cs +++ b/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/PercentageOfModifierType.cs @@ -14,7 +14,7 @@ namespace Artemis.Core.DefaultTypes public override object Apply(object currentValue, object parameterValue) { - var parameter = Convert.ToSingle(parameterValue); + float parameter = Convert.ToSingle(parameterValue); // Ye ye none of that if (parameter == 0f) return 100f; diff --git a/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/Rounding/CeilingModifierType.cs b/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/Rounding/CeilingModifierType.cs index 26d984aa2..a0ec3bd8e 100644 --- a/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/Rounding/CeilingModifierType.cs +++ b/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/Rounding/CeilingModifierType.cs @@ -15,7 +15,7 @@ namespace Artemis.Core.DefaultTypes public override object Apply(object currentValue, object parameterValue) { - var floatValue = Convert.ToSingle(currentValue); + float floatValue = Convert.ToSingle(currentValue); return Math.Ceiling(floatValue); } } diff --git a/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/Rounding/FloorModifierType.cs b/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/Rounding/FloorModifierType.cs index a8a1d4cba..1c61ca9a4 100644 --- a/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/Rounding/FloorModifierType.cs +++ b/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/Rounding/FloorModifierType.cs @@ -15,7 +15,7 @@ namespace Artemis.Core.DefaultTypes public override object Apply(object currentValue, object parameterValue) { - var floatValue = Convert.ToSingle(currentValue); + float floatValue = Convert.ToSingle(currentValue); return Math.Floor(floatValue); } } diff --git a/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/Rounding/RoundModifierType.cs b/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/Rounding/RoundModifierType.cs index 5475e2476..7952718ee 100644 --- a/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/Rounding/RoundModifierType.cs +++ b/src/Artemis.Core/DefaultTypes/DataBindings/Modifiers/Numbers/Rounding/RoundModifierType.cs @@ -15,7 +15,7 @@ namespace Artemis.Core.DefaultTypes public override object Apply(object currentValue, object parameterValue) { - var floatValue = Convert.ToSingle(currentValue); + float floatValue = Convert.ToSingle(currentValue); return Math.Round(floatValue, MidpointRounding.AwayFromZero); } } diff --git a/src/Artemis.Core/DefaultTypes/Properties/FloatLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/FloatLayerProperty.cs index 633d27763..4eb435574 100644 --- a/src/Artemis.Core/DefaultTypes/Properties/FloatLayerProperty.cs +++ b/src/Artemis.Core/DefaultTypes/Properties/FloatLayerProperty.cs @@ -27,7 +27,7 @@ /// protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased) { - var diff = NextKeyframe.Value - CurrentKeyframe.Value; + float diff = NextKeyframe.Value - CurrentKeyframe.Value; CurrentValue = CurrentKeyframe.Value + diff * keyframeProgressEased; } } diff --git a/src/Artemis.Core/DefaultTypes/Properties/IntLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/IntLayerProperty.cs index edb785e29..454f8328c 100644 --- a/src/Artemis.Core/DefaultTypes/Properties/IntLayerProperty.cs +++ b/src/Artemis.Core/DefaultTypes/Properties/IntLayerProperty.cs @@ -37,7 +37,7 @@ namespace Artemis.Core.DefaultTypes /// protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased) { - var diff = NextKeyframe.Value - CurrentKeyframe.Value; + int diff = NextKeyframe.Value - CurrentKeyframe.Value; CurrentValue = (int) Math.Round(CurrentKeyframe.Value + diff * keyframeProgressEased, MidpointRounding.AwayFromZero); } } diff --git a/src/Artemis.Core/DefaultTypes/Properties/SKPointLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/SKPointLayerProperty.cs index f9836d457..312e20749 100644 --- a/src/Artemis.Core/DefaultTypes/Properties/SKPointLayerProperty.cs +++ b/src/Artemis.Core/DefaultTypes/Properties/SKPointLayerProperty.cs @@ -22,8 +22,8 @@ namespace Artemis.Core.DefaultTypes /// protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased) { - var xDiff = NextKeyframe.Value.X - CurrentKeyframe.Value.X; - var yDiff = NextKeyframe.Value.Y - CurrentKeyframe.Value.Y; + float xDiff = NextKeyframe.Value.X - CurrentKeyframe.Value.X; + float yDiff = NextKeyframe.Value.Y - CurrentKeyframe.Value.Y; CurrentValue = new SKPoint(CurrentKeyframe.Value.X + xDiff * keyframeProgressEased, CurrentKeyframe.Value.Y + yDiff * keyframeProgressEased); } } diff --git a/src/Artemis.Core/DefaultTypes/Properties/SKSizeLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/SKSizeLayerProperty.cs index bdfc66688..ef2097c01 100644 --- a/src/Artemis.Core/DefaultTypes/Properties/SKSizeLayerProperty.cs +++ b/src/Artemis.Core/DefaultTypes/Properties/SKSizeLayerProperty.cs @@ -22,8 +22,8 @@ namespace Artemis.Core.DefaultTypes /// protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased) { - var widthDiff = NextKeyframe.Value.Width - CurrentKeyframe.Value.Width; - var heightDiff = NextKeyframe.Value.Height - CurrentKeyframe.Value.Height; + float widthDiff = NextKeyframe.Value.Width - CurrentKeyframe.Value.Width; + float heightDiff = NextKeyframe.Value.Height - CurrentKeyframe.Value.Height; CurrentValue = new SKSize(CurrentKeyframe.Value.Width + widthDiff * keyframeProgressEased, CurrentKeyframe.Value.Height + heightDiff * keyframeProgressEased); } } diff --git a/src/Artemis.Core/Extensions/DirectoryInfoExtensions.cs b/src/Artemis.Core/Extensions/DirectoryInfoExtensions.cs index 164f8ef2e..f1f0a7d68 100644 --- a/src/Artemis.Core/Extensions/DirectoryInfoExtensions.cs +++ b/src/Artemis.Core/Extensions/DirectoryInfoExtensions.cs @@ -6,9 +6,9 @@ namespace Artemis.Core { public static void CopyFilesRecursively(this DirectoryInfo source, DirectoryInfo target) { - foreach (var dir in source.GetDirectories()) + foreach (DirectoryInfo dir in source.GetDirectories()) CopyFilesRecursively(dir, target.CreateSubdirectory(dir.Name)); - foreach (var file in source.GetFiles()) + foreach (FileInfo file in source.GetFiles()) file.CopyTo(Path.Combine(target.FullName, file.Name)); } @@ -17,10 +17,10 @@ namespace Artemis.Core if (!baseDir.Exists) return; - foreach (var dir in baseDir.EnumerateDirectories()) + foreach (DirectoryInfo dir in baseDir.EnumerateDirectories()) DeleteRecursively(dir); - var files = baseDir.GetFiles(); - foreach (var file in files) + FileInfo[] files = baseDir.GetFiles(); + foreach (FileInfo file in files) { file.IsReadOnly = false; file.Delete(); diff --git a/src/Artemis.Core/Extensions/IEnumerableExtensions.cs b/src/Artemis.Core/Extensions/IEnumerableExtensions.cs index 8a33844e5..d0e591363 100644 --- a/src/Artemis.Core/Extensions/IEnumerableExtensions.cs +++ b/src/Artemis.Core/Extensions/IEnumerableExtensions.cs @@ -80,8 +80,8 @@ namespace Artemis.Core IEnumerable _() { - var knownKeys = new HashSet(comparer); - foreach (var element in source) + HashSet knownKeys = new HashSet(comparer); + foreach (TSource element in source) { if (knownKeys.Add(keySelector(element))) yield return element; diff --git a/src/Artemis.Core/Extensions/ProcessExtensions.cs b/src/Artemis.Core/Extensions/ProcessExtensions.cs index ce59cde59..39d1083ee 100644 --- a/src/Artemis.Core/Extensions/ProcessExtensions.cs +++ b/src/Artemis.Core/Extensions/ProcessExtensions.cs @@ -9,9 +9,9 @@ namespace Artemis.Core { public static string GetProcessFilename(this Process p) { - var capacity = 2000; - var builder = new StringBuilder(capacity); - var ptr = OpenProcess(ProcessAccessFlags.QueryLimitedInformation, false, p.Id); + int capacity = 2000; + StringBuilder builder = new StringBuilder(capacity); + IntPtr ptr = OpenProcess(ProcessAccessFlags.QueryLimitedInformation, false, p.Id); if (!QueryFullProcessImageName(ptr, 0, builder, ref capacity)) return string.Empty; return builder.ToString(); diff --git a/src/Artemis.Core/Extensions/RgbDeviceExtensions.cs b/src/Artemis.Core/Extensions/RgbDeviceExtensions.cs index baa0c1f11..98a1eb7a2 100644 --- a/src/Artemis.Core/Extensions/RgbDeviceExtensions.cs +++ b/src/Artemis.Core/Extensions/RgbDeviceExtensions.cs @@ -7,7 +7,7 @@ namespace Artemis.Core { public static string GetDeviceIdentifier(this IRGBDevice rgbDevice) { - var builder = new StringBuilder(); + StringBuilder builder = new StringBuilder(); builder.Append(rgbDevice.DeviceInfo.DeviceName); builder.Append('-'); builder.Append(rgbDevice.DeviceInfo.Manufacturer); diff --git a/src/Artemis.Core/Extensions/SKColorExtensions.cs b/src/Artemis.Core/Extensions/SKColorExtensions.cs index 01a09837e..09202b9e4 100644 --- a/src/Artemis.Core/Extensions/SKColorExtensions.cs +++ b/src/Artemis.Core/Extensions/SKColorExtensions.cs @@ -14,10 +14,10 @@ namespace Artemis.Core public static SKColor Interpolate(this SKColor from, SKColor to, float progress) { - var redDiff = to.Red - from.Red; - var greenDiff = to.Green - from.Green; - var blueDiff = to.Blue - from.Blue; - var alphaDiff = to.Alpha - from.Alpha; + int redDiff = to.Red - from.Red; + int greenDiff = to.Green - from.Green; + int blueDiff = to.Blue - from.Blue; + int alphaDiff = to.Alpha - from.Alpha; return new SKColor( ClampToByte(from.Red + redDiff * progress), diff --git a/src/Artemis.Core/Extensions/TypeExtensions.cs b/src/Artemis.Core/Extensions/TypeExtensions.cs index 9b82bf445..039087fff 100644 --- a/src/Artemis.Core/Extensions/TypeExtensions.cs +++ b/src/Artemis.Core/Extensions/TypeExtensions.cs @@ -78,7 +78,7 @@ namespace Artemis.Core return true; if (PrimitiveTypeConversions.ContainsKey(to) && PrimitiveTypeConversions[to].Contains(from)) return true; - var castable = from.GetMethods(BindingFlags.Public | BindingFlags.Static) + bool castable = from.GetMethods(BindingFlags.Public | BindingFlags.Static) .Any( m => m.ReturnType == to && (m.Name == "op_Implicit" || diff --git a/src/Artemis.Core/Models/Profile/Colors/ColorGradient.cs b/src/Artemis.Core/Models/Profile/Colors/ColorGradient.cs index d8a72622a..ae94b9a55 100644 --- a/src/Artemis.Core/Models/Profile/Colors/ColorGradient.cs +++ b/src/Artemis.Core/Models/Profile/Colors/ColorGradient.cs @@ -37,10 +37,10 @@ namespace Artemis.Core if (timesToRepeat == 0) return Stops.OrderBy(c => c.Position).Select(c => c.Color).ToArray(); - var colors = Stops.OrderBy(c => c.Position).Select(c => c.Color).ToList(); - var result = new List(); + List colors = Stops.OrderBy(c => c.Position).Select(c => c.Color).ToList(); + List result = new List(); - for (var i = 0; i <= timesToRepeat; i++) + for (int i = 0; i <= timesToRepeat; i++) result.AddRange(colors); return result.ToArray(); @@ -60,13 +60,13 @@ namespace Artemis.Core return Stops.OrderBy(c => c.Position).Select(c => c.Position).ToArray(); // Create stops and a list of divided stops - var stops = Stops.OrderBy(c => c.Position).Select(c => c.Position / (timesToRepeat + 1)).ToList(); - var result = new List(); + List stops = Stops.OrderBy(c => c.Position).Select(c => c.Position / (timesToRepeat + 1)).ToList(); + List result = new List(); // For each repeat cycle, add the base stops to the end result - for (var i = 0; i <= timesToRepeat; i++) + for (int i = 0; i <= timesToRepeat; i++) { - var localStops = stops.Select(s => s + result.LastOrDefault()).ToList(); + List localStops = stops.Select(s => s + result.LastOrDefault()).ToList(); result.AddRange(localStops); } @@ -90,11 +90,11 @@ namespace Artemis.Core if (!Stops.Any()) return SKColor.Empty; - var stops = Stops.OrderBy(x => x.Position).ToArray(); + ColorGradientStop[] stops = Stops.OrderBy(x => x.Position).ToArray(); if (position <= 0) return stops[0].Color; if (position >= 1) return stops[^1].Color; ColorGradientStop left = stops[0], right = null; - foreach (var stop in stops) + foreach (ColorGradientStop stop in stops) { if (stop.Position >= position) { @@ -109,10 +109,10 @@ namespace Artemis.Core return left.Color; position = (float) Math.Round((position - left.Position) / (right.Position - left.Position), 2); - var a = (byte) ((right.Color.Alpha - left.Color.Alpha) * position + left.Color.Alpha); - var r = (byte) ((right.Color.Red - left.Color.Red) * position + left.Color.Red); - var g = (byte) ((right.Color.Green - left.Color.Green) * position + left.Color.Green); - var b = (byte) ((right.Color.Blue - left.Color.Blue) * position + left.Color.Blue); + byte a = (byte) ((right.Color.Alpha - left.Color.Alpha) * position + left.Color.Alpha); + byte r = (byte) ((right.Color.Red - left.Color.Red) * position + left.Color.Red); + byte g = (byte) ((right.Color.Green - left.Color.Green) * position + left.Color.Green); + byte b = (byte) ((right.Color.Blue - left.Color.Blue) * position + left.Color.Blue); return new SKColor(r, g, b, a); } @@ -122,10 +122,10 @@ namespace Artemis.Core /// public static ColorGradient GetUnicornBarf() { - var gradient = new ColorGradient(); - for (var i = 0; i < 9; i++) + ColorGradient gradient = new ColorGradient(); + for (int i = 0; i < 9; i++) { - var color = i != 8 ? SKColor.FromHsv(i * 32, 100, 100) : SKColor.FromHsv(0, 100, 100); + SKColor color = i != 8 ? SKColor.FromHsv(i * 32, 100, 100) : SKColor.FromHsv(0, 100, 100); gradient.Stops.Add(new ColorGradientStop(color, 0.125f * i)); } diff --git a/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionGroup.cs b/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionGroup.cs index a3d91df6d..c731176ca 100644 --- a/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionGroup.cs +++ b/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionGroup.cs @@ -34,7 +34,7 @@ namespace Artemis.Core Entity = entity; BooleanOperator = (BooleanOperator) Entity.BooleanOperator; - foreach (var childEntity in Entity.Children) + foreach (DataModelConditionPartEntity childEntity in Entity.Children) { if (childEntity is DataModelConditionGroupEntity groupEntity) AddChild(new DataModelConditionGroup(this, groupEntity)); @@ -88,7 +88,7 @@ namespace Artemis.Core protected override void Dispose(bool disposing) { _disposed = true; - foreach (var child in Children) + foreach (DataModelConditionPart child in Children) child.Dispose(); base.Dispose(disposing); @@ -125,7 +125,7 @@ namespace Artemis.Core Entity.Children.Clear(); Entity.Children.AddRange(Children.Select(c => c.GetEntity())); - foreach (var child in Children) + foreach (DataModelConditionPart child in Children) child.Save(); } diff --git a/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionList.cs b/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionList.cs index 7c634c0aa..48f87e8cd 100644 --- a/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionList.cs +++ b/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionList.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using Artemis.Core.DataModelExpansions; @@ -97,7 +98,7 @@ namespace Artemis.Core if (dataModel != null) { - var listType = dataModel.GetListTypeAtPath(path); + Type listType = dataModel.GetListTypeAtPath(path); if (listType == null) throw new ArtemisCoreException($"Data model of type {dataModel.GetType().Name} does not contain a list at path '{path}'"); @@ -130,7 +131,7 @@ namespace Artemis.Core DataModelStore.DataModelAdded -= DataModelStoreOnDataModelAdded; DataModelStore.DataModelRemoved -= DataModelStoreOnDataModelRemoved; - foreach (var child in Children) + foreach (DataModelConditionPart child in Children) child.Dispose(); base.Dispose(disposing); @@ -148,7 +149,7 @@ namespace Artemis.Core if (!(target is IList list)) return false; - var objectList = list.Cast(); + IEnumerable objectList = list.Cast(); return ListOperator switch { ListOperator.Any => objectList.Any(o => Children[0].EvaluateObject(o)), @@ -174,7 +175,7 @@ namespace Artemis.Core // Children Entity.Children.Clear(); Entity.Children.AddRange(Children.Select(c => c.GetEntity())); - foreach (var child in Children) + foreach (DataModelConditionPart child in Children) child.Save(); } @@ -191,11 +192,11 @@ namespace Artemis.Core return; // Get the data model ... - var dataModel = DataModelStore.Get(Entity.ListDataModelGuid.Value)?.DataModel; + DataModel dataModel = DataModelStore.Get(Entity.ListDataModelGuid.Value)?.DataModel; if (dataModel == null) return; // ... and ensure the path is valid - var listType = dataModel.GetListTypeAtPath(Entity.ListPropertyPath); + Type listType = dataModel.GetListTypeAtPath(Entity.ListPropertyPath); if (listType == null) return; @@ -224,14 +225,14 @@ namespace Artemis.Core if (_disposed) throw new ObjectDisposedException("DataModelConditionList"); - var parameter = Expression.Parameter(typeof(object), "listDataModel"); - var accessor = ListPropertyPath.Split('.').Aggregate( + ParameterExpression parameter = Expression.Parameter(typeof(object), "listDataModel"); + Expression accessor = ListPropertyPath.Split('.').Aggregate( Expression.Convert(parameter, ListDataModel.GetType()), Expression.Property ); accessor = Expression.Convert(accessor, typeof(IList)); - var lambda = Expression.Lambda>(accessor, parameter); + Expression> lambda = Expression.Lambda>(accessor, parameter); CompiledListAccessor = lambda.Compile(); } @@ -240,7 +241,7 @@ namespace Artemis.Core private void DataModelStoreOnDataModelAdded(object sender, DataModelStoreEvent e) { - var dataModel = e.Registration.DataModel; + DataModel dataModel = e.Registration.DataModel; if (dataModel.PluginInfo.Guid == Entity.ListDataModelGuid && dataModel.ContainsPath(Entity.ListPropertyPath)) { ListDataModel = dataModel; diff --git a/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionListPredicate.cs b/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionListPredicate.cs index b68d18cbe..22a9491ca 100644 --- a/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionListPredicate.cs +++ b/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionListPredicate.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Linq.Expressions; +using System.Reflection; using Artemis.Core.DataModelExpansions; using Artemis.Storage.Entities.Profile.Abstract; using Artemis.Storage.Entities.Profile.Conditions; @@ -171,7 +172,7 @@ namespace Artemis.Core return; } - var leftType = GetTypeAtInnerPath(LeftPropertyPath); + Type leftType = GetTypeAtInnerPath(LeftPropertyPath); if (conditionOperator.SupportsType(leftType)) Operator = conditionOperator; @@ -195,11 +196,11 @@ namespace Artemis.Core if (DataModelConditionList.ListType == null) return false; - var parts = path.Split('.'); - var current = DataModelConditionList.ListType; - foreach (var part in parts) + string[] parts = path.Split('.'); + Type current = DataModelConditionList.ListType; + foreach (string part in parts) { - var property = current.GetProperty(part); + PropertyInfo? property = current.GetProperty(part); current = property?.PropertyType; if (property == null) @@ -237,13 +238,13 @@ namespace Artemis.Core if (!ListContainsInnerPath(path)) return null; - var parts = path.Split('.'); - var current = DataModelConditionList.ListType; + string[] parts = path.Split('.'); + Type current = DataModelConditionList.ListType; Type result = null; - foreach (var part in parts) + foreach (string part in parts) { - var property = current.GetProperty(part); + PropertyInfo? property = current.GetProperty(part); current = property.PropertyType; result = property.PropertyType; } @@ -274,7 +275,7 @@ namespace Artemis.Core private void ApplyParentList() { - var current = Parent; + DataModelConditionPart current = Parent; while (current != null) { @@ -311,7 +312,7 @@ namespace Artemis.Core // Operator if (Entity.OperatorPluginGuid != null) { - var conditionOperator = ConditionOperatorStore.Get(Entity.OperatorPluginGuid.Value, Entity.OperatorType)?.ConditionOperator; + ConditionOperator conditionOperator = ConditionOperatorStore.Get(Entity.OperatorPluginGuid.Value, Entity.OperatorType)?.ConditionOperator; if (conditionOperator != null) UpdateOperator(conditionOperator); } @@ -319,7 +320,7 @@ namespace Artemis.Core // Right side dynamic if (PredicateType == ListRightSideType.Dynamic && Entity.RightDataModelGuid != null && Entity.RightPropertyPath != null) { - var dataModel = DataModelStore.Get(Entity.RightDataModelGuid.Value)?.DataModel; + DataModel dataModel = DataModelStore.Get(Entity.RightDataModelGuid.Value)?.DataModel; if (dataModel != null && dataModel.ContainsPath(Entity.RightPropertyPath)) UpdateRightSideDynamic(dataModel, Entity.RightPropertyPath); } @@ -337,7 +338,7 @@ namespace Artemis.Core if (LeftPropertyPath != null) { // Use the left side type so JSON.NET has a better idea what to do - var leftSideType = GetTypeAtInnerPath(LeftPropertyPath); + Type leftSideType = GetTypeAtInnerPath(LeftPropertyPath); object rightSideValue; try @@ -385,20 +386,20 @@ namespace Artemis.Core if (LeftPropertyPath == null || Operator == null) return; - var leftSideType = GetTypeAtInnerPath(LeftPropertyPath); + Type leftSideType = GetTypeAtInnerPath(LeftPropertyPath); if (!Operator.SupportsType(leftSideType)) Operator = null; } private void ValidateRightSide() { - var leftSideType = GetTypeAtInnerPath(LeftPropertyPath); + Type leftSideType = GetTypeAtInnerPath(LeftPropertyPath); if (PredicateType == ListRightSideType.Dynamic) { if (RightDataModel == null) return; - var rightSideType = RightDataModel.GetTypeAtPath(RightPropertyPath); + Type rightSideType = RightDataModel.GetTypeAtPath(RightPropertyPath); if (!leftSideType.IsCastableFrom(rightSideType)) UpdateRightSideDynamic(null, null); } @@ -407,7 +408,7 @@ namespace Artemis.Core if (RightPropertyPath == null) return; - var rightSideType = GetTypeAtInnerPath(RightPropertyPath); + Type rightSideType = GetTypeAtInnerPath(RightPropertyPath); if (!leftSideType.IsCastableFrom(rightSideType)) UpdateRightSideDynamic(null); } @@ -429,7 +430,7 @@ namespace Artemis.Core return; } - var leftSideType = GetTypeAtInnerPath(LeftPropertyPath); + Type leftSideType = GetTypeAtInnerPath(LeftPropertyPath); // If not null ensure the types match and if not, convert it if (staticValue != null && staticValue.GetType() == leftSideType) @@ -449,9 +450,9 @@ namespace Artemis.Core return; // List accessors share the same parameter because a list always contains one item per entry - var leftSideParameter = Expression.Parameter(typeof(object), "listItem"); - var leftSideAccessor = CreateListAccessor(LeftPropertyPath, leftSideParameter); - var rightSideAccessor = CreateListAccessor(RightPropertyPath, leftSideParameter); + ParameterExpression leftSideParameter = Expression.Parameter(typeof(object), "listItem"); + Expression leftSideAccessor = CreateListAccessor(LeftPropertyPath, leftSideParameter); + Expression rightSideAccessor = CreateListAccessor(RightPropertyPath, leftSideParameter); // A conversion may be required if the types differ // This can cause issues if the DataModelConditionOperator wasn't accurate in it's supported types but that is not a concern here @@ -468,9 +469,9 @@ namespace Artemis.Core return; // List accessors share the same parameter because a list always contains one item per entry - var leftSideParameter = Expression.Parameter(typeof(object), "listItem"); - var leftSideAccessor = CreateListAccessor(LeftPropertyPath, leftSideParameter); - var rightSideAccessor = ExpressionUtilities.CreateDataModelAccessor(RightDataModel, RightPropertyPath, "right", out var rightSideParameter); + ParameterExpression leftSideParameter = Expression.Parameter(typeof(object), "listItem"); + Expression leftSideAccessor = CreateListAccessor(LeftPropertyPath, leftSideParameter); + Expression rightSideAccessor = ExpressionUtilities.CreateDataModelAccessor(RightDataModel, RightPropertyPath, "right", out ParameterExpression rightSideParameter); // A conversion may be required if the types differ // This can cause issues if the DataModelConditionOperator wasn't accurate in it's supported types but that is not a concern here @@ -487,8 +488,8 @@ namespace Artemis.Core return; // List accessors share the same parameter because a list always contains one item per entry - var leftSideParameter = Expression.Parameter(typeof(object), "listItem"); - var leftSideAccessor = DataModelConditionList.IsPrimitiveList + ParameterExpression leftSideParameter = Expression.Parameter(typeof(object), "listItem"); + Expression leftSideAccessor = DataModelConditionList.IsPrimitiveList ? Expression.Convert(leftSideParameter, DataModelConditionList.ListType) : CreateListAccessor(LeftPropertyPath, leftSideParameter); @@ -523,7 +524,7 @@ namespace Artemis.Core private void DataModelStoreOnDataModelAdded(object sender, DataModelStoreEvent e) { - var dataModel = e.Registration.DataModel; + DataModel dataModel = e.Registration.DataModel; if (dataModel.PluginInfo.Guid == Entity.RightDataModelGuid && dataModel.ContainsPath(Entity.RightPropertyPath)) UpdateRightSideDynamic(dataModel, Entity.RightPropertyPath); } @@ -539,7 +540,7 @@ namespace Artemis.Core private void ConditionOperatorStoreOnConditionOperatorAdded(object sender, ConditionOperatorStoreEvent e) { - var conditionOperator = e.Registration.ConditionOperator; + ConditionOperator conditionOperator = e.Registration.ConditionOperator; if (Entity.OperatorPluginGuid == conditionOperator.PluginInfo.Guid && Entity.OperatorType == conditionOperator.GetType().Name) UpdateOperator(conditionOperator); } diff --git a/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionPredicate.cs b/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionPredicate.cs index 246b54f58..342eed1d0 100644 --- a/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionPredicate.cs +++ b/src/Artemis.Core/Models/Profile/Conditions/DataModelConditionPredicate.cs @@ -147,7 +147,7 @@ namespace Artemis.Core return; } - var leftSideType = LeftDataModel.GetTypeAtPath(LeftPropertyPath); + Type leftSideType = LeftDataModel.GetTypeAtPath(LeftPropertyPath); // If not null ensure the types match and if not, convert it if (staticValue != null && staticValue.GetType() == leftSideType) @@ -184,7 +184,7 @@ namespace Artemis.Core return; } - var leftType = LeftDataModel.GetTypeAtPath(LeftPropertyPath); + Type leftType = LeftDataModel.GetTypeAtPath(LeftPropertyPath); if (!conditionOperator.SupportsType(leftType)) { throw new ArtemisCoreException($"Cannot apply operator {conditionOperator.GetType().Name} to this predicate because " + @@ -204,7 +204,7 @@ namespace Artemis.Core // Compare with a static value if (PredicateType == ProfileRightSideType.Static) { - var leftSideValue = LeftSideAccessor(LeftDataModel); + object leftSideValue = LeftSideAccessor(LeftDataModel); if (leftSideValue.GetType().IsValueType && RightStaticValue == null) return false; @@ -256,7 +256,7 @@ namespace Artemis.Core // Left side if (Entity.LeftDataModelGuid != null) { - var dataModel = DataModelStore.Get(Entity.LeftDataModelGuid.Value)?.DataModel; + DataModel dataModel = DataModelStore.Get(Entity.LeftDataModelGuid.Value)?.DataModel; if (dataModel != null && dataModel.ContainsPath(Entity.LeftPropertyPath)) UpdateLeftSide(dataModel, Entity.LeftPropertyPath); } @@ -264,7 +264,7 @@ namespace Artemis.Core // Operator if (Entity.OperatorPluginGuid != null) { - var conditionOperator = ConditionOperatorStore.Get(Entity.OperatorPluginGuid.Value, Entity.OperatorType)?.ConditionOperator; + ConditionOperator conditionOperator = ConditionOperatorStore.Get(Entity.OperatorPluginGuid.Value, Entity.OperatorType)?.ConditionOperator; if (conditionOperator != null) UpdateOperator(conditionOperator); } @@ -272,7 +272,7 @@ namespace Artemis.Core // Right side dynamic if (PredicateType == ProfileRightSideType.Dynamic && Entity.RightDataModelGuid != null) { - var dataModel = DataModelStore.Get(Entity.RightDataModelGuid.Value)?.DataModel; + DataModel dataModel = DataModelStore.Get(Entity.RightDataModelGuid.Value)?.DataModel; if (dataModel != null && dataModel.ContainsPath(Entity.RightPropertyPath)) UpdateRightSide(dataModel, Entity.RightPropertyPath); } @@ -284,7 +284,7 @@ namespace Artemis.Core if (LeftDataModel != null) { // Use the left side type so JSON.NET has a better idea what to do - var leftSideType = LeftDataModel.GetTypeAtPath(LeftPropertyPath); + Type leftSideType = LeftDataModel.GetTypeAtPath(LeftPropertyPath); object rightSideValue; try @@ -336,20 +336,20 @@ namespace Artemis.Core if (LeftDataModel == null || Operator == null) return; - var leftType = LeftDataModel.GetTypeAtPath(LeftPropertyPath); + Type leftType = LeftDataModel.GetTypeAtPath(LeftPropertyPath); if (!Operator.SupportsType(leftType)) Operator = null; } private void ValidateRightSide() { - var leftSideType = LeftDataModel.GetTypeAtPath(LeftPropertyPath); + Type leftSideType = LeftDataModel.GetTypeAtPath(LeftPropertyPath); if (PredicateType == ProfileRightSideType.Dynamic) { if (RightDataModel == null) return; - var rightSideType = RightDataModel.GetTypeAtPath(RightPropertyPath); + Type rightSideType = RightDataModel.GetTypeAtPath(RightPropertyPath); if (!leftSideType.IsCastableFrom(rightSideType)) UpdateRightSide(null, null); } @@ -367,8 +367,8 @@ namespace Artemis.Core if (LeftDataModel == null || RightDataModel == null || Operator == null) return; - var leftSideAccessor = ExpressionUtilities.CreateDataModelAccessor(LeftDataModel, LeftPropertyPath, "left", out var leftSideParameter); - var rightSideAccessor = ExpressionUtilities.CreateDataModelAccessor(RightDataModel, RightPropertyPath, "right", out var rightSideParameter); + Expression leftSideAccessor = ExpressionUtilities.CreateDataModelAccessor(LeftDataModel, LeftPropertyPath, "left", out ParameterExpression leftSideParameter); + Expression rightSideAccessor = ExpressionUtilities.CreateDataModelAccessor(RightDataModel, RightPropertyPath, "right", out ParameterExpression rightSideParameter); // A conversion may be required if the types differ // This can cause issues if the DataModelConditionOperator wasn't accurate in it's supported types but that is not a concern here @@ -384,8 +384,8 @@ namespace Artemis.Core if (LeftDataModel == null || Operator == null) return; - var leftSideAccessor = Expression.Convert( - ExpressionUtilities.CreateDataModelAccessor(LeftDataModel, LeftPropertyPath, "left", out var leftSideParameter), + UnaryExpression leftSideAccessor = Expression.Convert( + ExpressionUtilities.CreateDataModelAccessor(LeftDataModel, LeftPropertyPath, "left", out ParameterExpression leftSideParameter), typeof(object) ); @@ -402,7 +402,7 @@ namespace Artemis.Core private void DataModelStoreOnDataModelAdded(object sender, DataModelStoreEvent e) { - var dataModel = e.Registration.DataModel; + DataModel dataModel = e.Registration.DataModel; if (dataModel.PluginInfo.Guid == Entity.LeftDataModelGuid && dataModel.ContainsPath(Entity.LeftPropertyPath)) UpdateLeftSide(dataModel, Entity.LeftPropertyPath); if (dataModel.PluginInfo.Guid == Entity.RightDataModelGuid && dataModel.ContainsPath(Entity.RightPropertyPath)) @@ -426,7 +426,7 @@ namespace Artemis.Core private void ConditionOperatorStoreOnConditionOperatorAdded(object sender, ConditionOperatorStoreEvent e) { - var conditionOperator = e.Registration.ConditionOperator; + ConditionOperator conditionOperator = e.Registration.ConditionOperator; if (Entity.OperatorPluginGuid == conditionOperator.PluginInfo.Guid && Entity.OperatorType == conditionOperator.GetType().Name) UpdateOperator(conditionOperator); } diff --git a/src/Artemis.Core/Models/Profile/DataBindings/DataBinding.cs b/src/Artemis.Core/Models/Profile/DataBindings/DataBinding.cs index 1193015fe..ddb682a2a 100644 --- a/src/Artemis.Core/Models/Profile/DataBindings/DataBinding.cs +++ b/src/Artemis.Core/Models/Profile/DataBindings/DataBinding.cs @@ -93,8 +93,8 @@ namespace Artemis.Core if (Converter == null) return; - var converterValue = Converter.GetValue(); - var value = GetValue(converterValue); + TProperty converterValue = Converter.GetValue(); + TProperty value = GetValue(converterValue); Converter.ApplyValue(value); } @@ -121,7 +121,7 @@ namespace Artemis.Core if (Converter == null || DataBindingMode == null) return baseValue; - var value = DataBindingMode.GetValue(baseValue); + TProperty value = DataBindingMode.GetValue(baseValue); // If no easing is to be applied simple return whatever the current value is if (EasingTime == TimeSpan.Zero || !Converter.SupportsInterpolate) @@ -175,7 +175,7 @@ namespace Artemis.Core if (_easingProgress == EasingTime || !Converter.SupportsInterpolate) return _currentValue; - var easingAmount = _easingProgress.TotalSeconds / EasingTime.TotalSeconds; + double easingAmount = _easingProgress.TotalSeconds / EasingTime.TotalSeconds; return Converter.Interpolate(_previousValue, _currentValue, Easings.Interpolate(easingAmount, EasingFunction)); } @@ -229,7 +229,7 @@ namespace Artemis.Core throw new ObjectDisposedException("DataBinding"); // General - var registration = LayerProperty.GetDataBindingRegistration(Entity.TargetExpression); + DataBindingRegistration registration = LayerProperty.GetDataBindingRegistration(Entity.TargetExpression); if (registration != null) ApplyRegistration(registration); diff --git a/src/Artemis.Core/Models/Profile/DataBindings/DataBindingConverter.cs b/src/Artemis.Core/Models/Profile/DataBindings/DataBindingConverter.cs index 486c50632..4d89aa732 100644 --- a/src/Artemis.Core/Models/Profile/DataBindings/DataBindingConverter.cs +++ b/src/Artemis.Core/Models/Profile/DataBindings/DataBindingConverter.cs @@ -130,43 +130,43 @@ namespace Artemis.Core private void CreateSetReferenceTypeExpression() { - var propertyValue = Expression.Parameter(typeof(TProperty), "propertyValue"); - var parameter = Expression.Parameter(typeof(TLayerProperty), "currentValue"); - var memberAccess = Expression.MakeMemberAccess(parameter, DataBinding.Registration.Member); - var assignment = Expression.Assign(memberAccess, propertyValue); - var referenceTypeLambda = Expression.Lambda>(assignment, parameter, propertyValue); + ParameterExpression propertyValue = Expression.Parameter(typeof(TProperty), "propertyValue"); + ParameterExpression parameter = Expression.Parameter(typeof(TLayerProperty), "currentValue"); + MemberExpression memberAccess = Expression.MakeMemberAccess(parameter, DataBinding.Registration.Member); + BinaryExpression assignment = Expression.Assign(memberAccess, propertyValue); + Expression> referenceTypeLambda = Expression.Lambda>(assignment, parameter, propertyValue); ReferenceTypeSetExpression = referenceTypeLambda.Compile(); } private void CreateSetValueTypeExpression() { - var propertyValue = Expression.Parameter(typeof(TProperty), "propertyValue"); - var variableCurrent = Expression.Variable(typeof(TLayerProperty), "current"); - var layerProperty = Expression.Constant(DataBinding.LayerProperty); - var layerPropertyMemberAccess = Expression.MakeMemberAccess(layerProperty, + ParameterExpression propertyValue = Expression.Parameter(typeof(TProperty), "propertyValue"); + ParameterExpression variableCurrent = Expression.Variable(typeof(TLayerProperty), "current"); + ConstantExpression layerProperty = Expression.Constant(DataBinding.LayerProperty); + MemberExpression layerPropertyMemberAccess = Expression.MakeMemberAccess(layerProperty, DataBinding.LayerProperty.GetType().GetMember(nameof(DataBinding.LayerProperty.CurrentValue))[0]); - var body = Expression.Block( + BlockExpression body = Expression.Block( new[] {variableCurrent}, Expression.Assign(variableCurrent, layerPropertyMemberAccess), Expression.Assign(Expression.MakeMemberAccess(variableCurrent, DataBinding.Registration.Member), propertyValue), Expression.Assign(layerPropertyMemberAccess, variableCurrent) ); - var valueTypeLambda = Expression.Lambda>(body, propertyValue); + Expression> valueTypeLambda = Expression.Lambda>(body, propertyValue); ValueTypeSetExpression = valueTypeLambda.Compile(); } private void CreateSetCurrentValueExpression() { - var propertyValue = Expression.Parameter(typeof(TProperty), "propertyValue"); - var layerProperty = Expression.Constant(DataBinding.LayerProperty); - var layerPropertyMemberAccess = Expression.MakeMemberAccess(layerProperty, + ParameterExpression propertyValue = Expression.Parameter(typeof(TProperty), "propertyValue"); + ConstantExpression layerProperty = Expression.Constant(DataBinding.LayerProperty); + MemberExpression layerPropertyMemberAccess = Expression.MakeMemberAccess(layerProperty, DataBinding.LayerProperty.GetType().GetMember(nameof(DataBinding.LayerProperty.CurrentValue))[0]); - var body = Expression.Assign(layerPropertyMemberAccess, propertyValue); - var lambda = Expression.Lambda>(body, propertyValue); + BinaryExpression body = Expression.Assign(layerPropertyMemberAccess, propertyValue); + Expression> lambda = Expression.Lambda>(body, propertyValue); ValueTypeSetExpression = lambda.Compile(); } } diff --git a/src/Artemis.Core/Models/Profile/DataBindings/DataBindingRegistration.cs b/src/Artemis.Core/Models/Profile/DataBindings/DataBindingRegistration.cs index 6ef9dd14a..7a2caa179 100644 --- a/src/Artemis.Core/Models/Profile/DataBindings/DataBindingRegistration.cs +++ b/src/Artemis.Core/Models/Profile/DataBindings/DataBindingRegistration.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Linq.Expressions; using System.Reflection; +using Artemis.Storage.Entities.Profile.DataBindings; namespace Artemis.Core { @@ -58,7 +59,7 @@ namespace Artemis.Core if (DataBinding != null) return DataBinding; - var dataBinding = LayerProperty.Entity.DataBindingEntities.FirstOrDefault(e => e.TargetExpression == PropertyExpression.ToString()); + DataBindingEntity dataBinding = LayerProperty.Entity.DataBindingEntities.FirstOrDefault(e => e.TargetExpression == PropertyExpression.ToString()); if (dataBinding == null) return null; diff --git a/src/Artemis.Core/Models/Profile/DataBindings/Modes/ConditionalDataBinding.cs b/src/Artemis.Core/Models/Profile/DataBindings/Modes/ConditionalDataBinding.cs index c1955ec8e..d4b4e046b 100644 --- a/src/Artemis.Core/Models/Profile/DataBindings/Modes/ConditionalDataBinding.cs +++ b/src/Artemis.Core/Models/Profile/DataBindings/Modes/ConditionalDataBinding.cs @@ -36,7 +36,7 @@ namespace Artemis.Core if (_disposed) throw new ObjectDisposedException("ConditionalDataBinding"); - var condition = Conditions.FirstOrDefault(c => c.Evaluate()); + DataBindingCondition condition = Conditions.FirstOrDefault(c => c.Evaluate()); if (condition != null) Console.WriteLine(); return condition == null ? baseValue : condition.Value; @@ -49,7 +49,7 @@ namespace Artemis.Core { _disposed = true; - foreach (var dataBindingCondition in Conditions) + foreach (DataBindingCondition dataBindingCondition in Conditions) dataBindingCondition.Dispose(); } @@ -66,7 +66,7 @@ namespace Artemis.Core if (_disposed) throw new ObjectDisposedException("ConditionalDataBinding"); - var condition = new DataBindingCondition(this); + DataBindingCondition condition = new DataBindingCondition(this); _conditions.Add(condition); ApplyOrder(); @@ -102,9 +102,9 @@ namespace Artemis.Core throw new ObjectDisposedException("ConditionalDataBinding"); _conditions.Sort((a, b) => a.Order.CompareTo(b.Order)); - for (var index = 0; index < _conditions.Count; index++) + for (int index = 0; index < _conditions.Count; index++) { - var condition = _conditions[index]; + DataBindingCondition condition = _conditions[index]; condition.Order = index + 1; } } @@ -116,7 +116,7 @@ namespace Artemis.Core /// public void Load() { - foreach (var dataBindingConditionEntity in Entity.Values) + foreach (DataBindingConditionEntity dataBindingConditionEntity in Entity.Values) _conditions.Add(new DataBindingCondition(this, dataBindingConditionEntity)); ApplyOrder(); @@ -126,7 +126,7 @@ namespace Artemis.Core public void Save() { Entity.Values.Clear(); - foreach (var dataBindingCondition in Conditions) + foreach (DataBindingCondition dataBindingCondition in Conditions) dataBindingCondition.Save(); } diff --git a/src/Artemis.Core/Models/Profile/DataBindings/Modes/DataBindingModifier.cs b/src/Artemis.Core/Models/Profile/DataBindings/Modes/DataBindingModifier.cs index 904e44cce..ec6b96e23 100644 --- a/src/Artemis.Core/Models/Profile/DataBindings/Modes/DataBindingModifier.cs +++ b/src/Artemis.Core/Models/Profile/DataBindings/Modes/DataBindingModifier.cs @@ -147,7 +147,7 @@ namespace Artemis.Core if (ParameterType == ProfileRightSideType.Dynamic && CompiledParameterAccessor != null) { - var value = CompiledParameterAccessor(ParameterDataModel); + object value = CompiledParameterAccessor(ParameterDataModel); return ModifierType.Apply(currentValue, value); } @@ -174,7 +174,7 @@ namespace Artemis.Core return; } - var targetType = DirectDataBinding.DataBinding.GetTargetType(); + Type targetType = DirectDataBinding.DataBinding.GetTargetType(); if (!modifierType.SupportsType(targetType)) { throw new ArtemisCoreException($"Cannot apply modifier type {modifierType.GetType().Name} to this modifier because " + @@ -226,7 +226,7 @@ namespace Artemis.Core ParameterDataModel = null; ParameterPropertyPath = null; - var parameterType = ModifierType?.ParameterType ?? DirectDataBinding.DataBinding.GetTargetType(); + Type parameterType = ModifierType?.ParameterType ?? DirectDataBinding.DataBinding.GetTargetType(); // If not null ensure the types match and if not, convert it if (staticValue != null && staticValue.GetType() == parameterType) @@ -252,7 +252,7 @@ namespace Artemis.Core // Modifier type if (Entity.ModifierTypePluginGuid != null && ModifierType == null) { - var modifierType = DataBindingModifierTypeStore.Get(Entity.ModifierTypePluginGuid.Value, Entity.ModifierType)?.DataBindingModifierType; + DataBindingModifierType modifierType = DataBindingModifierTypeStore.Get(Entity.ModifierTypePluginGuid.Value, Entity.ModifierType)?.DataBindingModifierType; if (modifierType != null) UpdateModifierType(modifierType); } @@ -260,7 +260,7 @@ namespace Artemis.Core // Dynamic parameter if (ParameterType == ProfileRightSideType.Dynamic && Entity.ParameterDataModelGuid != null && ParameterDataModel == null) { - var dataModel = DataModelStore.Get(Entity.ParameterDataModelGuid.Value)?.DataModel; + DataModel dataModel = DataModelStore.Get(Entity.ParameterDataModelGuid.Value)?.DataModel; if (dataModel != null && dataModel.ContainsPath(Entity.ParameterPropertyPath)) UpdateParameter(dataModel, Entity.ParameterPropertyPath); } @@ -268,7 +268,7 @@ namespace Artemis.Core else if (ParameterType == ProfileRightSideType.Static && Entity.ParameterStaticValue != null && ParameterStaticValue == null) { // Use the target type so JSON.NET has a better idea what to do - var parameterType = ModifierType?.ParameterType ?? DirectDataBinding.DataBinding.GetTargetType(); + Type parameterType = ModifierType?.ParameterType ?? DirectDataBinding.DataBinding.GetTargetType(); object staticValue; try @@ -299,10 +299,10 @@ namespace Artemis.Core return; // If the right side value is null, the constant type cannot be inferred and must be provided based on the data binding target - var parameterAccessor = ExpressionUtilities.CreateDataModelAccessor( - ParameterDataModel, ParameterPropertyPath, "parameter", out var rightSideParameter + Expression parameterAccessor = ExpressionUtilities.CreateDataModelAccessor( + ParameterDataModel, ParameterPropertyPath, "parameter", out ParameterExpression rightSideParameter ); - var lambda = Expression.Lambda>(Expression.Convert(parameterAccessor, typeof(object)), rightSideParameter); + Expression> lambda = Expression.Lambda>(Expression.Convert(parameterAccessor, typeof(object)), rightSideParameter); CompiledParameterAccessor = lambda.Compile(); } } @@ -314,7 +314,7 @@ namespace Artemis.Core if (ModifierType != null) return; - var modifierType = e.TypeRegistration.DataBindingModifierType; + DataBindingModifierType modifierType = e.TypeRegistration.DataBindingModifierType; if (modifierType.PluginInfo.Guid == Entity.ModifierTypePluginGuid && modifierType.GetType().Name == Entity.ModifierType) UpdateModifierType(modifierType); } @@ -327,7 +327,7 @@ namespace Artemis.Core private void DataModelStoreOnDataModelAdded(object sender, DataModelStoreEvent e) { - var dataModel = e.Registration.DataModel; + DataModel dataModel = e.Registration.DataModel; if (dataModel.PluginInfo.Guid == Entity.ParameterDataModelGuid && dataModel.ContainsPath(Entity.ParameterPropertyPath)) UpdateParameter(dataModel, Entity.ParameterPropertyPath); } diff --git a/src/Artemis.Core/Models/Profile/DataBindings/Modes/DirectDataBinding.cs b/src/Artemis.Core/Models/Profile/DataBindings/Modes/DirectDataBinding.cs index c60b31fdb..b92144f42 100644 --- a/src/Artemis.Core/Models/Profile/DataBindings/Modes/DirectDataBinding.cs +++ b/src/Artemis.Core/Models/Profile/DataBindings/Modes/DirectDataBinding.cs @@ -58,8 +58,8 @@ namespace Artemis.Core if (CompiledTargetAccessor == null) return baseValue; - var dataBindingValue = CompiledTargetAccessor(SourceDataModel); - foreach (var dataBindingModifier in Modifiers) + object dataBindingValue = CompiledTargetAccessor(SourceDataModel); + foreach (DataBindingModifier dataBindingModifier in Modifiers) dataBindingValue = dataBindingModifier.Apply(dataBindingValue); return DataBinding.Converter.ConvertFromObject(dataBindingValue); @@ -75,7 +75,7 @@ namespace Artemis.Core DataModelStore.DataModelAdded -= DataModelStoreOnDataModelAdded; DataModelStore.DataModelRemoved -= DataModelStoreOnDataModelRemoved; - foreach (var dataBindingModifier in Modifiers) + foreach (DataBindingModifier dataBindingModifier in Modifiers) dataBindingModifier.Dispose(); } @@ -89,7 +89,7 @@ namespace Artemis.Core // Data model is done during Initialize // Modifiers - foreach (var dataBindingModifierEntity in Entity.Modifiers) + foreach (DataBindingModifierEntity dataBindingModifierEntity in Entity.Modifiers) _modifiers.Add(new DataBindingModifier(this, dataBindingModifierEntity)); ApplyOrder(); @@ -107,7 +107,7 @@ namespace Artemis.Core // Modifiers Entity.Modifiers.Clear(); - foreach (var dataBindingModifier in Modifiers) + foreach (DataBindingModifier dataBindingModifier in Modifiers) dataBindingModifier.Save(); } @@ -123,7 +123,7 @@ namespace Artemis.Core // Source if (Entity.SourceDataModelGuid != null && SourceDataModel == null) { - var dataModel = DataModelStore.Get(Entity.SourceDataModelGuid.Value)?.DataModel; + DataModel dataModel = DataModelStore.Get(Entity.SourceDataModelGuid.Value)?.DataModel; if (dataModel != null && dataModel.ContainsPath(Entity.SourcePropertyPath)) UpdateSource(dataModel, Entity.SourcePropertyPath); } @@ -131,19 +131,19 @@ namespace Artemis.Core private void CreateExpression() { - var listType = SourceDataModel.GetListTypeInPath(SourcePropertyPath); + Type listType = SourceDataModel.GetListTypeInPath(SourcePropertyPath); if (listType != null) throw new ArtemisCoreException($"Cannot create a regular accessor at path {SourcePropertyPath} because the path contains a list"); - var parameter = Expression.Parameter(typeof(DataModel), "targetDataModel"); - var accessor = SourcePropertyPath.Split('.').Aggregate( + ParameterExpression parameter = Expression.Parameter(typeof(DataModel), "targetDataModel"); + Expression accessor = SourcePropertyPath.Split('.').Aggregate( Expression.Convert(parameter, SourceDataModel.GetType()), // Cast to the appropriate type Expression.Property ); - var returnValue = Expression.Convert(accessor, typeof(object)); + UnaryExpression returnValue = Expression.Convert(accessor, typeof(object)); - var lambda = Expression.Lambda>(returnValue, parameter); + Expression> lambda = Expression.Lambda>(returnValue, parameter); CompiledTargetAccessor = lambda.Compile(); } @@ -198,7 +198,7 @@ namespace Artemis.Core if (_disposed) throw new ObjectDisposedException("DirectDataBinding"); - var modifier = new DataBindingModifier(this, type); + DataBindingModifier modifier = new DataBindingModifier(this, type); _modifiers.Add(modifier); ApplyOrder(); @@ -230,9 +230,9 @@ namespace Artemis.Core public void ApplyOrder() { _modifiers.Sort((a, b) => a.Order.CompareTo(b.Order)); - for (var index = 0; index < _modifiers.Count; index++) + for (int index = 0; index < _modifiers.Count; index++) { - var modifier = _modifiers[index]; + DataBindingModifier modifier = _modifiers[index]; modifier.Order = index + 1; } } @@ -243,7 +243,7 @@ namespace Artemis.Core private void DataModelStoreOnDataModelAdded(object sender, DataModelStoreEvent e) { - var dataModel = e.Registration.DataModel; + DataModel dataModel = e.Registration.DataModel; if (dataModel.PluginInfo.Guid == Entity.SourceDataModelGuid && dataModel.ContainsPath(Entity.SourcePropertyPath)) UpdateSource(dataModel, Entity.SourcePropertyPath); } diff --git a/src/Artemis.Core/Models/Profile/DataModel/DataModelPathSegment.cs b/src/Artemis.Core/Models/Profile/DataModel/DataModelPathSegment.cs index d7093ac38..e64c4243f 100644 --- a/src/Artemis.Core/Models/Profile/DataModel/DataModelPathSegment.cs +++ b/src/Artemis.Core/Models/Profile/DataModel/DataModelPathSegment.cs @@ -119,12 +119,12 @@ namespace Artemis.Core if (IsStartSegment) return null; - var propertyInfo = GetPropertyInfo(); + PropertyInfo propertyInfo = GetPropertyInfo(); if (propertyInfo == null) return null; // Static types may have one as an attribute - var attribute = (DataModelPropertyAttribute) Attribute.GetCustomAttribute(propertyInfo, typeof(DataModelPropertyAttribute)); + DataModelPropertyAttribute attribute = (DataModelPropertyAttribute) Attribute.GetCustomAttribute(propertyInfo, typeof(DataModelPropertyAttribute)); if (attribute != null) { if (string.IsNullOrWhiteSpace(attribute.Name)) @@ -145,12 +145,12 @@ namespace Artemis.Core return DataModelPath.Target.GetType(); // Prefer basing the type on the property info - var propertyInfo = GetPropertyInfo(); - var type = propertyInfo?.PropertyType; + PropertyInfo propertyInfo = GetPropertyInfo(); + Type type = propertyInfo?.PropertyType; // Property info is not available on dynamic paths though, so fall back on the current value if (propertyInfo == null) { - var currentValue = GetValue(); + object currentValue = GetValue(); if (currentValue != null) type = currentValue.GetType(); } @@ -166,7 +166,7 @@ namespace Artemis.Core return CreateExpression(parameter, expression, nullCondition); } - var previousType = Previous.GetPropertyType(); + Type previousType = Previous.GetPropertyType(); if (previousType == null) { Type = DataModelPathSegmentType.Invalid; @@ -179,13 +179,13 @@ namespace Artemis.Core // If no static type could be found, check if this is a data model and if so, look for a dynamic type if (Type == DataModelPathSegmentType.Invalid && typeof(DataModel).IsAssignableFrom(previousType)) { - var dataModel = (DataModel) Previous.GetValue(); + DataModel dataModel = (DataModel) Previous.GetValue(); // Cannot determine a dynamic type on a null data model, leave the segment invalid if (dataModel == null) return CreateExpression(parameter, expression, nullCondition); // If a dynamic data model is found the use that - var hasDynamicDataModel = dataModel.DynamicDataModels.TryGetValue(Identifier, out var dynamicDataModel); + bool hasDynamicDataModel = dataModel.DynamicDataModels.TryGetValue(Identifier, out DataModel dynamicDataModel); if (hasDynamicDataModel) DetermineDynamicType(dynamicDataModel); } @@ -241,7 +241,7 @@ namespace Artemis.Core private void DetermineStaticType(Type previousType) { - var property = previousType.GetProperty(Identifier, BindingFlags.Public | BindingFlags.Instance); + PropertyInfo? property = previousType.GetProperty(Identifier, BindingFlags.Public | BindingFlags.Instance); Type = property == null ? DataModelPathSegmentType.Invalid : DataModelPathSegmentType.Static; } } diff --git a/src/Artemis.Core/Models/Profile/Folder.cs b/src/Artemis.Core/Models/Profile/Folder.cs index 4bacbaf4d..e615ba920 100644 --- a/src/Artemis.Core/Models/Profile/Folder.cs +++ b/src/Artemis.Core/Models/Profile/Folder.cs @@ -61,8 +61,8 @@ namespace Artemis.Core /// public override List GetAllLayerProperties() { - var result = new List(); - foreach (var layerEffect in LayerEffects) + List result = new List(); + foreach (BaseLayerEffect layerEffect in LayerEffects) { if (layerEffect.BaseProperties != null) result.AddRange(layerEffect.BaseProperties.GetAllLayerProperties()); @@ -83,7 +83,7 @@ namespace Artemis.Core return; // Disable data bindings during an override - var wasApplyingDataBindings = ApplyDataBindingsEnabled; + bool wasApplyingDataBindings = ApplyDataBindingsEnabled; ApplyDataBindingsEnabled = false; UpdateDisplayCondition(); @@ -92,16 +92,16 @@ namespace Artemis.Core // to it's start UpdateTimeline(deltaTime); - foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled)) + foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => e.Enabled)) { baseLayerEffect.BaseProperties?.Update(deltaTime); baseLayerEffect.Update(deltaTime); } // Iterate the children in reverse because that's how they must be rendered too - for (var index = Children.Count - 1; index > -1; index--) + for (int index = Children.Count - 1; index > -1; index--) { - var profileElement = Children[index]; + ProfileElement profileElement = Children[index]; profileElement.Update(deltaTime); } @@ -127,19 +127,19 @@ namespace Artemis.Core if (!Enabled) return; - var beginTime = TimelinePosition; + TimeSpan beginTime = TimelinePosition; if (stickToMainSegment) { if (!DisplayContinuously) { - var position = timeOverride + StartSegmentLength; + TimeSpan position = timeOverride + StartSegmentLength; if (position > StartSegmentLength + EndSegmentLength) TimelinePosition = StartSegmentLength + EndSegmentLength; } else { - var progress = timeOverride.TotalMilliseconds % MainSegmentLength.TotalMilliseconds; + double progress = timeOverride.TotalMilliseconds % MainSegmentLength.TotalMilliseconds; if (progress > 0) TimelinePosition = TimeSpan.FromMilliseconds(progress) + StartSegmentLength; else @@ -149,9 +149,9 @@ namespace Artemis.Core else TimelinePosition = timeOverride; - var delta = (TimelinePosition - beginTime).TotalSeconds; + double delta = (TimelinePosition - beginTime).TotalSeconds; - foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled)) + foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => e.Enabled)) { baseLayerEffect.BaseProperties?.Update(delta); baseLayerEffect.Update(delta); @@ -178,24 +178,24 @@ namespace Artemis.Core _folderBitmap = new SKBitmap(new SKImageInfo((int) Path.Bounds.Width, (int) Path.Bounds.Height)); } - using var folderPath = new SKPath(Path); - using var folderCanvas = new SKCanvas(_folderBitmap); - using var folderPaint = new SKPaint(); + using SKPath folderPath = new SKPath(Path); + using SKCanvas folderCanvas = new SKCanvas(_folderBitmap); + using SKPaint folderPaint = new SKPaint(); folderCanvas.Clear(); folderPath.Transform(SKMatrix.MakeTranslation(folderPath.Bounds.Left * -1, folderPath.Bounds.Top * -1)); - var targetLocation = Path.Bounds.Location; + SKPoint targetLocation = Path.Bounds.Location; if (Parent is Folder parentFolder) targetLocation -= parentFolder.Path.Bounds.Location; canvas.Save(); - using var clipPath = new SKPath(folderPath); + using SKPath clipPath = new SKPath(folderPath); clipPath.Transform(SKMatrix.MakeTranslation(targetLocation.X, targetLocation.Y)); canvas.ClipPath(clipPath); - foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled)) + foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => e.Enabled)) baseLayerEffect.PreProcess(folderCanvas, _folderBitmap.Info, folderPath, folderPaint); // No point rendering if the alpha was set to zero by one of the effects @@ -203,10 +203,10 @@ namespace Artemis.Core return; // Iterate the children in reverse because the first layer must be rendered last to end up on top - for (var index = Children.Count - 1; index > -1; index--) + for (int index = Children.Count - 1; index > -1; index--) { folderCanvas.Save(); - var profileElement = Children[index]; + ProfileElement profileElement = Children[index]; profileElement.Render(deltaTime, folderCanvas, _folderBitmap.Info); folderCanvas.Restore(); } @@ -214,11 +214,11 @@ namespace Artemis.Core // If required, apply the opacity override of the module to the root folder if (IsRootFolder && Profile.Module.OpacityOverride < 1) { - var multiplier = Easings.SineEaseInOut(Profile.Module.OpacityOverride); + double multiplier = Easings.SineEaseInOut(Profile.Module.OpacityOverride); folderPaint.Color = folderPaint.Color.WithAlpha((byte) (folderPaint.Color.Alpha * multiplier)); } - foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled)) + foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => e.Enabled)) baseLayerEffect.PostProcess(canvas, canvasInfo, folderPath, folderPaint); canvas.DrawBitmap(_folderBitmap, targetLocation, folderPaint); @@ -257,8 +257,8 @@ namespace Artemis.Core if (_disposed) throw new ObjectDisposedException("Folder"); - var path = new SKPath {FillType = SKPathFillType.Winding}; - foreach (var child in Children) + SKPath path = new SKPath {FillType = SKPathFillType.Winding}; + foreach (ProfileElement child in Children) { if (child is RenderProfileElement effectChild && effectChild.Path != null) path.AddPath(effectChild.Path); @@ -277,7 +277,7 @@ namespace Artemis.Core { _disposed = true; - foreach (var profileElement in Children) + foreach (ProfileElement profileElement in Children) profileElement.Dispose(); _folderBitmap?.Dispose(); @@ -289,15 +289,15 @@ namespace Artemis.Core _expandedPropertyGroups.AddRange(FolderEntity.ExpandedPropertyGroups); // Load child folders - foreach (var childFolder in Profile.ProfileEntity.Folders.Where(f => f.ParentId == EntityId)) + foreach (FolderEntity childFolder in Profile.ProfileEntity.Folders.Where(f => f.ParentId == EntityId)) ChildrenList.Add(new Folder(Profile, this, childFolder)); // Load child layers - foreach (var childLayer in Profile.ProfileEntity.Layers.Where(f => f.ParentId == EntityId)) + foreach (LayerEntity childLayer in Profile.ProfileEntity.Layers.Where(f => f.ParentId == EntityId)) ChildrenList.Add(new Layer(Profile, this, childLayer)); // Ensure order integrity, should be unnecessary but no one is perfect specially me ChildrenList = ChildrenList.OrderBy(c => c.Order).ToList(); - for (var index = 0; index < ChildrenList.Count; index++) + for (int index = 0; index < ChildrenList.Count; index++) ChildrenList[index].Order = index + 1; LoadRenderElement(); diff --git a/src/Artemis.Core/Models/Profile/Layer.cs b/src/Artemis.Core/Models/Profile/Layer.cs index 9bd5aaa14..45c973df9 100644 --- a/src/Artemis.Core/Models/Profile/Layer.cs +++ b/src/Artemis.Core/Models/Profile/Layer.cs @@ -73,12 +73,12 @@ namespace Artemis.Core /// public override List GetAllLayerProperties() { - var result = new List(); + List result = new List(); result.AddRange(General.GetAllLayerProperties()); result.AddRange(Transform.GetAllLayerProperties()); if (LayerBrush?.BaseProperties != null) result.AddRange(LayerBrush.BaseProperties.GetAllLayerProperties()); - foreach (var layerEffect in LayerEffects) + foreach (BaseLayerEffect layerEffect in LayerEffects) { if (layerEffect.BaseProperties != null) result.AddRange(layerEffect.BaseProperties.GetAllLayerProperties()); @@ -162,11 +162,11 @@ namespace Artemis.Core LayerBrushStore.LayerBrushRemoved += LayerBrushStoreOnLayerBrushRemoved; // Layers have two hardcoded property groups, instantiate them - var generalAttribute = Attribute.GetCustomAttribute( + Attribute? generalAttribute = Attribute.GetCustomAttribute( GetType().GetProperty(nameof(General)), typeof(PropertyGroupDescriptionAttribute) ); - var transformAttribute = Attribute.GetCustomAttribute( + Attribute? transformAttribute = Attribute.GetCustomAttribute( GetType().GetProperty(nameof(Transform)), typeof(PropertyGroupDescriptionAttribute) ); @@ -214,9 +214,9 @@ namespace Artemis.Core // LEDs LayerEntity.Leds.Clear(); - foreach (var artemisLed in Leds) + foreach (ArtemisLed artemisLed in Leds) { - var ledEntity = new LedEntity + LedEntity ledEntity = new LedEntity { DeviceIdentifier = artemisLed.Device.RgbDevice.GetDeviceIdentifier(), LedName = artemisLed.RgbLed.Id.ToString() @@ -280,7 +280,7 @@ namespace Artemis.Core LayerBrush.BaseProperties?.Update(deltaTime); LayerBrush.Update(deltaTime); - foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled)) + foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => e.Enabled)) { baseLayerEffect.BaseProperties?.Update(deltaTime); baseLayerEffect.Update(deltaTime); @@ -301,10 +301,10 @@ namespace Artemis.Core return; // Disable data bindings during an override - var wasApplyingDataBindings = ApplyDataBindingsEnabled; + bool wasApplyingDataBindings = ApplyDataBindingsEnabled; ApplyDataBindingsEnabled = false; - var beginTime = TimelinePosition; + TimeSpan beginTime = TimelinePosition; if (stickToMainSegment) { @@ -312,7 +312,7 @@ namespace Artemis.Core TimelinePosition = StartSegmentLength + timeOverride; else { - var progress = timeOverride.TotalMilliseconds % MainSegmentLength.TotalMilliseconds; + double progress = timeOverride.TotalMilliseconds % MainSegmentLength.TotalMilliseconds; if (progress > 0) TimelinePosition = TimeSpan.FromMilliseconds(progress) + StartSegmentLength; else @@ -322,14 +322,14 @@ namespace Artemis.Core else TimelinePosition = timeOverride; - var delta = (TimelinePosition - beginTime).TotalSeconds; + double delta = (TimelinePosition - beginTime).TotalSeconds; General.Update(delta); Transform.Update(delta); LayerBrush.BaseProperties?.Update(delta); LayerBrush.Update(delta); - foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled)) + foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => e.Enabled)) { baseLayerEffect.BaseProperties?.Update(delta); baseLayerEffect.Update(delta); @@ -363,9 +363,9 @@ namespace Artemis.Core _layerBitmap = new SKBitmap(new SKImageInfo((int) Path.Bounds.Width, (int) Path.Bounds.Height)); } - using var layerPath = new SKPath(Path); - using var layerCanvas = new SKCanvas(_layerBitmap); - using var layerPaint = new SKPaint + using SKPath layerPath = new SKPath(Path); + using SKCanvas layerCanvas = new SKCanvas(_layerBitmap); + using SKPaint layerPaint = new SKPaint { FilterQuality = SKFilterQuality.Low, Color = new SKColor(0, 0, 0, (byte) (Transform.Opacity.CurrentValue * 2.55f)) @@ -374,7 +374,7 @@ namespace Artemis.Core layerPath.Transform(SKMatrix.MakeTranslation(layerPath.Bounds.Left * -1, layerPath.Bounds.Top * -1)); - foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled)) + foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => e.Enabled)) baseLayerEffect.PreProcess(layerCanvas, _layerBitmap.Info, layerPath, layerPaint); // No point rendering if the alpha was set to zero by one of the effects @@ -388,15 +388,15 @@ namespace Artemis.Core else if (General.ResizeMode.CurrentValue == LayerResizeMode.Clip) ClipRender(layerCanvas, _layerBitmap.Info, layerPaint, layerPath); - foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled)) + foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => e.Enabled)) baseLayerEffect.PostProcess(layerCanvas, _layerBitmap.Info, layerPath, layerPaint); - var targetLocation = new SKPoint(0, 0); + SKPoint targetLocation = new SKPoint(0, 0); if (Parent is Folder parentFolder) targetLocation = Path.Bounds.Location - parentFolder.Path.Bounds.Location; - using var canvasPaint = new SKPaint {BlendMode = General.BlendMode.CurrentValue}; - using var canvasPath = new SKPath(Path); + using SKPaint canvasPaint = new SKPaint {BlendMode = General.BlendMode.CurrentValue}; + using SKPath canvasPath = new SKPath(Path); canvasPath.Transform(SKMatrix.MakeTranslation( (canvasPath.Bounds.Left - targetLocation.X) * -1, (canvasPath.Bounds.Top - targetLocation.Y) * -1) @@ -407,46 +407,46 @@ namespace Artemis.Core private void SimpleRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPaint paint, SKPath layerPath) { - using var renderPath = new SKPath(LayerShape.Path); + using SKPath renderPath = new SKPath(LayerShape.Path); LayerBrush.InternalRender(canvas, canvasInfo, renderPath, paint); } private void StretchRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPaint paint, SKPath layerPath) { // Apply transformations - var sizeProperty = Transform.Scale.CurrentValue; - var rotationProperty = Transform.Rotation.CurrentValue; + SKSize sizeProperty = Transform.Scale.CurrentValue; + float rotationProperty = Transform.Rotation.CurrentValue; - var anchorPosition = GetLayerAnchorPosition(layerPath); - var anchorProperty = Transform.AnchorPoint.CurrentValue; + SKPoint anchorPosition = GetLayerAnchorPosition(layerPath); + SKPoint anchorProperty = Transform.AnchorPoint.CurrentValue; // Translation originates from the unscaled center of the shape and is tied to the anchor - var x = anchorPosition.X - layerPath.Bounds.MidX - anchorProperty.X * layerPath.Bounds.Width; - var y = anchorPosition.Y - layerPath.Bounds.MidY - anchorProperty.Y * layerPath.Bounds.Height; + float x = anchorPosition.X - layerPath.Bounds.MidX - anchorProperty.X * layerPath.Bounds.Width; + float y = anchorPosition.Y - layerPath.Bounds.MidY - anchorProperty.Y * layerPath.Bounds.Height; // Apply these before translation because anchorPosition takes translation into account canvas.RotateDegrees(rotationProperty, anchorPosition.X, anchorPosition.Y); canvas.Scale(sizeProperty.Width / 100f, sizeProperty.Height / 100f, anchorPosition.X, anchorPosition.Y); canvas.Translate(x, y); - using var renderPath = new SKPath(LayerShape.Path); + using SKPath renderPath = new SKPath(LayerShape.Path); LayerBrush.InternalRender(canvas, canvasInfo, renderPath, paint); } private void ClipRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPaint paint, SKPath layerPath) { // Apply transformation - var sizeProperty = Transform.Scale.CurrentValue; - var rotationProperty = Transform.Rotation.CurrentValue; + SKSize sizeProperty = Transform.Scale.CurrentValue; + float rotationProperty = Transform.Rotation.CurrentValue; - var anchorPosition = GetLayerAnchorPosition(layerPath); - var anchorProperty = Transform.AnchorPoint.CurrentValue; + SKPoint anchorPosition = GetLayerAnchorPosition(layerPath); + SKPoint anchorProperty = Transform.AnchorPoint.CurrentValue; // Translation originates from the unscaled center of the shape and is tied to the anchor - var x = anchorPosition.X - layerPath.Bounds.MidX - anchorProperty.X * layerPath.Bounds.Width; - var y = anchorPosition.Y - layerPath.Bounds.MidY - anchorProperty.Y * layerPath.Bounds.Height; + float x = anchorPosition.X - layerPath.Bounds.MidX - anchorProperty.X * layerPath.Bounds.Width; + float y = anchorPosition.Y - layerPath.Bounds.MidY - anchorProperty.Y * layerPath.Bounds.Height; - using var clipPath = new SKPath(LayerShape.Path); + using SKPath clipPath = new SKPath(LayerShape.Path); clipPath.Transform(SKMatrix.MakeTranslation(x, y)); clipPath.Transform(SKMatrix.MakeScale(sizeProperty.Width / 100f, sizeProperty.Height / 100f, anchorPosition.X, anchorPosition.Y)); clipPath.Transform(SKMatrix.MakeRotationDegrees(rotationProperty, anchorPosition.X, anchorPosition.Y)); @@ -457,13 +457,13 @@ namespace Artemis.Core // Render the layer in the largest required bounds, this still creates stretching in some situations // but the only alternative I see right now is always forcing brushes to render on the entire canvas - var boundsRect = new SKRect( + SKRect boundsRect = new SKRect( Math.Min(clipPath.Bounds.Left - x, Bounds.Left - x), Math.Min(clipPath.Bounds.Top - y, Bounds.Top - y), Math.Max(clipPath.Bounds.Right - x, Bounds.Right - x), Math.Max(clipPath.Bounds.Bottom - y, Bounds.Bottom - y) ); - using var renderPath = new SKPath(); + using SKPath renderPath = new SKPath(); renderPath.AddRect(boundsRect); LayerBrush.InternalRender(canvas, canvasInfo, renderPath, paint); @@ -478,8 +478,8 @@ namespace Artemis.Core Path = new SKPath(); else { - var path = new SKPath {FillType = SKPathFillType.Winding}; - foreach (var artemisLed in Leds) + SKPath path = new SKPath {FillType = SKPathFillType.Winding}; + foreach (ArtemisLed artemisLed in Leds) path.AddRect(artemisLed.AbsoluteRenderRectangle); Path = path; @@ -501,10 +501,10 @@ namespace Artemis.Core if (_disposed) throw new ObjectDisposedException("Layer"); - var positionProperty = Transform.Position.CurrentValue; + SKPoint positionProperty = Transform.Position.CurrentValue; // Start at the center of the shape - var position = zeroBased + SKPoint position = zeroBased ? new SKPoint(layerPath.Bounds.MidX - layerPath.Bounds.Left, layerPath.Bounds.MidY - layerPath.Bounds.Top) : new SKPoint(layerPath.Bounds.MidX, layerPath.Bounds.MidY); @@ -525,15 +525,15 @@ namespace Artemis.Core if (_disposed) throw new ObjectDisposedException("Layer"); - var sizeProperty = Transform.Scale.CurrentValue; - var rotationProperty = Transform.Rotation.CurrentValue; + SKSize sizeProperty = Transform.Scale.CurrentValue; + float rotationProperty = Transform.Rotation.CurrentValue; - var anchorPosition = GetLayerAnchorPosition(Path, zeroBased); - var anchorProperty = Transform.AnchorPoint.CurrentValue; + SKPoint anchorPosition = GetLayerAnchorPosition(Path, zeroBased); + SKPoint anchorProperty = Transform.AnchorPoint.CurrentValue; // Translation originates from the unscaled center of the shape and is tied to the anchor - var x = anchorPosition.X - (zeroBased ? Bounds.MidX - Bounds.Left : Bounds.MidX) - anchorProperty.X * Bounds.Width; - var y = anchorPosition.Y - (zeroBased ? Bounds.MidY - Bounds.Top : Bounds.MidY) - anchorProperty.Y * Bounds.Height; + float x = anchorPosition.X - (zeroBased ? Bounds.MidX - Bounds.Left : Bounds.MidX) - anchorProperty.X * Bounds.Width; + float y = anchorPosition.Y - (zeroBased ? Bounds.MidY - Bounds.Top : Bounds.MidY) - anchorProperty.Y * Bounds.Height; if (General.ResizeMode == LayerResizeMode.Normal) { @@ -557,18 +557,18 @@ namespace Artemis.Core if (_disposed) throw new ObjectDisposedException("Layer"); - var sizeProperty = Transform.Scale.CurrentValue; - var rotationProperty = Transform.Rotation.CurrentValue; + SKSize sizeProperty = Transform.Scale.CurrentValue; + float rotationProperty = Transform.Rotation.CurrentValue; - var anchorPosition = GetLayerAnchorPosition(Path, zeroBased); - var anchorProperty = Transform.AnchorPoint.CurrentValue; + SKPoint anchorPosition = GetLayerAnchorPosition(Path, zeroBased); + SKPoint anchorProperty = Transform.AnchorPoint.CurrentValue; // Translation originates from the unscaled center of the shape and is tied to the anchor - var x = anchorPosition.X - (zeroBased ? Bounds.MidX - Bounds.Left : Bounds.MidX) - anchorProperty.X * Bounds.Width; - var y = anchorPosition.Y - (zeroBased ? Bounds.MidY - Bounds.Top : Bounds.MidY) - anchorProperty.Y * Bounds.Height; + float x = anchorPosition.X - (zeroBased ? Bounds.MidX - Bounds.Left : Bounds.MidX) - anchorProperty.X * Bounds.Width; + float y = anchorPosition.Y - (zeroBased ? Bounds.MidY - Bounds.Top : Bounds.MidY) - anchorProperty.Y * Bounds.Height; - var reversedXScale = 1f / (sizeProperty.Width / 100f); - var reversedYScale = 1f / (sizeProperty.Height / 100f); + float reversedXScale = 1f / (sizeProperty.Width / 100f); + float reversedYScale = 1f / (sizeProperty.Height / 100f); if (General.ResizeMode == LayerResizeMode.Normal) { @@ -593,18 +593,18 @@ namespace Artemis.Core if (_disposed) throw new ObjectDisposedException("Layer"); - var sizeProperty = Transform.Scale.CurrentValue; - var rotationProperty = Transform.Rotation.CurrentValue; + SKSize sizeProperty = Transform.Scale.CurrentValue; + float rotationProperty = Transform.Rotation.CurrentValue; - var anchorPosition = GetLayerAnchorPosition(Path, zeroBased); - var anchorProperty = Transform.AnchorPoint.CurrentValue; + SKPoint anchorPosition = GetLayerAnchorPosition(Path, zeroBased); + SKPoint anchorProperty = Transform.AnchorPoint.CurrentValue; // Translation originates from the unscaled center of the shape and is tied to the anchor - var x = anchorPosition.X - (zeroBased ? Bounds.MidX - Bounds.Left : Bounds.MidX) - anchorProperty.X * Bounds.Width; - var y = anchorPosition.Y - (zeroBased ? Bounds.MidY - Bounds.Top : Bounds.MidY) - anchorProperty.Y * Bounds.Height; + float x = anchorPosition.X - (zeroBased ? Bounds.MidX - Bounds.Left : Bounds.MidX) - anchorProperty.X * Bounds.Width; + float y = anchorPosition.Y - (zeroBased ? Bounds.MidY - Bounds.Top : Bounds.MidY) - anchorProperty.Y * Bounds.Height; - var reversedXScale = 1f / (sizeProperty.Width / 100f); - var reversedYScale = 1f / (sizeProperty.Height / 100f); + float reversedXScale = 1f / (sizeProperty.Width / 100f); + float reversedYScale = 1f / (sizeProperty.Height / 100f); if (General.ResizeMode == LayerResizeMode.Normal) { @@ -680,14 +680,14 @@ namespace Artemis.Core if (_disposed) throw new ObjectDisposedException("Layer"); - var leds = new List(); + List leds = new List(); // Get the surface LEDs for this layer - var availableLeds = surface.Devices.SelectMany(d => d.Leds).ToList(); - foreach (var ledEntity in LayerEntity.Leds) + List availableLeds = surface.Devices.SelectMany(d => d.Leds).ToList(); + foreach (LedEntity ledEntity in LayerEntity.Leds) { - var match = availableLeds.FirstOrDefault(a => a.Device.RgbDevice.GetDeviceIdentifier() == ledEntity.DeviceIdentifier && - a.RgbLed.Id.ToString() == ledEntity.LedName); + ArtemisLed match = availableLeds.FirstOrDefault(a => a.Device.RgbDevice.GetDeviceIdentifier() == ledEntity.DeviceIdentifier && + a.RgbLed.Id.ToString() == ledEntity.LedName); if (match != null) leds.Add(match); } @@ -710,13 +710,13 @@ namespace Artemis.Core if (LayerBrush != null) { - var brush = LayerBrush; + BaseLayerBrush brush = LayerBrush; LayerBrush = null; brush.Dispose(); } // Ensure the brush reference matches the brush - var current = General.BrushReference.BaseValue; + LayerBrushReference current = General.BrushReference.BaseValue; if (!descriptor.MatchesLayerBrushReference(current)) General.BrushReference.BaseValue = new LayerBrushReference(descriptor); @@ -731,18 +731,18 @@ namespace Artemis.Core if (LayerBrush == null) return; - var brush = LayerBrush; + BaseLayerBrush brush = LayerBrush; DeactivateLayerBrush(); LayerEntity.PropertyEntities.RemoveAll(p => p.PluginGuid == brush.PluginInfo.Guid && p.Path.StartsWith("LayerBrush.")); } internal void ActivateLayerBrush() { - var current = General.BrushReference.CurrentValue; + LayerBrushReference current = General.BrushReference.CurrentValue; if (current == null) return; - var descriptor = LayerBrushStore.Get(current.BrushPluginGuid, current.BrushType)?.LayerBrushDescriptor; + LayerBrushDescriptor descriptor = LayerBrushStore.Get(current.BrushPluginGuid, current.BrushType)?.LayerBrushDescriptor; descriptor?.CreateInstance(this); OnLayerBrushUpdated(); @@ -753,7 +753,7 @@ namespace Artemis.Core if (LayerBrush == null) return; - var brush = LayerBrush; + BaseLayerBrush brush = LayerBrush; LayerBrush = null; brush.Dispose(); @@ -775,7 +775,7 @@ namespace Artemis.Core if (LayerBrush != null || General.BrushReference?.CurrentValue == null) return; - var current = General.BrushReference.CurrentValue; + LayerBrushReference current = General.BrushReference.CurrentValue; if (e.Registration.Plugin.PluginInfo.Guid == current.BrushPluginGuid && e.Registration.LayerBrushDescriptor.LayerBrushType.Name == current.BrushType) ActivateLayerBrush(); diff --git a/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs b/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs index 36f59be34..9338d25ac 100644 --- a/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs +++ b/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs @@ -56,7 +56,7 @@ namespace Artemis.Core { _disposed = true; - foreach (var dataBinding in _dataBindings) + foreach (IDataBinding dataBinding in _dataBindings) dataBinding.Dispose(); } @@ -158,7 +158,7 @@ namespace Artemis.Core else { // If on a keyframe, update the keyframe - var currentKeyframe = Keyframes.FirstOrDefault(k => k.Position == time.Value); + LayerPropertyKeyframe currentKeyframe = Keyframes.FirstOrDefault(k => k.Position == time.Value); // Create a new keyframe if none found if (currentKeyframe == null) AddKeyframe(new LayerPropertyKeyframe(value, time.Value, Easings.Functions.Linear, this)); @@ -256,7 +256,7 @@ namespace Artemis.Core if (_disposed) throw new ObjectDisposedException("LayerProperty"); - var newKeyframe = new LayerPropertyKeyframe( + LayerPropertyKeyframe newKeyframe = new LayerPropertyKeyframe( keyframe.Value, keyframe.Position, keyframe.EasingFunction, @@ -301,7 +301,7 @@ namespace Artemis.Core // The current keyframe is the last keyframe before the current time CurrentKeyframe = _keyframes.LastOrDefault(k => k.Position <= ProfileElement.TimelinePosition); // Keyframes are sorted by position so we can safely assume the next keyframe's position is after the current - var nextIndex = _keyframes.IndexOf(CurrentKeyframe) + 1; + int nextIndex = _keyframes.IndexOf(CurrentKeyframe) + 1; NextKeyframe = _keyframes.Count > nextIndex ? _keyframes[nextIndex] : null; // No need to update the current value if either of the keyframes are null @@ -312,9 +312,9 @@ namespace Artemis.Core // Only determine progress and current value if both keyframes are present else { - var timeDiff = NextKeyframe.Position - CurrentKeyframe.Position; - var keyframeProgress = (float) ((ProfileElement.TimelinePosition - CurrentKeyframe.Position).TotalMilliseconds / timeDiff.TotalMilliseconds); - var keyframeProgressEased = (float) Easings.Interpolate(keyframeProgress, CurrentKeyframe.EasingFunction); + TimeSpan timeDiff = NextKeyframe.Position - CurrentKeyframe.Position; + float keyframeProgress = (float) ((ProfileElement.TimelinePosition - CurrentKeyframe.Position).TotalMilliseconds / timeDiff.TotalMilliseconds); + float keyframeProgressEased = (float) Easings.Interpolate(keyframeProgress, CurrentKeyframe.EasingFunction); UpdateCurrentValue(keyframeProgress, keyframeProgressEased); } } @@ -350,8 +350,8 @@ namespace Artemis.Core if (_disposed) throw new ObjectDisposedException("LayerProperty"); - var match = _dataBindingRegistrations.FirstOrDefault(r => r is DataBindingRegistration registration && - registration.PropertyExpression.ToString() == expression); + IDataBindingRegistration match = _dataBindingRegistrations.FirstOrDefault(r => r is DataBindingRegistration registration && + registration.PropertyExpression.ToString() == expression); return (DataBindingRegistration) match; } @@ -392,7 +392,7 @@ namespace Artemis.Core if (dataBindingRegistration.DataBinding != null) throw new ArtemisCoreException("Provided data binding registration already has an enabled data binding"); - var dataBinding = new DataBinding(dataBindingRegistration); + DataBinding dataBinding = new DataBinding(dataBindingRegistration); _dataBindings.Add(dataBinding); OnDataBindingEnabled(new LayerPropertyEventArgs(dataBinding.LayerProperty)); @@ -417,7 +417,7 @@ namespace Artemis.Core private void UpdateDataBindings(double deltaTime) { - foreach (var dataBinding in _dataBindings) + foreach (IDataBinding dataBinding in _dataBindings) { dataBinding.Update(deltaTime); dataBinding.Apply(); @@ -497,9 +497,9 @@ namespace Artemis.Core } _dataBindings.Clear(); - foreach (var dataBindingRegistration in _dataBindingRegistrations) + foreach (IDataBindingRegistration dataBindingRegistration in _dataBindingRegistrations) { - var dataBinding = dataBindingRegistration.CreateDataBinding(); + IDataBinding dataBinding = dataBindingRegistration.CreateDataBinding(); if (dataBinding != null) _dataBindings.Add(dataBinding); } @@ -528,7 +528,7 @@ namespace Artemis.Core })); Entity.DataBindingEntities.Clear(); - foreach (var dataBinding in _dataBindings) + foreach (IDataBinding dataBinding in _dataBindings) dataBinding.Save(); } diff --git a/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs b/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs index 4300b13a9..c127199ef 100644 --- a/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs +++ b/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs @@ -95,9 +95,9 @@ namespace Artemis.Core _disposed = true; DisableProperties(); - foreach (var layerProperty in _layerProperties) + foreach (ILayerProperty layerProperty in _layerProperties) layerProperty.Dispose(); - foreach (var layerPropertyGroup in _layerPropertyGroups) + foreach (LayerPropertyGroup layerPropertyGroup in _layerPropertyGroups) layerPropertyGroup.Dispose(); } @@ -114,8 +114,8 @@ namespace Artemis.Core if (!PropertiesInitialized) return new List(); - var result = new List(LayerProperties); - foreach (var layerPropertyGroup in LayerPropertyGroups) + List result = new List(LayerProperties); + foreach (LayerPropertyGroup layerPropertyGroup in LayerPropertyGroups) result.AddRange(layerPropertyGroup.GetAllLayerProperties()); return result.AsReadOnly(); @@ -161,14 +161,14 @@ namespace Artemis.Core Path = path.TrimEnd('.'); // Get all properties with a PropertyDescriptionAttribute - foreach (var propertyInfo in GetType().GetProperties()) + foreach (PropertyInfo propertyInfo in GetType().GetProperties()) { - var propertyDescription = Attribute.GetCustomAttribute(propertyInfo, typeof(PropertyDescriptionAttribute)); + Attribute? propertyDescription = Attribute.GetCustomAttribute(propertyInfo, typeof(PropertyDescriptionAttribute)); if (propertyDescription != null) InitializeProperty(propertyInfo, (PropertyDescriptionAttribute) propertyDescription); else { - var propertyGroupDescription = Attribute.GetCustomAttribute(propertyInfo, typeof(PropertyGroupDescriptionAttribute)); + Attribute? propertyGroupDescription = Attribute.GetCustomAttribute(propertyInfo, typeof(PropertyGroupDescriptionAttribute)); if (propertyGroupDescription != null) InitializeChildGroup(propertyInfo, (PropertyGroupDescriptionAttribute) propertyGroupDescription); } @@ -178,7 +178,7 @@ namespace Artemis.Core PopulateDefaults(); // Load the layer properties after defaults have been applied - foreach (var layerProperty in _layerProperties) + foreach (ILayerProperty layerProperty in _layerProperties) layerProperty.Load(); EnableProperties(); @@ -191,10 +191,10 @@ namespace Artemis.Core if (!PropertiesInitialized) return; - foreach (var layerProperty in LayerProperties) + foreach (ILayerProperty layerProperty in LayerProperties) layerProperty.Save(); - foreach (var layerPropertyGroup in LayerPropertyGroups) + foreach (LayerPropertyGroup layerPropertyGroup in LayerPropertyGroups) layerPropertyGroup.ApplyToEntity(); } @@ -207,12 +207,12 @@ namespace Artemis.Core private void InitializeProperty(PropertyInfo propertyInfo, PropertyDescriptionAttribute propertyDescription) { - var path = $"{Path}.{propertyInfo.Name}"; + string path = $"{Path}.{propertyInfo.Name}"; if (!typeof(ILayerProperty).IsAssignableFrom(propertyInfo.PropertyType)) throw new ArtemisPluginException($"Layer property with PropertyDescription attribute must be of type LayerProperty at {path}"); - var instance = (ILayerProperty) Activator.CreateInstance(propertyInfo.PropertyType, true); + ILayerProperty instance = (ILayerProperty) Activator.CreateInstance(propertyInfo.PropertyType, true); if (instance == null) throw new ArtemisPluginException($"Failed to create instance of layer property at {path}"); @@ -220,7 +220,7 @@ namespace Artemis.Core if (string.IsNullOrWhiteSpace(propertyDescription.Name)) propertyDescription.Name = propertyInfo.Name.Humanize(); - var entity = GetPropertyEntity(ProfileElement, path, out var fromStorage); + PropertyEntity entity = GetPropertyEntity(ProfileElement, path, out bool fromStorage); instance.Initialize(ProfileElement, this, entity, fromStorage, propertyDescription, path); propertyInfo.SetValue(this, instance); _layerProperties.Add(instance); @@ -228,12 +228,12 @@ namespace Artemis.Core private void InitializeChildGroup(PropertyInfo propertyInfo, PropertyGroupDescriptionAttribute propertyGroupDescription) { - var path = Path + "."; + string path = Path + "."; if (!typeof(LayerPropertyGroup).IsAssignableFrom(propertyInfo.PropertyType)) throw new ArtemisPluginException("Layer property with PropertyGroupDescription attribute must be of type LayerPropertyGroup"); - var instance = (LayerPropertyGroup) Activator.CreateInstance(propertyInfo.PropertyType); + LayerPropertyGroup instance = (LayerPropertyGroup) Activator.CreateInstance(propertyInfo.PropertyType); if (instance == null) throw new ArtemisPluginException($"Failed to create instance of layer property group at {path + propertyInfo.Name}"); @@ -253,7 +253,7 @@ namespace Artemis.Core private PropertyEntity GetPropertyEntity(RenderProfileElement profileElement, string path, out bool fromStorage) { - var entity = profileElement.RenderElementEntity.PropertyEntities.FirstOrDefault(p => p.PluginGuid == PluginInfo.Guid && p.Path == path); + PropertyEntity entity = profileElement.RenderElementEntity.PropertyEntities.FirstOrDefault(p => p.PluginGuid == PluginInfo.Guid && p.Path == path); fromStorage = entity != null; if (entity == null) { diff --git a/src/Artemis.Core/Models/Profile/LayerShapes/EllipseShape.cs b/src/Artemis.Core/Models/Profile/LayerShapes/EllipseShape.cs index b699aafe0..8e74af7b7 100644 --- a/src/Artemis.Core/Models/Profile/LayerShapes/EllipseShape.cs +++ b/src/Artemis.Core/Models/Profile/LayerShapes/EllipseShape.cs @@ -14,7 +14,7 @@ namespace Artemis.Core /// public override void CalculateRenderProperties() { - var path = new SKPath(); + SKPath path = new SKPath(); path.AddOval(SKRect.Create(Layer.Bounds.Width, Layer.Bounds.Height)); Path = path; } diff --git a/src/Artemis.Core/Models/Profile/LayerShapes/RectangleShape.cs b/src/Artemis.Core/Models/Profile/LayerShapes/RectangleShape.cs index a6aa13b36..9a737a6f8 100644 --- a/src/Artemis.Core/Models/Profile/LayerShapes/RectangleShape.cs +++ b/src/Artemis.Core/Models/Profile/LayerShapes/RectangleShape.cs @@ -14,7 +14,7 @@ namespace Artemis.Core /// public override void CalculateRenderProperties() { - var path = new SKPath(); + SKPath path = new SKPath(); path.AddRect(SKRect.Create(Layer.Bounds.Width, Layer.Bounds.Height)); Path = path; } diff --git a/src/Artemis.Core/Models/Profile/Profile.cs b/src/Artemis.Core/Models/Profile/Profile.cs index 583c10119..cc224c313 100644 --- a/src/Artemis.Core/Models/Profile/Profile.cs +++ b/src/Artemis.Core/Models/Profile/Profile.cs @@ -22,7 +22,7 @@ namespace Artemis.Core UndoStack = new Stack(); RedoStack = new Stack(); - var _ = new Folder(this, "Root folder"); + Folder _ = new Folder(this, "Root folder"); Save(); } @@ -61,7 +61,7 @@ namespace Artemis.Core if (!IsActivated) throw new ArtemisCoreException($"Cannot update inactive profile: {this}"); - foreach (var profileElement in Children) + foreach (ProfileElement profileElement in Children) profileElement.Update(deltaTime); } } @@ -75,7 +75,7 @@ namespace Artemis.Core if (!IsActivated) throw new ArtemisCoreException($"Cannot render inactive profile: {this}"); - foreach (var profileElement in Children) + foreach (ProfileElement profileElement in Children) profileElement.Render(deltaTime, canvas, canvasInfo); } } @@ -98,15 +98,15 @@ namespace Artemis.Core lock (ChildrenList) { // Remove the old profile tree - foreach (var profileElement in Children) + foreach (ProfileElement profileElement in Children) profileElement.Dispose(); ChildrenList.Clear(); // Populate the profile starting at the root, the rest is populated recursively - var rootFolder = ProfileEntity.Folders.FirstOrDefault(f => f.ParentId == EntityId); + FolderEntity rootFolder = ProfileEntity.Folders.FirstOrDefault(f => f.ParentId == EntityId); if (rootFolder == null) { - var _ = new Folder(this, "Root folder"); + Folder _ = new Folder(this, "Root folder"); } else AddChild(new Folder(this, this, rootFolder)); @@ -125,7 +125,7 @@ namespace Artemis.Core OnDeactivating(); - foreach (var profileElement in Children) + foreach (ProfileElement profileElement in Children) profileElement.Dispose(); ChildrenList.Clear(); @@ -143,7 +143,7 @@ namespace Artemis.Core ProfileEntity.Name = Name; ProfileEntity.IsActive = IsActivated; - foreach (var profileElement in Children) + foreach (ProfileElement profileElement in Children) profileElement.Save(); ProfileEntity.Folders.Clear(); @@ -173,7 +173,7 @@ namespace Artemis.Core if (_disposed) throw new ObjectDisposedException("Profile"); - foreach (var layer in GetAllLayers()) + foreach (Layer layer in GetAllLayers()) layer.PopulateLeds(surface); } diff --git a/src/Artemis.Core/Models/Profile/ProfileElement.cs b/src/Artemis.Core/Models/Profile/ProfileElement.cs index c91bcd2fe..836d8c2e3 100644 --- a/src/Artemis.Core/Models/Profile/ProfileElement.cs +++ b/src/Artemis.Core/Models/Profile/ProfileElement.cs @@ -125,7 +125,7 @@ namespace Artemis.Core // Shift everything after the given order else { - foreach (var profileElement in ChildrenList.Where(c => c.Order >= order).ToList()) + foreach (ProfileElement profileElement in ChildrenList.Where(c => c.Order >= order).ToList()) profileElement.Order++; int targetIndex; @@ -160,7 +160,7 @@ namespace Artemis.Core ChildrenList.Remove(child); // Shift everything after the given order - foreach (var profileElement in ChildrenList.Where(c => c.Order > child.Order).ToList()) + foreach (ProfileElement profileElement in ChildrenList.Where(c => c.Order > child.Order).ToList()) profileElement.Order--; child.Parent = null; @@ -178,8 +178,8 @@ namespace Artemis.Core if (_disposed) throw new ObjectDisposedException(GetType().Name); - var folders = new List(); - foreach (var childFolder in Children.Where(c => c is Folder).Cast()) + List folders = new List(); + foreach (Folder childFolder in Children.Where(c => c is Folder).Cast()) { // Add all folders in this element folders.Add(childFolder); @@ -199,13 +199,13 @@ namespace Artemis.Core if (_disposed) throw new ObjectDisposedException(GetType().Name); - var layers = new List(); + List layers = new List(); // Add all layers in this element layers.AddRange(Children.Where(c => c is Layer).Cast()); // Add all layers in folders inside this element - foreach (var childFolder in Children.Where(c => c is Folder).Cast()) + foreach (Folder childFolder in Children.Where(c => c is Folder).Cast()) layers.AddRange(childFolder.GetAllLayers()); return layers; diff --git a/src/Artemis.Core/Models/Profile/RenderProfileElement.cs b/src/Artemis.Core/Models/Profile/RenderProfileElement.cs index 60e646947..55d948c89 100644 --- a/src/Artemis.Core/Models/Profile/RenderProfileElement.cs +++ b/src/Artemis.Core/Models/Profile/RenderProfileElement.cs @@ -31,7 +31,7 @@ namespace Artemis.Core LayerEffectStore.LayerEffectAdded -= LayerEffectStoreOnLayerEffectAdded; LayerEffectStore.LayerEffectRemoved -= LayerEffectStoreOnLayerEffectRemoved; - foreach (var baseLayerEffect in LayerEffects) + foreach (BaseLayerEffect baseLayerEffect in LayerEffects) baseLayerEffect.Dispose(); base.Dispose(disposing); @@ -68,9 +68,9 @@ namespace Artemis.Core RenderElementEntity.AlwaysFinishTimeline = AlwaysFinishTimeline; RenderElementEntity.LayerEffects.Clear(); - foreach (var layerEffect in LayerEffects) + foreach (BaseLayerEffect layerEffect in LayerEffects) { - var layerEffectEntity = new LayerEffectEntity + LayerEffectEntity layerEffectEntity = new LayerEffectEntity { Id = layerEffect.EntityId, PluginGuid = layerEffect.Descriptor.PlaceholderFor ?? layerEffect.PluginInfo.Guid, @@ -228,9 +228,9 @@ namespace Artemis.Core protected double UpdateTimeline(double deltaTime) { - var oldPosition = _timelinePosition; - var deltaTimeSpan = TimeSpan.FromSeconds(deltaTime); - var mainSegmentEnd = StartSegmentLength + MainSegmentLength; + TimeSpan oldPosition = _timelinePosition; + TimeSpan deltaTimeSpan = TimeSpan.FromSeconds(deltaTime); + TimeSpan mainSegmentEnd = StartSegmentLength + MainSegmentLength; TimelinePosition += deltaTimeSpan; // Manage segments while the condition is met @@ -278,7 +278,7 @@ namespace Artemis.Core if (descriptor == null) throw new ArgumentNullException(nameof(descriptor)); - var entity = new LayerEffectEntity + LayerEffectEntity entity = new LayerEffectEntity { Id = Guid.NewGuid(), Enabled = true, @@ -309,8 +309,8 @@ namespace Artemis.Core private void OrderEffects() { - var index = 0; - foreach (var baseLayerEffect in LayerEffects.OrderBy(e => e.Order)) + int index = 0; + foreach (BaseLayerEffect baseLayerEffect in LayerEffects.OrderBy(e => e.Order)) { baseLayerEffect.Order = Order = index + 1; index++; @@ -321,14 +321,14 @@ namespace Artemis.Core internal void ActivateEffects() { - foreach (var layerEffectEntity in RenderElementEntity.LayerEffects) + foreach (LayerEffectEntity layerEffectEntity in RenderElementEntity.LayerEffects) { // If there is a non-placeholder existing effect, skip this entity - var existing = _layerEffects.FirstOrDefault(e => e.EntityId == layerEffectEntity.Id); + BaseLayerEffect existing = _layerEffects.FirstOrDefault(e => e.EntityId == layerEffectEntity.Id); if (existing != null && existing.Descriptor.PlaceholderFor == null) continue; - var descriptor = LayerEffectStore.Get(layerEffectEntity.PluginGuid, layerEffectEntity.EffectType)?.LayerEffectDescriptor; + LayerEffectDescriptor descriptor = LayerEffectStore.Get(layerEffectEntity.PluginGuid, layerEffectEntity.EffectType)?.LayerEffectDescriptor; if (descriptor != null) { // If a descriptor is found but there is an existing placeholder, remove the placeholder @@ -362,15 +362,15 @@ namespace Artemis.Core private void LayerEffectStoreOnLayerEffectRemoved(object sender, LayerEffectStoreEvent e) { // If effects provided by the plugin are on the element, replace them with placeholders - var pluginEffects = _layerEffects.Where(ef => ef.Descriptor.LayerEffectProvider != null && - ef.PluginInfo.Guid == e.Registration.Plugin.PluginInfo.Guid).ToList(); - foreach (var pluginEffect in pluginEffects) + List pluginEffects = _layerEffects.Where(ef => ef.Descriptor.LayerEffectProvider != null && + ef.PluginInfo.Guid == e.Registration.Plugin.PluginInfo.Guid).ToList(); + foreach (BaseLayerEffect pluginEffect in pluginEffects) { - var entity = RenderElementEntity.LayerEffects.First(en => en.Id == pluginEffect.EntityId); + LayerEffectEntity entity = RenderElementEntity.LayerEffects.First(en => en.Id == pluginEffect.EntityId); _layerEffects.Remove(pluginEffect); pluginEffect.Dispose(); - var descriptor = PlaceholderLayerEffectDescriptor.Create(pluginEffect.PluginInfo.Guid); + LayerEffectDescriptor descriptor = PlaceholderLayerEffectDescriptor.Create(pluginEffect.PluginInfo.Guid); descriptor.CreateInstance(this, entity); } } @@ -420,7 +420,7 @@ namespace Artemis.Core public void UpdateDisplayCondition() { - var conditionMet = DisplayCondition == null || DisplayCondition.Evaluate(); + bool conditionMet = DisplayCondition == null || DisplayCondition.Evaluate(); if (conditionMet && !DisplayConditionMet) TimelinePosition = TimeSpan.Zero; diff --git a/src/Artemis.Core/Models/Surface/ArtemisDevice.cs b/src/Artemis.Core/Models/Surface/ArtemisDevice.cs index 61e830a89..fdef3a868 100644 --- a/src/Artemis.Core/Models/Surface/ArtemisDevice.cs +++ b/src/Artemis.Core/Models/Surface/ArtemisDevice.cs @@ -156,11 +156,11 @@ namespace Artemis.Core if (!Leds.Any()) return; - foreach (var led in Leds) + foreach (ArtemisLed led in Leds) led.CalculateRenderRectangle(); - var path = new SKPath {FillType = SKPathFillType.Winding}; - foreach (var artemisLed in Leds) + SKPath path = new SKPath {FillType = SKPathFillType.Winding}; + foreach (ArtemisLed artemisLed in Leds) path.AddRect(artemisLed.AbsoluteRenderRectangle); RenderPath = path; diff --git a/src/Artemis.Core/Models/Surface/ArtemisSurface.cs b/src/Artemis.Core/Models/Surface/ArtemisSurface.cs index 3c0af4aec..7b0a34376 100644 --- a/src/Artemis.Core/Models/Surface/ArtemisSurface.cs +++ b/src/Artemis.Core/Models/Surface/ArtemisSurface.cs @@ -76,7 +76,7 @@ namespace Artemis.Core public void UpdateScale(double value) { Scale = value; - foreach (var device in Devices) + foreach (ArtemisDevice device in Devices) device.CalculateRenderProperties(); OnScaleChanged(); @@ -89,7 +89,7 @@ namespace Artemis.Core SurfaceEntity.IsActive = IsActive; // Add missing device entities, don't remove old ones in case they come back later - foreach (var deviceEntity in Devices.Select(d => d.DeviceEntity).ToList()) + foreach (DeviceEntity deviceEntity in Devices.Select(d => d.DeviceEntity).ToList()) { if (!SurfaceEntity.DeviceEntities.Contains(deviceEntity)) SurfaceEntity.DeviceEntities.Add(deviceEntity); diff --git a/src/Artemis.Core/Ninject/LoggerProvider.cs b/src/Artemis.Core/Ninject/LoggerProvider.cs index 4ba1c8295..9d1107b2d 100644 --- a/src/Artemis.Core/Ninject/LoggerProvider.cs +++ b/src/Artemis.Core/Ninject/LoggerProvider.cs @@ -1,4 +1,5 @@ -using Ninject.Activation; +using System; +using Ninject.Activation; using Serilog; using Serilog.Core; using Serilog.Events; @@ -21,7 +22,7 @@ namespace Artemis.Core.Ninject protected override ILogger CreateInstance(IContext context) { - var requestingType = context.Request.ParentContext?.Plan?.Type; + Type requestingType = context.Request.ParentContext?.Plan?.Type; if (requestingType != null) return Logger.ForContext(requestingType); return Logger; diff --git a/src/Artemis.Core/Ninject/PluginSettingsProvider.cs b/src/Artemis.Core/Ninject/PluginSettingsProvider.cs index ceaabd17a..1a72cd8ff 100644 --- a/src/Artemis.Core/Ninject/PluginSettingsProvider.cs +++ b/src/Artemis.Core/Ninject/PluginSettingsProvider.cs @@ -18,12 +18,12 @@ namespace Artemis.Core.Ninject protected override PluginSettings CreateInstance(IContext context) { - var parentRequest = context.Request.ParentRequest; + IRequest parentRequest = context.Request.ParentRequest; if (parentRequest == null) throw new ArtemisCoreException("PluginSettings couldn't be injected, failed to get the injection parent request"); // First try by PluginInfo parameter - var pluginInfo = parentRequest.Parameters.FirstOrDefault(p => p.Name == "PluginInfo")?.GetValue(context, null) as PluginInfo; + PluginInfo pluginInfo = parentRequest.Parameters.FirstOrDefault(p => p.Name == "PluginInfo")?.GetValue(context, null) as PluginInfo; if (pluginInfo == null) pluginInfo = _pluginService.GetPluginByAssembly(parentRequest.Service.Assembly)?.PluginInfo; // Fall back to assembly based detection diff --git a/src/Artemis.Core/Ninject/SettingsServiceProvider.cs b/src/Artemis.Core/Ninject/SettingsServiceProvider.cs index e7f6c1f39..2188e4d4f 100644 --- a/src/Artemis.Core/Ninject/SettingsServiceProvider.cs +++ b/src/Artemis.Core/Ninject/SettingsServiceProvider.cs @@ -16,7 +16,7 @@ namespace Artemis.Core.Ninject protected override ISettingsService CreateInstance(IContext context) { - var parentRequest = context.Request.ParentRequest; + IRequest parentRequest = context.Request.ParentRequest; if (parentRequest == null || typeof(Plugin).IsAssignableFrom(parentRequest.Service)) throw new ArtemisPluginException($"SettingsService can not be injected into a plugin. Inject {nameof(PluginSettings)} instead."); diff --git a/src/Artemis.Core/Plugins/DataModelExpansions/DataModel.cs b/src/Artemis.Core/Plugins/DataModelExpansions/DataModel.cs index 5d61efb43..35670eda1 100644 --- a/src/Artemis.Core/Plugins/DataModelExpansions/DataModel.cs +++ b/src/Artemis.Core/Plugins/DataModelExpansions/DataModel.cs @@ -74,7 +74,7 @@ namespace Artemis.Core.DataModelExpansions if (_dynamicDataModels.ContainsValue(dynamicDataModel)) { - var existingKey = _dynamicDataModels.First(kvp => kvp.Value == dynamicDataModel).Key; + string existingKey = _dynamicDataModels.First(kvp => kvp.Value == dynamicDataModel).Key; throw new ArtemisCoreException($"Cannot add a dynamic data model with key '{key}' " + $"because the dynamic data model is already added with key '{existingKey}."); } @@ -111,8 +111,8 @@ namespace Artemis.Core.DataModelExpansions /// The dynamic data model to remove public void RemoveDynamicChild(DataModel dynamicDataModel) { - var keys = _dynamicDataModels.Where(kvp => kvp.Value == dynamicDataModel).Select(kvp => kvp.Key).ToList(); - foreach (var key in keys) + List keys = _dynamicDataModels.Where(kvp => kvp.Value == dynamicDataModel).Select(kvp => kvp.Key).ToList(); + foreach (string key in keys) _dynamicDataModels.Remove(key); } @@ -124,17 +124,17 @@ namespace Artemis.Core.DataModelExpansions /// If found, the dynamic data model otherwise null public T DynamicChild(string key) where T : DataModel { - _dynamicDataModels.TryGetValue(key, out var value); + _dynamicDataModels.TryGetValue(key, out DataModel value); return value as T; } internal bool ContainsPath(string path) { - var parts = path.Split('.'); - var current = GetType(); - foreach (var part in parts) + string[] parts = path.Split('.'); + Type current = GetType(); + foreach (string part in parts) { - var property = current?.GetProperty(part); + PropertyInfo? property = current?.GetProperty(part); current = property?.PropertyType; if (property == null) return false; @@ -148,13 +148,13 @@ namespace Artemis.Core.DataModelExpansions if (!ContainsPath(path)) return null; - var parts = path.Split('.'); - var current = GetType(); + string[] parts = path.Split('.'); + Type current = GetType(); Type result = null; - foreach (var part in parts) + foreach (string part in parts) { - var property = current.GetProperty(part); + PropertyInfo? property = current.GetProperty(part); current = property.PropertyType; result = property.PropertyType; } @@ -167,17 +167,17 @@ namespace Artemis.Core.DataModelExpansions if (!ContainsPath(path)) return null; - var parts = path.Split('.'); - var current = GetType(); + string[] parts = path.Split('.'); + Type current = GetType(); - var index = 0; - foreach (var part in parts) + int index = 0; + foreach (string part in parts) { // Only return a type if the path CONTAINS a list, not if it points TO a list if (index == parts.Length - 1) return null; - var property = current.GetProperty(part); + PropertyInfo? property = current.GetProperty(part); // For lists, look into the list type instead of the list itself if (typeof(IList).IsAssignableFrom(property.PropertyType)) @@ -195,7 +195,7 @@ namespace Artemis.Core.DataModelExpansions if (!ContainsPath(path)) return null; - var child = GetTypeAtPath(path); + Type child = GetTypeAtPath(path); return child.GenericTypeArguments.Length > 0 ? child.GenericTypeArguments[0] : null; } diff --git a/src/Artemis.Core/Plugins/DataModelExpansions/DataModelExpansion.cs b/src/Artemis.Core/Plugins/DataModelExpansions/DataModelExpansion.cs index 28946a89b..03b38aa78 100644 --- a/src/Artemis.Core/Plugins/DataModelExpansions/DataModelExpansion.cs +++ b/src/Artemis.Core/Plugins/DataModelExpansions/DataModelExpansion.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Linq.Expressions; +using System.Reflection; namespace Artemis.Core.DataModelExpansions { @@ -25,7 +26,7 @@ namespace Artemis.Core.DataModelExpansions /// A lambda expression pointing to the property to ignore public void HideProperty(Expression> propertyLambda) { - var propertyInfo = ReflectionUtilities.GetPropertyInfo(DataModel, propertyLambda); + PropertyInfo propertyInfo = ReflectionUtilities.GetPropertyInfo(DataModel, propertyLambda); if (!HiddenPropertiesList.Any(p => p.Equals(propertyInfo))) HiddenPropertiesList.Add(propertyInfo); } @@ -37,7 +38,7 @@ namespace Artemis.Core.DataModelExpansions /// A lambda expression pointing to the property to stop ignoring public void ShowProperty(Expression> propertyLambda) { - var propertyInfo = ReflectionUtilities.GetPropertyInfo(DataModel, propertyLambda); + PropertyInfo propertyInfo = ReflectionUtilities.GetPropertyInfo(DataModel, propertyLambda); HiddenPropertiesList.RemoveAll(p => p.Equals(propertyInfo)); } diff --git a/src/Artemis.Core/Plugins/DeviceProviders/DeviceProvider.cs b/src/Artemis.Core/Plugins/DeviceProviders/DeviceProvider.cs index f34cdc30e..9ddbbf919 100644 --- a/src/Artemis.Core/Plugins/DeviceProviders/DeviceProvider.cs +++ b/src/Artemis.Core/Plugins/DeviceProviders/DeviceProvider.cs @@ -54,7 +54,7 @@ namespace Artemis.Core.DeviceProviders else if (e.RelativePath != null) e.FinalPath = Path.Combine(PluginInfo.Directory.FullName, e.RelativePath); - var deviceInfo = ((IRGBDevice) sender).DeviceInfo; + IRGBDeviceInfo deviceInfo = ((IRGBDevice) sender).DeviceInfo; if (e.FileName != null && !File.Exists(e.FinalPath)) { Logger?.Information("Couldn't find a layout for device {deviceName}, model {deviceModel} at {filePath}", diff --git a/src/Artemis.Core/Plugins/LayerBrushes/LayerBrushDescriptor.cs b/src/Artemis.Core/Plugins/LayerBrushes/LayerBrushDescriptor.cs index 8524c5de1..b319ed448 100644 --- a/src/Artemis.Core/Plugins/LayerBrushes/LayerBrushDescriptor.cs +++ b/src/Artemis.Core/Plugins/LayerBrushes/LayerBrushDescriptor.cs @@ -62,7 +62,7 @@ namespace Artemis.Core.LayerBrushes if (layer.LayerBrush != null) throw new ArtemisCoreException("Layer already has an instantiated layer brush"); - var brush = (BaseLayerBrush) LayerBrushProvider.PluginInfo.Kernel.Get(LayerBrushType); + BaseLayerBrush brush = (BaseLayerBrush) LayerBrushProvider.PluginInfo.Kernel.Get(LayerBrushType); brush.Layer = layer; brush.Descriptor = this; brush.Initialize(); diff --git a/src/Artemis.Core/Plugins/LayerBrushes/LayerBrushProvider.cs b/src/Artemis.Core/Plugins/LayerBrushes/LayerBrushProvider.cs index 3766edb13..6994f60d1 100644 --- a/src/Artemis.Core/Plugins/LayerBrushes/LayerBrushProvider.cs +++ b/src/Artemis.Core/Plugins/LayerBrushes/LayerBrushProvider.cs @@ -41,7 +41,7 @@ namespace Artemis.Core.LayerBrushes if (!Enabled) throw new ArtemisPluginException(PluginInfo, "Can only add a layer brush descriptor when the plugin is enabled"); - var descriptor = new LayerBrushDescriptor(displayName, description, icon, typeof(T), this); + LayerBrushDescriptor descriptor = new LayerBrushDescriptor(displayName, description, icon, typeof(T), this); _layerBrushDescriptors.Add(descriptor); LayerBrushStore.Add(descriptor); } diff --git a/src/Artemis.Core/Plugins/LayerBrushes/PerLedLayerBrush.cs b/src/Artemis.Core/Plugins/LayerBrushes/PerLedLayerBrush.cs index b6783ad32..c76ea80b2 100644 --- a/src/Artemis.Core/Plugins/LayerBrushes/PerLedLayerBrush.cs +++ b/src/Artemis.Core/Plugins/LayerBrushes/PerLedLayerBrush.cs @@ -36,14 +36,14 @@ namespace Artemis.Core.LayerBrushes if (Layer.General.ResizeMode == LayerResizeMode.Normal) { // Apply a translated version of the shape as the clipping mask - var shapePath = new SKPath(Layer.LayerShape.Path); + SKPath shapePath = new SKPath(Layer.LayerShape.Path); Layer.IncludePathInTranslation(shapePath, true); canvas.ClipPath(shapePath); } - using var pointsPath = new SKPath(); - using var ledPaint = new SKPaint(); - foreach (var artemisLed in Layer.Leds) + using SKPath pointsPath = new SKPath(); + using SKPaint ledPaint = new SKPaint(); + foreach (ArtemisLed artemisLed in Layer.Leds) { pointsPath.AddPoly(new[] { @@ -53,18 +53,18 @@ namespace Artemis.Core.LayerBrushes } Layer.ExcludePathFromTranslation(pointsPath, true); - var points = pointsPath.Points; - for (var index = 0; index < Layer.Leds.Count; index++) + SKPoint[] points = pointsPath.Points; + for (int index = 0; index < Layer.Leds.Count; index++) { - var artemisLed = Layer.Leds[index]; - var renderPoint = points[index * 2 + 1]; + ArtemisLed artemisLed = Layer.Leds[index]; + SKPoint renderPoint = points[index * 2 + 1]; if (!float.IsFinite(renderPoint.X) || !float.IsFinite(renderPoint.Y)) continue; // Let the brush determine the color ledPaint.Color = GetColor(artemisLed, renderPoint); - var ledRectangle = SKRect.Create( + SKRect ledRectangle = SKRect.Create( artemisLed.AbsoluteRenderRectangle.Left - Layer.Bounds.Left, artemisLed.AbsoluteRenderRectangle.Top - Layer.Bounds.Top, artemisLed.AbsoluteRenderRectangle.Width, diff --git a/src/Artemis.Core/Plugins/LayerBrushes/RgbNetLayerBrush.cs b/src/Artemis.Core/Plugins/LayerBrushes/RgbNetLayerBrush.cs index 395486165..38acdb123 100644 --- a/src/Artemis.Core/Plugins/LayerBrushes/RgbNetLayerBrush.cs +++ b/src/Artemis.Core/Plugins/LayerBrushes/RgbNetLayerBrush.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using Artemis.Core.Services; using RGB.NET.Core; @@ -39,8 +40,8 @@ namespace Artemis.Core.LayerBrushes // TODO: This simply renders it on top of the rest, get a ZIndex based on layer position LedGroup.ZIndex = 1; - var missingLeds = Layer.Leds.Where(l => !LedGroup.ContainsLed(l.RgbLed)).Select(l => l.RgbLed).ToList(); - var extraLeds = LedGroup.GetLeds().Where(l => Layer.Leds.All(layerLed => layerLed.RgbLed != l)).ToList(); + List missingLeds = Layer.Leds.Where(l => !LedGroup.ContainsLed(l.RgbLed)).Select(l => l.RgbLed).ToList(); + List extraLeds = LedGroup.GetLeds().Where(l => Layer.Leds.All(layerLed => layerLed.RgbLed != l)).ToList(); LedGroup.AddLeds(missingLeds); LedGroup.RemoveLeds(extraLeds); LedGroup.Brush = GetBrush(); diff --git a/src/Artemis.Core/Plugins/LayerEffects/LayerEffectDescriptor.cs b/src/Artemis.Core/Plugins/LayerEffects/LayerEffectDescriptor.cs index d913de153..97f27da49 100644 --- a/src/Artemis.Core/Plugins/LayerEffects/LayerEffectDescriptor.cs +++ b/src/Artemis.Core/Plugins/LayerEffects/LayerEffectDescriptor.cs @@ -67,7 +67,7 @@ namespace Artemis.Core.LayerEffects return; } - var effect = (BaseLayerEffect) LayerEffectProvider.PluginInfo.Kernel.Get(LayerEffectType); + BaseLayerEffect effect = (BaseLayerEffect) LayerEffectProvider.PluginInfo.Kernel.Get(LayerEffectType); effect.ProfileElement = renderElement; effect.EntityId = entity.Id; effect.Order = entity.Order; @@ -83,7 +83,7 @@ namespace Artemis.Core.LayerEffects private void CreatePlaceHolderInstance(RenderProfileElement renderElement, LayerEffectEntity entity) { - var effect = new PlaceholderLayerEffect(entity, PlaceholderFor.Value) {ProfileElement = renderElement, Descriptor = this}; + PlaceholderLayerEffect effect = new PlaceholderLayerEffect(entity, PlaceholderFor.Value) {ProfileElement = renderElement, Descriptor = this}; effect.Initialize(); renderElement.ActivateLayerEffect(effect); } diff --git a/src/Artemis.Core/Plugins/LayerEffects/LayerEffectProvider.cs b/src/Artemis.Core/Plugins/LayerEffects/LayerEffectProvider.cs index 91f86414c..c578d9667 100644 --- a/src/Artemis.Core/Plugins/LayerEffects/LayerEffectProvider.cs +++ b/src/Artemis.Core/Plugins/LayerEffects/LayerEffectProvider.cs @@ -41,7 +41,7 @@ namespace Artemis.Core.LayerEffects if (!Enabled) throw new ArtemisPluginException(PluginInfo, "Can only add a layer effect descriptor when the plugin is enabled"); - var descriptor = new LayerEffectDescriptor(displayName, description, icon, typeof(T), this); + LayerEffectDescriptor descriptor = new LayerEffectDescriptor(displayName, description, icon, typeof(T), this); _layerEffectDescriptors.Add(descriptor); LayerEffectStore.Add(descriptor); } diff --git a/src/Artemis.Core/Plugins/LayerEffects/Placeholder/PlaceholderLayerEffectDescriptor.cs b/src/Artemis.Core/Plugins/LayerEffects/Placeholder/PlaceholderLayerEffectDescriptor.cs index 63e738c37..eec2835fb 100644 --- a/src/Artemis.Core/Plugins/LayerEffects/Placeholder/PlaceholderLayerEffectDescriptor.cs +++ b/src/Artemis.Core/Plugins/LayerEffects/Placeholder/PlaceholderLayerEffectDescriptor.cs @@ -6,7 +6,7 @@ namespace Artemis.Core.LayerEffects.Placeholder { public static LayerEffectDescriptor Create(Guid missingPluginGuid) { - var descriptor = new LayerEffectDescriptor("Missing effect", "This effect could not be loaded", "FileQuestion", null, Constants.EffectPlaceholderPlugin) + LayerEffectDescriptor descriptor = new LayerEffectDescriptor("Missing effect", "This effect could not be loaded", "FileQuestion", null, Constants.EffectPlaceholderPlugin) { PlaceholderFor = missingPluginGuid }; diff --git a/src/Artemis.Core/Plugins/Modules/ActivationRequirements/ProcessActivationRequirement.cs b/src/Artemis.Core/Plugins/Modules/ActivationRequirements/ProcessActivationRequirement.cs index d738b735c..51c471b0a 100644 --- a/src/Artemis.Core/Plugins/Modules/ActivationRequirements/ProcessActivationRequirement.cs +++ b/src/Artemis.Core/Plugins/Modules/ActivationRequirements/ProcessActivationRequirement.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; @@ -37,7 +38,7 @@ namespace Artemis.Core.Modules if (ProcessName == null && Location == null) return false; - var processes = ProcessName != null ? Process.GetProcessesByName(ProcessName).Where(p => !p.HasExited) : Process.GetProcesses().Where(p => !p.HasExited); + IEnumerable processes = ProcessName != null ? Process.GetProcessesByName(ProcessName).Where(p => !p.HasExited) : Process.GetProcesses().Where(p => !p.HasExited); return Location != null ? processes.Any(p => string.Equals(Path.GetDirectoryName(p.GetProcessFilename()), Location, StringComparison.CurrentCultureIgnoreCase)) : processes.Any(); @@ -46,7 +47,7 @@ namespace Artemis.Core.Modules /// public string GetUserFriendlyDescription() { - var description = $"Requirement met when \"{ProcessName}.exe\" is running"; + string description = $"Requirement met when \"{ProcessName}.exe\" is running"; if (Location != null) description += $" from \"{Location}\""; diff --git a/src/Artemis.Core/Plugins/Modules/ProfileModule.cs b/src/Artemis.Core/Plugins/Modules/ProfileModule.cs index 8df97f33c..fc2b84da2 100644 --- a/src/Artemis.Core/Plugins/Modules/ProfileModule.cs +++ b/src/Artemis.Core/Plugins/Modules/ProfileModule.cs @@ -55,7 +55,7 @@ namespace Artemis.Core.Modules /// A lambda expression pointing to the property to ignore public void HideProperty(Expression> propertyLambda) { - var propertyInfo = ReflectionUtilities.GetPropertyInfo(DataModel, propertyLambda); + PropertyInfo propertyInfo = ReflectionUtilities.GetPropertyInfo(DataModel, propertyLambda); if (!HiddenPropertiesList.Any(p => p.Equals(propertyInfo))) HiddenPropertiesList.Add(propertyInfo); } @@ -67,7 +67,7 @@ namespace Artemis.Core.Modules /// A lambda expression pointing to the property to stop ignoring public void ShowProperty(Expression> propertyLambda) { - var propertyInfo = ReflectionUtilities.GetPropertyInfo(DataModel, propertyLambda); + PropertyInfo propertyInfo = ReflectionUtilities.GetPropertyInfo(DataModel, propertyLambda); HiddenPropertiesList.RemoveAll(p => p.Equals(propertyInfo)); } @@ -227,7 +227,7 @@ namespace Artemis.Core.Modules { base.Deactivate(isOverride); - var profile = ActiveProfile; + Profile profile = ActiveProfile; ActiveProfile = null; profile?.Dispose(); } diff --git a/src/Artemis.Core/Plugins/Plugin.cs b/src/Artemis.Core/Plugins/Plugin.cs index c5d8abbcf..d9020b973 100644 --- a/src/Artemis.Core/Plugins/Plugin.cs +++ b/src/Artemis.Core/Plugins/Plugin.cs @@ -75,7 +75,7 @@ namespace Artemis.Core // Allow up to 15 seconds for plugins to activate. // This means plugins that need more time should do their long running tasks in a background thread, which is intentional // Little meh: Running this from a different thread could cause deadlocks - var enableTask = Task.Run(InternalEnablePlugin); + Task enableTask = Task.Run(InternalEnablePlugin); if (!enableTask.Wait(TimeSpan.FromSeconds(15))) throw new ArtemisPluginException(PluginInfo, "Plugin load timeout"); diff --git a/src/Artemis.Core/Plugins/PluginUpdateRegistration.cs b/src/Artemis.Core/Plugins/PluginUpdateRegistration.cs index 4bc43c93f..7abac0172 100644 --- a/src/Artemis.Core/Plugins/PluginUpdateRegistration.cs +++ b/src/Artemis.Core/Plugins/PluginUpdateRegistration.cs @@ -83,7 +83,7 @@ namespace Artemis.Core if (!PluginInfo.Instance.Enabled) return; - var interval = DateTime.Now - _lastEvent; + TimeSpan interval = DateTime.Now - _lastEvent; _lastEvent = DateTime.Now; // Modules don't always want to update, honor that diff --git a/src/Artemis.Core/Plugins/Settings/PluginSettings.cs b/src/Artemis.Core/Plugins/Settings/PluginSettings.cs index fd82b09c7..28eaac4e0 100644 --- a/src/Artemis.Core/Plugins/Settings/PluginSettings.cs +++ b/src/Artemis.Core/Plugins/Settings/PluginSettings.cs @@ -37,7 +37,7 @@ namespace Artemis.Core if (_settingEntities.ContainsKey(name)) return (PluginSetting) _settingEntities[name]; // Try to find in database - var settingEntity = _pluginRepository.GetSettingByNameAndGuid(name, _pluginInfo.Guid); + PluginSettingEntity settingEntity = _pluginRepository.GetSettingByNameAndGuid(name, _pluginInfo.Guid); // If not found, create a new one if (settingEntity == null) { @@ -45,7 +45,7 @@ namespace Artemis.Core _pluginRepository.AddSetting(settingEntity); } - var pluginSetting = new PluginSetting(_pluginInfo, _pluginRepository, settingEntity); + PluginSetting pluginSetting = new PluginSetting(_pluginInfo, _pluginRepository, settingEntity); // This overrides null with the default value, I'm not sure if that's desirable because you // might expect something to go null and you might not diff --git a/src/Artemis.Core/RGB.NET/BitmapBrush.cs b/src/Artemis.Core/RGB.NET/BitmapBrush.cs index b95dc6774..1bfa5a615 100644 --- a/src/Artemis.Core/RGB.NET/BitmapBrush.cs +++ b/src/Artemis.Core/RGB.NET/BitmapBrush.cs @@ -94,9 +94,9 @@ namespace Artemis.Core private void TakeCenter(IEnumerable renderTargets) { - foreach (var renderTarget in renderTargets) + foreach (BrushRenderTarget renderTarget in renderTargets) { - var scaledLocation = renderTarget.Point * Scale; + Point scaledLocation = renderTarget.Point * Scale; if (scaledLocation.X < Bitmap.Width && scaledLocation.Y < Bitmap.Height) RenderedTargets[renderTarget] = Bitmap.GetPixel(scaledLocation.X.RoundToInt(), scaledLocation.Y.RoundToInt()).ToRgbColor(); } @@ -104,35 +104,35 @@ namespace Artemis.Core private void TakeSamples(IEnumerable renderTargets) { - var sampleSize = _sampleSizeSetting.Value; - var sampleDepth = Math.Sqrt(sampleSize).RoundToInt(); + int sampleSize = _sampleSizeSetting.Value; + int sampleDepth = Math.Sqrt(sampleSize).RoundToInt(); - var bitmapWidth = Bitmap.Width; - var bitmapHeight = Bitmap.Height; + int bitmapWidth = Bitmap.Width; + int bitmapHeight = Bitmap.Height; - using var pixmap = Bitmap.PeekPixels(); - foreach (var renderTarget in renderTargets) + using SKPixmap pixmap = Bitmap.PeekPixels(); + foreach (BrushRenderTarget renderTarget in renderTargets) { // SKRect has all the good stuff we need - var left = (int) ((renderTarget.Rectangle.Location.X + 4) * Scale.Horizontal); - var top = (int) ((renderTarget.Rectangle.Location.Y + 4) * Scale.Vertical); - var width = (int) ((renderTarget.Rectangle.Size.Width - 8) * Scale.Horizontal); - var height = (int) ((renderTarget.Rectangle.Size.Height - 8) * Scale.Vertical); + int left = (int) ((renderTarget.Rectangle.Location.X + 4) * Scale.Horizontal); + int top = (int) ((renderTarget.Rectangle.Location.Y + 4) * Scale.Vertical); + int width = (int) ((renderTarget.Rectangle.Size.Width - 8) * Scale.Horizontal); + int height = (int) ((renderTarget.Rectangle.Size.Height - 8) * Scale.Vertical); - var verticalSteps = height / (sampleDepth - 1); - var horizontalSteps = width / (sampleDepth - 1); + int verticalSteps = height / (sampleDepth - 1); + int horizontalSteps = width / (sampleDepth - 1); int a = 0, r = 0, g = 0, b = 0; - for (var horizontalStep = 0; horizontalStep < sampleDepth; horizontalStep++) + for (int horizontalStep = 0; horizontalStep < sampleDepth; horizontalStep++) { - for (var verticalStep = 0; verticalStep < sampleDepth; verticalStep++) + for (int verticalStep = 0; verticalStep < sampleDepth; verticalStep++) { - var x = left + horizontalSteps * horizontalStep; - var y = top + verticalSteps * verticalStep; + int x = left + horizontalSteps * horizontalStep; + int y = top + verticalSteps * verticalStep; if (x < 0 || x >= bitmapWidth || y < 0 || y >= bitmapHeight) continue; - var color = pixmap.GetPixelColor(x, y); + SKColor color = pixmap.GetPixelColor(x, y); a += color.Alpha; r += color.Red; g += color.Green; @@ -149,8 +149,8 @@ namespace Artemis.Core private void CreateBitmap(Rectangle rectangle) { - var width = Math.Min((rectangle.Location.X + rectangle.Size.Width) * Scale.Horizontal, 4096); - var height = Math.Min((rectangle.Location.Y + rectangle.Size.Height) * Scale.Vertical, 4096); + double width = Math.Min((rectangle.Location.X + rectangle.Size.Width) * Scale.Horizontal, 4096); + double height = Math.Min((rectangle.Location.Y + rectangle.Size.Height) * Scale.Vertical, 4096); Bitmap = new SKBitmap(new SKImageInfo(width.RoundToInt(), height.RoundToInt(), SKColorType.Rgb888x)); } diff --git a/src/Artemis.Core/Services/CoreService.cs b/src/Artemis.Core/Services/CoreService.cs index a7a010118..8e5e54dab 100644 --- a/src/Artemis.Core/Services/CoreService.cs +++ b/src/Artemis.Core/Services/CoreService.cs @@ -79,7 +79,7 @@ namespace Artemis.Core.Services if (IsInitialized) throw new ArtemisCoreException("Cannot initialize the core as it is already initialized."); - var versionAttribute = typeof(CoreService).Assembly.GetCustomAttribute(); + AssemblyInformationalVersionAttribute? versionAttribute = typeof(CoreService).Assembly.GetCustomAttribute(); _logger.Information("Initializing Artemis Core version {version}", versionAttribute?.InformationalVersion); ApplyLoggingLevel(); @@ -89,7 +89,7 @@ namespace Artemis.Core.Services _pluginService.CopyBuiltInPlugins(); _pluginService.LoadPlugins(StartupArguments.Contains("--ignore-plugin-lock")); - var surfaceConfig = _surfaceService.ActiveSurface; + ArtemisSurface surfaceConfig = _surfaceService.ActiveSurface; if (surfaceConfig != null) _logger.Information("Initialized with active surface entity {surfaceConfig}-{guid}", surfaceConfig.Name, surfaceConfig.EntityId); else @@ -123,7 +123,7 @@ namespace Artemis.Core.Services _introAnimation.Render(args.DeltaTime, args.Canvas, _rgbService.BitmapBrush.Bitmap.Info); } - var introLength = _introAnimation.AnimationProfile.GetAllLayers().Max(l => l.TimelineLength); + TimeSpan introLength = _introAnimation.AnimationProfile.GetAllLayers().Max(l => l.TimelineLength); // Stop rendering after the profile finishes (take 1 second extra in case of slow updates) Task.Run(async () => @@ -167,7 +167,7 @@ namespace Artemis.Core.Services lock (_dataModelExpansions) { // Update all active modules - foreach (var dataModelExpansion in _dataModelExpansions) + foreach (BaseDataModelExpansion dataModelExpansion in _dataModelExpansions) dataModelExpansion.Update(args.DeltaTime); } @@ -181,7 +181,7 @@ namespace Artemis.Core.Services } // Update all active modules - foreach (var module in modules) + foreach (Module module in modules) module.InternalUpdate(args.DeltaTime); // If there is no ready bitmap brush, skip the frame @@ -194,12 +194,12 @@ namespace Artemis.Core.Services return; // Render all active modules - using var canvas = new SKCanvas(_rgbService.BitmapBrush.Bitmap); + using SKCanvas canvas = new SKCanvas(_rgbService.BitmapBrush.Bitmap); canvas.Clear(new SKColor(0, 0, 0)); if (!ModuleRenderingDisabled) { // While non-activated modules may be updated above if they expand the main data model, they may never render - foreach (var module in modules.Where(m => m.IsActivated)) + foreach (Module module in modules.Where(m => m.IsActivated)) module.InternalRender(args.DeltaTime, _surfaceService.ActiveSurface, canvas, _rgbService.BitmapBrush.Bitmap.Info); } diff --git a/src/Artemis.Core/Services/DeviceService.cs b/src/Artemis.Core/Services/DeviceService.cs index 8fdc47766..9952212a7 100644 --- a/src/Artemis.Core/Services/DeviceService.cs +++ b/src/Artemis.Core/Services/DeviceService.cs @@ -16,7 +16,7 @@ namespace Artemis.Core.Services private void BlinkDevice(ArtemisDevice device, int blinkCount) { // Create a LED group way at the top - var ledGroup = new ListLedGroup(device.Leds.Select(l => l.RgbLed)) + ListLedGroup ledGroup = new ListLedGroup(device.Leds.Select(l => l.RgbLed)) { Brush = new SolidColorBrush(new Color(255, 255, 255)), ZIndex = 999 diff --git a/src/Artemis.Core/Services/ModuleService.cs b/src/Artemis.Core/Services/ModuleService.cs index b7148fdd8..aa1af0734 100644 --- a/src/Artemis.Core/Services/ModuleService.cs +++ b/src/Artemis.Core/Services/ModuleService.cs @@ -28,11 +28,11 @@ namespace Artemis.Core.Services _profileService = profileService; _pluginService.PluginEnabled += PluginServiceOnPluginEnabled; - var activationUpdateTimer = new Timer(2000); + Timer activationUpdateTimer = new Timer(2000); activationUpdateTimer.Start(); activationUpdateTimer.Elapsed += ActivationUpdateTimerOnElapsed; - foreach (var module in _pluginService.GetPluginsOfType()) + foreach (Module module in _pluginService.GetPluginsOfType()) InitialiseOrApplyPriority(module); } @@ -56,8 +56,8 @@ namespace Artemis.Core.Services _logger.Information("Clearing active module override"); // Always deactivate all other modules whenever override is called - var modules = _pluginService.GetPluginsOfType().ToList(); - foreach (var module in modules.Where(m => m != overrideModule)) + List modules = _pluginService.GetPluginsOfType().ToList(); + foreach (Module module in modules.Where(m => m != overrideModule)) OverrideDeactivate(module); ActiveModuleOverride = overrideModule; @@ -81,7 +81,7 @@ namespace Artemis.Core.Services { // The conditions of the active module override may be matched, in that case reactivate as a non-override // the principle is different for this service but not for the module - var shouldBeActivated = ActiveModuleOverride.EvaluateActivationRequirements(); + bool shouldBeActivated = ActiveModuleOverride.EvaluateActivationRequirements(); if (shouldBeActivated && ActiveModuleOverride.IsActivatedOverride) { ActiveModuleOverride.Deactivate(true); @@ -96,14 +96,14 @@ namespace Artemis.Core.Services return; } - var stopwatch = new Stopwatch(); + Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); - var modules = _pluginService.GetPluginsOfType().ToList(); - var tasks = new List(); - foreach (var module in modules) + List modules = _pluginService.GetPluginsOfType().ToList(); + List tasks = new List(); + foreach (Module module in modules) { - var shouldBeActivated = module.EvaluateActivationRequirements(); + bool shouldBeActivated = module.EvaluateActivationRequirements(); if (shouldBeActivated && !module.IsActivated) tasks.Add(ActivateModule(module)); else if (!shouldBeActivated && module.IsActivated) @@ -127,7 +127,7 @@ namespace Artemis.Core.Services if (module.PriorityCategory == category && module.Priority == priority) return; - var modules = _pluginService.GetPluginsOfType().Where(m => m.PriorityCategory == category).OrderBy(m => m.Priority).ToList(); + List modules = _pluginService.GetPluginsOfType().Where(m => m.PriorityCategory == category).OrderBy(m => m.Priority).ToList(); if (modules.Contains(module)) modules.Remove(module); @@ -135,9 +135,9 @@ namespace Artemis.Core.Services modules.Insert(priority, module); module.PriorityCategory = category; - for (var index = 0; index < modules.Count; index++) + for (int index = 0; index < modules.Count; index++) { - var categoryModule = modules[index]; + Module categoryModule = modules[index]; categoryModule.Priority = index; // Don't save modules whose priority hasn't been initialized yet @@ -236,8 +236,8 @@ namespace Artemis.Core.Services private void InitialiseOrApplyPriority(Module module) { - var category = module.DefaultPriorityCategory; - var priority = 1; + ModulePriorityCategory category = module.DefaultPriorityCategory; + int priority = 1; module.Entity = _moduleRepository.GetByPluginGuid(module.PluginInfo.Guid); if (module.Entity != null) diff --git a/src/Artemis.Core/Services/PluginService.cs b/src/Artemis.Core/Services/PluginService.cs index 4eae4f677..2cd508c9b 100644 --- a/src/Artemis.Core/Services/PluginService.cs +++ b/src/Artemis.Core/Services/PluginService.cs @@ -44,26 +44,26 @@ namespace Artemis.Core.Services public void CopyBuiltInPlugins() { OnCopyingBuildInPlugins(); - var pluginDirectory = new DirectoryInfo(Path.Combine(Constants.DataFolder, "plugins")); + DirectoryInfo pluginDirectory = new DirectoryInfo(Path.Combine(Constants.DataFolder, "plugins")); // Iterate built-in plugins - var builtInPluginDirectory = new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "Plugins")); - foreach (var subDirectory in builtInPluginDirectory.EnumerateDirectories()) + DirectoryInfo builtInPluginDirectory = new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "Plugins")); + foreach (DirectoryInfo subDirectory in builtInPluginDirectory.EnumerateDirectories()) { // Load the metadata - var builtInMetadataFile = Path.Combine(subDirectory.FullName, "plugin.json"); + string builtInMetadataFile = Path.Combine(subDirectory.FullName, "plugin.json"); if (!File.Exists(builtInMetadataFile)) throw new ArtemisPluginException("Couldn't find the built-in plugins metadata file at " + builtInMetadataFile); - var builtInPluginInfo = JsonConvert.DeserializeObject(File.ReadAllText(builtInMetadataFile)); + PluginInfo builtInPluginInfo = JsonConvert.DeserializeObject(File.ReadAllText(builtInMetadataFile)); // Find the matching plugin in the plugin folder - var match = pluginDirectory.EnumerateDirectories().FirstOrDefault(d => d.Name == subDirectory.Name); + DirectoryInfo match = pluginDirectory.EnumerateDirectories().FirstOrDefault(d => d.Name == subDirectory.Name); if (match == null) CopyBuiltInPlugin(subDirectory); else { - var metadataFile = Path.Combine(match.FullName, "plugin.json"); + string metadataFile = Path.Combine(match.FullName, "plugin.json"); if (!File.Exists(metadataFile)) { _logger.Debug("Copying missing built-in plugin {builtInPluginInfo}", builtInPluginInfo); @@ -74,7 +74,7 @@ namespace Artemis.Core.Services try { // Compare versions, copy if the same when debugging - var pluginInfo = JsonConvert.DeserializeObject(File.ReadAllText(metadataFile)); + PluginInfo pluginInfo = JsonConvert.DeserializeObject(File.ReadAllText(metadataFile)); #if DEBUG if (builtInPluginInfo.Version >= pluginInfo.Version) { @@ -111,17 +111,17 @@ namespace Artemis.Core.Services UnloadPlugins(); // Load the plugin assemblies into the plugin context - var pluginDirectory = new DirectoryInfo(Path.Combine(Constants.DataFolder, "plugins")); - foreach (var subDirectory in pluginDirectory.EnumerateDirectories()) + DirectoryInfo pluginDirectory = new DirectoryInfo(Path.Combine(Constants.DataFolder, "plugins")); + foreach (DirectoryInfo subDirectory in pluginDirectory.EnumerateDirectories()) { try { // Load the metadata - var metadataFile = Path.Combine(subDirectory.FullName, "plugin.json"); + string metadataFile = Path.Combine(subDirectory.FullName, "plugin.json"); if (!File.Exists(metadataFile)) _logger.Warning(new ArtemisPluginException("Couldn't find the plugins metadata file at " + metadataFile), "Plugin exception"); // Locate the main entry - var pluginInfo = JsonConvert.DeserializeObject(File.ReadAllText(metadataFile)); + PluginInfo pluginInfo = JsonConvert.DeserializeObject(File.ReadAllText(metadataFile)); pluginInfo.Directory = subDirectory; LoadPlugin(pluginInfo); @@ -133,7 +133,7 @@ namespace Artemis.Core.Services } // Activate plugins after they are all loaded - foreach (var pluginInfo in _plugins.Where(p => p.Enabled)) + foreach (PluginInfo pluginInfo in _plugins.Where(p => p.Enabled)) { try { @@ -172,14 +172,14 @@ namespace Artemis.Core.Services if (_plugins.Contains(pluginInfo)) UnloadPlugin(pluginInfo); - var pluginEntity = _pluginRepository.GetPluginByGuid(pluginInfo.Guid); + PluginEntity pluginEntity = _pluginRepository.GetPluginByGuid(pluginInfo.Guid); if (pluginEntity == null) pluginEntity = new PluginEntity {Id = pluginInfo.Guid, IsEnabled = true}; pluginInfo.PluginEntity = pluginEntity; pluginInfo.Enabled = pluginEntity.IsEnabled; - var mainFile = Path.Combine(pluginInfo.Directory.FullName, pluginInfo.Main); + string mainFile = Path.Combine(pluginInfo.Directory.FullName, pluginInfo.Main); if (!File.Exists(mainFile)) throw new ArtemisPluginException(pluginInfo, "Couldn't find the plugins main entry at " + mainFile); @@ -215,10 +215,10 @@ namespace Artemis.Core.Services if (pluginTypes.Count == 0) throw new ArtemisPluginException(pluginInfo, "Plugin contains no implementation of Plugin"); - var pluginType = pluginTypes.Single(); + Type pluginType = pluginTypes.Single(); try { - var parameters = new IParameter[] + IParameter[] parameters = new IParameter[] { new Parameter("PluginInfo", pluginInfo, false) }; @@ -365,8 +365,8 @@ namespace Artemis.Core.Services private static void CopyBuiltInPlugin(DirectoryInfo builtInPluginDirectory) { - var pluginDirectory = new DirectoryInfo(Path.Combine(Constants.DataFolder, "plugins", builtInPluginDirectory.Name)); - var createLockFile = File.Exists(Path.Combine(pluginDirectory.FullName, "artemis.lock")); + DirectoryInfo pluginDirectory = new DirectoryInfo(Path.Combine(Constants.DataFolder, "plugins", builtInPluginDirectory.Name)); + bool createLockFile = File.Exists(Path.Combine(pluginDirectory.FullName, "artemis.lock")); // Remove the old directory if it exists if (Directory.Exists(pluginDirectory.FullName)) diff --git a/src/Artemis.Core/Services/Registration/DataModelService.cs b/src/Artemis.Core/Services/Registration/DataModelService.cs index a66816fb6..58b57ac07 100644 --- a/src/Artemis.Core/Services/Registration/DataModelService.cs +++ b/src/Artemis.Core/Services/Registration/DataModelService.cs @@ -11,9 +11,9 @@ namespace Artemis.Core.Services public DataModelService(IPluginService pluginService) { // Add data models of already loaded plugins - foreach (var module in pluginService.GetPluginsOfType().Where(p => p.Enabled)) + foreach (Module module in pluginService.GetPluginsOfType().Where(p => p.Enabled)) AddModuleDataModel(module); - foreach (var dataModelExpansion in pluginService.GetPluginsOfType().Where(p => p.Enabled)) + foreach (BaseDataModelExpansion dataModelExpansion in pluginService.GetPluginsOfType().Where(p => p.Enabled)) AddDataModelExpansionDataModel(dataModelExpansion); // Add data models of new plugins when they get enabled diff --git a/src/Artemis.Core/Services/Registration/LayerBrushService.cs b/src/Artemis.Core/Services/Registration/LayerBrushService.cs index 8a3a69e55..0ddca99ec 100644 --- a/src/Artemis.Core/Services/Registration/LayerBrushService.cs +++ b/src/Artemis.Core/Services/Registration/LayerBrushService.cs @@ -36,7 +36,7 @@ namespace Artemis.Core.Services public LayerBrushDescriptor GetDefaultLayerBrush() { - var defaultReference = _settingsService.GetSetting("ProfileEditor.DefaultLayerBrushDescriptor", new LayerBrushReference + PluginSetting defaultReference = _settingsService.GetSetting("ProfileEditor.DefaultLayerBrushDescriptor", new LayerBrushReference { BrushPluginGuid = Guid.Parse("92a9d6ba-6f7a-4937-94d5-c1d715b4141a"), BrushType = "ColorBrush" diff --git a/src/Artemis.Core/Services/RgbService.cs b/src/Artemis.Core/Services/RgbService.cs index c80e36736..5d096e91f 100644 --- a/src/Artemis.Core/Services/RgbService.cs +++ b/src/Artemis.Core/Services/RgbService.cs @@ -64,7 +64,7 @@ namespace Artemis.Core.Services return; } - foreach (var surfaceDevice in deviceProvider.Devices) + foreach (IRGBDevice surfaceDevice in deviceProvider.Devices) { _logger.Debug("Device provider {deviceProvider} added {deviceName}", deviceProvider.GetType().Name, surfaceDevice.DeviceInfo?.DeviceName); diff --git a/src/Artemis.Core/Services/Storage/ProfileService.cs b/src/Artemis.Core/Services/Storage/ProfileService.cs index bfaadba7e..32512f627 100644 --- a/src/Artemis.Core/Services/Storage/ProfileService.cs +++ b/src/Artemis.Core/Services/Storage/ProfileService.cs @@ -38,13 +38,13 @@ namespace Artemis.Core.Services public List GetProfileDescriptors(ProfileModule module) { - var profileEntities = _profileRepository.GetByPluginGuid(module.PluginInfo.Guid); + List profileEntities = _profileRepository.GetByPluginGuid(module.PluginInfo.Guid); return profileEntities.Select(e => new ProfileDescriptor(module, e)).ToList(); } public ProfileDescriptor CreateProfileDescriptor(ProfileModule module, string name) { - var profileEntity = new ProfileEntity {Id = Guid.NewGuid(), Name = name, PluginGuid = module.PluginInfo.Guid}; + ProfileEntity profileEntity = new ProfileEntity {Id = Guid.NewGuid(), Name = name, PluginGuid = module.PluginInfo.Guid}; _profileRepository.Add(profileEntity); return new ProfileDescriptor(module, profileEntity); @@ -52,14 +52,14 @@ namespace Artemis.Core.Services public void ActivateLastProfile(ProfileModule profileModule) { - var activeProfile = GetLastActiveProfile(profileModule); + ProfileDescriptor activeProfile = GetLastActiveProfile(profileModule); if (activeProfile != null) ActivateProfile(activeProfile); } public async Task ActivateLastProfileAnimated(ProfileModule profileModule) { - var activeProfile = GetLastActiveProfile(profileModule); + ProfileDescriptor activeProfile = GetLastActiveProfile(profileModule); if (activeProfile != null) await ActivateProfileAnimated(activeProfile); } @@ -69,11 +69,11 @@ namespace Artemis.Core.Services if (profileDescriptor.ProfileModule.ActiveProfile?.EntityId == profileDescriptor.Id) return profileDescriptor.ProfileModule.ActiveProfile; - var profileEntity = _profileRepository.Get(profileDescriptor.Id); + ProfileEntity profileEntity = _profileRepository.Get(profileDescriptor.Id); if (profileEntity == null) throw new ArtemisCoreException($"Cannot find profile named: {profileDescriptor.Name} ID: {profileDescriptor.Id}"); - var profile = new Profile(profileDescriptor.ProfileModule, profileEntity); + Profile profile = new Profile(profileDescriptor.ProfileModule, profileEntity); InstantiateProfile(profile); profileDescriptor.ProfileModule.ChangeActiveProfile(profile, _surfaceService.ActiveSurface); @@ -87,11 +87,11 @@ namespace Artemis.Core.Services if (profileDescriptor.ProfileModule.ActiveProfile?.EntityId == profileDescriptor.Id) return profileDescriptor.ProfileModule.ActiveProfile; - var profileEntity = _profileRepository.Get(profileDescriptor.Id); + ProfileEntity profileEntity = _profileRepository.Get(profileDescriptor.Id); if (profileEntity == null) throw new ArtemisCoreException($"Cannot find profile named: {profileDescriptor.Name} ID: {profileDescriptor.Id}"); - var profile = new Profile(profileDescriptor.ProfileModule, profileEntity); + Profile profile = new Profile(profileDescriptor.ProfileModule, profileEntity); InstantiateProfile(profile); void ActivatingProfileSurfaceUpdate(object sender, SurfaceConfigurationEventArgs e) @@ -146,23 +146,23 @@ namespace Artemis.Core.Services public void DeleteProfile(ProfileDescriptor profileDescriptor) { - var profileEntity = _profileRepository.Get(profileDescriptor.Id); + ProfileEntity profileEntity = _profileRepository.Get(profileDescriptor.Id); _profileRepository.Remove(profileEntity); } public void UpdateProfile(Profile profile, bool includeChildren) { _logger.Debug("Updating profile " + profile); - var memento = JsonConvert.SerializeObject(profile.ProfileEntity, MementoSettings); + string memento = JsonConvert.SerializeObject(profile.ProfileEntity, MementoSettings); profile.RedoStack.Clear(); profile.UndoStack.Push(memento); profile.Save(); if (includeChildren) { - foreach (var folder in profile.GetAllFolders()) + foreach (Folder folder in profile.GetAllFolders()) folder.Save(); - foreach (var layer in profile.GetAllLayers()) + foreach (Layer layer in profile.GetAllLayers()) layer.Save(); } @@ -180,8 +180,8 @@ namespace Artemis.Core.Services return false; } - var top = profile.UndoStack.Pop(); - var memento = JsonConvert.SerializeObject(profile.ProfileEntity, MementoSettings); + string top = profile.UndoStack.Pop(); + string memento = JsonConvert.SerializeObject(profile.ProfileEntity, MementoSettings); profile.RedoStack.Push(memento); profile.ProfileEntity = JsonConvert.DeserializeObject(top, MementoSettings); @@ -204,8 +204,8 @@ namespace Artemis.Core.Services return false; } - var top = profile.RedoStack.Pop(); - var memento = JsonConvert.SerializeObject(profile.ProfileEntity, MementoSettings); + string top = profile.RedoStack.Pop(); + string memento = JsonConvert.SerializeObject(profile.ProfileEntity, MementoSettings); profile.UndoStack.Push(memento); profile.ProfileEntity = JsonConvert.DeserializeObject(top, MementoSettings); @@ -224,7 +224,7 @@ namespace Artemis.Core.Services public string ExportProfile(ProfileDescriptor profileDescriptor) { - var profileEntity = _profileRepository.Get(profileDescriptor.Id); + ProfileEntity profileEntity = _profileRepository.Get(profileDescriptor.Id); if (profileEntity == null) throw new ArtemisCoreException($"Cannot find profile named: {profileDescriptor.Name} ID: {profileDescriptor.Id}"); @@ -233,7 +233,7 @@ namespace Artemis.Core.Services public ProfileDescriptor ImportProfile(string json, ProfileModule profileModule) { - var profileEntity = JsonConvert.DeserializeObject(json, ExportSettings); + ProfileEntity profileEntity = JsonConvert.DeserializeObject(json, ExportSettings); // Assign a new GUID to make sure it is unique in case of a previous import of the same content profileEntity.UpdateGuid(Guid.NewGuid()); @@ -245,11 +245,11 @@ namespace Artemis.Core.Services public ProfileDescriptor GetLastActiveProfile(ProfileModule module) { - var moduleProfiles = _profileRepository.GetByPluginGuid(module.PluginInfo.Guid); + List moduleProfiles = _profileRepository.GetByPluginGuid(module.PluginInfo.Guid); if (!moduleProfiles.Any()) return CreateProfileDescriptor(module, "Default"); - var profileEntity = moduleProfiles.FirstOrDefault(p => p.IsActive) ?? moduleProfiles.FirstOrDefault(); + ProfileEntity profileEntity = moduleProfiles.FirstOrDefault(p => p.IsActive) ?? moduleProfiles.FirstOrDefault(); return profileEntity == null ? null : new ProfileDescriptor(module, profileEntity); } @@ -258,8 +258,8 @@ namespace Artemis.Core.Services if (module.ActiveProfile == null) return; - var profileEntities = _profileRepository.GetByPluginGuid(module.PluginInfo.Guid); - foreach (var profileEntity in profileEntities) + List profileEntities = _profileRepository.GetByPluginGuid(module.PluginInfo.Guid); + foreach (ProfileEntity profileEntity in profileEntities) { profileEntity.IsActive = module.ActiveProfile.EntityId == profileEntity.Id; _profileRepository.Save(profileEntity); @@ -272,8 +272,8 @@ namespace Artemis.Core.Services /// private void ActiveProfilesPopulateLeds(ArtemisSurface surface) { - var profileModules = _pluginService.GetPluginsOfType(); - foreach (var profileModule in profileModules.Where(p => p.ActiveProfile != null).ToList()) + List profileModules = _pluginService.GetPluginsOfType(); + foreach (ProfileModule profileModule in profileModules.Where(p => p.ActiveProfile != null).ToList()) profileModule.ActiveProfile.PopulateLeds(surface); } diff --git a/src/Artemis.Core/Services/Storage/SurfaceService.cs b/src/Artemis.Core/Services/Storage/SurfaceService.cs index 37529e595..4b6a97880 100644 --- a/src/Artemis.Core/Services/Storage/SurfaceService.cs +++ b/src/Artemis.Core/Services/Storage/SurfaceService.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; +using Artemis.Storage.Entities.Surface; using Artemis.Storage.Repositories.Interfaces; using RGB.NET.Core; using Serilog; @@ -38,12 +39,12 @@ namespace Artemis.Core.Services public ArtemisSurface CreateSurfaceConfiguration(string name) { // Create a blank config - var configuration = new ArtemisSurface(_rgbService.Surface, name, _renderScaleSetting.Value); + ArtemisSurface configuration = new ArtemisSurface(_rgbService.Surface, name, _renderScaleSetting.Value); // Add all current devices - foreach (var rgbDevice in _rgbService.LoadedDevices) + foreach (IRGBDevice rgbDevice in _rgbService.LoadedDevices) { - var plugin = _pluginService.GetPluginByDevice(rgbDevice); + Plugin plugin = _pluginService.GetPluginByDevice(rgbDevice); configuration.Devices.Add(new ArtemisDevice(rgbDevice, plugin, configuration)); } @@ -69,7 +70,7 @@ namespace Artemis.Core.Services lock (_surfaceConfigurations) { // Mark only the new surface as active - foreach (var configuration in _surfaceConfigurations) + foreach (ArtemisSurface configuration in _surfaceConfigurations) { configuration.IsActive = configuration == ActiveSurface; configuration.ApplyToEntity(); @@ -81,7 +82,7 @@ namespace Artemis.Core.Services // Apply the active surface entity to the devices if (ActiveSurface != null) { - foreach (var device in ActiveSurface.Devices) + foreach (ArtemisDevice device in ActiveSurface.Devices) device.ApplyToRgbDevice(); } @@ -95,7 +96,7 @@ namespace Artemis.Core.Services surface.ApplyToEntity(); if (includeDevices) { - foreach (var deviceConfiguration in surface.Devices) + foreach (ArtemisDevice deviceConfiguration in surface.Devices) { deviceConfiguration.ApplyToEntity(); if (surface.IsActive) @@ -115,7 +116,7 @@ namespace Artemis.Core.Services lock (_surfaceConfigurations) { - var entity = surface.SurfaceEntity; + SurfaceEntity entity = surface.SurfaceEntity; _surfaceConfigurations.Remove(surface); _surfaceRepository.Remove(entity); } @@ -125,17 +126,17 @@ namespace Artemis.Core.Services private void LoadFromRepository() { - var configs = _surfaceRepository.GetAll(); - foreach (var surfaceEntity in configs) + List configs = _surfaceRepository.GetAll(); + foreach (SurfaceEntity surfaceEntity in configs) { // Create the surface entity - var surfaceConfiguration = new ArtemisSurface(_rgbService.Surface, surfaceEntity, _renderScaleSetting.Value); - foreach (var position in surfaceEntity.DeviceEntities) + ArtemisSurface surfaceConfiguration = new ArtemisSurface(_rgbService.Surface, surfaceEntity, _renderScaleSetting.Value); + foreach (DeviceEntity position in surfaceEntity.DeviceEntities) { - var device = _rgbService.Surface.Devices.FirstOrDefault(d => d.GetDeviceIdentifier() == position.DeviceIdentifier); + IRGBDevice device = _rgbService.Surface.Devices.FirstOrDefault(d => d.GetDeviceIdentifier() == position.DeviceIdentifier); if (device != null) { - var plugin = _pluginService.GetPluginByDevice(device); + Plugin plugin = _pluginService.GetPluginByDevice(device); surfaceConfiguration.Devices.Add(new ArtemisDevice(device, plugin, surfaceConfiguration, position)); } } @@ -148,7 +149,7 @@ namespace Artemis.Core.Services } // When all surface configs are loaded, apply the active surface config - var active = SurfaceConfigurations.FirstOrDefault(c => c.IsActive); + ArtemisSurface active = SurfaceConfigurations.FirstOrDefault(c => c.IsActive); if (active != null) SetActiveSurfaceConfiguration(active); else @@ -167,17 +168,17 @@ namespace Artemis.Core.Services private void AddDeviceIfMissing(IRGBDevice rgbDevice, ArtemisSurface surface) { - var deviceIdentifier = rgbDevice.GetDeviceIdentifier(); - var device = surface.Devices.FirstOrDefault(d => d.DeviceEntity.DeviceIdentifier == deviceIdentifier); + string deviceIdentifier = rgbDevice.GetDeviceIdentifier(); + ArtemisDevice device = surface.Devices.FirstOrDefault(d => d.DeviceEntity.DeviceIdentifier == deviceIdentifier); if (device != null) return; // Find an existing device config and use that - var existingDeviceConfig = surface.SurfaceEntity.DeviceEntities.FirstOrDefault(d => d.DeviceIdentifier == deviceIdentifier); + DeviceEntity existingDeviceConfig = surface.SurfaceEntity.DeviceEntities.FirstOrDefault(d => d.DeviceIdentifier == deviceIdentifier); if (existingDeviceConfig != null) { - var plugin = _pluginService.GetPluginByDevice(rgbDevice); + Plugin plugin = _pluginService.GetPluginByDevice(rgbDevice); device = new ArtemisDevice(rgbDevice, plugin, surface, existingDeviceConfig); } // Fall back on creating a new device @@ -188,7 +189,7 @@ namespace Artemis.Core.Services rgbDevice.DeviceInfo, deviceIdentifier ); - var plugin = _pluginService.GetPluginByDevice(rgbDevice); + Plugin plugin = _pluginService.GetPluginByDevice(rgbDevice); device = new ArtemisDevice(rgbDevice, plugin, surface); } @@ -203,7 +204,7 @@ namespace Artemis.Core.Services { lock (_surfaceConfigurations) { - foreach (var surfaceConfiguration in _surfaceConfigurations) + foreach (ArtemisSurface surfaceConfiguration in _surfaceConfigurations) AddDeviceIfMissing(e.Device, surfaceConfiguration); } @@ -212,7 +213,7 @@ namespace Artemis.Core.Services private void RenderScaleSettingOnSettingChanged(object sender, EventArgs e) { - foreach (var surfaceConfiguration in SurfaceConfigurations) + foreach (ArtemisSurface surfaceConfiguration in SurfaceConfigurations) { surfaceConfiguration.UpdateScale(_renderScaleSetting.Value); OnSurfaceConfigurationUpdated(new SurfaceConfigurationEventArgs(surfaceConfiguration)); diff --git a/src/Artemis.Core/Stores/ConditionOperatorStore.cs b/src/Artemis.Core/Stores/ConditionOperatorStore.cs index 0ee90cdd5..f7d49161d 100644 --- a/src/Artemis.Core/Stores/ConditionOperatorStore.cs +++ b/src/Artemis.Core/Stores/ConditionOperatorStore.cs @@ -53,13 +53,13 @@ namespace Artemis.Core if (type == null) return new List(Registrations); - var candidates = Registrations.Where(r => r.ConditionOperator.CompatibleTypes.Any(t => t.IsCastableFrom(type))).ToList(); + List candidates = Registrations.Where(r => r.ConditionOperator.CompatibleTypes.Any(t => t.IsCastableFrom(type))).ToList(); // If there are multiple operators with the same description, use the closest match - foreach (var candidate in candidates.GroupBy(r => r.ConditionOperator.Description).Where(g => g.Count() > 1).ToList()) + foreach (IGrouping candidate in candidates.GroupBy(r => r.ConditionOperator.Description).Where(g => g.Count() > 1).ToList()) { - var closest = candidate.OrderByDescending(r => r.ConditionOperator.CompatibleTypes.Contains(type)).FirstOrDefault(); - foreach (var conditionOperator in candidate) + ConditionOperatorRegistration closest = candidate.OrderByDescending(r => r.ConditionOperator.CompatibleTypes.Contains(type)).FirstOrDefault(); + foreach (ConditionOperatorRegistration conditionOperator in candidate) { if (conditionOperator != closest) candidates.Remove(conditionOperator); diff --git a/src/Artemis.Core/Stores/DataBindingModifierTypeStore.cs b/src/Artemis.Core/Stores/DataBindingModifierTypeStore.cs index faa26230a..3536bdb8d 100644 --- a/src/Artemis.Core/Stores/DataBindingModifierTypeStore.cs +++ b/src/Artemis.Core/Stores/DataBindingModifierTypeStore.cs @@ -53,13 +53,13 @@ namespace Artemis.Core if (type == null) return new List(Registrations); - var candidates = Registrations.Where(r => r.DataBindingModifierType.CompatibleTypes.Any(t => t == type)).ToList(); + List candidates = Registrations.Where(r => r.DataBindingModifierType.CompatibleTypes.Any(t => t == type)).ToList(); // If there are multiple operators with the same description, use the closest match - foreach (var displayDataBindingModifiers in candidates.GroupBy(r => r.DataBindingModifierType.Name).Where(g => g.Count() > 1).ToList()) + foreach (IGrouping displayDataBindingModifiers in candidates.GroupBy(r => r.DataBindingModifierType.Name).Where(g => g.Count() > 1).ToList()) { - var closest = displayDataBindingModifiers.OrderByDescending(r => r.DataBindingModifierType.CompatibleTypes.Contains(type)).FirstOrDefault(); - foreach (var displayDataBindingModifier in displayDataBindingModifiers) + DataBindingModifierTypeRegistration closest = displayDataBindingModifiers.OrderByDescending(r => r.DataBindingModifierType.CompatibleTypes.Contains(type)).FirstOrDefault(); + foreach (DataBindingModifierTypeRegistration displayDataBindingModifier in displayDataBindingModifiers) { if (displayDataBindingModifier != closest) candidates.Remove(displayDataBindingModifier); diff --git a/src/Artemis.Core/Utilities/CurrentProcessUtilities.cs b/src/Artemis.Core/Utilities/CurrentProcessUtilities.cs index 5674cb888..9e49da20c 100644 --- a/src/Artemis.Core/Utilities/CurrentProcessUtilities.cs +++ b/src/Artemis.Core/Utilities/CurrentProcessUtilities.cs @@ -21,12 +21,12 @@ namespace Artemis.Core public static void Shutdown(int delay, bool restart) { // Always kill the process after the delay has passed, with all the plugins a graceful shutdown cannot be guaranteed - var arguments = "-Command \"& {Start-Sleep -s " + delay + "; (Get-Process 'Artemis.UI').kill()}"; + string arguments = "-Command \"& {Start-Sleep -s " + delay + "; (Get-Process 'Artemis.UI').kill()}"; // If restart is required, start the executable again after the process was killed if (restart) arguments = "-Command \"& {Start-Sleep -s " + delay + "; (Get-Process 'Artemis.UI').kill(); Start-Process -FilePath '" + Process.GetCurrentProcess().MainModule.FileName + "'}\""; - var info = new ProcessStartInfo + ProcessStartInfo info = new ProcessStartInfo { Arguments = arguments, WindowStyle = ProcessWindowStyle.Hidden, diff --git a/src/Artemis.Core/Utilities/Easings.cs b/src/Artemis.Core/Utilities/Easings.cs index c26da8f76..3bffa45ed 100644 --- a/src/Artemis.Core/Utilities/Easings.cs +++ b/src/Artemis.Core/Utilities/Easings.cs @@ -106,7 +106,7 @@ namespace Artemis.Core /// public static double CubicEaseOut(double p) { - var f = p - 1; + double f = p - 1; return f * f * f + 1; } @@ -119,7 +119,7 @@ namespace Artemis.Core { if (p < 0.5) return 4 * p * p * p; - var f = 2 * p - 2; + double f = 2 * p - 2; return 0.5 * f * f * f + 1; } @@ -136,7 +136,7 @@ namespace Artemis.Core /// public static double QuarticEaseOut(double p) { - var f = p - 1; + double f = p - 1; return f * f * f * (1 - p) + 1; } @@ -149,7 +149,7 @@ namespace Artemis.Core { if (p < 0.5) return 8 * p * p * p * p; - var f = p - 1; + double f = p - 1; return -8 * f * f * f * f + 1; } @@ -166,7 +166,7 @@ namespace Artemis.Core /// public static double QuinticEaseOut(double p) { - var f = p - 1; + double f = p - 1; return f * f * f * f * f + 1; } @@ -179,7 +179,7 @@ namespace Artemis.Core { if (p < 0.5) return 16 * p * p * p * p * p; - var f = 2 * p - 2; + double f = 2 * p - 2; return 0.5 * f * f * f * f * f + 1; } @@ -306,7 +306,7 @@ namespace Artemis.Core /// public static double BackEaseOut(double p) { - var f = 1 - p; + double f = 1 - p; return 1 - (f * f * f - f * Math.Sin(f * PI)); } @@ -319,12 +319,12 @@ namespace Artemis.Core { if (p < 0.5) { - var f = 2 * p; + double f = 2 * p; return 0.5 * (f * f * f - f * Math.Sin(f * PI)); } else { - var f = 1 - (2 * p - 1); + double f = 1 - (2 * p - 1); return 0.5 * (1 - (f * f * f - f * Math.Sin(f * PI))) + 0.5; } } diff --git a/src/Artemis.Core/Utilities/ExpressionUtilities.cs b/src/Artemis.Core/Utilities/ExpressionUtilities.cs index ca43a078f..12a0a31a8 100644 --- a/src/Artemis.Core/Utilities/ExpressionUtilities.cs +++ b/src/Artemis.Core/Utilities/ExpressionUtilities.cs @@ -20,9 +20,9 @@ namespace Artemis.Core // Create an expression that checks every part of the path for null // In the same iteration, create the accessor Expression condition = null; - foreach (var memberName in path.Split('.')) + foreach (string memberName in path.Split('.')) { - var notNull = Expression.NotEqual(source, Expression.Constant(null)); + BinaryExpression notNull = Expression.NotEqual(source, Expression.Constant(null)); condition = condition != null ? Expression.AndAlso(condition, notNull) : notNull; source = Expression.PropertyOrField(source, memberName); } diff --git a/src/Artemis.Core/Utilities/IntroAnimation.cs b/src/Artemis.Core/Utilities/IntroAnimation.cs index 745e3a063..63008a8dc 100644 --- a/src/Artemis.Core/Utilities/IntroAnimation.cs +++ b/src/Artemis.Core/Utilities/IntroAnimation.cs @@ -40,10 +40,10 @@ namespace Artemis.Core try { // Load the intro profile from JSON into a ProfileEntity - var json = File.ReadAllText(Path.Combine(Constants.ApplicationFolder, "Resources", "intro-profile.json")); - var profileEntity = JsonConvert.DeserializeObject(json); + string json = File.ReadAllText(Path.Combine(Constants.ApplicationFolder, "Resources", "intro-profile.json")); + ProfileEntity profileEntity = JsonConvert.DeserializeObject(json); // Inject every LED on the surface into each layer - foreach (var profileEntityLayer in profileEntity.Layers) + foreach (LayerEntity profileEntityLayer in profileEntity.Layers) { profileEntityLayer.Leds.AddRange(_surfaceService.ActiveSurface.Devices.SelectMany(d => d.Leds).Select(l => new LedEntity { @@ -52,7 +52,7 @@ namespace Artemis.Core })); } - var profile = new Profile(new DummyModule(), profileEntity); + Profile profile = new Profile(new DummyModule(), profileEntity); profile.Activate(_surfaceService.ActiveSurface); _profileService.InstantiateProfile(profile); diff --git a/src/Artemis.Core/Utilities/ReflectionUtilities.cs b/src/Artemis.Core/Utilities/ReflectionUtilities.cs index 17be2320e..7816f36bb 100644 --- a/src/Artemis.Core/Utilities/ReflectionUtilities.cs +++ b/src/Artemis.Core/Utilities/ReflectionUtilities.cs @@ -8,13 +8,13 @@ namespace Artemis.Core { public static PropertyInfo GetPropertyInfo(TSource source, Expression> propertyLambda) { - var type = typeof(TSource); + Type type = typeof(TSource); - var member = propertyLambda.Body as MemberExpression; + MemberExpression member = propertyLambda.Body as MemberExpression; if (member == null) throw new ArgumentException(string.Format("Expression '{0}' refers to a method, not a property.", propertyLambda)); - var propInfo = member.Member as PropertyInfo; + PropertyInfo propInfo = member.Member as PropertyInfo; if (propInfo == null) throw new ArgumentException(string.Format("Expression '{0}' refers to a field, not a property.", propertyLambda)); diff --git a/src/Artemis.Storage/Entities/Profile/ProfileEntity.cs b/src/Artemis.Storage/Entities/Profile/ProfileEntity.cs index 3b16cc67f..ecd08497b 100644 --- a/src/Artemis.Storage/Entities/Profile/ProfileEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/ProfileEntity.cs @@ -23,10 +23,10 @@ namespace Artemis.Storage.Entities.Profile public void UpdateGuid(Guid guid) { - var oldGuid = Id; + Guid oldGuid = Id; Id = guid; - var rootFolder = Folders.FirstOrDefault(f => f.ParentId == oldGuid); + FolderEntity rootFolder = Folders.FirstOrDefault(f => f.ParentId == oldGuid); if (rootFolder != null) rootFolder.ParentId = Id; } diff --git a/src/Artemis.Storage/Migrations/M2ProfileEntitiesEnabledMigration.cs b/src/Artemis.Storage/Migrations/M2ProfileEntitiesEnabledMigration.cs index 8a0c809a9..e37a48776 100644 --- a/src/Artemis.Storage/Migrations/M2ProfileEntitiesEnabledMigration.cs +++ b/src/Artemis.Storage/Migrations/M2ProfileEntitiesEnabledMigration.cs @@ -1,4 +1,5 @@ -using Artemis.Storage.Entities.Profile; +using System.Collections.Generic; +using Artemis.Storage.Entities.Profile; using Artemis.Storage.Migrations.Interfaces; using LiteDB; @@ -10,20 +11,20 @@ namespace Artemis.Storage.Migrations public void Apply(LiteRepository repository) { - var profiles = repository.Query().ToList(); - foreach (var profileEntity in profiles) + List profiles = repository.Query().ToList(); + foreach (ProfileEntity profileEntity in profiles) { - foreach (var profileEntityFolder in profileEntity.Folders) + foreach (FolderEntity profileEntityFolder in profileEntity.Folders) { profileEntityFolder.Enabled = true; - foreach (var layerEffectEntity in profileEntityFolder.LayerEffects) + foreach (LayerEffectEntity layerEffectEntity in profileEntityFolder.LayerEffects) layerEffectEntity.Enabled = true; } - foreach (var profileEntityLayer in profileEntity.Layers) + foreach (LayerEntity profileEntityLayer in profileEntity.Layers) { profileEntityLayer.Enabled = true; - foreach (var layerEffectEntity in profileEntityLayer.LayerEffects) + foreach (LayerEffectEntity layerEffectEntity in profileEntityLayer.LayerEffects) layerEffectEntity.Enabled = true; } diff --git a/src/Artemis.Storage/Migrations/M4ProfileSegments.cs b/src/Artemis.Storage/Migrations/M4ProfileSegments.cs index b8d07325e..d5c85542e 100644 --- a/src/Artemis.Storage/Migrations/M4ProfileSegments.cs +++ b/src/Artemis.Storage/Migrations/M4ProfileSegments.cs @@ -2,6 +2,7 @@ using Artemis.Storage.Migrations.Interfaces; using LiteDB; using System; +using System.Collections.Generic; using System.Linq; namespace Artemis.Storage.Migrations @@ -12,10 +13,10 @@ namespace Artemis.Storage.Migrations public void Apply(LiteRepository repository) { - var profiles = repository.Query().ToList(); - foreach (var profileEntity in profiles) + List profiles = repository.Query().ToList(); + foreach (ProfileEntity profileEntity in profiles) { - foreach (var folder in profileEntity.Folders.Where(f => f.MainSegmentLength == TimeSpan.Zero)) + foreach (FolderEntity folder in profileEntity.Folders.Where(f => f.MainSegmentLength == TimeSpan.Zero)) { if (folder.PropertyEntities.Any(p => p.KeyframeEntities.Any())) folder.MainSegmentLength = folder.PropertyEntities.Where(p => p.KeyframeEntities.Any()).Max(p => p.KeyframeEntities.Max(k => k.Position)); @@ -25,7 +26,7 @@ namespace Artemis.Storage.Migrations folder.DisplayContinuously = true; } - foreach (var layer in profileEntity.Layers.Where(l => l.MainSegmentLength == TimeSpan.Zero)) + foreach (LayerEntity layer in profileEntity.Layers.Where(l => l.MainSegmentLength == TimeSpan.Zero)) { if (layer.PropertyEntities.Any(p => p.KeyframeEntities.Any())) layer.MainSegmentLength = layer.PropertyEntities.Where(p => p.KeyframeEntities.Any()).Max(p => p.KeyframeEntities.Max(k => k.Position)); diff --git a/src/Artemis.Storage/Migrations/M5DataBindingTypes.cs b/src/Artemis.Storage/Migrations/M5DataBindingTypes.cs index daede9a17..7bc4bcff6 100644 --- a/src/Artemis.Storage/Migrations/M5DataBindingTypes.cs +++ b/src/Artemis.Storage/Migrations/M5DataBindingTypes.cs @@ -9,18 +9,18 @@ namespace Artemis.Storage.Migrations public void Apply(LiteRepository repository) { - var collection = repository.Database.GetCollection("ProfileEntity"); - foreach (var bsonDocument in collection.FindAll()) + ILiteCollection collection = repository.Database.GetCollection("ProfileEntity"); + foreach (BsonDocument bsonDocument in collection.FindAll()) { - foreach (var bsonLayer in bsonDocument["Layers"].AsArray) + foreach (BsonValue bsonLayer in bsonDocument["Layers"].AsArray) { - foreach (var bsonPropertyEntity in bsonLayer["PropertyEntities"].AsArray) + foreach (BsonValue bsonPropertyEntity in bsonLayer["PropertyEntities"].AsArray) bsonPropertyEntity["DataBindingEntities"].AsArray.Clear(); } - foreach (var bsonLayer in bsonDocument["Folders"].AsArray) + foreach (BsonValue bsonLayer in bsonDocument["Folders"].AsArray) { - foreach (var bsonPropertyEntity in bsonLayer["PropertyEntities"].AsArray) + foreach (BsonValue bsonPropertyEntity in bsonLayer["PropertyEntities"].AsArray) bsonPropertyEntity["DataBindingEntities"].AsArray.Clear(); } diff --git a/src/Artemis.Storage/StorageMigrationService.cs b/src/Artemis.Storage/StorageMigrationService.cs index d0105ea4c..dc71f6542 100644 --- a/src/Artemis.Storage/StorageMigrationService.cs +++ b/src/Artemis.Storage/StorageMigrationService.cs @@ -23,7 +23,7 @@ namespace Artemis.Storage public void ApplyPendingMigrations() { - foreach (var storageMigration in _migrations.OrderBy(m => m.UserVersion)) + foreach (IStorageMigration storageMigration in _migrations.OrderBy(m => m.UserVersion)) { if (_repository.Database.UserVersion >= storageMigration.UserVersion) continue; diff --git a/src/Artemis.UI.Shared/Bootstrapper.cs b/src/Artemis.UI.Shared/Bootstrapper.cs index a4535542e..b5b158816 100644 --- a/src/Artemis.UI.Shared/Bootstrapper.cs +++ b/src/Artemis.UI.Shared/Bootstrapper.cs @@ -12,7 +12,7 @@ namespace Artemis.UI.Shared if (Initialized) return; - var colorPickerService = kernel.Get(); + IColorPickerService colorPickerService = kernel.Get(); GradientPicker.ColorPickerService = colorPickerService; ColorPicker.ColorPickerService = colorPickerService; diff --git a/src/Artemis.UI.Shared/Controls/ColorPicker.xaml.cs b/src/Artemis.UI.Shared/Controls/ColorPicker.xaml.cs index bf0cc3527..106aca5b5 100644 --- a/src/Artemis.UI.Shared/Controls/ColorPicker.xaml.cs +++ b/src/Artemis.UI.Shared/Controls/ColorPicker.xaml.cs @@ -97,7 +97,7 @@ namespace Artemis.UI.Shared private static void ColorPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var colorPicker = (ColorPicker) d; + ColorPicker colorPicker = (ColorPicker) d; if (colorPicker._inCallback) return; @@ -112,7 +112,7 @@ namespace Artemis.UI.Shared private static void PopupOpenPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var colorPicker = (ColorPicker) d; + ColorPicker colorPicker = (ColorPicker) d; if (colorPicker._inCallback) return; @@ -123,7 +123,7 @@ namespace Artemis.UI.Shared private static void StaysOpenPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var colorPicker = (ColorPicker) d; + ColorPicker colorPicker = (ColorPicker) d; if (colorPicker._inCallback) return; @@ -134,13 +134,13 @@ namespace Artemis.UI.Shared private static void ColorOpacityPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var colorPicker = (ColorPicker) d; + ColorPicker colorPicker = (ColorPicker) d; if (colorPicker._inCallback) return; colorPicker._inCallback = true; - var color = colorPicker.Color; + Color color = colorPicker.Color; if (e.NewValue is byte opacity) color = Color.FromArgb(opacity, color.R, color.G, color.B); colorPicker.SetCurrentValue(ColorProperty, color); diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs index c41b1f824..e833d3479 100644 --- a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs +++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs @@ -97,9 +97,9 @@ namespace Artemis.UI.Shared return; // Determine the scale required to fit the desired size of the control - var measureSize = MeasureDevice(); - var scale = Math.Min(DesiredSize.Width / measureSize.Width, DesiredSize.Height / measureSize.Height); - var scaledRect = new Rect(0, 0, measureSize.Width * scale, measureSize.Height * scale); + Size measureSize = MeasureDevice(); + double scale = Math.Min(DesiredSize.Width / measureSize.Width, DesiredSize.Height / measureSize.Height); + Rect scaledRect = new Rect(0, 0, measureSize.Width * scale, measureSize.Height * scale); // Center and scale the visualization in the desired bounding box if (DesiredSize.Width > 0 && DesiredSize.Height > 0) @@ -109,7 +109,7 @@ namespace Artemis.UI.Shared } // Determine the offset required to rotate within bounds - var rotationRect = new Rect(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height); + Rect rotationRect = new Rect(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height); rotationRect.Transform(new RotateTransform(Device.Rotation).Value); // Apply device rotation @@ -123,7 +123,7 @@ namespace Artemis.UI.Shared if (_deviceImage != null) drawingContext.DrawImage(_deviceImage, new Rect(0, 0, Device.RgbDevice.Size.Width, Device.RgbDevice.Size.Height)); - foreach (var deviceVisualizerLed in _deviceVisualizerLeds) + foreach (DeviceVisualizerLed deviceVisualizerLed in _deviceVisualizerLeds) deviceVisualizerLed.RenderImage(drawingContext); drawingContext.DrawDrawing(_backingStore); @@ -135,7 +135,7 @@ namespace Artemis.UI.Shared if (Device == null) return Size.Empty; - var deviceSize = MeasureDevice(); + Size deviceSize = MeasureDevice(); if (deviceSize.Width <= 0 || deviceSize.Height <= 0) return Size.Empty; @@ -162,7 +162,7 @@ namespace Artemis.UI.Shared if (Device == null) return Size.Empty; - var rotationRect = new Rect(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height); + Rect rotationRect = new Rect(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height); rotationRect.Transform(new RotateTransform(Device.Rotation).Value); return rotationRect.Size; @@ -198,13 +198,13 @@ namespace Artemis.UI.Shared private static void DevicePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var deviceVisualizer = (DeviceVisualizer) d; + DeviceVisualizer deviceVisualizer = (DeviceVisualizer) d; deviceVisualizer.Dispatcher.Invoke(() => { deviceVisualizer.SetupForDevice(); }); } private static void ShowColorsPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var deviceVisualizer = (DeviceVisualizer) d; + DeviceVisualizer deviceVisualizer = (DeviceVisualizer) d; deviceVisualizer.Dispatcher.Invoke(() => { deviceVisualizer.SetupForDevice(); }); } @@ -228,7 +228,7 @@ namespace Artemis.UI.Shared _deviceImage = new BitmapImage(Device.RgbDevice.DeviceInfo.Image); // Create all the LEDs - foreach (var artemisLed in Device.Leds) + foreach (ArtemisLed artemisLed in Device.Leds) _deviceVisualizerLeds.Add(new DeviceVisualizerLed(artemisLed)); if (!ShowColors) @@ -238,16 +238,16 @@ namespace Artemis.UI.Shared } // Create the opacity drawing group - var opacityDrawingGroup = new DrawingGroup(); - var drawingContext = opacityDrawingGroup.Open(); - foreach (var deviceVisualizerLed in _deviceVisualizerLeds) + DrawingGroup opacityDrawingGroup = new DrawingGroup(); + DrawingContext drawingContext = opacityDrawingGroup.Open(); + foreach (DeviceVisualizerLed deviceVisualizerLed in _deviceVisualizerLeds) deviceVisualizerLed.RenderOpacityMask(drawingContext); drawingContext.Close(); // Render the store as a bitmap - var drawingImage = new DrawingImage(opacityDrawingGroup); - var image = new Image {Source = drawingImage}; - var bitmap = new RenderTargetBitmap( + DrawingImage drawingImage = new DrawingImage(opacityDrawingGroup); + Image image = new Image {Source = drawingImage}; + RenderTargetBitmap bitmap = new RenderTargetBitmap( Math.Max(1, (int) (opacityDrawingGroup.Bounds.Width * 2.5)), Math.Max(1, (int) (opacityDrawingGroup.Bounds.Height * 2.5)), 96, @@ -259,7 +259,7 @@ namespace Artemis.UI.Shared bitmap.Freeze(); // Set the bitmap as the opacity mask for the colors backing store - var bitmapBrush = new ImageBrush(bitmap); + ImageBrush bitmapBrush = new ImageBrush(bitmap); bitmapBrush.Freeze(); _backingStore.OpacityMask = bitmapBrush; @@ -275,16 +275,16 @@ namespace Artemis.UI.Shared private void Render() { - var drawingContext = _backingStore.Open(); + DrawingContext drawingContext = _backingStore.Open(); if (HighlightedLeds != null && HighlightedLeds.Any()) { - foreach (var deviceVisualizerLed in _deviceVisualizerLeds) + foreach (DeviceVisualizerLed deviceVisualizerLed in _deviceVisualizerLeds) deviceVisualizerLed.RenderColor(drawingContext, !HighlightedLeds.Contains(deviceVisualizerLed.Led)); } else { - foreach (var deviceVisualizerLed in _deviceVisualizerLeds) + foreach (DeviceVisualizerLed deviceVisualizerLed in _deviceVisualizerLeds) deviceVisualizerLed.RenderColor(drawingContext, false); } diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs index a607d40c2..4635ce727 100644 --- a/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs +++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs @@ -39,9 +39,9 @@ namespace Artemis.UI.Shared if (DisplayGeometry == null) return; - var r = Led.RgbLed.Color.GetR(); - var g = Led.RgbLed.Color.GetG(); - var b = Led.RgbLed.Color.GetB(); + byte r = Led.RgbLed.Color.GetR(); + byte g = Led.RgbLed.Color.GetG(); + byte b = Led.RgbLed.Color.GetB(); drawingContext.DrawRectangle(isDimmed ? new SolidColorBrush(Color.FromArgb(100, r, g, b)) @@ -61,9 +61,9 @@ namespace Artemis.UI.Shared if (DisplayGeometry == null) return; - var fillBrush = new SolidColorBrush(Color.FromArgb(100, 255, 255, 255)); + SolidColorBrush fillBrush = new SolidColorBrush(Color.FromArgb(100, 255, 255, 255)); fillBrush.Freeze(); - var penBrush = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)); + SolidColorBrush penBrush = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)); penBrush.Freeze(); // Create transparent pixels covering the entire LedRect so the image size matched the LedRect size diff --git a/src/Artemis.UI.Shared/Controls/DraggableFloat.xaml.cs b/src/Artemis.UI.Shared/Controls/DraggableFloat.xaml.cs index f9b8ed325..4cdbf1909 100644 --- a/src/Artemis.UI.Shared/Controls/DraggableFloat.xaml.cs +++ b/src/Artemis.UI.Shared/Controls/DraggableFloat.xaml.cs @@ -72,7 +72,7 @@ namespace Artemis.UI.Shared private void UpdateValue(string value) { - if (!float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var parsedResult)) + if (!float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out float parsedResult)) return; Value = parsedResult; @@ -110,7 +110,7 @@ namespace Artemis.UI.Shared private static void FloatPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var draggableFloat = (DraggableFloat) d; + DraggableFloat draggableFloat = (DraggableFloat) d; if (draggableFloat._inCallback) return; @@ -133,7 +133,7 @@ namespace Artemis.UI.Shared { e.Handled = true; - var position = e.GetPosition((IInputElement) sender); + Point position = e.GetPosition((IInputElement) sender); if (position == _mouseDragStartPoint) DisplayInput(); else @@ -159,17 +159,17 @@ namespace Artemis.UI.Shared } // Use decimals for everything to avoid floating point errors - var startValue = new decimal(_startValue); - var startX = new decimal(_mouseDragStartPoint.X); - var x = new decimal(e.GetPosition((IInputElement) sender).X); - var stepSize = new decimal(StepSize); + decimal startValue = new decimal(_startValue); + decimal startX = new decimal(_mouseDragStartPoint.X); + decimal x = new decimal(e.GetPosition((IInputElement) sender).X); + decimal stepSize = new decimal(StepSize); if (stepSize == 0) stepSize = 0.1m; if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) stepSize = stepSize * 10; - var value = (float) RoundToNearestOf(startValue + stepSize * (x - startX), stepSize); + float value = (float) RoundToNearestOf(startValue + stepSize * (x - startX), stepSize); if (Min != null) value = Math.Max(value, Min.Value); if (Max != null) @@ -208,7 +208,7 @@ namespace Artemis.UI.Shared { if (e.DataObject.GetDataPresent(typeof(string))) { - var text = (string) e.DataObject.GetData(typeof(string)); + string text = (string) e.DataObject.GetData(typeof(string)); if (!_inputRegex.IsMatch(text)) e.CancelCommand(); } diff --git a/src/Artemis.UI.Shared/Controls/GradientPicker.xaml.cs b/src/Artemis.UI.Shared/Controls/GradientPicker.xaml.cs index 78c481c1f..453eb3189 100644 --- a/src/Artemis.UI.Shared/Controls/GradientPicker.xaml.cs +++ b/src/Artemis.UI.Shared/Controls/GradientPicker.xaml.cs @@ -78,7 +78,7 @@ namespace Artemis.UI.Shared private static void ColorGradientPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var gradientPicker = (GradientPicker) d; + GradientPicker gradientPicker = (GradientPicker) d; if (gradientPicker._inCallback) return; diff --git a/src/Artemis.UI.Shared/Converters/ColorGradientToGradientStopsConverter.cs b/src/Artemis.UI.Shared/Converters/ColorGradientToGradientStopsConverter.cs index 3188285e2..ab795404e 100644 --- a/src/Artemis.UI.Shared/Converters/ColorGradientToGradientStopsConverter.cs +++ b/src/Artemis.UI.Shared/Converters/ColorGradientToGradientStopsConverter.cs @@ -20,12 +20,12 @@ namespace Artemis.UI.Shared /// public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - var colorGradients = (BindableCollection) value; - var collection = new GradientStopCollection(); + BindableCollection colorGradients = (BindableCollection) value; + GradientStopCollection collection = new GradientStopCollection(); if (colorGradients == null) return collection; - foreach (var c in colorGradients.OrderBy(s => s.Position)) + foreach (ColorGradientStop c in colorGradients.OrderBy(s => s.Position)) collection.Add(new GradientStop(Color.FromArgb(c.Color.Alpha, c.Color.Red, c.Color.Green, c.Color.Blue), c.Position)); return collection; } @@ -33,12 +33,12 @@ namespace Artemis.UI.Shared /// public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - var collection = (GradientStopCollection) value; - var colorGradients = new BindableCollection(); + GradientStopCollection collection = (GradientStopCollection) value; + BindableCollection colorGradients = new BindableCollection(); if (collection == null) return colorGradients; - foreach (var c in collection.OrderBy(s => s.Offset)) + foreach (GradientStop c in collection.OrderBy(s => s.Offset)) colorGradients.Add(new ColorGradientStop(new SKColor(c.Color.R, c.Color.G, c.Color.B, c.Color.A), (float) c.Offset)); return colorGradients; } diff --git a/src/Artemis.UI.Shared/Converters/ColorToSKColorConverter.cs b/src/Artemis.UI.Shared/Converters/ColorToSKColorConverter.cs index 035b5d3f5..6f612d002 100644 --- a/src/Artemis.UI.Shared/Converters/ColorToSKColorConverter.cs +++ b/src/Artemis.UI.Shared/Converters/ColorToSKColorConverter.cs @@ -16,14 +16,14 @@ namespace Artemis.UI.Shared /// public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - var skColor = (SKColor) value; + SKColor skColor = (SKColor) value; return Color.FromArgb(skColor.Alpha, skColor.Red, skColor.Green, skColor.Blue); } /// public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { - var color = (Color) value; + Color color = (Color) value; return new SKColor(color.R, color.G, color.B, color.A); } } diff --git a/src/Artemis.UI.Shared/Converters/ColorToSolidColorConverter.cs b/src/Artemis.UI.Shared/Converters/ColorToSolidColorConverter.cs index 1e5ddd7b0..85fc3bdd0 100644 --- a/src/Artemis.UI.Shared/Converters/ColorToSolidColorConverter.cs +++ b/src/Artemis.UI.Shared/Converters/ColorToSolidColorConverter.cs @@ -16,7 +16,7 @@ namespace Artemis.UI.Shared /// public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - var color = (Color) value; + Color color = (Color) value; return Color.FromRgb(color.R, color.G, color.B); } diff --git a/src/Artemis.UI.Shared/Converters/ColorToStringConverter.cs b/src/Artemis.UI.Shared/Converters/ColorToStringConverter.cs index a285b1870..6b008793a 100644 --- a/src/Artemis.UI.Shared/Converters/ColorToStringConverter.cs +++ b/src/Artemis.UI.Shared/Converters/ColorToStringConverter.cs @@ -26,7 +26,7 @@ namespace Artemis.UI.Shared if (string.IsNullOrWhiteSpace((string) value)) return default(Color); - var color = ColorConverter.ConvertFromString((string) value); + object color = ColorConverter.ConvertFromString((string) value); if (color is Color c) return c; diff --git a/src/Artemis.UI.Shared/Converters/SKColorToStringConverter.cs b/src/Artemis.UI.Shared/Converters/SKColorToStringConverter.cs index fce6c3fde..ca3e04dca 100644 --- a/src/Artemis.UI.Shared/Converters/SKColorToStringConverter.cs +++ b/src/Artemis.UI.Shared/Converters/SKColorToStringConverter.cs @@ -25,7 +25,7 @@ namespace Artemis.UI.Shared if (string.IsNullOrWhiteSpace((string) value)) return SKColor.Empty; - return SKColor.TryParse((string) value, out var color) ? color : SKColor.Empty; + return SKColor.TryParse((string) value, out SKColor color) ? color : SKColor.Empty; } } } \ No newline at end of file diff --git a/src/Artemis.UI.Shared/DataModelVisualization/DataModelInputViewModel.cs b/src/Artemis.UI.Shared/DataModelVisualization/DataModelInputViewModel.cs index c9ec085a4..30a24989e 100644 --- a/src/Artemis.UI.Shared/DataModelVisualization/DataModelInputViewModel.cs +++ b/src/Artemis.UI.Shared/DataModelVisualization/DataModelInputViewModel.cs @@ -36,7 +36,7 @@ namespace Artemis.UI.Shared return; _closed = true; - foreach (var sourceUpdatingBinding in BindingOperations.GetSourceUpdatingBindings(View)) + foreach (BindingExpressionBase sourceUpdatingBinding in BindingOperations.GetSourceUpdatingBindings(View)) sourceUpdatingBinding.UpdateSource(); OnSubmit(); diff --git a/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelListPropertiesViewModel.cs b/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelListPropertiesViewModel.cs index b252793c3..314e37d39 100644 --- a/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelListPropertiesViewModel.cs +++ b/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelListPropertiesViewModel.cs @@ -45,7 +45,7 @@ namespace Artemis.UI.Shared ListType = DisplayValue.GetType(); PopulateProperties(dataModelUIService, DisplayValue); - foreach (var dataModelVisualizationViewModel in Children) + foreach (DataModelVisualizationViewModel dataModelVisualizationViewModel in Children) dataModelVisualizationViewModel.Update(dataModelUIService); } diff --git a/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelListViewModel.cs b/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelListViewModel.cs index 8a38f5f92..0bd4a2c91 100644 --- a/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelListViewModel.cs +++ b/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelListViewModel.cs @@ -34,12 +34,12 @@ namespace Artemis.UI.Shared public DataModelPropertiesViewModel GetListTypeViewModel(IDataModelUIService dataModelUIService) { - var type = DataModelPath.GetPropertyType(); + Type type = DataModelPath.GetPropertyType(); if (type == null) return null; // Create a property VM describing the type of the list - var viewModel = CreateListChild(dataModelUIService, type.GenericTypeArguments[0]); + DataModelVisualizationViewModel viewModel = CreateListChild(dataModelUIService, type.GenericTypeArguments[0]); // Put an empty value into the list type property view model if (viewModel is DataModelListPropertiesViewModel dataModelListClassViewModel) @@ -52,7 +52,7 @@ namespace Artemis.UI.Shared if (viewModel is DataModelListPropertyViewModel dataModelListPropertyViewModel) { dataModelListPropertyViewModel.DisplayValue = Activator.CreateInstance(dataModelListPropertyViewModel.ListType); - var wrapper = new DataModelPropertiesViewModel(null, null, null); + DataModelPropertiesViewModel wrapper = new DataModelPropertiesViewModel(null, null, null); wrapper.Children.Add(dataModelListPropertyViewModel); return wrapper; } @@ -69,8 +69,8 @@ namespace Artemis.UI.Shared if (List == null) return; - var index = 0; - foreach (var item in List) + int index = 0; + foreach (object? item in List) { DataModelVisualizationViewModel child; if (ListChildren.Count <= index) @@ -104,10 +104,10 @@ namespace Artemis.UI.Shared protected DataModelVisualizationViewModel CreateListChild(IDataModelUIService dataModelUIService, object listItem) { - var listType = listItem.GetType(); + Type listType = listItem.GetType(); // If a display VM was found, prefer to use that in any case - var typeViewModel = dataModelUIService.GetDataModelDisplayViewModel(listType); + DataModelDisplayViewModel typeViewModel = dataModelUIService.GetDataModelDisplayViewModel(listType); if (typeViewModel != null) return new DataModelListPropertyViewModel(DataModel, listItem, typeViewModel); // For primitives, create a property view model, it may be null that is fine diff --git a/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelPropertiesViewModel.cs b/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelPropertiesViewModel.cs index 90da4e1d5..adcda365d 100644 --- a/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelPropertiesViewModel.cs +++ b/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelPropertiesViewModel.cs @@ -19,7 +19,7 @@ namespace Artemis.UI.Shared if (Parent != null && !Parent.IsVisualizationExpanded && !Parent.IsRootViewModel) return; - foreach (var dataModelVisualizationViewModel in Children) + foreach (DataModelVisualizationViewModel dataModelVisualizationViewModel in Children) dataModelVisualizationViewModel.Update(dataModelUIService); } diff --git a/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelVisualizationViewModel.cs b/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelVisualizationViewModel.cs index ec2b2fc06..ca517fc4f 100644 --- a/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelVisualizationViewModel.cs +++ b/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelVisualizationViewModel.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Reflection; @@ -109,7 +110,7 @@ namespace Artemis.UI.Shared // If the VM has children, its own type is not relevant if (Children.Any()) { - foreach (var child in Children) + foreach (DataModelVisualizationViewModel child in Children) child?.ApplyTypeFilter(looseMatch, filteredTypes); IsMatchingFilteredTypes = true; @@ -124,7 +125,7 @@ namespace Artemis.UI.Shared } // If the type couldn't be retrieved either way, assume false - var type = DataModelPath.GetPropertyType(); + Type type = DataModelPath.GetPropertyType(); if (type == null) { IsMatchingFilteredTypes = false; @@ -154,14 +155,14 @@ namespace Artemis.UI.Shared IsVisualizationExpanded = false; } - foreach (var child in Children) + foreach (DataModelVisualizationViewModel child in Children) { // Try the child itself first if (child.Path == propertyPath) return child; // Try a child on the child next, this will go recursive - var match = child.GetChildByPath(dataModelGuid, propertyPath); + DataModelVisualizationViewModel match = child.GetChildByPath(dataModelGuid, propertyPath); if (match != null) return match; } @@ -188,15 +189,15 @@ namespace Artemis.UI.Shared modelType = DataModelPath.GetPropertyType(); // Add missing static children - foreach (var propertyInfo in modelType.GetProperties(BindingFlags.Public | BindingFlags.Instance)) + foreach (PropertyInfo propertyInfo in modelType.GetProperties(BindingFlags.Public | BindingFlags.Instance)) { - var childPath = Path != null ? $"{Path}.{propertyInfo.Name}" : propertyInfo.Name; + string childPath = Path != null ? $"{Path}.{propertyInfo.Name}" : propertyInfo.Name; if (Children.Any(c => c.Path != null && c.Path.Equals(childPath))) continue; if (propertyInfo.GetCustomAttribute() != null) continue; - var child = CreateChild(dataModelUIService, childPath, GetChildDepth(), overrideValue); + DataModelVisualizationViewModel child = CreateChild(dataModelUIService, childPath, GetChildDepth(), overrideValue); if (child != null) Children.Add(child); } @@ -207,10 +208,10 @@ namespace Artemis.UI.Shared hiddenProperties = overrideValueDataModel.GetHiddenProperties(); else hiddenProperties = DataModel.GetHiddenProperties(); - foreach (var hiddenProperty in hiddenProperties) + foreach (PropertyInfo hiddenProperty in hiddenProperties) { - var childPath = Path != null ? $"{Path}.{hiddenProperty.Name}" : hiddenProperty.Name; - var toRemove = Children.FirstOrDefault(c => c.Path != null && c.Path == childPath); + string childPath = Path != null ? $"{Path}.{hiddenProperty.Name}" : hiddenProperty.Name; + DataModelVisualizationViewModel toRemove = Children.FirstOrDefault(c => c.Path != null && c.Path == childPath); if (toRemove != null) Children.Remove(toRemove); } @@ -223,20 +224,20 @@ namespace Artemis.UI.Shared value = Parent.IsRootViewModel ? DataModel : DataModelPath.GetValue(); if (value is DataModel dataModel) { - foreach (var kvp in dataModel.DynamicDataModels) + foreach (KeyValuePair kvp in dataModel.DynamicDataModels) { - var childPath = Path != null ? $"{Path}.{kvp.Key}" : kvp.Key; + string childPath = Path != null ? $"{Path}.{kvp.Key}" : kvp.Key; if (Children.Any(c => c.Path != null && c.Path.Equals(childPath))) continue; - var child = CreateChild(dataModelUIService, childPath, GetChildDepth(), overrideValue); + DataModelVisualizationViewModel child = CreateChild(dataModelUIService, childPath, GetChildDepth(), overrideValue); if (child != null) Children.Add(child); } } // Remove dynamic children that have been removed from the data model - var toRemoveDynamic = Children.Where(c => !c.DataModelPath.IsValid).ToList(); + List toRemoveDynamic = Children.Where(c => !c.DataModelPath.IsValid).ToList(); if (toRemoveDynamic.Any()) Children.RemoveRange(toRemoveDynamic); } @@ -246,12 +247,12 @@ namespace Artemis.UI.Shared if (depth > MaxDepth) return null; - var dataModelPath = new DataModelPath(overrideValue ?? DataModel, path); + DataModelPath dataModelPath = new DataModelPath(overrideValue ?? DataModel, path); if (!dataModelPath.IsValid) return null; - var propertyInfo = dataModelPath.GetPropertyInfo(); - var propertyType = dataModelPath.GetPropertyType(); + PropertyInfo propertyInfo = dataModelPath.GetPropertyInfo(); + Type propertyType = dataModelPath.GetPropertyType(); // Skip properties decorated with DataModelIgnore if (propertyInfo != null && Attribute.IsDefined(propertyInfo, typeof(DataModelIgnoreAttribute))) @@ -261,7 +262,7 @@ namespace Artemis.UI.Shared return null; // If a display VM was found, prefer to use that in any case - var typeViewModel = dataModelUIService.GetDataModelDisplayViewModel(propertyType); + DataModelDisplayViewModel typeViewModel = dataModelUIService.GetDataModelDisplayViewModel(propertyType); if (typeViewModel != null) return new DataModelPropertyViewModel(DataModel, this, dataModelPath) {DisplayViewModel = typeViewModel, Depth = depth}; // For primitives, create a property view model, it may be null that is fine diff --git a/src/Artemis.UI.Shared/DependencyProperties/SizeObserver.cs b/src/Artemis.UI.Shared/DependencyProperties/SizeObserver.cs index 8fefcccf4..9f8308700 100644 --- a/src/Artemis.UI.Shared/DependencyProperties/SizeObserver.cs +++ b/src/Artemis.UI.Shared/DependencyProperties/SizeObserver.cs @@ -55,7 +55,7 @@ namespace Artemis.UI.Shared private static void OnObserveChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { - var frameworkElement = (FrameworkElement) dependencyObject; + FrameworkElement frameworkElement = (FrameworkElement) dependencyObject; if ((bool) e.NewValue) { diff --git a/src/Artemis.UI.Shared/Screens/Exceptions/ExceptionViewModel.cs b/src/Artemis.UI.Shared/Screens/Exceptions/ExceptionViewModel.cs index 91de685e3..4945156f2 100644 --- a/src/Artemis.UI.Shared/Screens/Exceptions/ExceptionViewModel.cs +++ b/src/Artemis.UI.Shared/Screens/Exceptions/ExceptionViewModel.cs @@ -14,7 +14,7 @@ namespace Artemis.UI.Shared.Screens.Exceptions Header = message; Exceptions = new List(); - var currentException = exception; + Exception currentException = exception; while (currentException != null) { Exceptions.Add(new DialogException(currentException)); diff --git a/src/Artemis.UI.Shared/Screens/GradientEditor/ColorStopViewModel.cs b/src/Artemis.UI.Shared/Screens/GradientEditor/ColorStopViewModel.cs index e4267dab3..99a7f9cf2 100644 --- a/src/Artemis.UI.Shared/Screens/GradientEditor/ColorStopViewModel.cs +++ b/src/Artemis.UI.Shared/Screens/GradientEditor/ColorStopViewModel.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Windows; @@ -89,8 +90,8 @@ namespace Artemis.UI.Shared.Screens.GradientEditor if (!((IInputElement) sender).IsMouseCaptured) return; - var parent = VisualTreeUtilities.FindParent((DependencyObject) sender, null); - var position = e.GetPosition(parent); + Canvas parent = VisualTreeUtilities.FindParent((DependencyObject) sender, null); + Point position = e.GetPosition(parent); if (position.Y > 50) { WillRemoveColorStop = true; @@ -99,11 +100,11 @@ namespace Artemis.UI.Shared.Screens.GradientEditor WillRemoveColorStop = false; - var minValue = 0.0; - var maxValue = _gradientEditorViewModel.PreviewWidth; - var stops = _gradientEditorViewModel.ColorGradient.Stops.OrderBy(s => s.Position).ToList(); - var previous = stops.IndexOf(ColorStop) >= 1 ? stops[stops.IndexOf(ColorStop) - 1] : null; - var next = stops.IndexOf(ColorStop) + 1 < stops.Count ? stops[stops.IndexOf(ColorStop) + 1] : null; + double minValue = 0.0; + double maxValue = _gradientEditorViewModel.PreviewWidth; + List stops = _gradientEditorViewModel.ColorGradient.Stops.OrderBy(s => s.Position).ToList(); + ColorGradientStop previous = stops.IndexOf(ColorStop) >= 1 ? stops[stops.IndexOf(ColorStop) - 1] : null; + ColorGradientStop next = stops.IndexOf(ColorStop) + 1 < stops.Count ? stops[stops.IndexOf(ColorStop) + 1] : null; if (previous != null) minValue = previous.Position * _gradientEditorViewModel.PreviewWidth; if (next != null) diff --git a/src/Artemis.UI.Shared/Screens/GradientEditor/GradientEditorViewModel.cs b/src/Artemis.UI.Shared/Screens/GradientEditor/GradientEditorViewModel.cs index 2b66328eb..ebfdfe4ad 100644 --- a/src/Artemis.UI.Shared/Screens/GradientEditor/GradientEditorViewModel.cs +++ b/src/Artemis.UI.Shared/Screens/GradientEditor/GradientEditorViewModel.cs @@ -50,14 +50,14 @@ namespace Artemis.UI.Shared.Screens.GradientEditor public void AddColorStop(object sender, MouseEventArgs e) { - var child = VisualTreeUtilities.FindChild((DependencyObject) sender, null); - var position = (float) (e.GetPosition(child).X / PreviewWidth); - var stop = new ColorGradientStop(ColorGradient.GetColor(position), position); + Canvas child = VisualTreeUtilities.FindChild((DependencyObject) sender, null); + float position = (float) (e.GetPosition(child).X / PreviewWidth); + ColorGradientStop stop = new ColorGradientStop(ColorGradient.GetColor(position), position); ColorGradient.Stops.Add(stop); ColorGradient.OnColorValuesUpdated(); - var index = ColorGradient.Stops.OrderBy(s => s.Position).ToList().IndexOf(stop); - var viewModel = new ColorStopViewModel(this, stop); + int index = ColorGradient.Stops.OrderBy(s => s.Position).ToList().IndexOf(stop); + ColorStopViewModel viewModel = new ColorStopViewModel(this, stop); ColorStopViewModels.Insert(index, viewModel); SelectColorStop(viewModel); @@ -74,14 +74,14 @@ namespace Artemis.UI.Shared.Screens.GradientEditor public Point GetPositionInPreview(object sender, MouseEventArgs e) { - var parent = VisualTreeUtilities.FindParent((DependencyObject) sender, null); + Canvas parent = VisualTreeUtilities.FindParent((DependencyObject) sender, null); return e.GetPosition(parent); } public void SelectColorStop(ColorStopViewModel colorStopViewModel) { SelectedColorStopViewModel = colorStopViewModel; - foreach (var stopViewModel in ColorStopViewModels) + foreach (ColorStopViewModel stopViewModel in ColorStopViewModels) stopViewModel.IsSelected = stopViewModel == SelectedColorStopViewModel; } @@ -105,7 +105,7 @@ namespace Artemis.UI.Shared.Screens.GradientEditor private void UpdateColorStopViewModels(object sender, PropertyChangedEventArgs e) { if (e.PropertyName != nameof(PreviewWidth)) return; - foreach (var colorStop in ColorGradient.Stops.OrderBy(s => s.Position)) + foreach (ColorGradientStop colorStop in ColorGradient.Stops.OrderBy(s => s.Position)) ColorStopViewModels.Add(new ColorStopViewModel(this, colorStop)); } } diff --git a/src/Artemis.UI.Shared/Services/ColorPickerService.cs b/src/Artemis.UI.Shared/Services/ColorPickerService.cs index 843cf4adb..14c23aa7b 100644 --- a/src/Artemis.UI.Shared/Services/ColorPickerService.cs +++ b/src/Artemis.UI.Shared/Services/ColorPickerService.cs @@ -72,7 +72,7 @@ namespace Artemis.UI.Shared.Services if (_overlayOpacity > 1f) _overlayOpacity = 1f; - using var overlayPaint = new SKPaint {Color = new SKColor(0, 0, 0, (byte) (255 * _overlayOpacity))}; + using SKPaint overlayPaint = new SKPaint {Color = new SKColor(0, 0, 0, (byte) (255 * _overlayOpacity))}; overlayPaint.Color = _overlayColor.WithAlpha((byte) (_overlayColor.Alpha * _overlayOpacity)); e.Canvas.DrawRect(0, 0, e.Canvas.LocalClipBounds.Width, e.Canvas.LocalClipBounds.Height, overlayPaint); } diff --git a/src/Artemis.UI.Shared/Services/DataModelUIService.cs b/src/Artemis.UI.Shared/Services/DataModelUIService.cs index d3f35326d..62f385157 100644 --- a/src/Artemis.UI.Shared/Services/DataModelUIService.cs +++ b/src/Artemis.UI.Shared/Services/DataModelUIService.cs @@ -32,8 +32,8 @@ namespace Artemis.UI.Shared.Services public DataModelPropertiesViewModel GetMainDataModelVisualization() { - var viewModel = new DataModelPropertiesViewModel(null, null, null); - foreach (var dataModelExpansion in _dataModelService.GetDataModels()) + DataModelPropertiesViewModel viewModel = new DataModelPropertiesViewModel(null, null, null); + foreach (DataModel dataModelExpansion in _dataModelService.GetDataModels()) viewModel.Children.Add(new DataModelPropertiesViewModel(dataModelExpansion, viewModel, null)); // Update to populate children @@ -46,24 +46,24 @@ namespace Artemis.UI.Shared.Services { if (includeMainDataModel) { - var mainDataModel = GetMainDataModelVisualization(); + DataModelPropertiesViewModel mainDataModel = GetMainDataModelVisualization(); // If the main data model already includes the plugin data model we're done if (mainDataModel.Children.Any(c => c.DataModel.PluginInfo.Instance == plugin)) return mainDataModel; // Otherwise get just the plugin data model and add it - var pluginDataModel = GetPluginDataModelVisualization(plugin, false); + DataModelPropertiesViewModel pluginDataModel = GetPluginDataModelVisualization(plugin, false); if (pluginDataModel != null) mainDataModel.Children.Add(pluginDataModel); return mainDataModel; } - var dataModel = _dataModelService.GetPluginDataModel(plugin); + DataModel dataModel = _dataModelService.GetPluginDataModel(plugin); if (dataModel == null) return null; - var viewModel = new DataModelPropertiesViewModel(null, null, null); + DataModelPropertiesViewModel viewModel = new DataModelPropertiesViewModel(null, null, null); viewModel.Children.Add(new DataModelPropertiesViewModel(dataModel, viewModel, null)); // Update to populate children @@ -76,11 +76,11 @@ namespace Artemis.UI.Shared.Services { if (compatibleConversionTypes == null) compatibleConversionTypes = new List(); - var viewModelType = typeof(T); + Type viewModelType = typeof(T); lock (_registeredDataModelEditors) { - var supportedType = viewModelType.BaseType.GetGenericArguments()[0]; - var existing = _registeredDataModelEditors.FirstOrDefault(r => r.SupportedType == supportedType); + Type supportedType = viewModelType.BaseType.GetGenericArguments()[0]; + DataModelVisualizationRegistration existing = _registeredDataModelEditors.FirstOrDefault(r => r.SupportedType == supportedType); if (existing != null) { if (existing.PluginInfo != pluginInfo) @@ -95,7 +95,7 @@ namespace Artemis.UI.Shared.Services _kernel.Bind(viewModelType).ToSelf(); // Create the registration - var registration = new DataModelVisualizationRegistration(this, RegistrationType.Input, pluginInfo, supportedType, viewModelType) + DataModelVisualizationRegistration registration = new DataModelVisualizationRegistration(this, RegistrationType.Input, pluginInfo, supportedType, viewModelType) { // Apply the compatible conversion types to the registration CompatibleConversionTypes = compatibleConversionTypes @@ -108,11 +108,11 @@ namespace Artemis.UI.Shared.Services public DataModelVisualizationRegistration RegisterDataModelDisplay(PluginInfo pluginInfo) where T : DataModelDisplayViewModel { - var viewModelType = typeof(T); + Type viewModelType = typeof(T); lock (_registeredDataModelDisplays) { - var supportedType = viewModelType.BaseType.GetGenericArguments()[0]; - var existing = _registeredDataModelDisplays.FirstOrDefault(r => r.SupportedType == supportedType); + Type supportedType = viewModelType.BaseType.GetGenericArguments()[0]; + DataModelVisualizationRegistration existing = _registeredDataModelDisplays.FirstOrDefault(r => r.SupportedType == supportedType); if (existing != null) { if (existing.PluginInfo != pluginInfo) @@ -125,7 +125,7 @@ namespace Artemis.UI.Shared.Services } _kernel.Bind(viewModelType).ToSelf(); - var registration = new DataModelVisualizationRegistration(this, RegistrationType.Display, pluginInfo, supportedType, viewModelType); + DataModelVisualizationRegistration registration = new DataModelVisualizationRegistration(this, RegistrationType.Display, pluginInfo, supportedType, viewModelType); _registeredDataModelDisplays.Add(registration); return registration; } @@ -163,7 +163,7 @@ namespace Artemis.UI.Shared.Services { lock (_registeredDataModelDisplays) { - var match = _registeredDataModelDisplays.FirstOrDefault(d => d.SupportedType == propertyType); + DataModelVisualizationRegistration match = _registeredDataModelDisplays.FirstOrDefault(d => d.SupportedType == propertyType); if (match != null) return (DataModelDisplayViewModel) match.PluginInfo.Kernel.Get(match.ViewModelType); return !fallBackToDefault ? null : _kernel.Get(); @@ -175,7 +175,7 @@ namespace Artemis.UI.Shared.Services lock (_registeredDataModelEditors) { // Prefer a VM that natively supports the type - var match = _registeredDataModelEditors.FirstOrDefault(d => d.SupportedType == propertyType); + DataModelVisualizationRegistration match = _registeredDataModelEditors.FirstOrDefault(d => d.SupportedType == propertyType); // Fall back on a VM that supports the type through conversion if (match == null) match = _registeredDataModelEditors.FirstOrDefault(d => d.CompatibleConversionTypes.Contains(propertyType)); @@ -185,7 +185,7 @@ namespace Artemis.UI.Shared.Services if (match != null) { - var viewModel = InstantiateDataModelInputViewModel(match, description, initialValue); + DataModelInputViewModel viewModel = InstantiateDataModelInputViewModel(match, description, initialValue); viewModel.UpdateCallback = updateCallback; return viewModel; } @@ -217,12 +217,12 @@ namespace Artemis.UI.Shared.Services if (initialValue != null && initialValue.GetType() != registration.SupportedType) initialValue = Convert.ChangeType(initialValue, registration.SupportedType); - var parameters = new IParameter[] + IParameter[] parameters = new IParameter[] { new ConstructorArgument("description", description), new ConstructorArgument("initialValue", initialValue) }; - var viewModel = (DataModelInputViewModel) registration.PluginInfo.Kernel.Get(registration.ViewModelType, parameters); + DataModelInputViewModel viewModel = (DataModelInputViewModel) registration.PluginInfo.Kernel.Get(registration.ViewModelType, parameters); viewModel.CompatibleConversionTypes = registration.CompatibleConversionTypes; return viewModel; } diff --git a/src/Artemis.UI.Shared/Services/Dialog/DialogService.cs b/src/Artemis.UI.Shared/Services/Dialog/DialogService.cs index 84b8e259d..e4d8d4aad 100644 --- a/src/Artemis.UI.Shared/Services/Dialog/DialogService.cs +++ b/src/Artemis.UI.Shared/Services/Dialog/DialogService.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using System.Windows; using Artemis.UI.Shared.Screens.Dialogs; using Artemis.UI.Shared.Screens.Exceptions; using MaterialDesignThemes.Wpf; @@ -27,27 +28,27 @@ namespace Artemis.UI.Shared.Services public async Task ShowConfirmDialog(string header, string text, string confirmText = "Confirm", string cancelText = "Cancel") { - var arguments = new IParameter[] + IParameter[] arguments = new IParameter[] { new ConstructorArgument("header", header), new ConstructorArgument("text", text), new ConstructorArgument("confirmText", confirmText.ToUpper()), new ConstructorArgument("cancelText", cancelText.ToUpper()) }; - var result = await ShowDialog(arguments); + object result = await ShowDialog(arguments); return (bool) result; } public async Task ShowConfirmDialogAt(string identifier, string header, string text, string confirmText = "Confirm", string cancelText = "Cancel") { - var arguments = new IParameter[] + IParameter[] arguments = new IParameter[] { new ConstructorArgument("header", header), new ConstructorArgument("text", text), new ConstructorArgument("confirmText", confirmText.ToUpper()), new ConstructorArgument("cancelText", cancelText.ToUpper()) }; - var result = await ShowDialogAt(identifier, arguments); + object result = await ShowDialogAt(identifier, arguments); return (bool) result; } @@ -61,7 +62,7 @@ namespace Artemis.UI.Shared.Services if (parameters == null) throw new ArgumentNullException(nameof(parameters)); - var paramsArray = parameters.Select(kv => new ConstructorArgument(kv.Key, kv.Value)).Cast().ToArray(); + IParameter[] paramsArray = parameters.Select(kv => new ConstructorArgument(kv.Key, kv.Value)).Cast().ToArray(); return ShowDialog(paramsArray); } @@ -81,7 +82,7 @@ namespace Artemis.UI.Shared.Services if (parameters == null) throw new ArgumentNullException(nameof(parameters)); - var paramsArray = parameters.Select(kv => new ConstructorArgument(kv.Key, kv.Value)).Cast().ToArray(); + IParameter[] paramsArray = parameters.Select(kv => new ConstructorArgument(kv.Key, kv.Value)).Cast().ToArray(); return await ShowDialogAt(identifier, paramsArray); } @@ -101,7 +102,7 @@ namespace Artemis.UI.Shared.Services Task result = null; await Execute.OnUIThreadAsync(() => { - var view = _viewManager.CreateViewForModel(viewModel); + UIElement view = _viewManager.CreateViewForModel(viewModel); _viewManager.BindViewToModel(view, viewModel); if (identifier == null) diff --git a/src/Artemis.UI.Shared/Services/Dialog/DialogViewModelHost.cs b/src/Artemis.UI.Shared/Services/Dialog/DialogViewModelHost.cs index e94b388f9..eb5e02eb9 100644 --- a/src/Artemis.UI.Shared/Services/Dialog/DialogViewModelHost.cs +++ b/src/Artemis.UI.Shared/Services/Dialog/DialogViewModelHost.cs @@ -1,4 +1,5 @@ -using MaterialDesignThemes.Wpf; +using System.Windows; +using MaterialDesignThemes.Wpf; using Stylet; namespace Artemis.UI.Shared.Services @@ -17,7 +18,7 @@ namespace Artemis.UI.Shared.Services public void OpenDialog(DialogViewModelBase viewModel, string dialogIdentifier) { - var view = _viewManager.CreateViewForModel(viewModel); + UIElement view = _viewManager.CreateViewForModel(viewModel); DialogHost.Show(view, dialogIdentifier, viewModel.OnDialogClosed); viewModel.DialogViewModelHost = this; diff --git a/src/Artemis.UI.Shared/Services/ProfileEditorService.cs b/src/Artemis.UI.Shared/Services/ProfileEditorService.cs index afdc19069..a637b7049 100644 --- a/src/Artemis.UI.Shared/Services/ProfileEditorService.cs +++ b/src/Artemis.UI.Shared/Services/ProfileEditorService.cs @@ -75,7 +75,7 @@ namespace Artemis.UI.Shared.Services _logger.Verbose("ChangeSelectedProfile {profile}", profile); ChangeSelectedProfileElement(null); - var profileElementEvent = new ProfileEventArgs(profile, SelectedProfile); + ProfileEventArgs profileElementEvent = new ProfileEventArgs(profile, SelectedProfile); // Ensure there is never a deactivated profile as the selected profile if (SelectedProfile != null) @@ -109,7 +109,7 @@ namespace Artemis.UI.Shared.Services return; _logger.Verbose("ChangeSelectedProfileElement {profile}", profileElement); - var profileElementEvent = new RenderProfileElementEventArgs(profileElement, SelectedProfileElement); + RenderProfileElementEventArgs profileElementEvent = new RenderProfileElementEventArgs(profileElement, SelectedProfileElement); SelectedProfileElement = profileElement; OnSelectedProfileElementChanged(profileElementEvent); @@ -140,9 +140,9 @@ namespace Artemis.UI.Shared.Services return; // Stick to the main segment for any element that is not currently selected - foreach (var folder in SelectedProfile.GetAllFolders()) + foreach (Folder folder in SelectedProfile.GetAllFolders()) folder.OverrideProgress(CurrentTime, folder != SelectedProfileElement); - foreach (var layer in SelectedProfile.GetAllLayers()) + foreach (Layer layer in SelectedProfile.GetAllLayers()) layer.OverrideProgress(CurrentTime, layer != SelectedProfileElement); OnProfilePreviewUpdated(); @@ -150,7 +150,7 @@ namespace Artemis.UI.Shared.Services public bool UndoUpdateProfile() { - var undid = _profileService.UndoUpdateProfile(SelectedProfile); + bool undid = _profileService.UndoUpdateProfile(SelectedProfile); if (!undid) return false; @@ -160,7 +160,7 @@ namespace Artemis.UI.Shared.Services public bool RedoUpdateProfile() { - var redid = _profileService.RedoUpdateProfile(SelectedProfile); + bool redid = _profileService.RedoUpdateProfile(SelectedProfile); if (!redid) return false; @@ -180,7 +180,7 @@ namespace Artemis.UI.Shared.Services lock (_registeredPropertyEditors) { - var supportedType = viewModelType.BaseType.GetGenericArguments()[0]; + Type supportedType = viewModelType.BaseType.GetGenericArguments()[0]; // If the supported type is a generic, assume there is a base type if (supportedType.IsGenericParameter) { @@ -189,7 +189,7 @@ namespace Artemis.UI.Shared.Services supportedType = supportedType.BaseType; } - var existing = _registeredPropertyEditors.FirstOrDefault(r => r.SupportedType == supportedType); + PropertyInputRegistration existing = _registeredPropertyEditors.FirstOrDefault(r => r.SupportedType == supportedType); if (existing != null) { if (existing.PluginInfo != pluginInfo) @@ -198,7 +198,7 @@ namespace Artemis.UI.Shared.Services } Kernel.Bind(viewModelType).ToSelf(); - var registration = new PropertyInputRegistration(this, pluginInfo, supportedType, viewModelType); + PropertyInputRegistration registration = new PropertyInputRegistration(this, pluginInfo, supportedType, viewModelType); _registeredPropertyEditors.Add(registration); return registration; } @@ -227,7 +227,7 @@ namespace Artemis.UI.Shared.Services return SelectedProfileElement.StartSegmentLength; // Snap to the end of the main segment - var mainSegmentEnd = SelectedProfileElement.StartSegmentLength + SelectedProfileElement.MainSegmentLength; + TimeSpan mainSegmentEnd = SelectedProfileElement.StartSegmentLength + SelectedProfileElement.MainSegmentLength; if (Math.Abs(time.TotalMilliseconds - mainSegmentEnd.TotalMilliseconds) < tolerance.TotalMilliseconds) return mainSegmentEnd; @@ -246,7 +246,7 @@ namespace Artemis.UI.Shared.Services if (snapTimes != null) { // Find the closest keyframe - var closeSnapTime = snapTimes.FirstOrDefault(s => Math.Abs(time.TotalMilliseconds - s.TotalMilliseconds) < tolerance.TotalMilliseconds); + TimeSpan closeSnapTime = snapTimes.FirstOrDefault(s => Math.Abs(time.TotalMilliseconds - s.TotalMilliseconds) < tolerance.TotalMilliseconds); if (closeSnapTime != TimeSpan.Zero) return closeSnapTime; } @@ -257,7 +257,7 @@ namespace Artemis.UI.Shared.Services public PropertyInputViewModel CreatePropertyInputViewModel(LayerProperty layerProperty) { Type viewModelType = null; - var registration = RegisteredPropertyEditors.FirstOrDefault(r => r.SupportedType == typeof(T)); + PropertyInputRegistration registration = RegisteredPropertyEditors.FirstOrDefault(r => r.SupportedType == typeof(T)); // Check for enums if no supported type was found if (registration == null && typeof(T).IsEnum) @@ -272,8 +272,8 @@ namespace Artemis.UI.Shared.Services else return null; - var parameter = new ConstructorArgument("layerProperty", layerProperty); - var kernel = registration != null ? registration.PluginInfo.Kernel : Kernel; + ConstructorArgument parameter = new ConstructorArgument("layerProperty", layerProperty); + IKernel kernel = registration != null ? registration.PluginInfo.Kernel : Kernel; return (PropertyInputViewModel) kernel.Get(viewModelType, parameter); } @@ -287,7 +287,7 @@ namespace Artemis.UI.Shared.Services // Trigger a profile change OnSelectedProfileChanged(new ProfileEventArgs(SelectedProfile, SelectedProfile)); // Trigger a selected element change - var previousSelectedProfileElement = SelectedProfileElement; + RenderProfileElement previousSelectedProfileElement = SelectedProfileElement; if (SelectedProfileElement is Folder folder) SelectedProfileElement = SelectedProfile.GetAllFolders().FirstOrDefault(f => f.EntityId == folder.EntityId); else if (SelectedProfileElement is Layer layer) diff --git a/src/Artemis.UI.Shared/Utilities/EnumUtilities.cs b/src/Artemis.UI.Shared/Utilities/EnumUtilities.cs index 6249950dc..728fd7dc6 100644 --- a/src/Artemis.UI.Shared/Utilities/EnumUtilities.cs +++ b/src/Artemis.UI.Shared/Utilities/EnumUtilities.cs @@ -19,13 +19,13 @@ namespace Artemis.UI.Shared /// A human readable description of the given enum value public static string Description(this Enum value) { - var attributes = value.GetType().GetField(value.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false); + object[] attributes = value.GetType().GetField(value.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false); if (attributes.Any()) return (attributes.First() as DescriptionAttribute).Description; // If no description is found, the least we can do is replace underscores with spaces // You can add your own custom default formatting logic here - var ti = CultureInfo.CurrentCulture.TextInfo; + TextInfo ti = CultureInfo.CurrentCulture.TextInfo; return ti.ToTitleCase(ti.ToLower(value.ToString().Replace("_", " "))); } diff --git a/src/Artemis.UI.Shared/Utilities/HitTestUtilities.cs b/src/Artemis.UI.Shared/Utilities/HitTestUtilities.cs index 1c5f56917..e2cd4fdc7 100644 --- a/src/Artemis.UI.Shared/Utilities/HitTestUtilities.cs +++ b/src/Artemis.UI.Shared/Utilities/HitTestUtilities.cs @@ -19,10 +19,10 @@ namespace Artemis.UI.Shared /// public static List GetHitViewModels(Visual container, RectangleGeometry rectangleGeometry) { - var result = new List(); - var hitTestParams = new GeometryHitTestParameters(rectangleGeometry); - var resultCallback = new HitTestResultCallback(r => HitTestResultBehavior.Continue); - var filterCallback = new HitTestFilterCallback(e => + List result = new List(); + GeometryHitTestParameters hitTestParams = new GeometryHitTestParameters(rectangleGeometry); + HitTestResultCallback resultCallback = new HitTestResultCallback(r => HitTestResultBehavior.Continue); + HitTestFilterCallback filterCallback = new HitTestFilterCallback(e => { if (e is FrameworkElement fe && fe.DataContext is T context && !result.Contains(context)) result.Add(context); diff --git a/src/Artemis.UI.Shared/Utilities/ShortcutUtilities.cs b/src/Artemis.UI.Shared/Utilities/ShortcutUtilities.cs index 83bfd11d4..79f45cc8d 100644 --- a/src/Artemis.UI.Shared/Utilities/ShortcutUtilities.cs +++ b/src/Artemis.UI.Shared/Utilities/ShortcutUtilities.cs @@ -24,7 +24,7 @@ namespace Artemis.UI.Shared /// The icon path of the shortcut public static void Create(string fileName, string targetPath, string arguments, string workingDirectory, string description, string hotkey, string iconPath) { - var shortcut = (IWshShortcut) m_type.InvokeMember("CreateShortcut", BindingFlags.InvokeMethod, null, m_shell, new object[] {fileName}); + IWshShortcut shortcut = (IWshShortcut) m_type.InvokeMember("CreateShortcut", BindingFlags.InvokeMethod, null, m_shell, new object[] {fileName}); shortcut.Description = description; shortcut.Hotkey = hotkey; shortcut.TargetPath = targetPath; diff --git a/src/Artemis.UI.Shared/Utilities/TriggerTracing.cs b/src/Artemis.UI.Shared/Utilities/TriggerTracing.cs index b1951cdd7..7b0552691 100644 --- a/src/Artemis.UI.Shared/Utilities/TriggerTracing.cs +++ b/src/Artemis.UI.Shared/Utilities/TriggerTracing.cs @@ -71,20 +71,20 @@ namespace Artemis.UI.Shared if (format.StartsWith("Storyboard has begun;")) { - var storyboard = args[1] as TriggerTraceStoryboard; + TriggerTraceStoryboard storyboard = args[1] as TriggerTraceStoryboard; if (storyboard != null) { // add a breakpoint here to see when your trigger has been // entered or exited // the element being acted upon - var targetElement = args[5]; + object targetElement = args[5]; // the namescope of the element being acted upon - var namescope = (INameScope) args[7]; + INameScope namescope = (INameScope) args[7]; - var triggerBase = storyboard.TriggerBase; - var triggerName = GetTriggerName(storyboard.TriggerBase); + TriggerBase triggerBase = storyboard.TriggerBase; + string triggerName = GetTriggerName(storyboard.TriggerBase); Debug.WriteLine("Element: {0}, {1}: {2}: {3}", targetElement, triggerBase.GetType().Name, triggerName, storyboard.StoryboardType); } @@ -164,7 +164,7 @@ namespace Artemis.UI.Shared private static void OnTraceEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var triggerBase = d as TriggerBase; + TriggerBase triggerBase = d as TriggerBase; if (triggerBase == null) return; @@ -176,7 +176,7 @@ namespace Artemis.UI.Shared { // insert dummy story-boards which can later be traced using WPF animation tracing - var storyboard = new TriggerTraceStoryboard(triggerBase, TriggerTraceStoryboardType.Enter); + TriggerTraceStoryboard storyboard = new TriggerTraceStoryboard(triggerBase, TriggerTraceStoryboardType.Enter); triggerBase.EnterActions.Insert(0, new BeginStoryboard {Storyboard = storyboard}); storyboard = new TriggerTraceStoryboard(triggerBase, TriggerTraceStoryboardType.Exit); @@ -186,11 +186,11 @@ namespace Artemis.UI.Shared { // remove the dummy storyboards - foreach (var actionCollection in new[] {triggerBase.EnterActions, triggerBase.ExitActions}) + foreach (TriggerActionCollection actionCollection in new[] {triggerBase.EnterActions, triggerBase.ExitActions}) { - foreach (var triggerAction in actionCollection) + foreach (TriggerAction triggerAction in actionCollection) { - var bsb = triggerAction as BeginStoryboard; + BeginStoryboard bsb = triggerAction as BeginStoryboard; if (bsb != null && bsb.Storyboard != null && bsb.Storyboard is TriggerTraceStoryboard) { diff --git a/src/Artemis.UI.Shared/Utilities/VisualTreeUtilities.cs b/src/Artemis.UI.Shared/Utilities/VisualTreeUtilities.cs index 969771934..ea069f53a 100644 --- a/src/Artemis.UI.Shared/Utilities/VisualTreeUtilities.cs +++ b/src/Artemis.UI.Shared/Utilities/VisualTreeUtilities.cs @@ -27,10 +27,10 @@ namespace Artemis.UI.Shared T foundChild = null; - var childrenCount = VisualTreeHelper.GetChildrenCount(parent); - for (var i = 0; i < childrenCount; i++) + int childrenCount = VisualTreeHelper.GetChildrenCount(parent); + for (int i = 0; i < childrenCount; i++) { - var child = VisualTreeHelper.GetChild(parent, i); + DependencyObject child = VisualTreeHelper.GetChild(parent, i); // If the child is not of the request child type child if (!(child is T)) { @@ -75,7 +75,7 @@ namespace Artemis.UI.Shared public static T FindParent(DependencyObject child, string parentName) where T : DependencyObject { // Get parent item - var parentObject = VisualTreeHelper.GetParent(child); + DependencyObject parentObject = VisualTreeHelper.GetParent(child); // We've reached the end of the tree if (parentObject == null) diff --git a/src/Artemis.UI/Behaviors/InputBindingBehavior.cs b/src/Artemis.UI/Behaviors/InputBindingBehavior.cs index 6c22d9681..6cc384fd6 100644 --- a/src/Artemis.UI/Behaviors/InputBindingBehavior.cs +++ b/src/Artemis.UI/Behaviors/InputBindingBehavior.cs @@ -32,15 +32,15 @@ namespace Artemis.UI.Behaviors private static void OnLoaded(object sender, RoutedEventArgs e) { - var frameworkElement = (FrameworkElement) sender; + FrameworkElement frameworkElement = (FrameworkElement) sender; - var window = Window.GetWindow(frameworkElement); + Window window = Window.GetWindow(frameworkElement); if (window == null) return; // Move input bindings from the FrameworkElement to the window. - for (var i = frameworkElement.InputBindings.Count - 1; i >= 0; i--) + for (int i = frameworkElement.InputBindings.Count - 1; i >= 0; i--) { - var inputBinding = frameworkElement.InputBindings[i]; + InputBinding inputBinding = frameworkElement.InputBindings[i]; window.InputBindings.Add(inputBinding); frameworkElement.InputBindings.Remove(inputBinding); @@ -50,10 +50,10 @@ namespace Artemis.UI.Behaviors private static void OnUnloaded(object sender, RoutedEventArgs e) { - var frameworkElement = (FrameworkElement) sender; + FrameworkElement frameworkElement = (FrameworkElement) sender; - var toRemove = _movedInputBindings.Where(m => m.Item1 == frameworkElement).ToList(); - foreach (var (_, window, inputBinding) in toRemove) + List> toRemove = _movedInputBindings.Where(m => m.Item1 == frameworkElement).ToList(); + foreach ((FrameworkElement _, Window window, InputBinding inputBinding) in toRemove) { if (window.InputBindings.Contains(inputBinding)) window.InputBindings.Remove(inputBinding); diff --git a/src/Artemis.UI/Behaviors/MouseBehavior.cs b/src/Artemis.UI/Behaviors/MouseBehavior.cs index 184bdf765..8a2c5d273 100644 --- a/src/Artemis.UI/Behaviors/MouseBehavior.cs +++ b/src/Artemis.UI/Behaviors/MouseBehavior.cs @@ -22,16 +22,16 @@ namespace Artemis.UI.Behaviors private static void MouseUpCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var element = (FrameworkElement) d; + FrameworkElement element = (FrameworkElement) d; element.MouseUp += element_MouseUp; } private static void element_MouseUp(object sender, MouseButtonEventArgs e) { - var element = (FrameworkElement) sender; + FrameworkElement element = (FrameworkElement) sender; - var command = GetMouseUpCommand(element); + ICommand command = GetMouseUpCommand(element); command.Execute(e); } diff --git a/src/Artemis.UI/Behaviors/TreeViewSelectionBehavior.cs b/src/Artemis.UI/Behaviors/TreeViewSelectionBehavior.cs index f2e333196..1e5acda30 100644 --- a/src/Artemis.UI/Behaviors/TreeViewSelectionBehavior.cs +++ b/src/Artemis.UI/Behaviors/TreeViewSelectionBehavior.cs @@ -83,7 +83,7 @@ namespace Artemis.UI.Behaviors private static void OnSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args) { - var behavior = (TreeViewSelectionBehavior) sender; + TreeViewSelectionBehavior behavior = (TreeViewSelectionBehavior) sender; if (behavior._modelHandled) return; if (behavior.AssociatedObject == null) @@ -98,7 +98,7 @@ namespace Artemis.UI.Behaviors private void UpdateTreeViewItem(TreeViewItem item, bool recurse) { // if (SelectedItem == null) return; - var model = item.DataContext; + object model = item.DataContext; // If the selected item is this model and is not yet selected - select and return if (SelectedItem == model && !item.IsSelected) @@ -110,7 +110,7 @@ namespace Artemis.UI.Behaviors // If the selected item is a parent of this model - expand else { - var isParentOfModel = HierarchyPredicate?.Invoke(SelectedItem, model) ?? true; + bool isParentOfModel = HierarchyPredicate?.Invoke(SelectedItem, model) ?? true; if (isParentOfModel) item.IsExpanded = true; } @@ -118,9 +118,9 @@ namespace Artemis.UI.Behaviors // Recurse into children if (recurse) { - foreach (var subitem in item.Items) + foreach (object? subitem in item.Items) { - var tvi = item.ItemContainerGenerator.ContainerFromItem(subitem) as TreeViewItem; + TreeViewItem tvi = item.ItemContainerGenerator.ContainerFromItem(subitem) as TreeViewItem; if (tvi != null) UpdateTreeViewItem(tvi, true); } @@ -130,10 +130,10 @@ namespace Artemis.UI.Behaviors // Update state of all items private void UpdateAllTreeViewItems() { - var treeView = AssociatedObject; - foreach (var item in treeView.Items) + TreeView treeView = AssociatedObject; + foreach (object? item in treeView.Items) { - var tvi = treeView.ItemContainerGenerator.ContainerFromItem(item) as TreeViewItem; + TreeViewItem tvi = treeView.ItemContainerGenerator.ContainerFromItem(item) as TreeViewItem; if (tvi != null) UpdateTreeViewItem(tvi, true); } diff --git a/src/Artemis.UI/Bootstrapper.cs b/src/Artemis.UI/Bootstrapper.cs index f91e1d0c4..dbced1ec0 100644 --- a/src/Artemis.UI/Bootstrapper.cs +++ b/src/Artemis.UI/Bootstrapper.cs @@ -39,8 +39,8 @@ namespace Artemis.UI protected override void Launch() { - var logger = Kernel.Get(); - var viewManager = Kernel.Get(); + ILogger logger = Kernel.Get(); + IViewManager viewManager = Kernel.Get(); StartupArguments = Args.ToList(); CreateDataDirectory(logger); @@ -99,10 +99,10 @@ namespace Artemis.UI protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e) { - var logger = Kernel.Get(); + ILogger logger = Kernel.Get(); logger.Fatal(e.Exception, "Unhandled exception"); - var dialogService = Kernel.Get(); + IDialogService dialogService = Kernel.Get(); try { dialogService.ShowExceptionDialog("Artemis encountered an error", e.Exception); @@ -127,8 +127,8 @@ namespace Artemis.UI // During creation ensure all local users can access the data folder // This is needed when later running Artemis as a different user or when Artemis is first run as admin - var directoryInfo = new DirectoryInfo(Constants.DataFolder); - var accessControl = directoryInfo.GetAccessControl(); + DirectoryInfo directoryInfo = new DirectoryInfo(Constants.DataFolder); + DirectorySecurity accessControl = directoryInfo.GetAccessControl(); accessControl.AddAccessRule(new FileSystemAccessRule( new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null), FileSystemRights.FullControl, diff --git a/src/Artemis.UI/Converters/EnumToCollectionConverter.cs b/src/Artemis.UI/Converters/EnumToCollectionConverter.cs index 8ea483dd6..7bffd9951 100644 --- a/src/Artemis.UI/Converters/EnumToCollectionConverter.cs +++ b/src/Artemis.UI/Converters/EnumToCollectionConverter.cs @@ -28,12 +28,12 @@ namespace Artemis.UI.Converters private static string Description(Enum value) { - var attributes = value.GetType().GetField(value.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false); + object[] attributes = value.GetType().GetField(value.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false); if (attributes.Any()) return (attributes.First() as DescriptionAttribute)?.Description; // If no description is found, the least we can do is replace underscores with spaces - var ti = CultureInfo.CurrentCulture.TextInfo; + TextInfo ti = CultureInfo.CurrentCulture.TextInfo; return ti.ToTitleCase(ti.ToLower(value.ToString().Replace("_", " "))); } diff --git a/src/Artemis.UI/DataTemplateSelectors/ComboBoxTemplateSelector.cs b/src/Artemis.UI/DataTemplateSelectors/ComboBoxTemplateSelector.cs index 9bde939ef..67c22d223 100644 --- a/src/Artemis.UI/DataTemplateSelectors/ComboBoxTemplateSelector.cs +++ b/src/Artemis.UI/DataTemplateSelectors/ComboBoxTemplateSelector.cs @@ -16,7 +16,7 @@ namespace Artemis.UI.DataTemplateSelectors public override DataTemplate SelectTemplate(object item, DependencyObject container) { - var itemToCheck = container; + DependencyObject itemToCheck = container; // Search up the visual tree, stopping at either a ComboBox or // a ComboBoxItem (or null). This will determine which template to use @@ -24,7 +24,7 @@ namespace Artemis.UI.DataTemplateSelectors itemToCheck = VisualTreeHelper.GetParent(itemToCheck); // If you stopped at a ComboBoxItem, you're in the dropdown - var inDropDown = itemToCheck is ComboBoxItem; + bool inDropDown = itemToCheck is ComboBoxItem; return inDropDown ? DropdownItemsTemplate ?? DropdownItemsTemplateSelector?.SelectTemplate(item, container) diff --git a/src/Artemis.UI/DefaultTypes/DataModel/Input/DoubleDataModelInputViewModel.cs b/src/Artemis.UI/DefaultTypes/DataModel/Input/DoubleDataModelInputViewModel.cs index f11403f26..df9507368 100644 --- a/src/Artemis.UI/DefaultTypes/DataModel/Input/DoubleDataModelInputViewModel.cs +++ b/src/Artemis.UI/DefaultTypes/DataModel/Input/DoubleDataModelInputViewModel.cs @@ -14,8 +14,8 @@ namespace Artemis.UI.DefaultTypes.DataModel.Input public void NumberValidationTextBox(object sender, TextCompositionEventArgs e) { - var seperator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator; - var regex = new Regex("^[" + seperator + "][0-9]+$|^[0-9]*[" + seperator + "]{0,1}[0-9]*$"); + string seperator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator; + Regex regex = new Regex("^[" + seperator + "][0-9]+$|^[0-9]*[" + seperator + "]{0,1}[0-9]*$"); e.Handled = !regex.IsMatch(e.Text); } } diff --git a/src/Artemis.UI/DefaultTypes/DataModel/Input/IntDataModelInputViewModel.cs b/src/Artemis.UI/DefaultTypes/DataModel/Input/IntDataModelInputViewModel.cs index f35623ee1..f00c4addc 100644 --- a/src/Artemis.UI/DefaultTypes/DataModel/Input/IntDataModelInputViewModel.cs +++ b/src/Artemis.UI/DefaultTypes/DataModel/Input/IntDataModelInputViewModel.cs @@ -13,7 +13,7 @@ namespace Artemis.UI.DefaultTypes.DataModel.Input public void NumberValidationTextBox(object sender, TextCompositionEventArgs e) { - var regex = new Regex("[^0-9]+"); + Regex regex = new Regex("[^0-9]+"); e.Handled = regex.IsMatch(e.Text); } } diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputViewModel.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputViewModel.cs index 61c512175..33270c15a 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputViewModel.cs +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputViewModel.cs @@ -39,7 +39,7 @@ namespace Artemis.UI.PropertyInput public void UpdateEnumValues() { - var layerBrushProviders = _pluginService.GetPluginsOfType(); + List layerBrushProviders = _pluginService.GetPluginsOfType(); Descriptors = new BindableCollection(layerBrushProviders.SelectMany(l => l.LayerBrushDescriptors)); NotifyOfPropertyChange(nameof(SelectedDescriptor)); } diff --git a/src/Artemis.UI/Extensions/BindableCollectionExtensions.cs b/src/Artemis.UI/Extensions/BindableCollectionExtensions.cs index f523f169f..25897b11f 100644 --- a/src/Artemis.UI/Extensions/BindableCollectionExtensions.cs +++ b/src/Artemis.UI/Extensions/BindableCollectionExtensions.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using Stylet; @@ -8,10 +9,10 @@ namespace Artemis.UI.Extensions { public static void Sort(this BindableCollection collection, Func order) { - var ordered = collection.OrderBy(order).ToList(); - for (var index = 0; index < ordered.Count; index++) + List ordered = collection.OrderBy(order).ToList(); + for (int index = 0; index < ordered.Count; index++) { - var dataBindingConditionViewModel = ordered[index]; + T dataBindingConditionViewModel = ordered[index]; if (collection.IndexOf(dataBindingConditionViewModel) != index) collection.Move(collection.IndexOf(dataBindingConditionViewModel), index); } diff --git a/src/Artemis.UI/Extensions/RgbColorExtensions.cs b/src/Artemis.UI/Extensions/RgbColorExtensions.cs index 10891abad..1880699a1 100644 --- a/src/Artemis.UI/Extensions/RgbColorExtensions.cs +++ b/src/Artemis.UI/Extensions/RgbColorExtensions.cs @@ -7,7 +7,7 @@ namespace Artemis.UI.Extensions { public static Color ToMediaColor(this RGB.NET.Core.Color color) { - var (_, r, g, b) = color.GetRGBBytes(); + (_, byte r, byte g, byte b) = color.GetRGBBytes(); return Color.FromRgb(r, g, b); } } diff --git a/src/Artemis.UI/Extensions/TreeViewItemExtensions.cs b/src/Artemis.UI/Extensions/TreeViewItemExtensions.cs index 7b6a6fc5c..193030750 100644 --- a/src/Artemis.UI/Extensions/TreeViewItemExtensions.cs +++ b/src/Artemis.UI/Extensions/TreeViewItemExtensions.cs @@ -1,4 +1,5 @@ -using System.Windows.Controls; +using System.Windows; +using System.Windows.Controls; using System.Windows.Media; namespace Artemis.UI.Extensions @@ -15,7 +16,7 @@ namespace Artemis.UI.Extensions private static TreeViewItem GetParent(TreeViewItem item) { - var parent = VisualTreeHelper.GetParent(item); + DependencyObject parent = VisualTreeHelper.GetParent(item); while (!(parent is TreeViewItem || parent is TreeView)) parent = VisualTreeHelper.GetParent(parent); return parent as TreeViewItem; diff --git a/src/Artemis.UI/Ninject/InstanceProviders/DataBindingsViewModelInstanceProvider.cs b/src/Artemis.UI/Ninject/InstanceProviders/DataBindingsViewModelInstanceProvider.cs index 8a8e829fe..3ab21713f 100644 --- a/src/Artemis.UI/Ninject/InstanceProviders/DataBindingsViewModelInstanceProvider.cs +++ b/src/Artemis.UI/Ninject/InstanceProviders/DataBindingsViewModelInstanceProvider.cs @@ -14,7 +14,7 @@ namespace Artemis.UI.Ninject.InstanceProviders return base.GetType(methodInfo, arguments); // Find LayerProperty type - var descriptionPropertyType = arguments[0].GetType(); + Type descriptionPropertyType = arguments[0].GetType(); while (descriptionPropertyType != null && (!descriptionPropertyType.IsGenericType || descriptionPropertyType.GetGenericTypeDefinition() != typeof(DataBindingRegistration<,>))) descriptionPropertyType = descriptionPropertyType.BaseType; if (descriptionPropertyType == null) diff --git a/src/Artemis.UI/Ninject/InstanceProviders/LayerPropertyViewModelInstanceProvider.cs b/src/Artemis.UI/Ninject/InstanceProviders/LayerPropertyViewModelInstanceProvider.cs index 34ed14551..506ebce40 100644 --- a/src/Artemis.UI/Ninject/InstanceProviders/LayerPropertyViewModelInstanceProvider.cs +++ b/src/Artemis.UI/Ninject/InstanceProviders/LayerPropertyViewModelInstanceProvider.cs @@ -15,7 +15,7 @@ namespace Artemis.UI.Ninject.InstanceProviders return base.GetType(methodInfo, arguments); // Find LayerProperty type - var layerPropertyType = arguments[0].GetType(); + Type layerPropertyType = arguments[0].GetType(); while (layerPropertyType != null && (!layerPropertyType.IsGenericType || layerPropertyType.GetGenericTypeDefinition() != typeof(LayerProperty<>))) layerPropertyType = layerPropertyType.BaseType; if (layerPropertyType == null) diff --git a/src/Artemis.UI/Screens/Modules/ModuleRootViewModel.cs b/src/Artemis.UI/Screens/Modules/ModuleRootViewModel.cs index d8086b15f..1986f77b0 100644 --- a/src/Artemis.UI/Screens/Modules/ModuleRootViewModel.cs +++ b/src/Artemis.UI/Screens/Modules/ModuleRootViewModel.cs @@ -39,13 +39,13 @@ namespace Artemis.UI.Screens.Modules if (Module.ModuleTabs != null) { - var moduleTabs = new List(Module.ModuleTabs); - foreach (var moduleTab in moduleTabs.Where(m => m != null)) + List moduleTabs = new List(Module.ModuleTabs); + foreach (ModuleTab moduleTab in moduleTabs.Where(m => m != null)) { - var module = new ConstructorArgument("module", Module); - var displayName = new ConstructorArgument("displayName", DisplayName); + ConstructorArgument module = new ConstructorArgument("module", Module); + ConstructorArgument displayName = new ConstructorArgument("displayName", DisplayName); - var viewModel = (ModuleViewModel) Module.PluginInfo.Kernel.Get(moduleTab.Type, module, displayName); + ModuleViewModel viewModel = (ModuleViewModel) Module.PluginInfo.Kernel.Get(moduleTab.Type, module, displayName); Items.Add(viewModel); } } diff --git a/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionGroupViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionGroupViewModel.cs index 27f6875fc..ad2afb3d5 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionGroupViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionGroupViewModel.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Artemis.Core; @@ -63,7 +64,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions public void SelectBooleanOperator(string type) { - var enumValue = Enum.Parse(type); + BooleanOperator enumValue = Enum.Parse(type); DataModelConditionGroup.BooleanOperator = enumValue; NotifyOfPropertyChange(nameof(SelectedBooleanOperator)); @@ -108,12 +109,12 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions NotifyOfPropertyChange(nameof(SelectedBooleanOperator)); // Remove VMs of effects no longer applied on the layer - var toRemove = Items.Where(c => !DataModelConditionGroup.Children.Contains(c.Model)).ToList(); + List toRemove = Items.Where(c => !DataModelConditionGroup.Children.Contains(c.Model)).ToList(); // Using RemoveRange breaks our lovely animations - foreach (var DataModelConditionViewModel in toRemove) + foreach (DataModelConditionViewModel DataModelConditionViewModel in toRemove) Items.Remove(DataModelConditionViewModel); - foreach (var childModel in Model.Children) + foreach (DataModelConditionPart childModel in Model.Children) { if (Items.Any(c => c.Model == childModel)) continue; @@ -137,7 +138,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions } } - foreach (var childViewModel in Items) + foreach (DataModelConditionViewModel childViewModel in Items) childViewModel.Update(); if (IsRootGroup && Parent is DisplayConditionsViewModel displayConditionsViewModel) diff --git a/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionListPredicateViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionListPredicateViewModel.cs index 61f60d8e1..84e3c6c61 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionListPredicateViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionListPredicateViewModel.cs @@ -99,7 +99,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions public void Initialize() { - var listDataModel = GetListDataModel(); + DataModelVisualizationViewModel listDataModel = GetListDataModel(); if (listDataModel.Children.Count == 1 && listDataModel.Children.First() is DataModelListPropertyViewModel) _isPrimitiveList = true; else @@ -114,7 +114,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions } // Determine which types are currently supported - var editors = _dataModelUIService.RegisteredDataModelEditors; + IReadOnlyCollection editors = _dataModelUIService.RegisteredDataModelEditors; _supportedInputTypes = editors.Select(e => e.SupportedType).ToList(); _supportedInputTypes.AddRange(editors.Where(e => e.CompatibleConversionTypes != null).SelectMany(e => e.CompatibleConversionTypes)); @@ -123,7 +123,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions public override void Update() { - var listDataModelGuid = DataModelConditionListPredicate.DataModelConditionList.ListDataModel.PluginInfo.Guid; + Guid listDataModelGuid = DataModelConditionListPredicate.DataModelConditionList.ListDataModel.PluginInfo.Guid; if (!_isPrimitiveList) { LeftSideSelectionViewModel.FilterTypes = _supportedInputTypes.ToArray(); @@ -133,7 +133,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions ); } - var leftSideType = _isPrimitiveList + Type leftSideType = _isPrimitiveList ? DataModelConditionListPredicate.DataModelConditionList.ListType : LeftSideSelectionViewModel.SelectedPropertyViewModel?.DataModelPath?.GetPropertyType(); @@ -235,8 +235,8 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions private DataModelVisualizationViewModel GetListDataModel() { - var dataModel = _dataModelUIService.GetPluginDataModelVisualization(_profileEditorService.GetCurrentModule(), true); - var listDataModel = (DataModelListViewModel) dataModel.GetChildByPath( + DataModelPropertiesViewModel dataModel = _dataModelUIService.GetPluginDataModelVisualization(_profileEditorService.GetCurrentModule(), true); + DataModelListViewModel listDataModel = (DataModelListViewModel) dataModel.GetChildByPath( DataModelConditionListPredicate.DataModelConditionList.ListDataModel.PluginInfo.Guid, DataModelConditionListPredicate.DataModelConditionList.ListPropertyPath ); diff --git a/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionListViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionListViewModel.cs index ebead3072..0e1291382 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionListViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionListViewModel.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Linq; using System.Windows.Media; using Artemis.Core; @@ -50,7 +51,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions public void SelectListOperator(string type) { - var enumValue = Enum.Parse(type); + ListOperator enumValue = Enum.Parse(type); DataModelConditionList.ListOperator = enumValue; NotifyOfPropertyChange(nameof(SelectedListOperator)); @@ -110,24 +111,24 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions NotifyOfPropertyChange(nameof(SelectedListOperator)); // Remove VMs of effects no longer applied on the layer - var toRemove = Items.Where(c => !DataModelConditionList.Children.Contains(c.Model)).ToList(); + List toRemove = Items.Where(c => !DataModelConditionList.Children.Contains(c.Model)).ToList(); // Using RemoveRange breaks our lovely animations - foreach (var conditionViewModel in toRemove) + foreach (DataModelConditionViewModel conditionViewModel in toRemove) Items.Remove(conditionViewModel); - foreach (var childModel in Model.Children) + foreach (DataModelConditionPart childModel in Model.Children) { if (Items.Any(c => c.Model == childModel)) continue; if (!(childModel is DataModelConditionGroup dataModelConditionGroup)) continue; - var viewModel = _dataModelConditionsVmFactory.DataModelConditionGroupViewModel(dataModelConditionGroup, true); + DataModelConditionGroupViewModel viewModel = _dataModelConditionsVmFactory.DataModelConditionGroupViewModel(dataModelConditionGroup, true); viewModel.IsRootGroup = true; Items.Add(viewModel); } - foreach (var childViewModel in Items) + foreach (DataModelConditionViewModel childViewModel in Items) childViewModel.Update(); } diff --git a/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionPredicateViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionPredicateViewModel.cs index fd200ceba..9dfc8e826 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionPredicateViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionPredicateViewModel.cs @@ -106,7 +106,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions LeftSideSelectionViewModel = _dataModelUIService.GetDynamicSelectionViewModel(_profileEditorService.GetCurrentModule()); LeftSideSelectionViewModel.PropertySelected += LeftSideOnPropertySelected; // Determine which types are currently supported - var editors = _dataModelUIService.RegisteredDataModelEditors; + IReadOnlyCollection editors = _dataModelUIService.RegisteredDataModelEditors; _supportedInputTypes = editors.Select(e => e.SupportedType).ToList(); _supportedInputTypes.AddRange(editors.Where(e => e.CompatibleConversionTypes != null).SelectMany(e => e.CompatibleConversionTypes)); @@ -120,7 +120,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions DataModelConditionPredicate.LeftDataModel, DataModelConditionPredicate.LeftPropertyPath ); - var leftSideType = LeftSideSelectionViewModel.SelectedPropertyViewModel?.DataModelPath?.GetPropertyType(); + Type leftSideType = LeftSideSelectionViewModel.SelectedPropertyViewModel?.DataModelPath?.GetPropertyType(); // Get the supported operators Operators.Clear(); @@ -135,7 +135,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions } // Ensure the right side has the proper VM - var targetType = LeftSideSelectionViewModel?.SelectedPropertyViewModel?.DataModelPath?.GetPropertyType(); + Type targetType = LeftSideSelectionViewModel?.SelectedPropertyViewModel?.DataModelPath?.GetPropertyType(); if (DataModelConditionPredicate.PredicateType == ProfileRightSideType.Dynamic && SelectedOperator.SupportsRightSide) { DisposeRightSideStatic(); diff --git a/src/Artemis.UI/Screens/ProfileEditor/Dialogs/ProfileExportViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Dialogs/ProfileExportViewModel.cs index d32bc61bb..4e7a82817 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Dialogs/ProfileExportViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Dialogs/ProfileExportViewModel.cs @@ -24,7 +24,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Dialogs public void Accept() { - var encoded = _profileService.ExportProfile(ProfileDescriptor); + string encoded = _profileService.ExportProfile(ProfileDescriptor); Clipboard.SetText(encoded); _mainMessageQueue.Enqueue("Profile contents exported to clipboard."); diff --git a/src/Artemis.UI/Screens/ProfileEditor/Dialogs/ProfileImportViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Dialogs/ProfileImportViewModel.cs index 52e51de3c..3c824de7e 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Dialogs/ProfileImportViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Dialogs/ProfileImportViewModel.cs @@ -1,4 +1,5 @@ -using Artemis.Core.Modules; +using Artemis.Core; +using Artemis.Core.Modules; using Artemis.Core.Services; using Artemis.UI.Shared.Services; using ICSharpCode.AvalonEdit.Document; @@ -32,7 +33,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Dialogs public void Accept() { - var descriptor = _profileService.ImportProfile(Document.Text, ProfileModule); + ProfileDescriptor descriptor = _profileService.ImportProfile(Document.Text, ProfileModule); _mainMessageQueue.Enqueue("Profile imported."); Session.Close(descriptor); } diff --git a/src/Artemis.UI/Screens/ProfileEditor/Dialogs/RenameView.xaml.cs b/src/Artemis.UI/Screens/ProfileEditor/Dialogs/RenameView.xaml.cs index 1d5130ada..e48bd38f1 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Dialogs/RenameView.xaml.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Dialogs/RenameView.xaml.cs @@ -16,7 +16,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Dialogs private void FrameworkElement_OnLoaded(object sender, RoutedEventArgs e) { - var textBox = (TextBox) sender; + TextBox textBox = (TextBox) sender; Keyboard.Focus(textBox); textBox.SelectAll(); } diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/ConditionalDataBindingModeViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/ConditionalDataBindingModeViewModel.cs index 03a50daa2..680107b7f 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/ConditionalDataBindingModeViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/ConditionalDataBindingModeViewModel.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using Artemis.Core; @@ -48,7 +49,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio { ConditionalDataBinding.ConditionsUpdated -= ConditionalDataBindingOnConditionsUpdated; - foreach (var conditionViewModel in ConditionViewModels) + foreach (DataBindingConditionViewModel conditionViewModel in ConditionViewModels) conditionViewModel.Dispose(); ConditionViewModels.Clear(); } @@ -57,10 +58,10 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio public void AddCondition(string type) { - var condition = ConditionalDataBinding.AddCondition(); + DataBindingCondition condition = ConditionalDataBinding.AddCondition(); // Find the VM of the new condition - var viewModel = ConditionViewModels.First(c => c.DataBindingCondition == condition); + DataBindingConditionViewModel viewModel = ConditionViewModels.First(c => c.DataBindingCondition == condition); viewModel.ActiveItem.AddCondition(type); _profileEditorService.UpdateSelectedProfileElement(); @@ -71,15 +72,15 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio _updating = true; // Remove old VMs - var toRemove = ConditionViewModels.Where(c => !ConditionalDataBinding.Conditions.Contains(c.DataBindingCondition)).ToList(); - foreach (var dataBindingConditionViewModel in toRemove) + List> toRemove = ConditionViewModels.Where(c => !ConditionalDataBinding.Conditions.Contains(c.DataBindingCondition)).ToList(); + foreach (DataBindingConditionViewModel dataBindingConditionViewModel in toRemove) { ConditionViewModels.Remove(dataBindingConditionViewModel); dataBindingConditionViewModel.Dispose(); } // Add missing VMs - foreach (var condition in ConditionalDataBinding.Conditions) + foreach (DataBindingCondition condition in ConditionalDataBinding.Conditions) { if (ConditionViewModels.All(c => c.DataBindingCondition != condition)) ConditionViewModels.Add(_dataBindingsVmFactory.DataBindingConditionViewModel(condition)); @@ -103,9 +104,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio if (_updating || e.Action != NotifyCollectionChangedAction.Add) return; - for (var index = 0; index < ConditionViewModels.Count; index++) + for (int index = 0; index < ConditionViewModels.Count; index++) { - var conditionViewModel = ConditionViewModels[index]; + DataBindingConditionViewModel conditionViewModel = ConditionViewModels[index]; conditionViewModel.DataBindingCondition.Order = index + 1; } diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs index 88ade0bd2..31b5f07be 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs @@ -226,7 +226,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings Registration.DataBinding.Update(0.04); if (ActiveItem.SupportsTestValue) { - var currentValue = Registration.Converter.ConvertFromObject(ActiveItem?.GetTestValue() ?? default(TProperty)); + TProperty currentValue = Registration.Converter.ConvertFromObject(ActiveItem?.GetTestValue() ?? default(TProperty)); TestInputValue.UpdateValue(currentValue); TestResultValue.UpdateValue(Registration.DataBinding != null ? Registration.DataBinding.GetValue(currentValue) : default); } diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingsViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingsViewModel.cs index d1ce4357c..81e4c9e12 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingsViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingsViewModel.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using Artemis.Core; using Artemis.UI.Ninject.Factories; using Artemis.UI.Shared.Services; using Stylet; @@ -36,15 +38,15 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings { Items.Clear(); - var layerProperty = _profileEditorService.SelectedDataBinding; + ILayerProperty layerProperty = _profileEditorService.SelectedDataBinding; if (layerProperty == null) return; - var registrations = layerProperty.GetAllDataBindingRegistrations(); + List registrations = layerProperty.GetAllDataBindingRegistrations(); // Create a data binding VM for each data bindable property. These VMs will be responsible for retrieving // and creating the actual data bindings - foreach (var registration in registrations) + foreach (IDataBindingRegistration registration in registrations) Items.Add(_dataBindingsVmFactory.DataBindingViewModel(registration)); SelectedItemIndex = 0; diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DataBindingModifierViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DataBindingModifierViewModel.cs index 983b8dd66..a2d4eea65 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DataBindingModifierViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DataBindingModifierViewModel.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using Artemis.Core; using Artemis.Core.Services; @@ -92,7 +93,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa { if (Modifier.ParameterType == ProfileRightSideType.Dynamic) { - var sourceType = Modifier.DirectDataBinding.GetSourceType(); + Type sourceType = Modifier.DirectDataBinding.GetSourceType(); Modifier.UpdateParameter((Modifier.ModifierType.ParameterType ?? sourceType).GetDefault()); } else @@ -116,7 +117,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa private void Update() { - var sourceType = Modifier.DirectDataBinding.GetSourceType(); + Type sourceType = Modifier.DirectDataBinding.GetSourceType(); if (sourceType == null) throw new ArtemisUIException("Cannot use a data binding modifier VM for a data binding without a source"); @@ -150,11 +151,11 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa } // Modifier type - var root = new ModifierTypeCategoryViewModel(null, null); - var modifierTypes = _dataBindingService.GetCompatibleModifierTypes(sourceType).GroupBy(t => t.Category); - foreach (var dataBindingModifierTypes in modifierTypes) + ModifierTypeCategoryViewModel root = new ModifierTypeCategoryViewModel(null, null); + IEnumerable> modifierTypes = _dataBindingService.GetCompatibleModifierTypes(sourceType).GroupBy(t => t.Category); + foreach (IGrouping dataBindingModifierTypes in modifierTypes) { - var viewModels = dataBindingModifierTypes.Select(t => new ModifierTypeViewModel(t)); + IEnumerable viewModels = dataBindingModifierTypes.Select(t => new ModifierTypeViewModel(t)); if (dataBindingModifierTypes.Key == null) root.Children.AddRange(viewModels); else diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DirectDataBindingModeViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DirectDataBindingModeViewModel.cs index 108fbacbd..67abde326 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DirectDataBindingModeViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DirectDataBindingModeViewModel.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using Artemis.Core; @@ -75,7 +76,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa TargetSelectionViewModel.Dispose(); DirectDataBinding.ModifiersUpdated -= DirectDataBindingOnModifiersUpdated; - foreach (var dataBindingModifierViewModel in ModifierViewModels) + foreach (DataBindingModifierViewModel dataBindingModifierViewModel in ModifierViewModels) dataBindingModifierViewModel.Dispose(); ModifierViewModels.Clear(); } @@ -96,9 +97,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa if (_updating || e.Action != NotifyCollectionChangedAction.Add) return; - for (var index = 0; index < ModifierViewModels.Count; index++) + for (int index = 0; index < ModifierViewModels.Count; index++) { - var dataBindingModifierViewModel = ModifierViewModels[index]; + DataBindingModifierViewModel dataBindingModifierViewModel = ModifierViewModels[index]; dataBindingModifierViewModel.Modifier.Order = index + 1; } @@ -132,15 +133,15 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa _updating = true; // Remove old VMs - var toRemove = ModifierViewModels.Where(m => !DirectDataBinding.Modifiers.Contains(m.Modifier)).ToList(); - foreach (var modifierViewModel in toRemove) + List> toRemove = ModifierViewModels.Where(m => !DirectDataBinding.Modifiers.Contains(m.Modifier)).ToList(); + foreach (DataBindingModifierViewModel modifierViewModel in toRemove) { ModifierViewModels.Remove(modifierViewModel); modifierViewModel.Dispose(); } // Add missing VMs - foreach (var modifier in DirectDataBinding.Modifiers) + foreach (DataBindingModifier modifier in DirectDataBinding.Modifiers) { if (ModifierViewModels.All(m => m.Modifier != modifier)) ModifierViewModels.Add(_dataBindingsVmFactory.DataBindingModifierViewModel(modifier)); diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/LayerEffects/EffectsViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/LayerEffects/EffectsViewModel.cs index 199318a63..1abc15d2c 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/LayerEffects/EffectsViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/LayerEffects/EffectsViewModel.cs @@ -1,4 +1,5 @@ -using System.ComponentModel; +using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Threading.Tasks; using Artemis.Core; @@ -34,14 +35,14 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.LayerEffects public void PopulateDescriptors() { - var layerBrushProviders = _pluginService.GetPluginsOfType(); - var descriptors = layerBrushProviders.SelectMany(l => l.LayerEffectDescriptors).ToList(); + List layerBrushProviders = _pluginService.GetPluginsOfType(); + List descriptors = layerBrushProviders.SelectMany(l => l.LayerEffectDescriptors).ToList(); Items.AddRange(descriptors.Except(Items)); Items.RemoveRange(Items.Except(descriptors)); // Sort by display name - var index = 0; - foreach (var layerEffectDescriptor in Items.OrderBy(d => d.DisplayName).ToList()) + int index = 0; + foreach (LayerEffectDescriptor layerEffectDescriptor in Items.OrderBy(d => d.DisplayName).ToList()) { if (Items.IndexOf(layerEffectDescriptor) != index) ((BindableCollection) Items).Move(Items.IndexOf(layerEffectDescriptor), index); diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/LayerPropertiesViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/LayerPropertiesViewModel.cs index 3bacabc15..3ed17124f 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/LayerPropertiesViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/LayerPropertiesViewModel.cs @@ -7,6 +7,7 @@ using System.Windows; using System.Windows.Input; using System.Windows.Media; using Artemis.Core; +using Artemis.Core.LayerEffects; using Artemis.Core.Services; using Artemis.UI.Ninject.Factories; using Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings; @@ -230,8 +231,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties public List GetAllLayerPropertyGroupViewModels() { - var groups = LayerPropertyGroups.ToList(); - var toAdd = groups.SelectMany(g => g.Children).Where(g => g is LayerPropertyGroupViewModel).Cast().ToList(); + List groups = LayerPropertyGroups.ToList(); + List toAdd = groups.SelectMany(g => g.Children).Where(g => g is LayerPropertyGroupViewModel).Cast().ToList(); groups.AddRange(toAdd); return groups; } @@ -245,7 +246,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties SelectedLayer.LayerBrushUpdated -= SelectedLayerOnLayerBrushUpdated; // Clear old properties - foreach (var layerPropertyGroupViewModel in LayerPropertyGroups) + foreach (LayerPropertyGroupViewModel layerPropertyGroupViewModel in LayerPropertyGroups) layerPropertyGroupViewModel.Dispose(); LayerPropertyGroups.Clear(); _brushPropertyGroup = null; @@ -285,7 +286,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties if (SelectedLayer == null) return; - var hideRenderRelatedProperties = SelectedLayer?.LayerBrush != null && !SelectedLayer.LayerBrush.SupportsTransformation; + bool hideRenderRelatedProperties = SelectedLayer?.LayerBrush != null && !SelectedLayer.LayerBrush.SupportsTransformation; SelectedLayer.General.ShapeType.IsHidden = hideRenderRelatedProperties; SelectedLayer.General.ResizeMode.IsHidden = hideRenderRelatedProperties; @@ -313,14 +314,14 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties return; // Remove VMs of effects no longer applied on the layer - var toRemove = LayerPropertyGroups + List toRemove = LayerPropertyGroups .Where(l => l.LayerPropertyGroup.LayerEffect != null && !SelectedProfileElement.LayerEffects.Contains(l.LayerPropertyGroup.LayerEffect)) .ToList(); LayerPropertyGroups.RemoveRange(toRemove); - foreach (var layerPropertyGroupViewModel in toRemove) + foreach (LayerPropertyGroupViewModel layerPropertyGroupViewModel in toRemove) layerPropertyGroupViewModel.Dispose(); - foreach (var layerEffect in SelectedProfileElement.LayerEffects) + foreach (BaseLayerEffect layerEffect in SelectedProfileElement.LayerEffects) { if (LayerPropertyGroups.Any(l => l.LayerPropertyGroup.LayerEffect == layerEffect) || layerEffect.BaseProperties == null) continue; @@ -334,26 +335,26 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties private void SortProperties() { // Get all non-effect properties - var nonEffectProperties = LayerPropertyGroups + List nonEffectProperties = LayerPropertyGroups .Where(l => l.TreeGroupViewModel.GroupType != LayerEffectRoot) .ToList(); // Order the effects - var effectProperties = LayerPropertyGroups + List effectProperties = LayerPropertyGroups .Where(l => l.TreeGroupViewModel.GroupType == LayerEffectRoot) .OrderBy(l => l.LayerPropertyGroup.LayerEffect.Order) .ToList(); // Put the non-effect properties in front - for (var index = 0; index < nonEffectProperties.Count; index++) + for (int index = 0; index < nonEffectProperties.Count; index++) { - var layerPropertyGroupViewModel = nonEffectProperties[index]; + LayerPropertyGroupViewModel layerPropertyGroupViewModel = nonEffectProperties[index]; LayerPropertyGroups.Move(LayerPropertyGroups.IndexOf(layerPropertyGroupViewModel), index); } // Put the effect properties after, sorted by their order - for (var index = 0; index < effectProperties.Count; index++) + for (int index = 0; index < effectProperties.Count; index++) { - var layerPropertyGroupViewModel = effectProperties[index]; + LayerPropertyGroupViewModel layerPropertyGroupViewModel = effectProperties[index]; LayerPropertyGroups.Move(LayerPropertyGroups.IndexOf(layerPropertyGroupViewModel), index + nonEffectProperties.Count); } } @@ -378,8 +379,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties if (dropInfo.InsertIndex == 1) return; - var source = dropInfo.Data as LayerPropertyGroupViewModel; - var target = dropInfo.TargetItem as LayerPropertyGroupViewModel; + LayerPropertyGroupViewModel source = dropInfo.Data as LayerPropertyGroupViewModel; + LayerPropertyGroupViewModel target = dropInfo.TargetItem as LayerPropertyGroupViewModel; if (source == target || target?.TreeGroupViewModel.GroupType != LayerEffectRoot || @@ -397,8 +398,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties if (dropInfo.InsertIndex == 1) return; - var source = dropInfo.Data as LayerPropertyGroupViewModel; - var target = dropInfo.TargetItem as LayerPropertyGroupViewModel; + LayerPropertyGroupViewModel source = dropInfo.Data as LayerPropertyGroupViewModel; + LayerPropertyGroupViewModel target = dropInfo.TargetItem as LayerPropertyGroupViewModel; if (source == target || target?.TreeGroupViewModel.GroupType != LayerEffectRoot || @@ -430,8 +431,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties private void ApplyCurrentEffectsOrder() { - var order = 1; - foreach (var groupViewModel in LayerPropertyGroups.Where(p => p.TreeGroupViewModel.GroupType == LayerEffectRoot)) + int order = 1; + foreach (LayerPropertyGroupViewModel groupViewModel in LayerPropertyGroups.Where(p => p.TreeGroupViewModel.GroupType == LayerEffectRoot)) { groupViewModel.UpdateOrder(order); order++; @@ -486,15 +487,15 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties public void GoToPreviousFrame() { - var frameTime = 1000.0 / SettingsService.GetSetting("Core.TargetFrameRate", 25).Value; - var newTime = Math.Max(0, Math.Round((ProfileEditorService.CurrentTime.TotalMilliseconds - frameTime) / frameTime) * frameTime); + double frameTime = 1000.0 / SettingsService.GetSetting("Core.TargetFrameRate", 25).Value; + double newTime = Math.Max(0, Math.Round((ProfileEditorService.CurrentTime.TotalMilliseconds - frameTime) / frameTime) * frameTime); ProfileEditorService.CurrentTime = TimeSpan.FromMilliseconds(newTime); } public void GoToNextFrame() { - var frameTime = 1000.0 / SettingsService.GetSetting("Core.TargetFrameRate", 25).Value; - var newTime = Math.Round((ProfileEditorService.CurrentTime.TotalMilliseconds + frameTime) / frameTime) * frameTime; + double frameTime = 1000.0 / SettingsService.GetSetting("Core.TargetFrameRate", 25).Value; + double newTime = Math.Round((ProfileEditorService.CurrentTime.TotalMilliseconds + frameTime) / frameTime) * frameTime; newTime = Math.Min(newTime, CalculateEndTime().TotalMilliseconds); ProfileEditorService.CurrentTime = TimeSpan.FromMilliseconds(newTime); } @@ -522,7 +523,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties private TimeSpan CalculateEndTime() { - var keyframeViewModels = LayerPropertyGroups.SelectMany(g => g.GetAllKeyframeViewModels(false)).ToList(); + List keyframeViewModels = LayerPropertyGroups.SelectMany(g => g.GetAllKeyframeViewModels(false)).ToList(); // If there are no keyframes, don't stop at all if (!keyframeViewModels.Any()) @@ -533,7 +534,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties private TimeSpan GetCurrentSegmentStart() { - var current = ProfileEditorService.CurrentTime; + TimeSpan current = ProfileEditorService.CurrentTime; if (current < StartTimelineSegmentViewModel.SegmentEnd) return StartTimelineSegmentViewModel.SegmentStart; if (current < MainTimelineSegmentViewModel.SegmentEnd) @@ -546,7 +547,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties private TimeSpan GetCurrentSegmentEnd() { - var current = ProfileEditorService.CurrentTime; + TimeSpan current = ProfileEditorService.CurrentTime; if (current < StartTimelineSegmentViewModel.SegmentEnd) return StartTimelineSegmentViewModel.SegmentEnd; if (current < MainTimelineSegmentViewModel.SegmentEnd) @@ -561,7 +562,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties { Execute.PostToUIThread(() => { - var newTime = ProfileEditorService.CurrentTime.Add(TimeSpan.FromSeconds(e.DeltaTime)); + TimeSpan newTime = ProfileEditorService.CurrentTime.Add(TimeSpan.FromSeconds(e.DeltaTime)); if (SelectedProfileElement != null) { if (Repeating && RepeatTimeline) @@ -604,9 +605,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties if (e.LeftButton == MouseButtonState.Pressed) { // Get the parent grid, need that for our position - var parent = (IInputElement) VisualTreeHelper.GetParent((DependencyObject) sender); - var x = Math.Max(0, e.GetPosition(parent).X); - var newTime = TimeSpan.FromSeconds(x / ProfileEditorService.PixelsPerSecond); + IInputElement parent = (IInputElement) VisualTreeHelper.GetParent((DependencyObject) sender); + double x = Math.Max(0, e.GetPosition(parent).X); + TimeSpan newTime = TimeSpan.FromSeconds(x / ProfileEditorService.PixelsPerSecond); // Round the time to something that fits the current zoom level if (ProfileEditorService.PixelsPerSecond < 200) @@ -619,8 +620,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties // If holding down shift, snap to the closest segment or keyframe if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) { - var snapTimes = LayerPropertyGroups.SelectMany(g => g.GetAllKeyframeViewModels(true)).Select(k => k.Position).ToList(); - var snappedTime = ProfileEditorService.SnapToTimeline(newTime, TimeSpan.FromMilliseconds(1000f / ProfileEditorService.PixelsPerSecond * 5), true, false, snapTimes); + List snapTimes = LayerPropertyGroups.SelectMany(g => g.GetAllKeyframeViewModels(true)).Select(k => k.Position).ToList(); + TimeSpan snappedTime = ProfileEditorService.SnapToTimeline(newTime, TimeSpan.FromMilliseconds(1000f / ProfileEditorService.PixelsPerSecond * 5), true, false, snapTimes); ProfileEditorService.CurrentTime = snappedTime; return; } @@ -628,7 +629,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties // If holding down control, round to the closest 50ms if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { - var roundedTime = TimeSpan.FromMilliseconds(Math.Round(newTime.TotalMilliseconds / 50.0) * 50.0); + TimeSpan roundedTime = TimeSpan.FromMilliseconds(Math.Round(newTime.TotalMilliseconds / 50.0) * 50.0); ProfileEditorService.CurrentTime = roundedTime; return; } diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/LayerPropertyGroupViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/LayerPropertyGroupViewModel.cs index b1e29fca2..9932d6757 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/LayerPropertyGroupViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/LayerPropertyGroupViewModel.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Reflection; using Artemis.Core; using Artemis.UI.Ninject.Factories; using Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline; @@ -56,7 +57,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties { TimelineGroupViewModel.Dispose(); LayerPropertyGroup.VisibilityChanged -= LayerPropertyGroupOnVisibilityChanged; - foreach (var child in Children) + foreach (PropertyChangedBase child in Children) { if (child is IDisposable disposableChild) disposableChild.Dispose(); @@ -71,11 +72,11 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties public List GetAllKeyframeViewModels(bool expandedOnly) { - var result = new List(); + List result = new List(); if (expandedOnly && !IsExpanded) return result; - foreach (var child in Children) + foreach (PropertyChangedBase child in Children) { if (child is LayerPropertyViewModel layerPropertyViewModel) result.AddRange(layerPropertyViewModel.TimelinePropertyViewModel.GetAllKeyframeViewModels()); @@ -94,7 +95,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties /// The position at which to start removing keyframes, if null this will end at the last keyframe public virtual void WipeKeyframes(TimeSpan? start, TimeSpan? end) { - foreach (var child in Children) + foreach (PropertyChangedBase child in Children) { if (child is LayerPropertyViewModel layerPropertyViewModel) layerPropertyViewModel.TimelinePropertyViewModel.WipeKeyframes(start, end); @@ -114,7 +115,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties /// The amount to shift the keyframes for public void ShiftKeyframes(TimeSpan? start, TimeSpan? end, TimeSpan amount) { - foreach (var child in Children) + foreach (PropertyChangedBase child in Children) { if (child is LayerPropertyViewModel layerPropertyViewModel) layerPropertyViewModel.TimelinePropertyViewModel.ShiftKeyframes(start, end, amount); @@ -134,16 +135,16 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties { // Get all properties and property groups and create VMs for them // The group has methods for getting this without reflection but then we lose the order of the properties as they are defined on the group - foreach (var propertyInfo in LayerPropertyGroup.GetType().GetProperties()) + foreach (PropertyInfo propertyInfo in LayerPropertyGroup.GetType().GetProperties()) { - var propertyAttribute = (PropertyDescriptionAttribute) Attribute.GetCustomAttribute(propertyInfo, typeof(PropertyDescriptionAttribute)); - var groupAttribute = (PropertyGroupDescriptionAttribute) Attribute.GetCustomAttribute(propertyInfo, typeof(PropertyGroupDescriptionAttribute)); - var value = propertyInfo.GetValue(LayerPropertyGroup); + PropertyDescriptionAttribute propertyAttribute = (PropertyDescriptionAttribute) Attribute.GetCustomAttribute(propertyInfo, typeof(PropertyDescriptionAttribute)); + PropertyGroupDescriptionAttribute groupAttribute = (PropertyGroupDescriptionAttribute) Attribute.GetCustomAttribute(propertyInfo, typeof(PropertyGroupDescriptionAttribute)); + object? value = propertyInfo.GetValue(LayerPropertyGroup); // Create VMs for properties on the group if (propertyAttribute != null && value is ILayerProperty layerProperty) { - var layerPropertyViewModel = _layerPropertyVmFactory.LayerPropertyViewModel(layerProperty); + LayerPropertyViewModel layerPropertyViewModel = _layerPropertyVmFactory.LayerPropertyViewModel(layerProperty); // After creation ensure a supported input VM was found, if not, discard the VM if (!layerPropertyViewModel.TreePropertyViewModel.HasPropertyInputViewModel) layerPropertyViewModel.Dispose(); diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/Controls/PropertyTimelineHeader.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/Controls/PropertyTimelineHeader.cs index 8fbc466ee..903f8eb34 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/Controls/PropertyTimelineHeader.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/Controls/PropertyTimelineHeader.cs @@ -71,23 +71,23 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline.Controls base.OnRender(drawingContext); UpdateTimeScale(); - var linePen = new Pen(Fill, 1); - var width = HorizontalOffset + VisibleWidth; - var frameStart = 0; + Pen linePen = new Pen(Fill, 1); + double width = HorizontalOffset + VisibleWidth; + int frameStart = 0; - var units = PixelsPerSecond / _subd1; - var offsetUnits = frameStart * PixelsPerSecond % units; + double units = PixelsPerSecond / _subd1; + double offsetUnits = frameStart * PixelsPerSecond % units; // Labels - var count = (width + offsetUnits) / units; - for (var i = 0; i < count; i++) + double count = (width + offsetUnits) / units; + for (int i = 0; i < count; i++) { - var x = i * units - offsetUnits; + double x = i * units - offsetUnits; // Add a 100px margin to allow the text to partially render when needed if (x < HorizontalOffset - 100 || x > HorizontalOffset + width) continue; - var t = TimeSpan.FromSeconds((i * units - offsetUnits) / PixelsPerSecond + frameStart); + TimeSpan t = TimeSpan.FromSeconds((i * units - offsetUnits) / PixelsPerSecond + frameStart); // 0.00 is always formatted as 0.00 if (t == TimeSpan.Zero) RenderLabel(drawingContext, "0.00", x); @@ -102,9 +102,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline.Controls // Large ticks units = PixelsPerSecond / _subd2; count = (width + offsetUnits) / units; - for (var i = 0; i < count; i++) + for (int i = 0; i < count; i++) { - var x = i * units - offsetUnits; + double x = i * units - offsetUnits; if (x == 0 && OffsetFirstValue) drawingContext.DrawLine(linePen, new Point(1, 20), new Point(1, 30)); else if (x > HorizontalOffset && x < HorizontalOffset + width) @@ -112,13 +112,13 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline.Controls } // Small ticks - var mul = _subd3 / _subd2; + double mul = _subd3 / _subd2; units = PixelsPerSecond / _subd3; count = (width + offsetUnits) / units; - for (var i = 0; i < count; i++) + for (int i = 0; i < count; i++) { if (Math.Abs(i % mul) < 0.001) continue; - var x = i * units - offsetUnits; + double x = i * units - offsetUnits; if (x > HorizontalOffset && x < HorizontalOffset + width) drawingContext.DrawLine(linePen, new Point(x, 25), new Point(x, 30)); } @@ -126,8 +126,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline.Controls private void RenderLabel(DrawingContext drawingContext, string text, double x) { - var typeFace = new Typeface(FontFamily, new FontStyle(), new FontWeight(), new FontStretch()); - var formattedText = new FormattedText(text, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, typeFace, 9, Fill, null, VisualTreeHelper.GetDpi(this).PixelsPerDip); + Typeface typeFace = new Typeface(FontFamily, new FontStyle(), new FontWeight(), new FontStretch()); + FormattedText formattedText = new FormattedText(text, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, typeFace, 9, Fill, null, VisualTreeHelper.GetDpi(this).PixelsPerDip); if (x == 0 && OffsetFirstValue) drawingContext.DrawText(formattedText, new Point(2, 5)); else diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/Dialogs/TimelineSegmentDialogViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/Dialogs/TimelineSegmentDialogViewModel.cs index 91ee090ee..d6575636e 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/Dialogs/TimelineSegmentDialogViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/Dialogs/TimelineSegmentDialogViewModel.cs @@ -71,7 +71,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline.Dialogs public static TimeSpan CreateTime(string s) { - var parts = s.Split("."); + string[] parts = s.Split("."); // Only seconds provided if (parts.Length == 1) diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelineEasingViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelineEasingViewModel.cs index 7f4489171..23970e95e 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelineEasingViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelineEasingViewModel.cs @@ -19,10 +19,10 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline Description = easingFunction.Humanize(); EasingPoints = new PointCollection(); - for (var i = 1; i <= 10; i++) + for (int i = 1; i <= 10; i++) { - var x = i; - var y = Easings.Interpolate(i / 10.0, EasingFunction) * 10; + int x = i; + double y = Easings.Interpolate(i / 10.0, EasingFunction) * 10; EasingPoints.Add(new Point(x, y)); } } diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelineKeyframeViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelineKeyframeViewModel.cs index 4c48afda8..92e96040b 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelineKeyframeViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelineKeyframeViewModel.cs @@ -55,7 +55,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline _profileEditorService.PixelsPerSecondChanged -= ProfileEditorServiceOnPixelsPerSecondChanged; LayerPropertyKeyframe.PropertyChanged -= LayerPropertyKeyframeOnPropertyChanged; - foreach (var timelineEasingViewModel in EasingViewModels) + foreach (TimelineEasingViewModel timelineEasingViewModel in EasingViewModels) timelineEasingViewModel.EasingModeSelected -= TimelineEasingViewModelOnEasingModeSelected; } @@ -87,7 +87,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline .Cast() .Select(e => new TimelineEasingViewModel(e, e == LayerPropertyKeyframe.EasingFunction))); - foreach (var timelineEasingViewModel in EasingViewModels) + foreach (TimelineEasingViewModel timelineEasingViewModel in EasingViewModels) timelineEasingViewModel.EasingModeSelected += TimelineEasingViewModelOnEasingModeSelected; } @@ -105,7 +105,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline { LayerPropertyKeyframe.EasingFunction = easingViewModel.EasingFunction; // Set every selection to false except on the VM that made the change - foreach (var propertyTrackEasingViewModel in EasingViewModels.Where(vm => vm != easingViewModel)) + foreach (TimelineEasingViewModel propertyTrackEasingViewModel in EasingViewModels.Where(vm => vm != easingViewModel)) propertyTrackEasingViewModel.IsEasingModeSelected = false; _profileEditorService.UpdateSelectedProfileElement(); @@ -162,14 +162,14 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline public void Copy() { - var newKeyframe = new LayerPropertyKeyframe( + LayerPropertyKeyframe newKeyframe = new LayerPropertyKeyframe( LayerPropertyKeyframe.Value, LayerPropertyKeyframe.Position, LayerPropertyKeyframe.EasingFunction, LayerPropertyKeyframe.LayerProperty ); // If possible, shift the keyframe to the right by 11 pixels - var desiredPosition = newKeyframe.Position + TimeSpan.FromMilliseconds(1000f / _profileEditorService.PixelsPerSecond * 11); + TimeSpan desiredPosition = newKeyframe.Position + TimeSpan.FromMilliseconds(1000f / _profileEditorService.PixelsPerSecond * 11); if (desiredPosition <= newKeyframe.LayerProperty.ProfileElement.TimelineLength) newKeyframe.Position = desiredPosition; // Otherwise if possible shift it to the left by 11 pixels diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelinePropertyViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelinePropertyViewModel.cs index f7cc43387..888d0db50 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelinePropertyViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelinePropertyViewModel.cs @@ -44,8 +44,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline start ??= TimeSpan.Zero; end ??= TimeSpan.MaxValue; - var toShift = LayerProperty.Keyframes.Where(k => k.Position >= start && k.Position < end).ToList(); - foreach (var keyframe in toShift) + List> toShift = LayerProperty.Keyframes.Where(k => k.Position >= start && k.Position < end).ToList(); + foreach (LayerPropertyKeyframe keyframe in toShift) LayerProperty.RemoveKeyframe(keyframe); UpdateKeyframes(); @@ -56,8 +56,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline start ??= TimeSpan.Zero; end ??= TimeSpan.MaxValue; - var toShift = LayerProperty.Keyframes.Where(k => k.Position >= start && k.Position < end).ToList(); - foreach (var keyframe in toShift) + List> toShift = LayerProperty.Keyframes.Where(k => k.Position >= start && k.Position < end).ToList(); + foreach (LayerPropertyKeyframe keyframe in toShift) keyframe.Position += amount; UpdateKeyframes(); @@ -90,9 +90,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline // Only show keyframes if they are enabled if (LayerProperty.KeyframesEnabled) { - var keyframes = LayerProperty.Keyframes.ToList(); - var toRemove = Items.Where(t => !keyframes.Contains(t.LayerPropertyKeyframe)).ToList(); - foreach (var timelineKeyframeViewModel in toRemove) + List> keyframes = LayerProperty.Keyframes.ToList(); + List> toRemove = Items.Where(t => !keyframes.Contains(t.LayerPropertyKeyframe)).ToList(); + foreach (TimelineKeyframeViewModel timelineKeyframeViewModel in toRemove) timelineKeyframeViewModel.Dispose(); Items.RemoveRange(toRemove); @@ -104,7 +104,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline else Items.Clear(); - foreach (var timelineKeyframeViewModel in Items) + foreach (TimelineKeyframeViewModel timelineKeyframeViewModel in Items) timelineKeyframeViewModel.Update(); } } diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelineSegmentViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelineSegmentViewModel.cs index 78e651ac0..578bbf7a2 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelineSegmentViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelineSegmentViewModel.cs @@ -197,10 +197,10 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline public void DisableSegment() { - var startSegmentEnd = SelectedProfileElement.StartSegmentLength; - var mainSegmentEnd = SelectedProfileElement.StartSegmentLength + SelectedProfileElement.MainSegmentLength; + TimeSpan startSegmentEnd = SelectedProfileElement.StartSegmentLength; + TimeSpan mainSegmentEnd = SelectedProfileElement.StartSegmentLength + SelectedProfileElement.MainSegmentLength; - var oldSegmentLength = SegmentLength; + TimeSpan oldSegmentLength = SegmentLength; if (Segment == SegmentViewModelType.Start) { @@ -264,10 +264,10 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline return; // Get the parent scroll viewer, need that for our position - var parent = VisualTreeUtilities.FindParent((DependencyObject) sender, "TimelineHeaderScrollViewer"); + ScrollViewer parent = VisualTreeUtilities.FindParent((DependencyObject) sender, "TimelineHeaderScrollViewer"); - var x = Math.Max(0, e.GetPosition(parent).X); - var newTime = TimeSpan.FromSeconds(x / ProfileEditorService.PixelsPerSecond); + double x = Math.Max(0, e.GetPosition(parent).X); + TimeSpan newTime = TimeSpan.FromSeconds(x / ProfileEditorService.PixelsPerSecond); // Round the time to something that fits the current zoom level if (ProfileEditorService.PixelsPerSecond < 200) @@ -280,7 +280,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline // If holding down shift, snap to the closest element on the timeline if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) { - var keyframeTimes = LayerPropertyGroups.SelectMany(g => g.GetAllKeyframeViewModels(true)).Select(k => k.Position).ToList(); + List keyframeTimes = LayerPropertyGroups.SelectMany(g => g.GetAllKeyframeViewModels(true)).Select(k => k.Position).ToList(); newTime = ProfileEditorService.SnapToTimeline(newTime, TimeSpan.FromMilliseconds(1000f / ProfileEditorService.PixelsPerSecond * 5), false, true, keyframeTimes); } // If holding down control, round to the closest 50ms @@ -292,7 +292,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline public void UpdateLength(TimeSpan newTime) { - var oldSegmentLength = SegmentLength; + TimeSpan oldSegmentLength = SegmentLength; if (Segment == SegmentViewModelType.Start) { if (newTime < TimeSpan.FromMilliseconds(100)) @@ -361,7 +361,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline public void ShiftNextSegment(TimeSpan amount) { - var segmentEnd = TimeSpan.Zero; + TimeSpan segmentEnd = TimeSpan.Zero; if (Segment == SegmentViewModelType.Start) segmentEnd = SelectedProfileElement.StartSegmentLength; else if (Segment == SegmentViewModelType.Main) @@ -374,13 +374,13 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline private void WipeKeyframes(TimeSpan? start, TimeSpan? end) { - foreach (var layerPropertyGroupViewModel in LayerPropertyGroups) + foreach (LayerPropertyGroupViewModel layerPropertyGroupViewModel in LayerPropertyGroups) layerPropertyGroupViewModel.WipeKeyframes(start, end); } private void ShiftKeyframes(TimeSpan? start, TimeSpan? end, TimeSpan amount) { - foreach (var layerPropertyGroupViewModel in LayerPropertyGroups) + foreach (LayerPropertyGroupViewModel layerPropertyGroupViewModel in LayerPropertyGroups) layerPropertyGroupViewModel.ShiftKeyframes(start, end, amount); } } diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelineViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelineViewModel.cs index 3d1e8f37e..83c271cb4 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelineViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Timeline/TimelineViewModel.cs @@ -102,7 +102,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline // if (e.LeftButton == MouseButtonState.Released) // return; - var viewModel = (sender as Ellipse)?.DataContext as ITimelineKeyframeViewModel; + ITimelineKeyframeViewModel viewModel = (sender as Ellipse)?.DataContext as ITimelineKeyframeViewModel; if (viewModel == null) return; @@ -153,15 +153,15 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline public void Copy(ITimelineKeyframeViewModel viewModel) { // viewModel.Copy(); - var keyframeViewModels = GetAllKeyframeViewModels(); - foreach (var keyframeViewModel in keyframeViewModels.Where(k => k.IsSelected)) + List keyframeViewModels = GetAllKeyframeViewModels(); + foreach (ITimelineKeyframeViewModel keyframeViewModel in keyframeViewModels.Where(k => k.IsSelected)) keyframeViewModel.Copy(); } public void Delete(ITimelineKeyframeViewModel viewModel) { - var keyframeViewModels = GetAllKeyframeViewModels(); - foreach (var keyframeViewModel in keyframeViewModels.Where(k => k.IsSelected)) + List keyframeViewModels = GetAllKeyframeViewModels(); + foreach (ITimelineKeyframeViewModel keyframeViewModel in keyframeViewModels.Where(k => k.IsSelected)) keyframeViewModel.Delete(); } @@ -170,8 +170,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline private TimeSpan GetCursorTime(Point position) { // Get the parent grid, need that for our position - var x = Math.Max(0, position.X); - var time = TimeSpan.FromSeconds(x / _profileEditorService.PixelsPerSecond); + double x = Math.Max(0, position.X); + TimeSpan time = TimeSpan.FromSeconds(x / _profileEditorService.PixelsPerSecond); // Round the time to something that fits the current zoom level if (_profileEditorService.PixelsPerSecond < 200) @@ -185,7 +185,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline // Take a tolerance of 5 pixels (half a keyframe width) if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) { - var tolerance = 1000f / _profileEditorService.PixelsPerSecond * 5; + float tolerance = 1000f / _profileEditorService.PixelsPerSecond * 5; if (Math.Abs(_profileEditorService.CurrentTime.TotalMilliseconds - time.TotalMilliseconds) < tolerance) time = _profileEditorService.CurrentTime; else if (Math.Abs(_profileEditorService.SelectedProfileElement.StartSegmentLength.TotalMilliseconds - time.TotalMilliseconds) < tolerance) @@ -204,8 +204,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline // Ensure the selection rectangle doesn't show, the view isn't aware of different types of dragging SelectionRectangle.Rect = new Rect(); - var keyframeViewModels = GetAllKeyframeViewModels(); - foreach (var keyframeViewModel in keyframeViewModels.Where(k => k.IsSelected)) + List keyframeViewModels = GetAllKeyframeViewModels(); + foreach (ITimelineKeyframeViewModel keyframeViewModel in keyframeViewModels.Where(k => k.IsSelected)) keyframeViewModel.SaveOffsetToKeyframe(sourceKeyframeViewModel); if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) @@ -221,7 +221,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline sourceKeyframeViewModel.UpdatePosition(cursorTime); - foreach (var keyframeViewModel in keyframeViewModels.Where(k => k.IsSelected)) + foreach (ITimelineKeyframeViewModel keyframeViewModel in keyframeViewModels.Where(k => k.IsSelected)) keyframeViewModel.ApplyOffsetToKeyframe(sourceKeyframeViewModel); _profileEditorService.UpdateProfilePreview(); @@ -230,8 +230,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline public void ReleaseSelectedKeyframes() { - var keyframeViewModels = GetAllKeyframeViewModels(); - foreach (var keyframeViewModel in keyframeViewModels.Where(k => k.IsSelected)) + List keyframeViewModels = GetAllKeyframeViewModels(); + foreach (ITimelineKeyframeViewModel keyframeViewModel in keyframeViewModels.Where(k => k.IsSelected)) keyframeViewModel.ReleaseMovement(); } @@ -266,13 +266,13 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline if (!_mouseDragging) return; - var position = e.GetPosition((IInputElement) sender); - var selectedRect = new Rect(_mouseDragStartPoint, position); + Point position = e.GetPosition((IInputElement) sender); + Rect selectedRect = new Rect(_mouseDragStartPoint, position); SelectionRectangle.Rect = selectedRect; - var keyframeViewModels = GetAllKeyframeViewModels(); - var selectedKeyframes = HitTestUtilities.GetHitViewModels((Visual) sender, SelectionRectangle); - foreach (var keyframeViewModel in keyframeViewModels) + List keyframeViewModels = GetAllKeyframeViewModels(); + List selectedKeyframes = HitTestUtilities.GetHitViewModels((Visual) sender, SelectionRectangle); + foreach (ITimelineKeyframeViewModel keyframeViewModel in keyframeViewModels) keyframeViewModel.IsSelected = selectedKeyframes.Contains(keyframeViewModel); _mouseDragging = false; @@ -284,8 +284,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline { if (_mouseDragging && e.LeftButton == MouseButtonState.Pressed) { - var position = e.GetPosition((IInputElement) sender); - var selectedRect = new Rect(_mouseDragStartPoint, position); + Point position = e.GetPosition((IInputElement) sender); + Rect selectedRect = new Rect(_mouseDragStartPoint, position); SelectionRectangle.Rect = selectedRect; e.Handled = true; } @@ -293,10 +293,10 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline public void SelectKeyframe(ITimelineKeyframeViewModel clicked, bool selectBetween, bool toggle) { - var keyframeViewModels = GetAllKeyframeViewModels(); + List keyframeViewModels = GetAllKeyframeViewModels(); if (selectBetween) { - var selectedIndex = keyframeViewModels.FindIndex(k => k.IsSelected); + int selectedIndex = keyframeViewModels.FindIndex(k => k.IsSelected); // If nothing is selected, select only the clicked if (selectedIndex == -1) { @@ -304,18 +304,18 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline return; } - foreach (var keyframeViewModel in keyframeViewModels) + foreach (ITimelineKeyframeViewModel keyframeViewModel in keyframeViewModels) keyframeViewModel.IsSelected = false; - var clickedIndex = keyframeViewModels.IndexOf(clicked); + int clickedIndex = keyframeViewModels.IndexOf(clicked); if (clickedIndex < selectedIndex) { - foreach (var keyframeViewModel in keyframeViewModels.Skip(clickedIndex).Take(selectedIndex - clickedIndex + 1)) + foreach (ITimelineKeyframeViewModel keyframeViewModel in keyframeViewModels.Skip(clickedIndex).Take(selectedIndex - clickedIndex + 1)) keyframeViewModel.IsSelected = true; } else { - foreach (var keyframeViewModel in keyframeViewModels.Skip(selectedIndex).Take(clickedIndex - selectedIndex + 1)) + foreach (ITimelineKeyframeViewModel keyframeViewModel in keyframeViewModels.Skip(selectedIndex).Take(clickedIndex - selectedIndex + 1)) keyframeViewModel.IsSelected = true; } } @@ -327,7 +327,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline else { // Only select the clicked keyframe - foreach (var keyframeViewModel in keyframeViewModels) + foreach (ITimelineKeyframeViewModel keyframeViewModel in keyframeViewModels) keyframeViewModel.IsSelected = false; clicked.IsSelected = true; } @@ -335,8 +335,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline private List GetAllKeyframeViewModels() { - var viewModels = new List(); - foreach (var layerPropertyGroupViewModel in LayerPropertyGroups) + List viewModels = new List(); + foreach (LayerPropertyGroupViewModel layerPropertyGroupViewModel in LayerPropertyGroups) viewModels.AddRange(layerPropertyGroupViewModel.GetAllKeyframeViewModels(false)); return viewModels; diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreeGroupViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreeGroupViewModel.cs index 4c7b82e33..48d37fe72 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreeGroupViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreeGroupViewModel.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using System.Reflection; using Artemis.Core; using Artemis.Core.LayerBrushes; using Artemis.Core.LayerEffects; @@ -53,22 +54,22 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree public void OpenBrushSettings() { - var layerBrush = LayerPropertyGroup.LayerBrush; - var configurationViewModel = layerBrush.ConfigurationDialog; + BaseLayerBrush layerBrush = LayerPropertyGroup.LayerBrush; + LayerBrushConfigurationDialog configurationViewModel = layerBrush.ConfigurationDialog; if (configurationViewModel == null) return; try { // Limit to one constructor, there's no need to have more and it complicates things anyway - var constructors = configurationViewModel.Type.GetConstructors(); + ConstructorInfo[] constructors = configurationViewModel.Type.GetConstructors(); if (constructors.Length != 1) throw new ArtemisUIException("Brush configuration dialogs must have exactly one constructor"); // Find the BaseLayerBrush parameter, it is required by the base constructor so its there for sure - var brushParameter = constructors.First().GetParameters().First(p => typeof(BaseLayerBrush).IsAssignableFrom(p.ParameterType)); - var argument = new ConstructorArgument(brushParameter.Name, layerBrush); - var viewModel = (BrushConfigurationViewModel) layerBrush.PluginInfo.Kernel.Get(configurationViewModel.Type, argument); + ParameterInfo brushParameter = constructors.First().GetParameters().First(p => typeof(BaseLayerBrush).IsAssignableFrom(p.ParameterType)); + ConstructorArgument argument = new ConstructorArgument(brushParameter.Name, layerBrush); + BrushConfigurationViewModel viewModel = (BrushConfigurationViewModel) layerBrush.PluginInfo.Kernel.Get(configurationViewModel.Type, argument); _windowManager.ShowDialog(new LayerBrushSettingsWindowViewModel(viewModel)); } @@ -80,21 +81,21 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree public void OpenEffectSettings() { - var layerEffect = LayerPropertyGroup.LayerEffect; - var configurationViewModel = layerEffect.ConfigurationDialog; + BaseLayerEffect layerEffect = LayerPropertyGroup.LayerEffect; + LayerEffectConfigurationDialog configurationViewModel = layerEffect.ConfigurationDialog; if (configurationViewModel == null) return; try { // Limit to one constructor, there's no need to have more and it complicates things anyway - var constructors = configurationViewModel.Type.GetConstructors(); + ConstructorInfo[] constructors = configurationViewModel.Type.GetConstructors(); if (constructors.Length != 1) throw new ArtemisUIException("Effect configuration dialogs must have exactly one constructor"); - var effectParameter = constructors.First().GetParameters().First(p => typeof(BaseLayerEffect).IsAssignableFrom(p.ParameterType)); - var argument = new ConstructorArgument(effectParameter.Name, layerEffect); - var viewModel = (EffectConfigurationViewModel) layerEffect.PluginInfo.Kernel.Get(configurationViewModel.Type, argument); + ParameterInfo effectParameter = constructors.First().GetParameters().First(p => typeof(BaseLayerEffect).IsAssignableFrom(p.ParameterType)); + ConstructorArgument argument = new ConstructorArgument(effectParameter.Name, layerEffect); + EffectConfigurationViewModel viewModel = (EffectConfigurationViewModel) layerEffect.PluginInfo.Kernel.Get(configurationViewModel.Type, argument); _windowManager.ShowDialog(new LayerEffectSettingsWindowViewModel(viewModel)); } catch (Exception e) @@ -106,7 +107,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree public async void RenameEffect() { - var result = await _dialogService.ShowDialogAt( + object result = await _dialogService.ShowDialogAt( "PropertyTreeDialogHost", new Dictionary { @@ -138,8 +139,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree public double GetDepth() { - var depth = 0; - var current = LayerPropertyGroup.Parent; + int depth = 0; + LayerPropertyGroup current = LayerPropertyGroup.Parent; while (current != null) { depth++; diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreePropertyViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreePropertyViewModel.cs index 44cd7b1b5..deb82fe90 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreePropertyViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreePropertyViewModel.cs @@ -39,8 +39,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree public bool HasDataBinding => LayerProperty.HasDataBinding; public double GetDepth() { - var depth = 0; - var current = LayerProperty.LayerPropertyGroup; + int depth = 0; + LayerPropertyGroup current = LayerProperty.LayerPropertyGroup; while (current != null) { depth++; diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreeViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreeViewModel.cs index 25c9bc682..ec17fd5c8 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreeViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreeViewModel.cs @@ -27,12 +27,12 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree return; e.Handled = true; - var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) + MouseWheelEventArgs eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) { RoutedEvent = UIElement.MouseWheelEvent, Source = sender }; - var parent = ((Control) sender).Parent as UIElement; + UIElement parent = ((Control) sender).Parent as UIElement; parent?.RaiseEvent(eventArg); } } diff --git a/src/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs index d51a41973..f90b48300 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs @@ -144,24 +144,24 @@ namespace Artemis.UI.Screens.ProfileEditor public ProfileDescriptor CreateProfile(string name) { - var profile = _profileService.CreateProfileDescriptor(Module, name); + ProfileDescriptor profile = _profileService.CreateProfileDescriptor(Module, name); Profiles.Add(profile); return profile; } public async Task AddProfile() { - var result = await DialogService.ShowDialog(); + object result = await DialogService.ShowDialog(); if (result is string name) { - var newProfile = CreateProfile(name); + ProfileDescriptor newProfile = CreateProfile(name); SelectedProfile = newProfile; } } public async Task DeleteProfile(ProfileDescriptor profileDescriptor) { - var result = await DialogService.ShowConfirmDialog( + bool result = await DialogService.ShowConfirmDialog( "Delete profile", $"Are you sure you want to delete '{profileDescriptor.Name}'? This cannot be undone." ); @@ -172,7 +172,7 @@ namespace Artemis.UI.Screens.ProfileEditor public async Task DeleteActiveProfile() { - var result = await DialogService.ShowConfirmDialog( + bool result = await DialogService.ShowConfirmDialog( "Delete active profile", "Are you sure you want to delete your currently active profile? This cannot be undone." ); @@ -191,7 +191,7 @@ namespace Artemis.UI.Screens.ProfileEditor public async Task ImportProfile() { - var result = await DialogService.ShowDialog(new Dictionary + object result = await DialogService.ShowDialog(new Dictionary { {"profileModule", Module} }); @@ -207,8 +207,8 @@ namespace Artemis.UI.Screens.ProfileEditor public void Undo() { // Expanded status is also undone because undoing works a bit crude, that's annoying - var beforeGroups = LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels(); - var expandedPaths = beforeGroups.Where(g => g.IsExpanded).Select(g => g.LayerPropertyGroup.Path).ToList(); + List beforeGroups = LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels(); + List expandedPaths = beforeGroups.Where(g => g.IsExpanded).Select(g => g.LayerPropertyGroup.Path).ToList(); if (!_profileEditorService.UndoUpdateProfile()) { @@ -217,7 +217,7 @@ namespace Artemis.UI.Screens.ProfileEditor } // Restore the expanded status - foreach (var allLayerPropertyGroupViewModel in LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels()) + foreach (LayerPropertyGroupViewModel allLayerPropertyGroupViewModel in LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels()) allLayerPropertyGroupViewModel.IsExpanded = expandedPaths.Contains(allLayerPropertyGroupViewModel.LayerPropertyGroup.Path); _snackbarMessageQueue.Enqueue("Undid profile update", "REDO", Redo); @@ -226,8 +226,8 @@ namespace Artemis.UI.Screens.ProfileEditor public void Redo() { // Expanded status is also undone because undoing works a bit crude, that's annoying - var beforeGroups = LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels(); - var expandedPaths = beforeGroups.Where(g => g.IsExpanded).Select(g => g.LayerPropertyGroup.Path).ToList(); + List beforeGroups = LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels(); + List expandedPaths = beforeGroups.Where(g => g.IsExpanded).Select(g => g.LayerPropertyGroup.Path).ToList(); if (!_profileEditorService.RedoUpdateProfile()) { @@ -236,7 +236,7 @@ namespace Artemis.UI.Screens.ProfileEditor } // Restore the expanded status - foreach (var allLayerPropertyGroupViewModel in LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels()) + foreach (LayerPropertyGroupViewModel allLayerPropertyGroupViewModel in LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels()) allLayerPropertyGroupViewModel.IsExpanded = expandedPaths.Contains(allLayerPropertyGroupViewModel.LayerPropertyGroup.Path); _snackbarMessageQueue.Enqueue("Redid profile update", "UNDO", Undo); @@ -273,10 +273,10 @@ namespace Artemis.UI.Screens.ProfileEditor if (SelectedProfile == profileDescriptor && !CanDeleteActiveProfile) return; - var index = Profiles.IndexOf(profileDescriptor); + int index = Profiles.IndexOf(profileDescriptor); // Get a new active profile - var newActiveProfile = index - 1 > -1 ? Profiles[index - 1] : Profiles[index + 1]; + ProfileDescriptor newActiveProfile = index - 1 > -1 ? Profiles[index - 1] : Profiles[index + 1]; // Activate the new active profile SelectedProfile = newActiveProfile; @@ -293,9 +293,9 @@ namespace Artemis.UI.Screens.ProfileEditor if (SelectedProfile == null) return; - var changeTask = _profileService.ActivateProfileAnimated(SelectedProfile); + Task changeTask = _profileService.ActivateProfileAnimated(SelectedProfile); _profileEditorService.ChangeSelectedProfile(null); - var profile = await changeTask; + Profile profile = await changeTask; _profileEditorService.ChangeSelectedProfile(profile); }); } diff --git a/src/Artemis.UI/Screens/ProfileEditor/ProfileTree/ProfileTreeViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/ProfileTree/ProfileTreeViewModel.cs index 76ef61fdd..4c1fbc54b 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/ProfileTree/ProfileTreeViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/ProfileTree/ProfileTreeViewModel.cs @@ -43,7 +43,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree public void DragOver(IDropInfo dropInfo) { - var dragDropType = GetDragDropType(dropInfo); + DragDropType dragDropType = GetDragDropType(dropInfo); switch (dragDropType) { @@ -61,10 +61,10 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree public void Drop(IDropInfo dropInfo) { - var source = (TreeItemViewModel) dropInfo.Data; - var target = (TreeItemViewModel) dropInfo.TargetItem; + TreeItemViewModel source = (TreeItemViewModel) dropInfo.Data; + TreeItemViewModel target = (TreeItemViewModel) dropInfo.TargetItem; - var dragDropType = GetDragDropType(dropInfo); + DragDropType dragDropType = GetDragDropType(dropInfo); switch (dragDropType) { case DragDropType.Add: @@ -111,7 +111,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree private void CreateRootFolderViewModel() { _updatingTree = true; - var firstChild = _profileEditorService.SelectedProfile?.Children?.FirstOrDefault(); + ProfileElement firstChild = _profileEditorService.SelectedProfile?.Children?.FirstOrDefault(); if (!(firstChild is Folder folder)) { ActivateItem(null); @@ -131,12 +131,12 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree private static DragDropType GetDragDropType(IDropInfo dropInfo) { - var source = (TreeItemViewModel) dropInfo.Data; - var target = (TreeItemViewModel) dropInfo.TargetItem; + TreeItemViewModel source = (TreeItemViewModel) dropInfo.Data; + TreeItemViewModel target = (TreeItemViewModel) dropInfo.TargetItem; if (source == target) return DragDropType.None; - var parent = target; + TreeItemViewModel parent = target; while (parent != null) { if (parent == source) @@ -190,7 +190,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree SelectedTreeItem = null; else { - var match = ActiveItem.GetAllChildren().FirstOrDefault(vm => vm.ProfileElement == e.RenderProfileElement); + TreeItemViewModel match = ActiveItem.GetAllChildren().FirstOrDefault(vm => vm.ProfileElement == e.RenderProfileElement); if (match != null) SelectedTreeItem = match; } diff --git a/src/Artemis.UI/Screens/ProfileEditor/ProfileTree/TreeItem/TreeItemViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/ProfileTree/TreeItem/TreeItemViewModel.cs index 88ffce82e..6451833b4 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/ProfileTree/TreeItem/TreeItemViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/ProfileTree/TreeItem/TreeItemViewModel.cs @@ -55,8 +55,8 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem public List GetAllChildren() { - var children = new List(); - foreach (var childFolder in Items) + List children = new List(); + foreach (TreeItemViewModel childFolder in Items) { // Add all children in this element children.Add(childFolder); @@ -69,8 +69,8 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem public void SetElementInFront(TreeItemViewModel source) { - var sourceParent = (TreeItemViewModel) source.Parent; - var parent = (TreeItemViewModel) Parent; + TreeItemViewModel sourceParent = (TreeItemViewModel) source.Parent; + TreeItemViewModel parent = (TreeItemViewModel) Parent; // If the parents are different, remove the element from the old parent and add it to the new parent if (source.Parent != Parent) @@ -89,8 +89,8 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem public void SetElementBehind(TreeItemViewModel source) { - var sourceParent = (TreeItemViewModel) source.Parent; - var parent = (TreeItemViewModel) Parent; + TreeItemViewModel sourceParent = (TreeItemViewModel) source.Parent; + TreeItemViewModel parent = (TreeItemViewModel) Parent; if (source.Parent != Parent) { sourceParent.RemoveExistingElement(source); @@ -129,7 +129,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem if (!SupportsChildren) throw new ArtemisUIException("Cannot add a folder to a profile element of type " + ProfileElement.GetType().Name); - var _ = new Folder(ProfileElement, "New folder"); + Folder _ = new Folder(ProfileElement, "New folder"); _profileEditorService.UpdateSelectedProfile(); } @@ -138,7 +138,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem if (!SupportsChildren) throw new ArtemisUIException("Cannot add a layer to a profile element of type " + ProfileElement.GetType().Name); - var layer = new Layer(ProfileElement, "New layer"); + Layer layer = new Layer(ProfileElement, "New layer"); layer.ChangeLayerBrush(_layerBrushService.GetDefaultLayerBrush()); layer.AddLeds(_surfaceService.ActiveSurface.Devices.SelectMany(d => d.Leds)); _profileEditorService.UpdateSelectedProfile(); @@ -148,7 +148,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem // ReSharper disable once UnusedMember.Global - Called from view public async Task RenameElement() { - var result = await _dialogService.ShowDialogAt( + object result = await _dialogService.ShowDialogAt( "ProfileTreeDialog", new Dictionary { @@ -166,7 +166,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem // ReSharper disable once UnusedMember.Global - Called from view public async Task DeleteElement() { - var result = await _dialogService.ShowConfirmDialogAt( + bool result = await _dialogService.ShowConfirmDialogAt( "ProfileTreeDialog", "Delete profile element", "Are you sure?" @@ -176,7 +176,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem return; // Farewell, cruel world - var parent = (TreeItemViewModel) Parent; + TreeItemViewModel parent = (TreeItemViewModel) Parent; ProfileElement.Parent?.RemoveChild(ProfileElement); parent.RemoveExistingElement(this); @@ -187,15 +187,15 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem public void UpdateProfileElements() { // Remove VMs that are no longer a child - var toRemove = Items.Where(c => c.ProfileElement.Parent != ProfileElement).ToList(); - foreach (var treeItemViewModel in toRemove) + List toRemove = Items.Where(c => c.ProfileElement.Parent != ProfileElement).ToList(); + foreach (TreeItemViewModel treeItemViewModel in toRemove) Items.Remove(treeItemViewModel); // Order the children - var vmsList = Items.OrderBy(v => v.ProfileElement.Order).ToList(); - for (var index = 0; index < vmsList.Count; index++) + List vmsList = Items.OrderBy(v => v.ProfileElement.Order).ToList(); + for (int index = 0; index < vmsList.Count; index++) { - var profileElementViewModel = vmsList[index]; + TreeItemViewModel profileElementViewModel = vmsList[index]; if (Items.IndexOf(profileElementViewModel) != index) ((BindableCollection) Items).Move(Items.IndexOf(profileElementViewModel), index); } @@ -204,8 +204,8 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem if (ProfileElement.Children == null) return; - var newChildren = new List(); - foreach (var profileElement in ProfileElement.Children.OrderBy(c => c.Order)) + List newChildren = new List(); + foreach (ProfileElement profileElement in ProfileElement.Children.OrderBy(c => c.Order)) { if (profileElement is Folder folder) { @@ -223,7 +223,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem return; // Add the new children in one call, prevent extra UI events - foreach (var treeItemViewModel in newChildren) + foreach (TreeItemViewModel treeItemViewModel in newChildren) { treeItemViewModel.UpdateProfileElements(); Items.Add(treeItemViewModel); diff --git a/src/Artemis.UI/Screens/ProfileEditor/Visualization/ProfileLayerViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Visualization/ProfileLayerViewModel.cs index ebe679a8f..ddebeb6b9 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Visualization/ProfileLayerViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Visualization/ProfileLayerViewModel.cs @@ -127,8 +127,8 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization Execute.PostToUIThread(() => { - var bounds = _layerEditorService.GetLayerBounds(Layer); - var shapeGeometry = Geometry.Empty; + Rect bounds = _layerEditorService.GetLayerBounds(Layer); + Geometry shapeGeometry = Geometry.Empty; switch (Layer.LayerShape) { case EllipseShape _: @@ -159,22 +159,22 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization private Geometry CreateRectangleGeometry(ArtemisLed led) { - var rect = led.RgbLed.AbsoluteLedRectangle.ToWindowsRect(1); + Rect rect = led.RgbLed.AbsoluteLedRectangle.ToWindowsRect(1); return new RectangleGeometry(rect); } private Geometry CreateCircleGeometry(ArtemisLed led) { - var rect = led.RgbLed.AbsoluteLedRectangle.ToWindowsRect(1); + Rect rect = led.RgbLed.AbsoluteLedRectangle.ToWindowsRect(1); return new EllipseGeometry(rect); } private Geometry CreateCustomGeometry(ArtemisLed led, double deflateAmount) { - var rect = led.RgbLed.AbsoluteLedRectangle.ToWindowsRect(1); + Rect rect = led.RgbLed.AbsoluteLedRectangle.ToWindowsRect(1); try { - var geometry = Geometry.Combine( + PathGeometry geometry = Geometry.Combine( Geometry.Empty, Geometry.Parse(led.RgbLed.ShapeData), GeometryCombineMode.Union, diff --git a/src/Artemis.UI/Screens/ProfileEditor/Visualization/ProfileViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Visualization/ProfileViewModel.cs index 64d7060d9..4470da58c 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Visualization/ProfileViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Visualization/ProfileViewModel.cs @@ -195,7 +195,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization OnlyShowSelectedShape.Save(); HighlightSelectedLayer.Save(); - foreach (var canvasViewModel in CanvasViewModels) + foreach (CanvasViewModel canvasViewModel in CanvasViewModels) canvasViewModel.Dispose(); CanvasViewModels.Clear(); @@ -209,19 +209,19 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization private void ApplyActiveProfile() { - var layerViewModels = CanvasViewModels.Where(vm => vm is ProfileLayerViewModel).Cast().ToList(); - var layers = _profileEditorService.SelectedProfile?.GetAllLayers() ?? new List(); + List layerViewModels = CanvasViewModels.Where(vm => vm is ProfileLayerViewModel).Cast().ToList(); + List layers = _profileEditorService.SelectedProfile?.GetAllLayers() ?? new List(); // Add new layers missing a VM - foreach (var layer in layers) + foreach (Layer layer in layers) { if (layerViewModels.All(vm => vm.Layer != layer)) CanvasViewModels.Add(_profileLayerVmFactory.Create(layer, this)); } // Remove layers that no longer exist - var toRemove = layerViewModels.Where(vm => !layers.Contains(vm.Layer)); - foreach (var profileLayerViewModel in toRemove) + IEnumerable toRemove = layerViewModels.Where(vm => !layers.Contains(vm.Layer)); + foreach (ProfileLayerViewModel profileLayerViewModel in toRemove) { profileLayerViewModel.Dispose(); CanvasViewModels.Remove(profileLayerViewModel); @@ -341,7 +341,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization public void InverseSelection() { - var current = SelectedLeds.ToList(); + List current = SelectedLeds.ToList(); SelectedLeds.Clear(); SelectedLeds.AddRange(Devices.SelectMany(d => d.Leds).Except(current)); } diff --git a/src/Artemis.UI/Screens/ProfileEditor/Visualization/Tools/EditToolViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Visualization/Tools/EditToolViewModel.cs index 2b3b9259b..8f88fc89b 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Visualization/Tools/EditToolViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Visualization/Tools/EditToolViewModel.cs @@ -62,7 +62,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools ShapeAnchor = _layerEditorService.GetLayerAnchorPosition(layer).ToSKPoint(); Execute.PostToUIThread(() => { - var shapeGeometry = new RectangleGeometry(_layerEditorService.GetLayerBounds(layer)) + RectangleGeometry shapeGeometry = new RectangleGeometry(_layerEditorService.GetLayerBounds(layer)) { Transform = _layerEditorService.GetLayerTransformGroup(layer) }; @@ -99,15 +99,15 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools if (!_rotating || !(ProfileEditorService.SelectedProfileElement is Layer layer)) return; - var previousDragAngle = _previousDragAngle; - var newRotation = CalculateAngle(layer, sender, e.MouseEventArgs); + float previousDragAngle = _previousDragAngle; + float newRotation = CalculateAngle(layer, sender, e.MouseEventArgs); _previousDragAngle = newRotation; // Allow the user to rotate the shape in increments of 5 if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) newRotation = (float) Math.Round(newRotation / 5f) * 5f; - var difference = newRotation - previousDragAngle; + float difference = newRotation - previousDragAngle; if (difference < -350) difference += 360; else if (difference > 350) @@ -136,7 +136,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools if (_isResizing || !(ProfileEditorService.SelectedProfileElement is Layer layer)) return; - var dragStart = GetRelativePosition(sender, e.MouseEventArgs).ToSKPoint(); + SKPoint dragStart = GetRelativePosition(sender, e.MouseEventArgs).ToSKPoint(); _dragOffset = _layerEditorService.GetDragOffset(layer, dragStart); _dragStart = dragStart + _dragOffset; _dragStartScale = layer.Transform.Scale.CurrentValue; @@ -156,7 +156,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools return; float width, height; - var position = GetRelativePosition(sender, e.MouseEventArgs).ToSKPoint() + _dragOffset; + SKPoint position = GetRelativePosition(sender, e.MouseEventArgs).ToSKPoint() + _dragOffset; switch (e.ShapeControlPoint) { case ShapeControlPoint.TopLeft: @@ -198,8 +198,8 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools // Make the sides even if shift is held down if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift) && e.ShapeControlPoint < ShapeControlPoint.TopCenter) { - var bounds = _layerEditorService.GetLayerBounds(layer); - var smallestSide = Math.Min(bounds.Width * width, bounds.Height * height); + Rect bounds = _layerEditorService.GetLayerBounds(layer); + double smallestSide = Math.Min(bounds.Width * width, bounds.Height * height); width = (float) Math.Round(1.0 / bounds.Width * smallestSide, 2, MidpointRounding.AwayFromZero); height = (float) Math.Round(1.0 / bounds.Height * smallestSide, 2, MidpointRounding.AwayFromZero); } @@ -211,13 +211,13 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools private float HorizontalResize(Layer layer, SKPoint position, ResizeOrigin origin) { // Apply rotation to the mouse - var points = UnTransformPoints(new[] {position, _dragStart}, layer, ShapeAnchor, false); + SKPoint[] points = UnTransformPoints(new[] {position, _dragStart}, layer, ShapeAnchor, false); position = points[0]; - var dragStart = points[1]; + SKPoint dragStart = points[1]; - var shapePath = _layerEditorService.GetLayerPath(layer, true, false, false); - var scalePerPixel = 1f / shapePath.Bounds.Width; - var anchorDistance = origin == ResizeOrigin.Left + SKPath shapePath = _layerEditorService.GetLayerPath(layer, true, false, false); + float scalePerPixel = 1f / shapePath.Bounds.Width; + float anchorDistance = origin == ResizeOrigin.Left ? shapePath.Bounds.Left - ShapeAnchor.X : shapePath.Bounds.Right - ShapeAnchor.X; @@ -226,10 +226,10 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools if (Math.Abs(anchorDistance) < 0.001) return _dragStartScale.Width; - var anchorOffset = anchorDistance / shapePath.Bounds.Width; + float anchorOffset = anchorDistance / shapePath.Bounds.Width; - var pixelsToAdd = (position - dragStart).X / anchorOffset; - var scaleToAdd = scalePerPixel * pixelsToAdd * 100f; + float pixelsToAdd = (position - dragStart).X / anchorOffset; + float scaleToAdd = scalePerPixel * pixelsToAdd * 100f; return (float) Math.Round(Math.Max(0, _dragStartScale.Width + scaleToAdd), 2, MidpointRounding.AwayFromZero); } @@ -237,13 +237,13 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools private float VerticalResize(Layer layer, SKPoint position, ResizeOrigin origin) { // Apply rotation to the mouse - var points = UnTransformPoints(new[] {position, _dragStart}, layer, ShapeAnchor, false); + SKPoint[] points = UnTransformPoints(new[] {position, _dragStart}, layer, ShapeAnchor, false); position = points[0]; - var dragStart = points[1]; + SKPoint dragStart = points[1]; - var shapePath = _layerEditorService.GetLayerPath(layer, true, false, false); - var scalePerPixel = 1f / shapePath.Bounds.Height; - var anchorDistance = origin == ResizeOrigin.Top + SKPath shapePath = _layerEditorService.GetLayerPath(layer, true, false, false); + float scalePerPixel = 1f / shapePath.Bounds.Height; + float anchorDistance = origin == ResizeOrigin.Top ? shapePath.Bounds.Top - ShapeAnchor.Y : shapePath.Bounds.Bottom - ShapeAnchor.Y; @@ -252,10 +252,10 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools if (Math.Abs(anchorDistance) < 0.001) return _dragStartScale.Width; - var anchorOffset = anchorDistance / shapePath.Bounds.Height; + float anchorOffset = anchorDistance / shapePath.Bounds.Height; - var pixelsToAdd = (position - dragStart).Y / anchorOffset; - var scaleToAdd = scalePerPixel * pixelsToAdd * 100f; + float pixelsToAdd = (position - dragStart).Y / anchorOffset; + float scaleToAdd = scalePerPixel * pixelsToAdd * 100f; return (float) Math.Round(Math.Max(0, _dragStartScale.Height + scaleToAdd), 2, MidpointRounding.AwayFromZero); } @@ -277,18 +277,18 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools if (e.ShapeControlPoint == ShapeControlPoint.LayerShape) { - var dragStart = GetRelativePosition(sender, e.MouseEventArgs).ToSKPoint(); + SKPoint dragStart = GetRelativePosition(sender, e.MouseEventArgs).ToSKPoint(); _dragOffset = _layerEditorService.GetDragOffset(layer, dragStart); _dragStart = dragStart + _dragOffset; _movingShape = true; } else if (e.ShapeControlPoint == ShapeControlPoint.Anchor) { - var dragStartPosition = GetRelativePosition(sender, e.MouseEventArgs).ToSKPoint(); + SKPoint dragStartPosition = GetRelativePosition(sender, e.MouseEventArgs).ToSKPoint(); // Mouse doesn't care about rotation so get the layer path without rotation - var path = _layerEditorService.GetLayerPath(layer, true, true, false); - var topLeft = path.Points[0]; + SKPath path = _layerEditorService.GetLayerPath(layer, true, true, false); + SKPoint topLeft = path.Points[0]; // Measure from the top-left of the shape (without rotation) _dragOffset = topLeft + (dragStartPosition - topLeft); // Get the absolute layer anchor and make it relative to the unrotated shape @@ -320,7 +320,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools if (!(ProfileEditorService.SelectedProfileElement is Layer layer)) return; - var position = GetRelativePosition(sender, e).ToSKPoint() + _dragOffset; + SKPoint position = GetRelativePosition(sender, e).ToSKPoint() + _dragOffset; // Allow the user to move the shape only horizontally or vertically when holding down shift if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) { @@ -347,7 +347,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools } // Scale down the resulting position and make it relative - var scaled = _layerEditorService.GetScaledPoint(layer, position, true); + SKPoint scaled = _layerEditorService.GetScaledPoint(layer, position, true); // Round and update the position property layer.Transform.Position.SetCurrentValue(RoundPoint(scaled, 3), ProfileEditorService.CurrentTime); @@ -360,22 +360,22 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools return; // The start anchor is relative to an unrotated version of the shape - var start = _dragStartAnchor; + SKPoint start = _dragStartAnchor; // Add the current position to the start anchor to determine the new position - var current = start + (GetRelativePosition(sender, e).ToSKPoint() - _dragOffset); + SKPoint current = start + (GetRelativePosition(sender, e).ToSKPoint() - _dragOffset); // In order to keep the mouse movement unrotated, counter-act the active rotation - var countered = UnTransformPoints(new[] {start, current}, layer, start, true); + SKPoint[] countered = UnTransformPoints(new[] {start, current}, layer, start, true); // If shift is held down, round down to 1 decimal to allow moving the anchor in big increments - var decimals = Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift) ? 1 : 3; - var scaled = RoundPoint(_layerEditorService.GetScaledPoint(layer, countered[1], false), decimals); + int decimals = Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift) ? 1 : 3; + SKPoint scaled = RoundPoint(_layerEditorService.GetScaledPoint(layer, countered[1], false), decimals); // Update the anchor point, this causes the shape to move layer.Transform.AnchorPoint.SetCurrentValue(scaled, ProfileEditorService.CurrentTime); // TopLeft is not updated yet and acts as a snapshot of the top-left before changing the anchor - var path = _layerEditorService.GetLayerPath(layer, true, true, true); + SKPath path = _layerEditorService.GetLayerPath(layer, true, true, true); // Calculate the (scaled) difference between the old and now position - var difference = _layerEditorService.GetScaledPoint(layer, _topLeft - path.Points[0], false); + SKPoint difference = _layerEditorService.GetScaledPoint(layer, _topLeft - path.Points[0], false); // Apply the difference so that the shape effectively stays in place layer.Transform.Position.SetCurrentValue(layer.Transform.Position.CurrentValue + difference, ProfileEditorService.CurrentTime); @@ -393,7 +393,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools private SKPoint[] UnTransformPoints(SKPoint[] skPoints, Layer layer, SKPoint pivot, bool includeScale) { - using var counterRotatePath = new SKPath(); + using SKPath counterRotatePath = new SKPath(); counterRotatePath.AddPoly(skPoints, false); counterRotatePath.Transform(SKMatrix.MakeRotationDegrees(layer.Transform.Rotation.CurrentValue * -1, pivot.X, pivot.Y)); if (includeScale) @@ -404,18 +404,18 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools private Point GetRelativePosition(object sender, MouseEventArgs mouseEventArgs) { - var parent = VisualTreeHelper.GetParent((DependencyObject) sender); + DependencyObject parent = VisualTreeHelper.GetParent((DependencyObject) sender); return mouseEventArgs.GetPosition((IInputElement) parent); } private float CalculateAngle(Layer layer, object mouseEventSender, MouseEventArgs mouseEvent) { - var layerBounds = _layerEditorService.GetLayerBounds(layer); - var start = _layerEditorService.GetLayerAnchorPosition(layer); - var arrival = GetRelativePosition(mouseEventSender, mouseEvent); + Rect layerBounds = _layerEditorService.GetLayerBounds(layer); + Point start = _layerEditorService.GetLayerAnchorPosition(layer); + Point arrival = GetRelativePosition(mouseEventSender, mouseEvent); - var radian = (float) Math.Atan2(start.Y - arrival.Y, start.X - arrival.X); - var angle = radian * (180f / (float) Math.PI); + float radian = (float) Math.Atan2(start.Y - arrival.Y, start.X - arrival.X); + float angle = radian * (180f / (float) Math.PI); if (angle < 0f) angle += 360f; diff --git a/src/Artemis.UI/Screens/ProfileEditor/Visualization/Tools/SelectionRemoveToolViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Visualization/Tools/SelectionRemoveToolViewModel.cs index 0cf6eb665..81f575d49 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Visualization/Tools/SelectionRemoveToolViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Visualization/Tools/SelectionRemoveToolViewModel.cs @@ -1,4 +1,5 @@ -using System.IO; +using System.Collections.Generic; +using System.IO; using System.Linq; using System.Windows; using System.Windows.Input; @@ -14,7 +15,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools public SelectionRemoveToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService) : base(profileViewModel, profileEditorService) { - using (var stream = new MemoryStream(Resources.aero_pen_min)) + using (MemoryStream stream = new MemoryStream(Resources.aero_pen_min)) { Cursor = new Cursor(stream); } @@ -30,18 +31,18 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools { base.MouseUp(sender, e); - var position = ProfileViewModel.PanZoomViewModel.GetRelativeMousePosition(sender, e); - var selectedRect = new Rect(MouseDownStartPosition, position); + Point position = ProfileViewModel.PanZoomViewModel.GetRelativeMousePosition(sender, e); + Rect selectedRect = new Rect(MouseDownStartPosition, position); // Get selected LEDs - var selectedLeds = ProfileViewModel.GetLedsInRectangle(selectedRect); + List selectedLeds = ProfileViewModel.GetLedsInRectangle(selectedRect); ProfileViewModel.SelectedLeds.Clear(); ProfileViewModel.SelectedLeds.AddRange(selectedLeds); // Apply the selection to the selected layer layer if (ProfileEditorService.SelectedProfileElement is Layer layer) { - var remainingLeds = layer.Leds.Except(selectedLeds).ToList(); + List remainingLeds = layer.Leds.Except(selectedLeds).ToList(); layer.ClearLeds(); layer.AddLeds(remainingLeds); @@ -58,9 +59,9 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools return; } - var position = ProfileViewModel.PanZoomViewModel.GetRelativeMousePosition(sender, e); - var selectedRect = new Rect(MouseDownStartPosition, position); - var selectedLeds = ProfileViewModel.GetLedsInRectangle(selectedRect); + Point position = ProfileViewModel.PanZoomViewModel.GetRelativeMousePosition(sender, e); + Rect selectedRect = new Rect(MouseDownStartPosition, position); + List selectedLeds = ProfileViewModel.GetLedsInRectangle(selectedRect); // Unless shift is held down, clear the current selection if (!Keyboard.IsKeyDown(Key.LeftShift) && !Keyboard.IsKeyDown(Key.RightShift)) diff --git a/src/Artemis.UI/Screens/ProfileEditor/Visualization/Tools/SelectionToolViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Visualization/Tools/SelectionToolViewModel.cs index 5e08f3227..b4481817c 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Visualization/Tools/SelectionToolViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Visualization/Tools/SelectionToolViewModel.cs @@ -20,7 +20,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools ILayerBrushService layerBrushService) : base(profileViewModel, profileEditorService) { _layerBrushService = layerBrushService; - using (var stream = new MemoryStream(Resources.aero_crosshair)) + using (MemoryStream stream = new MemoryStream(Resources.aero_crosshair)) { Cursor = new Cursor(stream); } @@ -36,11 +36,11 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools { base.MouseUp(sender, e); - var position = ProfileViewModel.PanZoomViewModel.GetRelativeMousePosition(sender, e); - var selectedRect = new Rect(MouseDownStartPosition, position); + Point position = ProfileViewModel.PanZoomViewModel.GetRelativeMousePosition(sender, e); + Rect selectedRect = new Rect(MouseDownStartPosition, position); // Get selected LEDs - var selectedLeds = ProfileViewModel.GetLedsInRectangle(selectedRect); + List selectedLeds = ProfileViewModel.GetLedsInRectangle(selectedRect); // Apply the selection to the selected layer layer if (ProfileEditorService.SelectedProfileElement is Layer layer) @@ -62,7 +62,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools // If no folder selected, apply it to a new layer in the root folder else { - var rootFolder = ProfileEditorService.SelectedProfile.GetRootFolder(); + Folder rootFolder = ProfileEditorService.SelectedProfile.GetRootFolder(); CreateLayer(rootFolder, selectedLeds); } } @@ -76,9 +76,9 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools return; } - var position = ProfileViewModel.PanZoomViewModel.GetRelativeMousePosition(sender, e); - var selectedRect = new Rect(MouseDownStartPosition, position); - var selectedLeds = ProfileViewModel.GetLedsInRectangle(selectedRect); + Point position = ProfileViewModel.PanZoomViewModel.GetRelativeMousePosition(sender, e); + Rect selectedRect = new Rect(MouseDownStartPosition, position); + List selectedLeds = ProfileViewModel.GetLedsInRectangle(selectedRect); // Unless shift is held down, clear the current selection if (!Keyboard.IsKeyDown(Key.LeftShift) && !Keyboard.IsKeyDown(Key.RightShift)) @@ -90,7 +90,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools private void CreateLayer(Folder folder, List selectedLeds) { - var newLayer = new Layer(folder, "New layer"); + Layer newLayer = new Layer(folder, "New layer"); newLayer.ChangeLayerBrush(_layerBrushService.GetDefaultLayerBrush()); newLayer.AddLeds(selectedLeds); ProfileEditorService.ChangeSelectedProfileElement(newLayer); diff --git a/src/Artemis.UI/Screens/ProfileEditor/Visualization/Tools/VisualizationToolViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Visualization/Tools/VisualizationToolViewModel.cs index ce967b019..f14e433c7 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Visualization/Tools/VisualizationToolViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Visualization/Tools/VisualizationToolViewModel.cs @@ -73,7 +73,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools protected Rect GetSquareRectBetweenPoints(Point start, Point end) { // Find the shortest side - var size = Math.Min(Math.Abs(start.X - end.X), Math.Abs(start.Y - end.Y)); + double size = Math.Min(Math.Abs(start.X - end.X), Math.Abs(start.Y - end.Y)); // There's probably a very elegant way to do this, and this is not it if (end.X < start.X && end.Y < start.Y) diff --git a/src/Artemis.UI/Screens/ProfileEditor/Visualization/UserControls/LayerShapeControl.xaml.cs b/src/Artemis.UI/Screens/ProfileEditor/Visualization/UserControls/LayerShapeControl.xaml.cs index 189d85e1e..4036ec376 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Visualization/UserControls/LayerShapeControl.xaml.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Visualization/UserControls/LayerShapeControl.xaml.cs @@ -87,7 +87,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.UserControls private static void ZoomChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var layerShapeControl = (LayerShapeControl) d; + LayerShapeControl layerShapeControl = (LayerShapeControl) d; layerShapeControl.SetCurrentValue(ZoomProperty, e.NewValue); layerShapeControl.UpdateDimensions(); @@ -95,7 +95,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.UserControls private static void ShapePathChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var layerShapeControl = (LayerShapeControl) d; + LayerShapeControl layerShapeControl = (LayerShapeControl) d; layerShapeControl.SetCurrentValue(ShapePathProperty, e.NewValue); layerShapeControl.UpdatePositions(); @@ -103,7 +103,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.UserControls private static void ShapeAnchorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var layerShapeControl = (LayerShapeControl) d; + LayerShapeControl layerShapeControl = (LayerShapeControl) d; layerShapeControl.SetCurrentValue(ShapeAnchorProperty, e.NewValue); layerShapeControl.UpdateShapeAnchor(); @@ -111,7 +111,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.UserControls private static void ShapeGeometryChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - var layerShapeControl = (LayerShapeControl) d; + LayerShapeControl layerShapeControl = (LayerShapeControl) d; layerShapeControl.SetCurrentValue(ShapeGeometryProperty, e.NewValue); layerShapeControl.UpdateShapeGeometry(); @@ -161,14 +161,14 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.UserControls private void UpdateControlPosition(UIElement control, SKPoint point1, SKPoint point2) { - var point = new SKPoint((point1.X + point2.X) / 2, (point1.Y + point2.Y) / 2); + SKPoint point = new SKPoint((point1.X + point2.X) / 2, (point1.Y + point2.Y) / 2); UpdateControlPosition(control, point); } private void UpdateRotateDimensions(Shape rotateControl) { - var controlSize = Math.Max(10 / Zoom, 4); - var rotateSize = controlSize * 8; + double controlSize = Math.Max(10 / Zoom, 4); + double rotateSize = controlSize * 8; rotateControl.Width = rotateSize; rotateControl.Height = rotateSize; @@ -177,7 +177,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.UserControls private void UpdateResizeDimensions(Shape resizeControl) { - var controlSize = Math.Max(10 / Zoom, 4); + double controlSize = Math.Max(10 / Zoom, 4); resizeControl.Width = controlSize; resizeControl.Height = controlSize; diff --git a/src/Artemis.UI/Screens/RootViewModel.cs b/src/Artemis.UI/Screens/RootViewModel.cs index 707520d5b..1b84c0ec7 100644 --- a/src/Artemis.UI/Screens/RootViewModel.cs +++ b/src/Artemis.UI/Screens/RootViewModel.cs @@ -64,7 +64,7 @@ namespace Artemis.UI.Screens ActiveItem = SidebarViewModel.SelectedItem; ActiveItemReady = true; - var versionAttribute = typeof(RootViewModel).Assembly.GetCustomAttribute(); + AssemblyInformationalVersionAttribute? versionAttribute = typeof(RootViewModel).Assembly.GetCustomAttribute(); WindowTitle = $"Artemis {versionAttribute?.InformationalVersion}"; } @@ -96,7 +96,7 @@ namespace Artemis.UI.Screens public void WindowDeactivated() { - var windowState = ((Window) View).WindowState; + WindowState windowState = ((Window) View).WindowState; if (windowState == WindowState.Minimized) return; @@ -185,12 +185,12 @@ namespace Artemis.UI.Screens private void ChangeMaterialColors(ApplicationColorScheme colorScheme) { - var paletteHelper = new PaletteHelper(); - var theme = paletteHelper.GetTheme(); + PaletteHelper paletteHelper = new PaletteHelper(); + ITheme theme = paletteHelper.GetTheme(); theme.SetBaseTheme(colorScheme == ApplicationColorScheme.Dark ? Theme.Dark : Theme.Light); paletteHelper.SetTheme(theme); - var extensionsPaletteHelper = new MaterialDesignExtensions.Themes.PaletteHelper(); + MaterialDesignExtensions.Themes.PaletteHelper extensionsPaletteHelper = new MaterialDesignExtensions.Themes.PaletteHelper(); extensionsPaletteHelper.SetLightDark(colorScheme == ApplicationColorScheme.Dark); } @@ -213,7 +213,7 @@ namespace Artemis.UI.Screens protected override void OnViewLoaded() { - var window = (MaterialWindow) View; + MaterialWindow window = (MaterialWindow) View; if (_windowSize.Value != null) _windowSize.Value.ApplyToWindow(window); else @@ -253,7 +253,7 @@ namespace Artemis.UI.Screens MainMessageQueue = null; _frameTimeUpdateTimer.Stop(); - var window = (MaterialWindow) View; + MaterialWindow window = (MaterialWindow) View; _windowSize.Value ??= new WindowSize(); _windowSize.Value.ApplyFromWindow(window); _windowSize.Save(); diff --git a/src/Artemis.UI/Screens/Settings/Debug/Tabs/RenderDebugViewModel.cs b/src/Artemis.UI/Screens/Settings/Debug/Tabs/RenderDebugViewModel.cs index 215b4eae9..c757eb0b6 100644 --- a/src/Artemis.UI/Screens/Settings/Debug/Tabs/RenderDebugViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Debug/Tabs/RenderDebugViewModel.cs @@ -63,11 +63,11 @@ namespace Artemis.UI.Screens.Settings.Debug.Tabs try { - using (var skiaImage = SKImage.FromPixels(e.BitmapBrush.Bitmap.PeekPixels())) + using (SKImage skiaImage = SKImage.FromPixels(e.BitmapBrush.Bitmap.PeekPixels())) { - var info = new SKImageInfo(skiaImage.Width, skiaImage.Height); + SKImageInfo info = new SKImageInfo(skiaImage.Width, skiaImage.Height); writeableBitmap.Lock(); - using (var pixmap = new SKPixmap(info, writeableBitmap.BackBuffer, writeableBitmap.BackBufferStride)) + using (SKPixmap pixmap = new SKPixmap(info, writeableBitmap.BackBuffer, writeableBitmap.BackBufferStride)) { skiaImage.ReadPixels(pixmap, 0, 0); } diff --git a/src/Artemis.UI/Screens/Settings/Tabs/Devices/DeviceSettingsTabViewModel.cs b/src/Artemis.UI/Screens/Settings/Tabs/Devices/DeviceSettingsTabViewModel.cs index 13c422dda..84d6be584 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/Devices/DeviceSettingsTabViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Tabs/Devices/DeviceSettingsTabViewModel.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Artemis.Core.Services; using Artemis.UI.Ninject.Factories; @@ -28,8 +29,8 @@ namespace Artemis.UI.Screens.Settings.Tabs.Devices Items.Clear(); await Task.Delay(200); - var instances = _surfaceService.ActiveSurface.Devices.Select(d => _settingsVmFactory.CreateDeviceSettingsViewModel(d)).ToList(); - foreach (var deviceSettingsViewModel in instances) + List instances = _surfaceService.ActiveSurface.Devices.Select(d => _settingsVmFactory.CreateDeviceSettingsViewModel(d)).ToList(); + foreach (DeviceSettingsViewModel deviceSettingsViewModel in instances) Items.Add(deviceSettingsViewModel); }); diff --git a/src/Artemis.UI/Screens/Settings/Tabs/General/GeneralSettingsTabViewModel.cs b/src/Artemis.UI/Screens/Settings/Tabs/General/GeneralSettingsTabViewModel.cs index 0b82dcc5e..5760fd78f 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/General/GeneralSettingsTabViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Tabs/General/GeneralSettingsTabViewModel.cs @@ -36,17 +36,17 @@ namespace Artemis.UI.Screens.Settings.Tabs.General LogLevels = new BindableCollection(EnumUtilities.GetAllValuesAndDescriptions(typeof(LogEventLevel))); ColorSchemes = new BindableCollection(EnumUtilities.GetAllValuesAndDescriptions(typeof(ApplicationColorScheme))); RenderScales = new List> {new Tuple("10%", 0.1)}; - for (var i = 25; i <= 100; i += 25) + for (int i = 25; i <= 100; i += 25) RenderScales.Add(new Tuple(i + "%", i / 100.0)); TargetFrameRates = new List>(); - for (var i = 10; i <= 30; i += 5) + for (int i = 10; i <= 30; i += 5) TargetFrameRates.Add(new Tuple(i + " FPS", i)); // Anything else is kinda broken right now SampleSizes = new List {1, 9}; - var layerBrushProviders = pluginService.GetPluginsOfType(); + List layerBrushProviders = pluginService.GetPluginsOfType(); LayerBrushDescriptors = new BindableCollection(layerBrushProviders.SelectMany(l => l.LayerBrushDescriptors)); _defaultLayerBrushDescriptor = _settingsService.GetSetting("ProfileEditor.DefaultLayerBrushDescriptor", new LayerBrushReference @@ -221,8 +221,8 @@ namespace Artemis.UI.Screens.Settings.Tabs.General { try { - var autoRunFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), "Artemis.lnk"); - var executableFile = Constants.ExecutablePath; + string autoRunFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), "Artemis.lnk"); + string executableFile = Constants.ExecutablePath; if (File.Exists(autoRunFile)) File.Delete(autoRunFile); diff --git a/src/Artemis.UI/Screens/Settings/Tabs/Modules/ModuleOrderTabViewModel.cs b/src/Artemis.UI/Screens/Settings/Tabs/Modules/ModuleOrderTabViewModel.cs index 43077bd70..7e1452e6d 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/Modules/ModuleOrderTabViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Tabs/Modules/ModuleOrderTabViewModel.cs @@ -44,9 +44,9 @@ namespace Artemis.UI.Screens.Settings.Tabs.Modules if (dropInfo.TargetItem == dropInfo.Data) return; - var viewModel = (ModuleOrderModuleViewModel) dropInfo.Data; - var targetCollection = (BindableCollection) dropInfo.TargetCollection; - var insertIndex = dropInfo.InsertIndex; + ModuleOrderModuleViewModel viewModel = (ModuleOrderModuleViewModel) dropInfo.Data; + BindableCollection targetCollection = (BindableCollection) dropInfo.TargetCollection; + int insertIndex = dropInfo.InsertIndex; ModulePriorityCategory category; if (targetCollection == NormalModules) @@ -76,7 +76,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Modules OverlayModules.Clear(); OverlayModules.AddRange(_modules.Where(m => m.Module.PriorityCategory == ModulePriorityCategory.Overlay).OrderBy(m => m.Module.Priority)); - foreach (var moduleOrderModuleViewModel in _modules) + foreach (ModuleOrderModuleViewModel moduleOrderModuleViewModel in _modules) moduleOrderModuleViewModel.Update(); } } diff --git a/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsTabViewModel.cs b/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsTabViewModel.cs index fe3b33df9..9693c7d51 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsTabViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsTabViewModel.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Artemis.Core.Services; using Artemis.UI.Ninject.Factories; @@ -28,8 +29,8 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins Items.Clear(); await Task.Delay(200); - var instances = _pluginService.GetAllPluginInfo().Select(p => _settingsVmFactory.CreatePluginSettingsViewModel(p.Instance)).ToList(); - foreach (var pluginSettingsViewModel in instances) + List instances = _pluginService.GetAllPluginInfo().Select(p => _settingsVmFactory.CreatePluginSettingsViewModel(p.Instance)).ToList(); + foreach (PluginSettingsViewModel pluginSettingsViewModel in instances) Items.Add(pluginSettingsViewModel); }); diff --git a/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsViewModel.cs b/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsViewModel.cs index 0796a1297..96ca0a119 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsViewModel.cs @@ -2,6 +2,7 @@ using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection; using System.Threading.Tasks; using Artemis.Core; using Artemis.Core.DataModelExpansions; @@ -17,6 +18,7 @@ using Ninject; using Ninject.Parameters; using Serilog; using Stylet; +using Module = Artemis.Core.Modules.Module; namespace Artemis.UI.Screens.Settings.Tabs.Plugins { @@ -80,20 +82,20 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins public void OpenSettings() { - var configurationViewModel = Plugin.ConfigurationDialog; + PluginConfigurationDialog configurationViewModel = Plugin.ConfigurationDialog; if (configurationViewModel == null) return; try { // Limit to one constructor, there's no need to have more and it complicates things anyway - var constructors = configurationViewModel.Type.GetConstructors(); + ConstructorInfo[] constructors = configurationViewModel.Type.GetConstructors(); if (constructors.Length != 1) throw new ArtemisUIException("Plugin configuration dialogs must have exactly one constructor"); - var pluginParameter = constructors.First().GetParameters().First(p => typeof(Plugin).IsAssignableFrom(p.ParameterType)); - var plugin = new ConstructorArgument(pluginParameter.Name, Plugin); - var viewModel = (PluginConfigurationViewModel) PluginInfo.Kernel.Get(configurationViewModel.Type, plugin); + ParameterInfo pluginParameter = constructors.First().GetParameters().First(p => typeof(Plugin).IsAssignableFrom(p.ParameterType)); + ConstructorArgument plugin = new ConstructorArgument(pluginParameter.Name, Plugin); + PluginConfigurationViewModel viewModel = (PluginConfigurationViewModel) PluginInfo.Kernel.Get(configurationViewModel.Type, plugin); _windowManager.ShowDialog(new PluginSettingsWindowViewModel(viewModel, Icon)); } catch (Exception e) @@ -136,7 +138,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins { if (PluginInfo.Icon != null) { - var parsedIcon = Enum.TryParse(PluginInfo.Icon, true, out var iconEnum); + bool parsedIcon = Enum.TryParse(PluginInfo.Icon, true, out PackIconKind iconEnum); if (parsedIcon) return iconEnum; } @@ -203,10 +205,10 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins private async Task DisableDeviceProvider() { - var restart = false; + bool restart = false; // If any plugin already requires a restart, don't ask the user again - var restartQueued = _pluginService.GetAllPluginInfo().Any(p => p.Instance != null && !p.Enabled && p.Instance.Enabled); + bool restartQueued = _pluginService.GetAllPluginInfo().Any(p => p.Instance != null && !p.Enabled && p.Instance.Enabled); // If the plugin isn't enabled (load failed), it can be disabled without a restart if (!restartQueued && Plugin.Enabled) { diff --git a/src/Artemis.UI/Screens/Shared/PanZoomViewModel.cs b/src/Artemis.UI/Screens/Shared/PanZoomViewModel.cs index 18b3c4eb6..f6773cf1e 100644 --- a/src/Artemis.UI/Screens/Shared/PanZoomViewModel.cs +++ b/src/Artemis.UI/Screens/Shared/PanZoomViewModel.cs @@ -84,9 +84,9 @@ namespace Artemis.UI.Screens.Shared public void ProcessMouseScroll(object sender, MouseWheelEventArgs e) { - var relative = GetRelativeMousePosition(sender, e); - var absoluteX = relative.X * Zoom + PanX; - var absoluteY = relative.Y * Zoom + PanY; + Point relative = GetRelativeMousePosition(sender, e); + double absoluteX = relative.X * Zoom + PanX; + double absoluteY = relative.Y * Zoom + PanY; if (e.Delta > 0) Zoom *= 1.1; @@ -120,8 +120,8 @@ namespace Artemis.UI.Screens.Shared if (LastPanPosition == null) LastPanPosition = e.GetPosition((IInputElement) sender); - var position = e.GetPosition((IInputElement) sender); - var delta = LastPanPosition - position; + Point position = e.GetPosition((IInputElement) sender); + Vector? delta = LastPanPosition - position; if (LimitToZero) { @@ -152,7 +152,7 @@ namespace Artemis.UI.Screens.Shared public Rect TransformContainingRect(Rect rect) { // Create the same transform group the view is using - var transformGroup = new TransformGroup(); + TransformGroup transformGroup = new TransformGroup(); transformGroup.Children.Add(new ScaleTransform(Zoom, Zoom)); transformGroup.Children.Add(new TranslateTransform(PanX, PanY)); @@ -168,7 +168,7 @@ namespace Artemis.UI.Screens.Shared private void SetZoomFromPercentage(double value) { - var newZoom = value / 100; + double newZoom = value / 100; // Focus towards the center of the zoomed area PanX += newZoom - Zoom; PanY += newZoom - Zoom; diff --git a/src/Artemis.UI/Screens/Sidebar/SidebarViewModel.cs b/src/Artemis.UI/Screens/Sidebar/SidebarViewModel.cs index 01daee98b..cccc40208 100644 --- a/src/Artemis.UI/Screens/Sidebar/SidebarViewModel.cs +++ b/src/Artemis.UI/Screens/Sidebar/SidebarViewModel.cs @@ -117,8 +117,8 @@ namespace Artemis.UI.Screens.Sidebar // Add all activated modules SidebarItems.Add(new DividerNavigationItem()); SidebarItems.Add(new SubheaderNavigationItem {Subheader = "Modules"}); - var modules = _pluginService.GetPluginsOfType().ToList(); - foreach (var module in modules) + List modules = _pluginService.GetPluginsOfType().ToList(); + foreach (Module module in modules) AddModule(module); // Select the top item, which will be one of the defaults @@ -149,13 +149,13 @@ namespace Artemis.UI.Screens.Sidebar else { // Icon is provided as string to avoid having to reference MaterialDesignThemes - var parsedIcon = Enum.TryParse(module.DisplayIcon, true, out var iconEnum); + bool parsedIcon = Enum.TryParse(module.DisplayIcon, true, out PackIconKind iconEnum); if (parsedIcon == false) iconEnum = PackIconKind.QuestionMarkCircle; icon = iconEnum; } - var sidebarItem = new FirstLevelNavigationItem {Icon = icon, Label = module.DisplayName}; + FirstLevelNavigationItem sidebarItem = new FirstLevelNavigationItem {Icon = icon, Label = module.DisplayName}; SidebarItems.Add(sidebarItem); SidebarModules.Add(sidebarItem, module); } @@ -166,7 +166,7 @@ namespace Artemis.UI.Screens.Sidebar if (SidebarModules.All(io => io.Value != module)) return; - var existing = SidebarModules.First(io => io.Value == module); + KeyValuePair existing = SidebarModules.First(io => io.Value == module); SidebarItems.Remove(existing.Key); SidebarModules.Remove(existing.Key); } @@ -176,7 +176,7 @@ namespace Artemis.UI.Screens.Sidebar if (!IsSidebarOpen) return; - var activeModules = SidebarModules.Count(m => m.Value.IsActivated); + int activeModules = SidebarModules.Count(m => m.Value.IsActivated); ActiveModules = activeModules == 1 ? "1 active module" : $"{activeModules} active modules"; } diff --git a/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorViewModel.cs b/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorViewModel.cs index 7e0a278ec..5e59bd77d 100644 --- a/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorViewModel.cs +++ b/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorViewModel.cs @@ -101,7 +101,7 @@ namespace Artemis.UI.Screens.SurfaceEditor public ArtemisSurface CreateSurfaceConfiguration(string name) { - var config = _surfaceService.CreateSurfaceConfiguration(name); + ArtemisSurface config = _surfaceService.CreateSurfaceConfiguration(name); Execute.PostToUIThread(() => SurfaceConfigurations.Add(config)); return config; } @@ -119,10 +119,10 @@ namespace Artemis.UI.Screens.SurfaceEditor private void LoadSurfaceConfigurations() { // Get surface configs - var configs = _surfaceService.SurfaceConfigurations.ToList(); + List configs = _surfaceService.SurfaceConfigurations.ToList(); // Get the active config, if empty, create a default config - var activeConfig = _surfaceService.ActiveSurface; + ArtemisSurface activeConfig = _surfaceService.ActiveSurface; if (activeConfig == null) { activeConfig = CreateSurfaceConfiguration("Default"); @@ -134,7 +134,7 @@ namespace Artemis.UI.Screens.SurfaceEditor { // Populate the UI collection SurfaceConfigurations.Clear(); - foreach (var surfaceConfiguration in configs) + foreach (ArtemisSurface surfaceConfiguration in configs) SurfaceConfigurations.Add(surfaceConfiguration); // Set the active config @@ -149,14 +149,14 @@ namespace Artemis.UI.Screens.SurfaceEditor { lock (Devices) { - var existing = Devices.ToList(); - var deviceViewModels = new List(); + List existing = Devices.ToList(); + List deviceViewModels = new List(); // Add missing/update existing - foreach (var surfaceDeviceConfiguration in SelectedSurface.Devices.OrderBy(d => d.ZIndex).ToList()) + foreach (ArtemisDevice surfaceDeviceConfiguration in SelectedSurface.Devices.OrderBy(d => d.ZIndex).ToList()) { // Create VMs for missing devices - var viewModel = existing.FirstOrDefault(vm => vm.Device.RgbDevice == surfaceDeviceConfiguration.RgbDevice); + SurfaceDeviceViewModel viewModel = existing.FirstOrDefault(vm => vm.Device.RgbDevice == surfaceDeviceConfiguration.RgbDevice); if (viewModel == null) viewModel = new SurfaceDeviceViewModel(surfaceDeviceConfiguration); // Update existing devices @@ -195,7 +195,7 @@ namespace Artemis.UI.Screens.SurfaceEditor public async Task DeleteSurfaceConfiguration(ArtemisSurface surface) { - var result = await _dialogService.ShowConfirmDialogAt( + bool result = await _dialogService.ShowConfirmDialogAt( "SurfaceListDialogHost", "Delete surface configuration", "Are you sure you want to delete\nthis surface configuration?" @@ -209,7 +209,7 @@ namespace Artemis.UI.Screens.SurfaceEditor public async Task AddSurfaceConfiguration() { - var result = await _dialogService.ShowDialogAt("SurfaceListDialogHost"); + object result = await _dialogService.ShowDialogAt("SurfaceListDialogHost"); if (result is string name) CreateSurfaceConfiguration(name); } @@ -226,9 +226,9 @@ namespace Artemis.UI.Screens.SurfaceEditor public void BringToFront(SurfaceDeviceViewModel surfaceDeviceViewModel) { Devices.Move(Devices.IndexOf(surfaceDeviceViewModel), Devices.Count - 1); - for (var i = 0; i < Devices.Count; i++) + for (int i = 0; i < Devices.Count; i++) { - var deviceViewModel = Devices[i]; + SurfaceDeviceViewModel deviceViewModel = Devices[i]; deviceViewModel.Device.ZIndex = i + 1; } @@ -237,13 +237,13 @@ namespace Artemis.UI.Screens.SurfaceEditor public void BringForward(SurfaceDeviceViewModel surfaceDeviceViewModel) { - var currentIndex = Devices.IndexOf(surfaceDeviceViewModel); - var newIndex = Math.Min(currentIndex + 1, Devices.Count - 1); + int currentIndex = Devices.IndexOf(surfaceDeviceViewModel); + int newIndex = Math.Min(currentIndex + 1, Devices.Count - 1); Devices.Move(currentIndex, newIndex); - for (var i = 0; i < Devices.Count; i++) + for (int i = 0; i < Devices.Count; i++) { - var deviceViewModel = Devices[i]; + SurfaceDeviceViewModel deviceViewModel = Devices[i]; deviceViewModel.Device.ZIndex = i + 1; } @@ -253,9 +253,9 @@ namespace Artemis.UI.Screens.SurfaceEditor public void SendToBack(SurfaceDeviceViewModel surfaceDeviceViewModel) { Devices.Move(Devices.IndexOf(surfaceDeviceViewModel), 0); - for (var i = 0; i < Devices.Count; i++) + for (int i = 0; i < Devices.Count; i++) { - var deviceViewModel = Devices[i]; + SurfaceDeviceViewModel deviceViewModel = Devices[i]; deviceViewModel.Device.ZIndex = i + 1; } @@ -264,12 +264,12 @@ namespace Artemis.UI.Screens.SurfaceEditor public void SendBackward(SurfaceDeviceViewModel surfaceDeviceViewModel) { - var currentIndex = Devices.IndexOf(surfaceDeviceViewModel); - var newIndex = Math.Max(currentIndex - 1, 0); + int currentIndex = Devices.IndexOf(surfaceDeviceViewModel); + int newIndex = Math.Max(currentIndex - 1, 0); Devices.Move(currentIndex, newIndex); - for (var i = 0; i < Devices.Count; i++) + for (int i = 0; i < Devices.Count; i++) { - var deviceViewModel = Devices[i]; + SurfaceDeviceViewModel deviceViewModel = Devices[i]; deviceViewModel.Device.ZIndex = i + 1; } @@ -278,7 +278,7 @@ namespace Artemis.UI.Screens.SurfaceEditor public async Task ViewProperties(SurfaceDeviceViewModel surfaceDeviceViewModel) { - var madeChanges = await _dialogService.ShowDialog(new Dictionary + object madeChanges = await _dialogService.ShowDialog(new Dictionary { {"surfaceDeviceViewModel", surfaceDeviceViewModel} }); @@ -305,8 +305,8 @@ namespace Artemis.UI.Screens.SurfaceEditor if (IsPanKeyDown() || e.ChangedButton == MouseButton.Right) return; - var position = e.GetPosition((IInputElement) sender); - var relative = PanZoomViewModel.GetRelativeMousePosition(sender, e); + Point position = e.GetPosition((IInputElement) sender); + Point relative = PanZoomViewModel.GetRelativeMousePosition(sender, e); if (e.LeftButton == MouseButtonState.Pressed) StartMouseDrag(position, relative); else @@ -324,8 +324,8 @@ namespace Artemis.UI.Screens.SurfaceEditor return; } - var position = e.GetPosition((IInputElement) sender); - var relative = PanZoomViewModel.GetRelativeMousePosition(sender, e); + Point position = e.GetPosition((IInputElement) sender); + Point relative = PanZoomViewModel.GetRelativeMousePosition(sender, e); if (_mouseDragStatus == MouseDragStatus.Dragging) MoveSelected(relative); else if (_mouseDragStatus == MouseDragStatus.Selecting) @@ -335,7 +335,7 @@ namespace Artemis.UI.Screens.SurfaceEditor private void StartMouseDrag(Point position, Point relative) { // If drag started on top of a device, initialise dragging - var device = Devices.LastOrDefault(d => PanZoomViewModel.TransformContainingRect(d.DeviceRectangle).Contains(position)); + SurfaceDeviceViewModel device = Devices.LastOrDefault(d => PanZoomViewModel.TransformContainingRect(d.DeviceRectangle).Contains(position)); if (device != null) { _rgbService.IsRenderPaused = true; @@ -345,14 +345,14 @@ namespace Artemis.UI.Screens.SurfaceEditor { if (!Keyboard.IsKeyDown(Key.LeftShift) && !Keyboard.IsKeyDown(Key.RightShift)) { - foreach (var others in Devices) + foreach (SurfaceDeviceViewModel others in Devices) others.SelectionStatus = SelectionStatus.None; } device.SelectionStatus = SelectionStatus.Selected; } - foreach (var selectedDevice in Devices.Where(d => d.SelectionStatus == SelectionStatus.Selected)) + foreach (SurfaceDeviceViewModel selectedDevice in Devices.Where(d => d.SelectionStatus == SelectionStatus.Selected)) selectedDevice.StartMouseDrag(relative); } // Start multi-selection @@ -370,8 +370,8 @@ namespace Artemis.UI.Screens.SurfaceEditor { if (_mouseDragStatus != MouseDragStatus.Dragging) { - var selectedRect = new Rect(_mouseDragStartPoint, position); - foreach (var device in Devices) + Rect selectedRect = new Rect(_mouseDragStartPoint, position); + foreach (SurfaceDeviceViewModel device in Devices) { if (PanZoomViewModel.TransformContainingRect(device.DeviceRectangle).IntersectsWith(selectedRect)) device.SelectionStatus = SelectionStatus.Selected; @@ -391,10 +391,10 @@ namespace Artemis.UI.Screens.SurfaceEditor if (IsPanKeyDown()) return; - var selectedRect = new Rect(_mouseDragStartPoint, position); + Rect selectedRect = new Rect(_mouseDragStartPoint, position); SelectionRectangle.Rect = selectedRect; - foreach (var device in Devices) + foreach (SurfaceDeviceViewModel device in Devices) { if (PanZoomViewModel.TransformContainingRect(device.DeviceRectangle).IntersectsWith(selectedRect)) device.SelectionStatus = SelectionStatus.Selected; @@ -405,7 +405,7 @@ namespace Artemis.UI.Screens.SurfaceEditor private void MoveSelected(Point position) { - foreach (var device in Devices.Where(d => d.SelectionStatus == SelectionStatus.Selected)) + foreach (SurfaceDeviceViewModel device in Devices.Where(d => d.SelectionStatus == SelectionStatus.Selected)) device.UpdateMouseDrag(position); } diff --git a/src/Artemis.UI/Screens/SurfaceEditor/Visualization/SurfaceDeviceViewModel.cs b/src/Artemis.UI/Screens/SurfaceEditor/Visualization/SurfaceDeviceViewModel.cs index d7f85d990..20789c29b 100644 --- a/src/Artemis.UI/Screens/SurfaceEditor/Visualization/SurfaceDeviceViewModel.cs +++ b/src/Artemis.UI/Screens/SurfaceEditor/Visualization/SurfaceDeviceViewModel.cs @@ -53,8 +53,8 @@ namespace Artemis.UI.Screens.SurfaceEditor.Visualization public void UpdateMouseDrag(Point mousePosition) { - var roundedX = Math.Round((mousePosition.X + _dragOffsetX) / 10, 0, MidpointRounding.AwayFromZero) * 10; - var roundedY = Math.Round((mousePosition.Y + _dragOffsetY) / 10, 0, MidpointRounding.AwayFromZero) * 10; + double roundedX = Math.Round((mousePosition.X + _dragOffsetX) / 10, 0, MidpointRounding.AwayFromZero) * 10; + double roundedY = Math.Round((mousePosition.Y + _dragOffsetY) / 10, 0, MidpointRounding.AwayFromZero) * 10; Device.X = Math.Max(0, roundedX); Device.Y = Math.Max(0, roundedY); } diff --git a/src/Artemis.UI/Screens/TrayViewModel.cs b/src/Artemis.UI/Screens/TrayViewModel.cs index e5bffe1c7..ce3fa134e 100644 --- a/src/Artemis.UI/Screens/TrayViewModel.cs +++ b/src/Artemis.UI/Screens/TrayViewModel.cs @@ -25,8 +25,8 @@ namespace Artemis.UI.Screens _debugService = debugService; CanShowRootViewModel = true; - var autoRunning = Bootstrapper.StartupArguments.Contains("--autorun"); - var showOnAutoRun = settingsService.GetSetting("UI.ShowOnStartup", true).Value; + bool autoRunning = Bootstrapper.StartupArguments.Contains("--autorun"); + bool showOnAutoRun = settingsService.GetSetting("UI.ShowOnStartup", true).Value; if (!autoRunning || showOnAutoRun) { ShowSplashScreen(); @@ -54,7 +54,7 @@ namespace Artemis.UI.Screens { _splashViewModel?.RequestClose(); _splashViewModel = null; - var rootViewModel = _kernel.Get(); + RootViewModel rootViewModel = _kernel.Get(); rootViewModel.Closed += RootViewModelOnClosed; _windowManager.ShowWindow(rootViewModel); }); diff --git a/src/Artemis.UI/Services/DebugService.cs b/src/Artemis.UI/Services/DebugService.cs index 21e143692..158457079 100644 --- a/src/Artemis.UI/Services/DebugService.cs +++ b/src/Artemis.UI/Services/DebugService.cs @@ -43,7 +43,7 @@ namespace Artemis.UI.Services private void BringDebuggerToForeground() { - var materialWindow = (MaterialWindow) _debugViewModel.View; + MaterialWindow materialWindow = (MaterialWindow) _debugViewModel.View; // Not as straightforward as you might think, this ensures the window always shows, even if it's behind another window etc. // https://stackoverflow.com/a/4831839/5015269 diff --git a/src/Artemis.UI/Services/LayerEditorService.cs b/src/Artemis.UI/Services/LayerEditorService.cs index 403a68fe5..4141501c3 100644 --- a/src/Artemis.UI/Services/LayerEditorService.cs +++ b/src/Artemis.UI/Services/LayerEditorService.cs @@ -23,7 +23,7 @@ namespace Artemis.UI.Services public Rect GetLayerBounds(Layer layer) { // Adjust the render rectangle for the difference in render scale - var renderScale = _settingsService.GetSetting("Core.RenderScale", 0.5).Value; + double renderScale = _settingsService.GetSetting("Core.RenderScale", 0.5).Value; return new Rect( layer.Bounds.Left / renderScale * 1, layer.Bounds.Top / renderScale * 1, @@ -35,13 +35,13 @@ namespace Artemis.UI.Services /// public Point GetLayerAnchorPosition(Layer layer, SKPoint? positionOverride = null) { - var layerBounds = GetLayerBounds(layer).ToSKRect(); - var positionProperty = layer.Transform.Position.CurrentValue; + SKRect layerBounds = GetLayerBounds(layer).ToSKRect(); + SKPoint positionProperty = layer.Transform.Position.CurrentValue; if (positionOverride != null) positionProperty = positionOverride.Value; // Start at the center of the shape - var position = new Point(layerBounds.MidX, layerBounds.MidY); + Point position = new Point(layerBounds.MidX, layerBounds.MidY); // Apply translation position.X += positionProperty.X * layerBounds.Width; @@ -53,20 +53,20 @@ namespace Artemis.UI.Services /// public TransformGroup GetLayerTransformGroup(Layer layer) { - var layerBounds = GetLayerBounds(layer).ToSKRect(); + SKRect layerBounds = GetLayerBounds(layer).ToSKRect(); // Apply transformation like done by the core during layer rendering. // The order in which translations are applied are different because the UI renders the shape inside // the layer using the structure of the XAML while the Core has to deal with that by applying the layer // position to the translation - var anchorPosition = GetLayerAnchorPosition(layer); - var anchorProperty = layer.Transform.AnchorPoint.CurrentValue; + Point anchorPosition = GetLayerAnchorPosition(layer); + SKPoint anchorProperty = layer.Transform.AnchorPoint.CurrentValue; // Translation originates from the unscaled center of the shape and is tied to the anchor - var x = anchorPosition.X - layerBounds.MidX - anchorProperty.X * layerBounds.Width; - var y = anchorPosition.Y - layerBounds.MidY - anchorProperty.Y * layerBounds.Height; + double x = anchorPosition.X - layerBounds.MidX - anchorProperty.X * layerBounds.Width; + double y = anchorPosition.Y - layerBounds.MidY - anchorProperty.Y * layerBounds.Height; - var transformGroup = new TransformGroup(); + TransformGroup transformGroup = new TransformGroup(); transformGroup.Children.Add(new TranslateTransform(x, y)); transformGroup.Children.Add(new ScaleTransform(layer.Transform.Scale.CurrentValue.Width / 100f, layer.Transform.Scale.CurrentValue.Height / 100f, anchorPosition.X, anchorPosition.Y)); transformGroup.Children.Add(new RotateTransform(layer.Transform.Rotation.CurrentValue, anchorPosition.X, anchorPosition.Y)); @@ -77,20 +77,20 @@ namespace Artemis.UI.Services /// public SKPath GetLayerPath(Layer layer, bool includeTranslation, bool includeScale, bool includeRotation, SKPoint? anchorOverride = null) { - var layerBounds = GetLayerBounds(layer).ToSKRect(); + SKRect layerBounds = GetLayerBounds(layer).ToSKRect(); // Apply transformation like done by the core during layer rendering (same differences apply as in GetLayerTransformGroup) - var anchorPosition = GetLayerAnchorPosition(layer).ToSKPoint(); + SKPoint anchorPosition = GetLayerAnchorPosition(layer).ToSKPoint(); if (anchorOverride != null) anchorPosition = anchorOverride.Value; - var anchorProperty = layer.Transform.AnchorPoint.CurrentValue; + SKPoint anchorProperty = layer.Transform.AnchorPoint.CurrentValue; // Translation originates from the unscaled center of the shape and is tied to the anchor - var x = anchorPosition.X - layerBounds.MidX - anchorProperty.X * layerBounds.Width; - var y = anchorPosition.Y - layerBounds.MidY - anchorProperty.Y * layerBounds.Height; + float x = anchorPosition.X - layerBounds.MidX - anchorProperty.X * layerBounds.Width; + float y = anchorPosition.Y - layerBounds.MidY - anchorProperty.Y * layerBounds.Height; - var path = new SKPath(); + SKPath path = new SKPath(); path.AddRect(layerBounds); if (includeTranslation) path.Transform(SKMatrix.MakeTranslation(x, y)); @@ -105,7 +105,7 @@ namespace Artemis.UI.Services /// public SKPoint GetScaledPoint(Layer layer, SKPoint point, bool absolute) { - var renderScale = _settingsService.GetSetting("Core.RenderScale", 0.5).Value; + double renderScale = _settingsService.GetSetting("Core.RenderScale", 0.5).Value; if (absolute) { return new SKPoint( @@ -123,12 +123,12 @@ namespace Artemis.UI.Services public SKPoint GetDragOffset(Layer layer, SKPoint dragStart) { // Figure out what the top left will be if the shape moves to the current cursor position - var scaledDragStart = GetScaledPoint(layer, dragStart, true); - var tempAnchor = GetLayerAnchorPosition(layer, scaledDragStart).ToSKPoint(); - var tempTopLeft = GetLayerPath(layer, true, true, true, tempAnchor)[0]; + SKPoint scaledDragStart = GetScaledPoint(layer, dragStart, true); + SKPoint tempAnchor = GetLayerAnchorPosition(layer, scaledDragStart).ToSKPoint(); + SKPoint tempTopLeft = GetLayerPath(layer, true, true, true, tempAnchor)[0]; // Get the shape's position - var topLeft = GetLayerPath(layer, true, true, true)[0]; + SKPoint topLeft = GetLayerPath(layer, true, true, true)[0]; // The difference between the two is the offset return topLeft - tempTopLeft; diff --git a/src/Artemis.UI/Services/RegistrationService.cs b/src/Artemis.UI/Services/RegistrationService.cs index 5e1e44c22..707222791 100644 --- a/src/Artemis.UI/Services/RegistrationService.cs +++ b/src/Artemis.UI/Services/RegistrationService.cs @@ -78,7 +78,7 @@ namespace Artemis.UI.Services private void LoadPluginModules() { - foreach (var pluginInfo in _pluginService.GetAllPluginInfo()) + foreach (PluginInfo pluginInfo in _pluginService.GetAllPluginInfo()) pluginInfo.Kernel.Load(new[] { new PluginUIModule(pluginInfo) }); } } diff --git a/src/Artemis.UI/Stylet/ArtemisViewManager.cs b/src/Artemis.UI/Stylet/ArtemisViewManager.cs index 9d9d1f511..26a26deb7 100644 --- a/src/Artemis.UI/Stylet/ArtemisViewManager.cs +++ b/src/Artemis.UI/Stylet/ArtemisViewManager.cs @@ -10,7 +10,7 @@ namespace Artemis.UI.Stylet protected override string ViewTypeNameForModelTypeName(string modelTypeName) { - var cleaned = modelTypeName.Split('`')[0]; + string cleaned = modelTypeName.Split('`')[0]; return base.ViewTypeNameForModelTypeName(cleaned); } } diff --git a/src/Artemis.UI/Stylet/NinjectBootstrapper.cs b/src/Artemis.UI/Stylet/NinjectBootstrapper.cs index c0b0055b5..40103e939 100644 --- a/src/Artemis.UI/Stylet/NinjectBootstrapper.cs +++ b/src/Artemis.UI/Stylet/NinjectBootstrapper.cs @@ -39,7 +39,7 @@ namespace Artemis.UI.Stylet /// protected virtual void DefaultConfigureIoC(IKernel kernel) { - var viewManagerConfig = new ViewManagerConfig + ViewManagerConfig viewManagerConfig = new ViewManagerConfig { ViewFactory = GetInstance, ViewAssemblies = new List {GetType().Assembly} diff --git a/src/Artemis.UI/Utilities/ThemeWatcher.cs b/src/Artemis.UI/Utilities/ThemeWatcher.cs index 5fa56505b..175dd7a42 100644 --- a/src/Artemis.UI/Utilities/ThemeWatcher.cs +++ b/src/Artemis.UI/Utilities/ThemeWatcher.cs @@ -20,8 +20,8 @@ namespace Artemis.UI.Utilities public void WatchTheme() { - var currentUser = WindowsIdentity.GetCurrent(); - var query = string.Format( + WindowsIdentity currentUser = WindowsIdentity.GetCurrent(); + string query = string.Format( CultureInfo.InvariantCulture, @"SELECT * FROM RegistryValueChangeEvent WHERE Hive = 'HKEY_USERS' AND KeyPath = '{0}\\{1}' AND ValueName = '{2}'", currentUser.User.Value, @@ -30,10 +30,10 @@ namespace Artemis.UI.Utilities try { - var watcher = new ManagementEventWatcher(query); + ManagementEventWatcher watcher = new ManagementEventWatcher(query); watcher.EventArrived += (sender, args) => { - var newWindowsTheme = GetWindowsTheme(); + WindowsTheme newWindowsTheme = GetWindowsTheme(); OnThemeChanged(new WindowsThemeEventArgs(newWindowsTheme)); }; @@ -48,12 +48,12 @@ namespace Artemis.UI.Utilities public WindowsTheme GetWindowsTheme() { - using (var key = Registry.CurrentUser.OpenSubKey(RegistryKeyPath)) + using (RegistryKey key = Registry.CurrentUser.OpenSubKey(RegistryKeyPath)) { - var registryValueObject = key?.GetValue(RegistryValueName); + object registryValueObject = key?.GetValue(RegistryValueName); if (registryValueObject == null) return WindowsTheme.Light; - var registryValue = (int) registryValueObject; + int registryValue = (int) registryValueObject; return registryValue > 0 ? WindowsTheme.Light : WindowsTheme.Dark; } diff --git a/src/Plugins/Artemis.Plugins.DataModelExpansions.TestData/DataModels/PluginDataModel.cs b/src/Plugins/Artemis.Plugins.DataModelExpansions.TestData/DataModels/PluginDataModel.cs index 0e24eac8b..abe0bf469 100644 --- a/src/Plugins/Artemis.Plugins.DataModelExpansions.TestData/DataModels/PluginDataModel.cs +++ b/src/Plugins/Artemis.Plugins.DataModelExpansions.TestData/DataModels/PluginDataModel.cs @@ -10,7 +10,7 @@ namespace Artemis.Plugins.DataModelExpansions.TestData.DataModels { PluginSubDataModel = new PluginSubDataModel(); ListItems = new List(); - for (var i = 0; i < 20; i++) + for (int i = 0; i < 20; i++) ListItems.Add(new SomeListItem {ItemName = $"Item {i + 1}", Number = i}); } diff --git a/src/Plugins/Artemis.Plugins.Devices.DMX/ViewModels/DMXConfigurationViewModel.cs b/src/Plugins/Artemis.Plugins.Devices.DMX/ViewModels/DMXConfigurationViewModel.cs index a3af8cc54..108254af3 100644 --- a/src/Plugins/Artemis.Plugins.Devices.DMX/ViewModels/DMXConfigurationViewModel.cs +++ b/src/Plugins/Artemis.Plugins.Devices.DMX/ViewModels/DMXConfigurationViewModel.cs @@ -6,7 +6,7 @@ namespace Artemis.Plugins.Devices.DMX.ViewModels { public DMXConfigurationViewModel(Plugin plugin) : base(plugin) { - var dmxInstance = RGB.NET.Devices.DMX.DMXDeviceProvider.Instance; + RGB.NET.Devices.DMX.DMXDeviceProvider dmxInstance = RGB.NET.Devices.DMX.DMXDeviceProvider.Instance; } } } \ No newline at end of file diff --git a/src/Plugins/Artemis.Plugins.Devices.Debug/DebugDeviceProvider.cs b/src/Plugins/Artemis.Plugins.Devices.Debug/DebugDeviceProvider.cs index ce47d7c94..132c5d5b7 100644 --- a/src/Plugins/Artemis.Plugins.Devices.Debug/DebugDeviceProvider.cs +++ b/src/Plugins/Artemis.Plugins.Devices.Debug/DebugDeviceProvider.cs @@ -31,11 +31,11 @@ namespace Artemis.Plugins.Devices.Debug ConfigurationDialog = new PluginConfigurationDialog(); PathHelper.ResolvingAbsolutePath += PathHelperOnResolvingAbsolutePath; - var definitions = _settings.GetSetting("DeviceDefinitions", new List()); + PluginSetting> definitions = _settings.GetSetting("DeviceDefinitions", new List()); if (definitions.Value == null) definitions.Value = new List(); - foreach (var deviceDefinition in definitions.Value) + foreach (DeviceDefinition deviceDefinition in definitions.Value) RGB.NET.Devices.Debug.DebugDeviceProvider.Instance.AddFakeDeviceDefinition(deviceDefinition.Layout, deviceDefinition.ImageLayout); try @@ -59,7 +59,7 @@ namespace Artemis.Plugins.Devices.Debug { if (debugRgbDevice.LayoutPath.Contains("\\Layouts\\")) { - var rootDirectory = debugRgbDevice.LayoutPath.Split("\\Layouts")[0]; + string rootDirectory = debugRgbDevice.LayoutPath.Split("\\Layouts")[0]; e.FinalPath = Path.Combine(rootDirectory, e.RelativePath); } } diff --git a/src/Plugins/Artemis.Plugins.Devices.Logitech/LogitechDeviceProvider.cs b/src/Plugins/Artemis.Plugins.Devices.Logitech/LogitechDeviceProvider.cs index 98cc72f34..9f4b4822b 100644 --- a/src/Plugins/Artemis.Plugins.Devices.Logitech/LogitechDeviceProvider.cs +++ b/src/Plugins/Artemis.Plugins.Devices.Logitech/LogitechDeviceProvider.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using System.Linq; using Artemis.Core; @@ -37,9 +38,9 @@ namespace Artemis.Plugins.Devices.Logitech private void LogDeviceIds() { - var devices = DeviceList.Local.GetHidDevices(VENDOR_ID).DistinctBy(d => d.ProductID).ToList(); + List devices = DeviceList.Local.GetHidDevices(VENDOR_ID).DistinctBy(d => d.ProductID).ToList(); _logger.Debug("Found {count} Logitech device(s)", devices.Count); - foreach (var hidDevice in devices) + foreach (HidDevice hidDevice in devices) { try { diff --git a/src/Plugins/Artemis.Plugins.Devices.WS281X/WS281XDeviceProvider.cs b/src/Plugins/Artemis.Plugins.Devices.WS281X/WS281XDeviceProvider.cs index d44be7c03..d90ef7a76 100644 --- a/src/Plugins/Artemis.Plugins.Devices.WS281X/WS281XDeviceProvider.cs +++ b/src/Plugins/Artemis.Plugins.Devices.WS281X/WS281XDeviceProvider.cs @@ -26,11 +26,11 @@ namespace Artemis.Plugins.Devices.WS281X { ConfigurationDialog = new PluginConfigurationDialog(); - var definitions = _settings.GetSetting>("DeviceDefinitions"); + PluginSetting> definitions = _settings.GetSetting>("DeviceDefinitions"); if (definitions.Value == null) definitions.Value = new List(); - foreach (var deviceDefinition in definitions.Value) + foreach (DeviceDefinition deviceDefinition in definitions.Value) { switch (deviceDefinition.Type) { diff --git a/src/Plugins/Artemis.Plugins.LayerBrushes.Color/ColorBrush.cs b/src/Plugins/Artemis.Plugins.LayerBrushes.Color/ColorBrush.cs index 9d66cbca8..f2c19944a 100644 --- a/src/Plugins/Artemis.Plugins.LayerBrushes.Color/ColorBrush.cs +++ b/src/Plugins/Artemis.Plugins.LayerBrushes.Color/ColorBrush.cs @@ -49,7 +49,7 @@ namespace Artemis.Plugins.LayerBrushes.Color { if (Layer.General.ResizeMode.CurrentValue == LayerResizeMode.Clip) { - var layerBounds = new SKRect(0, 0, Layer.Bounds.Width, Layer.Bounds.Height); + SKRect layerBounds = new SKRect(0, 0, Layer.Bounds.Width, Layer.Bounds.Height); if (layerBounds != _shaderBounds) { _shaderBounds = layerBounds; @@ -119,7 +119,7 @@ namespace Artemis.Plugins.LayerBrushes.Color private void CreateLinearGradient() { - var repeat = Properties.ColorsMultiplier.CurrentValue; + int repeat = Properties.ColorsMultiplier.CurrentValue; _linearGradientRotation = Properties.LinearGradientRotation.CurrentValue; _shader?.Dispose(); @@ -136,7 +136,7 @@ namespace Artemis.Plugins.LayerBrushes.Color private void CreateRadialGradient() { - var repeat = Properties.ColorsMultiplier.CurrentValue; + int repeat = Properties.ColorsMultiplier.CurrentValue; _shader?.Dispose(); _shader = SKShader.CreateRadialGradient( @@ -151,7 +151,7 @@ namespace Artemis.Plugins.LayerBrushes.Color private void CreateSweepGradient() { - var repeat = Properties.ColorsMultiplier.CurrentValue; + int repeat = Properties.ColorsMultiplier.CurrentValue; _shader?.Dispose(); _shader = SKShader.CreateSweepGradient( diff --git a/src/Plugins/Artemis.Plugins.LayerBrushes.Color/PropertyGroups/ColorBrushProperties.cs b/src/Plugins/Artemis.Plugins.LayerBrushes.Color/PropertyGroups/ColorBrushProperties.cs index 353fa5e43..90c6152fc 100644 --- a/src/Plugins/Artemis.Plugins.LayerBrushes.Color/PropertyGroups/ColorBrushProperties.cs +++ b/src/Plugins/Artemis.Plugins.LayerBrushes.Color/PropertyGroups/ColorBrushProperties.cs @@ -64,7 +64,7 @@ namespace Artemis.Plugins.LayerBrushes.Color.PropertyGroups private void UpdateVisibility() { - var normalRender = false; + bool normalRender = false; if (ProfileElement is Layer layer) normalRender = layer.General.ResizeMode.CurrentValue == LayerResizeMode.Normal; diff --git a/src/Plugins/Artemis.Plugins.LayerBrushes.Color/PropertyGroups/RadialGradientProperties.cs b/src/Plugins/Artemis.Plugins.LayerBrushes.Color/PropertyGroups/RadialGradientProperties.cs index 09499cdb5..aa58e5af9 100644 --- a/src/Plugins/Artemis.Plugins.LayerBrushes.Color/PropertyGroups/RadialGradientProperties.cs +++ b/src/Plugins/Artemis.Plugins.LayerBrushes.Color/PropertyGroups/RadialGradientProperties.cs @@ -37,7 +37,7 @@ namespace Artemis.Plugins.LayerBrushes.Color.PropertyGroups private void UpdateVisibility() { - var normalRender = false; + bool normalRender = false; if (ProfileElement is Layer layer) normalRender = layer.General.ResizeMode.CurrentValue == LayerResizeMode.Normal; diff --git a/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/NoiseBrush.cs b/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/NoiseBrush.cs index aea4e6024..e936cd3fe 100644 --- a/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/NoiseBrush.cs +++ b/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/NoiseBrush.cs @@ -62,25 +62,25 @@ namespace Artemis.Plugins.LayerBrushes.Noise public override SKColor GetColor(ArtemisLed led, SKPoint renderPoint) { - var mainColor = Properties.MainColor.CurrentValue; - var secondColor = Properties.SecondaryColor.CurrentValue; - var gradientColor = Properties.GradientColor.CurrentValue; - var scale = Properties.Scale.CurrentValue; - var hardness = Properties.Hardness.CurrentValue / 100f; + SKColor mainColor = Properties.MainColor.CurrentValue; + SKColor secondColor = Properties.SecondaryColor.CurrentValue; + ColorGradient gradientColor = Properties.GradientColor.CurrentValue; + SKSize scale = Properties.Scale.CurrentValue; + float hardness = Properties.Hardness.CurrentValue / 100f; - var scrolledX = renderPoint.X + _x; + float scrolledX = renderPoint.X + _x; if (float.IsNaN(scrolledX) || float.IsInfinity(scrolledX)) scrolledX = 0; - var scrolledY = renderPoint.Y + _y; + float scrolledY = renderPoint.Y + _y; if (float.IsNaN(scrolledY) || float.IsInfinity(scrolledY)) scrolledY = 0; - var evalX = scrolledX * (scale.Width * -1) / 1000f; - var evalY = scrolledY * (scale.Height * -1) / 1000f; + float evalX = scrolledX * (scale.Width * -1) / 1000f; + float evalY = scrolledY * (scale.Height * -1) / 1000f; - var v = (float) _noise.Evaluate(evalX, evalY, _z) * hardness; - var amount = Math.Max(0f, Math.Min(1f, v)); + float v = (float) _noise.Evaluate(evalX, evalY, _z) * hardness; + float amount = Math.Max(0f, Math.Min(1f, v)); if (Properties.ColorType.BaseValue == ColorMappingType.Simple) return mainColor.Interpolate(secondColor, amount); @@ -177,8 +177,8 @@ namespace Artemis.Plugins.LayerBrushes.Noise private void CreateColorMap() { - var colorMap = new SKColor[101]; - for (var i = 0; i < 101; i++) + SKColor[] colorMap = new SKColor[101]; + for (int i = 0; i < 101; i++) colorMap[i] = Properties.GradientColor.BaseValue.GetColor(i / 100f); _colorMap = colorMap; diff --git a/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/Utilities/OpenSimplexNoise.cs b/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/Utilities/OpenSimplexNoise.cs index ad20c1786..9857aad68 100644 --- a/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/Utilities/OpenSimplexNoise.cs +++ b/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/Utilities/OpenSimplexNoise.cs @@ -42,20 +42,20 @@ namespace Artemis.Plugins.LayerBrushes.Noise.Utilities static OpenSimplexNoise() { - var base2D = new[] + int[][] base2D = new[] { new[] {1, 1, 0, 1, 0, 1, 0, 0, 0}, new[] {1, 1, 0, 1, 0, 1, 2, 1, 1} }; - var p2D = new[] {0, 0, 1, -1, 0, 0, -1, 1, 0, 2, 1, 1, 1, 2, 2, 0, 1, 2, 0, 2, 1, 0, 0, 0}; - var lookupPairs2D = new[] {0, 1, 1, 0, 4, 1, 17, 0, 20, 2, 21, 2, 22, 5, 23, 5, 26, 4, 39, 3, 42, 4, 43, 3}; + int[] p2D = new[] {0, 0, 1, -1, 0, 0, -1, 1, 0, 2, 1, 1, 1, 2, 2, 0, 1, 2, 0, 2, 1, 0, 0, 0}; + int[] lookupPairs2D = new[] {0, 1, 1, 0, 4, 1, 17, 0, 20, 2, 21, 2, 22, 5, 23, 5, 26, 4, 39, 3, 42, 4, 43, 3}; - var contributions2D = new Contribution2[p2D.Length / 4]; - for (var i = 0; i < p2D.Length; i += 4) + Contribution2[] contributions2D = new Contribution2[p2D.Length / 4]; + for (int i = 0; i < p2D.Length; i += 4) { - var baseSet = base2D[p2D[i]]; + int[] baseSet = base2D[p2D[i]]; Contribution2 previous = null, current = null; - for (var k = 0; k < baseSet.Length; k += 3) + for (int k = 0; k < baseSet.Length; k += 3) { current = new Contribution2(baseSet[k], baseSet[k + 1], baseSet[k + 2]); if (previous == null) @@ -69,24 +69,24 @@ namespace Artemis.Plugins.LayerBrushes.Noise.Utilities } lookup2D = new Contribution2[64]; - for (var i = 0; i < lookupPairs2D.Length; i += 2) + for (int i = 0; i < lookupPairs2D.Length; i += 2) lookup2D[lookupPairs2D[i]] = contributions2D[lookupPairs2D[i + 1]]; - var base3D = new[] + int[][] base3D = new[] { new[] {0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1}, new[] {2, 1, 1, 0, 2, 1, 0, 1, 2, 0, 1, 1, 3, 1, 1, 1}, new[] {1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 2, 1, 1, 0, 2, 1, 0, 1, 2, 0, 1, 1} }; - var p3D = new[] + int[] p3D = new[] { 0, 0, 1, -1, 0, 0, 1, 0, -1, 0, 0, -1, 1, 0, 0, 0, 1, -1, 0, 0, -1, 0, 1, 0, 0, -1, 1, 0, 2, 1, 1, 0, 1, 1, 1, -1, 0, 2, 1, 0, 1, 1, 1, -1, 1, 0, 2, 0, 1, 1, 1, -1, 1, 1, 1, 3, 2, 1, 0, 3, 1, 2, 0, 1, 3, 2, 0, 1, 3, 1, 0, 2, 1, 3, 0, 2, 1, 3, 0, 1, 2, 1, 1, 1, 0, 0, 2, 2, 0, 0, 1, 1, 0, 1, 0, 2, 0, 2, 0, 1, 1, 0, 0, 1, 2, 0, 0, 2, 2, 0, 0, 0, 0, 1, 1, -1, 1, 2, 0, 0, 0, 0, 1, -1, 1, 1, 2, 0, 0, 0, 0, 1, 1, 1, -1, 2, 3, 1, 1, 1, 2, 0, 0, 2, 2, 3, 1, 1, 1, 2, 2, 0, 0, 2, 3, 1, 1, 1, 2, 0, 2, 0, 2, 1, 1, -1, 1, 2, 0, 0, 2, 2, 1, 1, -1, 1, 2, 2, 0, 0, 2, 1, -1, 1, 1, 2, 0, 0, 2, 2, 1, -1, 1, 1, 2, 0, 2, 0, 2, 1, 1, 1, -1, 2, 2, 0, 0, 2, 1, 1, 1, -1, 2, 0, 2, 0 }; - var lookupPairs3D = new[] + int[] lookupPairs3D = new[] { 0, 2, 1, 1, 2, 2, 5, 1, 6, 0, 7, 0, 32, 2, 34, 2, 129, 1, 133, 1, 160, 5, 161, 5, 518, 0, 519, 0, 546, 4, 550, 4, 645, 3, 647, 3, 672, 5, 673, 5, 674, 4, 677, 3, 678, 4, 679, 3, 680, 13, 681, 13, 682, 12, 685, 14, 686, 12, 687, 14, 712, 20, 714, 18, 809, 21, 813, 23, 840, 20, 841, 21, 1198, 19, 1199, 22, 1226, 18, 1230, 19, 1325, 23, 1327, 22, 1352, 15, 1353, 17, @@ -94,12 +94,12 @@ namespace Artemis.Plugins.LayerBrushes.Noise.Utilities 1910, 7, 2005, 6, 2007, 6, 2032, 8, 2033, 8, 2034, 7, 2037, 6, 2038, 7, 2039, 6 }; - var contributions3D = new Contribution3[p3D.Length / 9]; - for (var i = 0; i < p3D.Length; i += 9) + Contribution3[] contributions3D = new Contribution3[p3D.Length / 9]; + for (int i = 0; i < p3D.Length; i += 9) { - var baseSet = base3D[p3D[i]]; + int[] baseSet = base3D[p3D[i]]; Contribution3 previous = null, current = null; - for (var k = 0; k < baseSet.Length; k += 4) + for (int k = 0; k < baseSet.Length; k += 4) { current = new Contribution3(baseSet[k], baseSet[k + 1], baseSet[k + 2], baseSet[k + 3]); if (previous == null) @@ -114,7 +114,7 @@ namespace Artemis.Plugins.LayerBrushes.Noise.Utilities } lookup3D = new Contribution3[2048]; - for (var i = 0; i < lookupPairs3D.Length; i += 2) + for (int i = 0; i < lookupPairs3D.Length; i += 2) lookup3D[lookupPairs3D[i]] = contributions3D[lookupPairs3D[i + 1]]; } @@ -129,16 +129,16 @@ namespace Artemis.Plugins.LayerBrushes.Noise.Utilities perm2D = new byte[256]; perm3D = new byte[256]; perm4D = new byte[256]; - var source = new byte[256]; - for (var i = 0; i < 256; i++) + byte[] source = new byte[256]; + for (int i = 0; i < 256; i++) source[i] = (byte) i; seed = seed * 6364136223846793005L + 1442695040888963407L; seed = seed * 6364136223846793005L + 1442695040888963407L; seed = seed * 6364136223846793005L + 1442695040888963407L; - for (var i = 255; i >= 0; i--) + for (int i = 255; i >= 0; i--) { seed = seed * 6364136223846793005L + 1442695040888963407L; - var r = (int) ((seed + 31) % (i + 1)); + int r = (int) ((seed + 31) % (i + 1)); if (r < 0) r += i + 1; perm[i] = source[r]; @@ -151,43 +151,43 @@ namespace Artemis.Plugins.LayerBrushes.Noise.Utilities public double Evaluate(double x, double y) { - var stretchOffset = (x + y) * STRETCH_2D; - var xs = x + stretchOffset; - var ys = y + stretchOffset; + double stretchOffset = (x + y) * STRETCH_2D; + double xs = x + stretchOffset; + double ys = y + stretchOffset; - var xsb = FastFloor(xs); - var ysb = FastFloor(ys); + int xsb = FastFloor(xs); + int ysb = FastFloor(ys); - var squishOffset = (xsb + ysb) * SQUISH_2D; - var dx0 = x - (xsb + squishOffset); - var dy0 = y - (ysb + squishOffset); + double squishOffset = (xsb + ysb) * SQUISH_2D; + double dx0 = x - (xsb + squishOffset); + double dy0 = y - (ysb + squishOffset); - var xins = xs - xsb; - var yins = ys - ysb; + double xins = xs - xsb; + double yins = ys - ysb; - var inSum = xins + yins; + double inSum = xins + yins; - var hash = + int hash = (int) (xins - yins + 1) | ((int) inSum << 1) | ((int) (inSum + yins) << 2) | ((int) (inSum + xins) << 4); - var c = lookup2D[hash]; + Contribution2 c = lookup2D[hash]; - var value = 0.0; + double value = 0.0; while (c != null) { - var dx = dx0 + c.dx; - var dy = dy0 + c.dy; - var attn = 2 - dx * dx - dy * dy; + double dx = dx0 + c.dx; + double dy = dy0 + c.dy; + double attn = 2 - dx * dx - dy * dy; if (attn > 0) { - var px = xsb + c.xsb; - var py = ysb + c.ysb; + int px = xsb + c.xsb; + int py = ysb + c.ysb; - var i = perm2D[(perm[px & 0xFF] + py) & 0xFF]; - var valuePart = gradients2D[i] * dx + gradients2D[i + 1] * dy; + byte i = perm2D[(perm[px & 0xFF] + py) & 0xFF]; + double valuePart = gradients2D[i] * dx + gradients2D[i + 1] * dy; attn *= attn; value += attn * attn * valuePart; @@ -202,27 +202,27 @@ namespace Artemis.Plugins.LayerBrushes.Noise.Utilities [MethodImpl(MethodImplOptions.AggressiveInlining)] public double Evaluate(double x, double y, double z) { - var stretchOffset = (x + y + z) * STRETCH_3D; - var xs = x + stretchOffset; - var ys = y + stretchOffset; - var zs = z + stretchOffset; + double stretchOffset = (x + y + z) * STRETCH_3D; + double xs = x + stretchOffset; + double ys = y + stretchOffset; + double zs = z + stretchOffset; - var xsb = FastFloor(xs); - var ysb = FastFloor(ys); - var zsb = FastFloor(zs); + int xsb = FastFloor(xs); + int ysb = FastFloor(ys); + int zsb = FastFloor(zs); - var squishOffset = (xsb + ysb + zsb) * SQUISH_3D; - var dx0 = x - (xsb + squishOffset); - var dy0 = y - (ysb + squishOffset); - var dz0 = z - (zsb + squishOffset); + double squishOffset = (xsb + ysb + zsb) * SQUISH_3D; + double dx0 = x - (xsb + squishOffset); + double dy0 = y - (ysb + squishOffset); + double dz0 = z - (zsb + squishOffset); - var xins = xs - xsb; - var yins = ys - ysb; - var zins = zs - zsb; + double xins = xs - xsb; + double yins = ys - ysb; + double zins = zs - zsb; - var inSum = xins + yins + zins; + double inSum = xins + yins + zins; - var hash = + int hash = (int) (yins - zins + 1) | ((int) (xins - yins + 1) << 1) | ((int) (xins - zins + 1) << 2) | @@ -231,23 +231,23 @@ namespace Artemis.Plugins.LayerBrushes.Noise.Utilities ((int) (inSum + yins) << 7) | ((int) (inSum + xins) << 9); - var c = lookup3D[hash]; + Contribution3 c = lookup3D[hash]; - var value = 0.0; + double value = 0.0; while (c != null) { - var dx = dx0 + c.dx; - var dy = dy0 + c.dy; - var dz = dz0 + c.dz; - var attn = 2 - dx * dx - dy * dy - dz * dz; + double dx = dx0 + c.dx; + double dy = dy0 + c.dy; + double dz = dz0 + c.dz; + double attn = 2 - dx * dx - dy * dy - dz * dz; if (attn > 0) { - var px = xsb + c.xsb; - var py = ysb + c.ysb; - var pz = zsb + c.zsb; + int px = xsb + c.xsb; + int py = ysb + c.ysb; + int pz = zsb + c.zsb; - var i = perm3D[(perm[(perm[px & 0xFF] + py) & 0xFF] + pz) & 0xFF]; - var valuePart = gradients3D[i] * dx + gradients3D[i + 1] * dy + gradients3D[i + 2] * dz; + byte i = perm3D[(perm[(perm[px & 0xFF] + py) & 0xFF] + pz) & 0xFF]; + double valuePart = gradients3D[i] * dx + gradients3D[i + 1] * dy + gradients3D[i + 2] * dz; attn *= attn; value += attn * attn * valuePart; @@ -262,7 +262,7 @@ namespace Artemis.Plugins.LayerBrushes.Noise.Utilities [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int FastFloor(double x) { - var xi = (int) x; + int xi = (int) x; return x < xi ? xi - 1 : xi; } diff --git a/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs b/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs index 2c2db08cf..1099f977d 100644 --- a/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs +++ b/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs @@ -49,7 +49,7 @@ namespace Artemis.Plugins.Modules.General public void UpdateCurrentWindow() { - var processId = WindowUtilities.GetActiveProcessId(); + int processId = WindowUtilities.GetActiveProcessId(); if (DataModel.ActiveWindow == null || DataModel.ActiveWindow.Process.Id != processId) DataModel.ActiveWindow = new WindowDataModel(Process.GetProcessById(processId)); if (DataModel.ActiveWindow != null && string.IsNullOrWhiteSpace(DataModel.ActiveWindow.WindowTitle)) diff --git a/src/Plugins/Artemis.Plugins.Modules.General/Utilities/WindowUtilities.cs b/src/Plugins/Artemis.Plugins.Modules.General/Utilities/WindowUtilities.cs index e8b32b08b..d6901f7d9 100644 --- a/src/Plugins/Artemis.Plugins.Modules.General/Utilities/WindowUtilities.cs +++ b/src/Plugins/Artemis.Plugins.Modules.General/Utilities/WindowUtilities.cs @@ -7,8 +7,8 @@ namespace Artemis.Plugins.Modules.General.Utilities { public static int GetActiveProcessId() { - var hWnd = GetForegroundWindow(); // Get foreground window handle - GetWindowThreadProcessId(hWnd, out var processId); + IntPtr hWnd = GetForegroundWindow(); // Get foreground window handle + GetWindowThreadProcessId(hWnd, out uint processId); return (int) processId; }