1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 21:38:38 +00:00

Unified line endings

This commit is contained in:
SpoinkyNL 2016-03-27 14:55:44 +02:00
parent 5e385d4e3d
commit 958c98dad5
91 changed files with 6296 additions and 6296 deletions

View File

@ -1,60 +1,60 @@
using System;
using System.Windows;
using System.Windows.Threading;
using Artemis.Utilities;
using WpfExceptionViewer;
namespace Artemis
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
if (!GeneralHelpers.IsRunAsAdministrator())
GeneralHelpers.RunAsAdministrator();
InitializeComponent();
}
public bool DoHandle { get; set; }
private void Application_Startup(object sender, StartupEventArgs e)
{
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
}
private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
if (DoHandle)
{
GetArtemisExceptionViewer(e.Exception).ShowDialog();
e.Handled = true;
}
else
{
GetArtemisExceptionViewer(e.Exception).ShowDialog();
e.Handled = false;
}
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
var ex = e.ExceptionObject as Exception;
GetArtemisExceptionViewer(ex).ShowDialog();
}
private static ExceptionViewer GetArtemisExceptionViewer(Exception e)
{
return new ExceptionViewer("An unexpected error occurred in Artemis.", e)
{
Title = "Artemis - Exception :c",
Height = 400,
Width = 800
};
}
}
using System;
using System.Windows;
using System.Windows.Threading;
using Artemis.Utilities;
using WpfExceptionViewer;
namespace Artemis
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
if (!GeneralHelpers.IsRunAsAdministrator())
GeneralHelpers.RunAsAdministrator();
InitializeComponent();
}
public bool DoHandle { get; set; }
private void Application_Startup(object sender, StartupEventArgs e)
{
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
}
private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
if (DoHandle)
{
GetArtemisExceptionViewer(e.Exception).ShowDialog();
e.Handled = true;
}
else
{
GetArtemisExceptionViewer(e.Exception).ShowDialog();
e.Handled = false;
}
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
var ex = e.ExceptionObject as Exception;
GetArtemisExceptionViewer(ex).ShowDialog();
}
private static ExceptionViewer GetArtemisExceptionViewer(Exception e)
{
return new ExceptionViewer("An unexpected error occurred in Artemis.", e)
{
Title = "Artemis - Exception :c",
Height = 400,
Width = 800
};
}
}
}

View File

