1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 21:38:38 +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>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<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" />
<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.Witcher3.Witcher3" 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" 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 name="userSettings"
type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<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" />
<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.Witcher3.Witcher3"
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"
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>
</configSections>
<connectionStrings />

View File

@ -1,9 +1,10 @@
using System.Drawing;
using CUE.NET;
using CUE.NET.Brushes;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Keyboard;
using CUE.NET.Brushes;
using CUE.NET.Devices.Keyboard.Keys;
using CUE.NET.Exceptions;
namespace Artemis.KeyboardProviders.Corsair
{
@ -15,8 +16,9 @@ namespace Artemis.KeyboardProviders.Corsair
{
Name = "Corsair Gaming K70 RGB";
}
/// <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>
public override void Enable()
{
@ -24,10 +26,13 @@ namespace Artemis.KeyboardProviders.Corsair
{
CueSDK.Initialize();
}
catch (CUE.NET.Exceptions.WrapperException) {/*CUE is already initialized*/}
catch (WrapperException)
{
/*CUE is already initialized*/
}
_keyboard = CueSDK.KeyboardSDK;
Height = (int)_keyboard.KeyboardRectangle.Height;
Width = (int)_keyboard.KeyboardRectangle.Width;
Height = (int) _keyboard.KeyboardRectangle.Height;
Width = (int) _keyboard.KeyboardRectangle.Width;
_keyboard.UpdateMode = UpdateMode.Manual;
_keyboard.Brush = new SolidColorBrush(Color.Black);
@ -39,21 +44,32 @@ namespace Artemis.KeyboardProviders.Corsair
}
/// <summary>
/// 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.
/// 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.
/// </summary>
/// <param name="bitmap"></param>
public override void DrawBitmap(Bitmap bitmap)
{
RectangleF[,] ledRectangles = new RectangleF[bitmap.Width, bitmap.Height];
RectangleKeyGroup[,] ledGroups = new RectangleKeyGroup[bitmap.Width, bitmap.Height];
var ledRectangles = new RectangleF[bitmap.Width, bitmap.Height];
var ledGroups = new RectangleKeyGroup[bitmap.Width, bitmap.Height];
//_keyboard.Brush = new SolidColorBrush(Color.Black);
for (var x = 0; x < bitmap.Width; x++)
{
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);
ledGroups[x, y] = new RectangleKeyGroup(_keyboard, ledRectangles[x, y], 0.01f) { Brush = new SolidColorBrush(bitmap.GetPixel(x, 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);
ledGroups[x, y] = new RectangleKeyGroup(_keyboard, ledRectangles[x, y], 0.01f)
{
Brush = new SolidColorBrush(bitmap.GetPixel(x, y))
};
}
}
_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.Devices.Keyboard;
using Artemis.Utilities;
using CUE.NET.Brushes;
using CUE.NET.Exceptions;
namespace Artemis.KeyboardProviders.Corsair
{
@ -17,7 +16,7 @@ namespace Artemis.KeyboardProviders.Corsair
}
/// <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>
public override void Enable()
{
@ -25,12 +24,15 @@ namespace Artemis.KeyboardProviders.Corsair
{
CueSDK.Initialize();
}
catch (CUE.NET.Exceptions.WrapperException){/*CUE is already initialized*/}
catch (WrapperException)
{
/*CUE is already initialized*/
}
_keyboard = CueSDK.KeyboardSDK;
Height = (int)_keyboard.KeyboardRectangle.Height;
Width = (int)_keyboard.KeyboardRectangle.Width;
Height = (int) _keyboard.KeyboardRectangle.Height;
Width = (int) _keyboard.KeyboardRectangle.Width;
// _keyboard.UpdateMode = UpdateMode.Manual;
// _keyboard.UpdateMode = UpdateMode.Manual;
_keyboard.Update(true);
}
@ -39,28 +41,28 @@ namespace Artemis.KeyboardProviders.Corsair
}
/// <summary>
/// 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.
/// 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.
/// </summary>
/// <param name="bitmap//"></param>
public override void DrawBitmap(Bitmap bitmap)
{
using (
var resized = ImageUtilities.ResizeImage(bitmap,
(int)_keyboard.KeyboardRectangle.Width,
(int)_keyboard.KeyboardRectangle.Height)
)
(int) _keyboard.KeyboardRectangle.Width,
(int) _keyboard.KeyboardRectangle.Height)
)
{
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))
ledColor = Color.Black;
item.Led.Color = ledColor;
}
}
_keyboard.Update(true);
}
/*

View File

@ -13,13 +13,13 @@ namespace Artemis.KeyboardProviders
public abstract void DrawBitmap(Bitmap bitmap);
/// <summary>
/// Returns a bitmap matching the keyboard's dimensions
/// 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
/// 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

@ -107,5 +107,5 @@ namespace Artemis.KeyboardProviders.Logitech.Utilities
NUM_ZERO = 0x52,
NUM_PERIOD = 0x53,
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_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_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;

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,7 @@
<?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 />
<Settings>
<Setting Name="Sensitivity" Type="System.Int32" Scope="User">

View File

@ -70,7 +70,6 @@ namespace Artemis.Modules.Effects.AudioVisualizer
ColorHelpers.ToDrawingColor(Settings.BottomColor)
},
LinearGradientMode.Vertical) {ContainedBrush = false});
}
_sampleAggregator.FftCalculated += FftCalculated;
@ -109,7 +108,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
// Apply Sensitivity setting
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)
SoundRectangles[i].Height = keyboardHeight;
else
@ -119,7 +118,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
SoundRectangles[i].Width = Scale;
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;
}

View File

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

View File

@ -90,7 +90,7 @@
HorizontalAlignment="Right" Width="110" TickPlacement="BottomRight" TickFrequency="1"
Value="{Binding Path=AudioVisualizerSettings.Bars, Mode=TwoWay}" Minimum="2" Maximum="21"
SmallChange="1" IsSnapToTickEnabled="True" />
<!-- Sensitivity -->
<TextBlock Grid.Row="6" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
Height="16" Margin="0,8">

View File

@ -28,15 +28,15 @@ namespace Artemis.Modules.Effects.Debug
public override void Enable()
{
KeyboardRectangle = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List<Color>
{
Color.Red,
Color.OrangeRed,
Color.Yellow,
Color.Green,
Color.Blue,
Color.Purple,
Color.DeepPink
}, LinearGradientMode.Horizontal);
{
Color.Red,
Color.OrangeRed,
Color.Yellow,
Color.Green,
Color.Blue,
Color.Purple,
Color.DeepPink
}, LinearGradientMode.Horizontal);
}
public override void Update()

View File

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

View File

@ -76,7 +76,7 @@
HorizontalAlignment="Right" Width="110" TickPlacement="BottomRight" TickFrequency="1"
Value="{Binding Path=DebugEffectSettings.Scale, Mode=TwoWay}" Minimum="1" Maximum="4"
SmallChange="1" IsSnapToTickEnabled="True" />
<!-- Color rotation -->
<TextBlock Grid.Row="5" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
Height="16" Margin="0,9,0,10">
@ -100,7 +100,7 @@
</InlineUIContainer>
</TextBlock>
</StackPanel>
<!-- Buttons -->
<StackPanel Grid.Column="0" Grid.Row="8" Orientation="Horizontal" VerticalAlignment="Bottom">
<Button x:Name="ResetSettings" Content="Reset effect" VerticalAlignment="Top" Width="100"

View File

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

View File

@ -7,7 +7,6 @@ using System.Windows.Forms;
using Artemis.KeyboardProviders.Logitech.Utilities;
using Artemis.Models;
using Artemis.Utilities;
using Gma.System.MouseKeyHook;
namespace Artemis.Modules.Effects.TypeWave
{
@ -53,7 +52,8 @@ namespace Artemis.Modules.Effects.TypeWave
_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 = 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)
@ -114,7 +114,7 @@ namespace Artemis.Modules.Effects.TypeWave
// 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;

View File

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

View File

@ -35,7 +35,7 @@
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Label Content="Enable effect" Margin="0 3 0 0" HorizontalAlignment="Right" />
<ToggleButton x:Name="EffectEnabled" Margin="0 3 0 0" Width="25" Height="25"
cal:Message.Attach="[Event Click] = [Action ToggleEffect]"
cal:Message.Attach="[Event Click] = [Action ToggleEffect]"
Style="{DynamicResource MetroCircleToggleButtonStyle}" />
</StackPanel>
</StackPanel>

View File

@ -46,7 +46,8 @@
<StackPanel Grid.Row="1"
Grid.Column="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>
<TextBox x:Name="GameDirectory" Height="23" TextWrapping="Wrap" Margin="5,0,30,0"
Text="{Binding Path=CounterStrikeSettings.GameDirectory, Mode=TwoWay}"

View File

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

View File

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

View File

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

View File

@ -1,5 +1,7 @@
<?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 />
<Settings>
<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.Sockets;
using System.Text;
using System.Threading;
using Artemis.Settings;
using Newtonsoft.Json;
namespace Artemis.Utilities.GameState
@ -31,7 +30,7 @@ namespace Artemis.Utilities.GameState
return;
_listener.Prefixes.Clear();
Port = Settings.General.Default.GamestatePort;
Port = General.Default.GamestatePort;
_listener.Prefixes.Add($"http://localhost:{Port}/");
_listener.Start();

View File

@ -1,22 +1,22 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace Artemis.Utilities
{
class ImageUtilities
internal class ImageUtilities
{
private static Dictionary<string, ImageCodecInfo> encoders = null;
private static Dictionary<string, ImageCodecInfo> encoders;
/// <summary>
/// A lock to prevent concurrency issues loading the encoders.
/// A lock to prevent concurrency issues loading the encoders.
/// </summary>
private static object encodersLock = new object();
private static readonly object encodersLock = new object();
/// <summary>
/// A quick lookup for getting image encoders
/// A quick lookup for getting image encoders
/// </summary>
public static Dictionary<string, ImageCodecInfo> Encoders
{
@ -35,7 +35,7 @@ namespace Artemis.Utilities
encoders = new Dictionary<string, ImageCodecInfo>();
//get all the codecs
foreach (ImageCodecInfo codec in ImageCodecInfo.GetImageEncoders())
foreach (var codec in ImageCodecInfo.GetImageEncoders())
{
//add each codec to the quick lookup
encoders.Add(codec.MimeType.ToLower(), codec);
@ -50,7 +50,7 @@ namespace Artemis.Utilities
}
/// <summary>
/// Resize the image to the specified width and height.
/// 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>
@ -59,17 +59,17 @@ namespace Artemis.Utilities
public static Bitmap ResizeImage(Image image, int width, int height)
{
//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
result.SetResolution(image.HorizontalResolution, image.VerticalResolution);
//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
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = SmoothingMode.HighQuality;
//draw the image into the target bitmap
graphics.DrawImage(image, 0, 0, result.Width, result.Height);
}
@ -78,14 +78,16 @@ namespace Artemis.Utilities
return result;
}
/// <summary>
/// Saves an image as a jpeg image, with the given quality
/// </summary>
/// <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
/// highest quality</param>
/// <summary>
/// Saves an image as a jpeg image, with the given quality
/// </summary>
/// <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
/// highest quality
/// </param>
/// <exception cref="ArgumentOutOfRangeException">
/// An invalid value was entered for image quality.
/// An invalid value was entered for image quality.
/// </exception>
public static void SaveJpeg(string path, Image image, int quality)
{
@ -93,31 +95,34 @@ namespace Artemis.Utilities
if ((quality < 0) || (quality > 100))
{
//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 new ArgumentOutOfRangeException(error);
}
//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
ImageCodecInfo jpegCodec = GetEncoderInfo("image/jpeg");
var jpegCodec = GetEncoderInfo("image/jpeg");
//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
encoderParams.Param[0] = qualityParam;
//save the image using the codec and the parameters
image.Save(path, jpegCodec, encoderParams);
}
/// <summary>
/// Returns the image codec with the given mime type
/// </summary>
/// <summary>
/// Returns the image codec with the given mime type
/// </summary>
public static ImageCodecInfo GetEncoderInfo(string mimeType)
{
//do a case insensitive search for the mime type
string lookupKey = mimeType.ToLower();
var lookupKey = mimeType.ToLower();
//the codec to return, default to null
ImageCodecInfo foundCodec = null;
@ -132,4 +137,4 @@ namespace Artemis.Utilities
return foundCodec;
}
}
}
}

View File

@ -159,7 +159,7 @@ namespace Artemis.Utilities.Keyboard
private ColorBlend CreateColorBlend()
{
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
? new ColorBlend {Colors = CreateTilebleColors(Colors).ToArray()}
: new ColorBlend {Colors = Colors.ToArray()};

View File

@ -11,17 +11,17 @@ namespace Artemis.Utilities.Memory
[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)
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)]

View File

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

View File

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

View File

@ -20,9 +20,9 @@ namespace Artemis.ViewModels
DisplayName = "Artemis";
_effectsVm = new EffectsViewModel(MainModel) {DisplayName = "Effects"};
_gamesVm = new GamesViewModel(MainModel) { DisplayName = "Games" };
_gamesVm = new GamesViewModel(MainModel) {DisplayName = "Games"};
_overlaysVm = new OverlaysViewModel(MainModel) {DisplayName = "Overlays"};
Flyouts.Add(new FlyoutSettingsViewModel());
// By now Effects are added to the MainModel so we can savely start one
@ -32,15 +32,6 @@ namespace Artemis.ViewModels
public IObservableCollection<FlyoutBaseViewModel> Flyouts { get; set; } =
new BindableCollection<FlyoutBaseViewModel>();
protected override void OnActivate()
{
base.OnActivate();
ActivateItem(_effectsVm);
ActivateItem(_gamesVm);
ActivateItem(_overlaysVm);
}
public bool EffectsEnabled
{
get { return MainModel.Enabled; }
@ -53,6 +44,15 @@ namespace Artemis.ViewModels
public MainModel MainModel { get; set; }
protected override void OnActivate()
{
base.OnActivate();
ActivateItem(_effectsVm);
ActivateItem(_gamesVm);
ActivateItem(_overlaysVm);
}
public void ToggleEffects()
{
if (EffectsEnabled)

View File

@ -32,7 +32,7 @@
Content="Enable Artemis:" />
<controls:ToggleSwitch Grid.Row="0" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No"
VerticalAlignment="Center" HorizontalAlignment="Right" Width="125" />
<!-- Startup with Windows -->
<Label Grid.Row="1" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
Content="Startup with Windows:" />
@ -75,8 +75,9 @@
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row ="0" Grid.Column="0" Text="Artemis pre-release" VerticalAlignment="Center" HorizontalAlignment="Left" />
<Button Grid.Row ="0" Grid.Column="1" Focusable="False" Style="{StaticResource AccentedSquareButtonStyle}"
<TextBlock Grid.Row="0" Grid.Column="0" Text="Artemis pre-release" VerticalAlignment="Center"
HorizontalAlignment="Left" />
<Button Grid.Row="0" Grid.Column="1" Focusable="False" Style="{StaticResource AccentedSquareButtonStyle}"
cal:Message.Attach="[Action NavigateTo('https://github.com/SpoinkyNL/Artemis')]"
Content="View on GitHub" Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Right" />
</Grid>

View File

@ -13,12 +13,12 @@
<Controls:MetroWindow.IconTemplate>
<DataTemplate>
<Grid Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
Margin="0,0,-10,0"
Background="Transparent"
RenderOptions.EdgeMode="Aliased"
RenderOptions.BitmapScalingMode="HighQuality">
<Image Source="/Artemis;component/Resources/bow.png"></Image>
Height="{TemplateBinding Height}"
Margin="0,0,-10,0"
Background="Transparent"
RenderOptions.EdgeMode="Aliased"
RenderOptions.BitmapScalingMode="HighQuality">
<Image Source="/Artemis;component/Resources/bow.png" />
</Grid>
</DataTemplate>
</Controls:MetroWindow.IconTemplate>
@ -49,7 +49,7 @@
</Controls:FlyoutsControl.ItemTemplate>
<Controls:FlyoutsControl.ItemContainerStyle>
<Style BasedOn="{StaticResource {x:Type Controls:Flyout}}" TargetType="{x:Type Controls:Flyout}">
<Setter Property="Header" Value="{Binding Header}" />
<Setter Property="Header" Value="{Binding Header}" />
<Setter Property="IsOpen" Value="{Binding IsOpen}" />
<Setter Property="Position" Value="{Binding Position}" />
</Style>

View File

@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cal="http://www.caliburnproject.org"
xmlns:tb="http://www.hardcodet.net/taskbar"
Title="SystemTrayView"
Title="SystemTrayView"
Height="0" Width="0"
WindowStartupLocation="CenterScreen"
WindowStyle="None"

View File

@ -1,21 +1,9 @@
using System;
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;
using System.Windows;
namespace Artemis.Views
{
/// <summary>
/// Interaction logic for SystemTrayView.xaml
/// Interaction logic for SystemTrayView.xaml
/// </summary>
public partial class SystemTrayView : Window
{
@ -24,4 +12,4 @@ namespace Artemis.Views
InitializeComponent();
}
}
}
}

View File

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