1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2026-01-01 18:23:32 +00:00
Added Caps/Scroll/Numlock (#179)
This commit is contained in:
SpoinkyNL 2016-11-17 18:24:32 +01:00
parent bc5e450d78
commit 09ec7853c6
3 changed files with 43 additions and 18 deletions

View File

@ -13,6 +13,7 @@ namespace Artemis.Modules.Effects.WindowsProfile
Cpu = new CpuDataModel(); Cpu = new CpuDataModel();
Performance = new PerformanceDataModel(); Performance = new PerformanceDataModel();
CurrentTime = new CurrentTime(); CurrentTime = new CurrentTime();
Keyboard = new KbDataModel();
} }
public CpuDataModel Cpu { get; set; } public CpuDataModel Cpu { get; set; }
@ -20,6 +21,7 @@ namespace Artemis.Modules.Effects.WindowsProfile
public Spotify Spotify { get; set; } public Spotify Spotify { get; set; }
public GooglePlayMusic GooglePlayMusic { get; set; } public GooglePlayMusic GooglePlayMusic { get; set; }
public CurrentTime CurrentTime { get; set; } public CurrentTime CurrentTime { get; set; }
public KbDataModel Keyboard { get; set; }
} }
[MoonSharpUserData] [MoonSharpUserData]
@ -94,10 +96,18 @@ namespace Artemis.Modules.Effects.WindowsProfile
public bool disliked { get; set; } public bool disliked { get; set; }
} }
[MoonSharpUserData]
public class Time public class Time
{ {
public int current { get; set; } public int current { get; set; }
public int total { get; set; } public int total { get; set; }
} }
[MoonSharpUserData]
public class KbDataModel
{
public bool NumLock { get; set; }
public bool CapsLock { get; set; }
public bool ScrollLock { get; set; }
}
} }

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.DAL; using Artemis.DAL;
@ -50,6 +51,7 @@ namespace Artemis.Modules.Effects.WindowsProfile
UpdateCpu(dataModel); UpdateCpu(dataModel);
UpdateMusicPlayers(dataModel); UpdateMusicPlayers(dataModel);
UpdateDay(dataModel); UpdateDay(dataModel);
UpdateKeyStates(dataModel);
} }
#region Current Time #region Current Time
@ -233,5 +235,20 @@ namespace Artemis.Modules.Effects.WindowsProfile
} }
#endregion #endregion
#region System
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true,
CallingConvention = CallingConvention.Winapi)]
public static extern short GetKeyState(int keyCode);
private void UpdateKeyStates(WindowsProfileDataModel dataModel)
{
dataModel.Keyboard.NumLock = ((ushort)GetKeyState(0x90) & 0xffff) != 0;
dataModel.Keyboard.CapsLock = ((ushort)GetKeyState(0x14) & 0xffff) != 0;
dataModel.Keyboard.ScrollLock = ((ushort)GetKeyState(0x91) & 0xffff) != 0;
}
#endregion
} }
} }

View File

@ -24,7 +24,6 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using Artemis.Dialogs; using Artemis.Dialogs;
using Artemis.Styles;
using Caliburn.Micro; using Caliburn.Micro;
using MahApps.Metro.Controls; using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs; using MahApps.Metro.Controls.Dialogs;
@ -57,28 +56,30 @@ namespace Artemis.Services
public void ShowMarkdownDialog(string title, string markdown) public void ShowMarkdownDialog(string title, string markdown)
{ {
if (GetActiveWindow() == null) var window = GetActiveWindow();
if (window == null)
return; return;
var dialog = new MarkdownDialog(GetActiveWindow()) var dialog = new MarkdownDialog(window)
{ {
Markdown = markdown, Markdown = markdown,
Title = title Title = title
}; };
Execute.OnUIThread(() => GetActiveWindow().ShowMetroDialogAsync(dialog)); window.Dispatcher.Invoke(() => window.ShowMetroDialogAsync(dialog));
} }
public override async Task<bool?> ShowQuestionMessageBox(string title, string message) public override async Task<bool?> ShowQuestionMessageBox(string title, string message)
{ {
if (GetActiveWindow() == null) var window = GetActiveWindow();
if (window == null)
return null; return null;
var metroDialogSettings = new MetroDialogSettings {AffirmativeButtonText = "Yes", NegativeButtonText = "No"}; var metroDialogSettings = new MetroDialogSettings {AffirmativeButtonText = "Yes", NegativeButtonText = "No"};
var result = var result = await window.Dispatcher.Invoke(() =>
await window.ShowMessageAsync(title, message, MessageDialogStyle.AffirmativeAndNegative,
GetActiveWindow() metroDialogSettings));
.ShowMessageAsync(title, message, MessageDialogStyle.AffirmativeAndNegative, metroDialogSettings);
switch (result) switch (result)
{ {
case MessageDialogResult.Negative: case MessageDialogResult.Negative:
@ -92,10 +93,8 @@ namespace Artemis.Services
public override Task<string> ShowInputDialog(string title, string message, MetroDialogSettings settings = null) public override Task<string> ShowInputDialog(string title, string message, MetroDialogSettings settings = null)
{ {
if (GetActiveWindow() == null) var window = GetActiveWindow();
return null; return window?.Dispatcher.Invoke(() => window.ShowInputAsync(title, message, settings));
return GetActiveWindow().ShowInputAsync(title, message, settings);
} }
public override bool ShowOpenDialog(out string path, string defaultExt, string filter, string initialDir = null) public override bool ShowOpenDialog(out string path, string defaultExt, string filter, string initialDir = null)
@ -132,15 +131,14 @@ namespace Artemis.Services
path = lPath; path = lPath;
return res.Value; return res != null && res.Value;
} }
public Task<ProgressDialogController> ShowProgressDialog(string title, string message, bool isCancelable = false, public Task<ProgressDialogController> ShowProgressDialog(string title, string message, bool isCancelable = false,
MetroDialogSettings settings = null) MetroDialogSettings settings = null)
{ {
var activeWindow = GetActiveWindow(); var window = GetActiveWindow();
return activeWindow?.Dispatcher.Invoke( return window?.Dispatcher.Invoke(() => window.ShowProgressAsync(title, message, isCancelable, settings));
() => activeWindow.ShowProgressAsync(title, message, isCancelable, settings));
} }
} }
} }