mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
parent
bc5e450d78
commit
09ec7853c6
@ -13,6 +13,7 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
||||
Cpu = new CpuDataModel();
|
||||
Performance = new PerformanceDataModel();
|
||||
CurrentTime = new CurrentTime();
|
||||
Keyboard = new KbDataModel();
|
||||
}
|
||||
|
||||
public CpuDataModel Cpu { get; set; }
|
||||
@ -20,6 +21,7 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
||||
public Spotify Spotify { get; set; }
|
||||
public GooglePlayMusic GooglePlayMusic { get; set; }
|
||||
public CurrentTime CurrentTime { get; set; }
|
||||
public KbDataModel Keyboard { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
@ -94,10 +96,18 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
||||
public bool disliked { get; set; }
|
||||
}
|
||||
|
||||
[MoonSharpUserData]
|
||||
public class Time
|
||||
{
|
||||
public int current { 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; }
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.DAL;
|
||||
@ -50,6 +51,7 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
||||
UpdateCpu(dataModel);
|
||||
UpdateMusicPlayers(dataModel);
|
||||
UpdateDay(dataModel);
|
||||
UpdateKeyStates(dataModel);
|
||||
}
|
||||
|
||||
#region Current Time
|
||||
@ -64,7 +66,7 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region CPU
|
||||
|
||||
private void SetupCpu()
|
||||
@ -233,5 +235,20 @@ namespace Artemis.Modules.Effects.WindowsProfile
|
||||
}
|
||||
|
||||
#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
|
||||
}
|
||||
}
|
||||
@ -24,7 +24,6 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Artemis.Dialogs;
|
||||
using Artemis.Styles;
|
||||
using Caliburn.Micro;
|
||||
using MahApps.Metro.Controls;
|
||||
using MahApps.Metro.Controls.Dialogs;
|
||||
@ -57,28 +56,30 @@ namespace Artemis.Services
|
||||
|
||||
public void ShowMarkdownDialog(string title, string markdown)
|
||||
{
|
||||
if (GetActiveWindow() == null)
|
||||
var window = GetActiveWindow();
|
||||
if (window == null)
|
||||
return;
|
||||
|
||||
var dialog = new MarkdownDialog(GetActiveWindow())
|
||||
var dialog = new MarkdownDialog(window)
|
||||
{
|
||||
Markdown = markdown,
|
||||
Title = title
|
||||
};
|
||||
|
||||
Execute.OnUIThread(() => GetActiveWindow().ShowMetroDialogAsync(dialog));
|
||||
window.Dispatcher.Invoke(() => window.ShowMetroDialogAsync(dialog));
|
||||
}
|
||||
|
||||
public override async Task<bool?> ShowQuestionMessageBox(string title, string message)
|
||||
{
|
||||
if (GetActiveWindow() == null)
|
||||
var window = GetActiveWindow();
|
||||
if (window == null)
|
||||
return null;
|
||||
|
||||
var metroDialogSettings = new MetroDialogSettings {AffirmativeButtonText = "Yes", NegativeButtonText = "No"};
|
||||
var result =
|
||||
await
|
||||
GetActiveWindow()
|
||||
.ShowMessageAsync(title, message, MessageDialogStyle.AffirmativeAndNegative, metroDialogSettings);
|
||||
var result = await window.Dispatcher.Invoke(() =>
|
||||
window.ShowMessageAsync(title, message, MessageDialogStyle.AffirmativeAndNegative,
|
||||
metroDialogSettings));
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case MessageDialogResult.Negative:
|
||||
@ -92,10 +93,8 @@ namespace Artemis.Services
|
||||
|
||||
public override Task<string> ShowInputDialog(string title, string message, MetroDialogSettings settings = null)
|
||||
{
|
||||
if (GetActiveWindow() == null)
|
||||
return null;
|
||||
|
||||
return GetActiveWindow().ShowInputAsync(title, message, settings);
|
||||
var window = GetActiveWindow();
|
||||
return window?.Dispatcher.Invoke(() => window.ShowInputAsync(title, message, settings));
|
||||
}
|
||||
|
||||
public override bool ShowOpenDialog(out string path, string defaultExt, string filter, string initialDir = null)
|
||||
@ -132,15 +131,14 @@ namespace Artemis.Services
|
||||
|
||||
path = lPath;
|
||||
|
||||
return res.Value;
|
||||
return res != null && res.Value;
|
||||
}
|
||||
|
||||
public Task<ProgressDialogController> ShowProgressDialog(string title, string message, bool isCancelable = false,
|
||||
MetroDialogSettings settings = null)
|
||||
{
|
||||
var activeWindow = GetActiveWindow();
|
||||
return activeWindow?.Dispatcher.Invoke(
|
||||
() => activeWindow.ShowProgressAsync(title, message, isCancelable, settings));
|
||||
var window = GetActiveWindow();
|
||||
return window?.Dispatcher.Invoke(() => window.ShowProgressAsync(title, message, isCancelable, settings));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user