mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Darthified code
This commit is contained in:
1 parent
5b80c1e4fe
commit
ae64db8a13
198 files changed
+1339
-1305
No files matched your search
@@ -12,7 +12,7 @@ namespace Artemis.UI.Shared
|
||||
if (Initialized)
|
||||
return;
|
||||
|
||||
var colorPickerService = kernel.Get<IColorPickerService>();
|
||||
IColorPickerService colorPickerService = kernel.Get<IColorPickerService>();
|
||||
GradientPicker.ColorPickerService = colorPickerService;
|
||||
ColorPicker.ColorPickerService = colorPickerService;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ namespace Artemis.UI.Shared
|
||||
/// <inheritdoc />
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var colorGradients = (BindableCollection<ColorGradientStop>) value;
|
||||
var collection = new GradientStopCollection();
|
||||
BindableCollection<ColorGradientStop> colorGradients = (BindableCollection<ColorGradientStop>) 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
|
||||
/// <inheritdoc />
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var collection = (GradientStopCollection) value;
|
||||
var colorGradients = new BindableCollection<ColorGradientStop>();
|
||||
GradientStopCollection collection = (GradientStopCollection) value;
|
||||
BindableCollection<ColorGradientStop> colorGradients = new BindableCollection<ColorGradientStop>();
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@ namespace Artemis.UI.Shared
|
||||
/// <inheritdoc />
|
||||
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);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Artemis.UI.Shared
|
||||
/// <inheritdoc />
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+19
-18
@@ -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<DataModelIgnoreAttribute>() != 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<string, DataModel> 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<DataModelVisualizationViewModel> 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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Artemis.UI.Shared.Screens.Exceptions
|
||||
Header = message;
|
||||
Exceptions = new List<DialogException>();
|
||||
|
||||
var currentException = exception;
|
||||
Exception currentException = exception;
|
||||
while (currentException != null)
|
||||
{
|
||||
Exceptions.Add(new DialogException(currentException));
|
||||
|
||||
@@ -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<Canvas>((DependencyObject) sender, null);
|
||||
var position = e.GetPosition(parent);
|
||||
Canvas parent = VisualTreeUtilities.FindParent<Canvas>((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<ColorGradientStop> 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)
|
||||
|
||||
@@ -50,14 +50,14 @@ namespace Artemis.UI.Shared.Screens.GradientEditor
|
||||
|
||||
public void AddColorStop(object sender, MouseEventArgs e)
|
||||
{
|
||||
var child = VisualTreeUtilities.FindChild<Canvas>((DependencyObject) sender, null);
|
||||
var position = (float) (e.GetPosition(child).X / PreviewWidth);
|
||||
var stop = new ColorGradientStop(ColorGradient.GetColor(position), position);
|
||||
Canvas child = VisualTreeUtilities.FindChild<Canvas>((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<Canvas>((DependencyObject) sender, null);
|
||||
Canvas parent = VisualTreeUtilities.FindParent<Canvas>((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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<Type>();
|
||||
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<T>(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<DefaultDataModelDisplayViewModel>();
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<bool> 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<ConfirmDialogViewModel>(arguments);
|
||||
object result = await ShowDialog<ConfirmDialogViewModel>(arguments);
|
||||
return (bool) result;
|
||||
}
|
||||
|
||||
public async Task<bool> 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<ConfirmDialogViewModel>(identifier, arguments);
|
||||
object result = await ShowDialogAt<ConfirmDialogViewModel>(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<IParameter>().ToArray();
|
||||
IParameter[] paramsArray = parameters.Select(kv => new ConstructorArgument(kv.Key, kv.Value)).Cast<IParameter>().ToArray();
|
||||
return ShowDialog<T>(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<IParameter>().ToArray();
|
||||
IParameter[] paramsArray = parameters.Select(kv => new ConstructorArgument(kv.Key, kv.Value)).Cast<IParameter>().ToArray();
|
||||
return await ShowDialogAt<T>(identifier, paramsArray);
|
||||
}
|
||||
|
||||
@@ -101,7 +102,7 @@ namespace Artemis.UI.Shared.Services
|
||||
Task<object> result = null;
|
||||
await Execute.OnUIThreadAsync(() =>
|
||||
{
|
||||
var view = _viewManager.CreateViewForModel(viewModel);
|
||||
UIElement view = _viewManager.CreateViewForModel(viewModel);
|
||||
_viewManager.BindViewToModel(view, viewModel);
|
||||
|
||||
if (identifier == null)
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<T> CreatePropertyInputViewModel<T>(LayerProperty<T> 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<T>) 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)
|
||||
|
||||
@@ -19,13 +19,13 @@ namespace Artemis.UI.Shared
|
||||
/// <returns>A human readable description of the given enum value</returns>
|
||||
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("_", " ")));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ namespace Artemis.UI.Shared
|
||||
/// <returns></returns>
|
||||
public static List<T> GetHitViewModels<T>(Visual container, RectangleGeometry rectangleGeometry)
|
||||
{
|
||||
var result = new List<T>();
|
||||
var hitTestParams = new GeometryHitTestParameters(rectangleGeometry);
|
||||
var resultCallback = new HitTestResultCallback(r => HitTestResultBehavior.Continue);
|
||||
var filterCallback = new HitTestFilterCallback(e =>
|
||||
List<T> result = new List<T>();
|
||||
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);
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Artemis.UI.Shared
|
||||
/// <param name="iconPath">The icon path of the shortcut</param>
|
||||
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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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<T>(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)
|
||||
|
||||
Reference in new issue
Block a user