1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Automated code cleanup

This commit is contained in:
SpoinkyNL 2016-02-18 20:12:51 +01:00
parent ebfdfda7d4
commit 741870a7a8
38 changed files with 219 additions and 181 deletions

View File

@ -2,19 +2,44 @@
<configuration> <configuration>
<configSections> <configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <sectionGroup name="userSettings"
<section name="Artemis.Modules.Games.RocketLeague.RocketLeague" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Artemis.Settings.Offsets" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> <section name="Artemis.Modules.Games.RocketLeague.RocketLeague"
<section name="Artemis.Modules.Games.Witcher3.Witcher3" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
<section name="Artemis.Modules.Effects.AudioVisualizer.AudioVisualization" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Games.CounterStrike.CounterStrike" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> <section name="Artemis.Settings.Offsets"
<section name="Artemis.Settings.CounterStrike" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
<section name="Artemis.Settings.VolumeDisplay" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.AudioVisualization" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> <section name="Artemis.Modules.Games.Witcher3.Witcher3"
<section name="Artemis.Settings.RocketLeague" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
<section name="Artemis.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.TypeWave" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> <section name="Artemis.Modules.Effects.AudioVisualizer.AudioVisualization"
<section name="Artemis.Settings.General" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Games.CounterStrike.CounterStrike"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.CounterStrike"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.VolumeDisplay"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.AudioVisualization"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.RocketLeague"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.TypeWave"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.General"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup> </sectionGroup>
</configSections> </configSections>
<connectionStrings /> <connectionStrings />

View File