@ -1,51 +1,51 @@
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Forms;
using Artemis.Utilities;
using Artemis.Utilities.LogitechDll;
using Artemis.ViewModels;
using Autofac;
using Caliburn.Micro;
using Caliburn.Micro.Autofac;
using Application = System.Windows.Application;
using MessageBox = System.Windows.Forms.MessageBox;
namespace Artemis
{
public class ArtemisBootstrapper : AutofacBootstrapper<SystemTrayViewModel>
{
public ArtemisBootstrapper()
{
CheckDuplicateInstances();
Initialize();
}
protected override void ConfigureContainer(ContainerBuilder builder)
{
base.ConfigureContainer(builder);
// create a window manager instance to be used by everyone asking for one (including Caliburn.Micro)
builder.RegisterInstance<IWindowManager>(new WindowManager());
builder.RegisterType<SystemTrayViewModel>();
builder.RegisterType<ShellViewModel>();
}
protected override void OnStartup(object sender, StartupEventArgs e)
{
DisplayRootViewFor<SystemTrayViewModel>();
}
private void CheckDuplicateInstances()
{
var processes = Process.GetProcesses();
if (processes.Count(p => p.ProcessName == "Artemis") < 2)
return;
MessageBox.Show("An instance of Artemis is already running (check your system tray).",
"Artemis (╯°□°)╯︵ ┻━┻", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Application.Current.Shutdown();
}
}
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Forms;
using Artemis.Utilities;
using Artemis.Utilities.LogitechDll;
using Artemis.ViewModels;
using Autofac;
using Caliburn.Micro;
using Caliburn.Micro.Autofac;
using Application = System.Windows.Application;
using MessageBox = System.Windows.Forms.MessageBox;
namespace Artemis
{
public class ArtemisBootstrapper : AutofacBootstrapper<SystemTrayViewModel>
{
public ArtemisBootstrapper()
{
CheckDuplicateInstances();
Initialize();
}
protected override void ConfigureContainer(ContainerBuilder builder)
{
base.ConfigureContainer(builder);
// create a window manager instance to be used by everyone asking for one (including Caliburn.Micro)
builder.RegisterInstance<IWindowManager>(new WindowManager());
builder.RegisterType<SystemTrayViewModel>();
builder.RegisterType<ShellViewModel>();
}
protected override void OnStartup(object sender, StartupEventArgs e)
{
DisplayRootViewFor<SystemTrayViewModel>();
}
private void CheckDuplicateInstances()
{
var processes = Process.GetProcesses();
if (processes.Count(p => p.ProcessName == "Artemis") < 2)
return;
MessageBox.Show("An instance of Artemis is already running (check your system tray).",
"Artemis (╯°□°)╯︵ ┻━┻", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Application.Current.Shutdown();
}
}
}

View File

@ -1,12 +1,12 @@
namespace Artemis.Events
{
public class ActiveEffectChanged
{
public ActiveEffectChanged(string activeEffect)
{
ActiveEffect = activeEffect;
}
public string ActiveEffect { get; set; }
}
namespace Artemis.Events
{
public class ActiveEffectChanged
{
public ActiveEffectChanged(string activeEffect)
{
ActiveEffect = activeEffect;
}
public string ActiveEffect { get; set; }
}
}

View File

@ -1,19 +1,19 @@
using System.Drawing;
namespace Artemis.Events
{
public class ChangeBitmap
{
public ChangeBitmap(Bitmap bitmap)
{
Bitmap = bitmap;
}
public Bitmap Bitmap { get; private set; }
public void ChangeTextMessage(Bitmap bitmap)
{
Bitmap = bitmap;
}
}
using System.Drawing;
namespace Artemis.Events
{
public class ChangeBitmap
{
public ChangeBitmap(Bitmap bitmap)
{
Bitmap = bitmap;
}
public Bitmap Bitmap { get; private set; }
public void ChangeTextMessage(Bitmap bitmap)
{
Bitmap = bitmap;
}
}
}

View File

@ -1,12 +1,12 @@
namespace Artemis.Events
{
public class ToggleEnabled
{
public ToggleEnabled(bool enabled)
{
Enabled = enabled;
}
public bool Enabled { get; set; }
}
namespace Artemis.Events
{
public class ToggleEnabled
{
public ToggleEnabled(bool enabled)
{
Enabled = enabled;
}
public bool Enabled { get; set; }
}
}

View File

@ -1,32 +1,32 @@
using System.Collections.Generic;
using System.Drawing;
namespace Artemis.KeyboardProviders
{
public abstract class KeyboardProvider
{
public string Name { get; set; }
public int Height { get; set; }
public int Width { get; set; }
public string CantEnableText { get; set; }
public List<KeyboardRegion> KeyboardRegions { get; set; }
public abstract bool CanEnable();
public abstract void Enable();
public abstract void Disable();
public abstract void DrawBitmap(Bitmap bitmap);
/// <summary>
/// Returns a bitmap matching the keyboard's dimensions
/// </summary>
/// <returns></returns>
public Bitmap KeyboardBitmap() => new Bitmap(Width, Height);
/// <summary>
/// Returns a bitmap matching the keyboard's dimensions using the provided scale
/// </summary>
/// <returns></returns>
public Bitmap KeyboardBitmap(int scale) => new Bitmap(Width*scale, Height*scale);
}
using System.Collections.Generic;
using System.Drawing;
namespace Artemis.KeyboardProviders
{
public abstract class KeyboardProvider
{
public string Name { get; set; }
public int Height { get; set; }
public int Width { get; set; }
public string CantEnableText { get; set; }
public List<KeyboardRegion> KeyboardRegions { get; set; }
public abstract bool CanEnable();
public abstract void Enable();
public abstract void Disable();
public abstract void DrawBitmap(Bitmap bitmap);
/// <summary>
/// Returns a bitmap matching the keyboard's dimensions
/// </summary>
/// <returns></returns>
public Bitmap KeyboardBitmap() => new Bitmap(Width, Height);
/// <summary>
/// Returns a bitmap matching the keyboard's dimensions using the provided scale
/// </summary>
/// <returns></returns>
public Bitmap KeyboardBitmap(int scale) => new Bitmap(Width*scale, Height*scale);
}
}

View File

@ -1,20 +1,20 @@
using System.Drawing;
namespace Artemis.KeyboardProviders
{
public class KeyboardRegion
{
public KeyboardRegion(string regionName, Point topLeft, Point bottomRight)
{
RegionName = regionName;
TopLeft = topLeft;
BottomRight = bottomRight;
}
public string RegionName { get; set; }
public Point TopLeft { get; set; }
public Point BottomRight { get; set; }
public Rectangle GetRectangle() => new Rectangle(TopLeft.X, TopLeft.Y, BottomRight.X - TopLeft.X, BottomRight.Y - TopLeft.Y);
}
using System.Drawing;
namespace Artemis.KeyboardProviders
{
public class KeyboardRegion
{
public KeyboardRegion(string regionName, Point topLeft, Point bottomRight)
{
RegionName = regionName;
TopLeft = topLeft;
BottomRight = bottomRight;
}
public string RegionName { get; set; }
public Point TopLeft { get; set; }
public Point BottomRight { get; set; }
public Rectangle GetRectangle() => new Rectangle(TopLeft.X, TopLeft.Y, BottomRight.X - TopLeft.X, BottomRight.Y - TopLeft.Y);
}
}

View File

@ -1,137 +1,137 @@
using System.Collections.Generic;
using System.Windows.Forms;
using Artemis.Utilities.Keyboard;
namespace Artemis.KeyboardProviders.Logitech.Utilities
{
public static class KeyMap
{
static KeyMap()
{
// There are several keyboard layouts
// TODO: Implemented more layouts and an option to select them
UsEnglishOrionKeys = new List<Key>
{
// Row 1
new Key(Keys.Escape, 0, 0),
new Key(Keys.F1, 1, 0),
new Key(Keys.F2, 2, 0),
new Key(Keys.F3, 3, 0),
new Key(Keys.F4, 4, 0),
new Key(Keys.F5, 5, 0),
new Key(Keys.F6, 6, 0),
new Key(Keys.F7, 7, 0),
new Key(Keys.F8, 8, 0),
new Key(Keys.F9, 9, 0),
new Key(Keys.F10, 10, 0),
new Key(Keys.F11, 11, 0),
new Key(Keys.F12, 12, 0),
new Key(Keys.PrintScreen, 13, 0),
new Key(Keys.Scroll, 14, 0),
new Key(Keys.Pause, 15, 0),
// Row 2
new Key(Keys.Oemtilde, 0, 1),
new Key(Keys.D1, 1, 1),
new Key(Keys.D2, 2, 1),
new Key(Keys.D3, 3, 1),
new Key(Keys.D4, 4, 1),
new Key(Keys.D5, 5, 1),
new Key(Keys.D6, 6, 1),
new Key(Keys.D7, 7, 1),
new Key(Keys.D8, 8, 1),
new Key(Keys.D9, 9, 1),
new Key(Keys.D0, 10, 1),
new Key(Keys.OemMinus, 11, 1),
new Key(Keys.Oemplus, 12, 1),
new Key(Keys.Back, 13, 1),
new Key(Keys.Insert, 14, 1),
new Key(Keys.Home, 15, 1),
new Key(Keys.PageUp, 16, 1),
new Key(Keys.NumLock, 17, 1),
new Key(Keys.Divide, 18, 1),
new Key(Keys.Multiply, 19, 1),
new Key(Keys.Subtract, 20, 1),
// Row 3
new Key(Keys.Tab, 0, 2),
new Key(Keys.Q, 1, 2),
new Key(Keys.W, 2, 2),
new Key(Keys.E, 3, 2),
new Key(Keys.R, 4, 2),
new Key(Keys.T, 5, 2),
new Key(Keys.Y, 6, 2),
new Key(Keys.U, 7, 2),
new Key(Keys.I, 8, 2),
new Key(Keys.O, 9, 2),
new Key(Keys.P, 10, 2),
new Key(Keys.OemOpenBrackets, 11, 2),
new Key(Keys.Oem6, 12, 2),
new Key(Keys.Delete, 14, 2),
new Key(Keys.End, 15, 2),
new Key(Keys.Next, 16, 2),
new Key(Keys.NumPad7, 17, 2),
new Key(Keys.NumPad8, 18, 2),
new Key(Keys.NumPad9, 19, 2),
new Key(Keys.Add, 20, 2),
// Row 4
new Key(Keys.Capital, 0, 3),
new Key(Keys.A, 1, 3),
new Key(Keys.S, 2, 3),
new Key(Keys.D, 3, 3),
new Key(Keys.F, 4, 3),
new Key(Keys.G, 5, 3),
new Key(Keys.H, 6, 3),
new Key(Keys.J, 7, 3),
new Key(Keys.K, 8, 3),
new Key(Keys.L, 9, 3),
new Key(Keys.Oem1, 10, 3),
new Key(Keys.Oem7, 11, 3),
new Key(Keys.Oem5, 12, 3),
new Key(Keys.Return, 13, 3),
new Key(Keys.NumPad4, 17, 3),
new Key(Keys.NumPad5, 18, 3),
new Key(Keys.NumPad6, 19, 3),
// Row 5
new Key(Keys.LShiftKey, 1, 4),
new Key(Keys.OemBackslash, 2, 4),
new Key(Keys.Z, 2, 4),
new Key(Keys.X, 3, 4),
new Key(Keys.C, 4, 4),
new Key(Keys.V, 5, 4),
new Key(Keys.B, 6, 4),
new Key(Keys.N, 7, 4),
new Key(Keys.M, 8, 4),
new Key(Keys.Oemcomma, 9, 4),
new Key(Keys.OemPeriod, 10, 4),
new Key(Keys.OemQuestion, 11, 4),
new Key(Keys.RShiftKey, 13, 4),
new Key(Keys.Up, 15, 4),
new Key(Keys.NumPad1, 17, 4),
new Key(Keys.NumPad2, 18, 4),
new Key(Keys.NumPad3, 19, 4),
// Both returns return "Return" (Yes...)
// new OrionKey(System.Windows.Forms.Keys.Return, 20, 4),
// Row 6
new Key(Keys.LControlKey, 0, 5),
new Key(Keys.LWin, 1, 5),
new Key(Keys.LMenu, 2, 5),
new Key(Keys.Space, 5, 5),
new Key(Keys.RMenu, 11, 5),
new Key(Keys.RWin, 12, 5),
new Key(Keys.Apps, 13, 5),
new Key(Keys.RControlKey, 14, 5),
new Key(Keys.Left, 15, 5),
new Key(Keys.Down, 16, 5),
new Key(Keys.Right, 17, 5),
new Key(Keys.NumPad0, 18, 5),
new Key(Keys.Decimal, 19, 5)
};
}
public static List<Key> UsEnglishOrionKeys { get; set; }
}
using System.Collections.Generic;
using System.Windows.Forms;
using Artemis.Utilities.Keyboard;
namespace Artemis.KeyboardProviders.Logitech.Utilities
{
public static class KeyMap
{
static KeyMap()
{
// There are several keyboard layouts
// TODO: Implemented more layouts and an option to select them
UsEnglishOrionKeys = new List<Key>
{
// Row 1
new Key(Keys.Escape, 0, 0),
new Key(Keys.F1, 1, 0),
new Key(Keys.F2, 2, 0),
new Key(Keys.F3, 3, 0),
new Key(Keys.F4, 4, 0),
new Key(Keys.F5, 5, 0),
new Key(Keys.F6, 6, 0),
new Key(Keys.F7, 7, 0),
new Key(Keys.F8, 8, 0),
new Key(Keys.F9, 9, 0),
new Key(Keys.F10, 10, 0),
new Key(Keys.F11, 11, 0),
new Key(Keys.F12, 12, 0),
new Key(Keys.PrintScreen, 13, 0),
new Key(Keys.Scroll, 14, 0),
new Key(Keys.Pause, 15, 0),
// Row 2
new Key(Keys.Oemtilde, 0, 1),
new Key(Keys.D1, 1, 1),
new Key(Keys.D2, 2, 1),
new Key(Keys.D3, 3, 1),
new Key(Keys.D4, 4, 1),
new Key(Keys.D5, 5, 1),
new Key(Keys.D6, 6, 1),
new Key(Keys.D7, 7, 1),
new Key(Keys.D8, 8, 1),
new Key(Keys.D9, 9, 1),
new Key(Keys.D0, 10, 1),
new Key(Keys.OemMinus, 11, 1),
new Key(Keys.Oemplus, 12, 1),
new Key(Keys.Back, 13, 1),
new Key(Keys.Insert, 14, 1),
new Key(Keys.Home, 15, 1),
new Key(Keys.PageUp, 16, 1),
new Key(Keys.NumLock, 17, 1),
new Key(Keys.Divide, 18, 1),
new Key(Keys.Multiply, 19, 1),
new Key(Keys.Subtract, 20, 1),
// Row 3
new Key(Keys.Tab, 0, 2),
new Key(Keys.Q, 1, 2),
new Key(Keys.W, 2, 2),
new Key(Keys.E, 3, 2),
new Key(Keys.R, 4, 2),
new Key(Keys.T, 5, 2),
new Key(Keys.Y, 6, 2),
new Key(Keys.U, 7, 2),
new Key(Keys.I, 8, 2),
new Key(Keys.O, 9, 2),
new Key(Keys.P, 10, 2),
new Key(Keys.OemOpenBrackets, 11, 2),
new Key(Keys.Oem6, 12, 2),
new Key(Keys.Delete, 14, 2),
new Key(Keys.End, 15, 2),
new Key(Keys.Next, 16, 2),
new Key(Keys.NumPad7, 17, 2),
new Key(Keys.NumPad8, 18, 2),
new Key(Keys.NumPad9, 19, 2),
new Key(Keys.Add, 20, 2),
// Row 4
new Key(Keys.Capital, 0, 3),
new Key(Keys.A, 1, 3),
new Key(Keys.S, 2, 3),
new Key(Keys.D, 3, 3),
new Key(Keys.F, 4, 3),
new Key(Keys.G, 5, 3),
new Key(Keys.H, 6, 3),
new Key(Keys.J, 7, 3),
new Key(Keys.K, 8, 3),
new Key(Keys.L, 9, 3),
new Key(Keys.Oem1, 10, 3),
new Key(Keys.Oem7, 11, 3),
new Key(Keys.Oem5, 12, 3),
new Key(Keys.Return, 13, 3),
new Key(Keys.NumPad4, 17, 3),
new Key(Keys.NumPad5, 18, 3),
new Key(Keys.NumPad6, 19, 3),
// Row 5
new Key(Keys.LShiftKey, 1, 4),
new Key(Keys.OemBackslash, 2, 4),
new Key(Keys.Z, 2, 4),
new Key(Keys.X, 3, 4),
new Key(Keys.C, 4, 4),
new Key(Keys.V, 5, 4),
new Key(Keys.B, 6, 4),
new Key(Keys.N, 7, 4),
new Key(Keys.M, 8, 4),
new Key(Keys.Oemcomma, 9, 4),
new Key(Keys.OemPeriod, 10, 4),
new Key(Keys.OemQuestion, 11, 4),
new Key(Keys.RShiftKey, 13, 4),
new Key(Keys.Up, 15, 4),
new Key(Keys.NumPad1, 17, 4),
new Key(Keys.NumPad2, 18, 4),
new Key(Keys.NumPad3, 19, 4),
// Both returns return "Return" (Yes...)
// new OrionKey(System.Windows.Forms.Keys.Return, 20, 4),
// Row 6
new Key(Keys.LControlKey, 0, 5),
new Key(Keys.LWin, 1, 5),
new Key(Keys.LMenu, 2, 5),
new Key(Keys.Space, 5, 5),
new Key(Keys.RMenu, 11, 5),
new Key(Keys.RWin, 12, 5),
new Key(Keys.Apps, 13, 5),
new Key(Keys.RControlKey, 14, 5),
new Key(Keys.Left, 15, 5),
new Key(Keys.Down, 16, 5),
new Key(Keys.Right, 17, 5),
new Key(Keys.NumPad0, 18, 5),
new Key(Keys.Decimal, 19, 5)
};
}
public static List<Key> UsEnglishOrionKeys { get; set; }
}
}

View File

@ -1,111 +1,111 @@
namespace Artemis.KeyboardProviders.Logitech.Utilities
{
public enum KeyboardNames
{
ESC = 0x01,
F1 = 0x3b,
F2 = 0x3c,
F3 = 0x3d,
F4 = 0x3e,
F5 = 0x3f,
F6 = 0x40,
F7 = 0x41,
F8 = 0x42,
F9 = 0x43,
F10 = 0x44,
F11 = 0x57,
F12 = 0x58,
PRINT_SCREEN = 0x137,
SCROLL_LOCK = 0x46,
PAUSE_BREAK = 0x45,
TILDE = 0x29,
ONE = 0x02,
TWO = 0x03,
THREE = 0x04,
FOUR = 0x05,
FIVE = 0x06,
SIX = 0x07,
SEVEN = 0x08,
EIGHT = 0x09,
NINE = 0x0A,
ZERO = 0x0B,
MINUS = 0x0C,
EQUALS = 0x0D,
BACKSPACE = 0x0E,
INSERT = 0x152,
HOME = 0x147,
PAGE_UP = 0x149,
NUM_LOCK = 0x145,
NUM_SLASH = 0x135,
NUM_ASTERISK = 0x37,
NUM_MINUS = 0x4A,
TAB = 0x0F,
Q = 0x10,
W = 0x11,
E = 0x12,
R = 0x13,
T = 0x14,
Y = 0x15,
U = 0x16,
I = 0x17,
O = 0x18,
P = 0x19,
OPEN_BRACKET = 0x1A,
CLOSE_BRACKET = 0x1B,
BACKSLASH = 0x2B,
KEYBOARD_DELETE = 0x153,
END = 0x14F,
PAGE_DOWN = 0x151,
NUM_SEVEN = 0x47,
NUM_EIGHT = 0x48,
NUM_NINE = 0x49,
NUM_PLUS = 0x4E,
CAPS_LOCK = 0x3A,
A = 0x1E,
S = 0x1F,
D = 0x20,
F = 0x21,
G = 0x22,
H = 0x23,
J = 0x24,
K = 0x25,
L = 0x26,
SEMICOLON = 0x27,
APOSTROPHE = 0x28,
ENTER = 0x1C,
NUM_FOUR = 0x4B,
NUM_FIVE = 0x4C,
NUM_SIX = 0x4D,
LEFT_SHIFT = 0x2A,
Z = 0x2C,
X = 0x2D,
C = 0x2E,
V = 0x2F,
B = 0x30,
N = 0x31,
M = 0x32,
COMMA = 0x33,
PERIOD = 0x34,
FORWARD_SLASH = 0x35,
RIGHT_SHIFT = 0x36,
ARROW_UP = 0x148,
NUM_ONE = 0x4F,
NUM_TWO = 0x50,
NUM_THREE = 0x51,
NUM_ENTER = 0x11C,
LEFT_CONTROL = 0x1D,
LEFT_WINDOWS = 0x15B,
LEFT_ALT = 0x38,
SPACE = 0x39,
RIGHT_ALT = 0x138,
RIGHT_WINDOWS = 0x15C,
APPLICATION_SELECT = 0x15D,
RIGHT_CONTROL = 0x11D,
ARROW_LEFT = 0x14B,
ARROW_DOWN = 0x150,
ARROW_RIGHT = 0x14D,
NUM_ZERO = 0x52,
NUM_PERIOD = 0x53,
TEST = 0x1
}
namespace Artemis.KeyboardProviders.Logitech.Utilities
{
public enum KeyboardNames
{
ESC = 0x01,
F1 = 0x3b,
F2 = 0x3c,
F3 = 0x3d,
F4 = 0x3e,
F5 = 0x3f,
F6 = 0x40,
F7 = 0x41,
F8 = 0x42,
F9 = 0x43,
F10 = 0x44,
F11 = 0x57,
F12 = 0x58,
PRINT_SCREEN = 0x137,
SCROLL_LOCK = 0x46,
PAUSE_BREAK = 0x45,
TILDE = 0x29,
ONE = 0x02,
TWO = 0x03,
THREE = 0x04,
FOUR = 0x05,
FIVE = 0x06,
SIX = 0x07,
SEVEN = 0x08,
EIGHT = 0x09,
NINE = 0x0A,
ZERO = 0x0B,
MINUS = 0x0C,
EQUALS = 0x0D,
BACKSPACE = 0x0E,
INSERT = 0x152,
HOME = 0x147,
PAGE_UP = 0x149,
NUM_LOCK = 0x145,
NUM_SLASH = 0x135,
NUM_ASTERISK = 0x37,
NUM_MINUS = 0x4A,
TAB = 0x0F,
Q = 0x10,
W = 0x11,
E = 0x12,
R = 0x13,
T = 0x14,
Y = 0x15,
U = 0x16,
I = 0x17,
O = 0x18,
P = 0x19,
OPEN_BRACKET = 0x1A,
CLOSE_BRACKET = 0x1B,
BACKSLASH = 0x2B,
KEYBOARD_DELETE = 0x153,
END = 0x14F,
PAGE_DOWN = 0x151,
NUM_SEVEN = 0x47,
NUM_EIGHT = 0x48,
NUM_NINE = 0x49,
NUM_PLUS = 0x4E,
CAPS_LOCK = 0x3A,
A = 0x1E,
S = 0x1F,
D = 0x20,
F = 0x21,
G = 0x22,
H = 0x23,
J = 0x24,
K = 0x25,
L = 0x26,
SEMICOLON = 0x27,
APOSTROPHE = 0x28,
ENTER = 0x1C,
NUM_FOUR = 0x4B,
NUM_FIVE = 0x4C,
NUM_SIX = 0x4D,
LEFT_SHIFT = 0x2A,
Z = 0x2C,
X = 0x2D,
C = 0x2E,
V = 0x2F,
B = 0x30,
N = 0x31,
M = 0x32,
COMMA = 0x33,
PERIOD = 0x34,
FORWARD_SLASH = 0x35,
RIGHT_SHIFT = 0x36,
ARROW_UP = 0x148,
NUM_ONE = 0x4F,
NUM_TWO = 0x50,
NUM_THREE = 0x51,
NUM_ENTER = 0x11C,
LEFT_CONTROL = 0x1D,
LEFT_WINDOWS = 0x15B,
LEFT_ALT = 0x38,
SPACE = 0x39,
RIGHT_ALT = 0x138,
RIGHT_WINDOWS = 0x15C,
APPLICATION_SELECT = 0x15D,
RIGHT_CONTROL = 0x11D,
ARROW_LEFT = 0x14B,
ARROW_DOWN = 0x150,
ARROW_RIGHT = 0x14D,
NUM_ZERO = 0x52,
NUM_PERIOD = 0x53,
TEST = 0x1
}
}

View File

@ -1,95 +1,95 @@
using System.Runtime.InteropServices;
// ReSharper disable InconsistentNaming
namespace Artemis.KeyboardProviders.Logitech.Utilities
{
public class LogitechGSDK
{
//LED SDK
private const int LOGI_DEVICETYPE_MONOCHROME_ORD = 0;
private const int LOGI_DEVICETYPE_RGB_ORD = 1;
private const int LOGI_DEVICETYPE_PERKEY_RGB_ORD = 2;
public const int LOGI_DEVICETYPE_MONOCHROME = 1 << LOGI_DEVICETYPE_MONOCHROME_ORD;
public const int LOGI_DEVICETYPE_RGB = 1 << LOGI_DEVICETYPE_RGB_ORD;
public const int LOGI_DEVICETYPE_PERKEY_RGB = 1 << LOGI_DEVICETYPE_PERKEY_RGB_ORD;
public const int LOGI_LED_BITMAP_WIDTH = 21;
public const int LOGI_LED_BITMAP_HEIGHT = 6;
public const int LOGI_LED_BITMAP_BYTES_PER_KEY = 4;
public const int LOGI_LED_BITMAP_SIZE =
LOGI_LED_BITMAP_WIDTH*LOGI_LED_BITMAP_HEIGHT*LOGI_LED_BITMAP_BYTES_PER_KEY;
public const int LOGI_LED_DURATION_INFINITE = 0;
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedInit();
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSetTargetDevice(int targetDevice);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedGetSdkVersion(ref int majorNum, ref int minorNum, ref int buildNum);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSaveCurrentLighting();
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSetLighting(int redPercentage, int greenPercentage, int bluePercentage);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedRestoreLighting();
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedFlashLighting(int redPercentage, int greenPercentage, int bluePercentage,
int milliSecondsDuration, int milliSecondsInterval);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedPulseLighting(int redPercentage, int greenPercentage, int bluePercentage,
int milliSecondsDuration, int milliSecondsInterval);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedStopEffects();
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSetLightingFromBitmap(byte[] bitmap);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSetLightingForKeyWithScanCode(int keyCode, int redPercentage,
int greenPercentage, int bluePercentage);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSetLightingForKeyWithHidCode(int keyCode, int redPercentage,
int greenPercentage, int bluePercentage);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSetLightingForKeyWithQuartzCode(int keyCode, int redPercentage,
int greenPercentage, int bluePercentage);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSetLightingForKeyWithKeyName(int keyCode, int redPercentage,
int greenPercentage, int bluePercentage);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSaveLightingForKey(KeyboardNames keyName);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedRestoreLightingForKey(KeyboardNames keyName);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedFlashSingleKey(KeyboardNames keyName, int redPercentage, int greenPercentage,
int bluePercentage, int msDuration, int msInterval);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedPulseSingleKey(KeyboardNames keyName, int startRedPercentage,
int startGreenPercentage, int startBluePercentage, int finishRedPercentage, int finishGreenPercentage,
int finishBluePercentage, int msDuration, bool isInfinite);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedStopEffectsOnKey(KeyboardNames keyName);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern void LogiLedShutdown();
}
using System.Runtime.InteropServices;
// ReSharper disable InconsistentNaming
namespace Artemis.KeyboardProviders.Logitech.Utilities
{
public class LogitechGSDK
{
//LED SDK
private const int LOGI_DEVICETYPE_MONOCHROME_ORD = 0;
private const int LOGI_DEVICETYPE_RGB_ORD = 1;
private const int LOGI_DEVICETYPE_PERKEY_RGB_ORD = 2;
public const int LOGI_DEVICETYPE_MONOCHROME = 1 << LOGI_DEVICETYPE_MONOCHROME_ORD;
public const int LOGI_DEVICETYPE_RGB = 1 << LOGI_DEVICETYPE_RGB_ORD;
public const int LOGI_DEVICETYPE_PERKEY_RGB = 1 << LOGI_DEVICETYPE_PERKEY_RGB_ORD;
public const int LOGI_LED_BITMAP_WIDTH = 21;
public const int LOGI_LED_BITMAP_HEIGHT = 6;
public const int LOGI_LED_BITMAP_BYTES_PER_KEY = 4;
public const int LOGI_LED_BITMAP_SIZE =
LOGI_LED_BITMAP_WIDTH*LOGI_LED_BITMAP_HEIGHT*LOGI_LED_BITMAP_BYTES_PER_KEY;
public const int LOGI_LED_DURATION_INFINITE = 0;
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedInit();
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSetTargetDevice(int targetDevice);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedGetSdkVersion(ref int majorNum, ref int minorNum, ref int buildNum);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSaveCurrentLighting();
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSetLighting(int redPercentage, int greenPercentage, int bluePercentage);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedRestoreLighting();
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedFlashLighting(int redPercentage, int greenPercentage, int bluePercentage,
int milliSecondsDuration, int milliSecondsInterval);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedPulseLighting(int redPercentage, int greenPercentage, int bluePercentage,
int milliSecondsDuration, int milliSecondsInterval);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedStopEffects();
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSetLightingFromBitmap(byte[] bitmap);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSetLightingForKeyWithScanCode(int keyCode, int redPercentage,
int greenPercentage, int bluePercentage);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSetLightingForKeyWithHidCode(int keyCode, int redPercentage,
int greenPercentage, int bluePercentage);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSetLightingForKeyWithQuartzCode(int keyCode, int redPercentage,
int greenPercentage, int bluePercentage);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSetLightingForKeyWithKeyName(int keyCode, int redPercentage,
int greenPercentage, int bluePercentage);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSaveLightingForKey(KeyboardNames keyName);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedRestoreLightingForKey(KeyboardNames keyName);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedFlashSingleKey(KeyboardNames keyName, int redPercentage, int greenPercentage,
int bluePercentage, int msDuration, int msInterval);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedPulseSingleKey(KeyboardNames keyName, int startRedPercentage,
int startGreenPercentage, int startBluePercentage, int finishRedPercentage, int finishGreenPercentage,
int finishBluePercentage, int msDuration, bool isInfinite);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedStopEffectsOnKey(KeyboardNames keyName);
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern void LogiLedShutdown();
}
}

View File

@ -1,230 +1,230 @@
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
namespace Artemis.KeyboardProviders.Logitech.Utilities
{
public static class OrionUtilities
{
public static KeyMapping[] Keymappings =
{
// First row
new KeyMapping(0, 0),
new KeyMapping(1, 1),
new KeyMapping(2, 1),
new KeyMapping(3, 2),
new KeyMapping(4, 3),
new KeyMapping(5, 4),
new KeyMapping(6, 5),
new KeyMapping(7, 6),
new KeyMapping(8, 7),
new KeyMapping(9, 8),
new KeyMapping(10, 9),
new KeyMapping(11, 9),
new KeyMapping(12, 10),
new KeyMapping(13, 11),
new KeyMapping(13, 12),
new KeyMapping(14, 13),
new KeyMapping(15, 14),
new KeyMapping(16, 15),
new KeyMapping(17, 16),
new KeyMapping(18, 17),
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
namespace Artemis.KeyboardProviders.Logitech.Utilities
{
public static class OrionUtilities
{
public static KeyMapping[] Keymappings =
{
// First row
new KeyMapping(0, 0),
new KeyMapping(1, 1),
new KeyMapping(2, 1),
new KeyMapping(3, 2),
new KeyMapping(4, 3),
new KeyMapping(5, 4),
new KeyMapping(6, 5),
new KeyMapping(7, 6),
new KeyMapping(8, 7),
new KeyMapping(9, 8),
new KeyMapping(10, 9),
new KeyMapping(11, 9),
new KeyMapping(12, 10),
new KeyMapping(13, 11),
new KeyMapping(13, 12),
new KeyMapping(14, 13),
new KeyMapping(15, 14),
new KeyMapping(16, 15),
new KeyMapping(17, 16),
new KeyMapping(18, 17),
new KeyMapping(19, 18),
// Second row
new KeyMapping(21, 21),
new KeyMapping(22, 22),
new KeyMapping(23, 23),
new KeyMapping(24, 24),
new KeyMapping(25, 25),
new KeyMapping(26, 26),
new KeyMapping(27, 27),
new KeyMapping(28, 28),
new KeyMapping(29, 29),
new KeyMapping(30, 30),
new KeyMapping(31, 31),
new KeyMapping(32, 32),
new KeyMapping(33, 33),
new KeyMapping(34, 34),
new KeyMapping(35, 35),
new KeyMapping(36, 36),
new KeyMapping(37, 37),
new KeyMapping(38, 38),
new KeyMapping(39, 39),
new KeyMapping(21, 21),
new KeyMapping(22, 22),
new KeyMapping(23, 23),
new KeyMapping(24, 24),
new KeyMapping(25, 25),
new KeyMapping(26, 26),
new KeyMapping(27, 27),
new KeyMapping(28, 28),
new KeyMapping(29, 29),
new KeyMapping(30, 30),
new KeyMapping(31, 31),
new KeyMapping(32, 32),
new KeyMapping(33, 33),
new KeyMapping(34, 34),
new KeyMapping(35, 35),
new KeyMapping(36, 36),
new KeyMapping(37, 37),
new KeyMapping(38, 38),
new KeyMapping(39, 39),
new KeyMapping(40, 40),
new KeyMapping(41, 41),
// Third row
new KeyMapping(42, 42),
new KeyMapping(43, 43),
new KeyMapping(44, 44),
new KeyMapping(45, 45),
new KeyMapping(46, 46),
new KeyMapping(47, 46),
new KeyMapping(48, 47),
new KeyMapping(49, 48),
new KeyMapping(50, 49),
new KeyMapping(51, 50),
new KeyMapping(52, 51),
new KeyMapping(53, 52),
new KeyMapping(54, 53),
new KeyMapping(54, 54),
new KeyMapping(55, 55),
new KeyMapping(56, 56),
new KeyMapping(57, 57),
new KeyMapping(58, 58),
new KeyMapping(59, 59),
new KeyMapping(60, 60),
new KeyMapping(61, 61),
new KeyMapping(62, 62),
// Fourth row
new KeyMapping(63, 63),
new KeyMapping(64, 64),
new KeyMapping(65, 65),
new KeyMapping(66, 65),
new KeyMapping(67, 66),
new KeyMapping(68, 67),
new KeyMapping(69, 68),
new KeyMapping(70, 69),
new KeyMapping(71, 70),
new KeyMapping(72, 71),
new KeyMapping(73, 72),
new KeyMapping(74, 73),
new KeyMapping(75, 74),
new KeyMapping(76, 75),
new KeyMapping(76, 76),
new KeyMapping(78, 77),
new KeyMapping(79, 78),
new KeyMapping(79, 79),
new KeyMapping(80, 80),
new KeyMapping(81, 81),
new KeyMapping(82, 82),
// Fifth row
new KeyMapping(84, 84),
new KeyMapping(85, 85),
new KeyMapping(86, 86),
new KeyMapping(87, 87),
new KeyMapping(88, 88),
new KeyMapping(89, 89),
new KeyMapping(90, 90),
new KeyMapping(91, 91),
new KeyMapping(92, 92),
new KeyMapping(93, 93),
new KeyMapping(94, 94),
new KeyMapping(95, 95),
new KeyMapping(96, 96),
new KeyMapping(97, 97),
new KeyMapping(98, 98),
new KeyMapping(99, 99),
new KeyMapping(100, 100),
new KeyMapping(101, 101),
new KeyMapping(102, 102),
new KeyMapping(103, 103),
new KeyMapping(104, 104),
// Sixth row
new KeyMapping(105, 105),
new KeyMapping(106, 106),
new KeyMapping(107, 107),
new KeyMapping(108, 107),
new KeyMapping(109, 109),
new KeyMapping(110, 110),
new KeyMapping(111, 110),
new KeyMapping(112, 111),
new KeyMapping(113, 112),
new KeyMapping(114, 113),
new KeyMapping(115, 114),
new KeyMapping(116, 115),
new KeyMapping(115, 116), // ALTGR
new KeyMapping(116, 117),
new KeyMapping(117, 118),
new KeyMapping(118, 119),
new KeyMapping(119, 120),
new KeyMapping(120, 121),
new KeyMapping(121, 122),
new KeyMapping(122, 123),
new KeyMapping(124, 124),
};
public static byte[] BitmapToByteArray(Bitmap b, bool remap = true)
{
if (b.Width > 21 || b.Height > 6)
b = ResizeImage(b, 21, 6);
var rect = new Rectangle(0, 0, b.Width, b.Height);
var bitmapData = b.LockBits(rect, ImageLockMode.ReadWrite, b.PixelFormat);
var depth = Image.GetPixelFormatSize(b.PixelFormat);
var step = depth/8;
var pixels = new byte[21*6*step];
var iptr = bitmapData.Scan0;
// Copy data from pointer to array
Marshal.Copy(iptr, pixels, 0, pixels.Length);
if (!remap)
return pixels;
var remapped = new byte[pixels.Length];
// Every key is 4 bytes
for (var i = 0; i <= pixels.Length /4; i++)
{
var firstSByte = Keymappings[i].Source * 4;
var firstTByte = Keymappings[i].Target * 4;
for (var j = 0; j < 4; j++)
remapped[firstTByte + j] = pixels[firstSByte + j];
}
return remapped;
}
/// <summary>
/// Resize the image to the specified width and height.
/// </summary>
/// <param name="image">The image to resize.</param>
/// <param name="width">The width to resize to.</param>
/// <param name="height">The height to resize to.</param>
/// <returns>The resized image.</returns>
public static Bitmap ResizeImage(Image image, int width, int height)
{
var destRect = new Rectangle(0, 0, width, height);
var destImage = new Bitmap(width, height);
destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
using (var graphics = Graphics.FromImage(destImage))
{
graphics.CompositingMode = CompositingMode.SourceCopy;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
using (var wrapMode = new ImageAttributes())
{
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode);
}
}
return destImage;
}
public struct KeyMapping
{
public KeyMapping(int source, int target)
{
Source = source;
Target = target;
}
public int Source { get; set; }
public int Target { get; set; }
}
}
new KeyMapping(42, 42),
new KeyMapping(43, 43),
new KeyMapping(44, 44),
new KeyMapping(45, 45),
new KeyMapping(46, 46),
new KeyMapping(47, 46),
new KeyMapping(48, 47),
new KeyMapping(49, 48),
new KeyMapping(50, 49),
new KeyMapping(51, 50),
new KeyMapping(52, 51),
new KeyMapping(53, 52),
new KeyMapping(54, 53),
new KeyMapping(54, 54),
new KeyMapping(55, 55),
new KeyMapping(56, 56),
new KeyMapping(57, 57),
new KeyMapping(58, 58),
new KeyMapping(59, 59),
new KeyMapping(60, 60),
new KeyMapping(61, 61),
new KeyMapping(62, 62),
// Fourth row
new KeyMapping(63, 63),
new KeyMapping(64, 64),
new KeyMapping(65, 65),
new KeyMapping(66, 65),
new KeyMapping(67, 66),
new KeyMapping(68, 67),
new KeyMapping(69, 68),
new KeyMapping(70, 69),
new KeyMapping(71, 70),
new KeyMapping(72, 71),
new KeyMapping(73, 72),
new KeyMapping(74, 73),
new KeyMapping(75, 74),
new KeyMapping(76, 75),
new KeyMapping(76, 76),
new KeyMapping(78, 77),
new KeyMapping(79, 78),
new KeyMapping(79, 79),
new KeyMapping(80, 80),
new KeyMapping(81, 81),
new KeyMapping(82, 82),
// Fifth row
new KeyMapping(84, 84),
new KeyMapping(85, 85),
new KeyMapping(86, 86),
new KeyMapping(87, 87),
new KeyMapping(88, 88),
new KeyMapping(89, 89),
new KeyMapping(90, 90),
new KeyMapping(91, 91),
new KeyMapping(92, 92),
new KeyMapping(93, 93),
new KeyMapping(94, 94),
new KeyMapping(95, 95),
new KeyMapping(96, 96),
new KeyMapping(97, 97),
new KeyMapping(98, 98),
new KeyMapping(99, 99),
new KeyMapping(100, 100),
new KeyMapping(101, 101),
new KeyMapping(102, 102),
new KeyMapping(103, 103),
new KeyMapping(104, 104),
// Sixth row
new KeyMapping(105, 105),
new KeyMapping(106, 106),
new KeyMapping(107, 107),
new KeyMapping(108, 107),
new KeyMapping(109, 109),
new KeyMapping(110, 110),
new KeyMapping(111, 110),
new KeyMapping(112, 111),
new KeyMapping(113, 112),
new KeyMapping(114, 113),
new KeyMapping(115, 114),
new KeyMapping(116, 115),
new KeyMapping(115, 116), // ALTGR
new KeyMapping(116, 117),
new KeyMapping(117, 118),
new KeyMapping(118, 119),
new KeyMapping(119, 120),
new KeyMapping(120, 121),
new KeyMapping(121, 122),
new KeyMapping(122, 123),
new KeyMapping(124, 124),
};
public static byte[] BitmapToByteArray(Bitmap b, bool remap = true)
{
if (b.Width > 21 || b.Height > 6)
b = ResizeImage(b, 21, 6);
var rect = new Rectangle(0, 0, b.Width, b.Height);
var bitmapData = b.LockBits(rect, ImageLockMode.ReadWrite, b.PixelFormat);
var depth = Image.GetPixelFormatSize(b.PixelFormat);
var step = depth/8;
var pixels = new byte[21*6*step];
var iptr = bitmapData.Scan0;
// Copy data from pointer to array
Marshal.Copy(iptr, pixels, 0, pixels.Length);
if (!remap)
return pixels;
var remapped = new byte[pixels.Length];
// Every key is 4 bytes
for (var i = 0; i <= pixels.Length /4; i++)
{
var firstSByte = Keymappings[i].Source * 4;
var firstTByte = Keymappings[i].Target * 4;
for (var j = 0; j < 4; j++)
remapped[firstTByte + j] = pixels[firstSByte + j];
}
return remapped;
}
/// <summary>
/// Resize the image to the specified width and height.
/// </summary>
/// <param name="image">The image to resize.</param>
/// <param name="width">The width to resize to.</param>
/// <param name="height">The height to resize to.</param>
/// <returns>The resized image.</returns>
public static Bitmap ResizeImage(Image image, int width, int height)
{
var destRect = new Rectangle(0, 0, width, height);
var destImage = new Bitmap(width, height);
destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
using (var graphics = Graphics.FromImage(destImage))
{
graphics.CompositingMode = CompositingMode.SourceCopy;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
using (var wrapMode = new ImageAttributes())
{
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode);
}
}
return destImage;
}
public struct KeyMapping
{
public KeyMapping(int source, int target)
{
Source = source;
Target = target;
}
public int Source { get; set; }
public int Target { get; set; }
}
}
}

View File

@ -1,20 +1,20 @@
using System.Collections.Generic;
using Artemis.KeyboardProviders.Corsair;
using Artemis.KeyboardProviders.Logitech;
using Artemis.KeyboardProviders.Razer;
namespace Artemis.KeyboardProviders
{
public static class ProviderHelper
{
public static List<KeyboardProvider> GetKeyboardProviders()
{
return new List<KeyboardProvider>
{
new CorsairRGB(),
new Orion(),
new BlackWidow()
};
}
}
using System.Collections.Generic;
using Artemis.KeyboardProviders.Corsair;
using Artemis.KeyboardProviders.Logitech;
using Artemis.KeyboardProviders.Razer;
namespace Artemis.KeyboardProviders
{
public static class ProviderHelper
{
public static List<KeyboardProvider> GetKeyboardProviders()
{
return new List<KeyboardProvider>
{
new CorsairRGB(),
new Orion(),
new BlackWidow()
};
}
}
}

View File

@ -1,55 +1,55 @@
using System;
using System.Drawing;
using Artemis.KeyboardProviders.Razer.Utilities;
using Corale.Colore.Core;
using Corale.Colore.Razer.Keyboard;
using ColoreColor = Corale.Colore.Core.Color;
using KeyboardCustom = Corale.Colore.Razer.Keyboard.Effects.Custom;
namespace Artemis.KeyboardProviders.Razer
{
public class BlackWidow : KeyboardProvider
{
public BlackWidow()
{
Name = "Razer BlackWidow Chroma";
CantEnableText = "Couldn't connect to your Razer BlackWidow Chroma.\n " +
"Please check your cables and try updating Razer Synapse.\n\n " +
"If needed, you can select a different keyboard in Artemis under settings.";
}
public override bool CanEnable()
{
if (!Chroma.IsSdkAvailable())
return false;
// Some people have Synapse installed, but not a Chroma keyboard, deal with this
var blackWidowFound = Chroma.Instance.Query(Corale.Colore.Razer.Devices.Blackwidow).Connected;
var blackWidowTeFound = Chroma.Instance.Query(Corale.Colore.Razer.Devices.BlackwidowTe).Connected;
return (blackWidowFound || blackWidowTeFound);
}
public override void Enable()
{
Chroma.Instance.Initialize();
Height = Constants.MaxRows;
Width = Constants.MaxColumns;
using System;
using System.Drawing;
using Artemis.KeyboardProviders.Razer.Utilities;
using Corale.Colore.Core;
using Corale.Colore.Razer.Keyboard;
using ColoreColor = Corale.Colore.Core.Color;
using KeyboardCustom = Corale.Colore.Razer.Keyboard.Effects.Custom;
namespace Artemis.KeyboardProviders.Razer
{
public class BlackWidow : KeyboardProvider
{
public BlackWidow()
{
Name = "Razer BlackWidow Chroma";
CantEnableText = "Couldn't connect to your Razer BlackWidow Chroma.\n " +
"Please check your cables and try updating Razer Synapse.\n\n " +
"If needed, you can select a different keyboard in Artemis under settings.";
}
public override bool CanEnable()
{
if (!Chroma.IsSdkAvailable())
return false;
// Some people have Synapse installed, but not a Chroma keyboard, deal with this
var blackWidowFound = Chroma.Instance.Query(Corale.Colore.Razer.Devices.Blackwidow).Connected;
var blackWidowTeFound = Chroma.Instance.Query(Corale.Colore.Razer.Devices.BlackwidowTe).Connected;
return (blackWidowFound || blackWidowTeFound);
}
public override void Enable()
{
Chroma.Instance.Initialize();
Height = Constants.MaxRows;
Width = Constants.MaxColumns;
KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(0, 0), new Point(19, 0)));
KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(20, 1), new Point(23, 6)));
KeyboardRegions.Add(new KeyboardRegion("QWER", new Point(2, 2), new Point(5, 2)));
}
public override void Disable()
{
Chroma.Instance.Uninitialize();
}
public override void DrawBitmap(Bitmap bitmap)
{
var razerArray = RazerUtilities.BitmapColorArray(bitmap, Height, Width);
Chroma.Instance.Keyboard.SetCustom(razerArray);
}
}
KeyboardRegions.Add(new KeyboardRegion("QWER", new Point(2, 2), new Point(5, 2)));
}
public override void Disable()
{
Chroma.Instance.Uninitialize();
}
public override void DrawBitmap(Bitmap bitmap)
{
var razerArray = RazerUtilities.BitmapColorArray(bitmap, Height, Width);
Chroma.Instance.Keyboard.SetCustom(razerArray);
}
}
}

View File

@ -1,24 +1,24 @@
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using Artemis.Utilities;
using Corale.Colore.Razer.Keyboard.Effects;
namespace Artemis.KeyboardProviders.Razer.Utilities
{
public static class RazerUtilities
{
public static Custom BitmapColorArray(Bitmap b, int height, int width)
{
var keyboardGrid = Custom.Create();
if (b.Width > width || b.Height > height)
b = ImageUtilities.ResizeImage(b, width, height);
for (var y = 0; y < b.Height; y++)
for (var x = 0; x < b.Width; x++)
keyboardGrid[y, x] = b.GetPixel(x, y);
return keyboardGrid;
}
}
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using Artemis.Utilities;
using Corale.Colore.Razer.Keyboard.Effects;
namespace Artemis.KeyboardProviders.Razer.Utilities
{
public static class RazerUtilities
{
public static Custom BitmapColorArray(Bitmap b, int height, int width)
{
var keyboardGrid = Custom.Create();
if (b.Width > width || b.Height > height)
b = ImageUtilities.ResizeImage(b, width, height);
for (var y = 0; y < b.Height; y++)
for (var x = 0; x < b.Width; x++)
keyboardGrid[y, x] = b.GetPixel(x, y);
return keyboardGrid;
}
}
}

View File

@ -1,20 +1,20 @@
namespace Artemis.Models
{
public abstract class EffectSettings
{
/// <summary>
/// Loads the settings from the settings file
/// </summary>
public abstract void Load();
/// <summary>
/// Saves the settings to the settings file
/// </summary>
public abstract void Save();
/// <summary>
/// Returns the settings to their default value
/// </summary>
public abstract void ToDefault();
}
namespace Artemis.Models
{
public abstract class EffectSettings
{
/// <summary>
/// Loads the settings from the settings file
/// </summary>
public abstract void Load();
/// <summary>
/// Saves the settings to the settings file
/// </summary>
public abstract void Save();
/// <summary>
/// Returns the settings to their default value
/// </summary>
public abstract void ToDefault();
}
}

View File

@ -1,14 +1,14 @@
using Artemis.Managers;
namespace Artemis.Models
{
public abstract class GameModel : EffectModel
{
public bool Enabled;
public string ProcessName;
protected GameModel(MainManager mainManager) : base(mainManager)
{
}
}
using Artemis.Managers;
namespace Artemis.Models
{
public abstract class GameModel : EffectModel
{
public bool Enabled;
public string ProcessName;
protected GameModel(MainManager mainManager) : base(mainManager)
{
}
}
}

View File

@ -1,46 +1,46 @@
using System.Drawing;
using Artemis.Managers;
namespace Artemis.Models
{
public abstract class OverlayModel : EffectModel
{
private bool _enabled;
public string ProcessName;
protected OverlayModel(MainManager mainManager) : base(mainManager)
{
}
public bool Enabled
{
get { return _enabled; }
set
{
if (_enabled == value)
return;
if (value)
Enable();
else
Dispose();
_enabled = value;
}
}
public void SetEnabled(bool enabled)
{
if (Enabled == enabled)
return;
if (enabled)
Enable();
else
Dispose();
Enabled = enabled;
}
public abstract Bitmap GenerateBitmap(Bitmap bitmap);
}
using System.Drawing;
using Artemis.Managers;
namespace Artemis.Models
{
public abstract class OverlayModel : EffectModel
{
private bool _enabled;
public string ProcessName;
protected OverlayModel(MainManager mainManager) : base(mainManager)
{
}
public bool Enabled
{
get { return _enabled; }
set
{
if (_enabled == value)
return;
if (value)
Enable();
else
Dispose();
_enabled = value;
}
}
public void SetEnabled(bool enabled)
{
if (Enabled == enabled)
return;
if (enabled)
Enable();
else
Dispose();
Enabled = enabled;
}
public abstract Bitmap GenerateBitmap(Bitmap bitmap);
}
}

View File

@ -1,37 +1,37 @@
using System.Drawing.Drawing2D;
using Artemis.Models;
namespace Artemis.Modules.Effects.AmbientLightning
{
internal class AmbientLightningEffectSettings : EffectSettings
{
public AmbientLightningEffectSettings()
{
Load();
}
public int Width { get; set; }
public int Height { get; set; }
public bool Rotate { get; set; }
public int Scale { get; set; }
public LinearGradientMode Type { get; set; }
public sealed override void Load()
{
ToDefault();
}
public sealed override void Save()
{
}
public sealed override void ToDefault()
{
Width = 84;
Height = 24;
Scale = 4;
Type = LinearGradientMode.Horizontal;
Rotate = true;
}
}
using System.Drawing.Drawing2D;
using Artemis.Models;
namespace Artemis.Modules.Effects.AmbientLightning
{
internal class AmbientLightningEffectSettings : EffectSettings
{
public AmbientLightningEffectSettings()
{
Load();
}
public int Width { get; set; }
public int Height { get; set; }
public bool Rotate { get; set; }
public int Scale { get; set; }
public LinearGradientMode Type { get; set; }
public sealed override void Load()
{
ToDefault();
}
public sealed override void Save()
{
}
public sealed override void ToDefault()
{
Width = 84;
Height = 24;
Scale = 4;
Type = LinearGradientMode.Horizontal;
Rotate = true;
}
}
}

View File

@ -1,32 +1,32 @@
using Artemis.Events;
using Artemis.Managers;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro;
namespace Artemis.Modules.Effects.AmbientLightning
{
internal class AmbientLightningEffectViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
{
public AmbientLightningEffectViewModel(MainManager mainManager)
{
// Subscribe to main model
MainManager = mainManager;
MainManager.Events.Subscribe(this);
// Settings are loaded from file by class
EffectSettings = new AmbientLightningEffectSettings();
// Create effect model and add it to MainManager
EffectModel = new AmbientLightningEffectModel(mainManager, (AmbientLightningEffectSettings) EffectSettings);
MainManager.EffectManager.EffectModels.Add(EffectModel);
}
public static string Name => "Ambient Lightning";
public void Handle(ActiveEffectChanged message)
{
NotifyOfPropertyChange(() => EffectEnabled);
}
}
using Artemis.Events;
using Artemis.Managers;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro;
namespace Artemis.Modules.Effects.AmbientLightning
{
internal class AmbientLightningEffectViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
{
public AmbientLightningEffectViewModel(MainManager mainManager)
{
// Subscribe to main model
MainManager = mainManager;
MainManager.Events.Subscribe(this);
// Settings are loaded from file by class
EffectSettings = new AmbientLightningEffectSettings();
// Create effect model and add it to MainManager
EffectModel = new AmbientLightningEffectModel(mainManager, (AmbientLightningEffectSettings) EffectSettings);
MainManager.EffectManager.EffectModels.Add(EffectModel);
}
public static string Name => "Ambient Lightning";
public void Handle(ActiveEffectChanged message)
{
NotifyOfPropertyChange(() => EffectEnabled);
}
}
}

View File

@ -1,110 +1,110 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Artemis.Modules.Effects.AudioVisualizer {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class AudioVisualization : global::System.Configuration.ApplicationSettingsBase {
private static AudioVisualization defaultInstance = ((AudioVisualization)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new AudioVisualization())));
public static AudioVisualization Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("4")]
public int Sensitivity {
get {
return ((int)(this["Sensitivity"]));
}
set {
this["Sensitivity"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("21")]
public int Bars {
get {
return ((int)(this["Bars"]));
}
set {
this["Bars"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool FromBottom {
get {
return ((bool)(this["FromBottom"]));
}
set {
this["FromBottom"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("3")]
public int FadeSpeed {
get {
return ((int)(this["FadeSpeed"]));
}
set {
this["FadeSpeed"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("#FFF90000")]
public global::System.Windows.Media.Color TopColor {
get {
return ((global::System.Windows.Media.Color)(this["TopColor"]));
}
set {
this["TopColor"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("#FFFF761E")]
public global::System.Windows.Media.Color MiddleColor {
get {
return ((global::System.Windows.Media.Color)(this["MiddleColor"]));
}
set {
this["MiddleColor"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("#FF00DF00")]
public global::System.Windows.Media.Color BottomColor {
get {
return ((global::System.Windows.Media.Color)(this["BottomColor"]));
}
set {
this["BottomColor"] = value;
}
}
}
}
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Artemis.Modules.Effects.AudioVisualizer {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class AudioVisualization : global::System.Configuration.ApplicationSettingsBase {
private static AudioVisualization defaultInstance = ((AudioVisualization)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new AudioVisualization())));
public static AudioVisualization Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("4")]
public int Sensitivity {
get {
return ((int)(this["Sensitivity"]));
}
set {
this["Sensitivity"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("21")]
public int Bars {
get {
return ((int)(this["Bars"]));
}
set {
this["Bars"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool FromBottom {
get {
return ((bool)(this["FromBottom"]));
}
set {
this["FromBottom"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("3")]
public int FadeSpeed {
get {
return ((int)(this["FadeSpeed"]));
}
set {
this["FadeSpeed"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("#FFF90000")]
public global::System.Windows.Media.Color TopColor {
get {
return ((global::System.Windows.Media.Color)(this["TopColor"]));
}
set {
this["TopColor"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("#FFFF761E")]
public global::System.Windows.Media.Color MiddleColor {
get {
return ((global::System.Windows.Media.Color)(this["MiddleColor"]));
}
set {
this["MiddleColor"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("#FF00DF00")]
public global::System.Windows.Media.Color BottomColor {
get {
return ((global::System.Windows.Media.Color)(this["BottomColor"]));
}
set {
this["BottomColor"] = value;
}
}
}
}

View File

@ -1,203 +1,203 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Modules.Effects.AudioVisualizer.Utilities;
using Artemis.Utilities;
using Artemis.Utilities.Keyboard;
using NAudio.CoreAudioApi;
using NAudio.Wave;
namespace Artemis.Modules.Effects.AudioVisualizer
{
public class AudioVisualizerModel : EffectModel
{
private const int FftLength = 2048;
private readonly SampleAggregator _sampleAggregator = new SampleAggregator(FftLength);
private bool _fromBottom;
private bool _generating;
private int _sensitivity;
private IWaveIn _waveIn;
public AudioVisualizerModel(MainManager mainManager, AudioVisualizerSettings settings) : base(mainManager)
{
Settings = settings;
Name = "Audiovisualizer";
DeviceIds = new List<string>();
SpectrumData = new List<byte>();
Scale = 4;
Initialized = false;
}
public int Lines { get; set; }
public int Scale { get; set; }
public AudioVisualizerSettings Settings { get; set; }
public List<byte> SpectrumData { get; set; }
public List<KeyboardRectangle> SoundRectangles { get; set; }
public List<string> DeviceIds { get; set; }
public string SelectedDeviceId { get; set; }
public override void Dispose()
{
Initialized = false;
_sampleAggregator.PerformFFT = false;
_sampleAggregator.FftCalculated -= FftCalculated;
_waveIn.StopRecording();
_waveIn.DataAvailable -= OnDataAvailable;
_waveIn = null;
}
public override void Enable()
{
Initialized = false;
Lines = MainManager.KeyboardManager.ActiveKeyboard.Width;
// TODO: Device selection
SelectedDeviceId = new MMDeviceEnumerator()
.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active)
.FirstOrDefault()?.ID;
// Apply settings
SoundRectangles = new List<KeyboardRectangle>();
for (var i = 0; i < Lines; i++)
{
SoundRectangles.Add(new KeyboardRectangle(
MainManager.KeyboardManager.ActiveKeyboard,
0, 0, new List<Color>
{
ColorHelpers.ToDrawingColor(Settings.TopColor),
ColorHelpers.ToDrawingColor(Settings.MiddleColor),
ColorHelpers.ToDrawingColor(Settings.BottomColor)
},
LinearGradientMode.Vertical) {ContainedBrush = false, Height = 0});
}
_sensitivity = Settings.Sensitivity;
_fromBottom = Settings.FromBottom;
_sampleAggregator.FftCalculated += FftCalculated;
_sampleAggregator.PerformFFT = true;
// Start listening for sound data
_waveIn = new WasapiLoopbackCapture();
_waveIn.DataAvailable += OnDataAvailable;
_waveIn.StartRecording();
Initialized = true;
}
public override void Update()
{
// TODO: Use lock instead of a bool
// Start filling the model
_generating = true;
if (SelectedDeviceId == null)
return;
var device = new MMDeviceEnumerator()
.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active)
.FirstOrDefault(d => d.ID == SelectedDeviceId);
if (device == null || SpectrumData == null)
return;
if (!SpectrumData.Any())
return;
// Parse spectrum data
for (var i = 0; i < Lines; i++)
{
int height;
if (SpectrumData.Count - 1 < i || SpectrumData[i] == 0)
height = 0;
else
height = (int) Math.Round(SpectrumData[i]/2.55);
// Apply Sensitivity setting
height = height*_sensitivity;
var keyboardHeight =
(int) Math.Round(MainManager.KeyboardManager.ActiveKeyboard.Height/100.00*height*Scale);
if (keyboardHeight > SoundRectangles[i].Height)
SoundRectangles[i].Height = keyboardHeight;
else
SoundRectangles[i].Height = SoundRectangles[i].Height - Settings.FadeSpeed;
// Apply Bars setting
SoundRectangles[i].X = i*Scale;
SoundRectangles[i].Width = Scale;
if (_fromBottom)
SoundRectangles[i].Y = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale -
SoundRectangles[i].Height;
}
_generating = false;
}
public override Bitmap GenerateBitmap()
{
if (SpectrumData == null || SoundRectangles == null)
return null;
// Lock the _spectrumData array while busy with it
_generating = true;
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap))
{
foreach (var soundRectangle in SoundRectangles)
soundRectangle.Draw(g);
}
_generating = false;
return bitmap;
}
private void OnDataAvailable(object sender, WaveInEventArgs e)
{
var buffer = e.Buffer;
var bytesRecorded = e.BytesRecorded;
var bufferIncrement = _waveIn.WaveFormat.BlockAlign;
for (var index = 0; index < bytesRecorded; index += bufferIncrement)
{
var sample32 = BitConverter.ToSingle(buffer, index);
_sampleAggregator.Add(sample32);
}
}
private void FftCalculated(object sender, FftEventArgs e)
{
if (_generating)
return;
int x;
var b0 = 0;
SpectrumData.Clear();
for (x = 0; x < Lines; x++)
{
float peak = 0;
var b1 = (int) Math.Pow(2, x*10.0/(Lines - 1));
if (b1 > 2047)
b1 = 2047;
if (b1 <= b0)
b1 = b0 + 1;
for (; b0 < b1; b0++)
{
if (peak < e.Result[1 + b0].X)
peak = e.Result[1 + b0].X;
}
var y = (int) (Math.Sqrt(peak)*3*255 - 4);
if (y > 255)
y = 255;
if (y < 0)
y = 0;
SpectrumData.Add((byte) y);
}
}
}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Modules.Effects.AudioVisualizer.Utilities;
using Artemis.Utilities;
using Artemis.Utilities.Keyboard;
using NAudio.CoreAudioApi;
using NAudio.Wave;
namespace Artemis.Modules.Effects.AudioVisualizer
{
public class AudioVisualizerModel : EffectModel
{
private const int FftLength = 2048;
private readonly SampleAggregator _sampleAggregator = new SampleAggregator(FftLength);
private bool _fromBottom;
private bool _generating;
private int _sensitivity;
private IWaveIn _waveIn;
public AudioVisualizerModel(MainManager mainManager, AudioVisualizerSettings settings) : base(mainManager)
{
Settings = settings;
Name = "Audiovisualizer";
DeviceIds = new List<string>();
SpectrumData = new List<byte>();
Scale = 4;
Initialized = false;
}
public int Lines { get; set; }
public int Scale { get; set; }
public AudioVisualizerSettings Settings { get; set; }
public List<byte> SpectrumData { get; set; }
public List<KeyboardRectangle> SoundRectangles { get; set; }
public List<string> DeviceIds { get; set; }
public string SelectedDeviceId { get; set; }
public override void Dispose()
{
Initialized = false;
_sampleAggregator.PerformFFT = false;
_sampleAggregator.FftCalculated -= FftCalculated;
_waveIn.StopRecording();
_waveIn.DataAvailable -= OnDataAvailable;
_waveIn = null;
}
public override void Enable()
{
Initialized = false;
Lines = MainManager.KeyboardManager.ActiveKeyboard.Width;
// TODO: Device selection
SelectedDeviceId = new MMDeviceEnumerator()
.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active)
.FirstOrDefault()?.ID;
// Apply settings
SoundRectangles = new List<KeyboardRectangle>();
for (var i = 0; i < Lines; i++)
{
SoundRectangles.Add(new KeyboardRectangle(
MainManager.KeyboardManager.ActiveKeyboard,
0, 0, new List<Color>
{
ColorHelpers.ToDrawingColor(Settings.TopColor),
ColorHelpers.ToDrawingColor(Settings.MiddleColor),
ColorHelpers.ToDrawingColor(Settings.BottomColor)
},
LinearGradientMode.Vertical) {ContainedBrush = false, Height = 0});
}
_sensitivity = Settings.Sensitivity;
_fromBottom = Settings.FromBottom;
_sampleAggregator.FftCalculated += FftCalculated;
_sampleAggregator.PerformFFT = true;
// Start listening for sound data
_waveIn = new WasapiLoopbackCapture();
_waveIn.DataAvailable += OnDataAvailable;
_waveIn.StartRecording();
Initialized = true;
}
public override void Update()
{
// TODO: Use lock instead of a bool
// Start filling the model
_generating = true;
if (SelectedDeviceId == null)
return;
var device = new MMDeviceEnumerator()
.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active)
.FirstOrDefault(d => d.ID == SelectedDeviceId);
if (device == null || SpectrumData == null)
return;
if (!SpectrumData.Any())
return;
// Parse spectrum data
for (var i = 0; i < Lines; i++)
{
int height;
if (SpectrumData.Count - 1 < i || SpectrumData[i] == 0)
height = 0;
else
height = (int) Math.Round(SpectrumData[i]/2.55);
// Apply Sensitivity setting
height = height*_sensitivity;
var keyboardHeight =
(int) Math.Round(MainManager.KeyboardManager.ActiveKeyboard.Height/100.00*height*Scale);
if (keyboardHeight > SoundRectangles[i].Height)
SoundRectangles[i].Height = keyboardHeight;
else
SoundRectangles[i].Height = SoundRectangles[i].Height - Settings.FadeSpeed;
// Apply Bars setting
SoundRectangles[i].X = i*Scale;
SoundRectangles[i].Width = Scale;
if (_fromBottom)
SoundRectangles[i].Y = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale -
SoundRectangles[i].Height;
}
_generating = false;
}
public override Bitmap GenerateBitmap()
{
if (SpectrumData == null || SoundRectangles == null)
return null;
// Lock the _spectrumData array while busy with it
_generating = true;
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap))
{
foreach (var soundRectangle in SoundRectangles)
soundRectangle.Draw(g);
}
_generating = false;
return bitmap;
}
private void OnDataAvailable(object sender, WaveInEventArgs e)
{
var buffer = e.Buffer;
var bytesRecorded = e.BytesRecorded;
var bufferIncrement = _waveIn.WaveFormat.BlockAlign;
for (var index = 0; index < bytesRecorded; index += bufferIncrement)
{
var sample32 = BitConverter.ToSingle(buffer, index);
_sampleAggregator.Add(sample32);
}
}
private void FftCalculated(object sender, FftEventArgs e)
{
if (_generating)
return;
int x;
var b0 = 0;
SpectrumData.Clear();
for (x = 0; x < Lines; x++)
{
float peak = 0;
var b1 = (int) Math.Pow(2, x*10.0/(Lines - 1));
if (b1 > 2047)
b1 = 2047;
if (b1 <= b0)
b1 = b0 + 1;
for (; b0 < b1; b0++)
{
if (peak < e.Result[1 + b0].X)
peak = e.Result[1 + b0].X;
}
var y = (int) (Math.Sqrt(peak)*3*255 - 4);
if (y > 255)
y = 255;
if (y < 0)
y = 0;
SpectrumData.Add((byte) y);
}
}
}
}

View File

@ -1,56 +1,56 @@
using System.Windows.Media;
using Artemis.Models;
namespace Artemis.Modules.Effects.AudioVisualizer
{
public class AudioVisualizerSettings : EffectSettings
{
public AudioVisualizerSettings()
{
Load();
}
public int Sensitivity { get; set; }
public int Bars { get; set; }
public bool FromBottom { get; set; }
public int FadeSpeed { get; set; }
public Color TopColor { get; set; }
public Color MiddleColor { get; set; }
public Color BottomColor { get; set; }
public sealed override void Load()
{
Sensitivity = AudioVisualization.Default.Sensitivity;
Bars = AudioVisualization.Default.Bars;
FromBottom = AudioVisualization.Default.FromBottom;
FadeSpeed = AudioVisualization.Default.FadeSpeed;
TopColor = AudioVisualization.Default.TopColor;
MiddleColor = AudioVisualization.Default.MiddleColor;
BottomColor = AudioVisualization.Default.BottomColor;
}
public sealed override void Save()
{
AudioVisualization.Default.Sensitivity = Sensitivity;
AudioVisualization.Default.Bars = Bars;
AudioVisualization.Default.FromBottom = FromBottom;
AudioVisualization.Default.FadeSpeed = FadeSpeed;
AudioVisualization.Default.TopColor = TopColor;
AudioVisualization.Default.MiddleColor = MiddleColor;
AudioVisualization.Default.BottomColor = BottomColor;
AudioVisualization.Default.Save();
}
public sealed override void ToDefault()
{
Sensitivity = 4;
Bars = 21;
FromBottom = true;
FadeSpeed = 3;
TopColor = Color.FromArgb(255, 249, 0, 0);
MiddleColor = Color.FromArgb(255, 255, 118, 30);
BottomColor = Color.FromArgb(255, 0, 223, 0);
}
}
using System.Windows.Media;
using Artemis.Models;
namespace Artemis.Modules.Effects.AudioVisualizer
{
public class AudioVisualizerSettings : EffectSettings
{
public AudioVisualizerSettings()
{
Load();
}
public int Sensitivity { get; set; }
public int Bars { get; set; }
public bool FromBottom { get; set; }
public int FadeSpeed { get; set; }
public Color TopColor { get; set; }
public Color MiddleColor { get; set; }
public Color BottomColor { get; set; }
public sealed override void Load()
{
Sensitivity = AudioVisualization.Default.Sensitivity;
Bars = AudioVisualization.Default.Bars;
FromBottom = AudioVisualization.Default.FromBottom;
FadeSpeed = AudioVisualization.Default.FadeSpeed;
TopColor = AudioVisualization.Default.TopColor;
MiddleColor = AudioVisualization.Default.MiddleColor;
BottomColor = AudioVisualization.Default.BottomColor;
}
public sealed override void Save()
{
AudioVisualization.Default.Sensitivity = Sensitivity;
AudioVisualization.Default.Bars = Bars;
AudioVisualization.Default.FromBottom = FromBottom;
AudioVisualization.Default.FadeSpeed = FadeSpeed;
AudioVisualization.Default.TopColor = TopColor;
AudioVisualization.Default.MiddleColor = MiddleColor;
AudioVisualization.Default.BottomColor = BottomColor;
AudioVisualization.Default.Save();
}
public sealed override void ToDefault()
{
Sensitivity = 4;
Bars = 21;
FromBottom = true;
FadeSpeed = 3;
TopColor = Color.FromArgb(255, 249, 0, 0);
MiddleColor = Color.FromArgb(255, 255, 118, 30);
BottomColor = Color.FromArgb(255, 0, 223, 0);
}
}
}

View File

@ -1,15 +1,15 @@
using System.Windows.Controls;
namespace Artemis.Modules.Effects.AudioVisualizer
{
/// <summary>
/// Interaction logic for AudioVisualizerView.xaml
/// </summary>
public partial class AudioVisualizerView : UserControl
{
public AudioVisualizerView()
{
InitializeComponent();
}
}
using System.Windows.Controls;
namespace Artemis.Modules.Effects.AudioVisualizer
{
/// <summary>
/// Interaction logic for AudioVisualizerView.xaml
/// </summary>
public partial class AudioVisualizerView : UserControl
{
public AudioVisualizerView()
{
InitializeComponent();
}
}
}

View File

@ -1,31 +1,31 @@
using Artemis.Events;
using Artemis.Managers;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro;
namespace Artemis.Modules.Effects.AudioVisualizer
{
public class AudioVisualizerViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
{
public AudioVisualizerViewModel(MainManager mainManager)
{
// Subscribe to main model
MainManager = mainManager;
MainManager.Events.Subscribe(this);
// Settings are loaded from file by class
EffectSettings = new AudioVisualizerSettings();
// Create effect model and add it to MainManager
EffectModel = new AudioVisualizerModel(mainManager, (AudioVisualizerSettings) EffectSettings);
MainManager.EffectManager.EffectModels.Add(EffectModel);
}
public static string Name => "Audio Visualizer";
public void Handle(ActiveEffectChanged message)
{
NotifyOfPropertyChange(() => EffectEnabled);
}
}
using Artemis.Events;
using Artemis.Managers;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro;
namespace Artemis.Modules.Effects.AudioVisualizer
{
public class AudioVisualizerViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
{
public AudioVisualizerViewModel(MainManager mainManager)
{
// Subscribe to main model
MainManager = mainManager;
MainManager.Events.Subscribe(this);
// Settings are loaded from file by class
EffectSettings = new AudioVisualizerSettings();
// Create effect model and add it to MainManager
EffectModel = new AudioVisualizerModel(mainManager, (AudioVisualizerSettings) EffectSettings);
MainManager.EffectManager.EffectModels.Add(EffectModel);
}
public static string Name => "Audio Visualizer";
public void Handle(ActiveEffectChanged message)
{
NotifyOfPropertyChange(() => EffectEnabled);
}
}
}

View File

@ -2,16 +2,16 @@ using System;
using System.Diagnostics;
using NAudio.Dsp;
namespace Artemis.Modules.Effects.AudioVisualizer.Utilities
{
public class FftEventArgs : EventArgs
{
[DebuggerStepThrough]
public FftEventArgs(Complex[] result)
{
Result = result;
}
public Complex[] Result { get; private set; }
}
namespace Artemis.Modules.Effects.AudioVisualizer.Utilities
{
public class FftEventArgs : EventArgs
{
[DebuggerStepThrough]
public FftEventArgs(Complex[] result)
{
Result = result;
}
public Complex[] Result { get; private set; }
}
}

View File

@ -1,55 +1,55 @@
using System;
using NAudio.Dsp;
namespace Artemis.Modules.Effects.AudioVisualizer.Utilities
{ // The Complex and FFT are here!
public class SampleAggregator
{
private readonly FftEventArgs fftArgs;
// This Complex is NAudio's own!
private readonly Complex[] fftBuffer;
private readonly int fftLength;
private readonly int m;
private int fftPos;
public SampleAggregator(int fftLength)
{
if (!IsPowerOfTwo(fftLength))
{
throw new ArgumentException("FFT Length must be a power of two");
}
m = (int) Math.Log(fftLength, 2.0);
this.fftLength = fftLength;
fftBuffer = new Complex[fftLength];
fftArgs = new FftEventArgs(fftBuffer);
}
public bool PerformFFT { get; set; }
// FFT
public event EventHandler<FftEventArgs> FftCalculated;
private bool IsPowerOfTwo(int x)
{
return (x & (x - 1)) == 0;
}
public void Add(float value)
{
if (PerformFFT && FftCalculated != null)
{
// Remember the window function! There are many others as well.
fftBuffer[fftPos].X = (float) (value*FastFourierTransform.HammingWindow(fftPos, fftLength));
fftBuffer[fftPos].Y = 0; // This is always zero with audio.
fftPos++;
if (fftPos >= fftLength)
{
fftPos = 0;
FastFourierTransform.FFT(true, m, fftBuffer);
FftCalculated(this, fftArgs);
}
}
}
}
namespace Artemis.Modules.Effects.AudioVisualizer.Utilities
{ // The Complex and FFT are here!
public class SampleAggregator
{
private readonly FftEventArgs fftArgs;
// This Complex is NAudio's own!
private readonly Complex[] fftBuffer;
private readonly int fftLength;
private readonly int m;
private int fftPos;
public SampleAggregator(int fftLength)
{
if (!IsPowerOfTwo(fftLength))
{
throw new ArgumentException("FFT Length must be a power of two");
}
m = (int) Math.Log(fftLength, 2.0);
this.fftLength = fftLength;
fftBuffer = new Complex[fftLength];
fftArgs = new FftEventArgs(fftBuffer);
}
public bool PerformFFT { get; set; }
// FFT
public event EventHandler<FftEventArgs> FftCalculated;
private bool IsPowerOfTwo(int x)
{
return (x & (x - 1)) == 0;
}
public void Add(float value)
{
if (PerformFFT && FftCalculated != null)
{
// Remember the window function! There are many others as well.
fftBuffer[fftPos].X = (float) (value*FastFourierTransform.HammingWindow(fftPos, fftLength));
fftBuffer[fftPos].Y = 0; // This is always zero with audio.
fftPos++;
if (fftPos >= fftLength)
{
fftPos = 0;
FastFourierTransform.FFT(true, m, fftBuffer);
FftCalculated(this, fftArgs);
}
}
}
}
}

View File

@ -1,71 +1,71 @@
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Utilities.Keyboard;
namespace Artemis.Modules.Effects.Debug
{
internal class DebugEffectModel : EffectModel
{
public DebugEffectModel(MainManager mainManager, DebugEffectSettings settings) : base(mainManager)
{
Name = "Debug Effect";
Settings = settings;
Scale = 4;
Initialized = false;
}
public int Scale { get; set; }
public DebugEffectSettings Settings { get; set; }
public KeyboardRectangle KeyboardRectangle { get; set; }
public override void Dispose()
{
Initialized = false;
}
public override void Enable()
{
Initialized = false;
KeyboardRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>
{
Color.Red,
Color.OrangeRed,
Color.Yellow,
Color.Green,
Color.Blue,
Color.Purple,
Color.DeepPink
}, LinearGradientMode.Horizontal);
Initialized = true;
}
public override void Update()
{
KeyboardRectangle.Height = Settings.Height;
KeyboardRectangle.Width = Settings.Width;
KeyboardRectangle.GradientMode = Settings.Type;
KeyboardRectangle.Rotate = Settings.Rotate;
KeyboardRectangle.Scale = Settings.Scale;
Scale = Settings.Scale;
}
public override Bitmap GenerateBitmap()
{
var bitmap = new Bitmap(21*Scale, 6*Scale);
using (var g = Graphics.FromImage(bitmap))
{
g.Clear(Color.Transparent);
KeyboardRectangle.Draw(g);
}
return bitmap;
}
}
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Utilities.Keyboard;
namespace Artemis.Modules.Effects.Debug
{
internal class DebugEffectModel : EffectModel
{
public DebugEffectModel(MainManager mainManager, DebugEffectSettings settings) : base(mainManager)
{
Name = "Debug Effect";
Settings = settings;
Scale = 4;
Initialized = false;
}
public int Scale { get; set; }
public DebugEffectSettings Settings { get; set; }
public KeyboardRectangle KeyboardRectangle { get; set; }
public override void Dispose()
{
Initialized = false;
}
public override void Enable()
{
Initialized = false;
KeyboardRectangle = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>
{
Color.Red,
Color.OrangeRed,
Color.Yellow,
Color.Green,
Color.Blue,
Color.Purple,
Color.DeepPink
}, LinearGradientMode.Horizontal);
Initialized = true;
}
public override void Update()
{
KeyboardRectangle.Height = Settings.Height;
KeyboardRectangle.Width = Settings.Width;
KeyboardRectangle.GradientMode = Settings.Type;
KeyboardRectangle.Rotate = Settings.Rotate;
KeyboardRectangle.Scale = Settings.Scale;
Scale = Settings.Scale;
}
public override Bitmap GenerateBitmap()
{
var bitmap = new Bitmap(21*Scale, 6*Scale);
using (var g = Graphics.FromImage(bitmap))
{
g.Clear(Color.Transparent);
KeyboardRectangle.Draw(g);
}
return bitmap;
}
}
}

View File

@ -1,37 +1,37 @@
using System.Drawing.Drawing2D;
using Artemis.Models;
namespace Artemis.Modules.Effects.Debug
{
internal class DebugEffectSettings : EffectSettings
{
public DebugEffectSettings()
{
Load();
}
public int Width { get; set; }
public int Height { get; set; }
public bool Rotate { get; set; }
public int Scale { get; set; }
public LinearGradientMode Type { get; set; }
public sealed override void Load()
{
ToDefault();
}
public sealed override void Save()
{
}
public sealed override void ToDefault()
{
Width = 84;
Height = 24;
Scale = 4;
Type = LinearGradientMode.Horizontal;
Rotate = true;
}
}
using System.Drawing.Drawing2D;
using Artemis.Models;
namespace Artemis.Modules.Effects.Debug
{
internal class DebugEffectSettings : EffectSettings
{
public DebugEffectSettings()
{
Load();
}
public int Width { get; set; }
public int Height { get; set; }
public bool Rotate { get; set; }
public int Scale { get; set; }
public LinearGradientMode Type { get; set; }
public sealed override void Load()
{
ToDefault();
}
public sealed override void Save()
{
}
public sealed override void ToDefault()
{
Width = 84;
Height = 24;
Scale = 4;
Type = LinearGradientMode.Horizontal;
Rotate = true;
}
}
}

View File

@ -1,15 +1,15 @@
using System.Windows.Controls;
namespace Artemis.Modules.Effects.Debug
{
/// <summary>
/// Interaction logic for DebugEffectView.xaml
/// </summary>
public partial class DebugEffectView : UserControl
{
public DebugEffectView()
{
InitializeComponent();
}
}
using System.Windows.Controls;
namespace Artemis.Modules.Effects.Debug
{
/// <summary>
/// Interaction logic for DebugEffectView.xaml
/// </summary>
public partial class DebugEffectView : UserControl
{
public DebugEffectView()
{
InitializeComponent();
}
}
}

View File

@ -1,85 +1,85 @@
using System;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Artemis.Events;
using Artemis.Managers;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro;
namespace Artemis.Modules.Effects.Debug
{
internal class DebugEffectViewModel : EffectViewModel, IHandle<ChangeBitmap>, IHandle<ActiveEffectChanged>
{
private ImageSource _imageSource;
private string _selectedRectangleType;
public DebugEffectViewModel(MainManager mainManager)
{
// Subscribe to main model
MainManager = mainManager;
MainManager.Events.Subscribe(this);
// Settings are loaded from file by class
EffectSettings = new DebugEffectSettings();
// Create effect model and add it to MainManager
EffectModel = new DebugEffectModel(mainManager, (DebugEffectSettings) EffectSettings);
MainManager.EffectManager.EffectModels.Add(EffectModel);
}
public static string Name => "Debug Effect";
public BindableCollection<string> RectangleTypes
=> new BindableCollection<string>(Enum.GetNames(typeof (LinearGradientMode)));
public string SelectedRectangleType
{
get { return _selectedRectangleType; }
set
{
if (value == _selectedRectangleType) return;
_selectedRectangleType = value;
NotifyOfPropertyChange(() => SelectedRectangleType);
((DebugEffectSettings) EffectSettings).Type =
(LinearGradientMode) Enum.Parse(typeof (LinearGradientMode), value);
}
}
public ImageSource ImageSource
{
get { return _imageSource; }
set
{
_imageSource = value;
NotifyOfPropertyChange(() => ImageSource);
}
}
public void Handle(ActiveEffectChanged message)
{
NotifyOfPropertyChange(() => EffectEnabled);
}
public void Handle(ChangeBitmap message)
{
using (var memory = new MemoryStream())
{
message.Bitmap.Save(memory, ImageFormat.Png);
memory.Position = 0;
var bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.StreamSource = memory;
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.EndInit();
ImageSource = bitmapImage;
}
}
}
using System;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Artemis.Events;
using Artemis.Managers;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro;
namespace Artemis.Modules.Effects.Debug
{
internal class DebugEffectViewModel : EffectViewModel, IHandle<ChangeBitmap>, IHandle<ActiveEffectChanged>
{
private ImageSource _imageSource;
private string _selectedRectangleType;
public DebugEffectViewModel(MainManager mainManager)
{
// Subscribe to main model
MainManager = mainManager;
MainManager.Events.Subscribe(this);
// Settings are loaded from file by class
EffectSettings = new DebugEffectSettings();
// Create effect model and add it to MainManager
EffectModel = new DebugEffectModel(mainManager, (DebugEffectSettings) EffectSettings);
MainManager.EffectManager.EffectModels.Add(EffectModel);
}
public static string Name => "Debug Effect";
public BindableCollection<string> RectangleTypes
=> new BindableCollection<string>(Enum.GetNames(typeof (LinearGradientMode)));
public string SelectedRectangleType
{
get { return _selectedRectangleType; }
set
{
if (value == _selectedRectangleType) return;
_selectedRectangleType = value;
NotifyOfPropertyChange(() => SelectedRectangleType);
((DebugEffectSettings) EffectSettings).Type =
(LinearGradientMode) Enum.Parse(typeof (LinearGradientMode), value);
}
}
public ImageSource ImageSource
{
get { return _imageSource; }
set
{
_imageSource = value;
NotifyOfPropertyChange(() => ImageSource);
}
}
public void Handle(ActiveEffectChanged message)
{
NotifyOfPropertyChange(() => EffectEnabled);
}
public void Handle(ChangeBitmap message)
{
using (var memory = new MemoryStream())
{
message.Bitmap.Save(memory, ImageFormat.Png);
memory.Position = 0;
var bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.StreamSource = memory;
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.EndInit();
ImageSource = bitmapImage;
}
}
}
}

View File

@ -1,40 +1,40 @@
using System.Drawing;
using Artemis.Managers;
using Artemis.Models;
namespace Artemis.Modules.Effects.TypeHole
{
public class TypeHoleModel : EffectModel
{
public TypeHoleModel(MainManager mainManager) : base(mainManager)
{
Name = "TypeHole";
Initialized = false;
}
public override void Dispose()
{
Initialized = false;
// Disable logic
}
public override void Enable()
{
Initialized = false;
// Enable logic
Initialized = true;
}
public override void Update()
{
}
public override Bitmap GenerateBitmap()
{
return null;
}
}
using System.Drawing;
using Artemis.Managers;
using Artemis.Models;
namespace Artemis.Modules.Effects.TypeHole
{
public class TypeHoleModel : EffectModel
{
public TypeHoleModel(MainManager mainManager) : base(mainManager)
{
Name = "TypeHole";
Initialized = false;
}
public override void Dispose()
{
Initialized = false;
// Disable logic
}
public override void Enable()
{
Initialized = false;
// Enable logic
Initialized = true;
}
public override void Update()
{
}
public override Bitmap GenerateBitmap()
{
return null;
}
}
}

View File

@ -1,15 +1,15 @@
using System.Windows.Controls;
namespace Artemis.Modules.Effects.TypeHole
{
/// <summary>
/// Interaction logic for TypeHoleView.xaml
/// </summary>
public partial class TypeHoleView : UserControl
{
public TypeHoleView()
{
InitializeComponent();
}
}
using System.Windows.Controls;
namespace Artemis.Modules.Effects.TypeHole
{
/// <summary>
/// Interaction logic for TypeHoleView.xaml
/// </summary>
public partial class TypeHoleView : UserControl
{
public TypeHoleView()
{
InitializeComponent();
}
}
}

View File

@ -1,28 +1,28 @@
using Artemis.Events;
using Artemis.Managers;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro;
namespace Artemis.Modules.Effects.TypeHole
{
public class TypeHoleViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
{
public TypeHoleViewModel(MainManager mainManager)
{
// Subscribe to main model
MainManager = mainManager;
MainManager.Events.Subscribe(this);
// Create effect model and add it to MainManager
EffectModel = new TypeHoleModel(mainManager);
MainManager.EffectManager.EffectModels.Add(EffectModel);
}
public static string Name => "Type Holes (NYI)";
public void Handle(ActiveEffectChanged message)
{
NotifyOfPropertyChange(() => EffectEnabled);
}
}
using Artemis.Events;
using Artemis.Managers;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro;
namespace Artemis.Modules.Effects.TypeHole
{
public class TypeHoleViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
{
public TypeHoleViewModel(MainManager mainManager)
{
// Subscribe to main model
MainManager = mainManager;
MainManager.Events.Subscribe(this);
// Create effect model and add it to MainManager
EffectModel = new TypeHoleModel(mainManager);
MainManager.EffectManager.EffectModels.Add(EffectModel);
}
public static string Name => "Type Holes (NYI)";
public void Handle(ActiveEffectChanged message)
{
NotifyOfPropertyChange(() => EffectEnabled);
}
}
}

View File

@ -1,98 +1,98 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Artemis.Settings {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class TypeWave : global::System.Configuration.ApplicationSettingsBase {
private static TypeWave defaultInstance = ((TypeWave)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new TypeWave())));
public static TypeWave Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool IsRandomColors {
get {
return ((bool)(this["IsRandomColors"]));
}
set {
this["IsRandomColors"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("#FFFF0000")]
public global::System.Windows.Media.Color WaveColor {
get {
return ((global::System.Windows.Media.Color)(this["WaveColor"]));
}
set {
this["WaveColor"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool IsShiftColors {
get {
return ((bool)(this["IsShiftColors"]));
}
set {
this["IsShiftColors"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("20")]
public int ShiftColorSpeed {
get {
return ((int)(this["ShiftColorSpeed"]));
}
set {
this["ShiftColorSpeed"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("500")]
public int TimeToLive {
get {
return ((int)(this["TimeToLive"]));
}
set {
this["TimeToLive"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("4")]
public int SpreadSpeed {
get {
return ((int)(this["SpreadSpeed"]));
}
set {
this["SpreadSpeed"] = value;
}
}
}
}
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Artemis.Settings {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class TypeWave : global::System.Configuration.ApplicationSettingsBase {
private static TypeWave defaultInstance = ((TypeWave)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new TypeWave())));
public static TypeWave Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool IsRandomColors {
get {
return ((bool)(this["IsRandomColors"]));
}
set {
this["IsRandomColors"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("#FFFF0000")]
public global::System.Windows.Media.Color WaveColor {
get {
return ((global::System.Windows.Media.Color)(this["WaveColor"]));
}
set {
this["WaveColor"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool IsShiftColors {
get {
return ((bool)(this["IsShiftColors"]));
}
set {
this["IsShiftColors"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("20")]
public int ShiftColorSpeed {
get {
return ((int)(this["ShiftColorSpeed"]));
}
set {
this["ShiftColorSpeed"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("500")]
public int TimeToLive {
get {
return ((int)(this["TimeToLive"]));
}
set {
this["TimeToLive"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("4")]
public int SpreadSpeed {
get {
return ((int)(this["SpreadSpeed"]));
}
set {
this["SpreadSpeed"] = value;
}
}
}
}

View File

@ -1,152 +1,152 @@
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Windows.Forms;
using Artemis.KeyboardProviders.Corsair;
using Artemis.KeyboardProviders.Logitech.Utilities;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Utilities;
namespace Artemis.Modules.Effects.TypeWave
{
public class TypeWaveModel : EffectModel
{
private readonly List<Wave> _waves;
private Color _randomColor;
public TypeWaveModel(MainManager mainManager, TypeWaveSettings settings) : base(mainManager)
{
Name = "TypeWave";
_waves = new List<Wave>();
_randomColor = Color.Red;
Settings = settings;
Initialized = false;
Scale = 4;
}
public int Scale { get; set; }
public TypeWaveSettings Settings { get; set; }
public override void Dispose()
{
Initialized = false;
MainManager.KeyboardHook.KeyDownCallback -= KeyboardHookOnKeyDownCallback;
}
private void KeyboardHookOnKeyDownCallback(KeyEventArgs e)
{
// More than 25 waves is pointless
if (_waves.Count >= 25)
return;
var keyMatch = KeyMap.UsEnglishOrionKeys.FirstOrDefault(k => k.KeyCode == e.KeyCode);
if (keyMatch == null)
return;
_waves.Add(Settings.IsRandomColors
? new Wave(new Point(keyMatch.PosX * Scale, keyMatch.PosY * Scale), 0, _randomColor)
: new Wave(new Point(keyMatch.PosX * Scale, keyMatch.PosY * Scale), 0,
ColorHelpers.ToDrawingColor(Settings.WaveColor)));
}
public override void Enable()
{
Initialized = false;
// Listener won't start unless the effect is active
MainManager.KeyboardHook.KeyDownCallback += KeyboardHookOnKeyDownCallback;
Initialized = true;
}
public override void Update()
{
if (Settings.IsRandomColors)
_randomColor = ColorHelpers.ShiftColor(_randomColor, 25);
for (var i = 0; i < _waves.Count; i++)
{
// TODO: Get from settings
var fps = 25;
_waves[i].Size += Settings.SpreadSpeed * Scale;
if (Settings.IsShiftColors)
_waves[i].Color = ColorHelpers.ShiftColor(_waves[i].Color, Settings.ShiftColorSpeed);
var decreaseAmount = 255/(Settings.TimeToLive/fps);
_waves[i].Color = Color.FromArgb(
_waves[i].Color.A - decreaseAmount, _waves[i].Color.R,
_waves[i].Color.G,
_waves[i].Color.B);
if (_waves[i].Color.A >= decreaseAmount)
continue;
_waves.RemoveAt(i);
i--;
}
}
public override Bitmap GenerateBitmap()
{
if (_waves.Count == 0)
return null;
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap))
{
g.Clear(Color.Transparent);
g.SmoothingMode = SmoothingMode.HighQuality;
// Don't want a for-each, collection is changed in different thread
// ReSharper disable once ForCanBeConvertedToForeach
for (var i = 0; i < _waves.Count; i++)
{
if (_waves[i].Size == 0)
continue;
var path = new GraphicsPath();
path.AddEllipse(_waves[i].Point.X - _waves[i].Size/2, _waves[i].Point.Y - _waves[i].Size/2,
_waves[i].Size, _waves[i].Size);
Color fillColor;
if (MainManager.KeyboardManager.ActiveKeyboard is CorsairRGB)
fillColor = Color.Black;
else
fillColor = Color.Transparent;
var pthGrBrush = new PathGradientBrush(path)
{
SurroundColors = new[] {_waves[i].Color},
CenterColor = fillColor
};
g.FillPath(pthGrBrush, path);
pthGrBrush.FocusScales = new PointF(0.3f, 0.8f);
g.FillPath(pthGrBrush, path);
g.DrawEllipse(new Pen(pthGrBrush, 1), _waves[i].Point.X - _waves[i].Size/2,
_waves[i].Point.Y - _waves[i].Size/2, _waves[i].Size, _waves[i].Size);
}
}
return bitmap;
}
}
public class Wave
{
public Wave(Point point, int size, Color color)
{
Point = point;
Size = size;
Color = color;
}
public Point Point { get; set; }
public int Size { get; set; }
public Color Color { get; set; }
}
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Windows.Forms;
using Artemis.KeyboardProviders.Corsair;
using Artemis.KeyboardProviders.Logitech.Utilities;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Utilities;
namespace Artemis.Modules.Effects.TypeWave
{
public class TypeWaveModel : EffectModel
{
private readonly List<Wave> _waves;
private Color _randomColor;
public TypeWaveModel(MainManager mainManager, TypeWaveSettings settings) : base(mainManager)
{
Name = "TypeWave";
_waves = new List<Wave>();
_randomColor = Color.Red;
Settings = settings;
Initialized = false;
Scale = 4;
}
public int Scale { get; set; }
public TypeWaveSettings Settings { get; set; }
public override void Dispose()
{
Initialized = false;
MainManager.KeyboardHook.KeyDownCallback -= KeyboardHookOnKeyDownCallback;
}
private void KeyboardHookOnKeyDownCallback(KeyEventArgs e)
{
// More than 25 waves is pointless
if (_waves.Count >= 25)
return;
var keyMatch = KeyMap.UsEnglishOrionKeys.FirstOrDefault(k => k.KeyCode == e.KeyCode);
if (keyMatch == null)
return;
_waves.Add(Settings.IsRandomColors
? new Wave(new Point(keyMatch.PosX * Scale, keyMatch.PosY * Scale), 0, _randomColor)
: new Wave(new Point(keyMatch.PosX * Scale, keyMatch.PosY * Scale), 0,
ColorHelpers.ToDrawingColor(Settings.WaveColor)));
}
public override void Enable()
{
Initialized = false;
// Listener won't start unless the effect is active
MainManager.KeyboardHook.KeyDownCallback += KeyboardHookOnKeyDownCallback;
Initialized = true;
}
public override void Update()
{
if (Settings.IsRandomColors)
_randomColor = ColorHelpers.ShiftColor(_randomColor, 25);
for (var i = 0; i < _waves.Count; i++)
{
// TODO: Get from settings
var fps = 25;
_waves[i].Size += Settings.SpreadSpeed * Scale;
if (Settings.IsShiftColors)
_waves[i].Color = ColorHelpers.ShiftColor(_waves[i].Color, Settings.ShiftColorSpeed);
var decreaseAmount = 255/(Settings.TimeToLive/fps);
_waves[i].Color = Color.FromArgb(
_waves[i].Color.A - decreaseAmount, _waves[i].Color.R,
_waves[i].Color.G,
_waves[i].Color.B);
if (_waves[i].Color.A >= decreaseAmount)
continue;
_waves.RemoveAt(i);
i--;
}
}
public override Bitmap GenerateBitmap()
{
if (_waves.Count == 0)
return null;
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap))
{
g.Clear(Color.Transparent);
g.SmoothingMode = SmoothingMode.HighQuality;
// Don't want a for-each, collection is changed in different thread
// ReSharper disable once ForCanBeConvertedToForeach
for (var i = 0; i < _waves.Count; i++)
{
if (_waves[i].Size == 0)
continue;
var path = new GraphicsPath();
path.AddEllipse(_waves[i].Point.X - _waves[i].Size/2, _waves[i].Point.Y - _waves[i].Size/2,
_waves[i].Size, _waves[i].Size);
Color fillColor;
if (MainManager.KeyboardManager.ActiveKeyboard is CorsairRGB)
fillColor = Color.Black;
else
fillColor = Color.Transparent;
var pthGrBrush = new PathGradientBrush(path)
{
SurroundColors = new[] {_waves[i].Color},
CenterColor = fillColor
};
g.FillPath(pthGrBrush, path);
pthGrBrush.FocusScales = new PointF(0.3f, 0.8f);
g.FillPath(pthGrBrush, path);
g.DrawEllipse(new Pen(pthGrBrush, 1), _waves[i].Point.X - _waves[i].Size/2,
_waves[i].Point.Y - _waves[i].Size/2, _waves[i].Size, _waves[i].Size);
}
}
return bitmap;
}
}
public class Wave
{
public Wave(Point point, int size, Color color)
{
Point = point;
Size = size;
Color = color;
}
public Point Point { get; set; }
public int Size { get; set; }
public Color Color { get; set; }
}
}

View File

@ -1,52 +1,52 @@
using System.Windows.Media;
using Artemis.Models;
namespace Artemis.Modules.Effects.TypeWave
{
public class TypeWaveSettings : EffectSettings
{
public TypeWaveSettings()
{
Load();
}
public bool IsRandomColors { get; set; }
public Color WaveColor { get; set; }
public bool IsShiftColors { get; set; }
public int ShiftColorSpeed { get; set; }
public int TimeToLive { get; set; }
public int SpreadSpeed { get; set; }
public sealed override void Load()
{
IsRandomColors = Settings.TypeWave.Default.IsRandomColors;
WaveColor = Settings.TypeWave.Default.WaveColor;
IsShiftColors = Settings.TypeWave.Default.IsShiftColors;
ShiftColorSpeed = Settings.TypeWave.Default.ShiftColorSpeed;
TimeToLive = Settings.TypeWave.Default.TimeToLive;
SpreadSpeed = Settings.TypeWave.Default.SpreadSpeed;
}
public sealed override void Save()
{
Settings.TypeWave.Default.IsRandomColors = IsRandomColors;
Settings.TypeWave.Default.WaveColor = WaveColor;
Settings.TypeWave.Default.IsShiftColors = IsShiftColors;
Settings.TypeWave.Default.ShiftColorSpeed = ShiftColorSpeed;
Settings.TypeWave.Default.TimeToLive = TimeToLive;
Settings.TypeWave.Default.SpreadSpeed = SpreadSpeed;
Settings.TypeWave.Default.Save();
}
public sealed override void ToDefault()
{
IsRandomColors = true;
WaveColor = Color.FromArgb(255, 255, 0, 0);
IsShiftColors = true;
ShiftColorSpeed = 20;
TimeToLive = 500;
SpreadSpeed = 4;
}
}
using System.Windows.Media;
using Artemis.Models;
namespace Artemis.Modules.Effects.TypeWave
{
public class TypeWaveSettings : EffectSettings
{
public TypeWaveSettings()
{
Load();
}
public bool IsRandomColors { get; set; }
public Color WaveColor { get; set; }
public bool IsShiftColors { get; set; }
public int ShiftColorSpeed { get; set; }
public int TimeToLive { get; set; }
public int SpreadSpeed { get; set; }
public sealed override void Load()
{
IsRandomColors = Settings.TypeWave.Default.IsRandomColors;
WaveColor = Settings.TypeWave.Default.WaveColor;
IsShiftColors = Settings.TypeWave.Default.IsShiftColors;
ShiftColorSpeed = Settings.TypeWave.Default.ShiftColorSpeed;
TimeToLive = Settings.TypeWave.Default.TimeToLive;
SpreadSpeed = Settings.TypeWave.Default.SpreadSpeed;
}
public sealed override void Save()
{
Settings.TypeWave.Default.IsRandomColors = IsRandomColors;
Settings.TypeWave.Default.WaveColor = WaveColor;
Settings.TypeWave.Default.IsShiftColors = IsShiftColors;
Settings.TypeWave.Default.ShiftColorSpeed = ShiftColorSpeed;
Settings.TypeWave.Default.TimeToLive = TimeToLive;
Settings.TypeWave.Default.SpreadSpeed = SpreadSpeed;
Settings.TypeWave.Default.Save();
}
public sealed override void ToDefault()
{
IsRandomColors = true;
WaveColor = Color.FromArgb(255, 255, 0, 0);
IsShiftColors = true;
ShiftColorSpeed = 20;
TimeToLive = 500;
SpreadSpeed = 4;
}
}
}

View File

@ -1,15 +1,15 @@
using System.Windows.Controls;
namespace Artemis.Modules.Effects.TypeWave
{
/// <summary>
/// Interaction logic for TypeWaveView.xaml
/// </summary>
public partial class TypeWaveView : UserControl
{
public TypeWaveView()
{
InitializeComponent();
}
}
using System.Windows.Controls;
namespace Artemis.Modules.Effects.TypeWave
{
/// <summary>
/// Interaction logic for TypeWaveView.xaml
/// </summary>
public partial class TypeWaveView : UserControl
{
public TypeWaveView()
{
InitializeComponent();
}
}
}

View File

@ -1,31 +1,31 @@
using Artemis.Events;
using Artemis.Managers;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro;
namespace Artemis.Modules.Effects.TypeWave
{
public class TypeWaveViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
{
public TypeWaveViewModel(MainManager mainManager)
{
// Subscribe to main model
MainManager = mainManager;
MainManager.Events.Subscribe(this);
// Settings are loaded from file by class
EffectSettings = new TypeWaveSettings();
// Create effect model and add it to MainManager
EffectModel = new TypeWaveModel(mainManager, (TypeWaveSettings) EffectSettings);
MainManager.EffectManager.EffectModels.Add(EffectModel);
}
public static string Name => "Type Waves";
public void Handle(ActiveEffectChanged message)
{
NotifyOfPropertyChange(() => EffectEnabled);
}
}
using Artemis.Events;
using Artemis.Managers;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro;
namespace Artemis.Modules.Effects.TypeWave
{
public class TypeWaveViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
{
public TypeWaveViewModel(MainManager mainManager)
{
// Subscribe to main model
MainManager = mainManager;
MainManager.Events.Subscribe(this);
// Settings are loaded from file by class
EffectSettings = new TypeWaveSettings();
// Create effect model and add it to MainManager
EffectModel = new TypeWaveModel(mainManager, (TypeWaveSettings) EffectSettings);
MainManager.EffectManager.EffectModels.Add(EffectModel);
}
public static string Name => "Type Waves";
public void Handle(ActiveEffectChanged message)
{
NotifyOfPropertyChange(() => EffectEnabled);
}
}
}

View File

@ -1,209 +1,209 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using Artemis.KeyboardProviders;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Utilities;
using Artemis.Utilities.GameState;
using Artemis.Utilities.Keyboard;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Artemis.Modules.Games.CounterStrike
{
public class CounterStrikeModel : GameModel
{
private KeyboardRegion _topRow;
public CounterStrikeModel(MainManager mainManager, CounterStrikeSettings settings) : base(mainManager)
{
Settings = settings;
Name = "CounterStrike";
ProcessName = "csgo";
Scale = 4;
Enabled = Settings.Enabled;
Initialized = false;
}
public CounterStrikeSettings Settings { get; set; }
public KeyboardRectangle EventRect { get; set; }
public KeyboardRectangle TeamRect { get; set; }
public KeyboardRectangle AmmoRect { get; set; }
public JObject CsJson { get; set; }
public bool DrawingSmoke { get; set; }
public bool DrawingFlash { get; set; }
public int Scale { get; set; }
public override void Dispose()
{
Initialized = false;
MainManager.GameStateWebServer.GameDataReceived -= HandleGameData;
}
public override void Enable()
{
Initialized = false;
// Some keyboards have a different baseline, Corsair F-keys start at row 1
_topRow = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow");
AmmoRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, _topRow.TopLeft.X,
new List<Color>(),
LinearGradientMode.Horizontal) {Height = Scale, ContainedBrush = false};
TeamRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, _topRow.TopLeft.X + 1,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale - Scale
};
EventRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, _topRow.TopLeft.X + 1,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale - Scale
};
MainManager.GameStateWebServer.GameDataReceived += HandleGameData;
Initialized = true;
}
public override void Update()
{
if (CsJson == null)
return;
if (Settings.AmmoEnabled)
UpdateAmmo();
if (Settings.TeamColorEnabled)
UpdateTeam();
if (Settings.LowHpEnabled)
UpdateHealth();
if (Settings.FlashEnabled)
UpdateFlash();
if (Settings.SmokeEnabled)
UpdateSmoke();
}
private void UpdateHealth()
{
if (CsJson["player"]?["state"]?["health"] == null)
return;
var health = CsJson["player"]["state"]["health"].Value<int>();
if (health > 25 || health < 1)
return;
TeamRect.Colors = new List<Color> {Color.Red, Color.OrangeRed, Color.Red, Color.OrangeRed};
}
private void UpdateSmoke()
{
if (CsJson["player"]?["state"]?["smoked"] == null)
return;
var smoked = CsJson["player"]["state"]["smoked"].Value<int>();
if (smoked == 0 && !DrawingSmoke)
return;
EventRect.Colors = new List<Color> {Color.FromArgb(smoked, 255, 255, 255)};
DrawingSmoke = smoked != 0;
}
private void UpdateFlash()
{
if (CsJson["player"]?["state"]?["flashed"] == null)
return;
var flashed = CsJson["player"]["state"]["flashed"].Value<int>();
if (flashed == 0 && !DrawingFlash)
return;
EventRect.Colors = new List<Color> {Color.FromArgb(flashed, 255, 255, 255)};
DrawingFlash = flashed != 0;
}
private void UpdateTeam()
{
var currentTeam = CsJson["player"]?["team"];
if (currentTeam == null)
return;
var t1 = Color.FromArgb(255, 255, 129, 0);
var t2 = Color.FromArgb(255, 255, 170, 125);
var ct1 = Color.FromArgb(255, 203, 238, 255);
var ct2 = Color.FromArgb(255, 0, 173, 255);
TeamRect.Colors = currentTeam.Value<string>() == "T"
? new List<Color> {t1, t2, t1, t2}
: new List<Color> {ct1, ct2, ct1, ct2};
TeamRect.Rotate = true;
}
private void UpdateAmmo()
{
if (CsJson["player"]["weapons"] == null)
return;
var activeWeapon =
CsJson["player"]["weapons"].Children()
.Select(c => c.First)
.FirstOrDefault(w => w["state"]?.Value<string>() == "active");
// Update the ammo display
if (activeWeapon?["ammo_clip_max"] == null || activeWeapon["ammo_clip"] == null)
return;
var maxAmmo = activeWeapon["ammo_clip_max"].Value<int>();
var ammo = activeWeapon["ammo_clip"].Value<int>();
if (maxAmmo < 0)
return;
var ammoPercentage = (int) Math.Ceiling(100.00/maxAmmo)*ammo;
AmmoRect.Width = (int) Math.Floor(_topRow.BottomRight.Y/100.00*ammoPercentage)*Scale;
AmmoRect.Colors = new List<Color>
{
ColorHelpers.ToDrawingColor(Settings.AmmoMainColor),
ColorHelpers.ToDrawingColor(Settings.AmmoSecondaryColor)
};
// Low ammo indicator
if (ammoPercentage < 37)
AmmoRect.StartBlink(1000);
else
AmmoRect.StopBlink();
}
public override Bitmap GenerateBitmap()
{
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap))
{
g.Clear(Color.Transparent);
AmmoRect.Draw(g);
TeamRect.Draw(g);
EventRect.Draw(g);
}
return bitmap;
}
public void HandleGameData(object sender, GameDataReceivedEventArgs e)
{
var jsonString = e.Json.ToString();
// Ensure it's CS:GO JSON
if (!jsonString.Contains("Counter-Strike: Global Offensive"))
return;
// Parse the JSON
CsJson = JsonConvert.DeserializeObject<JObject>(jsonString);
}
}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using Artemis.KeyboardProviders;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Utilities;
using Artemis.Utilities.GameState;
using Artemis.Utilities.Keyboard;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Artemis.Modules.Games.CounterStrike
{
public class CounterStrikeModel : GameModel
{
private KeyboardRegion _topRow;
public CounterStrikeModel(MainManager mainManager, CounterStrikeSettings settings) : base(mainManager)
{
Settings = settings;
Name = "CounterStrike";
ProcessName = "csgo";
Scale = 4;
Enabled = Settings.Enabled;
Initialized = false;
}
public CounterStrikeSettings Settings { get; set; }
public KeyboardRectangle EventRect { get; set; }
public KeyboardRectangle TeamRect { get; set; }
public KeyboardRectangle AmmoRect { get; set; }
public JObject CsJson { get; set; }
public bool DrawingSmoke { get; set; }
public bool DrawingFlash { get; set; }
public int Scale { get; set; }
public override void Dispose()
{
Initialized = false;
MainManager.GameStateWebServer.GameDataReceived -= HandleGameData;
}
public override void Enable()
{
Initialized = false;
// Some keyboards have a different baseline, Corsair F-keys start at row 1
_topRow = MainManager.KeyboardManager.ActiveKeyboard.KeyboardRegions.First(r => r.RegionName == "TopRow");
AmmoRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, _topRow.TopLeft.X,
new List<Color>(),
LinearGradientMode.Horizontal) {Height = Scale, ContainedBrush = false};
TeamRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, _topRow.TopLeft.X + 1,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale - Scale
};
EventRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, _topRow.TopLeft.X + 1,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = MainManager.KeyboardManager.ActiveKeyboard.Height*Scale - Scale
};
MainManager.GameStateWebServer.GameDataReceived += HandleGameData;
Initialized = true;
}
public override void Update()
{
if (CsJson == null)
return;
if (Settings.AmmoEnabled)
UpdateAmmo();
if (Settings.TeamColorEnabled)
UpdateTeam();
if (Settings.LowHpEnabled)
UpdateHealth();
if (Settings.FlashEnabled)
UpdateFlash();
if (Settings.SmokeEnabled)
UpdateSmoke();
}
private void UpdateHealth()
{
if (CsJson["player"]?["state"]?["health"] == null)
return;
var health = CsJson["player"]["state"]["health"].Value<int>();
if (health > 25 || health < 1)
return;
TeamRect.Colors = new List<Color> {Color.Red, Color.OrangeRed, Color.Red, Color.OrangeRed};
}
private void UpdateSmoke()
{
if (CsJson["player"]?["state"]?["smoked"] == null)
return;
var smoked = CsJson["player"]["state"]["smoked"].Value<int>();
if (smoked == 0 && !DrawingSmoke)
return;
EventRect.Colors = new List<Color> {Color.FromArgb(smoked, 255, 255, 255)};
DrawingSmoke = smoked != 0;
}
private void UpdateFlash()
{
if (CsJson["player"]?["state"]?["flashed"] == null)
return;
var flashed = CsJson["player"]["state"]["flashed"].Value<int>();
if (flashed == 0 && !DrawingFlash)
return;
EventRect.Colors = new List<Color> {Color.FromArgb(flashed, 255, 255, 255)};
DrawingFlash = flashed != 0;
}
private void UpdateTeam()
{
var currentTeam = CsJson["player"]?["team"];
if (currentTeam == null)
return;
var t1 = Color.FromArgb(255, 255, 129, 0);
var t2 = Color.FromArgb(255, 255, 170, 125);
var ct1 = Color.FromArgb(255, 203, 238, 255);
var ct2 = Color.FromArgb(255, 0, 173, 255);
TeamRect.Colors = currentTeam.Value<string>() == "T"
? new List<Color> {t1, t2, t1, t2}
: new List<Color> {ct1, ct2, ct1, ct2};
TeamRect.Rotate = true;
}
private void UpdateAmmo()
{
if (CsJson["player"]["weapons"] == null)
return;
var activeWeapon =
CsJson["player"]["weapons"].Children()
.Select(c => c.First)
.FirstOrDefault(w => w["state"]?.Value<string>() == "active");
// Update the ammo display
if (activeWeapon?["ammo_clip_max"] == null || activeWeapon["ammo_clip"] == null)
return;
var maxAmmo = activeWeapon["ammo_clip_max"].Value<int>();
var ammo = activeWeapon["ammo_clip"].Value<int>();
if (maxAmmo < 0)
return;
var ammoPercentage = (int) Math.Ceiling(100.00/maxAmmo)*ammo;
AmmoRect.Width = (int) Math.Floor(_topRow.BottomRight.Y/100.00*ammoPercentage)*Scale;
AmmoRect.Colors = new List<Color>
{
ColorHelpers.ToDrawingColor(Settings.AmmoMainColor),
ColorHelpers.ToDrawingColor(Settings.AmmoSecondaryColor)
};
// Low ammo indicator
if (ammoPercentage < 37)
AmmoRect.StartBlink(1000);
else
AmmoRect.StopBlink();
}
public override Bitmap GenerateBitmap()
{
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap))
{
g.Clear(Color.Transparent);
AmmoRect.Draw(g);
TeamRect.Draw(g);
EventRect.Draw(g);
}
return bitmap;
}
public void HandleGameData(object sender, GameDataReceivedEventArgs e)
{
var jsonString = e.Json.ToString();
// Ensure it's CS:GO JSON
if (!jsonString.Contains("Counter-Strike: Global Offensive"))
return;
// Parse the JSON
CsJson = JsonConvert.DeserializeObject<JObject>(jsonString);
}
}
}

View File

@ -1,71 +1,71 @@
using System.Windows.Media;
using Artemis.Models;
namespace Artemis.Modules.Games.CounterStrike
{
public class CounterStrikeSettings : GameSettings
{
public CounterStrikeSettings()
{
Load();
}
public string GameDirectory { get; set; }
public bool AmmoEnabled { get; set; }
public Color AmmoMainColor { get; set; }
public Color AmmoSecondaryColor { get; set; }
public bool TeamColorEnabled { get; set; }
public bool FlashEnabled { get; set; }
public bool SmokeEnabled { get; set; }
public bool LowHpEnabled { get; set; }
public sealed override void Load()
{
Enabled = CounterStrike.Default.Enabled;
GameDirectory = CounterStrike.Default.GameDirectory;
AmmoEnabled = CounterStrike.Default.AmmoEnabled;
AmmoMainColor = CounterStrike.Default.AmmoMainColor;
AmmoSecondaryColor = CounterStrike.Default.AmmoSecondaryColor;
TeamColorEnabled = CounterStrike.Default.TeamColorEnabled;
FlashEnabled = CounterStrike.Default.FlashEnabled;
SmokeEnabled = CounterStrike.Default.SmokeEnabled;
LowHpEnabled = CounterStrike.Default.LowHpEnabled;
}
public sealed override void Save()
{
CounterStrike.Default.Enabled = Enabled;
CounterStrike.Default.GameDirectory = GameDirectory;
CounterStrike.Default.AmmoEnabled = AmmoEnabled;
CounterStrike.Default.AmmoMainColor = AmmoMainColor;
CounterStrike.Default.AmmoSecondaryColor = AmmoSecondaryColor;
CounterStrike.Default.TeamColorEnabled = TeamColorEnabled;
CounterStrike.Default.FlashEnabled = FlashEnabled;
CounterStrike.Default.SmokeEnabled = SmokeEnabled;
CounterStrike.Default.LowHpEnabled = LowHpEnabled;
CounterStrike.Default.Save();
}
public sealed override void ToDefault()
{
Enabled = true;
GameDirectory = string.Empty;
AmmoEnabled = true;
AmmoMainColor = Color.FromArgb(255, 38, 246, 0);
AmmoSecondaryColor = Color.FromArgb(255, 255, 41, 0);
TeamColorEnabled = true;
FlashEnabled = true;
SmokeEnabled = true;
LowHpEnabled = true;
}
}
using System.Windows.Media;
using Artemis.Models;
namespace Artemis.Modules.Games.CounterStrike
{
public class CounterStrikeSettings : GameSettings
{
public CounterStrikeSettings()
{
Load();
}
public string GameDirectory { get; set; }
public bool AmmoEnabled { get; set; }
public Color AmmoMainColor { get; set; }
public Color AmmoSecondaryColor { get; set; }
public bool TeamColorEnabled { get; set; }
public bool FlashEnabled { get; set; }
public bool SmokeEnabled { get; set; }
public bool LowHpEnabled { get; set; }
public sealed override void Load()
{
Enabled = CounterStrike.Default.Enabled;
GameDirectory = CounterStrike.Default.GameDirectory;
AmmoEnabled = CounterStrike.Default.AmmoEnabled;
AmmoMainColor = CounterStrike.Default.AmmoMainColor;
AmmoSecondaryColor = CounterStrike.Default.AmmoSecondaryColor;
TeamColorEnabled = CounterStrike.Default.TeamColorEnabled;
FlashEnabled = CounterStrike.Default.FlashEnabled;
SmokeEnabled = CounterStrike.Default.SmokeEnabled;
LowHpEnabled = CounterStrike.Default.LowHpEnabled;
}
public sealed override void Save()
{
CounterStrike.Default.Enabled = Enabled;
CounterStrike.Default.GameDirectory = GameDirectory;
CounterStrike.Default.AmmoEnabled = AmmoEnabled;
CounterStrike.Default.AmmoMainColor = AmmoMainColor;
CounterStrike.Default.AmmoSecondaryColor = AmmoSecondaryColor;
CounterStrike.Default.TeamColorEnabled = TeamColorEnabled;
CounterStrike.Default.FlashEnabled = FlashEnabled;
CounterStrike.Default.SmokeEnabled = SmokeEnabled;
CounterStrike.Default.LowHpEnabled = LowHpEnabled;
CounterStrike.Default.Save();
}
public sealed override void ToDefault()
{
Enabled = true;
GameDirectory = string.Empty;
AmmoEnabled = true;
AmmoMainColor = Color.FromArgb(255, 38, 246, 0);
AmmoSecondaryColor = Color.FromArgb(255, 255, 41, 0);
TeamColorEnabled = true;
FlashEnabled = true;
SmokeEnabled = true;
LowHpEnabled = true;
}
}
}

View File

@ -1,15 +1,15 @@
using System.Windows.Controls;
namespace Artemis.Modules.Games.CounterStrike
{
/// <summary>
/// Interaction logic for CounterStrikeView.xaml
/// </summary>
public partial class CounterStrikeView : UserControl
{
public CounterStrikeView()
{
InitializeComponent();
}
}
using System.Windows.Controls;
namespace Artemis.Modules.Games.CounterStrike
{
/// <summary>
/// Interaction logic for CounterStrikeView.xaml
/// </summary>
public partial class CounterStrikeView : UserControl
{
public CounterStrikeView()
{
InitializeComponent();
}
}
}

View File

@ -1,64 +1,64 @@
using System.IO;
using System.Windows.Forms;
using Artemis.Managers;
using Artemis.Properties;
using Artemis.ViewModels.Abstract;
namespace Artemis.Modules.Games.CounterStrike
{
public class CounterStrikeViewModel : GameViewModel
{
public CounterStrikeViewModel(MainManager mainManager)
{
MainManager = mainManager;
// Settings are loaded from file by class
GameSettings = new CounterStrikeSettings();
// Create effect model and add it to MainManager
GameModel = new CounterStrikeModel(mainManager, (CounterStrikeSettings) GameSettings);
MainManager.EffectManager.EffectModels.Add(GameModel);
PlaceConfigFile();
}
public static string Name => "CS:GO";
public string Content => "Counter-Strike: GO Content";
public void BrowseDirectory()
{
var dialog = new FolderBrowserDialog {SelectedPath = ((CounterStrikeSettings) GameSettings).GameDirectory};
var result = dialog.ShowDialog();
if (result != DialogResult.OK)
return;
((CounterStrikeSettings) GameSettings).GameDirectory = dialog.SelectedPath;
NotifyOfPropertyChange(() => GameSettings);
GameSettings.Save();
PlaceConfigFile();
}
public void PlaceConfigFile()
{
if (((CounterStrikeSettings) GameSettings).GameDirectory == string.Empty)
return;
if (Directory.Exists(((CounterStrikeSettings) GameSettings).GameDirectory + "/csgo/cfg"))
{
var cfgFile = Resources.csgoGamestateConfiguration.Replace("{{port}}",
MainManager.GameStateWebServer.Port.ToString());
File.WriteAllText(
((CounterStrikeSettings) GameSettings).GameDirectory + "/csgo/cfg/gamestate_integration_artemis.cfg",
cfgFile);
return;
}
MainManager.DialogService.ShowErrorMessageBox("Please select a valid CS:GO directory\n\n" +
@"By default CS:GO is in \SteamApps\common\Counter-Strike Global Offensive");
((CounterStrikeSettings) GameSettings).GameDirectory = string.Empty;
NotifyOfPropertyChange(() => GameSettings);
GameSettings.Save();
}
}
using System.IO;
using System.Windows.Forms;
using Artemis.Managers;
using Artemis.Properties;
using Artemis.ViewModels.Abstract;
namespace Artemis.Modules.Games.CounterStrike
{
public class CounterStrikeViewModel : GameViewModel
{
public CounterStrikeViewModel(MainManager mainManager)
{
MainManager = mainManager;
// Settings are loaded from file by class
GameSettings = new CounterStrikeSettings();
// Create effect model and add it to MainManager
GameModel = new CounterStrikeModel(mainManager, (CounterStrikeSettings) GameSettings);
MainManager.EffectManager.EffectModels.Add(GameModel);
PlaceConfigFile();
}
public static string Name => "CS:GO";
public string Content => "Counter-Strike: GO Content";
public void BrowseDirectory()
{
var dialog = new FolderBrowserDialog {SelectedPath = ((CounterStrikeSettings) GameSettings).GameDirectory};
var result = dialog.ShowDialog();
if (result != DialogResult.OK)
return;
((CounterStrikeSettings) GameSettings).GameDirectory = dialog.SelectedPath;
NotifyOfPropertyChange(() => GameSettings);
GameSettings.Save();
PlaceConfigFile();
}
public void PlaceConfigFile()
{
if (((CounterStrikeSettings) GameSettings).GameDirectory == string.Empty)
return;
if (Directory.Exists(((CounterStrikeSettings) GameSettings).GameDirectory + "/csgo/cfg"))
{
var cfgFile = Resources.csgoGamestateConfiguration.Replace("{{port}}",
MainManager.GameStateWebServer.Port.ToString());
File.WriteAllText(
((CounterStrikeSettings) GameSettings).GameDirectory + "/csgo/cfg/gamestate_integration_artemis.cfg",
cfgFile);
return;
}
MainManager.DialogService.ShowErrorMessageBox("Please select a valid CS:GO directory\n\n" +
@"By default CS:GO is in \SteamApps\common\Counter-Strike Global Offensive");
((CounterStrikeSettings) GameSettings).GameDirectory = string.Empty;
NotifyOfPropertyChange(() => GameSettings);
GameSettings.Save();
}
}
}

View File

@ -1,15 +1,15 @@
using System.Windows.Controls;
namespace Artemis.Modules.Games.Dota2
{
/// <summary>
/// Interaction logic for Dota2View.xaml
/// </summary>
public partial class Dota2View : UserControl
{
public Dota2View()
{
InitializeComponent();
}
}
using System.Windows.Controls;
namespace Artemis.Modules.Games.Dota2
{
/// <summary>
/// Interaction logic for Dota2View.xaml
/// </summary>
public partial class Dota2View : UserControl
{
public Dota2View()
{
InitializeComponent();
}
}
}

View File

@ -1,43 +1,43 @@
using System.Windows.Media;
using Artemis.Models;
namespace Artemis.Modules.Games.RocketLeague
{
public class RocketLeagueSettings : GameSettings
{
public RocketLeagueSettings()
{
Load();
}
public Color MainColor { get; set; }
public Color SecondaryColor { get; set; }
public bool ContextualColor { get; set; }
public sealed override void Load()
{
Enabled = RocketLeague.Default.Enabled;
MainColor = RocketLeague.Default.MainColor;
SecondaryColor = RocketLeague.Default.SecondaryColor;
ContextualColor = RocketLeague.Default.ContextualColor;
}
public sealed override void Save()
{
RocketLeague.Default.Enabled = Enabled;
RocketLeague.Default.MainColor = MainColor;
RocketLeague.Default.SecondaryColor = SecondaryColor;
RocketLeague.Default.ContextualColor = ContextualColor;
RocketLeague.Default.Save();
}
public sealed override void ToDefault()
{
Enabled = true;
MainColor = Color.FromArgb(255, 255, 80, 0);
SecondaryColor = Color.FromArgb(255, 255, 0, 0);
ContextualColor = false;
}
}
using System.Windows.Media;
using Artemis.Models;
namespace Artemis.Modules.Games.RocketLeague
{
public class RocketLeagueSettings : GameSettings
{
public RocketLeagueSettings()
{
Load();
}
public Color MainColor { get; set; }
public Color SecondaryColor { get; set; }
public bool ContextualColor { get; set; }
public sealed override void Load()
{
Enabled = RocketLeague.Default.Enabled;
MainColor = RocketLeague.Default.MainColor;
SecondaryColor = RocketLeague.Default.SecondaryColor;
ContextualColor = RocketLeague.Default.ContextualColor;
}
public sealed override void Save()
{
RocketLeague.Default.Enabled = Enabled;
RocketLeague.Default.MainColor = MainColor;
RocketLeague.Default.SecondaryColor = SecondaryColor;
RocketLeague.Default.ContextualColor = ContextualColor;
RocketLeague.Default.Save();
}
public sealed override void ToDefault()
{
Enabled = true;
MainColor = Color.FromArgb(255, 255, 80, 0);
SecondaryColor = Color.FromArgb(255, 255, 0, 0);
ContextualColor = false;
}
}
}

View File

@ -1,15 +1,15 @@
using System.Windows.Controls;
namespace Artemis.Modules.Games.RocketLeague
{
/// <summary>
/// Interaction logic for RocketLeagueView.xaml
/// </summary>
public partial class RocketLeagueView : UserControl
{
public RocketLeagueView()
{
InitializeComponent();
}
}
using System.Windows.Controls;
namespace Artemis.Modules.Games.RocketLeague
{
/// <summary>
/// Interaction logic for RocketLeagueView.xaml
/// </summary>
public partial class RocketLeagueView : UserControl
{
public RocketLeagueView()
{
InitializeComponent();
}
}
}

View File

@ -1,60 +1,60 @@
using Artemis.Managers;
using Artemis.Settings;
using Artemis.Utilities;
using Artemis.Utilities.Memory;
using Artemis.ViewModels.Abstract;
using Newtonsoft.Json;
namespace Artemis.Modules.Games.RocketLeague
{
public class RocketLeagueViewModel : GameViewModel
{
private string _versionText;
public RocketLeagueViewModel(MainManager mainManager)
{
MainManager = mainManager;
// Settings are loaded from file by class
GameSettings = new RocketLeagueSettings();
// Create effect model and add it to MainManager
GameModel = new RocketLeagueModel(mainManager, (RocketLeagueSettings) GameSettings);
MainManager.EffectManager.EffectModels.Add(GameModel);
SetVersionText();
}
public static string Name => "Rocket League";
public string VersionText
{
get { return _versionText; }
set
{
if (value == _versionText) return;
_versionText = value;
NotifyOfPropertyChange(() => VersionText);
}
}
public RocketLeagueModel RocketLeagueModel { get; set; }
private void SetVersionText()
{
if (!General.Default.EnablePointersUpdate)
{
VersionText = "Note: You disabled pointer updates, this could result in the " +
"Rocket League effect not working after a game update.";
return;
}
Updater.GetPointers();
var version = JsonConvert
.DeserializeObject<GamePointersCollection>(Offsets.Default.RocketLeague)
.GameVersion;
VersionText = $"Note: Requires patch {version}. When a new patch is released Artemis downloads " +
"new pointers for the latest version (unless disabled in settings).";
}
}
using Artemis.Managers;
using Artemis.Settings;
using Artemis.Utilities;
using Artemis.Utilities.Memory;
using Artemis.ViewModels.Abstract;
using Newtonsoft.Json;
namespace Artemis.Modules.Games.RocketLeague
{
public class RocketLeagueViewModel : GameViewModel
{
private string _versionText;
public RocketLeagueViewModel(MainManager mainManager)
{
MainManager = mainManager;
// Settings are loaded from file by class
GameSettings = new RocketLeagueSettings();
// Create effect model and add it to MainManager
GameModel = new RocketLeagueModel(mainManager, (RocketLeagueSettings) GameSettings);
MainManager.EffectManager.EffectModels.Add(GameModel);
SetVersionText();
}
public static string Name => "Rocket League";
public string VersionText
{
get { return _versionText; }
set
{
if (value == _versionText) return;
_versionText = value;
NotifyOfPropertyChange(() => VersionText);
}
}
public RocketLeagueModel RocketLeagueModel { get; set; }
private void SetVersionText()
{
if (!General.Default.EnablePointersUpdate)
{
VersionText = "Note: You disabled pointer updates, this could result in the " +
"Rocket League effect not working after a game update.";
return;
}
Updater.GetPointers();
var version = JsonConvert
.DeserializeObject<GamePointersCollection>(Offsets.Default.RocketLeague)
.GameVersion;
VersionText = $"Note: Requires patch {version}. When a new patch is released Artemis downloads " +
"new pointers for the latest version (unless disabled in settings).";
}
}
}

View File

@ -1,257 +1,257 @@
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Modules.Effects.TypeWave;
using Artemis.Utilities;
using Artemis.Utilities.Keyboard;
using Artemis.Utilities.LogitechDll;
using CUE.NET;
namespace Artemis.Modules.Games.TheDivision
{
public class TheDivisionModel : GameModel
{
private Wave _ammoWave;
private TheDivisionDataModel _dataModel;
private KeyboardRectangle _hpRect;
private KeyboardRectangle _p2;
private KeyboardRectangle _p3;
private KeyboardRectangle _p4;
private StickyValue<bool> _stickyAmmo;
private StickyValue<bool> _stickyHp;
private int _trans;
public TheDivisionModel(MainManager mainManager, TheDivisionSettings settings) : base(mainManager)
{
Settings = settings;
Name = "TheDivision";
ProcessName = "TheDivision";
Scale = 4;
Enabled = Settings.Enabled;
Initialized = false;
}
public TheDivisionSettings Settings { get; set; }
public int Scale { get; set; }
public override void Dispose()
{
Initialized = false;
DllManager.RestoreDll();
_stickyAmmo.Dispose();
_stickyHp.Dispose();
}
public override void Enable()
{
Initialized = false;
_ammoWave = new Wave(new Point(30, 14), 0, Color.Transparent);
_hpRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 3*Scale, 0*Scale,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = 7*Scale,
Width = 21*Scale,
Rotate = true,
ContainedBrush = false
};
_p2 = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0*Scale, 1*Scale,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = 2*Scale,
Width = 3*Scale,
Rotate = true,
ContainedBrush = false
};
_p3 = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0*Scale, 3*Scale,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = 2*Scale,
Width = 3*Scale,
Rotate = true,
ContainedBrush = false
};
_p4 = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0*Scale, 5*Scale,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = 2*Scale,
Width = 3*Scale,
Rotate = true,
ContainedBrush = false
};
_stickyAmmo = new StickyValue<bool>(200);
_stickyHp = new StickyValue<bool>(200);
DllManager.PlaceDll();
_dataModel = new TheDivisionDataModel();
for (var i = 1; i < 5; i++)
_dataModel.DivisionPlayers.Add(new DivisionPlayer(i));
MainManager.PipeServer.PipeMessage += PipeServerOnPipeMessage;
Initialized = true;
}
private void PipeServerOnPipeMessage(string reply)
{
if (!Initialized)
return;
// Convert the given string to a list of ints
var stringParts = reply.Split(' ');
var parts = new int[stringParts.Length];
for (var i = 0; i < stringParts.Length; i++)
parts[i] = int.Parse(stringParts[i]);
if (parts[0] == 1)
InterpertrateDivisionKey(parts);
}
// Parses Division key data to game data
private void InterpertrateDivisionKey(int[] parts)
{
var keyCode = parts[1];
var rPer = parts[2];
var gPer = parts[3];
var bPer = parts[4];
// F1 to F4 indicate the player and his party. Blinks red on damage taken
if (keyCode >= 59 && keyCode <= 62)
{
var playerId = keyCode - 58;
var playerDataModel = _dataModel.DivisionPlayers.FirstOrDefault(p => p.Id == playerId);
if (playerDataModel == null)
return;
if (gPer > 10)
playerDataModel.PlayerState = PlayerState.Online;
else if (rPer > 10)
playerDataModel.PlayerState = PlayerState.Hit;
else
playerDataModel.PlayerState = PlayerState.Offline;
}
// R blinks white when low on ammo
else if (keyCode == 19)
{
_stickyAmmo.Value = rPer == 100 && gPer > 1 && bPer > 1;
_dataModel.LowAmmo = _stickyAmmo.Value;
}
// G turns white when holding a grenade, turns off when out of grenades
else if (keyCode == 34)
{
if (rPer == 100 && gPer < 10 && bPer < 10)
_dataModel.GrenadeState = GrenadeState.HasGrenade;
else if (rPer == 100 && gPer > 10 && bPer > 10)
_dataModel.GrenadeState = GrenadeState.GrenadeEquipped;
else
_dataModel.GrenadeState = GrenadeState.HasNoGrenade;
}
// V blinks on low HP
else if (keyCode == 47)
{
_stickyHp.Value = rPer == 100 && gPer > 1 && bPer > 1;
_dataModel.LowHp = _stickyHp.Value;
}
}
public override void Update()
{
if (_dataModel.LowAmmo)
{
_ammoWave.Size++;
if (_ammoWave.Size > 30)
{
_ammoWave.Size = 0;
_trans = 255;
}
}
else
_ammoWave.Size = 0;
_hpRect.Colors = _dataModel.LowHp
? new List<Color> {Color.Red, Color.Orange}
: new List<Color> {Color.FromArgb(10, 255, 0), Color.FromArgb(80, 255, 45) };
if (_dataModel.DivisionPlayers[1].PlayerState == PlayerState.Offline)
_p2.Colors = new List<Color> {Color.Gray, Color.White};
else if (_dataModel.DivisionPlayers[1].PlayerState == PlayerState.Online)
_p2.Colors = new List<Color> { Color.FromArgb(10, 255, 0), Color.FromArgb(80, 255, 45) };
else
_p2.Colors = new List<Color> {Color.Red, Color.Orange};
if (_dataModel.DivisionPlayers[2].PlayerState == PlayerState.Offline)
_p3.Colors = new List<Color> {Color.Gray, Color.White};
else if (_dataModel.DivisionPlayers[2].PlayerState == PlayerState.Online)
_p3.Colors = new List<Color> { Color.FromArgb(10, 255, 0), Color.FromArgb(80, 255, 45) };
else
_p3.Colors = new List<Color> {Color.Red, Color.Orange};
if (_dataModel.DivisionPlayers[3].PlayerState == PlayerState.Offline)
_p4.Colors = new List<Color> {Color.Gray, Color.White};
else if (_dataModel.DivisionPlayers[3].PlayerState == PlayerState.Online)
_p4.Colors = new List<Color> { Color.FromArgb(10, 255, 0), Color.FromArgb(80, 255, 45) };
else
_p4.Colors = new List<Color> {Color.Red, Color.Orange};
if (!_dataModel.LowAmmo)
{
foreach (var corsairLed in CueSDK.MouseSDK.Leds)
corsairLed.Color = Color.Green;
}
else
{
foreach (var corsairLed in CueSDK.MouseSDK.Leds)
corsairLed.Color = Color.Red;
}
CueSDK.MouseSDK.Update();
}
public override Bitmap GenerateBitmap()
{
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap))
{
g.Clear(Color.Transparent);
_hpRect.Draw(g);
_p2.Draw(g);
_p3.Draw(g);
_p4.Draw(g);
// Very, very PH
if (_ammoWave.Size != 0)
{
var path = new GraphicsPath();
path.AddEllipse(_ammoWave.Point.X - _ammoWave.Size/2, _ammoWave.Point.Y - _ammoWave.Size/2,
_ammoWave.Size, _ammoWave.Size);
if (_ammoWave.Size > 15)
_trans = _trans - 16;
if (_trans < 1)
_trans = 255;
var pthGrBrush = new PathGradientBrush(path)
{
SurroundColors = new[] {_ammoWave.Color},
CenterColor = Color.FromArgb(_trans, 255, 0, 0)
};
g.FillPath(pthGrBrush, path);
pthGrBrush.FocusScales = new PointF(0.3f, 0.8f);
g.FillPath(pthGrBrush, path);
g.DrawEllipse(new Pen(pthGrBrush, 1), _ammoWave.Point.X - _ammoWave.Size/2,
_ammoWave.Point.Y - _ammoWave.Size/2, _ammoWave.Size, _ammoWave.Size);
}
}
return bitmap;
}
}
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Modules.Effects.TypeWave;
using Artemis.Utilities;
using Artemis.Utilities.Keyboard;
using Artemis.Utilities.LogitechDll;
using CUE.NET;
namespace Artemis.Modules.Games.TheDivision
{
public class TheDivisionModel : GameModel
{
private Wave _ammoWave;
private TheDivisionDataModel _dataModel;
private KeyboardRectangle _hpRect;
private KeyboardRectangle _p2;
private KeyboardRectangle _p3;
private KeyboardRectangle _p4;
private StickyValue<bool> _stickyAmmo;
private StickyValue<bool> _stickyHp;
private int _trans;
public TheDivisionModel(MainManager mainManager, TheDivisionSettings settings) : base(mainManager)
{
Settings = settings;
Name = "TheDivision";
ProcessName = "TheDivision";
Scale = 4;
Enabled = Settings.Enabled;
Initialized = false;
}
public TheDivisionSettings Settings { get; set; }
public int Scale { get; set; }
public override void Dispose()
{
Initialized = false;
DllManager.RestoreDll();
_stickyAmmo.Dispose();
_stickyHp.Dispose();
}
public override void Enable()
{
Initialized = false;
_ammoWave = new Wave(new Point(30, 14), 0, Color.Transparent);
_hpRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 3*Scale, 0*Scale,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = 7*Scale,
Width = 21*Scale,
Rotate = true,
ContainedBrush = false
};
_p2 = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0*Scale, 1*Scale,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = 2*Scale,
Width = 3*Scale,
Rotate = true,
ContainedBrush = false
};
_p3 = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0*Scale, 3*Scale,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = 2*Scale,
Width = 3*Scale,
Rotate = true,
ContainedBrush = false
};
_p4 = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0*Scale, 5*Scale,
new List<Color>(),
LinearGradientMode.Horizontal)
{
Height = 2*Scale,
Width = 3*Scale,
Rotate = true,
ContainedBrush = false
};
_stickyAmmo = new StickyValue<bool>(200);
_stickyHp = new StickyValue<bool>(200);
DllManager.PlaceDll();
_dataModel = new TheDivisionDataModel();
for (var i = 1; i < 5; i++)
_dataModel.DivisionPlayers.Add(new DivisionPlayer(i));
MainManager.PipeServer.PipeMessage += PipeServerOnPipeMessage;
Initialized = true;
}
private void PipeServerOnPipeMessage(string reply)
{
if (!Initialized)
return;
// Convert the given string to a list of ints
var stringParts = reply.Split(' ');
var parts = new int[stringParts.Length];
for (var i = 0; i < stringParts.Length; i++)
parts[i] = int.Parse(stringParts[i]);
if (parts[0] == 1)
InterpertrateDivisionKey(parts);
}
// Parses Division key data to game data
private void InterpertrateDivisionKey(int[] parts)
{
var keyCode = parts[1];
var rPer = parts[2];
var gPer = parts[3];
var bPer = parts[4];
// F1 to F4 indicate the player and his party. Blinks red on damage taken
if (keyCode >= 59 && keyCode <= 62)
{
var playerId = keyCode - 58;
var playerDataModel = _dataModel.DivisionPlayers.FirstOrDefault(p => p.Id == playerId);
if (playerDataModel == null)
return;
if (gPer > 10)
playerDataModel.PlayerState = PlayerState.Online;
else if (rPer > 10)
playerDataModel.PlayerState = PlayerState.Hit;
else
playerDataModel.PlayerState = PlayerState.Offline;
}
// R blinks white when low on ammo
else if (keyCode == 19)
{
_stickyAmmo.Value = rPer == 100 && gPer > 1 && bPer > 1;
_dataModel.LowAmmo = _stickyAmmo.Value;
}
// G turns white when holding a grenade, turns off when out of grenades
else if (keyCode == 34)
{
if (rPer == 100 && gPer < 10 && bPer < 10)
_dataModel.GrenadeState = GrenadeState.HasGrenade;
else if (rPer == 100 && gPer > 10 && bPer > 10)
_dataModel.GrenadeState = GrenadeState.GrenadeEquipped;
else
_dataModel.GrenadeState = GrenadeState.HasNoGrenade;
}
// V blinks on low HP
else if (keyCode == 47)
{
_stickyHp.Value = rPer == 100 && gPer > 1 && bPer > 1;
_dataModel.LowHp = _stickyHp.Value;
}
}
public override void Update()
{
if (_dataModel.LowAmmo)
{
_ammoWave.Size++;
if (_ammoWave.Size > 30)
{
_ammoWave.Size = 0;
_trans = 255;
}
}
else
_ammoWave.Size = 0;
_hpRect.Colors = _dataModel.LowHp
? new List<Color> {Color.Red, Color.Orange}
: new List<Color> {Color.FromArgb(10, 255, 0), Color.FromArgb(80, 255, 45) };
if (_dataModel.DivisionPlayers[1].PlayerState == PlayerState.Offline)
_p2.Colors = new List<Color> {Color.Gray, Color.White};
else if (_dataModel.DivisionPlayers[1].PlayerState == PlayerState.Online)
_p2.Colors = new List<Color> { Color.FromArgb(10, 255, 0), Color.FromArgb(80, 255, 45) };
else
_p2.Colors = new List<Color> {Color.Red, Color.Orange};
if (_dataModel.DivisionPlayers[2].PlayerState == PlayerState.Offline)
_p3.Colors = new List<Color> {Color.Gray, Color.White};
else if (_dataModel.DivisionPlayers[2].PlayerState == PlayerState.Online)
_p3.Colors = new List<Color> { Color.FromArgb(10, 255, 0), Color.FromArgb(80, 255, 45) };
else
_p3.Colors = new List<Color> {Color.Red, Color.Orange};
if (_dataModel.DivisionPlayers[3].PlayerState == PlayerState.Offline)
_p4.Colors = new List<Color> {Color.Gray, Color.White};
else if (_dataModel.DivisionPlayers[3].PlayerState == PlayerState.Online)
_p4.Colors = new List<Color> { Color.FromArgb(10, 255, 0), Color.FromArgb(80, 255, 45) };
else
_p4.Colors = new List<Color> {Color.Red, Color.Orange};
if (!_dataModel.LowAmmo)
{
foreach (var corsairLed in CueSDK.MouseSDK.Leds)
corsairLed.Color = Color.Green;
}
else
{
foreach (var corsairLed in CueSDK.MouseSDK.Leds)
corsairLed.Color = Color.Red;
}
CueSDK.MouseSDK.Update();
}
public override Bitmap GenerateBitmap()
{
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap))
{
g.Clear(Color.Transparent);
_hpRect.Draw(g);
_p2.Draw(g);
_p3.Draw(g);
_p4.Draw(g);
// Very, very PH
if (_ammoWave.Size != 0)
{
var path = new GraphicsPath();
path.AddEllipse(_ammoWave.Point.X - _ammoWave.Size/2, _ammoWave.Point.Y - _ammoWave.Size/2,
_ammoWave.Size, _ammoWave.Size);
if (_ammoWave.Size > 15)
_trans = _trans - 16;
if (_trans < 1)
_trans = 255;
var pthGrBrush = new PathGradientBrush(path)
{
SurroundColors = new[] {_ammoWave.Color},
CenterColor = Color.FromArgb(_trans, 255, 0, 0)
};
g.FillPath(pthGrBrush, path);
pthGrBrush.FocusScales = new PointF(0.3f, 0.8f);
g.FillPath(pthGrBrush, path);
g.DrawEllipse(new Pen(pthGrBrush, 1), _ammoWave.Point.X - _ammoWave.Size/2,
_ammoWave.Point.Y - _ammoWave.Size/2, _ammoWave.Size, _ammoWave.Size);
}
}
return bitmap;
}
}
}

View File

@ -1,29 +1,29 @@
using Artemis.Models;
namespace Artemis.Modules.Games.TheDivision
{
public class TheDivisionSettings : GameSettings
{
public TheDivisionSettings()
{
Load();
}
public sealed override void Load()
{
Enabled = TheDivision.Default.Enabled;
}
public sealed override void Save()
{
TheDivision.Default.Enabled = Enabled;
TheDivision.Default.Save();
}
public sealed override void ToDefault()
{
Enabled = true;
}
}
using Artemis.Models;
namespace Artemis.Modules.Games.TheDivision
{
public class TheDivisionSettings : GameSettings
{
public TheDivisionSettings()
{
Load();
}
public sealed override void Load()
{
Enabled = TheDivision.Default.Enabled;
}
public sealed override void Save()
{
TheDivision.Default.Enabled = Enabled;
TheDivision.Default.Save();
}
public sealed override void ToDefault()
{
Enabled = true;
}
}
}

View File

@ -1,22 +1,22 @@
using Artemis.Managers;
using Artemis.ViewModels.Abstract;
namespace Artemis.Modules.Games.TheDivision
{
public class TheDivisionViewModel : GameViewModel
{
public TheDivisionViewModel(MainManager mainManager)
{
MainManager = mainManager;
// Settings are loaded from file by class
GameSettings = new TheDivisionSettings();
// Create effect model and add it to MainManager
GameModel = new TheDivisionModel(mainManager, (TheDivisionSettings) GameSettings);
MainManager.EffectManager.EffectModels.Add(GameModel);
}
public static string Name => "The Division";
}
using Artemis.Managers;
using Artemis.ViewModels.Abstract;
namespace Artemis.Modules.Games.TheDivision
{
public class TheDivisionViewModel : GameViewModel
{
public TheDivisionViewModel(MainManager mainManager)
{
MainManager = mainManager;
// Settings are loaded from file by class
GameSettings = new TheDivisionSettings();
// Create effect model and add it to MainManager
GameModel = new TheDivisionModel(mainManager, (TheDivisionSettings) GameSettings);
MainManager.EffectManager.EffectModels.Add(GameModel);
}
public static string Name => "The Division";
}
}

View File

@ -1,121 +1,121 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Text.RegularExpressions;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Utilities.Keyboard;
namespace Artemis.Modules.Games.Witcher3
{
public class Witcher3Model : GameModel
{
private readonly Regex _signRegex;
private readonly Stopwatch _updateSw;
private KeyboardRectangle _signRect;
private string _witcherSettings;
public Witcher3Model(MainManager mainManager, Witcher3Settings settings) : base(mainManager)
{
Settings = settings;
Name = "Witcher3";
ProcessName = "witcher3";
Scale = 4;
Enabled = Settings.Enabled;
Initialized = false;
_updateSw = new Stopwatch();
_signRegex = new Regex("ActiveSign=(.*)", RegexOptions.Compiled);
}
public Witcher3Settings Settings { get; set; }
public int Scale { get; set; }
public override void Dispose()
{
Initialized = false;
_witcherSettings = null;
_updateSw.Reset();
}
public override void Enable()
{
Initialized = false;
_signRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
LinearGradientMode.Horizontal)
{
Rotate = true,
LoopSpeed = 0.5
};
// Ensure the config file is found
var witcherSettings = Environment.GetFolderPath(Environment.SpecialFolder.Personal) +
@"\The Witcher 3\user.settings";
if (File.Exists(witcherSettings))
_witcherSettings = witcherSettings;
_updateSw.Start();
Initialized = true;
}
public override void Update()
{
// Witcher effect is very static and reads from disk, don't want to update too often.
if (_updateSw.ElapsedMilliseconds < 500)
return;
_updateSw.Restart();
if (_witcherSettings == null)
return;
var reader = new StreamReader(File.Open(_witcherSettings,
FileMode.Open,
FileAccess.Read,
FileShare.ReadWrite));
var configContent = reader.ReadToEnd();
reader.Close();
var signRes = _signRegex.Match(configContent);
if (signRes.Groups.Count < 2)
return;
var sign = signRes.Groups[1].Value;
switch (sign)
{
case "ST_Aard\r":
_signRect.Colors = new List<Color> {Color.DeepSkyBlue, Color.Blue};
break;
case "ST_Yrden\r":
_signRect.Colors = new List<Color> {Color.Purple, Color.DeepPink};
break;
case "ST_Igni\r":
_signRect.Colors = new List<Color> {Color.DarkOrange, Color.Red};
break;
case "ST_Quen\r":
_signRect.Colors = new List<Color> {Color.DarkOrange, Color.FromArgb(232, 193, 0)};
break;
case "ST_Axii\r":
_signRect.Colors = new List<Color> {Color.LawnGreen, Color.DarkGreen};
break;
}
}
public override Bitmap GenerateBitmap()
{
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap))
{
g.Clear(Color.Transparent);
_signRect.Draw(g);
}
return bitmap;
}
}
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Text.RegularExpressions;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Utilities.Keyboard;
namespace Artemis.Modules.Games.Witcher3
{
public class Witcher3Model : GameModel
{
private readonly Regex _signRegex;
private readonly Stopwatch _updateSw;
private KeyboardRectangle _signRect;
private string _witcherSettings;
public Witcher3Model(MainManager mainManager, Witcher3Settings settings) : base(mainManager)
{
Settings = settings;
Name = "Witcher3";
ProcessName = "witcher3";
Scale = 4;
Enabled = Settings.Enabled;
Initialized = false;
_updateSw = new Stopwatch();
_signRegex = new Regex("ActiveSign=(.*)", RegexOptions.Compiled);
}
public Witcher3Settings Settings { get; set; }
public int Scale { get; set; }
public override void Dispose()
{
Initialized = false;
_witcherSettings = null;
_updateSw.Reset();
}
public override void Enable()
{
Initialized = false;
_signRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>(),
LinearGradientMode.Horizontal)
{
Rotate = true,
LoopSpeed = 0.5
};
// Ensure the config file is found
var witcherSettings = Environment.GetFolderPath(Environment.SpecialFolder.Personal) +
@"\The Witcher 3\user.settings";
if (File.Exists(witcherSettings))
_witcherSettings = witcherSettings;
_updateSw.Start();
Initialized = true;
}
public override void Update()
{
// Witcher effect is very static and reads from disk, don't want to update too often.
if (_updateSw.ElapsedMilliseconds < 500)
return;
_updateSw.Restart();
if (_witcherSettings == null)
return;
var reader = new StreamReader(File.Open(_witcherSettings,
FileMode.Open,
FileAccess.Read,
FileShare.ReadWrite));
var configContent = reader.ReadToEnd();
reader.Close();
var signRes = _signRegex.Match(configContent);
if (signRes.Groups.Count < 2)
return;
var sign = signRes.Groups[1].Value;
switch (sign)
{
case "ST_Aard\r":
_signRect.Colors = new List<Color> {Color.DeepSkyBlue, Color.Blue};
break;
case "ST_Yrden\r":
_signRect.Colors = new List<Color> {Color.Purple, Color.DeepPink};
break;
case "ST_Igni\r":
_signRect.Colors = new List<Color> {Color.DarkOrange, Color.Red};
break;
case "ST_Quen\r":
_signRect.Colors = new List<Color> {Color.DarkOrange, Color.FromArgb(232, 193, 0)};
break;
case "ST_Axii\r":
_signRect.Colors = new List<Color> {Color.LawnGreen, Color.DarkGreen};
break;
}
}
public override Bitmap GenerateBitmap()
{
var bitmap = MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap))
{
g.Clear(Color.Transparent);
_signRect.Draw(g);
}
return bitmap;
}
}
}

View File

@ -1,29 +1,29 @@
using Artemis.Models;
namespace Artemis.Modules.Games.Witcher3
{
public class Witcher3Settings : GameSettings
{
public Witcher3Settings()
{
Load();
}
public sealed override void Load()
{
Enabled = Witcher3.Default.Enabled;
}
public sealed override void Save()
{
Witcher3.Default.Enabled = Enabled;
Witcher3.Default.Save();
}
public sealed override void ToDefault()
{
Enabled = true;
}
}
using Artemis.Models;
namespace Artemis.Modules.Games.Witcher3
{
public class Witcher3Settings : GameSettings
{
public Witcher3Settings()
{
Load();
}
public sealed override void Load()
{
Enabled = Witcher3.Default.Enabled;
}
public sealed override void Save()
{
Witcher3.Default.Enabled = Enabled;
Witcher3.Default.Save();
}
public sealed override void ToDefault()
{
Enabled = true;
}
}
}

View File

@ -1,15 +1,15 @@
using System.Windows.Controls;
namespace Artemis.Modules.Games.Witcher3
{
/// <summary>
/// Interaction logic for Witcher3View.xaml
/// </summary>
public partial class Witcher3View : UserControl
{
public Witcher3View()
{
InitializeComponent();
}
}
using System.Windows.Controls;
namespace Artemis.Modules.Games.Witcher3
{
/// <summary>
/// Interaction logic for Witcher3View.xaml
/// </summary>
public partial class Witcher3View : UserControl
{
public Witcher3View()
{
InitializeComponent();
}
}
}

View File

@ -1,112 +1,112 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Artemis.Managers;
using Artemis.Properties;
using Artemis.ViewModels.Abstract;
namespace Artemis.Modules.Games.Witcher3
{
public class Witcher3ViewModel : GameViewModel
{
public Witcher3ViewModel(MainManager mainManager)
{
MainManager = mainManager;
// Settings are loaded from file by class
GameSettings = new Witcher3Settings();
// Create effect model and add it to MainManager
GameModel = new Witcher3Model(mainManager, (Witcher3Settings) GameSettings);
MainManager.EffectManager.EffectModels.Add(GameModel);
}
public static string Name => "The Witcher 3";
public async void AutoInstall()
{
// Request The Witcher 3 folder
var dialog = new FolderBrowserDialog
{
Description = "Please select your Witcher 3 install path (root directory)."
};
var result = dialog.ShowDialog();
if (result != DialogResult.OK)
return;
// If the subfolder doesn't contain witcher3.exe, it's the wrong folder.
if (!File.Exists(dialog.SelectedPath + @"\bin\x64\witcher3.exe"))
{
var retry = await
MainManager.DialogService.ShowQuestionMessageBox("Installation error",
"That's not a valid Witcher 3 directory\n\n" +
"Default directories:\n" +
"Steam: \\SteamApps\\common\\The Witcher 3\n" +
"GOG: C:\\GOG Games\\The Witcher 3 Wild Hunt\n\n" +
"Retry?");
if (retry.Value)
AutoInstall();
return;
}
// Look for any conflicting mods
if (Directory.Exists(dialog.SelectedPath + @"\mods"))
{
var file =
Directory.GetFiles(dialog.SelectedPath + @"\mods", "playerWitcher.ws", SearchOption.AllDirectories)
.FirstOrDefault();
if (file != null)
{
// Don't trip over our own mod
if (!file.Contains("modArtemis"))
{
var viewHelp = await
MainManager.DialogService.ShowQuestionMessageBox("Conflicting mod found",
"Oh no, you have a conflicting mod!\n\n" +
"Conflicting file: " + file.Remove(0, dialog.SelectedPath.Length) +
"\n\nWould you like to view instructions on how to manually install the mod?");
if (!viewHelp.Value)
return;
// Put the mod in the documents folder instead
// Create the directory structure
var folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Artemis";
if (
!Directory.Exists(folder + @"\Witcher3\mods\modArtemis\content\scripts\game\player"))
Directory.CreateDirectory(folder +
@"\Witcher3\mods\modArtemis\content\scripts\game\player");
if (
!Directory.Exists(folder + @"\Witcher3\bin\config\r4game\user_config_matrix\pc"))
Directory.CreateDirectory(folder + @"\Witcher3\bin\config\r4game\user_config_matrix\pc");
// Install the mod files
File.WriteAllText(folder + @"\Witcher3\bin\config\r4game\user_config_matrix\pc\artemis.xml",
Resources.artemisXml);
File.WriteAllText(
folder + @"\Witcher3\mods\modArtemis\content\scripts\game\player\playerWitcher.ws",
Resources.playerWitcherWs);
Process.Start(new ProcessStartInfo("https://github.com/SpoinkyNL/Artemis/wiki/The-Witcher-3"));
return;
}
}
}
// Create the directory structure
if (!Directory.Exists(dialog.SelectedPath + @"\mods\modArtemis\content\scripts\game\player"))
Directory.CreateDirectory(dialog.SelectedPath + @"\mods\modArtemis\content\scripts\game\player");
if (!Directory.Exists(dialog.SelectedPath + @"\bin\config\r4game\user_config_matrix\pc"))
Directory.CreateDirectory(dialog.SelectedPath + @"\bin\config\r4game\user_config_matrix\pc");
// Install the mod files
File.WriteAllText(dialog.SelectedPath + @"\bin\config\r4game\user_config_matrix\pc\artemis.xml",
Resources.artemisXml);
File.WriteAllText(dialog.SelectedPath + @"\mods\modArtemis\content\scripts\game\player\playerWitcher.ws",
Resources.playerWitcherWs);
MainManager.DialogService.ShowMessageBox("Success", "The mod was successfully installed!");
}
}
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using Artemis.Managers;
using Artemis.Properties;
using Artemis.ViewModels.Abstract;
namespace Artemis.Modules.Games.Witcher3
{
public class Witcher3ViewModel : GameViewModel
{
public Witcher3ViewModel(MainManager mainManager)
{
MainManager = mainManager;
// Settings are loaded from file by class
GameSettings = new Witcher3Settings();
// Create effect model and add it to MainManager
GameModel = new Witcher3Model(mainManager, (Witcher3Settings) GameSettings);
MainManager.EffectManager.EffectModels.Add(GameModel);
}
public static string Name => "The Witcher 3";
public async void AutoInstall()
{
// Request The Witcher 3 folder
var dialog = new FolderBrowserDialog
{
Description = "Please select your Witcher 3 install path (root directory)."
};
var result = dialog.ShowDialog();
if (result != DialogResult.OK)
return;
// If the subfolder doesn't contain witcher3.exe, it's the wrong folder.
if (!File.Exists(dialog.SelectedPath + @"\bin\x64\witcher3.exe"))
{
var retry = await
MainManager.DialogService.ShowQuestionMessageBox("Installation error",
"That's not a valid Witcher 3 directory\n\n" +
"Default directories:\n" +
"Steam: \\SteamApps\\common\\The Witcher 3\n" +
"GOG: C:\\GOG Games\\The Witcher 3 Wild Hunt\n\n" +
"Retry?");
if (retry.Value)
AutoInstall();
return;
}
// Look for any conflicting mods
if (Directory.Exists(dialog.SelectedPath + @"\mods"))
{
var file =
Directory.GetFiles(dialog.SelectedPath + @"\mods", "playerWitcher.ws", SearchOption.AllDirectories)
.FirstOrDefault();
if (file != null)
{
// Don't trip over our own mod
if (!file.Contains("modArtemis"))
{
var viewHelp = await
MainManager.DialogService.ShowQuestionMessageBox("Conflicting mod found",
"Oh no, you have a conflicting mod!\n\n" +
"Conflicting file: " + file.Remove(0, dialog.SelectedPath.Length) +
"\n\nWould you like to view instructions on how to manually install the mod?");
if (!viewHelp.Value)
return;
// Put the mod in the documents folder instead
// Create the directory structure
var folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Artemis";
if (
!Directory.Exists(folder + @"\Witcher3\mods\modArtemis\content\scripts\game\player"))
Directory.CreateDirectory(folder +
@"\Witcher3\mods\modArtemis\content\scripts\game\player");
if (
!Directory.Exists(folder + @"\Witcher3\bin\config\r4game\user_config_matrix\pc"))
Directory.CreateDirectory(folder + @"\Witcher3\bin\config\r4game\user_config_matrix\pc");
// Install the mod files
File.WriteAllText(folder + @"\Witcher3\bin\config\r4game\user_config_matrix\pc\artemis.xml",
Resources.artemisXml);
File.WriteAllText(
folder + @"\Witcher3\mods\modArtemis\content\scripts\game\player\playerWitcher.ws",
Resources.playerWitcherWs);
Process.Start(new ProcessStartInfo("https://github.com/SpoinkyNL/Artemis/wiki/The-Witcher-3"));
return;
}
}
}
// Create the directory structure
if (!Directory.Exists(dialog.SelectedPath + @"\mods\modArtemis\content\scripts\game\player"))
Directory.CreateDirectory(dialog.SelectedPath + @"\mods\modArtemis\content\scripts\game\player");
if (!Directory.Exists(dialog.SelectedPath + @"\bin\config\r4game\user_config_matrix\pc"))
Directory.CreateDirectory(dialog.SelectedPath + @"\bin\config\r4game\user_config_matrix\pc");
// Install the mod files
File.WriteAllText(dialog.SelectedPath + @"\bin\config\r4game\user_config_matrix\pc\artemis.xml",
Resources.artemisXml);
File.WriteAllText(dialog.SelectedPath + @"\mods\modArtemis\content\scripts\game\player\playerWitcher.ws",
Resources.playerWitcherWs);
MainManager.DialogService.ShowMessageBox("Success", "The mod was successfully installed!");
}
}
}

View File

@ -1,46 +1,46 @@
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using Artemis.Managers;
using Artemis.Utilities;
using Artemis.Utilities.Keyboard;
namespace Artemis.Modules.Overlays.VolumeDisplay
{
public class VolumeBar
{
public VolumeBar(MainManager mainManager, VolumeDisplaySettings settings)
{
MainManager = mainManager;
Settings = settings;
Transparancy = 255;
Scale = 4;
}
public MainManager MainManager { get; set; }
public VolumeDisplaySettings Settings { get; set; }
public int Scale { get; set; }
public int Ttl { get; set; }
public byte Transparancy { get; set; }
public int Volume { get; set; }
public void Draw(Graphics g)
{
var volumeRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>
{
ColorHelpers.ToDrawingColor(Settings.MainColor),
ColorHelpers.ToDrawingColor(Settings.SecondaryColor)
},
LinearGradientMode.Horizontal)
{
Width = (int) (MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*Volume),
ContainedBrush = false
};
volumeRect.Draw(g);
}
}
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using Artemis.Managers;
using Artemis.Utilities;
using Artemis.Utilities.Keyboard;
namespace Artemis.Modules.Overlays.VolumeDisplay
{
public class VolumeBar
{
public VolumeBar(MainManager mainManager, VolumeDisplaySettings settings)
{
MainManager = mainManager;
Settings = settings;
Transparancy = 255;
Scale = 4;
}
public MainManager MainManager { get; set; }
public VolumeDisplaySettings Settings { get; set; }
public int Scale { get; set; }
public int Ttl { get; set; }
public byte Transparancy { get; set; }
public int Volume { get; set; }
public void Draw(Graphics g)
{
var volumeRect = new KeyboardRectangle(MainManager.KeyboardManager.ActiveKeyboard, 0, 0, new List<Color>
{
ColorHelpers.ToDrawingColor(Settings.MainColor),
ColorHelpers.ToDrawingColor(Settings.SecondaryColor)
},
LinearGradientMode.Horizontal)
{
Width = (int) (MainManager.KeyboardManager.ActiveKeyboard.Width*Scale/100.00*Volume),
ContainedBrush = false
};
volumeRect.Draw(g);
}
}
}

View File

@ -1,91 +1,91 @@
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Artemis.Managers;
using Artemis.Models;
using NAudio.CoreAudioApi;
namespace Artemis.Modules.Overlays.VolumeDisplay
{
public class VolumeDisplayModel : OverlayModel
{
public VolumeDisplayModel(MainManager mainManager, VolumeDisplaySettings settings) : base(mainManager)
{
Settings = settings;
Name = "VolumeDisplay";
Enabled = Settings.Enabled;
VolumeDisplay = new VolumeBar(mainManager, settings);
}
public VolumeBar VolumeDisplay { get; set; }
public VolumeDisplaySettings Settings { get; set; }
public override void Dispose()
{
MainManager.KeyboardHook.KeyDownCallback -= KeyPressTask;
}
public override void Enable()
{
// Listener won't start unless the effect is active
MainManager.KeyboardHook.KeyDownCallback += KeyPressTask;
}
public override void Update()
{
// TODO: Get from settings
var fps = 25;
if (VolumeDisplay == null)
return;
if (VolumeDisplay.Ttl < 1)
return;
var decreaseAmount = 500/fps;
VolumeDisplay.Ttl = VolumeDisplay.Ttl - decreaseAmount;
if (VolumeDisplay.Ttl < 128)
VolumeDisplay.Transparancy = (byte) (VolumeDisplay.Transparancy - 20);
try
{
var enumerator = new MMDeviceEnumerator();
var volumeFloat =
enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console)
.AudioEndpointVolume.MasterVolumeLevelScalar;
VolumeDisplay.Volume = (int) (volumeFloat*100);
}
catch (COMException)
{
}
}
public override Bitmap GenerateBitmap()
{
return GenerateBitmap(MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(4));
}
public override Bitmap GenerateBitmap(Bitmap bitmap)
{
if (VolumeDisplay == null)
return bitmap;
if (VolumeDisplay.Ttl < 1)
return bitmap;
using (var g = Graphics.FromImage(bitmap))
VolumeDisplay.Draw(g);
return bitmap;
}
private void KeyPressTask(KeyEventArgs e)
{
if (e.KeyCode != Keys.VolumeUp && e.KeyCode != Keys.VolumeDown)
return;
VolumeDisplay.Ttl = 1000;
VolumeDisplay.Transparancy = 255;
}
}
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Artemis.Managers;
using Artemis.Models;
using NAudio.CoreAudioApi;
namespace Artemis.Modules.Overlays.VolumeDisplay
{
public class VolumeDisplayModel : OverlayModel
{
public VolumeDisplayModel(MainManager mainManager, VolumeDisplaySettings settings) : base(mainManager)
{
Settings = settings;
Name = "VolumeDisplay";
Enabled = Settings.Enabled;
VolumeDisplay = new VolumeBar(mainManager, settings);
}
public VolumeBar VolumeDisplay { get; set; }
public VolumeDisplaySettings Settings { get; set; }
public override void Dispose()
{
MainManager.KeyboardHook.KeyDownCallback -= KeyPressTask;
}
public override void Enable()
{
// Listener won't start unless the effect is active
MainManager.KeyboardHook.KeyDownCallback += KeyPressTask;
}
public override void Update()
{
// TODO: Get from settings
var fps = 25;
if (VolumeDisplay == null)
return;
if (VolumeDisplay.Ttl < 1)
return;
var decreaseAmount = 500/fps;
VolumeDisplay.Ttl = VolumeDisplay.Ttl - decreaseAmount;
if (VolumeDisplay.Ttl < 128)
VolumeDisplay.Transparancy = (byte) (VolumeDisplay.Transparancy - 20);
try
{
var enumerator = new MMDeviceEnumerator();
var volumeFloat =
enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console)
.AudioEndpointVolume.MasterVolumeLevelScalar;
VolumeDisplay.Volume = (int) (volumeFloat*100);
}
catch (COMException)
{
}
}
public override Bitmap GenerateBitmap()
{
return GenerateBitmap(MainManager.KeyboardManager.ActiveKeyboard.KeyboardBitmap(4));
}
public override Bitmap GenerateBitmap(Bitmap bitmap)
{
if (VolumeDisplay == null)
return bitmap;
if (VolumeDisplay.Ttl < 1)
return bitmap;
using (var g = Graphics.FromImage(bitmap))
VolumeDisplay.Draw(g);
return bitmap;
}
private void KeyPressTask(KeyEventArgs e)
{
if (e.KeyCode != Keys.VolumeUp && e.KeyCode != Keys.VolumeDown)
return;
VolumeDisplay.Ttl = 1000;
VolumeDisplay.Transparancy = 255;
}
}
}

View File

@ -1,40 +1,40 @@
using System.Windows.Media;
using Artemis.Models;
namespace Artemis.Modules.Overlays.VolumeDisplay
{
public class VolumeDisplaySettings : EffectSettings
{
public VolumeDisplaySettings()
{
Load();
}
public bool Enabled { get; set; }
public Color MainColor { get; set; }
public Color SecondaryColor { get; set; }
public sealed override void Load()
{
Enabled = VolumeDisplay.Default.Enabled;
MainColor = VolumeDisplay.Default.MainColor;
SecondaryColor = VolumeDisplay.Default.SecondaryColor;
}
public sealed override void Save()
{
VolumeDisplay.Default.Enabled = Enabled;
VolumeDisplay.Default.MainColor = MainColor;
VolumeDisplay.Default.SecondaryColor = SecondaryColor;
VolumeDisplay.Default.Save();
}
public sealed override void ToDefault()
{
Enabled = true;
MainColor = Color.FromArgb(255, 38, 246, 0);
SecondaryColor = Color.FromArgb(255, 255, 41, 0);
}
}
using System.Windows.Media;
using Artemis.Models;
namespace Artemis.Modules.Overlays.VolumeDisplay
{
public class VolumeDisplaySettings : EffectSettings
{
public VolumeDisplaySettings()
{
Load();
}
public bool Enabled { get; set; }
public Color MainColor { get; set; }
public Color SecondaryColor { get; set; }
public sealed override void Load()
{
Enabled = VolumeDisplay.Default.Enabled;
MainColor = VolumeDisplay.Default.MainColor;
SecondaryColor = VolumeDisplay.Default.SecondaryColor;
}
public sealed override void Save()
{
VolumeDisplay.Default.Enabled = Enabled;
VolumeDisplay.Default.MainColor = MainColor;
VolumeDisplay.Default.SecondaryColor = SecondaryColor;
VolumeDisplay.Default.Save();
}
public sealed override void ToDefault()
{
Enabled = true;
MainColor = Color.FromArgb(255, 38, 246, 0);
SecondaryColor = Color.FromArgb(255, 255, 41, 0);
}
}
}

View File

@ -1,15 +1,15 @@
using System.Windows.Controls;
namespace Artemis.Modules.Overlays.VolumeDisplay
{
/// <summary>
/// Interaction logic for MediaKeysDisplayView.xaml
/// </summary>
public partial class VolumeDisplayView : UserControl
{
public VolumeDisplayView()
{
InitializeComponent();
}
}
using System.Windows.Controls;
namespace Artemis.Modules.Overlays.VolumeDisplay
{
/// <summary>
/// Interaction logic for MediaKeysDisplayView.xaml
/// </summary>
public partial class VolumeDisplayView : UserControl
{
public VolumeDisplayView()
{
InitializeComponent();
}
}
}

View File

@ -1,60 +1,60 @@
using Artemis.Managers;
using Caliburn.Micro;
namespace Artemis.Modules.Overlays.VolumeDisplay
{
public class VolumeDisplayViewModel : Screen
{
private VolumeDisplaySettings _volumeDisplaySettings;
public VolumeDisplayViewModel(MainManager mainManager)
{
MainManager = mainManager;
// Settings are loaded from file by class
VolumeDisplaySettings = new VolumeDisplaySettings();
// Create effect model and add it to MainManager
VolumeDisplayModel = new VolumeDisplayModel(mainManager, VolumeDisplaySettings);
MainManager.EffectManager.EffectModels.Add(VolumeDisplayModel);
}
public static string Name => "Volume Display";
public MainManager MainManager { get; set; }
public VolumeDisplayModel VolumeDisplayModel { get; set; }
public VolumeDisplaySettings VolumeDisplaySettings
{
get { return _volumeDisplaySettings; }
set
{
if (Equals(value, _volumeDisplaySettings)) return;
_volumeDisplaySettings = value;
NotifyOfPropertyChange(() => VolumeDisplaySettings);
}
}
public void ToggleEffect()
{
VolumeDisplayModel.Enabled = _volumeDisplaySettings.Enabled;
}
public void SaveSettings()
{
if (VolumeDisplayModel == null)
return;
VolumeDisplaySettings.Save();
}
public void ResetSettings()
{
// TODO: Confirmation dialog (Generic MVVM approach)
VolumeDisplaySettings.ToDefault();
NotifyOfPropertyChange(() => VolumeDisplaySettings);
SaveSettings();
}
}
using Artemis.Managers;
using Caliburn.Micro;
namespace Artemis.Modules.Overlays.VolumeDisplay
{
public class VolumeDisplayViewModel : Screen
{
private VolumeDisplaySettings _volumeDisplaySettings;
public VolumeDisplayViewModel(MainManager mainManager)
{
MainManager = mainManager;
// Settings are loaded from file by class
VolumeDisplaySettings = new VolumeDisplaySettings();
// Create effect model and add it to MainManager
VolumeDisplayModel = new VolumeDisplayModel(mainManager, VolumeDisplaySettings);
MainManager.EffectManager.EffectModels.Add(VolumeDisplayModel);
}
public static string Name => "Volume Display";
public MainManager MainManager { get; set; }
public VolumeDisplayModel VolumeDisplayModel { get; set; }
public VolumeDisplaySettings VolumeDisplaySettings
{
get { return _volumeDisplaySettings; }
set
{
if (Equals(value, _volumeDisplaySettings)) return;
_volumeDisplaySettings = value;
NotifyOfPropertyChange(() => VolumeDisplaySettings);
}
}
public void ToggleEffect()
{
VolumeDisplayModel.Enabled = _volumeDisplaySettings.Enabled;
}
public void SaveSettings()
{
if (VolumeDisplayModel == null)
return;
VolumeDisplaySettings.Save();
}
public void ResetSettings()
{
// TODO: Confirmation dialog (Generic MVVM approach)
VolumeDisplaySettings.ToDefault();
NotifyOfPropertyChange(() => VolumeDisplaySettings);
SaveSettings();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,56 +1,56 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Artemis")]
[assembly: AssemblyDescription("Adds third-party support for RGB keyboards to games")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Artemis developers")]
[assembly: AssemblyProduct("Artemis")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Artemis")]
[assembly: AssemblyDescription("Adds third-party support for RGB keyboards to games")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Artemis developers")]
[assembly: AssemblyProduct("Artemis")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,18 +1,18 @@
"Artemis"
{
"uri" "http://localhost:{{port}}/csgo_game_event"
"timeout" "5.0"
"buffer" "0.1"
"throttle" "0.1"
"heartbeat" "30.0"
"data"
{
"provider" "1"
"map" "1"
"round" "1"
"player_id" "1"
"player_state" "1"
"player_weapons" "1"
"player_match_stats" "1"
}
"Artemis"
{
"uri" "http://localhost:{{port}}/csgo_game_event"
"timeout" "5.0"
"buffer" "0.1"
"throttle" "0.1"
"heartbeat" "30.0"
"data"
{
"provider" "1"
"map" "1"
"round" "1"
"player_id" "1"
"player_state" "1"
"player_weapons" "1"
"player_match_stats" "1"
}
}

View File

@ -1,3 +1,3 @@
Entypo (http://www.entypo.com/) is created by Daniel Bruce and released under the Creative Commons, Share Alike/Attribution license.
Entypo (http://www.entypo.com/) is created by Daniel Bruce and released under the Creative Commons, Share Alike/Attribution license.
http://creativecommons.org/licenses/by-sa/3.0/

View File

@ -1,62 +1,62 @@
# License
Please carefully understand the license and download the latest icons at ModernUIIcons.com.
## Understand Your Rights
No Attribution and No Derived Works
http://creativecommons.org/licenses/by-nd/3.0/ *
- If your project is open source include this license file in the source.
- Nothing is needed in the front facing project (UNLESS you
are using any of the icons listed below in the attribution section).
- Commercial use is not only allowed but encouraged. If it is an icon
in the attribution list below, you still need to attribute those!
- Do not distribute the entire package (I've allowed this dozens of
times for open source projects, but email me first).
## Creator
- Austin Andrews (@templarian)
## Contributor**
- Jay Zawrotny (@JayZawrotny)
- A Bunch
- Oren Nachman
- appbar.chevron.down
- appbar.chevron.up
- appbar.chevron.left
- appbar.chevron.right
## Derived Works
- Alex Peattie
- Social: http://www.alexpeattie.com/projects/justvector_icons/
## Attribution***
- Kris Vandermotten (@kvandermotten)
- appbar.medical.pulse
- Constantin Kichinsky (@kichinsky)
- appbar.currency.rubles
- appbar.currency.grivna
- Massimo Savazzi (@msavazzi)
- List of missing exported icons
- Proletkult Graphik, from The Noun Project
- appbar.draw.pen (inspired)
- Olivier Guin, from The Noun Project
- appbar.draw.marker
- Gibran Bisio, from The Noun Project
- appbar.draw.bucket
Andrew Forrester, from The Noun Project
- appbar.fingerprint
* The license is for attribution, but this is not required.
** Developers and designers that emailed Templarian the source .design icons to be added into the package. PNGs also accepted, but may take longer to be added.
*** Icons I've copied so closely you want to attribute them and are also under the CC license.
Contact
- http://templarian.com/
- admin[@]templarian[.]com
* Does not apply to copyrighted logos
- Skype
- Facebook
- Twitter
- etc...
# License
Please carefully understand the license and download the latest icons at ModernUIIcons.com.
## Understand Your Rights
No Attribution and No Derived Works
http://creativecommons.org/licenses/by-nd/3.0/ *
- If your project is open source include this license file in the source.
- Nothing is needed in the front facing project (UNLESS you
are using any of the icons listed below in the attribution section).
- Commercial use is not only allowed but encouraged. If it is an icon
in the attribution list below, you still need to attribute those!
- Do not distribute the entire package (I've allowed this dozens of
times for open source projects, but email me first).
## Creator
- Austin Andrews (@templarian)
## Contributor**
- Jay Zawrotny (@JayZawrotny)
- A Bunch
- Oren Nachman
- appbar.chevron.down
- appbar.chevron.up
- appbar.chevron.left
- appbar.chevron.right
## Derived Works
- Alex Peattie
- Social: http://www.alexpeattie.com/projects/justvector_icons/
## Attribution***
- Kris Vandermotten (@kvandermotten)
- appbar.medical.pulse
- Constantin Kichinsky (@kichinsky)
- appbar.currency.rubles
- appbar.currency.grivna
- Massimo Savazzi (@msavazzi)
- List of missing exported icons
- Proletkult Graphik, from The Noun Project
- appbar.draw.pen (inspired)
- Olivier Guin, from The Noun Project
- appbar.draw.marker
- Gibran Bisio, from The Noun Project
- appbar.draw.bucket
Andrew Forrester, from The Noun Project
- appbar.fingerprint
* The license is for attribution, but this is not required.
** Developers and designers that emailed Templarian the source .design icons to be added into the package. PNGs also accepted, but may take longer to be added.
*** Icons I've copied so closely you want to attribute them and are also under the CC license.
Contact
- http://templarian.com/
- admin[@]templarian[.]com
* Does not apply to copyrighted logos
- Skype
- Facebook
- Twitter
- etc...

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-16"?>
<!-- Used by Artemis to get the active Sign -->
<UserConfig>
<Group id="Artemis" displayName="Artemis">
<VisibleVars>
<Var id="ActiveSign" displayName="ActiveSign" displayType="SLIDER:0:1:1000000"/>
</VisibleVars>
</Group>
<?xml version="1.0" encoding="UTF-16"?>
<!-- Used by Artemis to get the active Sign -->
<UserConfig>
<Group id="Artemis" displayName="Artemis">
<VisibleVars>
<Var id="ActiveSign" displayName="ActiveSign" displayType="SLIDER:0:1:1000000"/>
</VisibleVars>
</Group>
</UserConfig>

View File

@ -1,100 +1,100 @@
using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices.ComTypes;
using Artemis.Utilities;
namespace Artemis.Settings
{
public class GeneralSettings
{
public int GamestatePort
{
get { return General.Default.GamestatePort; }
set
{
if (General.Default.GamestatePort == value) return;
General.Default.GamestatePort = value;
}
}
public bool EnablePointersUpdate
{
get { return General.Default.EnablePointersUpdate; }
set
{
if (General.Default.EnablePointersUpdate == value) return;
General.Default.EnablePointersUpdate = value;
}
}
public bool Autorun
{
get { return General.Default.Autorun; }
set
{
if (General.Default.Autorun == value) return;
General.Default.Autorun = value;
}
}
public bool CheckForUpdates
{
get { return General.Default.CheckForUpdates; }
set
{
if (General.Default.CheckForUpdates == value) return;
General.Default.CheckForUpdates = value;
}
}
public bool ShowOnStartup
{
get { return General.Default.ShowOnStartup; }
set
{
if (General.Default.ShowOnStartup == value) return;
General.Default.ShowOnStartup = value;
}
}
private void ApplyGamestatePort()
{
// TODO: Restart Gamestate server with new port
}
private void ApplyAutorun()
{
var startupFolder = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
if (Autorun)
{
var link = (IShellLink) new ShellLink();
link.SetPath(Assembly.GetExecutingAssembly().Location);
var file = (IPersistFile) link;
file.Save(startupFolder + @"\Artemis.lnk", false);
}
else if (File.Exists(startupFolder + @"\Artemis.lnk"))
File.Delete(startupFolder + @"\Artemis.lnk");
}
public void SaveSettings()
{
General.Default.Save();
ApplyAutorun();
ApplyGamestatePort();
}
public void ResetSettings()
{
GamestatePort = 51364;
EnablePointersUpdate = true;
Autorun = true;
CheckForUpdates = true;
ShowOnStartup = true;
SaveSettings();
}
}
using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices.ComTypes;
using Artemis.Utilities;
namespace Artemis.Settings
{
public class GeneralSettings
{
public int GamestatePort
{
get { return General.Default.GamestatePort; }
set
{
if (General.Default.GamestatePort == value) return;
General.Default.GamestatePort = value;
}
}
public bool EnablePointersUpdate
{
get { return General.Default.EnablePointersUpdate; }
set
{
if (General.Default.EnablePointersUpdate == value) return;
General.Default.EnablePointersUpdate = value;
}
}
public bool Autorun
{
get { return General.Default.Autorun; }
set
{
if (General.Default.Autorun == value) return;
General.Default.Autorun = value;
}
}
public bool CheckForUpdates
{
get { return General.Default.CheckForUpdates; }
set
{
if (General.Default.CheckForUpdates == value) return;
General.Default.CheckForUpdates = value;
}
}
public bool ShowOnStartup
{
get { return General.Default.ShowOnStartup; }
set
{
if (General.Default.ShowOnStartup == value) return;
General.Default.ShowOnStartup = value;
}
}
private void ApplyGamestatePort()
{
// TODO: Restart Gamestate server with new port
}
private void ApplyAutorun()
{
var startupFolder = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
if (Autorun)
{
var link = (IShellLink) new ShellLink();
link.SetPath(Assembly.GetExecutingAssembly().Location);
var file = (IPersistFile) link;
file.Save(startupFolder + @"\Artemis.lnk", false);
}
else if (File.Exists(startupFolder + @"\Artemis.lnk"))
File.Delete(startupFolder + @"\Artemis.lnk");
}
public void SaveSettings()
{
General.Default.Save();
ApplyAutorun();
ApplyGamestatePort();
}
public void ResetSettings()
{
GamestatePort = 51364;
EnablePointersUpdate = true;
Autorun = true;
CheckForUpdates = true;
ShowOnStartup = true;
SaveSettings();
}
}
}

View File

@ -1,52 +1,52 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Artemis.Settings {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class Offsets : global::System.Configuration.ApplicationSettingsBase {
private static Offsets defaultInstance = ((Offsets)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Offsets())));
public static Offsets Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("{\"Game\":\"RocketLeague\",\"GameVersion\":\"1.10\",\"GameAddresses\":[{\"Description\":\"Boos" +
"t\",\"BasePointer\":{\"value\":21998084},\"Offsets\":[88,1452,1780,540]}]}")]
public string RocketLeague {
get {
return ((string)(this["RocketLeague"]));
}
set {
this["RocketLeague"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("{\"Game\":\"Witcher3\",\"GameVersion\":\"1.11\",\"GameAddresses\":[{\"Description\":\"Sign\",\"B" +
"asePointer\":{\"value\":42942304},\"Offsets\":[40,16,32,3008]}]}")]
public string Witcher3 {
get {
return ((string)(this["Witcher3"]));
}
set {
this["Witcher3"] = value;
}
}
}
}
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Artemis.Settings {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
internal sealed partial class Offsets : global::System.Configuration.ApplicationSettingsBase {
private static Offsets defaultInstance = ((Offsets)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Offsets())));
public static Offsets Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("{\"Game\":\"RocketLeague\",\"GameVersion\":\"1.10\",\"GameAddresses\":[{\"Description\":\"Boos" +
"t\",\"BasePointer\":{\"value\":21998084},\"Offsets\":[88,1452,1780,540]}]}")]
public string RocketLeague {
get {
return ((string)(this["RocketLeague"]));
}
set {
this["RocketLeague"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("{\"Game\":\"Witcher3\",\"GameVersion\":\"1.11\",\"GameAddresses\":[{\"Description\":\"Sign\",\"B" +
"asePointer\":{\"value\":42942304},\"Offsets\":[40,16,32,3008]}]}")]
public string Witcher3 {
get {
return ((string)(this["Witcher3"]));
}
set {
this["Witcher3"] = value;
}
}
}
}

View File

@ -1,83 +1,83 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
namespace Artemis.Utilities
{
public static class ColorHelpers
{
/// <summary>
/// Comes up with a 'pure' psuedo-random color
/// </summary>
/// <returns>The color</returns>
public static Color GetRandomRainbowColor()
{
var colors = new List<int>();
var rand = new Random();
for (var i = 0; i < 3; i++)
colors.Add(rand.Next(0, 256));
var highest = colors.Max();
var lowest = colors.Min();
colors[colors.FindIndex(c => c == highest)] = 255;
colors[colors.FindIndex(c => c == lowest)] = 0;
var returnColor = Color.FromArgb(255, colors[0], colors[1], colors[2]);
return returnColor;
}
public static Color ShiftColor(Color c, int shiftAmount)
{
int newRed = c.R;
int newGreen = c.G;
int newBlue = c.B;
// Red to purple
if (c.R == 255 && c.B < 255 && c.G == 0)
newBlue = newBlue + shiftAmount;
// Purple to blue
else if (c.B == 255 && c.R > 0)
newRed = newRed - shiftAmount;
// Blue to light-blue
else if (c.B == 255 && c.G < 255)
newGreen = newGreen + shiftAmount;
// Light-blue to green
else if (c.G == 255 && c.B > 0)
newBlue = newBlue - shiftAmount;
// Green to yellow
else if (c.G == 255 && c.R < 255)
newRed = newRed + shiftAmount;
// Yellow to red
else if (c.R == 255 && c.G > 0)
newGreen = newGreen - shiftAmount;
newRed = BringIntInColorRange(newRed);
newGreen = BringIntInColorRange(newGreen);
newBlue = BringIntInColorRange(newBlue);
return Color.FromArgb(c.A, newRed, newGreen, newBlue);
}
private static int BringIntInColorRange(int i)
{
if (i < 0)
return 0;
if (i > 255)
return 255;
return i;
}
public static Color ToDrawingColor(System.Windows.Media.Color mColor)
{
return Color.FromArgb(mColor.A, mColor.R, mColor.G, mColor.B);
}
public static System.Windows.Media.Color ToMediaColor(Color dColor)
{
return System.Windows.Media.Color.FromArgb(dColor.A, dColor.R, dColor.G, dColor.B);
}
}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
namespace Artemis.Utilities
{
public static class ColorHelpers
{
/// <summary>
/// Comes up with a 'pure' psuedo-random color
/// </summary>
/// <returns>The color</returns>
public static Color GetRandomRainbowColor()
{
var colors = new List<int>();
var rand = new Random();
for (var i = 0; i < 3; i++)
colors.Add(rand.Next(0, 256));
var highest = colors.Max();
var lowest = colors.Min();
colors[colors.FindIndex(c => c == highest)] = 255;
colors[colors.FindIndex(c => c == lowest)] = 0;
var returnColor = Color.FromArgb(255, colors[0], colors[1], colors[2]);
return returnColor;
}
public static Color ShiftColor(Color c, int shiftAmount)
{
int newRed = c.R;
int newGreen = c.G;
int newBlue = c.B;
// Red to purple
if (c.R == 255 && c.B < 255 && c.G == 0)
newBlue = newBlue + shiftAmount;
// Purple to blue
else if (c.B == 255 && c.R > 0)
newRed = newRed - shiftAmount;
// Blue to light-blue
else if (c.B == 255 && c.G < 255)
newGreen = newGreen + shiftAmount;
// Light-blue to green
else if (c.G == 255 && c.B > 0)
newBlue = newBlue - shiftAmount;
// Green to yellow
else if (c.G == 255 && c.R < 255)
newRed = newRed + shiftAmount;
// Yellow to red
else if (c.R == 255 && c.G > 0)
newGreen = newGreen - shiftAmount;
newRed = BringIntInColorRange(newRed);
newGreen = BringIntInColorRange(newGreen);
newBlue = BringIntInColorRange(newBlue);
return Color.FromArgb(c.A, newRed, newGreen, newBlue);
}
private static int BringIntInColorRange(int i)
{
if (i < 0)
return 0;
if (i > 255)
return 255;
return i;
}
public static Color ToDrawingColor(System.Windows.Media.Color mColor)
{
return Color.FromArgb(mColor.A, mColor.R, mColor.G, mColor.B);
}
public static System.Windows.Media.Color ToMediaColor(Color dColor)
{
return System.Windows.Media.Color.FromArgb(dColor.A, dColor.R, dColor.G, dColor.B);
}
}
}

View File

@ -1,14 +1,14 @@
using System;
namespace Artemis.Utilities.GameState
{
public class GameDataReceivedEventArgs : EventArgs
{
public GameDataReceivedEventArgs(object json)
{
Json = json;
}
public object Json { get; set; }
}
using System;
namespace Artemis.Utilities.GameState
{
public class GameDataReceivedEventArgs : EventArgs
{
public GameDataReceivedEventArgs(object json)
{
Json = json;
}
public object Json { get; set; }
}
}

View File

@ -37,12 +37,12 @@ namespace Artemis.Utilities
Environment.Exit(0);
}
public static bool IsRunAsAdministrator()
{
var wi = WindowsIdentity.GetCurrent();
var wp = new WindowsPrincipal(wi);
return wp.IsInRole(WindowsBuiltInRole.Administrator);
public static bool IsRunAsAdministrator()
{
var wi = WindowsIdentity.GetCurrent();
var wp = new WindowsPrincipal(wi);
return wp.IsInRole(WindowsBuiltInRole.Administrator);
}
}
}

View File

@ -1,18 +1,18 @@
using System.Windows.Forms;
namespace Artemis.Utilities.Keyboard
{
public class Key
{
public Key(Keys keyCode, int posX, int posY)
{
KeyCode = keyCode;
PosX = posX;
PosY = posY;
}
public Keys KeyCode { get; set; }
public int PosX { get; set; }
public int PosY { get; set; }
}
using System.Windows.Forms;
namespace Artemis.Utilities.Keyboard
{
public class Key
{
public Key(Keys keyCode, int posX, int posY)
{
KeyCode = keyCode;
PosX = posX;
PosY = posY;
}
public Keys KeyCode { get; set; }
public int PosX { get; set; }
public int PosY { get; set; }
}
}

View File

@ -1,24 +1,24 @@
using System.Threading.Tasks;
using System.Windows.Forms;
using VirtualInput;
namespace Artemis.Utilities.Keyboard
{
public class KeyboardHook
{
public delegate void KeyDownCallbackHandler(KeyEventArgs e);
public KeyboardHook()
{
VirtualKeyboard.KeyDown += VirtualKeyboardOnKeyDown;
VirtualKeyboard.StartInterceptor();
}
private void VirtualKeyboardOnKeyDown(object sender, KeyEventArgs keyEventArgs)
{
Task.Factory.StartNew(() => { KeyDownCallback?.Invoke(keyEventArgs); });
}
public event KeyDownCallbackHandler KeyDownCallback;
}
using System.Threading.Tasks;
using System.Windows.Forms;
using VirtualInput;
namespace Artemis.Utilities.Keyboard
{
public class KeyboardHook
{
public delegate void KeyDownCallbackHandler(KeyEventArgs e);
public KeyboardHook()
{
VirtualKeyboard.KeyDown += VirtualKeyboardOnKeyDown;
VirtualKeyboard.StartInterceptor();
}
private void VirtualKeyboardOnKeyDown(object sender, KeyEventArgs keyEventArgs)
{
Task.Factory.StartNew(() => { KeyDownCallback?.Invoke(keyEventArgs); });
}
public event KeyDownCallbackHandler KeyDownCallback;
}
}

View File

@ -1,194 +1,194 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Artemis.KeyboardProviders;
namespace Artemis.Utilities.Keyboard
{
public class KeyboardRectangle
{
private readonly BackgroundWorker _blinkWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
private readonly KeyboardProvider _keyboard;
private int _blinkDelay;
private double _rotationProgress;
/// <summary>
/// Represents a Rectangle on the keyboard which can be drawn to a Bitmap.
/// By default, a rectangle is the entire keyboard's size.
/// </summary>
/// <param name="keyboard">The keyboard this rectangle will be used for</param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="colors">An array of colors the ColorBlend will use</param>
/// <param name="gradientMode"></param>
public KeyboardRectangle(KeyboardProvider keyboard, int x, int y, List<Color> colors,
LinearGradientMode gradientMode)
{
_keyboard = keyboard;
_rotationProgress = 0;
_blinkWorker.DoWork += BlinkWorker_DoWork;
Scale = 4;
X = x;
Y = y;
Width = keyboard.Width*Scale;
Height = keyboard.Height*Scale;
Visible = true;
Opacity = 255;
ContainedBrush = true;
GradientMode = gradientMode;
Rotate = false;
LoopSpeed = 1;
Colors = colors;
}
public int X { get; set; }
public int Y { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public bool Visible { get; set; }
public byte Opacity { get; set; } // TODO: Remove
/// <summary>
/// Sets wether or not the colors should be contained within the rectangle, or span the entire keyboard.
/// </summary>
public bool ContainedBrush { get; set; }
/// <summary>
/// Used when ContainedBrush is set to false to make sure the colors span the entire keyboard on a higher scale.
/// </summary>
public int Scale { get; set; }
/// <summary>
/// Determines what grientmode to use in the LinearGradientBrush.
/// </summary>
public LinearGradientMode GradientMode { get; set; }
/// <summary>
/// Wether or not to rotate the colors over the brush.
/// </summary>
public bool Rotate { get; set; }
/// <summary>
/// What speed to ratate the colors on.
/// </summary>
public double LoopSpeed { get; set; }
/// <summary>
/// Colors used on the brush.
/// </summary>
public List<Color> Colors { get; set; }
public void StartBlink(int delay)
{
_blinkDelay = delay;
if (!_blinkWorker.IsBusy)
_blinkWorker.RunWorkerAsync();
}
public void StartBlink(int delay, int time)
{
StartBlink(delay);
Task.Factory.StartNew(() =>
{
Thread.Sleep(delay);
StopBlink();
});
}
public void StopBlink()
{
if (_blinkWorker.IsBusy)
_blinkWorker.CancelAsync();
}
private void BlinkWorker_DoWork(object sender, DoWorkEventArgs e)
{
while (!_blinkWorker.CancellationPending)
{
Thread.Sleep(_blinkDelay);
Visible = !Visible;
}
Visible = true;
}
public void Draw(Graphics g)
{
if (!Visible || Height < 1 || Width < 1 || !Colors.Any())
return;
var brush = CreateBrush();
var baseRect = new Rectangle(X, Y, Width, Height);
g.FillRectangle(brush, baseRect);
if (!Rotate)
return;
_rotationProgress = _rotationProgress + LoopSpeed;
if (ContainedBrush && _rotationProgress > Width)
_rotationProgress = LoopSpeed;
else if (!ContainedBrush && _rotationProgress > _keyboard.Width*Scale)
_rotationProgress = LoopSpeed;
}
private LinearGradientBrush CreateBrush()
{
var colorBlend = CreateColorBlend();
RectangleF rect;
if (Rotate)
rect = ContainedBrush
? new Rectangle((int) _rotationProgress, Y, Width*2, Height*2)
: new Rectangle((int) _rotationProgress, 0, _keyboard.Width*Scale*2, _keyboard.Height*Scale*2);
else
rect = ContainedBrush
? new Rectangle(X, Y, Width, Height)
: new Rectangle(0, 0, _keyboard.Width*Scale, _keyboard.Height*Scale);
return new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, GradientMode)
{
InterpolationColors = colorBlend
};
}
private ColorBlend CreateColorBlend()
{
if (Colors.Count == 1)
return new ColorBlend {Colors = new[] {Colors[0], Colors[0]}, Positions = new[] {0F, 1F}};
var colorBlend = Rotate
? new ColorBlend {Colors = CreateTilebleColors(Colors).ToArray()}
: new ColorBlend {Colors = Colors.ToArray()};
// If needed, apply opacity to the colors in the blend
if (Opacity < 255)
for (var i = 0; i < colorBlend.Colors.Length; i++)
colorBlend.Colors[i] = Color.FromArgb(Opacity, colorBlend.Colors[i]);
// Devide the colors over the colorblend
var devider = (float) colorBlend.Colors.Length - 1;
var positions = new List<float>();
for (var i = 0; i < colorBlend.Colors.Length; i++)
positions.Add(i/devider);
// Apply the devided positions
colorBlend.Positions = positions.ToArray();
return colorBlend;
}
private List<Color> CreateTilebleColors(List<Color> sourceColors)
{
// Create a list using the original colors
var tilebleColors = new List<Color>(sourceColors);
// Add the original colors again
tilebleColors.AddRange(sourceColors);
// Add the first color, smoothing the transition
tilebleColors.Add(sourceColors.FirstOrDefault());
return tilebleColors;
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Artemis.KeyboardProviders;
namespace Artemis.Utilities.Keyboard
{
public class KeyboardRectangle
{
private readonly BackgroundWorker _blinkWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
private readonly KeyboardProvider _keyboard;
private int _blinkDelay;
private double _rotationProgress;
/// <summary>
/// Represents a Rectangle on the keyboard which can be drawn to a Bitmap.
/// By default, a rectangle is the entire keyboard's size.
/// </summary>
/// <param name="keyboard">The keyboard this rectangle will be used for</param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="colors">An array of colors the ColorBlend will use</param>
/// <param name="gradientMode"></param>
public KeyboardRectangle(KeyboardProvider keyboard, int x, int y, List<Color> colors,
LinearGradientMode gradientMode)
{
_keyboard = keyboard;
_rotationProgress = 0;
_blinkWorker.DoWork += BlinkWorker_DoWork;
Scale = 4;
X = x;
Y = y;
Width = keyboard.Width*Scale;
Height = keyboard.Height*Scale;
Visible = true;
Opacity = 255;
ContainedBrush = true;
GradientMode = gradientMode;
Rotate = false;
LoopSpeed = 1;
Colors = colors;
}
public int X { get; set; }
public int Y { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public bool Visible { get; set; }
public byte Opacity { get; set; } // TODO: Remove
/// <summary>
/// Sets wether or not the colors should be contained within the rectangle, or span the entire keyboard.
/// </summary>
public bool ContainedBrush { get; set; }
/// <summary>
/// Used when ContainedBrush is set to false to make sure the colors span the entire keyboard on a higher scale.
/// </summary>
public int Scale { get; set; }
/// <summary>
/// Determines what grientmode to use in the LinearGradientBrush.
/// </summary>
public LinearGradientMode GradientMode { get; set; }
/// <summary>
/// Wether or not to rotate the colors over the brush.
/// </summary>
public bool Rotate { get; set; }
/// <summary>
/// What speed to ratate the colors on.
/// </summary>
public double LoopSpeed { get; set; }
/// <summary>
/// Colors used on the brush.
/// </summary>
public List<Color> Colors { get; set; }
public void StartBlink(int delay)
{
_blinkDelay = delay;
if (!_blinkWorker.IsBusy)
_blinkWorker.RunWorkerAsync();
}
public void StartBlink(int delay, int time)
{
StartBlink(delay);
Task.Factory.StartNew(() =>
{
Thread.Sleep(delay);
StopBlink();
});
}
public void StopBlink()
{
if (_blinkWorker.IsBusy)
_blinkWorker.CancelAsync();
}
private void BlinkWorker_DoWork(object sender, DoWorkEventArgs e)
{
while (!_blinkWorker.CancellationPending)
{
Thread.Sleep(_blinkDelay);
Visible = !Visible;
}
Visible = true;
}
public void Draw(Graphics g)
{
if (!Visible || Height < 1 || Width < 1 || !Colors.Any())
return;
var brush = CreateBrush();
var baseRect = new Rectangle(X, Y, Width, Height);
g.FillRectangle(brush, baseRect);
if (!Rotate)
return;
_rotationProgress = _rotationProgress + LoopSpeed;
if (ContainedBrush && _rotationProgress > Width)
_rotationProgress = LoopSpeed;
else if (!ContainedBrush && _rotationProgress > _keyboard.Width*Scale)
_rotationProgress = LoopSpeed;
}
private LinearGradientBrush CreateBrush()
{
var colorBlend = CreateColorBlend();
RectangleF rect;
if (Rotate)
rect = ContainedBrush
? new Rectangle((int) _rotationProgress, Y, Width*2, Height*2)
: new Rectangle((int) _rotationProgress, 0, _keyboard.Width*Scale*2, _keyboard.Height*Scale*2);
else
rect = ContainedBrush
? new Rectangle(X, Y, Width, Height)
: new Rectangle(0, 0, _keyboard.Width*Scale, _keyboard.Height*Scale);
return new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, GradientMode)
{
InterpolationColors = colorBlend
};
}
private ColorBlend CreateColorBlend()
{
if (Colors.Count == 1)
return new ColorBlend {Colors = new[] {Colors[0], Colors[0]}, Positions = new[] {0F, 1F}};
var colorBlend = Rotate
? new ColorBlend {Colors = CreateTilebleColors(Colors).ToArray()}
: new ColorBlend {Colors = Colors.ToArray()};
// If needed, apply opacity to the colors in the blend
if (Opacity < 255)
for (var i = 0; i < colorBlend.Colors.Length; i++)
colorBlend.Colors[i] = Color.FromArgb(Opacity, colorBlend.Colors[i]);
// Devide the colors over the colorblend
var devider = (float) colorBlend.Colors.Length - 1;
var positions = new List<float>();
for (var i = 0; i < colorBlend.Colors.Length; i++)
positions.Add(i/devider);
// Apply the devided positions
colorBlend.Positions = positions.ToArray();
return colorBlend;
}
private List<Color> CreateTilebleColors(List<Color> sourceColors)
{
// Create a list using the original colors
var tilebleColors = new List<Color>(sourceColors);
// Add the original colors again
tilebleColors.AddRange(sourceColors);
// Add the first color, smoothing the transition
tilebleColors.Add(sourceColors.FirstOrDefault());
return tilebleColors;
}
}
}

View File

@ -1,425 +1,425 @@
using System;
using System.Diagnostics;
using System.Text.RegularExpressions;
namespace Artemis.Utilities.Memory
{
/// <summary>
/// Represents an access to a remote process memory
/// </summary>
public class Memory : IDisposable
{
public const string OffsetPattern = "(\\+|\\-){0,1}(0x){0,1}[a-fA-F0-9]{1,}";
private bool isDisposed;
private IntPtr processHandle;
/// <summary>
/// Initializes a new instance of the Memory
/// </summary>
/// <param name="process">Remote process</param>
public Memory(Process process)
{
if (process == null)
throw new ArgumentNullException("process");
Process = process;
processHandle = Win32.OpenProcess(
Win32.ProcessAccessType.PROCESS_VM_READ | Win32.ProcessAccessType.PROCESS_VM_WRITE |
Win32.ProcessAccessType.PROCESS_VM_OPERATION, true, (uint) process.Id);
if (processHandle == IntPtr.Zero)
throw new InvalidOperationException("Could not open the process");
}
#region Properties
/// <summary>
/// Gets the process to which this memory is attached to
/// </summary>
public Process Process { get; private set; }
#endregion
/// <summary>
/// Finds module with the given name
/// </summary>
/// <param name="name">Module name</param>
/// <returns></returns>
protected ProcessModule FindModule(string name)
{
if (string.IsNullOrEmpty(name))
throw new ArgumentNullException("name");
foreach (ProcessModule module in Process.Modules)
{
if (module.ModuleName.ToLower() == name.ToLower())
return module;
}
return null;
}
/// <summary>
/// Gets module based address
/// </summary>
/// <param name="moduleName">Module name</param>
/// <param name="baseAddress">Base address</param>
/// <param name="offsets">Collection of offsets</param>
/// <returns></returns>
public IntPtr GetAddress(string moduleName, IntPtr baseAddress, int[] offsets)
{
if (string.IsNullOrEmpty(moduleName))
throw new ArgumentNullException("moduleName");
var module = FindModule(moduleName);
if (module == null)
return IntPtr.Zero;
var address = module.BaseAddress.ToInt32() + baseAddress.ToInt32();
return GetAddress((IntPtr) address, offsets);
}
/// <summary>
/// Gets module based address
/// </summary>
/// <param name="moduleName">Module name</param>
/// <param name="baseAddress">Base address</param>
/// <param name="offsets">Collection of offsets</param>
/// <returns></returns>
public IntPtr GetAddressX64(string moduleName, IntPtr baseAddress, int[] offsets)
{
if (string.IsNullOrEmpty(moduleName))
throw new ArgumentNullException("moduleName");
var module = FindModule(moduleName);
if (module == null)
return IntPtr.Zero;
var address = module.BaseAddress.ToInt64() + baseAddress.ToInt64();
return GetAddressX64((IntPtr) address, offsets);
}
/// <summary>
/// Gets address
/// </summary>
/// <param name="baseAddress">Base address</param>
/// <param name="offsets">Collection of offsets</param>
/// <returns></returns>
public IntPtr GetAddress(IntPtr baseAddress, int[] offsets)
{
if (baseAddress == IntPtr.Zero)
throw new ArgumentException("Invalid base address");
var address = baseAddress.ToInt32();
if (offsets != null && offsets.Length > 0)
{
var buffer = new byte[4];
foreach (var offset in offsets)
address = ReadInt32((IntPtr) address) + offset;
}
return (IntPtr) address;
}
/// <summary>
/// Gets address
/// </summary>
/// <param name="baseAddress">Base address</param>
/// <param name="offsets">Collection of offsets</param>
/// <returns></returns>
public IntPtr GetAddressX64(IntPtr baseAddress, int[] offsets)
{
if (baseAddress == IntPtr.Zero)
throw new ArgumentException("Invalid base address");
var address = baseAddress.ToInt64();
if (offsets != null && offsets.Length > 0)
{
var buffer = new byte[4];
foreach (var offset in offsets)
address = ReadInt32((IntPtr) address) + offset;
}
return (IntPtr) address;
}
/// <summary>
/// Gets address pointer
/// </summary>
/// <param name="address">Address</param>
/// <returns></returns>
public IntPtr GetAddressX64(string address)
{
if (string.IsNullOrEmpty(address))
throw new ArgumentNullException("address");
string moduleName = null;
var index = address.IndexOf('"');
if (index != -1)
{
// Module name at the beginning
var endIndex = address.IndexOf('"', index + 1);
if (endIndex == -1)
throw new ArgumentException("Invalid module name. Could not find matching \"");
moduleName = address.Substring(index + 1, endIndex - 1);
address = address.Substring(endIndex + 1);
}
var offsets = GetAddressOffsets(address);
int[] _offsets = null;
var baseAddress = offsets != null && offsets.Length > 0
? (IntPtr) offsets[0]
: IntPtr.Zero;
if (offsets != null && offsets.Length > 1)
{
_offsets = new int[offsets.Length - 1];
for (var i = 0; i < offsets.Length - 1; i++)
_offsets[i] = offsets[i + 1];
}
if (moduleName != null)
return GetAddressX64(moduleName, baseAddress, _offsets);
return GetAddressX64(baseAddress, _offsets);
}
/// <summary>
/// Gets address pointer
/// </summary>
/// <param name="address">Address</param>
/// <returns></returns>
public IntPtr GetAddress(string address)
{
if (string.IsNullOrEmpty(address))
throw new ArgumentNullException("address");
string moduleName = null;
var index = address.IndexOf('"');
if (index != -1)
{
// Module name at the beginning
var endIndex = address.IndexOf('"', index + 1);
if (endIndex == -1)
throw new ArgumentException("Invalid module name. Could not find matching \"");
moduleName = address.Substring(index + 1, endIndex - 1);
address = address.Substring(endIndex + 1);
}
var offsets = GetAddressOffsets(address);
int[] _offsets = null;
var baseAddress = offsets != null && offsets.Length > 0
? (IntPtr) offsets[0]
: IntPtr.Zero;
if (offsets != null && offsets.Length > 1)
{
_offsets = new int[offsets.Length - 1];
for (var i = 0; i < offsets.Length - 1; i++)
_offsets[i] = offsets[i + 1];
}
if (moduleName != null)
return GetAddress(moduleName, baseAddress, _offsets);
return GetAddress(baseAddress, _offsets);
}
/// <summary>
/// Gets address offsets
/// </summary>
/// <param name="address">Address</param>
/// <returns></returns>
protected static int[] GetAddressOffsets(string address)
{
if (string.IsNullOrEmpty(address))
return new int[0];
var matches = Regex.Matches(address, OffsetPattern);
var offsets = new int[matches.Count];
string value;
char ch;
for (var i = 0; i < matches.Count; i++)
{
ch = matches[i].Value[0];
if (ch == '+' || ch == '-')
value = matches[i].Value.Substring(1);
else
value = matches[i].Value;
offsets[i] = Convert.ToInt32(value, 16);
if (ch == '-')
offsets[i] = -offsets[i];
}
return offsets;
}
/// <summary>
/// Reads memory at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <param name="buffer">Buffer</param>
/// <param name="size">Size in bytes</param>
public void ReadMemory(IntPtr address, byte[] buffer, int size)
{
if (isDisposed)
throw new ObjectDisposedException("Memory");
if (buffer == null)
throw new ArgumentNullException("buffer");
if (size <= 0)
throw new ArgumentException("Size must be greater than zero");
if (address == IntPtr.Zero)
throw new ArgumentException("Invalid address");
uint read = 0;
Win32.ReadProcessMemory(processHandle, address, buffer, (uint) size, ref read);
}
/// <summary>
/// Writes memory at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <param name="buffer">Buffer</param>
/// <param name="size">Size in bytes</param>
public void WriteMemory(IntPtr address, byte[] buffer, int size)
{
if (isDisposed)
throw new ObjectDisposedException("Memory");
if (buffer == null)
throw new ArgumentNullException("buffer");
if (size <= 0)
throw new ArgumentException("Size must be greater than zero");
if (address == IntPtr.Zero)
throw new ArgumentException("Invalid address");
uint write = 0;
if (!Win32.WriteProcessMemory(processHandle, address, buffer, (uint) size, ref write) ||
write != size)
throw new AccessViolationException();
}
/// <summary>
/// Reads 32 bit signed integer at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <returns></returns>
public int ReadInt32(IntPtr address)
{
var buffer = new byte[4];
ReadMemory(address, buffer, 4);
return BitConverter.ToInt32(buffer, 0);
}
/// <summary>
/// Reads 32 bit signed integer at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <returns></returns>
public long ReadInt64(IntPtr address)
{
var buffer = new byte[8];
ReadMemory(address, buffer, 8);
return BitConverter.ToInt64(buffer, 0);
}
/// <summary>
/// Reads 32 bit unsigned integer at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <returns></returns>
public uint ReadUInt32(IntPtr address)
{
var buffer = new byte[4];
ReadMemory(address, buffer, 4);
return BitConverter.ToUInt32(buffer, 0);
}
/// <summary>
/// Reads single precision value at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <returns></returns>
public float ReadFloat(IntPtr address)
{
var buffer = new byte[4];
ReadMemory(address, buffer, 4);
return BitConverter.ToSingle(buffer, 0);
}
/// <summary>
/// Reads double precision value at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <returns></returns>
public double ReadDouble(IntPtr address)
{
var buffer = new byte[8];
ReadMemory(address, buffer, 8);
return BitConverter.ToDouble(buffer, 0);
}
/// <summary>
/// Writes 32 bit unsigned integer at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <param name="value">Value</param>
/// <returns></returns>
public void WriteUInt32(IntPtr address, uint value)
{
var buffer = BitConverter.GetBytes(value);
WriteMemory(address, buffer, 4);
}
/// <summary>
/// Writes 32 bit signed integer at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <param name="value">Value</param>
/// <returns></returns>
public void WriteInt32(IntPtr address, int value)
{
var buffer = BitConverter.GetBytes(value);
WriteMemory(address, buffer, 4);
}
/// <summary>
/// Writes single precision value at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <param name="value">Value</param>
/// <returns></returns>
public void WriteFloat(IntPtr address, float value)
{
var buffer = BitConverter.GetBytes(value);
WriteMemory(address, buffer, 4);
}
/// <summary>
/// Writes double precision value at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <param name="value">Value</param>
/// <returns></returns>
public void WriteDouble(IntPtr address, double value)
{
var buffer = BitConverter.GetBytes(value);
WriteMemory(address, buffer, 8);
}
#region IDisposable
~Memory()
{
Dispose(false);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
if (isDisposed)
return;
Win32.CloseHandle(processHandle);
Process = null;
processHandle = IntPtr.Zero;
isDisposed = true;
}
#endregion
}
using System;
using System.Diagnostics;
using System.Text.RegularExpressions;
namespace Artemis.Utilities.Memory
{
/// <summary>
/// Represents an access to a remote process memory
/// </summary>
public class Memory : IDisposable
{
public const string OffsetPattern = "(\\+|\\-){0,1}(0x){0,1}[a-fA-F0-9]{1,}";
private bool isDisposed;
private IntPtr processHandle;
/// <summary>
/// Initializes a new instance of the Memory
/// </summary>
/// <param name="process">Remote process</param>
public Memory(Process process)
{
if (process == null)
throw new ArgumentNullException("process");
Process = process;
processHandle = Win32.OpenProcess(
Win32.ProcessAccessType.PROCESS_VM_READ | Win32.ProcessAccessType.PROCESS_VM_WRITE |
Win32.ProcessAccessType.PROCESS_VM_OPERATION, true, (uint) process.Id);
if (processHandle == IntPtr.Zero)
throw new InvalidOperationException("Could not open the process");
}
#region Properties
/// <summary>
/// Gets the process to which this memory is attached to
/// </summary>
public Process Process { get; private set; }
#endregion
/// <summary>
/// Finds module with the given name
/// </summary>
/// <param name="name">Module name</param>
/// <returns></returns>
protected ProcessModule FindModule(string name)
{
if (string.IsNullOrEmpty(name))
throw new ArgumentNullException("name");
foreach (ProcessModule module in Process.Modules)
{
if (module.ModuleName.ToLower() == name.ToLower())
return module;
}
return null;
}
/// <summary>
/// Gets module based address
/// </summary>
/// <param name="moduleName">Module name</param>
/// <param name="baseAddress">Base address</param>
/// <param name="offsets">Collection of offsets</param>
/// <returns></returns>
public IntPtr GetAddress(string moduleName, IntPtr baseAddress, int[] offsets)
{
if (string.IsNullOrEmpty(moduleName))
throw new ArgumentNullException("moduleName");
var module = FindModule(moduleName);
if (module == null)
return IntPtr.Zero;
var address = module.BaseAddress.ToInt32() + baseAddress.ToInt32();
return GetAddress((IntPtr) address, offsets);
}
/// <summary>
/// Gets module based address
/// </summary>
/// <param name="moduleName">Module name</param>
/// <param name="baseAddress">Base address</param>
/// <param name="offsets">Collection of offsets</param>
/// <returns></returns>
public IntPtr GetAddressX64(string moduleName, IntPtr baseAddress, int[] offsets)
{
if (string.IsNullOrEmpty(moduleName))
throw new ArgumentNullException("moduleName");
var module = FindModule(moduleName);
if (module == null)
return IntPtr.Zero;
var address = module.BaseAddress.ToInt64() + baseAddress.ToInt64();
return GetAddressX64((IntPtr) address, offsets);
}
/// <summary>
/// Gets address
/// </summary>
/// <param name="baseAddress">Base address</param>
/// <param name="offsets">Collection of offsets</param>
/// <returns></returns>
public IntPtr GetAddress(IntPtr baseAddress, int[] offsets)
{
if (baseAddress == IntPtr.Zero)
throw new ArgumentException("Invalid base address");
var address = baseAddress.ToInt32();
if (offsets != null && offsets.Length > 0)
{
var buffer = new byte[4];
foreach (var offset in offsets)
address = ReadInt32((IntPtr) address) + offset;
}
return (IntPtr) address;
}
/// <summary>
/// Gets address
/// </summary>
/// <param name="baseAddress">Base address</param>
/// <param name="offsets">Collection of offsets</param>
/// <returns></returns>
public IntPtr GetAddressX64(IntPtr baseAddress, int[] offsets)
{
if (baseAddress == IntPtr.Zero)
throw new ArgumentException("Invalid base address");
var address = baseAddress.ToInt64();
if (offsets != null && offsets.Length > 0)
{
var buffer = new byte[4];
foreach (var offset in offsets)
address = ReadInt32((IntPtr) address) + offset;
}
return (IntPtr) address;
}
/// <summary>
/// Gets address pointer
/// </summary>
/// <param name="address">Address</param>
/// <returns></returns>
public IntPtr GetAddressX64(string address)
{
if (string.IsNullOrEmpty(address))
throw new ArgumentNullException("address");
string moduleName = null;
var index = address.IndexOf('"');
if (index != -1)
{
// Module name at the beginning
var endIndex = address.IndexOf('"', index + 1);
if (endIndex == -1)
throw new ArgumentException("Invalid module name. Could not find matching \"");
moduleName = address.Substring(index + 1, endIndex - 1);
address = address.Substring(endIndex + 1);
}
var offsets = GetAddressOffsets(address);
int[] _offsets = null;
var baseAddress = offsets != null && offsets.Length > 0
? (IntPtr) offsets[0]
: IntPtr.Zero;
if (offsets != null && offsets.Length > 1)
{
_offsets = new int[offsets.Length - 1];
for (var i = 0; i < offsets.Length - 1; i++)
_offsets[i] = offsets[i + 1];
}
if (moduleName != null)
return GetAddressX64(moduleName, baseAddress, _offsets);
return GetAddressX64(baseAddress, _offsets);
}
/// <summary>
/// Gets address pointer
/// </summary>
/// <param name="address">Address</param>
/// <returns></returns>
public IntPtr GetAddress(string address)
{
if (string.IsNullOrEmpty(address))
throw new ArgumentNullException("address");
string moduleName = null;
var index = address.IndexOf('"');
if (index != -1)
{
// Module name at the beginning
var endIndex = address.IndexOf('"', index + 1);
if (endIndex == -1)
throw new ArgumentException("Invalid module name. Could not find matching \"");
moduleName = address.Substring(index + 1, endIndex - 1);
address = address.Substring(endIndex + 1);
}
var offsets = GetAddressOffsets(address);
int[] _offsets = null;
var baseAddress = offsets != null && offsets.Length > 0
? (IntPtr) offsets[0]
: IntPtr.Zero;
if (offsets != null && offsets.Length > 1)
{
_offsets = new int[offsets.Length - 1];
for (var i = 0; i < offsets.Length - 1; i++)
_offsets[i] = offsets[i + 1];
}
if (moduleName != null)
return GetAddress(moduleName, baseAddress, _offsets);
return GetAddress(baseAddress, _offsets);
}
/// <summary>
/// Gets address offsets
/// </summary>
/// <param name="address">Address</param>
/// <returns></returns>
protected static int[] GetAddressOffsets(string address)
{
if (string.IsNullOrEmpty(address))
return new int[0];
var matches = Regex.Matches(address, OffsetPattern);
var offsets = new int[matches.Count];
string value;
char ch;
for (var i = 0; i < matches.Count; i++)
{
ch = matches[i].Value[0];
if (ch == '+' || ch == '-')
value = matches[i].Value.Substring(1);
else
value = matches[i].Value;
offsets[i] = Convert.ToInt32(value, 16);
if (ch == '-')
offsets[i] = -offsets[i];
}
return offsets;
}
/// <summary>
/// Reads memory at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <param name="buffer">Buffer</param>
/// <param name="size">Size in bytes</param>
public void ReadMemory(IntPtr address, byte[] buffer, int size)
{
if (isDisposed)
throw new ObjectDisposedException("Memory");
if (buffer == null)
throw new ArgumentNullException("buffer");
if (size <= 0)
throw new ArgumentException("Size must be greater than zero");
if (address == IntPtr.Zero)
throw new ArgumentException("Invalid address");
uint read = 0;
Win32.ReadProcessMemory(processHandle, address, buffer, (uint) size, ref read);
}
/// <summary>
/// Writes memory at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <param name="buffer">Buffer</param>
/// <param name="size">Size in bytes</param>
public void WriteMemory(IntPtr address, byte[] buffer, int size)
{
if (isDisposed)
throw new ObjectDisposedException("Memory");
if (buffer == null)
throw new ArgumentNullException("buffer");
if (size <= 0)
throw new ArgumentException("Size must be greater than zero");
if (address == IntPtr.Zero)
throw new ArgumentException("Invalid address");
uint write = 0;
if (!Win32.WriteProcessMemory(processHandle, address, buffer, (uint) size, ref write) ||
write != size)
throw new AccessViolationException();
}
/// <summary>
/// Reads 32 bit signed integer at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <returns></returns>
public int ReadInt32(IntPtr address)
{
var buffer = new byte[4];
ReadMemory(address, buffer, 4);
return BitConverter.ToInt32(buffer, 0);
}
/// <summary>
/// Reads 32 bit signed integer at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <returns></returns>
public long ReadInt64(IntPtr address)
{
var buffer = new byte[8];
ReadMemory(address, buffer, 8);
return BitConverter.ToInt64(buffer, 0);
}
/// <summary>
/// Reads 32 bit unsigned integer at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <returns></returns>
public uint ReadUInt32(IntPtr address)
{
var buffer = new byte[4];
ReadMemory(address, buffer, 4);
return BitConverter.ToUInt32(buffer, 0);
}
/// <summary>
/// Reads single precision value at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <returns></returns>
public float ReadFloat(IntPtr address)
{
var buffer = new byte[4];
ReadMemory(address, buffer, 4);
return BitConverter.ToSingle(buffer, 0);
}
/// <summary>
/// Reads double precision value at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <returns></returns>
public double ReadDouble(IntPtr address)
{
var buffer = new byte[8];
ReadMemory(address, buffer, 8);
return BitConverter.ToDouble(buffer, 0);
}
/// <summary>
/// Writes 32 bit unsigned integer at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <param name="value">Value</param>
/// <returns></returns>
public void WriteUInt32(IntPtr address, uint value)
{
var buffer = BitConverter.GetBytes(value);
WriteMemory(address, buffer, 4);
}
/// <summary>
/// Writes 32 bit signed integer at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <param name="value">Value</param>
/// <returns></returns>
public void WriteInt32(IntPtr address, int value)
{
var buffer = BitConverter.GetBytes(value);
WriteMemory(address, buffer, 4);
}
/// <summary>
/// Writes single precision value at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <param name="value">Value</param>
/// <returns></returns>
public void WriteFloat(IntPtr address, float value)
{
var buffer = BitConverter.GetBytes(value);
WriteMemory(address, buffer, 4);
}
/// <summary>
/// Writes double precision value at the address
/// </summary>
/// <param name="address">Memory address</param>
/// <param name="value">Value</param>
/// <returns></returns>
public void WriteDouble(IntPtr address, double value)
{
var buffer = BitConverter.GetBytes(value);
WriteMemory(address, buffer, 8);
}
#region IDisposable
~Memory()
{
Dispose(false);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
if (isDisposed)
return;
Win32.CloseHandle(processHandle);
Process = null;
processHandle = IntPtr.Zero;
isDisposed = true;
}
#endregion
}
}

View File

@ -1,41 +1,41 @@
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Artemis.Utilities.Memory
{
public static class MemoryHelpers
{
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [Out] byte[] lpBuffer,
int dwSize, ref int lpNumberOfBytesRead);
public static Process GetProcessIfRunning(string processName)
{
var processes = Process.GetProcessesByName(processName);
return processes.Length >= 1 ? processes[0] : null;
}
public static IntPtr FindAddress(IntPtr pHandle, IntPtr baseAddress, IntPtr staticPointer, int[] offsets)
{
// Create a buffer that is 4 bytes on a 32-bit system or 8 bytes on a 64-bit system.
var tmp = new byte[IntPtr.Size];
var address = baseAddress;
// We must check for 32-bit vs 64-bit.
address = IntPtr.Size == 4
? new IntPtr(address.ToInt32() + staticPointer.ToInt32())
: new IntPtr(address.ToInt64() + staticPointer.ToInt64());
// Loop through each offset to find the address
foreach (IntPtr t in offsets)
{
var lpNumberOfBytesRead = 0;
ReadProcessMemory(pHandle, address, tmp, IntPtr.Size, ref lpNumberOfBytesRead);
address = IntPtr.Size == 4
? new IntPtr(BitConverter.ToInt32(tmp, 0) + t.ToInt32())
: new IntPtr(BitConverter.ToInt64(tmp, 0) + t.ToInt64());
}
return address;
}
}
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Artemis.Utilities.Memory
{
public static class MemoryHelpers
{
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [Out] byte[] lpBuffer,
int dwSize, ref int lpNumberOfBytesRead);
public static Process GetProcessIfRunning(string processName)
{
var processes = Process.GetProcessesByName(processName);
return processes.Length >= 1 ? processes[0] : null;
}
public static IntPtr FindAddress(IntPtr pHandle, IntPtr baseAddress, IntPtr staticPointer, int[] offsets)
{
// Create a buffer that is 4 bytes on a 32-bit system or 8 bytes on a 64-bit system.
var tmp = new byte[IntPtr.Size];
var address = baseAddress;
// We must check for 32-bit vs 64-bit.
address = IntPtr.Size == 4
? new IntPtr(address.ToInt32() + staticPointer.ToInt32())
: new IntPtr(address.ToInt64() + staticPointer.ToInt64());
// Loop through each offset to find the address
foreach (IntPtr t in offsets)
{
var lpNumberOfBytesRead = 0;
ReadProcessMemory(pHandle, address, tmp, IntPtr.Size, ref lpNumberOfBytesRead);
address = IntPtr.Size == 4
? new IntPtr(BitConverter.ToInt32(tmp, 0) + t.ToInt32())
: new IntPtr(BitConverter.ToInt64(tmp, 0) + t.ToInt64());
}
return address;
}
}
}

View File

@ -1,43 +1,43 @@
using System;
using System.Runtime.InteropServices;
namespace Artemis.Utilities.Memory
{
/// <summary>
/// Win32 methods
/// </summary>
public static class Win32
{
[Flags]
public enum ProcessAccessType
{
PROCESS_TERMINATE = 0x0001,
PROCESS_CREATE_THREAD = 0x0002,
PROCESS_SET_SESSIONID = 0x0004,
PROCESS_VM_OPERATION = 0x0008,
PROCESS_VM_READ = 0x0010,
PROCESS_VM_WRITE = 0x0020,
PROCESS_DUP_HANDLE = 0x0040,
PROCESS_CREATE_PROCESS = 0x0080,
PROCESS_SET_QUOTA = 0x0100,
PROCESS_SET_INFORMATION = 0x0200,
PROCESS_QUERY_INFORMATION = 0x0400
}
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool WriteProcessMemory(
IntPtr process, IntPtr address, byte[] buffer, uint size, ref uint written);
[DllImport("Kernel32.dll", SetLastError = true)]
public static extern bool ReadProcessMemory(
IntPtr process, IntPtr address, byte[] buffer, uint size, ref uint read);
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(
[MarshalAs(UnmanagedType.U4)] ProcessAccessType access,
[MarshalAs(UnmanagedType.Bool)] bool inheritHandler, uint processId);
[DllImport("kernel32.dll")]
public static extern int CloseHandle(IntPtr objectHandle);
}
using System;
using System.Runtime.InteropServices;
namespace Artemis.Utilities.Memory
{
/// <summary>
/// Win32 methods
/// </summary>
public static class Win32
{
[Flags]
public enum ProcessAccessType
{
PROCESS_TERMINATE = 0x0001,
PROCESS_CREATE_THREAD = 0x0002,
PROCESS_SET_SESSIONID = 0x0004,
PROCESS_VM_OPERATION = 0x0008,
PROCESS_VM_READ = 0x0010,
PROCESS_VM_WRITE = 0x0020,
PROCESS_DUP_HANDLE = 0x0040,
PROCESS_CREATE_PROCESS = 0x0080,
PROCESS_SET_QUOTA = 0x0100,
PROCESS_SET_INFORMATION = 0x0200,
PROCESS_QUERY_INFORMATION = 0x0400
}
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool WriteProcessMemory(
IntPtr process, IntPtr address, byte[] buffer, uint size, ref uint written);
[DllImport("Kernel32.dll", SetLastError = true)]
public static extern bool ReadProcessMemory(
IntPtr process, IntPtr address, byte[] buffer, uint size, ref uint read);
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(
[MarshalAs(UnmanagedType.U4)] ProcessAccessType access,
[MarshalAs(UnmanagedType.Bool)] bool inheritHandler, uint processId);
[DllImport("kernel32.dll")]
public static extern int CloseHandle(IntPtr objectHandle);
}
}

View File

@ -1,46 +1,46 @@
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace Artemis.Utilities
{
/// <summary>
/// Creates a shortcut (.lnk) file.
/// Source: http://stackoverflow.com/a/14632782/5015269
/// </summary>
[ComImport]
[Guid("00021401-0000-0000-C000-000000000046")]
internal class ShellLink
{
}
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("000214F9-0000-0000-C000-000000000046")]
internal interface IShellLink
{
void GetPath([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxPath, out IntPtr pfd,
int fFlags);
void GetIDList(out IntPtr ppidl);
void SetIDList(IntPtr pidl);
void GetDescription([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszName, int cchMaxName);
void SetDescription([MarshalAs(UnmanagedType.LPWStr)] string pszName);
void GetWorkingDirectory([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszDir, int cchMaxPath);
void SetWorkingDirectory([MarshalAs(UnmanagedType.LPWStr)] string pszDir);
void GetArguments([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs, int cchMaxPath);
void SetArguments([MarshalAs(UnmanagedType.LPWStr)] string pszArgs);
void GetHotkey(out short pwHotkey);
void SetHotkey(short wHotkey);
void GetShowCmd(out int piShowCmd);
void SetShowCmd(int iShowCmd);
void GetIconLocation([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszIconPath, int cchIconPath,
out int piIcon);
void SetIconLocation([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon);
void SetRelativePath([MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, int dwReserved);
void Resolve(IntPtr hwnd, int fFlags);
void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile);
}
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace Artemis.Utilities
{
/// <summary>
/// Creates a shortcut (.lnk) file.
/// Source: http://stackoverflow.com/a/14632782/5015269
/// </summary>
[ComImport]
[Guid("00021401-0000-0000-C000-000000000046")]
internal class ShellLink
{
}
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("000214F9-0000-0000-C000-000000000046")]
internal interface IShellLink
{
void GetPath([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxPath, out IntPtr pfd,
int fFlags);
void GetIDList(out IntPtr ppidl);
void SetIDList(IntPtr pidl);
void GetDescription([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszName, int cchMaxName);
void SetDescription([MarshalAs(UnmanagedType.LPWStr)] string pszName);
void GetWorkingDirectory([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszDir, int cchMaxPath);
void SetWorkingDirectory([MarshalAs(UnmanagedType.LPWStr)] string pszDir);
void GetArguments([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs, int cchMaxPath);
void SetArguments([MarshalAs(UnmanagedType.LPWStr)] string pszArgs);
void GetHotkey(out short pwHotkey);
void SetHotkey(short wHotkey);
void GetShowCmd(out int piShowCmd);
void SetShowCmd(int iShowCmd);
void GetIconLocation([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszIconPath, int cchIconPath,
out int piIcon);
void SetIconLocation([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon);
void SetRelativePath([MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, int dwReserved);
void Resolve(IntPtr hwnd, int fFlags);
void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile);
}
}

View File

@ -1,39 +1,39 @@
using Artemis.Managers;
using Artemis.Modules.Effects.AmbientLightning;
using Artemis.Modules.Effects.AudioVisualizer;
using Artemis.Modules.Effects.Debug;
using Artemis.Modules.Effects.TypeHole;
using Artemis.Modules.Effects.TypeWave;
using Caliburn.Micro;
namespace Artemis.ViewModels
{
public class EffectsViewModel : Conductor<IScreen>.Collection.OneActive
{
private readonly AudioVisualizerViewModel _audioVisualizerVm;
private readonly DebugEffectViewModel _debugVm;
private readonly TypeHoleViewModel _typeHoleVm;
private readonly TypeWaveViewModel _typeWaveVm;
//private readonly AmbientLightningEffectViewModel _ambientLightningVm;
public EffectsViewModel(MainManager mainManager)
{
_typeWaveVm = new TypeWaveViewModel(mainManager) {DisplayName = "Type Waves"};
//_typeHoleVm = new TypeHoleViewModel(MainManager) {DisplayName = "Type Holes (NYI)"};
_audioVisualizerVm = new AudioVisualizerViewModel(mainManager) {DisplayName = "Audio Visualization"};
//_ambientLightningVm = new AmbientLightningEffectViewModel(mainManager) {DisplayName = "Ambient Lightning"};
_debugVm = new DebugEffectViewModel(mainManager) {DisplayName = "Debug Effect"};
}
protected override void OnActivate()
{
base.OnActivate();
ActivateItem(_typeWaveVm);
//ActivateItem(_typeHoleVm);
ActivateItem(_audioVisualizerVm);
//ActivateItem(_ambientLightningVm);
ActivateItem(_debugVm);
}
}
using Artemis.Managers;
using Artemis.Modules.Effects.AmbientLightning;
using Artemis.Modules.Effects.AudioVisualizer;
using Artemis.Modules.Effects.Debug;
using Artemis.Modules.Effects.TypeHole;
using Artemis.Modules.Effects.TypeWave;
using Caliburn.Micro;
namespace Artemis.ViewModels
{
public class EffectsViewModel : Conductor<IScreen>.Collection.OneActive
{
private readonly AudioVisualizerViewModel _audioVisualizerVm;
private readonly DebugEffectViewModel _debugVm;
private readonly TypeHoleViewModel _typeHoleVm;
private readonly TypeWaveViewModel _typeWaveVm;
//private readonly AmbientLightningEffectViewModel _ambientLightningVm;
public EffectsViewModel(MainManager mainManager)
{
_typeWaveVm = new TypeWaveViewModel(mainManager) {DisplayName = "Type Waves"};
//_typeHoleVm = new TypeHoleViewModel(MainManager) {DisplayName = "Type Holes (NYI)"};
_audioVisualizerVm = new AudioVisualizerViewModel(mainManager) {DisplayName = "Audio Visualization"};
//_ambientLightningVm = new AmbientLightningEffectViewModel(mainManager) {DisplayName = "Ambient Lightning"};
_debugVm = new DebugEffectViewModel(mainManager) {DisplayName = "Debug Effect"};
}
protected override void OnActivate()
{
base.OnActivate();
ActivateItem(_typeWaveVm);
//ActivateItem(_typeHoleVm);
ActivateItem(_audioVisualizerVm);
//ActivateItem(_ambientLightningVm);
ActivateItem(_debugVm);
}
}
}

View File

@ -1,57 +1,57 @@
using Caliburn.Micro;
using MahApps.Metro.Controls;
namespace Artemis.ViewModels
{
public abstract class FlyoutBaseViewModel : PropertyChangedBase
{
private string _header;
private bool _isOpen;
private Position _position;
public string Header
{
get { return _header; }
set
{
if (value == _header)
return;
_header = value;
NotifyOfPropertyChange(() => Header);
}
}
public bool IsOpen
{
get { return _isOpen; }
set
{
if (value.Equals(_isOpen))
return;
_isOpen = value;
HandleOpen();
NotifyOfPropertyChange(() => IsOpen);
}
}
public Position Position
{
get { return _position; }
set
{
if (value == _position)
return;
_position = value;
NotifyOfPropertyChange(() => Position);
}
}
protected abstract void HandleOpen();
}
using Caliburn.Micro;
using MahApps.Metro.Controls;
namespace Artemis.ViewModels
{
public abstract class FlyoutBaseViewModel : PropertyChangedBase
{
private string _header;
private bool _isOpen;
private Position _position;
public string Header
{
get { return _header; }
set
{
if (value == _header)
return;
_header = value;
NotifyOfPropertyChange(() => Header);
}
}
public bool IsOpen
{
get { return _isOpen; }
set
{
if (value.Equals(_isOpen))
return;
_isOpen = value;
HandleOpen();
NotifyOfPropertyChange(() => IsOpen);
}
}
public Position Position
{
get { return _position; }
set
{
if (value == _position)
return;
_position = value;
NotifyOfPropertyChange(() => Position);
}
}
protected abstract void HandleOpen();
}
}

View File

@ -1,134 +1,134 @@
using System.Diagnostics;
using System.Linq;
using Artemis.Events;
using Artemis.Managers;
using Artemis.Settings;
using Caliburn.Micro;
using MahApps.Metro.Controls;
namespace Artemis.ViewModels.Flyouts
{
public class FlyoutSettingsViewModel : FlyoutBaseViewModel, IHandle<ToggleEnabled>, IHandle<ActiveEffectChanged>
{
private string _activeEffectName;
private bool _enabled;
private GeneralSettings _generalSettings;
private string _selectedKeyboardProvider;
public FlyoutSettingsViewModel(MainManager mainManager)
{
MainManager = mainManager;
Header = "Settings";
Position = Position.Right;
GeneralSettings = new GeneralSettings();
MainManager.Events.Subscribe(this);
}
public GeneralSettings GeneralSettings
{
get { return _generalSettings; }
set
{
if (Equals(value, _generalSettings)) return;
_generalSettings = value;
NotifyOfPropertyChange(() => GeneralSettings);
}
}
public MainManager MainManager { get; set; }
public BindableCollection<string> KeyboardProviders
{
get
{
var collection = new BindableCollection<string>(MainManager.KeyboardManager.KeyboardProviders
.Select(k => k.Name));
collection.Insert(0, "None");
return collection;
}
}
public string SelectedKeyboardProvider
{
get { return _selectedKeyboardProvider; }
set
{
if (value == _selectedKeyboardProvider) return;
_selectedKeyboardProvider = value;
NotifyOfPropertyChange(() => SelectedKeyboardProvider);
if (value == null)
return;
MainManager.KeyboardManager.ChangeKeyboard(
MainManager.KeyboardManager.KeyboardProviders.FirstOrDefault(
k => k.Name == _selectedKeyboardProvider));
}
}
public bool Enabled
{
get { return MainManager.ProgramEnabled; }
set
{
if (value)
MainManager.EnableProgram();
else
MainManager.DisableProgram();
}
}
public string ActiveEffectName
{
get { return _activeEffectName; }
set
{
if (value == _activeEffectName) return;
_activeEffectName = value;
NotifyOfPropertyChange(() => ActiveEffectName);
}
}
public void Handle(ActiveEffectChanged message)
{
var effectDisplay = message.ActiveEffect.Length > 0 ? message.ActiveEffect : "none";
ActiveEffectName = $"Active effect: {effectDisplay}";
}
public void Handle(ToggleEnabled message)
{
NotifyOfPropertyChange(() => Enabled);
}
public void ToggleEnabled()
{
if (Enabled)
MainManager.DisableProgram();
else
MainManager.EnableProgram();
}
public void ResetSettings()
{
GeneralSettings.ResetSettings();
NotifyOfPropertyChange(() => GeneralSettings);
}
public void SaveSettings()
{
GeneralSettings.SaveSettings();
}
public void NavigateTo(string url)
{
Process.Start(new ProcessStartInfo(url));
}
protected override void HandleOpen()
{
SelectedKeyboardProvider = General.Default.LastKeyboard.Length > 0
? General.Default.LastKeyboard
: "None";
}
}
using System.Diagnostics;
using System.Linq;
using Artemis.Events;
using Artemis.Managers;
using Artemis.Settings;
using Caliburn.Micro;
using MahApps.Metro.Controls;
namespace Artemis.ViewModels.Flyouts
{
public class FlyoutSettingsViewModel : FlyoutBaseViewModel, IHandle<ToggleEnabled>, IHandle<ActiveEffectChanged>
{
private string _activeEffectName;
private bool _enabled;
private GeneralSettings _generalSettings;
private string _selectedKeyboardProvider;
public FlyoutSettingsViewModel(MainManager mainManager)
{
MainManager = mainManager;
Header = "Settings";
Position = Position.Right;
GeneralSettings = new GeneralSettings();
MainManager.Events.Subscribe(this);
}
public GeneralSettings GeneralSettings
{
get { return _generalSettings; }
set
{
if (Equals(value, _generalSettings)) return;
_generalSettings = value;
NotifyOfPropertyChange(() => GeneralSettings);
}
}
public MainManager MainManager { get; set; }
public BindableCollection<string> KeyboardProviders
{
get
{
var collection = new BindableCollection<string>(MainManager.KeyboardManager.KeyboardProviders
.Select(k => k.Name));
collection.Insert(0, "None");
return collection;
}
}
public string SelectedKeyboardProvider
{
get { return _selectedKeyboardProvider; }
set
{
if (value == _selectedKeyboardProvider) return;
_selectedKeyboardProvider = value;
NotifyOfPropertyChange(() => SelectedKeyboardProvider);
if (value == null)
return;
MainManager.KeyboardManager.ChangeKeyboard(
MainManager.KeyboardManager.KeyboardProviders.FirstOrDefault(
k => k.Name == _selectedKeyboardProvider));
}
}
public bool Enabled
{
get { return MainManager.ProgramEnabled; }
set
{
if (value)
MainManager.EnableProgram();
else
MainManager.DisableProgram();
}
}
public string ActiveEffectName
{
get { return _activeEffectName; }
set
{
if (value == _activeEffectName) return;
_activeEffectName = value;
NotifyOfPropertyChange(() => ActiveEffectName);
}
}
public void Handle(ActiveEffectChanged message)
{
var effectDisplay = message.ActiveEffect.Length > 0 ? message.ActiveEffect : "none";
ActiveEffectName = $"Active effect: {effectDisplay}";
}
public void Handle(ToggleEnabled message)
{
NotifyOfPropertyChange(() => Enabled);
}
public void ToggleEnabled()
{
if (Enabled)
MainManager.DisableProgram();
else
MainManager.EnableProgram();
}
public void ResetSettings()
{
GeneralSettings.ResetSettings();
NotifyOfPropertyChange(() => GeneralSettings);
}
public void SaveSettings()
{
GeneralSettings.SaveSettings();
}
public void NavigateTo(string url)
{
Process.Start(new ProcessStartInfo(url));
}
protected override void HandleOpen()
{
SelectedKeyboardProvider = General.Default.LastKeyboard.Length > 0
? General.Default.LastKeyboard
: "None";
}
}
}

View File

@ -1,39 +1,39 @@
using Artemis.Managers;
using Artemis.Modules.Games.CounterStrike;
using Artemis.Modules.Games.Dota2;
using Artemis.Modules.Games.RocketLeague;
using Artemis.Modules.Games.TheDivision;
using Artemis.Modules.Games.Witcher3;
using Caliburn.Micro;
namespace Artemis.ViewModels
{
public class GamesViewModel : Conductor<IScreen>.Collection.OneActive
{
private readonly CounterStrikeViewModel _counterStrikeVm;
private readonly Dota2ViewModel _dota2Vm;
private readonly RocketLeagueViewModel _rocketLeagueVm;
private readonly Witcher3ViewModel _witcher3Vm;
private readonly TheDivisionViewModel _divisionVm;
public GamesViewModel(MainManager mainManager)
{
_rocketLeagueVm = new RocketLeagueViewModel(mainManager) {DisplayName = "Rocket League"};
_counterStrikeVm = new CounterStrikeViewModel(mainManager) {DisplayName = "CS:GO"};
_dota2Vm = new Dota2ViewModel(mainManager) {DisplayName = "Dota 2"};
_witcher3Vm = new Witcher3ViewModel(mainManager) {DisplayName = "The Witcher 3"};
// _divisionVm = new TheDivisionViewModel(mainManager) {DisplayName = "The Division"};
}
protected override void OnActivate()
{
base.OnActivate();
ActivateItem(_rocketLeagueVm);
ActivateItem(_counterStrikeVm);
ActivateItem(_dota2Vm);
ActivateItem(_witcher3Vm);
// ActivateItem(_divisionVm);
}
}
using Artemis.Managers;
using Artemis.Modules.Games.CounterStrike;
using Artemis.Modules.Games.Dota2;
using Artemis.Modules.Games.RocketLeague;
using Artemis.Modules.Games.TheDivision;
using Artemis.Modules.Games.Witcher3;
using Caliburn.Micro;
namespace Artemis.ViewModels
{
public class GamesViewModel : Conductor<IScreen>.Collection.OneActive
{
private readonly CounterStrikeViewModel _counterStrikeVm;
private readonly Dota2ViewModel _dota2Vm;
private readonly RocketLeagueViewModel _rocketLeagueVm;
private readonly Witcher3ViewModel _witcher3Vm;
private readonly TheDivisionViewModel _divisionVm;
public GamesViewModel(MainManager mainManager)
{
_rocketLeagueVm = new RocketLeagueViewModel(mainManager) {DisplayName = "Rocket League"};
_counterStrikeVm = new CounterStrikeViewModel(mainManager) {DisplayName = "CS:GO"};
_dota2Vm = new Dota2ViewModel(mainManager) {DisplayName = "Dota 2"};
_witcher3Vm = new Witcher3ViewModel(mainManager) {DisplayName = "The Witcher 3"};
// _divisionVm = new TheDivisionViewModel(mainManager) {DisplayName = "The Division"};
}
protected override void OnActivate()
{
base.OnActivate();
ActivateItem(_rocketLeagueVm);
ActivateItem(_counterStrikeVm);
ActivateItem(_dota2Vm);
ActivateItem(_witcher3Vm);
// ActivateItem(_divisionVm);
}
}
}

View File

@ -1,29 +1,29 @@
using Artemis.Managers;
using Artemis.Modules.Overlays.VolumeDisplay;
using Caliburn.Micro;
namespace Artemis.ViewModels
{
public class OverlaysViewModel : Conductor<IScreen>.Collection.OneActive
{
private readonly MainManager _mainManager;
private VolumeDisplayViewModel _volumeDisplayVm;
public OverlaysViewModel(MainManager mainManager)
{
_mainManager = mainManager;
}
protected override void OnActivate()
{
base.OnActivate();
Items.Clear();
// This VM appears to be going out of scope, so recreating it every time just to be sure.
_volumeDisplayVm = new VolumeDisplayViewModel(_mainManager) {DisplayName = "Volume Display"};
ActivateItem(_volumeDisplayVm);
ActiveItem = _volumeDisplayVm;
}
}
using Artemis.Managers;
using Artemis.Modules.Overlays.VolumeDisplay;
using Caliburn.Micro;
namespace Artemis.ViewModels
{
public class OverlaysViewModel : Conductor<IScreen>.Collection.OneActive
{
private readonly MainManager _mainManager;
private VolumeDisplayViewModel _volumeDisplayVm;
public OverlaysViewModel(MainManager mainManager)
{
_mainManager = mainManager;
}
protected override void OnActivate()
{
base.OnActivate();
Items.Clear();
// This VM appears to be going out of scope, so recreating it every time just to be sure.
_volumeDisplayVm = new VolumeDisplayViewModel(_mainManager) {DisplayName = "Volume Display"};
ActivateItem(_volumeDisplayVm);
ActiveItem = _volumeDisplayVm;
}
}
}

View File

@ -1,59 +1,59 @@
using System.Linq;
using Artemis.Managers;
using Artemis.Services;
using Artemis.ViewModels.Flyouts;
using Caliburn.Micro;
namespace Artemis.ViewModels
{
public sealed class ShellViewModel : Conductor<IScreen>.Collection.OneActive
{
private readonly EffectsViewModel _effectsVm;
private readonly GamesViewModel _gamesVm;
private readonly OverlaysViewModel _overlaysVm;
private readonly WelcomeViewModel _welcomeVm;
public ShellViewModel()
{
var dialogService = new MetroDialogService(this);
IEventAggregator events = new EventAggregator();
MainManager = new MainManager(events, dialogService);
DisplayName = "Artemis";
_welcomeVm = new WelcomeViewModel {DisplayName = "Welcome"};
_effectsVm = new EffectsViewModel(MainManager) {DisplayName = "Effects"};
_gamesVm = new GamesViewModel(MainManager) {DisplayName = "Games"};
_overlaysVm = new OverlaysViewModel(MainManager) {DisplayName = "Overlays"};
Flyouts.Add(new FlyoutSettingsViewModel(MainManager));
}
public IObservableCollection<FlyoutBaseViewModel> Flyouts { get; set; } =
new BindableCollection<FlyoutBaseViewModel>();
public MainManager MainManager { get; set; }
protected override void OnActivate()
{
base.OnActivate();
ActivateItem(_welcomeVm);
ActivateItem(_effectsVm);
ActivateItem(_gamesVm);
ActivateItem(_overlaysVm);
ActiveItem = _welcomeVm;
}
public void Settings()
{
Flyouts.First().IsOpen = !Flyouts.First().IsOpen;
}
public void CloseSettings()
{
Flyouts.First().IsOpen = false;
}
}
using System.Linq;
using Artemis.Managers;
using Artemis.Services;
using Artemis.ViewModels.Flyouts;
using Caliburn.Micro;
namespace Artemis.ViewModels
{
public sealed class ShellViewModel : Conductor<IScreen>.Collection.OneActive
{
private readonly EffectsViewModel _effectsVm;
private readonly GamesViewModel _gamesVm;
private readonly OverlaysViewModel _overlaysVm;
private readonly WelcomeViewModel _welcomeVm;
public ShellViewModel()
{
var dialogService = new MetroDialogService(this);
IEventAggregator events = new EventAggregator();
MainManager = new MainManager(events, dialogService);
DisplayName = "Artemis";
_welcomeVm = new WelcomeViewModel {DisplayName = "Welcome"};
_effectsVm = new EffectsViewModel(MainManager) {DisplayName = "Effects"};
_gamesVm = new GamesViewModel(MainManager) {DisplayName = "Games"};
_overlaysVm = new OverlaysViewModel(MainManager) {DisplayName = "Overlays"};
Flyouts.Add(new FlyoutSettingsViewModel(MainManager));
}
public IObservableCollection<FlyoutBaseViewModel> Flyouts { get; set; } =
new BindableCollection<FlyoutBaseViewModel>();
public MainManager MainManager { get; set; }
protected override void OnActivate()
{
base.OnActivate();
ActivateItem(_welcomeVm);
ActivateItem(_effectsVm);
ActivateItem(_gamesVm);
ActivateItem(_overlaysVm);
ActiveItem = _welcomeVm;
}
public void Settings()
{
Flyouts.First().IsOpen = !Flyouts.First().IsOpen;
}
public void CloseSettings()
{
Flyouts.First().IsOpen = false;
}
}
}

View File

@ -1,54 +1,54 @@
using System;
using System.Windows;
using Artemis.Events;
using Artemis.Properties;
using Artemis.Settings;
using Artemis.Utilities;
using Caliburn.Micro;
namespace Artemis.ViewModels
{
public class SystemTrayViewModel : Screen, IHandle<ToggleEnabled>
{
private readonly ShellViewModel _shellViewModel;
private readonly IWindowManager _windowManager;
private string _activeIcon;
private bool _checkedForUpdate;
private bool _enabled;
private string _toggleText;
public SystemTrayViewModel(IWindowManager windowManager, ShellViewModel shellViewModel)
{
_windowManager = windowManager;
_shellViewModel = shellViewModel;
_shellViewModel.MainManager.Events.Subscribe(this);
_shellViewModel.MainManager.EnableProgram();
_checkedForUpdate = false;
//ActiveIcon = "../logo.ico";
if (General.Default.ShowOnStartup)
ShowWindow();
}
public bool CanShowWindow => !_shellViewModel.IsActive;
public bool CanHideWindow => _shellViewModel.IsActive;
public bool Enabled
{
get { return _enabled; }
set
{
if (value == _enabled) return;
_enabled = value;
ToggleText = _enabled ? "Disable Artemis" : "Enable Artemis";
ActiveIcon = _enabled ? "../Resources/logo.ico" : "../Resources/logo-disabled.ico";
NotifyOfPropertyChange(() => Enabled);
}
}
using System;
using System.Windows;
using Artemis.Events;
using Artemis.Properties;
using Artemis.Settings;
using Artemis.Utilities;
using Caliburn.Micro;
namespace Artemis.ViewModels
{
public class SystemTrayViewModel : Screen, IHandle<ToggleEnabled>
{
private readonly ShellViewModel _shellViewModel;
private readonly IWindowManager _windowManager;
private string _activeIcon;
private bool _checkedForUpdate;
private bool _enabled;
private string _toggleText;
public SystemTrayViewModel(IWindowManager windowManager, ShellViewModel shellViewModel)
{
_windowManager = windowManager;
_shellViewModel = shellViewModel;
_shellViewModel.MainManager.Events.Subscribe(this);
_shellViewModel.MainManager.EnableProgram();
_checkedForUpdate = false;
//ActiveIcon = "../logo.ico";
if (General.Default.ShowOnStartup)
ShowWindow();
}
public bool CanShowWindow => !_shellViewModel.IsActive;
public bool CanHideWindow => _shellViewModel.IsActive;
public bool Enabled
{
get { return _enabled; }
set
{
if (value == _enabled) return;
_enabled = value;
ToggleText = _enabled ? "Disable Artemis" : "Enable Artemis";
ActiveIcon = _enabled ? "../Resources/logo.ico" : "../Resources/logo-disabled.ico";
NotifyOfPropertyChange(() => Enabled);
}
}
public string ActiveIcon
{
get { return _activeIcon; }
@ -57,77 +57,77 @@ namespace Artemis.ViewModels
_activeIcon = value;
NotifyOfPropertyChange();
}
}
public string ToggleText
{
get { return _toggleText; }
set
{
if (value == _toggleText) return;
_toggleText = value;
NotifyOfPropertyChange(() => ToggleText);
}
}
public void Handle(ToggleEnabled message)
{
Enabled = message.Enabled;
}
public void ToggleEnabled()
{
if (Enabled)
_shellViewModel.MainManager.DisableProgram();
else
_shellViewModel.MainManager.EnableProgram();
}
protected override void OnActivate()
{
base.OnActivate();
NotifyOfPropertyChange(() => CanShowWindow);
NotifyOfPropertyChange(() => CanHideWindow);
}
public void ShowWindow()
{
if (!CanShowWindow)
return;
// manually show the next window view-model
_windowManager.ShowWindow(_shellViewModel);
NotifyOfPropertyChange(() => CanShowWindow);
NotifyOfPropertyChange(() => CanHideWindow);
if (_checkedForUpdate)
return;
_checkedForUpdate = true;
Updater.CheckForUpdate(_shellViewModel.MainManager.DialogService);
}
public void HideWindow()
{
if (!CanHideWindow)
return;
_shellViewModel.TryClose();
NotifyOfPropertyChange(() => CanShowWindow);
NotifyOfPropertyChange(() => CanHideWindow);
}
public void ExitApplication()
{
_shellViewModel.MainManager.Shutdown();
Application.Current.Shutdown();
// Sometimes you need to be rough.
Environment.Exit(0);
}
}
}
public string ToggleText
{
get { return _toggleText; }
set
{
if (value == _toggleText) return;
_toggleText = value;
NotifyOfPropertyChange(() => ToggleText);
}
}
public void Handle(ToggleEnabled message)
{
Enabled = message.Enabled;
}
public void ToggleEnabled()
{
if (Enabled)
_shellViewModel.MainManager.DisableProgram();
else
_shellViewModel.MainManager.EnableProgram();
}
protected override void OnActivate()
{
base.OnActivate();
NotifyOfPropertyChange(() => CanShowWindow);
NotifyOfPropertyChange(() => CanHideWindow);
}
public void ShowWindow()
{
if (!CanShowWindow)
return;
// manually show the next window view-model
_windowManager.ShowWindow(_shellViewModel);
NotifyOfPropertyChange(() => CanShowWindow);
NotifyOfPropertyChange(() => CanHideWindow);
if (_checkedForUpdate)
return;
_checkedForUpdate = true;
Updater.CheckForUpdate(_shellViewModel.MainManager.DialogService);
}
public void HideWindow()
{
if (!CanHideWindow)
return;
_shellViewModel.TryClose();
NotifyOfPropertyChange(() => CanShowWindow);
NotifyOfPropertyChange(() => CanHideWindow);
}
public void ExitApplication()
{
_shellViewModel.MainManager.Shutdown();
Application.Current.Shutdown();
// Sometimes you need to be rough.
Environment.Exit(0);
}
}
}

View File

@ -1,13 +1,13 @@
using System.Diagnostics;
using Caliburn.Micro;
namespace Artemis.ViewModels
{
public class WelcomeViewModel : Screen
{
public void NavigateTo(string url)
{
Process.Start(new ProcessStartInfo(url));
}
}
using System.Diagnostics;
using Caliburn.Micro;
namespace Artemis.ViewModels
{
public class WelcomeViewModel : Screen
{
public void NavigateTo(string url)
{
Process.Start(new ProcessStartInfo(url));
}
}
}

View File

@ -1,15 +1,15 @@
using System.Windows.Controls;
namespace Artemis.Views
{
/// <summary>
/// Interaction logic for EffectsView.xaml
/// </summary>
public partial class EffectsView : UserControl
{
public EffectsView()
{
InitializeComponent();
}
}
using System.Windows.Controls;
namespace Artemis.Views
{
/// <summary>
/// Interaction logic for EffectsView.xaml
/// </summary>
public partial class EffectsView : UserControl
{
public EffectsView()
{
InitializeComponent();
}
}
}

View File

@ -1,15 +1,15 @@
using System.Windows.Controls;
namespace Artemis.Views.Flyouts
{
/// <summary>
/// Interaction logic for FlyoutSettingsView.xaml
/// </summary>
public partial class FlyoutSettingsView : UserControl
{
public FlyoutSettingsView()
{
InitializeComponent();
}
}
using System.Windows.Controls;
namespace Artemis.Views.Flyouts
{
/// <summary>
/// Interaction logic for FlyoutSettingsView.xaml
/// </summary>
public partial class FlyoutSettingsView : UserControl
{
public FlyoutSettingsView()
{
InitializeComponent();
}
}
}

View File

@ -1,15 +1,15 @@
using System.Windows.Controls;
namespace Artemis.Views
{
/// <summary>
/// Interaction logic for GamesView.xaml
/// </summary>
public partial class GamesView : UserControl
{
public GamesView()
{
InitializeComponent();
}
}
using System.Windows.Controls;
namespace Artemis.Views
{
/// <summary>
/// Interaction logic for GamesView.xaml
/// </summary>
public partial class GamesView : UserControl
{
public GamesView()
{
InitializeComponent();
}
}
}

View File

@ -1,15 +1,15 @@
using System.Windows.Controls;
namespace Artemis.Views
{
/// <summary>
/// Interaction logic for OverlaysView.xaml
/// </summary>
public partial class OverlaysView : UserControl
{
public OverlaysView()
{
InitializeComponent();
}
}
using System.Windows.Controls;
namespace Artemis.Views
{
/// <summary>
/// Interaction logic for OverlaysView.xaml
/// </summary>
public partial class OverlaysView : UserControl
{
public OverlaysView()
{
InitializeComponent();
}
}
}

View File

@ -1,13 +1,13 @@
namespace Artemis.Views
{
/// <summary>
/// Interaction logic for ShellView.xaml
/// </summary>
public partial class ShellView
{
public ShellView()
{
InitializeComponent();
}
}
namespace Artemis.Views
{
/// <summary>
/// Interaction logic for ShellView.xaml
/// </summary>
public partial class ShellView
{
public ShellView()
{
InitializeComponent();
}
}
}

View File

@ -1,15 +1,15 @@
using MahApps.Metro.Controls;
namespace Artemis.Views
{
/// <summary>
/// Interaction logic for SystemTrayView.xaml
/// </summary>
public partial class SystemTrayView : MetroWindow
{
public SystemTrayView()
{
InitializeComponent();
}
}
using MahApps.Metro.Controls;
namespace Artemis.Views
{
/// <summary>
/// Interaction logic for SystemTrayView.xaml
/// </summary>
public partial class SystemTrayView : MetroWindow
{
public SystemTrayView()
{
InitializeComponent();
}
}
}

View File

@ -1,22 +1,22 @@
using System.Diagnostics;
using System.Windows.Controls;
using System.Windows.Navigation;
namespace Artemis.Views
{
/// <summary>
/// Interaction logic for WelcomeView.xaml
/// </summary>
public partial class WelcomeView : UserControl
{
public WelcomeView()
{
InitializeComponent();
}
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
Process.Start("https://github.com/SpoinkyNL/Artemis/wiki/Frequently-Asked-Questions-(FAQ)");
}
}
using System.Diagnostics;
using System.Windows.Controls;
using System.Windows.Navigation;
namespace Artemis.Views
{
/// <summary>
/// Interaction logic for WelcomeView.xaml
/// </summary>
public partial class WelcomeView : UserControl
{
public WelcomeView()
{
InitializeComponent();
}
private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
Process.Start("https://github.com/SpoinkyNL/Artemis/wiki/Frequently-Asked-Questions-(FAQ)");
}
}
}