1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +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"
Margin="0 0 5 0"
Content="Alrighty, let's go!"
Style="{DynamicResource AccentedDialogSquareButton}" />
Style="{DynamicResource AccentedDialogSquareButton}" Click="PART_AffirmativeButton_Click" />
</StackPanel>
</Grid>
</dialogs:CustomDialog>

View File

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

View File

@ -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
}
}

View File

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

View File

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