mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Profile editor use RGB.NET's pretty update trigger
This commit is contained in:
parent
aa1cd70fd1
commit
44eaa6ac40
@ -68,10 +68,10 @@ namespace Artemis.Plugins.Modules.General
|
||||
public override void Render(double deltaTime, Surface surface, Graphics graphics)
|
||||
{
|
||||
// Per-device coloring, slower
|
||||
// RenderPerDevice(surface, graphics);
|
||||
RenderPerDevice(surface, graphics);
|
||||
|
||||
// Per-LED coloring, slowest
|
||||
RenderPerLed(surface, graphics);
|
||||
// RenderPerLed(surface, graphics);
|
||||
}
|
||||
|
||||
public void RenderFullSurface(Surface surface, Graphics graphics)
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
@ -7,17 +8,22 @@ using System.Windows.Media;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Core.Services.Storage;
|
||||
using Artemis.UI.ViewModels.Screens;
|
||||
using Artemis.UI.ViewModels.Utilities;
|
||||
using RGB.NET.Core;
|
||||
using Stylet;
|
||||
using Point = System.Windows.Point;
|
||||
|
||||
namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
||||
{
|
||||
public class ProfileEditorViewModel : ModuleViewModel
|
||||
{
|
||||
public ProfileEditorViewModel(Module module, ISurfaceService surfaceService, ICoreService coreService) : base(module, "Profile Editor")
|
||||
private TimerUpdateTrigger _updateTrigger;
|
||||
|
||||
public ProfileEditorViewModel(Module module, ISurfaceService surfaceService, ISettingsService settingsService) : base(module, "Profile Editor")
|
||||
{
|
||||
surfaceService.ActiveSurfaceConfigurationChanged += OnActiveSurfaceConfigurationChanged;
|
||||
Devices = new ObservableCollection<ProfileDeviceViewModel>();
|
||||
@ -29,10 +35,12 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
||||
|
||||
ApplySurfaceConfiguration(surfaceService.ActiveSurface);
|
||||
|
||||
_timer = new Timer(1000.0 / 15) {AutoReset = true};
|
||||
_timer.Elapsed += UpdateLeds;
|
||||
// Remove
|
||||
_timer.Start();
|
||||
// Borrow RGB.NET's update trigger, update up to 25 FPS, ignore higher settings than that
|
||||
var targetFps = Math.Min(settingsService.GetSetting("TargetFrameRate", 25).Value, 25);
|
||||
_updateTrigger = new TimerUpdateTrigger {UpdateFrequency = 1.0 / targetFps };
|
||||
_updateTrigger.Update += UpdateLeds;
|
||||
|
||||
_updateTrigger.Start();
|
||||
}
|
||||
|
||||
public ObservableCollection<ProfileDeviceViewModel> Devices { get; set; }
|
||||
@ -44,7 +52,7 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
||||
ApplySurfaceConfiguration(e.Surface);
|
||||
}
|
||||
|
||||
private void UpdateLeds(object sender, ElapsedEventArgs e)
|
||||
private void UpdateLeds(object sender, CustomUpdateData customUpdateData)
|
||||
{
|
||||
foreach (var profileDeviceViewModel in Devices)
|
||||
profileDeviceViewModel.Update();
|
||||
@ -67,13 +75,13 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
_timer.Start();
|
||||
_updateTrigger.Start();
|
||||
base.OnActivate();
|
||||
}
|
||||
|
||||
protected override void OnDeactivate()
|
||||
{
|
||||
_timer.Stop();
|
||||
_updateTrigger.Stop();
|
||||
base.OnDeactivate();
|
||||
}
|
||||
|
||||
@ -81,7 +89,6 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
||||
|
||||
private MouseDragStatus _mouseDragStatus;
|
||||
private Point _mouseDragStartPoint;
|
||||
private Timer _timer;
|
||||
|
||||
// ReSharper disable once UnusedMember.Global - Called from view
|
||||
public void EditorGridMouseClick(object sender, MouseEventArgs e)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<UserControl x:Class="Artemis.UI.Views.Controls.ProfileEditor.ProfileDeviceView"
|
||||
<UserControl x:Class="Artemis.UI.Views.Controls.ProfileEditor.ProfileDeviceView"
|
||||
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"
|
||||
@ -15,7 +15,7 @@
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<!-- Device image with fallback -->
|
||||
<Image Source="{Binding Device.RgbDevice.DeviceInfo.Image, Converter={StaticResource NullToImageConverter}}" />
|
||||
<Image Source="{Binding Device.RgbDevice.DeviceInfo.Image, Converter={StaticResource NullToImageConverter}}"/>
|
||||
|
||||
<Rectangle Fill="{DynamicResource ControlBackgroundBrush}"
|
||||
Stroke="{DynamicResource ControlBorderBrush}"
|
||||
|
||||
@ -12,10 +12,10 @@
|
||||
<UserControl.Resources>
|
||||
<Converters:NullToImageConverter x:Key="NullToImageConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid Width="{Binding Width}" Height="{Binding Height}" ClipToBounds="False">
|
||||
<Grid.Background>
|
||||
<Canvas Width="{Binding Width}" Height="{Binding Height}">
|
||||
<Canvas.Background>
|
||||
<ImageBrush AlignmentX="Center" AlignmentY="Center" Stretch="Fill" ImageSource="{Binding Led.Image, Converter={StaticResource NullToImageConverter}}" />
|
||||
</Grid.Background>
|
||||
</Canvas.Background>
|
||||
|
||||
<Path Data="{Binding DisplayGeometry}" ClipToBounds="False">
|
||||
<Path.Fill>
|
||||
@ -27,6 +27,5 @@
|
||||
<SolidColorBrush Color="{Binding DisplayColor}" />
|
||||
</Path.Fill>
|
||||
</Path>
|
||||
|
||||
</Grid>
|
||||
</Canvas>
|
||||
</UserControl>
|
||||
@ -28,9 +28,7 @@
|
||||
Background="Transparent"
|
||||
RenderOptions.BitmapScalingMode="HighQuality"
|
||||
Margin="0,0,-10,0">
|
||||
<Image Source="{StaticResource BowIcon}"
|
||||
Stretch="Uniform"
|
||||
Margin="6" />
|
||||
<Image Source="{StaticResource BowIcon}" Stretch="Uniform" Margin="6" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</metro:MetroWindow.IconTemplate>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user