mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 09:43:46 +00:00
Fixed LED borders, need to focus on perf now
This commit is contained in:
parent
79a77794a5
commit
ee5c5c1d74
@ -1,5 +1,6 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Timers;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
@ -19,7 +20,6 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
|||||||
public ProfileEditorViewModel(Module module, ISurfaceService surfaceService, ICoreService coreService) : base(module, "Profile Editor")
|
public ProfileEditorViewModel(Module module, ISurfaceService surfaceService, ICoreService coreService) : base(module, "Profile Editor")
|
||||||
{
|
{
|
||||||
surfaceService.ActiveSurfaceConfigurationChanged += OnActiveSurfaceConfigurationChanged;
|
surfaceService.ActiveSurfaceConfigurationChanged += OnActiveSurfaceConfigurationChanged;
|
||||||
coreService.FrameRendered += CoreServiceOnFrameRendered;
|
|
||||||
Devices = new ObservableCollection<ProfileDeviceViewModel>();
|
Devices = new ObservableCollection<ProfileDeviceViewModel>();
|
||||||
Execute.OnUIThread(() =>
|
Execute.OnUIThread(() =>
|
||||||
{
|
{
|
||||||
@ -28,8 +28,11 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
|||||||
});
|
});
|
||||||
|
|
||||||
ApplySurfaceConfiguration(surfaceService.ActiveSurface);
|
ApplySurfaceConfiguration(surfaceService.ActiveSurface);
|
||||||
|
|
||||||
|
_timer = new Timer(1000.0 / 15) {AutoReset = true};
|
||||||
|
_timer.Elapsed += UpdateLeds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableCollection<ProfileDeviceViewModel> Devices { get; set; }
|
public ObservableCollection<ProfileDeviceViewModel> Devices { get; set; }
|
||||||
public RectangleGeometry SelectionRectangle { get; set; }
|
public RectangleGeometry SelectionRectangle { get; set; }
|
||||||
public PanZoomViewModel PanZoomViewModel { get; set; }
|
public PanZoomViewModel PanZoomViewModel { get; set; }
|
||||||
@ -39,7 +42,7 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
|||||||
ApplySurfaceConfiguration(e.Surface);
|
ApplySurfaceConfiguration(e.Surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CoreServiceOnFrameRendered(object sender, FrameRenderedEventArgs e)
|
private void UpdateLeds(object sender, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
foreach (var profileDeviceViewModel in Devices)
|
foreach (var profileDeviceViewModel in Devices)
|
||||||
profileDeviceViewModel.Update();
|
profileDeviceViewModel.Update();
|
||||||
@ -60,10 +63,23 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnActivate()
|
||||||
|
{
|
||||||
|
_timer.Start();
|
||||||
|
base.OnActivate();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDeactivate()
|
||||||
|
{
|
||||||
|
_timer.Stop();
|
||||||
|
base.OnDeactivate();
|
||||||
|
}
|
||||||
|
|
||||||
#region Selection
|
#region Selection
|
||||||
|
|
||||||
private MouseDragStatus _mouseDragStatus;
|
private MouseDragStatus _mouseDragStatus;
|
||||||
private Point _mouseDragStartPoint;
|
private Point _mouseDragStartPoint;
|
||||||
|
private Timer _timer;
|
||||||
|
|
||||||
// ReSharper disable once UnusedMember.Global - Called from view
|
// ReSharper disable once UnusedMember.Global - Called from view
|
||||||
public void EditorGridMouseClick(object sender, MouseEventArgs e)
|
public void EditorGridMouseClick(object sender, MouseEventArgs e)
|
||||||
|
|||||||
@ -4,7 +4,6 @@ using System.Windows.Media;
|
|||||||
using Artemis.UI.Extensions;
|
using Artemis.UI.Extensions;
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
using Color = System.Windows.Media.Color;
|
|
||||||
|
|
||||||
namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
||||||
{
|
{
|
||||||
@ -14,8 +13,12 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
|||||||
{
|
{
|
||||||
Led = led;
|
Led = led;
|
||||||
|
|
||||||
Execute.OnUIThread(CreateLedGeometry);
|
Execute.OnUIThread(() =>
|
||||||
Update();
|
{
|
||||||
|
CreateLedGeometry();
|
||||||
|
FillBrush = new SolidColorBrush { Opacity = 0.25 };
|
||||||
|
BorderBrush = new SolidColorBrush();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Led Led { get; }
|
public Led Led { get; }
|
||||||
@ -26,9 +29,9 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
|||||||
public double Height { get; private set; }
|
public double Height { get; private set; }
|
||||||
|
|
||||||
public Geometry DisplayGeometry { get; private set; }
|
public Geometry DisplayGeometry { get; private set; }
|
||||||
public Geometry StrokeGeometry { get; private set; }
|
public SolidColorBrush FillBrush { get; set; }
|
||||||
public Color DisplayColor { get; private set; }
|
public SolidColorBrush BorderBrush { get; set; }
|
||||||
public bool ColorsEnabled { get; set; } = true;
|
|
||||||
|
|
||||||
public string Tooltip => $"{Led.Id} - {Led.LedRectangle}";
|
public string Tooltip => $"{Led.Id} - {Led.LedRectangle}";
|
||||||
|
|
||||||
@ -66,35 +69,19 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
|||||||
GeometryCombineMode.Union,
|
GeometryCombineMode.Union,
|
||||||
new ScaleTransform(Led.LedRectangle.Width, Led.LedRectangle.Height)
|
new ScaleTransform(Led.LedRectangle.Width, Led.LedRectangle.Height)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create a smaller version of the display geometry
|
|
||||||
var innerGeometry = Geometry.Combine(
|
|
||||||
Geometry.Empty,
|
|
||||||
geometry,
|
|
||||||
GeometryCombineMode.Union,
|
|
||||||
new TransformGroup
|
|
||||||
{
|
|
||||||
Children = new TransformCollection
|
|
||||||
{
|
|
||||||
new ScaleTransform(Led.LedRectangle.Width - 2, Led.LedRectangle.Height - 2),
|
|
||||||
new TranslateTransform(1, 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
// Stroke geometry is the display geometry excluding the inner geometry
|
|
||||||
StrokeGeometry = Geometry.Combine(
|
|
||||||
DisplayGeometry,
|
|
||||||
innerGeometry,
|
|
||||||
GeometryCombineMode.Exclude,
|
|
||||||
null
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
var newColor = Led.Color.ToMediaColor();
|
var newColor = Led.Color.ToMediaColor();
|
||||||
if (!DisplayColor.Equals(newColor))
|
Execute.OnUIThread(() =>
|
||||||
DisplayColor = newColor;
|
{
|
||||||
|
if (!FillBrush.Color.Equals(newColor))
|
||||||
|
{
|
||||||
|
FillBrush.Color = newColor;
|
||||||
|
BorderBrush.Color = newColor;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (Math.Abs(Led.LedRectangle.X - X) > 0.1)
|
if (Math.Abs(Led.LedRectangle.X - X) > 0.1)
|
||||||
X = Led.LedRectangle.X;
|
X = Led.LedRectangle.X;
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
using Artemis.Core.Plugins.Abstract;
|
using Artemis.Core.Plugins.Abstract;
|
||||||
using Artemis.UI.Ninject.Factories;
|
using Artemis.UI.Ninject.Factories;
|
||||||
using Artemis.UI.ViewModels.Controls.ProfileEditor;
|
|
||||||
using Stylet;
|
using Stylet;
|
||||||
|
|
||||||
namespace Artemis.UI.ViewModels.Screens
|
namespace Artemis.UI.ViewModels.Screens
|
||||||
|
|||||||
@ -1,15 +1,14 @@
|
|||||||
<UserControl
|
<UserControl
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:profileEditor="clr-namespace:Artemis.UI.ViewModels.Controls.ProfileEditor"
|
xmlns:profileEditor="clr-namespace:Artemis.UI.ViewModels.Controls.ProfileEditor"
|
||||||
xmlns:Converters="clr-namespace:Artemis.UI.Converters" x:Class="Artemis.UI.Views.Controls.ProfileEditor.ProfileLedView"
|
xmlns:Converters="clr-namespace:Artemis.UI.Converters" x:Class="Artemis.UI.Views.Controls.ProfileEditor.ProfileLedView"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DataContext="{d:DesignInstance {x:Type profileEditor:ProfileLedViewModel}}"
|
d:DataContext="{d:DesignInstance {x:Type profileEditor:ProfileLedViewModel}}"
|
||||||
d:DesignHeight="25" d:DesignWidth="25"
|
d:DesignHeight="25" d:DesignWidth="25"
|
||||||
ToolTip="{Binding Tooltip}"
|
ToolTip="{Binding Tooltip}">
|
||||||
ToolTipService.IsEnabled="{Binding ColorsEnabled}">
|
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<Converters:NullToImageConverter x:Key="NullToImageConverter"/>
|
<Converters:NullToImageConverter x:Key="NullToImageConverter"/>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
@ -18,15 +17,12 @@
|
|||||||
<ImageBrush AlignmentX="Center" AlignmentY="Center" Stretch="Fill" ImageSource="{Binding Led.Image, Converter={StaticResource NullToImageConverter}}" />
|
<ImageBrush AlignmentX="Center" AlignmentY="Center" Stretch="Fill" ImageSource="{Binding Led.Image, Converter={StaticResource NullToImageConverter}}" />
|
||||||
</Grid.Background>
|
</Grid.Background>
|
||||||
|
|
||||||
<Path Data="{Binding DisplayGeometry}" ClipToBounds="False" Visibility="{Binding ColorsEnabled, Converter={StaticResource BoolToVisibilityConverter}}">
|
<Path Data="{Binding DisplayGeometry}"
|
||||||
<Path.Fill>
|
Clip="{Binding Data, RelativeSource={RelativeSource Self}}"
|
||||||
<SolidColorBrush Color="{Binding DisplayColor}" Opacity="0.25" />
|
ClipToBounds="False"
|
||||||
</Path.Fill>
|
Fill="{Binding FillBrush}"
|
||||||
</Path>
|
Stroke="{Binding BorderBrush}"
|
||||||
<Path Data="{Binding StrokeGeometry}" ClipToBounds="False" Visibility="{Binding ColorsEnabled, Converter={StaticResource BoolToVisibilityConverter}}">
|
StrokeThickness="2">
|
||||||
<Path.Fill>
|
|
||||||
<SolidColorBrush Color="{Binding DisplayColor}" />
|
|
||||||
</Path.Fill>
|
|
||||||
</Path>
|
</Path>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
Loading…
x
Reference in New Issue
Block a user