mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Core - Flattened namespaces
Shared UI - Flattened namespaces Shared UI - General housekeeping Project - Code cleanup
This commit is contained in:
1 parent
029e39ec1d
commit
8718d01eae
454 files changed
+1678
-1938
No files matched your search
@@ -1,76 +0,0 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
namespace Artemis.UI.Shared.AnimationTimeline
|
||||
{
|
||||
public class BrushAnimation : System.Windows.Media.Animation.AnimationTimeline
|
||||
{
|
||||
public static readonly DependencyProperty FromProperty =
|
||||
DependencyProperty.Register("From", typeof(Brush), typeof(BrushAnimation));
|
||||
|
||||
public static readonly DependencyProperty ToProperty =
|
||||
DependencyProperty.Register("To", typeof(Brush), typeof(BrushAnimation));
|
||||
|
||||
public override Type TargetPropertyType => typeof(Brush);
|
||||
|
||||
//we must define From and To, AnimationTimeline does not have this properties
|
||||
public Brush From
|
||||
{
|
||||
get => (Brush) GetValue(FromProperty);
|
||||
set => SetValue(FromProperty, value);
|
||||
}
|
||||
|
||||
public Brush To
|
||||
{
|
||||
get => (Brush) GetValue(ToProperty);
|
||||
set => SetValue(ToProperty, value);
|
||||
}
|
||||
|
||||
public override object GetCurrentValue(object defaultOriginValue,
|
||||
object defaultDestinationValue,
|
||||
AnimationClock animationClock)
|
||||
{
|
||||
return GetCurrentValue(defaultOriginValue as Brush,
|
||||
defaultDestinationValue as Brush,
|
||||
animationClock);
|
||||
}
|
||||
|
||||
public object GetCurrentValue(Brush defaultOriginValue,
|
||||
Brush defaultDestinationValue,
|
||||
AnimationClock animationClock)
|
||||
{
|
||||
if (!animationClock.CurrentProgress.HasValue)
|
||||
return Brushes.Transparent;
|
||||
|
||||
//use the standard values if From and To are not set
|
||||
//(it is the value of the given property)
|
||||
defaultOriginValue = From ?? defaultOriginValue;
|
||||
defaultDestinationValue = To ?? defaultDestinationValue;
|
||||
|
||||
if (animationClock.CurrentProgress.Value == 0)
|
||||
return defaultOriginValue;
|
||||
if (animationClock.CurrentProgress.Value == 1)
|
||||
return defaultDestinationValue;
|
||||
|
||||
return new VisualBrush(new Border
|
||||
{
|
||||
Width = 1,
|
||||
Height = 1,
|
||||
Background = defaultOriginValue,
|
||||
Child = new Border
|
||||
{
|
||||
Background = defaultDestinationValue,
|
||||
Opacity = animationClock.CurrentProgress.Value
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected override Freezable CreateInstanceCore()
|
||||
{
|
||||
return new BrushAnimation();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=behaviors/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=controls/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=converters/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=datamodelvisualization/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=datamodelvisualization_005Cshared/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=dependencyproperties/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=events/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=exceptions/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=propertyinput/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=services_005Cdatamodelvisualization/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=services_005Cdialog/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=services_005Cinterfaces/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=utilities/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Windows.Controls;
|
||||
using Microsoft.Xaml.Behaviors;
|
||||
|
||||
namespace Artemis.UI.Shared.Behaviors
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
public class PutCursorAtEndTextBoxBehavior : Behavior<UIElement>
|
||||
{
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Shared.Converters" x:Class="Artemis.UI.Shared.Controls.ColorPicker"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared"
|
||||
x:Class="Artemis.UI.Shared.ColorPicker"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="101.848" d:DesignWidth="242.956">
|
||||
<UserControl.Resources>
|
||||
@@ -13,8 +14,8 @@
|
||||
<ResourceDictionary Source="pack://application:,,,/Artemis.UI.Shared;component/Resources/ArtemisShared.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ColorPicker.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<converters:ColorToStringConverter x:Key="ColorToStringConverter" />
|
||||
<converters:ColorToSolidColorConverter x:Key="ColorToSolidColorConverter" />
|
||||
<shared:ColorToStringConverter x:Key="ColorToStringConverter" />
|
||||
<shared:ColorToSolidColorConverter x:Key="ColorToSolidColorConverter" />
|
||||
<ControlTemplate x:Key="MaterialDesignOpacitySlider" TargetType="{x:Type Slider}">
|
||||
<Border
|
||||
x:Name="border"
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Artemis.UI.Shared.Controls
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ColorPicker.xaml
|
||||
|
||||
@@ -8,18 +8,30 @@ using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Threading;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.UI.Shared.Controls
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// Visualizes an <see cref="ArtemisDevice" /> with optional per-LED colors
|
||||
/// </summary>
|
||||
public class DeviceVisualizer : FrameworkElement, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The device to visualize
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty DeviceProperty = DependencyProperty.Register(nameof(Device), typeof(ArtemisDevice), typeof(DeviceVisualizer),
|
||||
new FrameworkPropertyMetadata(default(ArtemisDevice), FrameworkPropertyMetadataOptions.AffectsRender, DevicePropertyChangedCallback));
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not to show per-LED colors
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ShowColorsProperty = DependencyProperty.Register(nameof(ShowColors), typeof(bool), typeof(DeviceVisualizer),
|
||||
new FrameworkPropertyMetadata(default(bool), FrameworkPropertyMetadataOptions.AffectsRender, ShowColorsPropertyChangedCallback));
|
||||
|
||||
/// <summary>
|
||||
/// A list of LEDs to highlight
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty HighlightedLedsProperty = DependencyProperty.Register(nameof(HighlightedLeds), typeof(IEnumerable<ArtemisLed>), typeof(DeviceVisualizer),
|
||||
new FrameworkPropertyMetadata(default(IEnumerable<ArtemisLed>)));
|
||||
|
||||
@@ -29,6 +41,9 @@ namespace Artemis.UI.Shared.Controls
|
||||
private BitmapImage _deviceImage;
|
||||
private ArtemisDevice _oldDevice;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="DeviceVisualizer" /> class
|
||||
/// </summary>
|
||||
public DeviceVisualizer()
|
||||
{
|
||||
_backingStore = new DrawingGroup();
|
||||
@@ -42,44 +57,40 @@ namespace Artemis.UI.Shared.Controls
|
||||
Unloaded += OnUnloaded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the device to visualize
|
||||
/// </summary>
|
||||
public ArtemisDevice Device
|
||||
{
|
||||
get => (ArtemisDevice) GetValue(DeviceProperty);
|
||||
set => SetValue(DeviceProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether or not to show per-LED colors
|
||||
/// </summary>
|
||||
public bool ShowColors
|
||||
{
|
||||
get => (bool) GetValue(ShowColorsProperty);
|
||||
set => SetValue(ShowColorsProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a list of LEDs to highlight
|
||||
/// </summary>
|
||||
public IEnumerable<ArtemisLed> HighlightedLeds
|
||||
{
|
||||
get => (IEnumerable<ArtemisLed>) GetValue(HighlightedLedsProperty);
|
||||
set => SetValue(HighlightedLedsProperty, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
_timer.Stop();
|
||||
}
|
||||
|
||||
public static Size ResizeKeepAspect(Size src, double maxWidth, double maxHeight)
|
||||
{
|
||||
double scale;
|
||||
if (maxWidth == double.PositiveInfinity && maxHeight != double.PositiveInfinity)
|
||||
scale = maxHeight / src.Height;
|
||||
else if (maxWidth != double.PositiveInfinity && maxHeight == double.PositiveInfinity)
|
||||
scale = maxWidth / src.Width;
|
||||
else if (maxWidth == double.PositiveInfinity && maxHeight == double.PositiveInfinity)
|
||||
return src;
|
||||
|
||||
scale = Math.Min(maxWidth / src.Width, maxHeight / src.Height);
|
||||
|
||||
return new Size(src.Width * scale, src.Height * scale);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnRender(DrawingContext drawingContext)
|
||||
{
|
||||
if (Device == null)
|
||||
@@ -118,6 +129,32 @@ namespace Artemis.UI.Shared.Controls
|
||||
drawingContext.DrawDrawing(_backingStore);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override Size MeasureOverride(Size availableSize)
|
||||
{
|
||||
if (Device == null)
|
||||
return Size.Empty;
|
||||
|
||||
var deviceSize = MeasureDevice();
|
||||
return ResizeKeepAspect(deviceSize, availableSize.Width, availableSize.Height);
|
||||
}
|
||||
|
||||
private static Size ResizeKeepAspect(Size src, double maxWidth, double maxHeight)
|
||||
{
|
||||
double scale;
|
||||
// ??
|
||||
if (double.IsPositiveInfinity(maxWidth) && !double.IsPositiveInfinity(maxHeight))
|
||||
scale = maxHeight / src.Height;
|
||||
else if (!double.IsPositiveInfinity(maxWidth) && double.IsPositiveInfinity(maxHeight))
|
||||
scale = maxWidth / src.Width;
|
||||
else if (double.IsPositiveInfinity(maxWidth) && double.IsPositiveInfinity(maxHeight))
|
||||
return src;
|
||||
|
||||
scale = Math.Min(maxWidth / src.Width, maxHeight / src.Height);
|
||||
|
||||
return new Size(src.Width * scale, src.Height * scale);
|
||||
}
|
||||
|
||||
private Size MeasureDevice()
|
||||
{
|
||||
if (Device == null)
|
||||
@@ -129,15 +166,6 @@ namespace Artemis.UI.Shared.Controls
|
||||
return rotationRect.Size;
|
||||
}
|
||||
|
||||
protected override Size MeasureOverride(Size availableSize)
|
||||
{
|
||||
if (Device == null)
|
||||
return Size.Empty;
|
||||
|
||||
var deviceSize = MeasureDevice();
|
||||
return ResizeKeepAspect(deviceSize, availableSize.Width, availableSize.Height);
|
||||
}
|
||||
|
||||
private void OnUnloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_timer.Stop();
|
||||
|
||||
@@ -3,11 +3,11 @@ using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core;
|
||||
using RGB.NET.Core;
|
||||
using Color = System.Windows.Media.Color;
|
||||
|
||||
namespace Artemis.UI.Shared.Controls
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
internal class DeviceVisualizerLed
|
||||
{
|
||||
@@ -69,7 +69,7 @@ namespace Artemis.UI.Shared.Controls
|
||||
// Create transparent pixels covering the entire LedRect so the image size matched the LedRect size
|
||||
drawingContext.DrawRectangle(new SolidColorBrush(Colors.Transparent), null, LedRect);
|
||||
// Translate to the top-left of the LedRect
|
||||
drawingContext.PushTransform(new TranslateTransform(LedRect.X , LedRect.Y));
|
||||
drawingContext.PushTransform(new TranslateTransform(LedRect.X, LedRect.Y));
|
||||
// Render the LED geometry
|
||||
drawingContext.DrawGeometry(fillBrush, new Pen(penBrush, 1) {LineJoin = PenLineJoin.Round}, DisplayGeometry.GetOutlinedPathGeometry());
|
||||
// Restore the drawing context
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
<UserControl x:Class="Artemis.UI.Shared.Controls.DraggableFloat"
|
||||
<UserControl x:Class="Artemis.UI.Shared.DraggableFloat"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:controls="clr-namespace:Artemis.UI.Shared.Controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<UserControl.Style>
|
||||
@@ -19,7 +17,7 @@
|
||||
<VisualBrush>
|
||||
<VisualBrush.Visual>
|
||||
<Rectangle x:Name="BorderVisual"
|
||||
Stroke="{DynamicResource MaterialDesignTextBoxBorder}"
|
||||
Stroke="{DynamicResource MaterialDesignTextBoxBorder}"
|
||||
StrokeThickness="1"
|
||||
Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
|
||||
Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}" />
|
||||
@@ -50,6 +48,6 @@
|
||||
KeyDown="InputKeyDown"
|
||||
Visibility="Collapsed"
|
||||
RequestBringIntoView="Input_OnRequestBringIntoView"
|
||||
PreviewTextInput="Input_PreviewTextInput"/>
|
||||
PreviewTextInput="Input_PreviewTextInput" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -7,7 +7,7 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Artemis.UI.Shared.Controls
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for DraggableFloat.xaml
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<UserControl x:Class="Artemis.UI.Shared.Controls.GradientPicker"
|
||||
<UserControl x:Class="Artemis.UI.Shared.GradientPicker"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Shared.Converters"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<converters:ColorGradientToGradientStopsConverter x:Key="ColorGradientToGradientStopsConverter" />
|
||||
<shared:ColorGradientToGradientStopsConverter x:Key="ColorGradientToGradientStopsConverter" />
|
||||
<VisualBrush x:Key="Checkerboard" TileMode="Tile" Stretch="Uniform" ViewportUnits="Absolute" Viewport="0,0,10,10">
|
||||
<VisualBrush.Visual>
|
||||
<Grid Width="10" Height="10">
|
||||
|
||||
@@ -4,12 +4,12 @@ using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using Artemis.Core.Models.Profile.Colors;
|
||||
using Artemis.UI.Shared.Annotations;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared.Properties;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Shared.Controls
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for GradientPicker.xaml
|
||||
|
||||
@@ -3,11 +3,11 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using Artemis.Core.Models.Profile.Colors;
|
||||
using Artemis.Core;
|
||||
using SkiaSharp;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Shared.Converters
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
@@ -17,6 +17,7 @@ namespace Artemis.UI.Shared.Converters
|
||||
[ValueConversion(typeof(BindableCollection<ColorGradientStop>), typeof(GradientStopCollection))]
|
||||
public class ColorGradientToGradientStopsConverter : IValueConverter
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var colorGradients = (BindableCollection<ColorGradientStop>) value;
|
||||
@@ -29,6 +30,7 @@ namespace Artemis.UI.Shared.Converters
|
||||
return collection;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var collection = (GradientStopCollection) value;
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.UI.Shared.Converters
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
@@ -13,12 +13,14 @@ namespace Artemis.UI.Shared.Converters
|
||||
[ValueConversion(typeof(Color), typeof(SKColor))]
|
||||
public class SKColorToColorConverter : IValueConverter
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var 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;
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Artemis.UI.Shared.Converters
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
@@ -13,12 +13,14 @@ namespace Artemis.UI.Shared.Converters
|
||||
[ValueConversion(typeof(Color), typeof(string))]
|
||||
public class ColorToSolidColorConverter : IValueConverter
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var color = (Color) value;
|
||||
return Color.FromRgb(color.R, color.G, color.B);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Artemis.UI.Shared.Converters
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
@@ -12,11 +12,13 @@ namespace Artemis.UI.Shared.Converters
|
||||
[ValueConversion(typeof(Color), typeof(string))]
|
||||
public class ColorToStringConverter : IValueConverter
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value?.ToString();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -4,26 +4,28 @@ using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.UI.Shared.Converters
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Converts <see cref="SKColor"/>into <see cref="T:System.String" />.
|
||||
/// Converts <see cref="SKColor" />into <see cref="T:System.String" />.
|
||||
/// </summary>
|
||||
[ValueConversion(typeof(Color), typeof(string))]
|
||||
public class SKColorToStringConverter : IValueConverter
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value?.ToString();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
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 var color) ? color : SKColor.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Shared.DataModelVisualization
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
public abstract class DataModelDisplayViewModel<T> : DataModelDisplayViewModel
|
||||
{
|
||||
|
||||
@@ -4,10 +4,10 @@ using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using Artemis.Core.Plugins.DataModelExpansions.Attributes;
|
||||
using Artemis.Core.DataModelExpansions;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Shared.DataModelVisualization
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
public abstract class DataModelInputViewModel<T> : DataModelInputViewModel
|
||||
{
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Plugins;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Shared.DataModelVisualization
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
public class DataModelVisualizationRegistration
|
||||
{
|
||||
|
||||
+2
-3
@@ -1,11 +1,10 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Artemis.Core.Plugins.DataModelExpansions;
|
||||
using Artemis.Core.DataModelExpansions;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
public class DataModelListPropertiesViewModel : DataModelPropertiesViewModel
|
||||
{
|
||||
|
||||
+2
-3
@@ -1,11 +1,10 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Artemis.Core.Plugins.DataModelExpansions;
|
||||
using Artemis.Core.DataModelExpansions;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
public class DataModelListPropertyViewModel : DataModelPropertyViewModel
|
||||
{
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using Artemis.Core.Extensions;
|
||||
using Artemis.Core.Plugins.DataModelExpansions;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.DataModelExpansions;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
public class DataModelListViewModel : DataModelVisualizationViewModel
|
||||
{
|
||||
@@ -50,7 +49,7 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
if (viewModel is DataModelListPropertyViewModel dataModelListPropertyViewModel)
|
||||
{
|
||||
dataModelListPropertyViewModel.DisplayValue = Activator.CreateInstance(dataModelListPropertyViewModel.ListType);
|
||||
var wrapper = new DataModelPropertiesViewModel(null,null,null);
|
||||
var wrapper = new DataModelPropertiesViewModel(null, null, null);
|
||||
wrapper.Children.Add(dataModelListPropertyViewModel);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Artemis.Core.Plugins.DataModelExpansions;
|
||||
using Artemis.Core.DataModelExpansions;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
public class DataModelPropertiesViewModel : DataModelVisualizationViewModel
|
||||
{
|
||||
@@ -31,6 +30,11 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
return Parent.IsRootViewModel ? DataModel : base.GetCurrentValue();
|
||||
}
|
||||
|
||||
protected int GetChildDepth()
|
||||
{
|
||||
return PropertyDescription != null && !PropertyDescription.ResetsDepth ? Depth + 1 : 1;
|
||||
}
|
||||
|
||||
private void PopulateProperties(IDataModelUIService dataModelUIService)
|
||||
{
|
||||
if (IsRootViewModel)
|
||||
@@ -57,10 +61,5 @@ namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
Children.Remove(dataModelVisualizationViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
protected int GetChildDepth()
|
||||
{
|
||||
return PropertyDescription != null && !PropertyDescription.ResetsDepth ? Depth + 1 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Artemis.Core.Plugins.DataModelExpansions;
|
||||
using Artemis.Core.DataModelExpansions;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
public class DataModelPropertyViewModel : DataModelVisualizationViewModel
|
||||
{
|
||||
|
||||
+3
-9
@@ -1,20 +1,14 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows.Documents;
|
||||
using Artemis.Core.Extensions;
|
||||
using Artemis.Core.Models.Profile.Conditions;
|
||||
using Artemis.Core.Plugins.DataModelExpansions;
|
||||
using Artemis.Core.Plugins.DataModelExpansions.Attributes;
|
||||
using Artemis.UI.Shared.Exceptions;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.DataModelExpansions;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Humanizer;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Shared.DataModelVisualization.Shared
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
public abstract class DataModelVisualizationViewModel : PropertyChangedBase
|
||||
{
|
||||
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace Artemis.UI.Shared.Utilities
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a dependency property that can observe the size of an element and apply it to bindings
|
||||
/// </summary>
|
||||
public static class SizeObserver
|
||||
{
|
||||
public static readonly DependencyProperty ObserveProperty = DependencyProperty.RegisterAttached(
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.UI.Shared.Events
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
public class ProfileEventArgs : EventArgs
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.UI.Shared.Events
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
public class RenderProfileElementEventArgs : EventArgs
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.UI.Shared.Exceptions
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
public class ArtemisSharedUIException : Exception
|
||||
{
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
using Artemis.Core.Models.Profile.Colors;
|
||||
using Artemis.UI.Shared.Screens.GradientEditor;
|
||||
|
||||
namespace Artemis.UI.Shared.Ninject.Factories
|
||||
{
|
||||
public interface IVmFactory
|
||||
{
|
||||
}
|
||||
|
||||
public interface IGradientEditorVmFactory : IVmFactory
|
||||
{
|
||||
GradientEditorViewModel Create(ColorGradient colorGradient);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,22 @@
|
||||
using System;
|
||||
using Artemis.UI.Shared.Ninject.Factories;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Ninject.Extensions.Conventions;
|
||||
using Ninject.Modules;
|
||||
|
||||
namespace Artemis.UI.Shared.Ninject
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// The main <see cref="NinjectModule" /> of the Artemis Shared UI toolkit that binds all services
|
||||
/// </summary>
|
||||
public class SharedUIModule : NinjectModule
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void Load()
|
||||
{
|
||||
if (Kernel == null)
|
||||
throw new ArgumentNullException("Kernel shouldn't be null here.");
|
||||
|
||||
// Bind UI factories
|
||||
Kernel.Bind(x =>
|
||||
{
|
||||
x.FromAssemblyContaining<IVmFactory>()
|
||||
.IncludingNonPublicTypes()
|
||||
.SelectAllInterfaces()
|
||||
.InheritedFrom<IVmFactory>()
|
||||
.BindToFactory();
|
||||
});
|
||||
|
||||
// Bind all shared UI services as singletons
|
||||
Kernel.Bind(x =>
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ using System;
|
||||
// ReSharper disable MemberCanBeProtected.Global
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace Artemis.UI.Shared.Annotations
|
||||
namespace Artemis.UI.Shared.Properties
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that the value of the marked element could be <c>null</c> sometimes,
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Plugins;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Services;
|
||||
|
||||
namespace Artemis.UI.Shared.PropertyInput
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
public class PropertyInputRegistration
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Shared.PropertyInput
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
public abstract class PropertyInputViewModel<T> : PropertyInputViewModel
|
||||
{
|
||||
@@ -127,7 +127,7 @@ namespace Artemis.UI.Shared.PropertyInput
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For internal use only, implement <see cref="PropertyInputViewModel{T}"/> instead.
|
||||
/// For internal use only, implement <see cref="PropertyInputViewModel{T}" /> instead.
|
||||
/// </summary>
|
||||
public abstract class PropertyInputViewModel : ValidatingModelBase, IDisposable
|
||||
{
|
||||
@@ -140,7 +140,7 @@ namespace Artemis.UI.Shared.PropertyInput
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prevents this type being implemented directly, implement <see cref="PropertyInputViewModel{T}"/> instead.
|
||||
/// Prevents this type being implemented directly, implement <see cref="PropertyInputViewModel{T}" /> instead.
|
||||
/// </summary>
|
||||
// ReSharper disable once UnusedMember.Global
|
||||
internal abstract object InternalGuard { get; }
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Shared.Resources">
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<VisualBrush x:Key="Checkerboard" TileMode="Tile" Stretch="Uniform" ViewportUnits="Absolute" Viewport="0,0,10,10">
|
||||
<VisualBrush.Visual>
|
||||
<Grid Width="10" Height="10">
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<UserControl x:Class="Artemis.UI.Shared.Screens.Dialogs.ConfirmDialogView"
|
||||
<UserControl x:ClassModifier="internal"
|
||||
x:Class="Artemis.UI.Shared.Screens.Dialogs.ConfirmDialogView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:dialogs="clr-namespace:Artemis.UI.Shared.Screens.Dialogs"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="163.274" d:DesignWidth="254.425"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Artemis.UI.Shared.Services.Dialog;
|
||||
using Artemis.UI.Shared.Services;
|
||||
|
||||
namespace Artemis.UI.Shared.Screens.Dialogs
|
||||
{
|
||||
public class ConfirmDialogViewModel : DialogViewModelBase
|
||||
internal class ConfirmDialogViewModel : DialogViewModelBase
|
||||
{
|
||||
public ConfirmDialogViewModel(string header, string text, string confirmText, string cancelText)
|
||||
{
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<controls:MaterialWindow x:Class="Artemis.UI.Shared.Screens.Exceptions.ExceptionView"
|
||||
<controls:MaterialWindow x:ClassModifier="internal"
|
||||
x:Class="Artemis.UI.Shared.Screens.Exceptions.ExceptionView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:controls="clr-namespace:MaterialDesignExtensions.Controls;assembly=MaterialDesignExtensions"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:exceptions="clr-namespace:Artemis.UI.Shared.Screens.Exceptions"
|
||||
xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
|
||||
@@ -32,21 +32,21 @@
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}"
|
||||
Text="Stack trace"
|
||||
TextWrapping="Wrap"
|
||||
FontWeight="Bold"
|
||||
MaxWidth="1000" />
|
||||
Text="Stack trace"
|
||||
TextWrapping="Wrap"
|
||||
FontWeight="Bold"
|
||||
MaxWidth="1000" />
|
||||
|
||||
<avalonedit:TextEditor SyntaxHighlighting="C#"
|
||||
FontFamily="pack://application:,,,/Resources/Fonts/#Roboto Mono"
|
||||
FontSize="10pt"
|
||||
IsReadOnly="True"
|
||||
Document="{Binding Document}"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
Margin="0 10 10 0"
|
||||
MaxHeight="500"
|
||||
Padding="10" />
|
||||
FontFamily="pack://application:,,,/Resources/Fonts/#Roboto Mono"
|
||||
FontSize="10pt"
|
||||
IsReadOnly="True"
|
||||
Document="{Binding Document}"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
Margin="0 10 10 0"
|
||||
MaxHeight="500"
|
||||
Padding="10" />
|
||||
|
||||
<Separator Margin="0 15" />
|
||||
</StackPanel>
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.UI.Shared.Services.Dialog;
|
||||
using ICSharpCode.AvalonEdit.Document;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Shared.Screens.Exceptions
|
||||
{
|
||||
public class ExceptionViewModel : Screen
|
||||
internal class ExceptionViewModel : Screen
|
||||
{
|
||||
private List<DialogException> _exceptions;
|
||||
|
||||
@@ -32,7 +31,7 @@ namespace Artemis.UI.Shared.Screens.Exceptions
|
||||
}
|
||||
}
|
||||
|
||||
public class DialogException
|
||||
internal class DialogException
|
||||
{
|
||||
public DialogException(Exception exception)
|
||||
{
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<UserControl x:Class="Artemis.UI.Shared.Screens.GradientEditor.ColorStopView"
|
||||
<UserControl x:ClassModifier="internal"
|
||||
x:Class="Artemis.UI.Shared.Screens.GradientEditor.ColorStopView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Shared.Screens.GradientEditor"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Shared.Converters"
|
||||
xmlns:utilities="clr-namespace:Artemis.UI.Shared.Utilities"
|
||||
xmlns:animationTimeline="clr-namespace:Artemis.UI.Shared.AnimationTimeline"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:ColorStopViewModel}" Opacity="1">
|
||||
@@ -16,7 +15,7 @@
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/Artemis.UI.Shared;component/Resources/ArtemisShared.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<converters:SKColorToColorConverter x:Key="SKColorToColorConverter" />
|
||||
<shared:SKColorToColorConverter x:Key="SKColorToColorConverter" />
|
||||
<Style TargetType="Path" x:Key="ColorStopStyle">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding WillRemoveColorStop}" Value="True">
|
||||
|
||||
@@ -4,13 +4,12 @@ using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using Artemis.Core.Models.Profile.Colors;
|
||||
using Artemis.UI.Shared.Utilities;
|
||||
using Artemis.Core;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Shared.Screens.GradientEditor
|
||||
{
|
||||
public class ColorStopViewModel : PropertyChangedBase
|
||||
internal class ColorStopViewModel : PropertyChangedBase
|
||||
{
|
||||
private readonly GradientEditorViewModel _gradientEditorViewModel;
|
||||
private bool _isSelected;
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
<UserControl x:Class="Artemis.UI.Shared.Screens.GradientEditor.GradientEditorView"
|
||||
<UserControl x:ClassModifier="internal"
|
||||
x:Class="Artemis.UI.Shared.Screens.GradientEditor.GradientEditorView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Shared.Screens.GradientEditor"
|
||||
xmlns:controls="clr-namespace:MaterialDesignExtensions.Controls;assembly=MaterialDesignExtensions"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Shared.Converters"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:controls1="clr-namespace:Artemis.UI.Shared.Controls"
|
||||
xmlns:utilities="clr-namespace:Artemis.UI.Shared.Utilities"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared"
|
||||
mc:Ignorable="d"
|
||||
Background="{DynamicResource MaterialDesignPaper}"
|
||||
FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
|
||||
@@ -19,8 +17,8 @@
|
||||
d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:GradientEditorViewModel}">
|
||||
<UserControl.Resources>
|
||||
<converters:ColorGradientToGradientStopsConverter x:Key="ColorGradientToGradientStopsConverter" />
|
||||
<converters:SKColorToColorConverter x:Key="SKColorToColorConverter" />
|
||||
<shared:ColorGradientToGradientStopsConverter x:Key="ColorGradientToGradientStopsConverter" />
|
||||
<shared:SKColorToColorConverter x:Key="SKColorToColorConverter" />
|
||||
|
||||
<VisualBrush x:Key="Checkerboard" TileMode="Tile" Stretch="Uniform" ViewportUnits="Absolute" Viewport="0,0,10,10">
|
||||
<VisualBrush.Visual>
|
||||
@@ -62,7 +60,7 @@
|
||||
<TextBlock Margin="0 5">Gradient</TextBlock>
|
||||
|
||||
<Border Background="{StaticResource Checkerboard}">
|
||||
<Rectangle x:Name="Preview" Height="40" utilities:SizeObserver.Observe="True" utilities:SizeObserver.ObservedWidth="{Binding PreviewWidth, Mode=OneWayToSource}">
|
||||
<Rectangle x:Name="Preview" Height="40" shared:SizeObserver.Observe="True" shared:SizeObserver.ObservedWidth="{Binding PreviewWidth, Mode=OneWayToSource}">
|
||||
<Rectangle.Fill>
|
||||
<LinearGradientBrush
|
||||
GradientStops="{Binding ColorGradient.Stops, Converter={StaticResource ColorGradientToGradientStopsConverter}}"
|
||||
@@ -100,7 +98,7 @@
|
||||
|
||||
<StackPanel Grid.Column="0" Orientation="Horizontal">
|
||||
<Label HorizontalAlignment="Left" Margin="-5,0,0,0">Color:</Label>
|
||||
<controls1:ColorPicker
|
||||
<shared:ColorPicker
|
||||
x:Name="CurrentColor"
|
||||
Width="85"
|
||||
Margin="5,0,15,0"
|
||||
|
||||
@@ -4,18 +4,17 @@ using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using Artemis.Core.Models.Profile.Colors;
|
||||
using Artemis.UI.Shared.Services.Dialog;
|
||||
using Artemis.UI.Shared.Utilities;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Shared.Screens.GradientEditor
|
||||
{
|
||||
public class GradientEditorViewModel : DialogViewModelBase
|
||||
internal class GradientEditorViewModel : DialogViewModelBase
|
||||
{
|
||||
private readonly List<ColorGradientStop> _originalStops;
|
||||
private ColorStopViewModel _selectedColorStopViewModel;
|
||||
private double _previewWidth;
|
||||
private ColorStopViewModel _selectedColorStopViewModel;
|
||||
|
||||
public GradientEditorViewModel(ColorGradient colorGradient)
|
||||
{
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Shared.Services
|
||||
{
|
||||
public class DataBindingUIService : IDataBindingUIService
|
||||
internal class DataBindingUIService : IDataBindingUIService
|
||||
{
|
||||
public object GetDataBindingViewModel(Type propertyType)
|
||||
{
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Plugins;
|
||||
using Artemis.Core.Plugins.DataModelExpansions.Attributes;
|
||||
using Artemis.Core.Plugins.Exceptions;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.UI.Shared.DataModelVisualization;
|
||||
using Artemis.UI.Shared.DataModelVisualization.Shared;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.DataModelExpansions;
|
||||
using Artemis.Core.Services;
|
||||
using Ninject;
|
||||
using Ninject.Parameters;
|
||||
|
||||
@@ -57,7 +53,7 @@ namespace Artemis.UI.Shared.Services
|
||||
viewModel.UpdateRequested += (sender, args) => viewModel.Update(this);
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
|
||||
public bool GetPluginExtendsDataModel(Plugin plugin)
|
||||
{
|
||||
return _dataModelService.GetPluginExtendsDataModel(plugin);
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Artemis.Core.Plugins.DataModelExpansions;
|
||||
using Artemis.Core.DataModelExpansions;
|
||||
|
||||
namespace Artemis.UI.Shared.Services.DataModelVisualization
|
||||
namespace Artemis.UI.Shared.Services
|
||||
{
|
||||
public class ListDataModelWrapper : DataModel
|
||||
{
|
||||
public ListDataModelWrapper()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,12 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.Shared.Screens.Dialogs;
|
||||
using Artemis.UI.Shared.Screens.Exceptions;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Ninject;
|
||||
using Ninject.Parameters;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Shared.Services.Dialog
|
||||
namespace Artemis.UI.Shared.Services
|
||||
{
|
||||
internal class DialogService : IDialogService
|
||||
{
|
||||
@@ -24,7 +23,7 @@ namespace Artemis.UI.Shared.Services.Dialog
|
||||
_viewManager = viewManager;
|
||||
_windowManager = windowManager;
|
||||
}
|
||||
|
||||
|
||||
public async Task<bool> ShowConfirmDialog(string header, string text, string confirmText = "Confirm", string cancelText = "Cancel")
|
||||
{
|
||||
var arguments = new IParameter[]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Shared.Services.Dialog
|
||||
namespace Artemis.UI.Shared.Services
|
||||
{
|
||||
public abstract class DialogViewModelBase : ValidatingModelBase
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Shared.Services.Dialog
|
||||
namespace Artemis.UI.Shared.Services
|
||||
{
|
||||
public class DialogViewModelHost : PropertyChangedBase
|
||||
{
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Models.Profile.Colors;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared.Screens.GradientEditor;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Shared.Services
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Artemis.UI.Shared.Services.Interfaces
|
||||
namespace Artemis.UI.Shared.Services
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public interface IArtemisSharedUIService
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Shared.Services.Interfaces
|
||||
namespace Artemis.UI.Shared.Services
|
||||
{
|
||||
public interface IDataBindingUIService : IArtemisSharedUIService
|
||||
{
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.Plugins;
|
||||
using Artemis.Core.Plugins.DataModelExpansions.Attributes;
|
||||
using Artemis.UI.Shared.DataModelVisualization;
|
||||
using Artemis.UI.Shared.DataModelVisualization.Shared;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.DataModelExpansions;
|
||||
|
||||
namespace Artemis.UI.Shared.Services.Interfaces
|
||||
namespace Artemis.UI.Shared.Services
|
||||
{
|
||||
public interface IDataModelUIService : IArtemisSharedUIService
|
||||
{
|
||||
IReadOnlyCollection<DataModelVisualizationRegistration> RegisteredDataModelEditors { get; }
|
||||
IReadOnlyCollection<DataModelVisualizationRegistration> RegisteredDataModelDisplays { get; }
|
||||
DataModelPropertiesViewModel GetMainDataModelVisualization();
|
||||
DataModelPropertiesViewModel GetPluginDataModelVisualization(Plugin plugin);
|
||||
|
||||
@@ -26,7 +26,5 @@ namespace Artemis.UI.Shared.Services.Interfaces
|
||||
|
||||
DataModelDisplayViewModel GetDataModelDisplayViewModel(Type propertyType);
|
||||
DataModelInputViewModel GetDataModelInputViewModel(Type propertyType, DataModelPropertyAttribute description, object initialValue, Action<object, bool> updateCallback);
|
||||
IReadOnlyCollection<DataModelVisualizationRegistration> RegisteredDataModelEditors { get; }
|
||||
IReadOnlyCollection<DataModelVisualizationRegistration> RegisteredDataModelDisplays { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.Shared.Services.Dialog;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Ninject.Parameters;
|
||||
|
||||
namespace Artemis.UI.Shared.Services.Interfaces
|
||||
namespace Artemis.UI.Shared.Services
|
||||
{
|
||||
public interface IDialogService : IArtemisSharedUIService
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Models.Profile.Colors;
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.UI.Shared.Services.Interfaces
|
||||
namespace Artemis.UI.Shared.Services
|
||||
{
|
||||
public interface IGradientPickerService : IArtemisSharedUIService
|
||||
{
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Artemis.Core.Plugins;
|
||||
using Artemis.Core.Plugins.Modules;
|
||||
using Artemis.UI.Shared.Events;
|
||||
using Artemis.UI.Shared.PropertyInput;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Modules;
|
||||
using Ninject;
|
||||
|
||||
namespace Artemis.UI.Shared.Services.Interfaces
|
||||
namespace Artemis.UI.Shared.Services
|
||||
{
|
||||
public interface IProfileEditorService : IArtemisSharedUIService
|
||||
{
|
||||
@@ -50,7 +46,7 @@ namespace Artemis.UI.Shared.Services.Interfaces
|
||||
event EventHandler<RenderProfileElementEventArgs> SelectedProfileElementUpdated;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the currently selected data binding layer property is changed
|
||||
/// Occurs when the currently selected data binding layer property is changed
|
||||
/// </summary>
|
||||
event EventHandler SelectedDataBindingChanged;
|
||||
|
||||
@@ -92,5 +88,5 @@ namespace Artemis.UI.Shared.Services.Interfaces
|
||||
/// <param name="excludedKeyframe">A keyframe to exclude during keyframe snapping</param>
|
||||
/// <returns></returns>
|
||||
TimeSpan SnapToTimeline(TimeSpan time, TimeSpan tolerance, bool snapToSegments, bool snapToCurrentTime, bool snapToKeyframes, BaseLayerPropertyKeyframe excludedKeyframe = null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Artemis.Core.Plugins;
|
||||
using Artemis.Core.Plugins.Exceptions;
|
||||
using Artemis.Core.Plugins.Modules;
|
||||
using Artemis.Core.Services.Storage.Interfaces;
|
||||
using Artemis.UI.Shared.Events;
|
||||
using Artemis.UI.Shared.Exceptions;
|
||||
using Artemis.UI.Shared.PropertyInput;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Modules;
|
||||
using Artemis.Core.Services;
|
||||
using Ninject;
|
||||
using Serilog;
|
||||
using Stylet;
|
||||
@@ -329,14 +322,14 @@ namespace Artemis.UI.Shared.Services
|
||||
ProfilePreviewUpdated?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void SelectedProfileOnDeactivated(object sender, EventArgs e)
|
||||
{
|
||||
Execute.PostToUIThread(() => ChangeSelectedProfile(null));
|
||||
}
|
||||
|
||||
protected virtual void OnSelectedDataBindingChanged()
|
||||
{
|
||||
SelectedDataBindingChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void SelectedProfileOnDeactivated(object sender, EventArgs e)
|
||||
{
|
||||
Execute.PostToUIThread(() => ChangeSelectedProfile(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,18 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using Humanizer;
|
||||
|
||||
namespace Artemis.UI.Shared.Utilities
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides utilities for display enums in a human readable form
|
||||
/// </summary>
|
||||
public static class EnumUtilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a human readable description of the given enum value
|
||||
/// </summary>
|
||||
/// <param name="value">The value to get a description for</param>
|
||||
/// <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);
|
||||
@@ -21,6 +29,11 @@ namespace Artemis.UI.Shared.Utilities
|
||||
return ti.ToTitleCase(ti.ToLower(value.ToString().Replace("_", " ")));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a list containing a <see cref="ValueDescription" /> for each value in the enum type
|
||||
/// </summary>
|
||||
/// <param name="t">The enum type to create value descriptions for</param>
|
||||
/// <returns>A list containing a <see cref="ValueDescription" /> for each value in the enum type</returns>
|
||||
public static IEnumerable<ValueDescription> GetAllValuesAndDescriptions(Type t)
|
||||
{
|
||||
if (!t.IsEnum)
|
||||
@@ -29,6 +42,11 @@ namespace Artemis.UI.Shared.Utilities
|
||||
return Enum.GetValues(t).Cast<Enum>().Select(e => new ValueDescription {Value = e, Description = e.Humanize()}).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Humanizes the given enum value using the Humanizer library
|
||||
/// </summary>
|
||||
/// <param name="value">The enum value to humanize</param>
|
||||
/// <returns>A humanized string describing the given value</returns>
|
||||
public static string HumanizeValue(Enum value)
|
||||
{
|
||||
return value.Humanize();
|
||||
|
||||
@@ -2,12 +2,16 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Artemis.UI.Shared.Utilities
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides utilities for running hit tests on visual elements
|
||||
/// </summary>
|
||||
public static class HitTestUtilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Runs a hit test on children of the container within the rectangle matching all elements that have a data context of T
|
||||
/// Runs a hit test on children of the container within the rectangle matching all elements that have a data context of
|
||||
/// T
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="container"></param>
|
||||
|
||||
@@ -2,13 +2,26 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Artemis.UI.Shared.Utilities
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides utilities for creating desktop shortcuts
|
||||
/// </summary>
|
||||
public class ShortcutUtilities
|
||||
{
|
||||
private static readonly Type m_type = Type.GetTypeFromProgID("WScript.Shell");
|
||||
private static readonly object m_shell = Activator.CreateInstance(m_type);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a shortcut
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file to create the shortcut for</param>
|
||||
/// <param name="targetPath">The path of the file to create the shortcut for</param>
|
||||
/// <param name="arguments">Arguments to pass to the file when running</param>
|
||||
/// <param name="workingDirectory">The working directory of the shortcut</param>
|
||||
/// <param name="description">The description of the shortcut</param>
|
||||
/// <param name="hotkey">The hot key of the shortcut</param>
|
||||
/// <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});
|
||||
|
||||
@@ -20,7 +20,7 @@ using System.Windows.Media.Animation;
|
||||
//
|
||||
// As this works on anything that inherits from TriggerBase, it will also work on <MultiTrigger>.
|
||||
|
||||
namespace Artemis.UI.Shared.Utilities
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
#if DEBUG
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Artemis.UI.Shared.Utilities
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
/// <summary>
|
||||
/// Provides utilities for navigating the visual tree
|
||||
/// </summary>
|
||||
public static class VisualTreeUtilities
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
Reference in new issue
Block a user