mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 21:38:38 +00:00
Made all modules and rectangles keyboard width and height aware
This commit is contained in:
parent
8f9696a80a
commit
06b7f5413b
@ -272,6 +272,8 @@
|
|||||||
<Compile Include="Modules\Effects\Debug\DebugEffectViewModel.cs" />
|
<Compile Include="Modules\Effects\Debug\DebugEffectViewModel.cs" />
|
||||||
<Compile Include="Modules\Effects\TypeHole\TypeHoleViewModel.cs" />
|
<Compile Include="Modules\Effects\TypeHole\TypeHoleViewModel.cs" />
|
||||||
<Compile Include="Modules\Effects\TypeWave\TypeWaveViewModel.cs" />
|
<Compile Include="Modules\Effects\TypeWave\TypeWaveViewModel.cs" />
|
||||||
|
<Compile Include="ViewModels\FlyoutBaseViewModel.cs" />
|
||||||
|
<Compile Include="ViewModels\Flyouts\FlyoutSettingsViewModel.cs" />
|
||||||
<Compile Include="ViewModels\GamesViewModel.cs" />
|
<Compile Include="ViewModels\GamesViewModel.cs" />
|
||||||
<Compile Include="Modules\Games\CounterStrike\CounterStrikeViewModel.cs" />
|
<Compile Include="Modules\Games\CounterStrike\CounterStrikeViewModel.cs" />
|
||||||
<Compile Include="Modules\Games\Dota2\Dota2ViewModel.cs" />
|
<Compile Include="Modules\Games\Dota2\Dota2ViewModel.cs" />
|
||||||
@ -279,7 +281,6 @@
|
|||||||
<Compile Include="Modules\Games\Witcher3\Witcher3ViewModel.cs" />
|
<Compile Include="Modules\Games\Witcher3\Witcher3ViewModel.cs" />
|
||||||
<Compile Include="ViewModels\OverlaysViewModel.cs" />
|
<Compile Include="ViewModels\OverlaysViewModel.cs" />
|
||||||
<Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplayViewModel.cs" />
|
<Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplayViewModel.cs" />
|
||||||
<Compile Include="ViewModels\SettingsViewModel.cs" />
|
|
||||||
<Compile Include="ViewModels\ShellViewModel.cs" />
|
<Compile Include="ViewModels\ShellViewModel.cs" />
|
||||||
<Compile Include="Views\EffectsView.xaml.cs">
|
<Compile Include="Views\EffectsView.xaml.cs">
|
||||||
<DependentUpon>EffectsView.xaml</DependentUpon>
|
<DependentUpon>EffectsView.xaml</DependentUpon>
|
||||||
@ -296,6 +297,9 @@
|
|||||||
<Compile Include="Modules\Effects\TypeWave\TypeWaveView.xaml.cs">
|
<Compile Include="Modules\Effects\TypeWave\TypeWaveView.xaml.cs">
|
||||||
<DependentUpon>TypeWaveView.xaml</DependentUpon>
|
<DependentUpon>TypeWaveView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Views\Flyouts\FlyoutSettingsView.xaml.cs">
|
||||||
|
<DependentUpon>FlyoutSettingsView.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Views\GamesView.xaml.cs">
|
<Compile Include="Views\GamesView.xaml.cs">
|
||||||
<DependentUpon>GamesView.xaml</DependentUpon>
|
<DependentUpon>GamesView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -317,9 +321,6 @@
|
|||||||
<Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplayView.xaml.cs">
|
<Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplayView.xaml.cs">
|
||||||
<DependentUpon>VolumeDisplayView.xaml</DependentUpon>
|
<DependentUpon>VolumeDisplayView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Views\SettingsView.xaml.cs">
|
|
||||||
<DependentUpon>SettingsView.xaml</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Views\ShellView.xaml.cs">
|
<Compile Include="Views\ShellView.xaml.cs">
|
||||||
<DependentUpon>ShellView.xaml</DependentUpon>
|
<DependentUpon>ShellView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -402,6 +403,10 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="Views\Flyouts\FlyoutSettingsView.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\GamesView.xaml">
|
<Page Include="Views\GamesView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
@ -430,10 +435,6 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="Views\SettingsView.xaml">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Page>
|
|
||||||
<Page Include="Views\ShellView.xaml">
|
<Page Include="Views\ShellView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
@ -11,5 +11,17 @@ namespace Artemis.KeyboardProviders
|
|||||||
public abstract void Enable();
|
public abstract void Enable();
|
||||||
public abstract void Disable();
|
public abstract void Disable();
|
||||||
public abstract void DrawBitmap(Bitmap bitmap);
|
public abstract void DrawBitmap(Bitmap bitmap);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a bitmap matching the keyboard's dimensions
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Bitmap KeyboardBitmap() => new Bitmap(Height, Width);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a bitmap matching the keyboard's dimensions using the provided scale
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Bitmap KeyboardBitmap(int scale) => new Bitmap(Height*scale, Width*scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5,7 +5,14 @@ namespace Artemis.Models
|
|||||||
{
|
{
|
||||||
public abstract class EffectModel : IDisposable
|
public abstract class EffectModel : IDisposable
|
||||||
{
|
{
|
||||||
|
public MainModel MainModel;
|
||||||
public string Name;
|
public string Name;
|
||||||
|
|
||||||
|
protected EffectModel(MainModel mainModel)
|
||||||
|
{
|
||||||
|
MainModel = mainModel;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void Dispose();
|
public abstract void Dispose();
|
||||||
|
|
||||||
// Called on creation
|
// Called on creation
|
||||||
|
|||||||
@ -4,5 +4,9 @@
|
|||||||
{
|
{
|
||||||
public bool Enabled;
|
public bool Enabled;
|
||||||
public string ProcessName;
|
public string ProcessName;
|
||||||
|
|
||||||
|
protected GameModel(MainModel mainModel) : base(mainModel)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,6 +7,10 @@ namespace Artemis.Models
|
|||||||
private bool _enabled;
|
private bool _enabled;
|
||||||
public string ProcessName;
|
public string ProcessName;
|
||||||
|
|
||||||
|
protected OverlayModel(MainModel mainModel) : base(mainModel)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public bool Enabled
|
public bool Enabled
|
||||||
{
|
{
|
||||||
get { return _enabled; }
|
get { return _enabled; }
|
||||||
|
|||||||
@ -20,7 +20,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
private bool _previousFromBottom;
|
private bool _previousFromBottom;
|
||||||
private IWaveIn _waveIn;
|
private IWaveIn _waveIn;
|
||||||
|
|
||||||
public AudioVisualizerModel(AudioVisualizerSettings settings)
|
public AudioVisualizerModel(MainModel mainModel, AudioVisualizerSettings settings) : base(mainModel)
|
||||||
{
|
{
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
Name = "Audiovisualizer";
|
Name = "Audiovisualizer";
|
||||||
@ -28,8 +28,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
SpectrumData = new List<byte>();
|
SpectrumData = new List<byte>();
|
||||||
SoundRectangles = new List<KeyboardRectangle>();
|
SoundRectangles = new List<KeyboardRectangle>();
|
||||||
Scale = 4;
|
Scale = 4;
|
||||||
Lines = 21*Scale;
|
|
||||||
|
|
||||||
// Fill list with device IDs
|
// Fill list with device IDs
|
||||||
// Would rather just store a MMDevice object, but seems NAudio won't let me.
|
// Would rather just store a MMDevice object, but seems NAudio won't let me.
|
||||||
var deviceEnum = new MMDeviceEnumerator();
|
var deviceEnum = new MMDeviceEnumerator();
|
||||||
@ -65,6 +64,8 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
|
|
||||||
public override void Enable()
|
public override void Enable()
|
||||||
{
|
{
|
||||||
|
Lines = MainModel.ActiveKeyboard.Width * Scale;
|
||||||
|
|
||||||
_sampleAggregator.FftCalculated += FftCalculated;
|
_sampleAggregator.FftCalculated += FftCalculated;
|
||||||
_sampleAggregator.PerformFFT = true;
|
_sampleAggregator.PerformFFT = true;
|
||||||
|
|
||||||
@ -111,8 +112,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
height = (int) (Math.Round(SpectrumData[i]/2.55));
|
height = (int) (Math.Round(SpectrumData[i]/2.55));
|
||||||
|
|
||||||
if (SoundRectangles.Count <= i)
|
if (SoundRectangles.Count <= i)
|
||||||
SoundRectangles.Add(new KeyboardRectangle(Scale, 0, 0, 21, 6,
|
SoundRectangles.Add(new KeyboardRectangle(MainModel.ActiveKeyboard, Scale, 0, 0, new List<Color>
|
||||||
new List<Color>
|
|
||||||
{
|
{
|
||||||
ColorHelpers.MediaColorToDrawingColor(Settings.MainColor),
|
ColorHelpers.MediaColorToDrawingColor(Settings.MainColor),
|
||||||
ColorHelpers.MediaColorToDrawingColor(Settings.SecondaryColor)
|
ColorHelpers.MediaColorToDrawingColor(Settings.SecondaryColor)
|
||||||
@ -129,7 +129,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
SoundRectangles[i].Width = (int) Math.Ceiling((double) Lines/Settings.Bars);
|
SoundRectangles[i].Width = (int) Math.Ceiling((double) Lines/Settings.Bars);
|
||||||
|
|
||||||
if (Settings.FromBottom)
|
if (Settings.FromBottom)
|
||||||
SoundRectangles[i].Y = (Scale*8) - SoundRectangles[i].Height;
|
SoundRectangles[i].Y = (Scale*MainModel.ActiveKeyboard.Height) - SoundRectangles[i].Height;
|
||||||
}
|
}
|
||||||
_generating = false;
|
_generating = false;
|
||||||
}
|
}
|
||||||
@ -145,7 +145,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bitmap = new Bitmap(21*Scale, 6*Scale);
|
var bitmap = MainModel.ActiveKeyboard.KeyboardBitmap(Scale);
|
||||||
using (var g = Graphics.FromImage(bitmap))
|
using (var g = Graphics.FromImage(bitmap))
|
||||||
{
|
{
|
||||||
foreach (var soundRectangle in SoundRectangles)
|
foreach (var soundRectangle in SoundRectangles)
|
||||||
|
|||||||
@ -18,7 +18,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
|
|||||||
AudioVisualizerSettings = new AudioVisualizerSettings();
|
AudioVisualizerSettings = new AudioVisualizerSettings();
|
||||||
|
|
||||||
// Create effect model and add it to MainModel
|
// Create effect model and add it to MainModel
|
||||||
AudioVisualizerModel = new AudioVisualizerModel(AudioVisualizerSettings);
|
AudioVisualizerModel = new AudioVisualizerModel(mainModel, AudioVisualizerSettings);
|
||||||
MainModel.EffectModels.Add(AudioVisualizerModel);
|
MainModel.EffectModels.Add(AudioVisualizerModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,23 +8,11 @@ namespace Artemis.Modules.Effects.Debug
|
|||||||
{
|
{
|
||||||
internal class DebugEffectModel : EffectModel
|
internal class DebugEffectModel : EffectModel
|
||||||
{
|
{
|
||||||
public DebugEffectModel(DebugEffectSettings settings)
|
public DebugEffectModel(MainModel mainModel, DebugEffectSettings settings) : base(mainModel)
|
||||||
{
|
{
|
||||||
Name = "Debug Effect";
|
Name = "Debug Effect";
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
Scale = 4;
|
Scale = 4;
|
||||||
|
|
||||||
KeyboardRectangle = new KeyboardRectangle(Scale, 0, 0, 21, 6,
|
|
||||||
new List<Color>
|
|
||||||
{
|
|
||||||
Color.Red,
|
|
||||||
Color.OrangeRed,
|
|
||||||
Color.Yellow,
|
|
||||||
Color.Green,
|
|
||||||
Color.Blue,
|
|
||||||
Color.Purple,
|
|
||||||
Color.DeepPink
|
|
||||||
}, LinearGradientMode.Horizontal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Scale { get; set; }
|
public int Scale { get; set; }
|
||||||
@ -39,6 +27,16 @@ namespace Artemis.Modules.Effects.Debug
|
|||||||
|
|
||||||
public override void Enable()
|
public override void Enable()
|
||||||
{
|
{
|
||||||
|
KeyboardRectangle = new KeyboardRectangle(MainModel.ActiveKeyboard, Scale, 0, 0, new List<Color>
|
||||||
|
{
|
||||||
|
Color.Red,
|
||||||
|
Color.OrangeRed,
|
||||||
|
Color.Yellow,
|
||||||
|
Color.Green,
|
||||||
|
Color.Blue,
|
||||||
|
Color.Purple,
|
||||||
|
Color.DeepPink
|
||||||
|
}, LinearGradientMode.Horizontal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
|
|||||||
@ -26,7 +26,7 @@ namespace Artemis.Modules.Effects.Debug
|
|||||||
DebugEffectSettings = new DebugEffectSettings();
|
DebugEffectSettings = new DebugEffectSettings();
|
||||||
|
|
||||||
// Create effect model and add it to MainModel
|
// Create effect model and add it to MainModel
|
||||||
DebugEffectModel = new DebugEffectModel(DebugEffectSettings);
|
DebugEffectModel = new DebugEffectModel(mainModel, DebugEffectSettings);
|
||||||
MainModel.EffectModels.Add(DebugEffectModel);
|
MainModel.EffectModels.Add(DebugEffectModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ namespace Artemis.Modules.Effects.TypeHole
|
|||||||
{
|
{
|
||||||
public class TypeHoleModel : EffectModel
|
public class TypeHoleModel : EffectModel
|
||||||
{
|
{
|
||||||
public TypeHoleModel()
|
public TypeHoleModel(MainModel mainModel) : base(mainModel)
|
||||||
{
|
{
|
||||||
Name = "TypeHole";
|
Name = "TypeHole";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ namespace Artemis.Modules.Effects.TypeHole
|
|||||||
MainModel.Events.Subscribe(this);
|
MainModel.Events.Subscribe(this);
|
||||||
|
|
||||||
// Create effect model and add it to MainModel
|
// Create effect model and add it to MainModel
|
||||||
TypeHoleModel = new TypeHoleModel();
|
TypeHoleModel = new TypeHoleModel(mainModel);
|
||||||
MainModel.EffectModels.Add(TypeHoleModel);
|
MainModel.EffectModels.Add(TypeHoleModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ namespace Artemis.Modules.Effects.TypeWave
|
|||||||
{
|
{
|
||||||
public class TypeWaveModel : EffectModel
|
public class TypeWaveModel : EffectModel
|
||||||
{
|
{
|
||||||
public TypeWaveModel(TypeWaveSettings settings)
|
public TypeWaveModel(MainModel mainModel, TypeWaveSettings settings) : base(mainModel)
|
||||||
{
|
{
|
||||||
Name = "TypeWave";
|
Name = "TypeWave";
|
||||||
Waves = new List<Wave>();
|
Waves = new List<Wave>();
|
||||||
|
|||||||
@ -18,7 +18,7 @@ namespace Artemis.Modules.Effects.TypeWave
|
|||||||
TypeWaveSettings = new TypeWaveSettings();
|
TypeWaveSettings = new TypeWaveSettings();
|
||||||
|
|
||||||
// Create effect model and add it to MainModel
|
// Create effect model and add it to MainModel
|
||||||
TypeWaveModel = new TypeWaveModel(TypeWaveSettings);
|
TypeWaveModel = new TypeWaveModel(mainModel, TypeWaveSettings);
|
||||||
MainModel.EffectModels.Add(TypeWaveModel);
|
MainModel.EffectModels.Add(TypeWaveModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,25 +15,13 @@ namespace Artemis.Modules.Games.CounterStrike
|
|||||||
public class CounterStrikeModel : GameModel
|
public class CounterStrikeModel : GameModel
|
||||||
{
|
{
|
||||||
private readonly CounterStrikeSettings _counterStrikeSettings;
|
private readonly CounterStrikeSettings _counterStrikeSettings;
|
||||||
private readonly MainModel _mainModel;
|
|
||||||
|
|
||||||
public CounterStrikeModel(CounterStrikeSettings counterStrikeSettings, MainModel mainModel)
|
public CounterStrikeModel(MainModel mainModel, CounterStrikeSettings counterStrikeSettings) : base(mainModel)
|
||||||
{
|
{
|
||||||
_counterStrikeSettings = counterStrikeSettings;
|
_counterStrikeSettings = counterStrikeSettings;
|
||||||
_mainModel = mainModel;
|
|
||||||
Name = "CounterStrike";
|
Name = "CounterStrike";
|
||||||
ProcessName = "csgo";
|
ProcessName = "csgo";
|
||||||
Scale = 4;
|
Scale = 4;
|
||||||
|
|
||||||
AmmoRect = new KeyboardRectangle(Scale, 0, 0, 16*Scale, 1*Scale,
|
|
||||||
new List<Color>(),
|
|
||||||
LinearGradientMode.Horizontal);
|
|
||||||
TeamRect = new KeyboardRectangle(Scale, 0, 1*Scale, 21*Scale, 8*Scale,
|
|
||||||
new List<Color>(),
|
|
||||||
LinearGradientMode.Horizontal);
|
|
||||||
EventRect = new KeyboardRectangle(Scale, 0, 1*Scale, 21*Scale, 8*Scale,
|
|
||||||
new List<Color>(),
|
|
||||||
LinearGradientMode.Horizontal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyboardRectangle EventRect { get; set; }
|
public KeyboardRectangle EventRect { get; set; }
|
||||||
@ -48,12 +36,16 @@ namespace Artemis.Modules.Games.CounterStrike
|
|||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
_mainModel.GameStateWebServer.GameDataReceived -= HandleGameData;
|
MainModel.GameStateWebServer.GameDataReceived -= HandleGameData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Enable()
|
public override void Enable()
|
||||||
{
|
{
|
||||||
_mainModel.GameStateWebServer.GameDataReceived += HandleGameData;
|
// TODO: Size stuff
|
||||||
|
AmmoRect = new KeyboardRectangle(MainModel.ActiveKeyboard, Scale, 0, 0, new List<Color>(), LinearGradientMode.Horizontal);
|
||||||
|
TeamRect = new KeyboardRectangle(MainModel.ActiveKeyboard, Scale, 0, 1 * Scale, new List<Color>(), LinearGradientMode.Horizontal);
|
||||||
|
EventRect = new KeyboardRectangle(MainModel.ActiveKeyboard, Scale, 0, 1 * Scale, new List<Color>(), LinearGradientMode.Horizontal);
|
||||||
|
MainModel.GameStateWebServer.GameDataReceived += HandleGameData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
|
|||||||
@ -18,7 +18,7 @@ namespace Artemis.Modules.Games.CounterStrike
|
|||||||
CounterStrikeSettings = new CounterStrikeSettings();
|
CounterStrikeSettings = new CounterStrikeSettings();
|
||||||
|
|
||||||
// Create effect model and add it to MainModel
|
// Create effect model and add it to MainModel
|
||||||
CounterStrikeModel = new CounterStrikeModel(CounterStrikeSettings, MainModel);
|
CounterStrikeModel = new CounterStrikeModel(mainModel, CounterStrikeSettings);
|
||||||
MainModel.EffectModels.Add(CounterStrikeModel);
|
MainModel.EffectModels.Add(CounterStrikeModel);
|
||||||
PlaceConfigFile();
|
PlaceConfigFile();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,29 +16,22 @@ namespace Artemis.Modules.Games.RocketLeague
|
|||||||
{
|
{
|
||||||
public class RocketLeagueModel : GameModel
|
public class RocketLeagueModel : GameModel
|
||||||
{
|
{
|
||||||
private readonly KeyboardRectangle _boostRect;
|
private readonly RocketLeagueSettings _settings;
|
||||||
|
private KeyboardRectangle _boostRect;
|
||||||
private int _boostAmount;
|
private int _boostAmount;
|
||||||
private bool _boostGrowing;
|
private bool _boostGrowing;
|
||||||
|
|
||||||
private Memory _memory;
|
private Memory _memory;
|
||||||
private GamePointersCollectionModel _pointer;
|
private GamePointersCollectionModel _pointer;
|
||||||
private int _previousBoost;
|
private int _previousBoost;
|
||||||
|
|
||||||
public RocketLeagueModel(RocketLeagueSettings settings)
|
public RocketLeagueModel(MainModel mainModel, RocketLeagueSettings settings) : base(mainModel)
|
||||||
{
|
{
|
||||||
Name = "RocketLeague";
|
Name = "RocketLeague";
|
||||||
ProcessName = "RocketLeague";
|
ProcessName = "RocketLeague";
|
||||||
Scale = 4;
|
Scale = 4;
|
||||||
|
|
||||||
_boostRect = new KeyboardRectangle(Scale, 0, 0, Scale*21, Scale*8,
|
|
||||||
new List<Color>
|
|
||||||
{
|
|
||||||
ColorHelpers.MediaColorToDrawingColor(settings.MainColor),
|
|
||||||
ColorHelpers.MediaColorToDrawingColor(settings.SecondaryColor)
|
|
||||||
}, LinearGradientMode.Horizontal);
|
|
||||||
|
|
||||||
Enabled = settings.Enabled;
|
Enabled = settings.Enabled;
|
||||||
|
|
||||||
|
_settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Scale { get; set; }
|
public int Scale { get; set; }
|
||||||
@ -50,6 +43,12 @@ namespace Artemis.Modules.Games.RocketLeague
|
|||||||
|
|
||||||
public override void Enable()
|
public override void Enable()
|
||||||
{
|
{
|
||||||
|
_boostRect = new KeyboardRectangle(MainModel.ActiveKeyboard, Scale, 0, 0, new List<Color>
|
||||||
|
{
|
||||||
|
ColorHelpers.MediaColorToDrawingColor(_settings.MainColor),
|
||||||
|
ColorHelpers.MediaColorToDrawingColor(_settings.SecondaryColor)
|
||||||
|
}, LinearGradientMode.Horizontal);
|
||||||
|
|
||||||
MemoryHelpers.GetPointers();
|
MemoryHelpers.GetPointers();
|
||||||
_pointer = JsonConvert
|
_pointer = JsonConvert
|
||||||
.DeserializeObject<GamePointersCollectionModel>(Offsets.Default.RocketLeague);
|
.DeserializeObject<GamePointersCollectionModel>(Offsets.Default.RocketLeague);
|
||||||
|
|||||||
@ -15,7 +15,7 @@ namespace Artemis.Modules.Games.RocketLeague
|
|||||||
RocketLeagueSettings = new RocketLeagueSettings();
|
RocketLeagueSettings = new RocketLeagueSettings();
|
||||||
|
|
||||||
// Create effect model and add it to MainModel
|
// Create effect model and add it to MainModel
|
||||||
RocketLeagueModel = new RocketLeagueModel(RocketLeagueSettings);
|
RocketLeagueModel = new RocketLeagueModel(mainModel, RocketLeagueSettings);
|
||||||
MainModel.EffectModels.Add(RocketLeagueModel);
|
MainModel.EffectModels.Add(RocketLeagueModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,24 +15,17 @@ namespace Artemis.Modules.Games.Witcher3
|
|||||||
{
|
{
|
||||||
public class Witcher3Model : GameModel
|
public class Witcher3Model : GameModel
|
||||||
{
|
{
|
||||||
private readonly KeyboardRectangle _signRect;
|
private KeyboardRectangle _signRect;
|
||||||
|
|
||||||
private IntPtr _baseAddress;
|
private IntPtr _baseAddress;
|
||||||
private GamePointersCollectionModel _pointer;
|
private GamePointersCollectionModel _pointer;
|
||||||
private RemoteProcess _process;
|
private RemoteProcess _process;
|
||||||
|
|
||||||
public Witcher3Model(RocketLeagueSettings settings)
|
public Witcher3Model(MainModel mainModel, RocketLeagueSettings settings) : base(mainModel)
|
||||||
{
|
{
|
||||||
Name = "Witcher3";
|
Name = "Witcher3";
|
||||||
ProcessName = "witcher3";
|
ProcessName = "witcher3";
|
||||||
Scale = 4;
|
Scale = 4;
|
||||||
|
|
||||||
_signRect = new KeyboardRectangle(Scale, 0, 0, 84, 24, new List<Color>(), LinearGradientMode.Horizontal)
|
|
||||||
{
|
|
||||||
Rotate = true,
|
|
||||||
LoopSpeed = 0.5
|
|
||||||
};
|
|
||||||
|
|
||||||
Enabled = settings.Enabled;
|
Enabled = settings.Enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,6 +38,11 @@ namespace Artemis.Modules.Games.Witcher3
|
|||||||
|
|
||||||
public override void Enable()
|
public override void Enable()
|
||||||
{
|
{
|
||||||
|
_signRect = new KeyboardRectangle(MainModel.ActiveKeyboard, Scale, 0, 0, new List<Color>(), LinearGradientMode.Horizontal)
|
||||||
|
{
|
||||||
|
Rotate = true,
|
||||||
|
LoopSpeed = 0.5
|
||||||
|
};
|
||||||
MemoryHelpers.GetPointers();
|
MemoryHelpers.GetPointers();
|
||||||
_pointer = JsonConvert
|
_pointer = JsonConvert
|
||||||
.DeserializeObject<GamePointersCollectionModel>(Offsets.Default.Witcher3);
|
.DeserializeObject<GamePointersCollectionModel>(Offsets.Default.Witcher3);
|
||||||
@ -123,7 +121,7 @@ namespace Artemis.Modules.Games.Witcher3
|
|||||||
|
|
||||||
public override Bitmap GenerateBitmap()
|
public override Bitmap GenerateBitmap()
|
||||||
{
|
{
|
||||||
var bitmap = new Bitmap(21, 6);
|
var bitmap = MainModel.ActiveKeyboard.KeyboardBitmap();
|
||||||
using (var g = Graphics.FromImage(bitmap))
|
using (var g = Graphics.FromImage(bitmap))
|
||||||
{
|
{
|
||||||
g.Clear(Color.Transparent);
|
g.Clear(Color.Transparent);
|
||||||
|
|||||||
@ -16,7 +16,7 @@ namespace Artemis.Modules.Games.Witcher3
|
|||||||
RocketLeagueSettings = new RocketLeagueSettings();
|
RocketLeagueSettings = new RocketLeagueSettings();
|
||||||
|
|
||||||
// Create effect model and add it to MainModel
|
// Create effect model and add it to MainModel
|
||||||
Witcher3Model = new Witcher3Model(RocketLeagueSettings);
|
Witcher3Model = new Witcher3Model(mainModel, RocketLeagueSettings);
|
||||||
MainModel.EffectModels.Add(Witcher3Model);
|
MainModel.EffectModels.Add(Witcher3Model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
|
using Artemis.Models;
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using Artemis.Utilities.Keyboard;
|
using Artemis.Utilities.Keyboard;
|
||||||
|
|
||||||
@ -9,13 +10,16 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
|||||||
{
|
{
|
||||||
public class VolumeDisplay
|
public class VolumeDisplay
|
||||||
{
|
{
|
||||||
public VolumeDisplay(VolumeDisplaySettings settings)
|
public VolumeDisplay(MainModel mainModel, VolumeDisplaySettings settings)
|
||||||
{
|
{
|
||||||
|
MainModel = mainModel;
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
Transparancy = 255;
|
Transparancy = 255;
|
||||||
Scale = 4;
|
Scale = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MainModel MainModel { get; set; }
|
||||||
|
|
||||||
public VolumeDisplaySettings Settings { get; set; }
|
public VolumeDisplaySettings Settings { get; set; }
|
||||||
|
|
||||||
public int Scale { get; set; }
|
public int Scale { get; set; }
|
||||||
@ -27,7 +31,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
|||||||
|
|
||||||
public void Draw(Graphics g)
|
public void Draw(Graphics g)
|
||||||
{
|
{
|
||||||
var volumeRect = new KeyboardRectangle(Scale, 0, 0, (int) Math.Ceiling(((Scale*21)/100.00)*Volume), 8*Scale,
|
var volumeRect = new KeyboardRectangle(MainModel.ActiveKeyboard, Scale, 0, 0,
|
||||||
new List<Color>
|
new List<Color>
|
||||||
{
|
{
|
||||||
ColorHelpers.MediaColorToDrawingColor(Settings.MainColor),
|
ColorHelpers.MediaColorToDrawingColor(Settings.MainColor),
|
||||||
|
|||||||
@ -12,7 +12,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
|||||||
{
|
{
|
||||||
private bool _enabled;
|
private bool _enabled;
|
||||||
|
|
||||||
public VolumeDisplayModel(VolumeDisplaySettings settings)
|
public VolumeDisplayModel(MainModel mainModel, VolumeDisplaySettings settings) : base(mainModel)
|
||||||
{
|
{
|
||||||
Settings = settings;
|
Settings = settings;
|
||||||
Name = "VolumeDisplay";
|
Name = "VolumeDisplay";
|
||||||
@ -22,7 +22,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
|||||||
|
|
||||||
Enabled = Settings.Enabled;
|
Enabled = Settings.Enabled;
|
||||||
|
|
||||||
VolumeDisplay = new VolumeDisplay(settings);
|
VolumeDisplay = new VolumeDisplay(mainModel, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VolumeDisplay VolumeDisplay { get; set; }
|
public VolumeDisplay VolumeDisplay { get; set; }
|
||||||
|
|||||||
@ -15,7 +15,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
|||||||
VolumeDisplaySettings = new VolumeDisplaySettings();
|
VolumeDisplaySettings = new VolumeDisplaySettings();
|
||||||
|
|
||||||
// Create effect model and add it to MainModel
|
// Create effect model and add it to MainModel
|
||||||
VolumeDisplayModel = new VolumeDisplayModel(VolumeDisplaySettings);
|
VolumeDisplayModel = new VolumeDisplayModel(mainModel, VolumeDisplaySettings);
|
||||||
MainModel.EffectModels.Add(VolumeDisplayModel);
|
MainModel.EffectModels.Add(VolumeDisplayModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,34 +5,37 @@ using System.Drawing.Drawing2D;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Artemis.KeyboardProviders;
|
||||||
|
|
||||||
namespace Artemis.Utilities.Keyboard
|
namespace Artemis.Utilities.Keyboard
|
||||||
{
|
{
|
||||||
public class KeyboardRectangle
|
public class KeyboardRectangle
|
||||||
{
|
{
|
||||||
private readonly BackgroundWorker _blinkWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
|
private readonly BackgroundWorker _blinkWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
|
||||||
|
private readonly KeyboardProvider _keyboard;
|
||||||
private int _blinkDelay;
|
private int _blinkDelay;
|
||||||
private List<Color> _colors;
|
private List<Color> _colors;
|
||||||
private double _rotationProgress;
|
private double _rotationProgress;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a Rectangle on the keyboard which can be drawn to a Bitmap
|
/// Represents a Rectangle on the keyboard which can be drawn to a Bitmap.
|
||||||
|
/// By default, a rectangle is the entire keyboard's size.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="keyboard">The keyboard this rectangle will be used for</param>
|
||||||
/// <param name="scale">The scale on which the rect should be rendered (Higher means smoother rotation)</param>
|
/// <param name="scale">The scale on which the rect should be rendered (Higher means smoother rotation)</param>
|
||||||
/// <param name="x"></param>
|
/// <param name="x"></param>
|
||||||
/// <param name="y"></param>
|
/// <param name="y"></param>
|
||||||
/// <param name="width"></param>
|
|
||||||
/// <param name="height"></param>
|
|
||||||
/// <param name="colors">An array of colors the ColorBlend will use</param>
|
/// <param name="colors">An array of colors the ColorBlend will use</param>
|
||||||
/// <param name="gradientMode"></param>
|
/// <param name="gradientMode"></param>
|
||||||
public KeyboardRectangle(int scale, int x, int y, int width, int height, List<Color> colors,
|
public KeyboardRectangle(KeyboardProvider keyboard, int scale, int x, int y, List<Color> colors,
|
||||||
LinearGradientMode gradientMode)
|
LinearGradientMode gradientMode)
|
||||||
{
|
{
|
||||||
|
_keyboard = keyboard;
|
||||||
Scale = scale;
|
Scale = scale;
|
||||||
X = x;
|
X = x;
|
||||||
Y = y;
|
Y = y;
|
||||||
Width = width;
|
Width = keyboard.Width*Scale;
|
||||||
Height = height;
|
Height = keyboard.Height*Scale;
|
||||||
Colors = colors;
|
Colors = colors;
|
||||||
GradientMode = gradientMode;
|
GradientMode = gradientMode;
|
||||||
|
|
||||||
@ -40,7 +43,7 @@ namespace Artemis.Utilities.Keyboard
|
|||||||
Rotate = false;
|
Rotate = false;
|
||||||
LoopSpeed = 1;
|
LoopSpeed = 1;
|
||||||
Visible = true;
|
Visible = true;
|
||||||
ContainedBrush = true;
|
ContainedBrush = false;
|
||||||
|
|
||||||
_rotationProgress = 0;
|
_rotationProgress = 0;
|
||||||
_blinkWorker.DoWork += BlinkWorker_DoWork;
|
_blinkWorker.DoWork += BlinkWorker_DoWork;
|
||||||
@ -53,6 +56,10 @@ namespace Artemis.Utilities.Keyboard
|
|||||||
public int Y { get; set; }
|
public int Y { get; set; }
|
||||||
public int Width { get; set; }
|
public int Width { get; set; }
|
||||||
public int Height { get; set; }
|
public int Height { get; set; }
|
||||||
|
public LinearGradientMode GradientMode { get; set; }
|
||||||
|
public bool Rotate { get; set; }
|
||||||
|
public double LoopSpeed { get; set; }
|
||||||
|
public bool Visible { get; set; }
|
||||||
|
|
||||||
public List<Color> Colors
|
public List<Color> Colors
|
||||||
{
|
{
|
||||||
@ -67,18 +74,6 @@ namespace Artemis.Utilities.Keyboard
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinearGradientMode GradientMode { get; set; }
|
|
||||||
|
|
||||||
public bool Rotate { get; set; }
|
|
||||||
public double LoopSpeed { get; set; }
|
|
||||||
|
|
||||||
public bool Visible { get; set; }
|
|
||||||
|
|
||||||
public KeyboardRectangle Clone()
|
|
||||||
{
|
|
||||||
return (KeyboardRectangle) MemberwiseClone();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StartBlink(int delay)
|
public void StartBlink(int delay)
|
||||||
{
|
{
|
||||||
_blinkDelay = delay;
|
_blinkDelay = delay;
|
||||||
@ -118,43 +113,26 @@ namespace Artemis.Utilities.Keyboard
|
|||||||
if (!Visible || Height < 1 || Width < 1 || !Colors.Any())
|
if (!Visible || Height < 1 || Width < 1 || !Colors.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var brush = ContainedBrush
|
var brush = CreateBrush();
|
||||||
? CreateContainedBrush()
|
|
||||||
: CreateBrush();
|
|
||||||
var colorBlend = CreateColorBlend();
|
|
||||||
|
|
||||||
var baseRect = new Rectangle(X, Y, Width, Height);
|
var baseRect = new Rectangle(X, Y, Width, Height);
|
||||||
var brushRect = ContainedBrush
|
|
||||||
? new Rectangle((int) _rotationProgress, Y, baseRect.Width*2, baseRect.Height*2)
|
|
||||||
: new Rectangle((int) _rotationProgress, 0, 21*2, 8*2);
|
|
||||||
LinearGradientBrush baseBrush;
|
|
||||||
if (Colors.Count > 5)
|
|
||||||
baseBrush = new LinearGradientBrush(brushRect, Colors.First(), Colors.Skip(1).FirstOrDefault(),
|
|
||||||
GradientMode) {InterpolationColors = colorBlend};
|
|
||||||
else if (Colors.Count > 1)
|
|
||||||
baseBrush = new LinearGradientBrush(baseRect, Colors[0], Colors[1], GradientMode);
|
|
||||||
else
|
|
||||||
baseBrush = new LinearGradientBrush(baseRect, Colors[0], Colors[0], GradientMode);
|
|
||||||
|
|
||||||
g.FillRectangle(baseBrush, baseRect);
|
g.FillRectangle(brush, baseRect);
|
||||||
if (!Rotate)
|
if (!Rotate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_rotationProgress = _rotationProgress + LoopSpeed;
|
_rotationProgress = _rotationProgress + LoopSpeed;
|
||||||
if (_rotationProgress > Width)
|
if (ContainedBrush && _rotationProgress > Width)
|
||||||
|
_rotationProgress = LoopSpeed;
|
||||||
|
else if (!ContainedBrush && _rotationProgress > _keyboard.Width*Scale)
|
||||||
_rotationProgress = LoopSpeed;
|
_rotationProgress = LoopSpeed;
|
||||||
}
|
|
||||||
|
|
||||||
private LinearGradientBrush CreateContainedBrush()
|
|
||||||
{
|
|
||||||
//throw new NotImplementedException();
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private LinearGradientBrush CreateBrush()
|
private LinearGradientBrush CreateBrush()
|
||||||
{
|
{
|
||||||
var colorBlend = CreateColorBlend();
|
var colorBlend = CreateColorBlend();
|
||||||
var rect = new Rectangle(0, 0, 21, 8);
|
var rect = ContainedBrush
|
||||||
|
? new Rectangle((int) _rotationProgress, Y, Width, Height)
|
||||||
|
: new Rectangle((int) _rotationProgress, 0, _keyboard.Width*Scale, _keyboard.Height*Scale);
|
||||||
|
|
||||||
if (Colors.Count > 5)
|
if (Colors.Count > 5)
|
||||||
return new LinearGradientBrush(rect, Colors[0], Colors[1], GradientMode)
|
return new LinearGradientBrush(rect, Colors[0], Colors[1], GradientMode)
|
||||||
|
|||||||
56
Artemis/Artemis/ViewModels/FlyoutBaseViewModel.cs
Normal file
56
Artemis/Artemis/ViewModels/FlyoutBaseViewModel.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
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;
|
||||||
|
NotifyOfPropertyChange(() => IsOpen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position Position
|
||||||
|
{
|
||||||
|
get { return position; }
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == position)
|
||||||
|
return;
|
||||||
|
|
||||||
|
position = value;
|
||||||
|
NotifyOfPropertyChange(() => Position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
using MahApps.Metro.Controls;
|
||||||
|
|
||||||
|
namespace Artemis.ViewModels.Flyouts
|
||||||
|
{
|
||||||
|
public class FlyoutSettingsViewModel : FlyoutBaseViewModel
|
||||||
|
{
|
||||||
|
public FlyoutSettingsViewModel()
|
||||||
|
{
|
||||||
|
Header = "settings";
|
||||||
|
Position = Position.Right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,53 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Windows;
|
|
||||||
using Artemis.Models;
|
|
||||||
using Caliburn.Micro;
|
|
||||||
|
|
||||||
namespace Artemis.ViewModels
|
|
||||||
{
|
|
||||||
internal sealed class ShellViewModel : Conductor<IScreen>.Collection.OneActive
|
|
||||||
{
|
|
||||||
public ShellViewModel()
|
|
||||||
{
|
|
||||||
IEventAggregator events = new EventAggregator();
|
|
||||||
MainModel = new MainModel(events);
|
|
||||||
|
|
||||||
DisplayName = "Artemis";
|
|
||||||
|
|
||||||
ActivateItem(new EffectsViewModel(MainModel) {DisplayName = "Effects"});
|
|
||||||
ActivateItem(new GamesViewModel(MainModel) {DisplayName = "Games"});
|
|
||||||
ActivateItem(new OverlaysViewModel(MainModel) {DisplayName = "Overlays"});
|
|
||||||
|
|
||||||
// By now Effects are added to the MainModel so we can savely start one
|
|
||||||
ToggleEffects();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool EffectsEnabled
|
|
||||||
{
|
|
||||||
get { return MainModel.Enabled; }
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
MainModel.Enabled = value;
|
|
||||||
NotifyOfPropertyChange(() => EffectsEnabled);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MainModel MainModel { get; set; }
|
|
||||||
|
|
||||||
public void ToggleEffects()
|
|
||||||
{
|
|
||||||
if (EffectsEnabled)
|
|
||||||
MainModel.ShutdownEffects();
|
|
||||||
else
|
|
||||||
MainModel.StartEffects();
|
|
||||||
|
|
||||||
EffectsEnabled = !EffectsEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnClose(EventArgs e)
|
|
||||||
{
|
|
||||||
MainModel.ShutdownEffects();
|
|
||||||
Application.Current.Shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,12 +1,59 @@
|
|||||||
using Caliburn.Micro;
|
using System;
|
||||||
|
using System.Windows;
|
||||||
|
using Artemis.Models;
|
||||||
|
using Caliburn.Micro;
|
||||||
|
using MessageBox = System.Windows.Forms.MessageBox;
|
||||||
|
|
||||||
namespace Artemis.ViewModels
|
namespace Artemis.ViewModels
|
||||||
{
|
{
|
||||||
internal sealed class SettingsViewModel : Conductor<IScreen>.Collection.OneActive
|
internal sealed class ShellViewModel : Conductor<IScreen>.Collection.OneActive
|
||||||
{
|
{
|
||||||
public SettingsViewModel()
|
public ShellViewModel()
|
||||||
{
|
{
|
||||||
DisplayName = "Artemis - Settings";
|
IEventAggregator events = new EventAggregator();
|
||||||
|
MainModel = new MainModel(events);
|
||||||
|
|
||||||
|
DisplayName = "Artemis";
|
||||||
|
|
||||||
|
ActivateItem(new EffectsViewModel(MainModel) {DisplayName = "Effects"});
|
||||||
|
ActivateItem(new GamesViewModel(MainModel) {DisplayName = "Games"});
|
||||||
|
ActivateItem(new OverlaysViewModel(MainModel) {DisplayName = "Overlays"});
|
||||||
|
|
||||||
|
// By now Effects are added to the MainModel so we can savely start one
|
||||||
|
ToggleEffects();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool EffectsEnabled
|
||||||
|
{
|
||||||
|
get { return MainModel.Enabled; }
|
||||||
|
private set
|
||||||
|
{
|
||||||
|
MainModel.Enabled = value;
|
||||||
|
NotifyOfPropertyChange(() => EffectsEnabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public MainModel MainModel { get; set; }
|
||||||
|
|
||||||
|
public void ToggleEffects()
|
||||||
|
{
|
||||||
|
if (EffectsEnabled)
|
||||||
|
MainModel.ShutdownEffects();
|
||||||
|
else
|
||||||
|
MainModel.StartEffects();
|
||||||
|
|
||||||
|
EffectsEnabled = !EffectsEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnClose(EventArgs e)
|
||||||
|
{
|
||||||
|
MainModel.ShutdownEffects();
|
||||||
|
Application.Current.Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ToggleSettings()
|
||||||
|
{
|
||||||
|
MessageBox.Show("Test");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
43
Artemis/Artemis/Views/Flyouts/FlyoutSettingsView.xaml
Normal file
43
Artemis/Artemis/Views/Flyouts/FlyoutSettingsView.xaml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<UserControl x:Class="Artemis.Views.Flyouts.FlyoutSettingsView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:Artemis.Views.Flyouts"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="300" d:DesignWidth="300">
|
||||||
|
<UserControl.Resources>
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<Label Grid.Row="0"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="5"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Content="Download language:" />
|
||||||
|
<ComboBox x:Name="flyoutSettingsComboboxDownloadlanguage"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="1"
|
||||||
|
Margin="0,5,5,5"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
|
||||||
|
<Button x:Name="flyoutSettingsButtonSave"
|
||||||
|
Grid.Row="1"
|
||||||
|
Grid.Column="1"
|
||||||
|
Width="75"
|
||||||
|
Margin="5"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Content="Save" />
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@ -1,13 +0,0 @@
|
|||||||
<controls:MetroWindow x:Class="Artemis.Views.SettingsView"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:local="clr-namespace:Artemis.Views"
|
|
||||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
Title="SettingsView" Height="300" Width="300">
|
|
||||||
<Grid>
|
|
||||||
|
|
||||||
</Grid>
|
|
||||||
</controls:MetroWindow>
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
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;
|
|
||||||
|
|
||||||
namespace Artemis.Views
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for SettingsView.xaml
|
|
||||||
/// </summary>
|
|
||||||
public partial class SettingsView : Window
|
|
||||||
{
|
|
||||||
public SettingsView()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -16,15 +16,19 @@
|
|||||||
GlowBrush="{DynamicResource AccentColorBrush}">
|
GlowBrush="{DynamicResource AccentColorBrush}">
|
||||||
<Controls:MetroWindow.RightWindowCommands>
|
<Controls:MetroWindow.RightWindowCommands>
|
||||||
<Controls:WindowCommands>
|
<Controls:WindowCommands>
|
||||||
<Button Content="settings" />
|
<Button x:Name="Settings">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<ToggleButton x:Name="EffectsEnabled" Width="25" Height="25"
|
<Rectangle Width="10" Height="10"
|
||||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
Fill="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}">
|
||||||
ToolTip="Toggle all effects"
|
<Rectangle.OpacityMask>
|
||||||
cal:Message.Attach="[Event Click] = [Action ToggleEffects]"
|
<VisualBrush Stretch="Fill" Visual="{StaticResource appbar_settings}" />
|
||||||
IsChecked="{Binding Path=EffectsEnabled, Mode=OneWay}" />
|
</Rectangle.OpacityMask>
|
||||||
<TextBlock VerticalAlignment="Center" Text="master switch" />
|
</Rectangle>
|
||||||
</StackPanel>
|
<TextBlock Margin="4 -3 0 0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Text="settings" />
|
||||||
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
</Controls:WindowCommands>
|
</Controls:WindowCommands>
|
||||||
</Controls:MetroWindow.RightWindowCommands>
|
</Controls:MetroWindow.RightWindowCommands>
|
||||||
<Grid>
|
<Grid>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user