@ -1,9 +1,10 @@
using System.Drawing; using System.Drawing;
using CUE.NET; using CUE.NET;
using CUE.NET.Brushes;
using CUE.NET.Devices.Generic.Enums; using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Keyboard; using CUE.NET.Devices.Keyboard;
using CUE.NET.Brushes;
using CUE.NET.Devices.Keyboard.Keys; using CUE.NET.Devices.Keyboard.Keys;
using CUE.NET.Exceptions;
namespace Artemis.KeyboardProviders.Corsair namespace Artemis.KeyboardProviders.Corsair
{ {
@ -15,6 +16,7 @@ namespace Artemis.KeyboardProviders.Corsair
{ {
Name = "Corsair Gaming K70 RGB"; Name = "Corsair Gaming K70 RGB";
} }
/// <summary> /// <summary>
/// Enables the SDK and sets updatemode to manual as well as the color of the background to black. /// Enables the SDK and sets updatemode to manual as well as the color of the background to black.
/// </summary> /// </summary>
@ -24,10 +26,13 @@ namespace Artemis.KeyboardProviders.Corsair
{ {
CueSDK.Initialize(); CueSDK.Initialize();
} }
catch (CUE.NET.Exceptions.WrapperException) {/*CUE is already initialized*/} catch (WrapperException)
{
/*CUE is already initialized*/
}
_keyboard = CueSDK.KeyboardSDK; _keyboard = CueSDK.KeyboardSDK;
Height = (int)_keyboard.KeyboardRectangle.Height; Height = (int) _keyboard.KeyboardRectangle.Height;
Width = (int)_keyboard.KeyboardRectangle.Width; Width = (int) _keyboard.KeyboardRectangle.Width;
_keyboard.UpdateMode = UpdateMode.Manual; _keyboard.UpdateMode = UpdateMode.Manual;
_keyboard.Brush = new SolidColorBrush(Color.Black); _keyboard.Brush = new SolidColorBrush(Color.Black);
@ -39,21 +44,32 @@ namespace Artemis.KeyboardProviders.Corsair
} }
/// <summary> /// <summary>
/// Properly resizes any size bitmap to the keyboard by creating a rectangle whose size is dependent on the bitmap size. /// Properly resizes any size bitmap to the keyboard by creating a rectangle whose size is dependent on the bitmap
/// size.
/// Does not reset the color each time. Uncomment line 48 for collor reset. /// Does not reset the color each time. Uncomment line 48 for collor reset.
/// </summary> /// </summary>
/// <param name="bitmap"></param> /// <param name="bitmap"></param>
public override void DrawBitmap(Bitmap bitmap) public override void DrawBitmap(Bitmap bitmap)
{ {
RectangleF[,] ledRectangles = new RectangleF[bitmap.Width, bitmap.Height]; var ledRectangles = new RectangleF[bitmap.Width, bitmap.Height];
RectangleKeyGroup[,] ledGroups = new RectangleKeyGroup[bitmap.Width, bitmap.Height]; var ledGroups = new RectangleKeyGroup[bitmap.Width, bitmap.Height];
//_keyboard.Brush = new SolidColorBrush(Color.Black); //_keyboard.Brush = new SolidColorBrush(Color.Black);
for (var x = 0; x < bitmap.Width; x++) for (var x = 0; x < bitmap.Width; x++)
{ {
for (var y = 0; y < bitmap.Height; y++) for (var y = 0; y < bitmap.Height; y++)
{ {
ledRectangles[x, y] = new RectangleF(_keyboard.KeyboardRectangle.X * (x * (_keyboard.KeyboardRectangle.Width / bitmap.Width / _keyboard.KeyboardRectangle.X)), _keyboard.KeyboardRectangle.Y * (y * (_keyboard.KeyboardRectangle.Height / bitmap.Height / _keyboard.KeyboardRectangle.Y)), _keyboard.KeyboardRectangle.Width / bitmap.Width, _keyboard.KeyboardRectangle.Height / bitmap.Height); ledRectangles[x, y] =
ledGroups[x, y] = new RectangleKeyGroup(_keyboard, ledRectangles[x, y], 0.01f) { Brush = new SolidColorBrush(bitmap.GetPixel(x, y)) }; new RectangleF(
_keyboard.KeyboardRectangle.X*
(x*(_keyboard.KeyboardRectangle.Width/bitmap.Width/_keyboard.KeyboardRectangle.X)),
_keyboard.KeyboardRectangle.Y*
(y*(_keyboard.KeyboardRectangle.Height/bitmap.Height/_keyboard.KeyboardRectangle.Y)),
_keyboard.KeyboardRectangle.Width/bitmap.Width,
_keyboard.KeyboardRectangle.Height/bitmap.Height);
ledGroups[x, y] = new RectangleKeyGroup(_keyboard, ledRectangles[x, y], 0.01f)
{
Brush = new SolidColorBrush(bitmap.GetPixel(x, y))
};
} }
} }
_keyboard.Update(); _keyboard.Update();

View File

@ -1,9 +1,8 @@
using System; using System.Drawing;
using System.Drawing; using Artemis.Utilities;
using CUE.NET; using CUE.NET;
using CUE.NET.Devices.Keyboard; using CUE.NET.Devices.Keyboard;
using Artemis.Utilities; using CUE.NET.Exceptions;
using CUE.NET.Brushes;
namespace Artemis.KeyboardProviders.Corsair namespace Artemis.KeyboardProviders.Corsair
{ {
@ -25,10 +24,13 @@ namespace Artemis.KeyboardProviders.Corsair
{ {
CueSDK.Initialize(); CueSDK.Initialize();
} }
catch (CUE.NET.Exceptions.WrapperException){/*CUE is already initialized*/} catch (WrapperException)
{
/*CUE is already initialized*/
}
_keyboard = CueSDK.KeyboardSDK; _keyboard = CueSDK.KeyboardSDK;
Height = (int)_keyboard.KeyboardRectangle.Height; Height = (int) _keyboard.KeyboardRectangle.Height;
Width = (int)_keyboard.KeyboardRectangle.Width; Width = (int) _keyboard.KeyboardRectangle.Width;
// _keyboard.UpdateMode = UpdateMode.Manual; // _keyboard.UpdateMode = UpdateMode.Manual;
_keyboard.Update(true); _keyboard.Update(true);
@ -39,7 +41,8 @@ namespace Artemis.KeyboardProviders.Corsair
} }
/// <summary> /// <summary>
/// Properly resizes any size bitmap to the keyboard by creating a rectangle whose size is dependent on the bitmap size. /// Properly resizes any size bitmap to the keyboard by creating a rectangle whose size is dependent on the bitmap
/// size.
/// Does not reset the color each time. Uncomment line 48 for collor reset. /// Does not reset the color each time. Uncomment line 48 for collor reset.
/// </summary> /// </summary>
/// <param name="bitmap//"></param> /// <param name="bitmap//"></param>
@ -47,20 +50,19 @@ namespace Artemis.KeyboardProviders.Corsair
{ {
using ( using (
var resized = ImageUtilities.ResizeImage(bitmap, var resized = ImageUtilities.ResizeImage(bitmap,
(int)_keyboard.KeyboardRectangle.Width, (int) _keyboard.KeyboardRectangle.Width,
(int)_keyboard.KeyboardRectangle.Height) (int) _keyboard.KeyboardRectangle.Height)
) )
{ {
foreach (var item in _keyboard.Keys) foreach (var item in _keyboard.Keys)
{ {
Color ledColor = resized.GetPixel((int)item.KeyRectangle.X, (int)item.KeyRectangle.Y); var ledColor = resized.GetPixel((int) item.KeyRectangle.X, (int) item.KeyRectangle.Y);
if (ledColor == Color.FromArgb(0, 0, 0, 0)) if (ledColor == Color.FromArgb(0, 0, 0, 0))
ledColor = Color.Black; ledColor = Color.Black;
item.Led.Color = ledColor; item.Led.Color = ledColor;
} }
} }
_keyboard.Update(true); _keyboard.Update(true);
} }
/* /*

View File

@ -107,5 +107,5 @@ namespace Artemis.KeyboardProviders.Logitech.Utilities
NUM_ZERO = 0x52, NUM_ZERO = 0x52,
NUM_PERIOD = 0x53, NUM_PERIOD = 0x53,
TEST = 0x1 TEST = 0x1
}; }
} }

View File

@ -11,9 +11,9 @@ namespace Artemis.KeyboardProviders.Logitech.Utilities
private const int LOGI_DEVICETYPE_RGB_ORD = 1; private const int LOGI_DEVICETYPE_RGB_ORD = 1;
private const int LOGI_DEVICETYPE_PERKEY_RGB_ORD = 2; 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_MONOCHROME = 1 << LOGI_DEVICETYPE_MONOCHROME_ORD;
public const int LOGI_DEVICETYPE_RGB = (1 << LOGI_DEVICETYPE_RGB_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_DEVICETYPE_PERKEY_RGB = 1 << LOGI_DEVICETYPE_PERKEY_RGB_ORD;
public const int LOGI_LED_BITMAP_WIDTH = 21; public const int LOGI_LED_BITMAP_WIDTH = 21;
public const int LOGI_LED_BITMAP_HEIGHT = 6; public const int LOGI_LED_BITMAP_HEIGHT = 6;
public const int LOGI_LED_BITMAP_BYTES_PER_KEY = 4; public const int LOGI_LED_BITMAP_BYTES_PER_KEY = 4;

View File

@ -17,7 +17,7 @@ namespace Artemis.KeyboardProviders.Logitech.Utilities
var depth = Image.GetPixelFormatSize(b.PixelFormat); var depth = Image.GetPixelFormatSize(b.PixelFormat);
var step = depth/8; var step = depth/8;
var pixels = new byte[(21*6)*step]; var pixels = new byte[21*6*step];
var iptr = bitmapData.Scan0; var iptr = bitmapData.Scan0;
// Copy data from pointer to array // Copy data from pointer to array

View File

@ -15,8 +15,8 @@ namespace Artemis.KeyboardProviders.Razer
public override void Enable() public override void Enable()
{ {
Chroma.Instance.Initialize(); Chroma.Instance.Initialize();
Height = (int)Constants.MaxRows; Height = (int) Constants.MaxRows;
Width = (int)Constants.MaxColumns; Width = (int) Constants.MaxColumns;
} }
public override void Disable() public override void Disable()

View File

@ -15,10 +15,10 @@ namespace Artemis.Models
MainModel = mainModel; MainModel = mainModel;
} }
public event SettingsUpdateHandler SettingsUpdateEvent;
public abstract void Dispose(); public abstract void Dispose();
public event SettingsUpdateHandler SettingsUpdateEvent;
// Called on creation // Called on creation
public abstract void Enable(); public abstract void Enable();

View File

@ -182,7 +182,7 @@ namespace Artemis.Models
} }
// Sleep according to time left this frame // Sleep according to time left this frame
var sleep = (int) ((1000/Fps) - sw.ElapsedMilliseconds); var sleep = (int) (1000/Fps - sw.ElapsedMilliseconds);
if (sleep > 0) if (sleep > 0)
Thread.Sleep(sleep); Thread.Sleep(sleep);
sw.Reset(); sw.Reset();

View File

@ -1,5 +1,7 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Artemis.Modules.Effects.AudioVisualizer" GeneratedClassName="AudioVisualization">
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"
GeneratedClassNamespace="Artemis.Modules.Effects.AudioVisualizer" GeneratedClassName="AudioVisualization">
<Profiles /> <Profiles />
<Settings> <Settings>
<Setting Name="Sensitivity" Type="System.Int32" Scope="User"> <Setting Name="Sensitivity" Type="System.Int32" Scope="User">

View File

@ -70,7 +70,6 @@ namespace Artemis.Modules.Effects.AudioVisualizer
ColorHelpers.ToDrawingColor(Settings.BottomColor) ColorHelpers.ToDrawingColor(Settings.BottomColor)
}, },
LinearGradientMode.Vertical) {ContainedBrush = false}); LinearGradientMode.Vertical) {ContainedBrush = false});
} }
_sampleAggregator.FftCalculated += FftCalculated; _sampleAggregator.FftCalculated += FftCalculated;
@ -109,7 +108,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
// Apply Sensitivity setting // Apply Sensitivity setting
height = height*Settings.Sensitivity; height = height*Settings.Sensitivity;
var keyboardHeight = (int) Math.Round(((MainModel.ActiveKeyboard.Height/100.00)*height)*Scale); var keyboardHeight = (int) Math.Round(MainModel.ActiveKeyboard.Height/100.00*height*Scale);
if (keyboardHeight > SoundRectangles[i].Height) if (keyboardHeight > SoundRectangles[i].Height)
SoundRectangles[i].Height = keyboardHeight; SoundRectangles[i].Height = keyboardHeight;
else else
@ -119,7 +118,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
SoundRectangles[i].Width = Scale; SoundRectangles[i].Width = Scale;
if (Settings.FromBottom) if (Settings.FromBottom)
SoundRectangles[i].Y = (MainModel.ActiveKeyboard.Height*Scale) - SoundRectangles[i].Height; SoundRectangles[i].Y = MainModel.ActiveKeyboard.Height*Scale - SoundRectangles[i].Height;
} }
_generating = false; _generating = false;
} }

View File

@ -18,7 +18,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
public Color MiddleColor { get; set; } public Color MiddleColor { get; set; }
public Color BottomColor { get; set; } public Color BottomColor { get; set; }
public override sealed void Load() public sealed override void Load()
{ {
Sensitivity = AudioVisualization.Default.Sensitivity; Sensitivity = AudioVisualization.Default.Sensitivity;
Bars = AudioVisualization.Default.Bars; Bars = AudioVisualization.Default.Bars;
@ -29,7 +29,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
BottomColor = AudioVisualization.Default.BottomColor; BottomColor = AudioVisualization.Default.BottomColor;
} }
public override sealed void Save() public sealed override void Save()
{ {
AudioVisualization.Default.Sensitivity = Sensitivity; AudioVisualization.Default.Sensitivity = Sensitivity;
AudioVisualization.Default.Bars = Bars; AudioVisualization.Default.Bars = Bars;
@ -42,7 +42,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
AudioVisualization.Default.Save(); AudioVisualization.Default.Save();
} }
public override sealed void ToDefault() public sealed override void ToDefault()
{ {
Sensitivity = 4; Sensitivity = 4;
Bars = 21; Bars = 21;

View File

@ -16,16 +16,16 @@ namespace Artemis.Modules.Effects.Debug
public int Scale { get; set; } public int Scale { get; set; }
public LinearGradientMode Type { get; set; } public LinearGradientMode Type { get; set; }
public override sealed void Load() public sealed override void Load()
{ {
ToDefault(); ToDefault();
} }
public override sealed void Save() public sealed override void Save()
{ {
} }
public override sealed void ToDefault() public sealed override void ToDefault()
{ {
Width = 84; Width = 84;
Height = 24; Height = 24;

View File

@ -2,8 +2,6 @@
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.IO; using System.IO;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using Artemis.Events; using Artemis.Events;

View File

@ -7,7 +7,6 @@ using System.Windows.Forms;
using Artemis.KeyboardProviders.Logitech.Utilities; using Artemis.KeyboardProviders.Logitech.Utilities;
using Artemis.Models; using Artemis.Models;
using Artemis.Utilities; using Artemis.Utilities;
using Gma.System.MouseKeyHook;
namespace Artemis.Modules.Effects.TypeWave namespace Artemis.Modules.Effects.TypeWave
{ {
@ -53,7 +52,8 @@ namespace Artemis.Modules.Effects.TypeWave
_waves[i].Color = ColorHelpers.ShiftColor(_waves[i].Color, Settings.ShiftColorSpeed); _waves[i].Color = ColorHelpers.ShiftColor(_waves[i].Color, Settings.ShiftColorSpeed);
var decreaseAmount = 255/(Settings.TimeToLive/fps); 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 = Color.FromArgb(_waves[i].Color.A - decreaseAmount, _waves[i].Color.R,
_waves[i].Color.G,
_waves[i].Color.B); _waves[i].Color.B);
if (_waves[i].Color.A >= decreaseAmount) if (_waves[i].Color.A >= decreaseAmount)

View File

@ -17,7 +17,7 @@ namespace Artemis.Modules.Effects.TypeWave
public int TimeToLive { get; set; } public int TimeToLive { get; set; }
public int SpreadSpeed { get; set; } public int SpreadSpeed { get; set; }
public override sealed void Load() public sealed override void Load()
{ {
IsRandomColors = Settings.TypeWave.Default.IsRandomColors; IsRandomColors = Settings.TypeWave.Default.IsRandomColors;
WaveColor = Settings.TypeWave.Default.WaveColor; WaveColor = Settings.TypeWave.Default.WaveColor;
@ -27,7 +27,7 @@ namespace Artemis.Modules.Effects.TypeWave
SpreadSpeed = Settings.TypeWave.Default.SpreadSpeed; SpreadSpeed = Settings.TypeWave.Default.SpreadSpeed;
} }
public override sealed void Save() public sealed override void Save()
{ {
Settings.TypeWave.Default.IsRandomColors = IsRandomColors; Settings.TypeWave.Default.IsRandomColors = IsRandomColors;
Settings.TypeWave.Default.WaveColor = WaveColor; Settings.TypeWave.Default.WaveColor = WaveColor;
@ -39,7 +39,7 @@ namespace Artemis.Modules.Effects.TypeWave
Settings.TypeWave.Default.Save(); Settings.TypeWave.Default.Save();
} }
public override sealed void ToDefault() public sealed override void ToDefault()
{ {
IsRandomColors = true; IsRandomColors = true;
WaveColor = Color.FromArgb(255, 255, 0, 0); WaveColor = Color.FromArgb(255, 255, 0, 0);

View File

@ -46,7 +46,8 @@
<StackPanel Grid.Row="1" <StackPanel Grid.Row="1"
Grid.Column="0" Grid.Column="0"
Grid.ColumnSpan="2" Margin="0,0,1,0"> Grid.ColumnSpan="2" Margin="0,0,1,0">
<Label FontSize="16" Content="CS:GO Directory" FontFamily="Segoe UI Semibold" Foreground="#535353" Width="130" HorizontalAlignment="Left" /> <Label FontSize="16" Content="CS:GO Directory" FontFamily="Segoe UI Semibold" Foreground="#535353"
Width="130" HorizontalAlignment="Left" />
<Grid> <Grid>
<TextBox x:Name="GameDirectory" Height="23" TextWrapping="Wrap" Margin="5,0,30,0" <TextBox x:Name="GameDirectory" Height="23" TextWrapping="Wrap" Margin="5,0,30,0"
Text="{Binding Path=CounterStrikeSettings.GameDirectory, Mode=TwoWay}" Text="{Binding Path=CounterStrikeSettings.GameDirectory, Mode=TwoWay}"

View File

@ -37,7 +37,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
}, },
LinearGradientMode.Horizontal) LinearGradientMode.Horizontal)
{ {
Width = (int) ((MainModel.ActiveKeyboard.Width * Scale / 100.00)*Volume), Width = (int) (MainModel.ActiveKeyboard.Width*Scale/100.00*Volume),
ContainedBrush = false ContainedBrush = false
}; };
volumeRect.Draw(g); volumeRect.Draw(g);

View File

@ -3,7 +3,6 @@ using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using Artemis.Models; using Artemis.Models;
using Gma.System.MouseKeyHook;
using NAudio.CoreAudioApi; using NAudio.CoreAudioApi;
namespace Artemis.Modules.Overlays.VolumeDisplay namespace Artemis.Modules.Overlays.VolumeDisplay

View File

@ -14,14 +14,14 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
public Color MainColor { get; set; } public Color MainColor { get; set; }
public Color SecondaryColor { get; set; } public Color SecondaryColor { get; set; }
public override sealed void Load() public sealed override void Load()
{ {
Enabled = Settings.VolumeDisplay.Default.Enabled; Enabled = Settings.VolumeDisplay.Default.Enabled;
MainColor = Settings.VolumeDisplay.Default.MainColor; MainColor = Settings.VolumeDisplay.Default.MainColor;
SecondaryColor = Settings.VolumeDisplay.Default.SecondaryColor; SecondaryColor = Settings.VolumeDisplay.Default.SecondaryColor;
} }
public override sealed void Save() public sealed override void Save()
{ {
Settings.VolumeDisplay.Default.Enabled = Enabled; Settings.VolumeDisplay.Default.Enabled = Enabled;
Settings.VolumeDisplay.Default.MainColor = MainColor; Settings.VolumeDisplay.Default.MainColor = MainColor;
@ -30,7 +30,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
Settings.VolumeDisplay.Default.Save(); Settings.VolumeDisplay.Default.Save();
} }
public override sealed void ToDefault() public sealed override void ToDefault()
{ {
Enabled = true; Enabled = true;
MainColor = Color.FromArgb(255, 38, 246, 0); MainColor = Color.FromArgb(255, 38, 246, 0);

View File

@ -1,5 +1,7 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Artemis.Settings" GeneratedClassName="General">
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"
GeneratedClassNamespace="Artemis.Settings" GeneratedClassName="General">
<Profiles /> <Profiles />
<Settings> <Settings>
<Setting Name="LastEffect" Type="System.String" Scope="User"> <Setting Name="LastEffect" Type="System.String" Scope="User">

View File

@ -1,9 +1,8 @@
using System; using System.IO;
using System.IO;
using System.Net; using System.Net;
using System.Net.Sockets;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using Artemis.Settings;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Artemis.Utilities.GameState namespace Artemis.Utilities.GameState
@ -31,7 +30,7 @@ namespace Artemis.Utilities.GameState
return; return;
_listener.Prefixes.Clear(); _listener.Prefixes.Clear();
Port = Settings.General.Default.GamestatePort; Port = General.Default.GamestatePort;
_listener.Prefixes.Add($"http://localhost:{Port}/"); _listener.Prefixes.Add($"http://localhost:{Port}/");
_listener.Start(); _listener.Start();

View File

@ -1,19 +1,19 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging; using System.Drawing.Imaging;
namespace Artemis.Utilities namespace Artemis.Utilities
{ {
class ImageUtilities internal class ImageUtilities
{ {
private static Dictionary<string, ImageCodecInfo> encoders = null; private static Dictionary<string, ImageCodecInfo> encoders;
/// <summary> /// <summary>
/// A lock to prevent concurrency issues loading the encoders. /// A lock to prevent concurrency issues loading the encoders.
/// </summary> /// </summary>
private static object encodersLock = new object(); private static readonly object encodersLock = new object();
/// <summary> /// <summary>
/// A quick lookup for getting image encoders /// A quick lookup for getting image encoders
@ -35,7 +35,7 @@ namespace Artemis.Utilities
encoders = new Dictionary<string, ImageCodecInfo>(); encoders = new Dictionary<string, ImageCodecInfo>();
//get all the codecs //get all the codecs
foreach (ImageCodecInfo codec in ImageCodecInfo.GetImageEncoders()) foreach (var codec in ImageCodecInfo.GetImageEncoders())
{ {
//add each codec to the quick lookup //add each codec to the quick lookup
encoders.Add(codec.MimeType.ToLower(), codec); encoders.Add(codec.MimeType.ToLower(), codec);
@ -59,17 +59,17 @@ namespace Artemis.Utilities
public static Bitmap ResizeImage(Image image, int width, int height) public static Bitmap ResizeImage(Image image, int width, int height)
{ {
//a holder for the result //a holder for the result
Bitmap result = new Bitmap(width, height); var result = new Bitmap(width, height);
//set the resolutions the same to avoid cropping due to resolution differences //set the resolutions the same to avoid cropping due to resolution differences
result.SetResolution(image.HorizontalResolution, image.VerticalResolution); result.SetResolution(image.HorizontalResolution, image.VerticalResolution);
//use a graphics object to draw the resized image into the bitmap //use a graphics object to draw the resized image into the bitmap
using (Graphics graphics = Graphics.FromImage(result)) using (var graphics = Graphics.FromImage(result))
{ {
//set the resize quality modes to high quality //set the resize quality modes to high quality
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; graphics.SmoothingMode = SmoothingMode.HighQuality;
//draw the image into the target bitmap //draw the image into the target bitmap
graphics.DrawImage(image, 0, 0, result.Width, result.Height); graphics.DrawImage(image, 0, 0, result.Width, result.Height);
} }
@ -82,8 +82,10 @@ namespace Artemis.Utilities
/// Saves an image as a jpeg image, with the given quality /// Saves an image as a jpeg image, with the given quality
/// </summary> /// </summary>
/// <param name="path">Path to which the image would be saved.</param> /// <param name="path">Path to which the image would be saved.</param>
/// <param name="quality">An integer from 0 to 100, with 100 being the /// <param name="quality">
/// highest quality</param> /// An integer from 0 to 100, with 100 being the
/// highest quality
/// </param>
/// <exception cref="ArgumentOutOfRangeException"> /// <exception cref="ArgumentOutOfRangeException">
/// An invalid value was entered for image quality. /// An invalid value was entered for image quality.
/// </exception> /// </exception>
@ -93,18 +95,21 @@ namespace Artemis.Utilities
if ((quality < 0) || (quality > 100)) if ((quality < 0) || (quality > 100))
{ {
//create the error message //create the error message
string error = string.Format("Jpeg image quality must be between 0 and 100, with 100 being the highest quality. A value of {0} was specified.", quality); var error =
string.Format(
"Jpeg image quality must be between 0 and 100, with 100 being the highest quality. A value of {0} was specified.",
quality);
//throw a helpful exception //throw a helpful exception
throw new ArgumentOutOfRangeException(error); throw new ArgumentOutOfRangeException(error);
} }
//create an encoder parameter for the image quality //create an encoder parameter for the image quality
EncoderParameter qualityParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality); var qualityParam = new EncoderParameter(Encoder.Quality, quality);
//get the jpeg codec //get the jpeg codec
ImageCodecInfo jpegCodec = GetEncoderInfo("image/jpeg"); var jpegCodec = GetEncoderInfo("image/jpeg");
//create a collection of all parameters that we will pass to the encoder //create a collection of all parameters that we will pass to the encoder
EncoderParameters encoderParams = new EncoderParameters(1); var encoderParams = new EncoderParameters(1);
//set the quality parameter for the codec //set the quality parameter for the codec
encoderParams.Param[0] = qualityParam; encoderParams.Param[0] = qualityParam;
//save the image using the codec and the parameters //save the image using the codec and the parameters
@ -117,7 +122,7 @@ namespace Artemis.Utilities
public static ImageCodecInfo GetEncoderInfo(string mimeType) public static ImageCodecInfo GetEncoderInfo(string mimeType)
{ {
//do a case insensitive search for the mime type //do a case insensitive search for the mime type
string lookupKey = mimeType.ToLower(); var lookupKey = mimeType.ToLower();
//the codec to return, default to null //the codec to return, default to null
ImageCodecInfo foundCodec = null; ImageCodecInfo foundCodec = null;

View File

@ -159,7 +159,7 @@ namespace Artemis.Utilities.Keyboard
private ColorBlend CreateColorBlend() private ColorBlend CreateColorBlend()
{ {
if (Colors.Count == 1) if (Colors.Count == 1)
return new ColorBlend { Colors = new []{Colors[0], Colors[0]}, Positions = new []{0F, 1F}}; return new ColorBlend {Colors = new[] {Colors[0], Colors[0]}, Positions = new[] {0F, 1F}};
var colorBlend = Rotate var colorBlend = Rotate
? new ColorBlend {Colors = CreateTilebleColors(Colors).ToArray()} ? new ColorBlend {Colors = CreateTilebleColors(Colors).ToArray()}
: new ColorBlend {Colors = Colors.ToArray()}; : new ColorBlend {Colors = Colors.ToArray()};

View File

@ -11,17 +11,17 @@ namespace Artemis.Utilities.Memory
[Flags] [Flags]
public enum ProcessAccessType public enum ProcessAccessType
{ {
PROCESS_TERMINATE = (0x0001), PROCESS_TERMINATE = 0x0001,
PROCESS_CREATE_THREAD = (0x0002), PROCESS_CREATE_THREAD = 0x0002,
PROCESS_SET_SESSIONID = (0x0004), PROCESS_SET_SESSIONID = 0x0004,
PROCESS_VM_OPERATION = (0x0008), PROCESS_VM_OPERATION = 0x0008,
PROCESS_VM_READ = (0x0010), PROCESS_VM_READ = 0x0010,
PROCESS_VM_WRITE = (0x0020), PROCESS_VM_WRITE = 0x0020,
PROCESS_DUP_HANDLE = (0x0040), PROCESS_DUP_HANDLE = 0x0040,
PROCESS_CREATE_PROCESS = (0x0080), PROCESS_CREATE_PROCESS = 0x0080,
PROCESS_SET_QUOTA = (0x0100), PROCESS_SET_QUOTA = 0x0100,
PROCESS_SET_INFORMATION = (0x0200), PROCESS_SET_INFORMATION = 0x0200,
PROCESS_QUERY_INFORMATION = (0x0400) PROCESS_QUERY_INFORMATION = 0x0400
} }
[DllImport("kernel32.dll", SetLastError = true)] [DllImport("kernel32.dll", SetLastError = true)]

View File

@ -9,17 +9,17 @@ namespace Artemis.ViewModels
{ {
public class EffectsViewModel : Conductor<IScreen>.Collection.OneActive public class EffectsViewModel : Conductor<IScreen>.Collection.OneActive
{ {
private readonly TypeWaveViewModel _typeWaveVm;
private readonly TypeHoleViewModel _typeHoleVm;
private readonly AudioVisualizerViewModel _audioVisualizerVm; private readonly AudioVisualizerViewModel _audioVisualizerVm;
private readonly DebugEffectViewModel _debugVm; private readonly DebugEffectViewModel _debugVm;
private readonly TypeHoleViewModel _typeHoleVm;
private readonly TypeWaveViewModel _typeWaveVm;
public EffectsViewModel(MainModel mainModel) public EffectsViewModel(MainModel mainModel)
{ {
_typeWaveVm = new TypeWaveViewModel(mainModel) {DisplayName = "Type Waves"}; _typeWaveVm = new TypeWaveViewModel(mainModel) {DisplayName = "Type Waves"};
_typeHoleVm = new TypeHoleViewModel(mainModel) { DisplayName = "Type Holes (NYI)" }; _typeHoleVm = new TypeHoleViewModel(mainModel) {DisplayName = "Type Holes (NYI)"};
_audioVisualizerVm = new AudioVisualizerViewModel(mainModel) { DisplayName = "Audio Visualization" }; _audioVisualizerVm = new AudioVisualizerViewModel(mainModel) {DisplayName = "Audio Visualization"};
_debugVm = new DebugEffectViewModel(mainModel) { DisplayName = "Debug Effect" }; _debugVm = new DebugEffectViewModel(mainModel) {DisplayName = "Debug Effect"};
} }
protected override void OnActivate() protected override void OnActivate()

View File

@ -9,17 +9,17 @@ namespace Artemis.ViewModels
{ {
public class GamesViewModel : Conductor<IScreen>.Collection.OneActive public class GamesViewModel : Conductor<IScreen>.Collection.OneActive
{ {
private readonly RocketLeagueViewModel _rocketLeagueVm;
private readonly CounterStrikeViewModel _counterStrikeVm; private readonly CounterStrikeViewModel _counterStrikeVm;
private readonly Dota2ViewModel _dota2Vm; private readonly Dota2ViewModel _dota2Vm;
private readonly RocketLeagueViewModel _rocketLeagueVm;
private readonly Witcher3ViewModel _witcher3Vm; private readonly Witcher3ViewModel _witcher3Vm;
public GamesViewModel(MainModel mainModel) public GamesViewModel(MainModel mainModel)
{ {
_rocketLeagueVm = new RocketLeagueViewModel(mainModel) {DisplayName = "Rocket League"}; _rocketLeagueVm = new RocketLeagueViewModel(mainModel) {DisplayName = "Rocket League"};
_counterStrikeVm = new CounterStrikeViewModel(mainModel) { DisplayName = "CS:GO" }; _counterStrikeVm = new CounterStrikeViewModel(mainModel) {DisplayName = "CS:GO"};
_dota2Vm = new Dota2ViewModel(mainModel) { DisplayName = "Dota 2 (NYI)" }; _dota2Vm = new Dota2ViewModel(mainModel) {DisplayName = "Dota 2 (NYI)"};
_witcher3Vm = new Witcher3ViewModel(mainModel) { DisplayName = "The Witcher 3" }; _witcher3Vm = new Witcher3ViewModel(mainModel) {DisplayName = "The Witcher 3"};
} }
protected override void OnActivate() protected override void OnActivate()

View File

@ -20,7 +20,7 @@ namespace Artemis.ViewModels
DisplayName = "Artemis"; DisplayName = "Artemis";
_effectsVm = new EffectsViewModel(MainModel) {DisplayName = "Effects"}; _effectsVm = new EffectsViewModel(MainModel) {DisplayName = "Effects"};
_gamesVm = new GamesViewModel(MainModel) { DisplayName = "Games" }; _gamesVm = new GamesViewModel(MainModel) {DisplayName = "Games"};
_overlaysVm = new OverlaysViewModel(MainModel) {DisplayName = "Overlays"}; _overlaysVm = new OverlaysViewModel(MainModel) {DisplayName = "Overlays"};
Flyouts.Add(new FlyoutSettingsViewModel()); Flyouts.Add(new FlyoutSettingsViewModel());
@ -32,15 +32,6 @@ namespace Artemis.ViewModels
public IObservableCollection<FlyoutBaseViewModel> Flyouts { get; set; } = public IObservableCollection<FlyoutBaseViewModel> Flyouts { get; set; } =
new BindableCollection<FlyoutBaseViewModel>(); new BindableCollection<FlyoutBaseViewModel>();
protected override void OnActivate()
{
base.OnActivate();
ActivateItem(_effectsVm);
ActivateItem(_gamesVm);
ActivateItem(_overlaysVm);
}
public bool EffectsEnabled public bool EffectsEnabled
{ {
get { return MainModel.Enabled; } get { return MainModel.Enabled; }
@ -53,6 +44,15 @@ namespace Artemis.ViewModels
public MainModel MainModel { get; set; } public MainModel MainModel { get; set; }
protected override void OnActivate()
{
base.OnActivate();
ActivateItem(_effectsVm);
ActivateItem(_gamesVm);
ActivateItem(_overlaysVm);
}
public void ToggleEffects() public void ToggleEffects()
{ {
if (EffectsEnabled) if (EffectsEnabled)

View File

@ -75,8 +75,9 @@
<RowDefinition Height="*" /> <RowDefinition Height="*" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Grid.Row ="0" Grid.Column="0" Text="Artemis pre-release" VerticalAlignment="Center" HorizontalAlignment="Left" /> <TextBlock Grid.Row="0" Grid.Column="0" Text="Artemis pre-release" VerticalAlignment="Center"
<Button Grid.Row ="0" Grid.Column="1" Focusable="False" Style="{StaticResource AccentedSquareButtonStyle}" HorizontalAlignment="Left" />
<Button Grid.Row="0" Grid.Column="1" Focusable="False" Style="{StaticResource AccentedSquareButtonStyle}"
cal:Message.Attach="[Action NavigateTo('https://github.com/SpoinkyNL/Artemis')]" cal:Message.Attach="[Action NavigateTo('https://github.com/SpoinkyNL/Artemis')]"
Content="View on GitHub" Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Right" /> Content="View on GitHub" Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Right" />
</Grid> </Grid>

View File

@ -18,7 +18,7 @@
Background="Transparent" Background="Transparent"
RenderOptions.EdgeMode="Aliased" RenderOptions.EdgeMode="Aliased"
RenderOptions.BitmapScalingMode="HighQuality"> RenderOptions.BitmapScalingMode="HighQuality">
<Image Source="/Artemis;component/Resources/bow.png"></Image> <Image Source="/Artemis;component/Resources/bow.png" />
</Grid> </Grid>
</DataTemplate> </DataTemplate>
</Controls:MetroWindow.IconTemplate> </Controls:MetroWindow.IconTemplate>

View File

@ -1,16 +1,4 @@
using System; using System.Windows;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Artemis.Views namespace Artemis.Views
{ {

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Autofac" version="3.5.2" targetFramework="net452" /> <package id="Autofac" version="3.5.2" targetFramework="net452" />
<package id="Caliburn.Micro" version="2.0.2" targetFramework="net452" /> <package id="Caliburn.Micro" version="2.0.2" targetFramework="net452" />