From 5106195450383fd9aab4490e6c7adbad7a47ba94 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Sat, 24 Aug 2019 23:24:13 +0200 Subject: [PATCH] Surface rearranging WIP --- src/Artemis.UI/App.xaml | 5 - src/Artemis.UI/Artemis.UI.csproj | 27 +-- .../Controls/Visualizers/LedVisualizer.cs | 47 ----- .../Visualizers/RGBDeviceVisualizer.cs | 78 -------- .../Visualizers/RGBSurfaceVisualizer.cs | 170 ------------------ .../Properties/Resources.Designer.cs | 10 ++ src/Artemis.UI/Properties/Resources.resx | 3 + src/Artemis.UI/Resources/tile.png | Bin 0 -> 165 bytes .../Styles/Visualizers/LedVisualizer.xaml | 98 ---------- .../Visualizers/RGBDeviceVisualizer.xaml | 43 ----- .../Visualizers/RGBSurfaceVisualizer.xaml | 46 ----- .../Controls/Editor/SurfaceEditorViewModel.cs | 47 ----- .../Controls/RgbDevice/RgbDeviceViewModel.cs | 26 ++- .../Controls/RgbDevice/RgbLedViewModel.cs | 11 +- .../ViewModels/Interfaces/IEditorViewModel.cs | 2 +- .../ViewModels/Screens/EditorViewModel.cs | 18 -- .../ViewModels/Screens/RootViewModel.cs | 4 +- .../Screens/SurfaceEditorViewModel.cs | 126 +++++++++++++ .../Controls/Editor/SurfaceEditorView.xaml | 33 ---- .../Controls/RgbDevice/RgbDeviceView.xaml | 49 ++++- .../Views/Controls/RgbDevice/RgbLedView.xaml | 8 +- src/Artemis.UI/Views/Screens/EditorView.xaml | 23 --- src/Artemis.UI/Views/Screens/RootView.xaml | 4 +- .../Views/Screens/SurfaceEditorView.xaml | 78 ++++++++ 24 files changed, 308 insertions(+), 648 deletions(-) delete mode 100644 src/Artemis.UI/Controls/Visualizers/LedVisualizer.cs delete mode 100644 src/Artemis.UI/Controls/Visualizers/RGBDeviceVisualizer.cs delete mode 100644 src/Artemis.UI/Controls/Visualizers/RGBSurfaceVisualizer.cs create mode 100644 src/Artemis.UI/Resources/tile.png delete mode 100644 src/Artemis.UI/Styles/Visualizers/LedVisualizer.xaml delete mode 100644 src/Artemis.UI/Styles/Visualizers/RGBDeviceVisualizer.xaml delete mode 100644 src/Artemis.UI/Styles/Visualizers/RGBSurfaceVisualizer.xaml delete mode 100644 src/Artemis.UI/ViewModels/Controls/Editor/SurfaceEditorViewModel.cs delete mode 100644 src/Artemis.UI/ViewModels/Screens/EditorViewModel.cs create mode 100644 src/Artemis.UI/ViewModels/Screens/SurfaceEditorViewModel.cs delete mode 100644 src/Artemis.UI/Views/Controls/Editor/SurfaceEditorView.xaml delete mode 100644 src/Artemis.UI/Views/Screens/EditorView.xaml create mode 100644 src/Artemis.UI/Views/Screens/SurfaceEditorView.xaml diff --git a/src/Artemis.UI/App.xaml b/src/Artemis.UI/App.xaml index 5b27fb1c2..062eb31e9 100644 --- a/src/Artemis.UI/App.xaml +++ b/src/Artemis.UI/App.xaml @@ -29,11 +29,6 @@ Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Teal.xaml" /> - - - - - diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj index b97b8fa26..f4e825062 100644 --- a/src/Artemis.UI/Artemis.UI.csproj +++ b/src/Artemis.UI/Artemis.UI.csproj @@ -147,9 +147,6 @@ - - - @@ -157,7 +154,7 @@ - + @@ -172,19 +169,6 @@ Code - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - Designer MSBuild:Compile @@ -201,7 +185,7 @@ Designer MSBuild:Compile - + MSBuild:Compile Designer @@ -213,10 +197,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - @@ -260,8 +240,7 @@ - - + diff --git a/src/Artemis.UI/Controls/Visualizers/LedVisualizer.cs b/src/Artemis.UI/Controls/Visualizers/LedVisualizer.cs deleted file mode 100644 index d875e61c8..000000000 --- a/src/Artemis.UI/Controls/Visualizers/LedVisualizer.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; -using RGB.NET.Core; - -namespace Artemis.UI.Controls.Visualizers -{ - /// - /// - /// Visualizes a in an wpf-application. - /// - public class LedVisualizer : Control - { - public void Select() - { - BorderBrush = new SolidColorBrush(Colors.RoyalBlue); - } - - public void Deselect() - { - BorderBrush = new SolidColorBrush(Colors.Black); - } - - #region DependencyProperties - - // ReSharper disable InconsistentNaming - - /// - /// Backing-property for the -property. - /// - public static readonly DependencyProperty LedProperty = DependencyProperty.Register( - "Led", typeof(Led), typeof(LedVisualizer), new PropertyMetadata(default(Led))); - - /// - /// Gets or sets the to visualize. - /// - public Led Led - { - get => (Led) GetValue(LedProperty); - set => SetValue(LedProperty, value); - } - - // ReSharper restore InconsistentNaming - - #endregion - } -} \ No newline at end of file diff --git a/src/Artemis.UI/Controls/Visualizers/RGBDeviceVisualizer.cs b/src/Artemis.UI/Controls/Visualizers/RGBDeviceVisualizer.cs deleted file mode 100644 index 111d59a76..000000000 --- a/src/Artemis.UI/Controls/Visualizers/RGBDeviceVisualizer.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System.Windows; -using System.Windows.Controls; -using RGB.NET.Core; - -namespace Artemis.UI.Controls.Visualizers -{ - /// - /// - /// Visualizes a in an wpf-application. - /// - [TemplatePart(Name = PART_CANVAS, Type = typeof(Canvas))] - public class RGBDeviceVisualizer : Control - { - #region Constants - - private const string PART_CANVAS = "PART_Canvas"; - - #endregion - - #region Properties & Fields - - public Canvas Canvas { get; private set; } - - #endregion - - #region DependencyProperties - - // ReSharper disable InconsistentNaming - - /// - /// Backing-property for the -property. - /// - public static readonly DependencyProperty DeviceProperty = DependencyProperty.Register( - "Device", typeof(IRGBDevice), typeof(RGBDeviceVisualizer), new PropertyMetadata(default(IRGBDevice), DeviceChanged)); - - /// - /// Gets or sets the to visualize. - /// - public IRGBDevice Device - { - get => (IRGBDevice) GetValue(DeviceProperty); - set => SetValue(DeviceProperty, value); - } - - // ReSharper restore InconsistentNaming - - #endregion - - #region Methods - - /// - public override void OnApplyTemplate() - { - Canvas = (Canvas) GetTemplateChild(PART_CANVAS); - - LayoutLeds(); - } - - private static void DeviceChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) - { - ((RGBDeviceVisualizer) dependencyObject).LayoutLeds(); - } - - private void LayoutLeds() - { - if (Canvas == null) return; - - Canvas.Children.Clear(); - - if (Device == null) return; - - foreach (var led in Device) - Canvas.Children.Add(new LedVisualizer {Led = led}); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Artemis.UI/Controls/Visualizers/RGBSurfaceVisualizer.cs b/src/Artemis.UI/Controls/Visualizers/RGBSurfaceVisualizer.cs deleted file mode 100644 index d05fd77c1..000000000 --- a/src/Artemis.UI/Controls/Visualizers/RGBSurfaceVisualizer.cs +++ /dev/null @@ -1,170 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using Artemis.UI.Adorners; -using RGB.NET.Core; -using RGB.NET.Groups; -using Point = System.Windows.Point; - -namespace Artemis.UI.Controls.Visualizers -{ - /// - /// - /// Visualizes the in an wpf-application. - /// - [TemplatePart(Name = PART_CANVAS, Type = typeof(Canvas))] - public class RGBSurfaceVisualizer : Control - { - #region Constants - - private const string PART_CANVAS = "PART_Canvas"; - - #endregion - - #region Properties & Fields - - private RGBSurface _surface; - private Canvas _canvas; - private BoundingBoxAdorner _boundingBox; - private Point _startingPoint; - - //TODO DarthAffe 17.06.2017: This is ugly - redesign how device connect/disconnect is generally handled! - private readonly List _newDevices = new List(); - - #endregion - - #region Constructors - - /// - /// - /// Initializes a new instance of the class. - /// - public RGBSurfaceVisualizer() - { - Loaded += OnLoaded; - Unloaded += OnUnloaded; - } - - private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) - { - _surface = RGBSurface.Instance; - - _surface.SurfaceLayoutChanged += RGBSurfaceOnSurfaceLayoutChanged; - foreach (var device in _surface.Devices) - _newDevices.Add(device); - - UpdateSurface(); - } - - private void OnUnloaded(object sender, RoutedEventArgs routedEventArgs) - { - _surface.SurfaceLayoutChanged -= RGBSurfaceOnSurfaceLayoutChanged; - _canvas?.Children.Clear(); - _newDevices.Clear(); - } - - private void RGBSurfaceOnSurfaceLayoutChanged(SurfaceLayoutChangedEventArgs args) - { - if (args.DeviceAdded) - foreach (var device in args.Devices) - _newDevices.Add(device); - - UpdateSurface(); - } - - #endregion - - #region Methods - - /// - public override void OnApplyTemplate() - { - // Detach any existing event handlers - if (_canvas != null) - { - _canvas.MouseLeftButtonDown -= ScrollViewerOnMouseLeftButtonDown; - _canvas.MouseLeftButtonUp -= ScrollViewerOnMouseLeftButtonUp; - } - - _canvas?.Children.Clear(); - _canvas = (Canvas) GetTemplateChild(PART_CANVAS); - - UpdateSurface(); - - if (_canvas == null) return; - _canvas.MouseLeftButtonDown += ScrollViewerOnMouseLeftButtonDown; - _canvas.MouseLeftButtonUp += ScrollViewerOnMouseLeftButtonUp; - _canvas.MouseMove += ScrollViewerOnMouseMove; - } - - - private void ScrollViewerOnMouseLeftButtonDown(object sender, MouseButtonEventArgs mouseButtonEventArgs) - { - _canvas.CaptureMouse(); - _startingPoint = mouseButtonEventArgs.GetPosition(_canvas); - _boundingBox = new BoundingBoxAdorner(_canvas, Colors.RoyalBlue); - - var adornerLayer = AdornerLayer.GetAdornerLayer(_canvas); - adornerLayer.Add(_boundingBox); - } - - private void ScrollViewerOnMouseLeftButtonUp(object sender, MouseButtonEventArgs mouseButtonEventArgs) - { - _canvas.ReleaseMouseCapture(); - var adornerLayer = AdornerLayer.GetAdornerLayer(_canvas); - var adorners = adornerLayer.GetAdorners(_canvas); - if (adorners == null) return; - foreach (var adorner in adorners) - adornerLayer.Remove(adorner); - - _boundingBox = null; - } - - private void ScrollViewerOnMouseMove(object sender, MouseEventArgs mouseEventArgs) - { - if (_boundingBox == null) return; - var currentPoint = mouseEventArgs.GetPosition(_canvas); - _boundingBox.Update(_startingPoint, currentPoint); - - var ledStart = new RGB.NET.Core.Point(_startingPoint.X, _startingPoint.Y); - var ledEnd = new RGB.NET.Core.Point(currentPoint.X, currentPoint.Y); - var selection = new RectangleLedGroup(ledStart, ledEnd, 0.1); - - // Deselect all LED of each device - var deviceLeds = new List(); - foreach (var rgbDeviceVisualizer in _canvas.Children.Cast()) - deviceLeds.AddRange(rgbDeviceVisualizer.Canvas.Children.Cast()); - - foreach (var ledVisualizer in deviceLeds) - ledVisualizer?.Deselect(); - - // Select all LEDs in the bounding box - foreach (var led in selection.GetLeds()) - { - var ledVisualizer = deviceLeds.FirstOrDefault(l => l.Led == led); - ledVisualizer?.Select(); - } - } - - private void UpdateSurface() - { - if (_canvas == null || _surface == null) return; - - if (_newDevices.Count > 0) - { - foreach (var device in _newDevices) - _canvas.Children.Add(new RGBDeviceVisualizer {Device = device}); - _newDevices.Clear(); - } - - _canvas.Width = _surface.SurfaceRectangle.Size.Width; - _canvas.Height = _surface.SurfaceRectangle.Size.Height; - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Artemis.UI/Properties/Resources.Designer.cs b/src/Artemis.UI/Properties/Resources.Designer.cs index 7f76887ff..30752e0a5 100644 --- a/src/Artemis.UI/Properties/Resources.Designer.cs +++ b/src/Artemis.UI/Properties/Resources.Designer.cs @@ -79,5 +79,15 @@ namespace Artemis.UI.Properties { return ((System.Drawing.Bitmap)(obj)); } } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap tile { + get { + object obj = ResourceManager.GetObject("tile", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/src/Artemis.UI/Properties/Resources.resx b/src/Artemis.UI/Properties/Resources.resx index 3024e066c..eac736e2b 100644 --- a/src/Artemis.UI/Properties/Resources.resx +++ b/src/Artemis.UI/Properties/Resources.resx @@ -124,4 +124,7 @@ ..\Resources\logo-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\tile.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/src/Artemis.UI/Resources/tile.png b/src/Artemis.UI/Resources/tile.png new file mode 100644 index 0000000000000000000000000000000000000000..b793d790609afed082c831013b3aa837b2931278 GIT binary patch literal 165 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}c0*}aI1_r*vAk26?e?0$zm)^{;`U$jxfx*+&&t;uc GLK6TQpfafd literal 0 HcmV?d00001 diff --git a/src/Artemis.UI/Styles/Visualizers/LedVisualizer.xaml b/src/Artemis.UI/Styles/Visualizers/LedVisualizer.xaml deleted file mode 100644 index 9bfb6bd80..000000000 --- a/src/Artemis.UI/Styles/Visualizers/LedVisualizer.xaml +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Artemis.UI/Views/Controls/RgbDevice/RgbDeviceView.xaml b/src/Artemis.UI/Views/Controls/RgbDevice/RgbDeviceView.xaml index a2377915c..5c98fa8ef 100644 --- a/src/Artemis.UI/Views/Controls/RgbDevice/RgbDeviceView.xaml +++ b/src/Artemis.UI/Views/Controls/RgbDevice/RgbDeviceView.xaml @@ -7,9 +7,11 @@ xmlns:xaml="https://github.com/canton7/Stylet" mc:Ignorable="d" d:DataContext="{d:DesignInstance rgbDevice:RgbDeviceViewModel}" - d:DesignHeight="450" d:DesignWidth="800"> + d:DesignHeight="450" d:DesignWidth="800" + Cursor="{Binding Cursor}"> + - + @@ -24,9 +26,50 @@ - + + + + + + + \ No newline at end of file diff --git a/src/Artemis.UI/Views/Controls/RgbDevice/RgbLedView.xaml b/src/Artemis.UI/Views/Controls/RgbDevice/RgbLedView.xaml index 25aa13f82..e1b3cb6c1 100644 --- a/src/Artemis.UI/Views/Controls/RgbDevice/RgbLedView.xaml +++ b/src/Artemis.UI/Views/Controls/RgbDevice/RgbLedView.xaml @@ -6,18 +6,20 @@ xmlns:rgbDevice="clr-namespace:Artemis.UI.ViewModels.Controls.RgbDevice" mc:Ignorable="d" d:DataContext="{d:DesignInstance rgbDevice:RgbLedViewModel}" - d:DesignHeight="450" d:DesignWidth="800"> + d:DesignHeight="25" d:DesignWidth="25" + ToolTip="{Binding Tooltip}" + ToolTipService.IsEnabled="{Binding ColorsEnabled}"> - + - + diff --git a/src/Artemis.UI/Views/Screens/EditorView.xaml b/src/Artemis.UI/Views/Screens/EditorView.xaml deleted file mode 100644 index 929b215b4..000000000 --- a/src/Artemis.UI/Views/Screens/EditorView.xaml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - In the editor you can either edit your surface layout or edit a profile. - - - \ No newline at end of file diff --git a/src/Artemis.UI/Views/Screens/RootView.xaml b/src/Artemis.UI/Views/Screens/RootView.xaml index c78ba1e17..34f6973c6 100644 --- a/src/Artemis.UI/Views/Screens/RootView.xaml +++ b/src/Artemis.UI/Views/Screens/RootView.xaml @@ -104,11 +104,11 @@ Workshop - + - Editor + Surface Editor diff --git a/src/Artemis.UI/Views/Screens/SurfaceEditorView.xaml b/src/Artemis.UI/Views/Screens/SurfaceEditorView.xaml new file mode 100644 index 000000000..11dd5da70 --- /dev/null +++ b/src/Artemis.UI/Views/Screens/SurfaceEditorView.xaml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + The surface is a digital representation of your LED setup. Set this up accurately and effects will seamlessly move from one device to the other. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file