mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-02 10:43:31 +00:00
Added core usage to WindowsProfileDataModel
This commit is contained in:
parent
cc4439126e
commit
be70786319
@ -51,9 +51,9 @@ namespace Artemis.Models
|
||||
// Render the keyboard layer-by-layer
|
||||
keyboard = Profile.GenerateBitmap(renderLayers, DataModel, MainManager.DeviceManager.ActiveKeyboard.KeyboardRectangle(4), false, true);
|
||||
// Render the first enabled mouse (will default to null if renderMice was false)
|
||||
mouse = Profile.GenerateBrush(renderLayers.FirstOrDefault(l => l.LayerType == LayerType.Mouse), DataModel);
|
||||
mouse = Profile.GenerateBrush(renderLayers.LastOrDefault(l => l.LayerType == LayerType.Mouse), DataModel);
|
||||
// Render the first enabled headset (will default to null if renderHeadsets was false)
|
||||
headset = Profile.GenerateBrush(renderLayers.FirstOrDefault(l => l.LayerType == LayerType.Headset), DataModel);
|
||||
headset = Profile.GenerateBrush(renderLayers.LastOrDefault(l => l.LayerType == LayerType.Headset), DataModel);
|
||||
}
|
||||
|
||||
public abstract List<LayerModel> GetRenderLayers(bool renderMice, bool renderHeadsets);
|
||||
|
||||
@ -22,7 +22,6 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
|
||||
</Grid.RowDefinitions>
|
||||
@ -80,38 +79,28 @@
|
||||
Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes"
|
||||
OffLabel="No" Margin="0,0,-5,0" Width="114" />
|
||||
|
||||
<!-- Bars amount -->
|
||||
<TextBlock Grid.Row="5" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Height="16" Margin="0,8">
|
||||
Bars amount (less bars means thicker bars)
|
||||
</TextBlock>
|
||||
<Slider x:Name="Bars" Grid.Row="5" Grid.Column="1" VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right" Width="110" TickPlacement="BottomRight" TickFrequency="1"
|
||||
Value="{Binding Path=EffectSettings.Bars, Mode=TwoWay}" Minimum="2" Maximum="21"
|
||||
SmallChange="1" IsSnapToTickEnabled="True" />
|
||||
|
||||
<!-- Sensitivity -->
|
||||
<TextBlock Grid.Row="6" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
<TextBlock Grid.Row="5" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Height="16" Margin="0,8">
|
||||
Volume sensitivity multiplier
|
||||
</TextBlock>
|
||||
<Slider x:Name="Sensitivity" Grid.Row="6" Grid.Column="1" VerticalAlignment="Center"
|
||||
<Slider x:Name="Sensitivity" Grid.Row="5" Grid.Column="1" VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right" Width="110" TickPlacement="BottomRight" TickFrequency="1"
|
||||
Value="{Binding Path=EffectSettings.Sensitivity, Mode=TwoWay}" Minimum="1" Maximum="10"
|
||||
SmallChange="1" IsSnapToTickEnabled="True" />
|
||||
|
||||
<!-- Fade speed -->
|
||||
<TextBlock Grid.Row="7" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
<TextBlock Grid.Row="6" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Height="16" Margin="0,8">
|
||||
Bar fade-out speed
|
||||
</TextBlock>
|
||||
<Slider x:Name="FadeSpeed" Grid.Row="7" Grid.Column="1" VerticalAlignment="Center"
|
||||
<Slider x:Name="FadeSpeed" Grid.Row="6" Grid.Column="1" VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right" Width="110" TickPlacement="BottomRight" TickFrequency="1"
|
||||
Value="{Binding Path=EffectSettings.FadeSpeed, Mode=TwoWay}" Minimum="1" Maximum="3"
|
||||
SmallChange="1" IsSnapToTickEnabled="True" />
|
||||
|
||||
<!-- Buttons -->
|
||||
<StackPanel Grid.Column="0" Grid.Row="8" Orientation="Horizontal" VerticalAlignment="Bottom">
|
||||
<StackPanel Grid.Column="0" Grid.Row="7" Orientation="Horizontal" VerticalAlignment="Bottom">
|
||||
<Button x:Name="ResetSettings" Content="Reset effect" VerticalAlignment="Top" Width="100"
|
||||
Style="{DynamicResource SquareButtonStyle}" />
|
||||
<Button x:Name="SaveSettings" Content="Save changes" VerticalAlignment="Top" Width="100"
|
||||
|
||||
@ -4,5 +4,23 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
||||
{
|
||||
public class WindowsProfileDataModel : IDataModel
|
||||
{
|
||||
public CpuDataModel Cpu { get; set; }
|
||||
|
||||
public WindowsProfileDataModel()
|
||||
{
|
||||
Cpu = new CpuDataModel();
|
||||
}
|
||||
}
|
||||
|
||||
public class CpuDataModel
|
||||
{
|
||||
public int Core1Usage { get; set; }
|
||||
public int Core2Usage { get; set; }
|
||||
public int Core3Usage { get; set; }
|
||||
public int Core4Usage { get; set; }
|
||||
public int Core5Usage { get; set; }
|
||||
public int Core6Usage { get; set; }
|
||||
public int Core7Usage { get; set; }
|
||||
public int Core8Usage { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Models;
|
||||
using Artemis.Models.Profiles;
|
||||
@ -7,6 +9,9 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
||||
{
|
||||
public class WindowsProfileModel : EffectModel
|
||||
{
|
||||
private List<PerformanceCounter> _cores;
|
||||
private int _cpuFrames;
|
||||
|
||||
public WindowsProfileModel(MainManager mainManager, WindowsProfileSettings settings)
|
||||
: base(mainManager, new WindowsProfileDataModel())
|
||||
{
|
||||
@ -23,16 +28,68 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
// Setup CPU cores
|
||||
_cores = GetPerformanceCounters();
|
||||
var coreCount = _cores.Count;
|
||||
while (coreCount < 8)
|
||||
{
|
||||
_cores.Add(null);
|
||||
coreCount++;
|
||||
}
|
||||
|
||||
Initialized = true;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
UpdateCpu();
|
||||
}
|
||||
|
||||
private void UpdateCpu()
|
||||
{
|
||||
// CPU is only updated every 15 frames, the performance counter gives 0 if updated too often
|
||||
_cpuFrames++;
|
||||
if (_cpuFrames < 16)
|
||||
return;
|
||||
|
||||
_cpuFrames = 0;
|
||||
|
||||
var dataModel = (WindowsProfileDataModel)DataModel;
|
||||
|
||||
// Update cores, not ideal but data models don't support lists.
|
||||
if (_cores[0] != null)
|
||||
dataModel.Cpu.Core1Usage = (int)_cores[0].NextValue();
|
||||
if (_cores[1] != null)
|
||||
dataModel.Cpu.Core2Usage = (int)_cores[1].NextValue();
|
||||
if (_cores[2] != null)
|
||||
dataModel.Cpu.Core3Usage = (int)_cores[2].NextValue();
|
||||
if (_cores[3] != null)
|
||||
dataModel.Cpu.Core4Usage = (int)_cores[3].NextValue();
|
||||
if (_cores[4] != null)
|
||||
dataModel.Cpu.Core5Usage = (int)_cores[4].NextValue();
|
||||
if (_cores[5] != null)
|
||||
dataModel.Cpu.Core6Usage = (int)_cores[5].NextValue();
|
||||
if (_cores[6] != null)
|
||||
dataModel.Cpu.Core7Usage = (int)_cores[6].NextValue();
|
||||
if (_cores[7] != null)
|
||||
dataModel.Cpu.Core8Usage = (int)_cores[7].NextValue();
|
||||
}
|
||||
|
||||
public override List<LayerModel> GetRenderLayers(bool renderMice, bool renderHeadsets)
|
||||
{
|
||||
return Profile.GetRenderLayers<WindowsProfileDataModel>(DataModel, renderMice, renderHeadsets, true);
|
||||
}
|
||||
|
||||
public static List<PerformanceCounter> GetPerformanceCounters()
|
||||
{
|
||||
var performanceCounters = new List<PerformanceCounter>();
|
||||
var procCount = Environment.ProcessorCount;
|
||||
for (var i = 0; i < procCount; i++)
|
||||
{
|
||||
var pc = new PerformanceCounter("Processor", "% Processor Time", i.ToString());
|
||||
performanceCounters.Add(pc);
|
||||
}
|
||||
return performanceCounters;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using System.ComponentModel;
|
||||
using Artemis.Events;
|
||||
using Artemis.InjectionFactories;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Models;
|
||||
@ -10,7 +11,7 @@ using Caliburn.Micro;
|
||||
namespace Artemis.Modules.Effects.WindowsProfile
|
||||
{
|
||||
// TODO: This effect is a hybrid between a regular effect and a game, may want to clean this up
|
||||
public sealed class WindowsProfileViewModel : EffectViewModel
|
||||
public sealed class WindowsProfileViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
|
||||
{
|
||||
public WindowsProfileViewModel(MainManager main, IEventAggregator events, IProfileEditorVmFactory pFactory,
|
||||
ProfilePreviewModel profilePreviewModel)
|
||||
@ -20,10 +21,11 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
||||
PFactory = pFactory;
|
||||
ProfilePreviewModel = profilePreviewModel;
|
||||
EffectSettings = ((WindowsProfileModel)EffectModel).Settings;
|
||||
|
||||
ProfileEditor = PFactory.CreateProfileEditorVm(events, main, (WindowsProfileModel)EffectModel,
|
||||
((WindowsProfileSettings)EffectSettings).LastProfile);
|
||||
ProfilePreviewModel.Profile = ProfileEditor.SelectedProfile;
|
||||
|
||||
events.Subscribe(this);
|
||||
ProfileEditor.PropertyChanged += ProfileUpdater;
|
||||
MainManager.EffectManager.EffectModels.Add(EffectModel);
|
||||
}
|
||||
@ -58,6 +60,11 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
||||
base.OnDeactivate(close);
|
||||
ProfileEditor.ProfileViewModel.Deactivate();
|
||||
}
|
||||
|
||||
public void Handle(ActiveEffectChanged message)
|
||||
{
|
||||
NotifyOfPropertyChange(() => EffectEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
public class WindowsProfileSettings : GameSettings
|
||||
|
||||
@ -188,6 +188,8 @@ namespace Artemis.ViewModels.Profiles
|
||||
var timeSinceDown = DateTime.Now - _downTime;
|
||||
if (!(timeSinceDown.TotalMilliseconds < 500))
|
||||
return;
|
||||
if (_draggingLayer != null)
|
||||
return;
|
||||
|
||||
var keyboard = _deviceManager.ActiveKeyboard;
|
||||
var pos = e.GetPosition((Image)e.OriginalSource);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user