1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-31 09:43:46 +00:00

Merge pull request #199 from SpoinkyNL/development

1.5.0.2
This commit is contained in:
Robert Beekman 2016-11-17 18:25:18 +01:00 committed by GitHub
commit 071484576e
6 changed files with 66 additions and 24 deletions

View File

@ -47,7 +47,7 @@
MinWidth="80" MinWidth="80"
Margin="0 0 5 0" Margin="0 0 5 0"
Content="Alrighty, let's go!" Content="Alrighty, let's go!"
Style="{DynamicResource AccentedDialogSquareButton}" /> Style="{DynamicResource AccentedDialogSquareButton}" Click="PART_AffirmativeButton_Click" />
</StackPanel> </StackPanel>
</Grid> </Grid>
</dialogs:CustomDialog> </dialogs:CustomDialog>

View File

@ -1,28 +1,45 @@
using System.Windows; using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
namespace Artemis.Dialogs namespace Artemis.Dialogs
{ {
/// <summary> /// <summary>
/// Interaction logic for MarkdownDialog.xaml /// Interaction logic for MarkdownDialog.xaml
/// </summary> /// </summary>
public partial class MarkdownDialog public partial class MarkdownDialog : CustomDialog
{ {
public MetroWindow ParentWindow { get; set; }
public static readonly DependencyProperty MarkdownProperty = DependencyProperty.Register("Markdown", public static readonly DependencyProperty MarkdownProperty = DependencyProperty.Register("Markdown",
typeof(string), typeof(MarkdownDialog), new PropertyMetadata(default(string))); typeof(string), typeof(MarkdownDialog), new PropertyMetadata(default(string)));
public MarkdownDialog()
public MarkdownDialog(MetroWindow parentWindow)
{ {
ParentWindow = parentWindow;
InitializeComponent(); InitializeComponent();
Tcs = new TaskCompletionSource<MessageDialogResult>();
CommandBindings.Add(new CommandBinding(NavigationCommands.GoToPage, CommandBindings.Add(new CommandBinding(NavigationCommands.GoToPage,
(sender, e) => System.Diagnostics.Process.Start((string) e.Parameter))); (sender, e) => System.Diagnostics.Process.Start((string) e.Parameter)));
} }
public TaskCompletionSource<MessageDialogResult> Tcs { get; set; }
public string Markdown public string Markdown
{ {
get { return (string) GetValue(MarkdownProperty); } get { return (string) GetValue(MarkdownProperty); }
set { SetValue(MarkdownProperty, value); } set { SetValue(MarkdownProperty, value); }
} }
private void PART_AffirmativeButton_Click(object sender, RoutedEventArgs e)
{
ParentWindow.HideMetroDialogAsync(this);
}
} }
} }

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

@ -53,8 +53,8 @@ using System.Windows;
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.0.0")] [assembly: AssemblyVersion("1.5.0.2")]
[assembly: AssemblyFileVersion("1.5.0.0")] [assembly: AssemblyFileVersion("1.5.0.2")]
[assembly: InternalsVisibleTo("Artemis.Tests")] [assembly: InternalsVisibleTo("Artemis.Tests")]
[assembly: InternalsVisibleTo("Artemis.Explorables")] [assembly: InternalsVisibleTo("Artemis.Explorables")]

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 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));
} }
} }
} }