1
0
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:
SpoinkyNL 2016-01-28 21:42:05 +01:00
parent 8f9696a80a
commit 06b7f5413b
31 changed files with 296 additions and 229 deletions

View File

@ -272,6 +272,8 @@
<Compile Include="Modules\Effects\Debug\DebugEffectViewModel.cs" />
<Compile Include="Modules\Effects\TypeHole\TypeHoleViewModel.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="Modules\Games\CounterStrike\CounterStrikeViewModel.cs" />
<Compile Include="Modules\Games\Dota2\Dota2ViewModel.cs" />
@ -279,7 +281,6 @@
<Compile Include="Modules\Games\Witcher3\Witcher3ViewModel.cs" />
<Compile Include="ViewModels\OverlaysViewModel.cs" />
<Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplayViewModel.cs" />
<Compile Include="ViewModels\SettingsViewModel.cs" />
<Compile Include="ViewModels\ShellViewModel.cs" />
<Compile Include="Views\EffectsView.xaml.cs">
<DependentUpon>EffectsView.xaml</DependentUpon>
@ -296,6 +297,9 @@
<Compile Include="Modules\Effects\TypeWave\TypeWaveView.xaml.cs">
<DependentUpon>TypeWaveView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Flyouts\FlyoutSettingsView.xaml.cs">
<DependentUpon>FlyoutSettingsView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\GamesView.xaml.cs">
<DependentUpon>GamesView.xaml</DependentUpon>
</Compile>
@ -317,9 +321,6 @@
<Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplayView.xaml.cs">
<DependentUpon>VolumeDisplayView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SettingsView.xaml.cs">
<DependentUpon>SettingsView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ShellView.xaml.cs">
<DependentUpon>ShellView.xaml</DependentUpon>
</Compile>
@ -402,6 +403,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Flyouts\FlyoutSettingsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\GamesView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -430,10 +435,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\SettingsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\ShellView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -11,5 +11,17 @@ namespace Artemis.KeyboardProviders
public abstract void Enable();
public abstract void Disable();
public abstract void DrawBitmap(Bitmap bitmap);
/// <summary>
/// Returns a bitmap matching the keyboard's dimensions
/// </summary>
/// <returns></returns>
public Bitmap KeyboardBitmap() => new Bitmap(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);
}
}

View File

@ -5,7 +5,14 @@ namespace Artemis.Models
{
public abstract class EffectModel : IDisposable
{
public MainModel MainModel;
public string Name;
protected EffectModel(MainModel mainModel)
{
MainModel = mainModel;
}
public abstract void Dispose();
// Called on creation

View File

@ -4,5 +4,9 @@
{
public bool Enabled;
public string ProcessName;
protected GameModel(MainModel mainModel) : base(mainModel)
{
}
}
}

View File

@ -7,6 +7,10 @@ namespace Artemis.Models
private bool _enabled;
public string ProcessName;
protected OverlayModel(MainModel mainModel) : base(mainModel)
{
}
public bool Enabled
{
get { return _enabled; }

View File

@ -20,7 +20,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
private bool _previousFromBottom;
private IWaveIn _waveIn;
public AudioVisualizerModel(AudioVisualizerSettings settings)
public AudioVisualizerModel(MainModel mainModel, AudioVisualizerSettings settings) : base(mainModel)
{
Settings = settings;
Name = "Audiovisualizer";
@ -28,7 +28,6 @@ namespace Artemis.Modules.Effects.AudioVisualizer
SpectrumData = new List<byte>();
SoundRectangles = new List<KeyboardRectangle>();
Scale = 4;
Lines = 21*Scale;
// Fill list with device IDs
// Would rather just store a MMDevice object, but seems NAudio won't let me.
@ -65,6 +64,8 @@ namespace Artemis.Modules.Effects.AudioVisualizer
public override void Enable()
{
Lines = MainModel.ActiveKeyboard.Width * Scale;
_sampleAggregator.FftCalculated += FftCalculated;
_sampleAggregator.PerformFFT = true;
@ -111,8 +112,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
height = (int) (Math.Round(SpectrumData[i]/2.55));
if (SoundRectangles.Count <= i)
SoundRectangles.Add(new KeyboardRectangle(Scale, 0, 0, 21, 6,
new List<Color>
SoundRectangles.Add(new KeyboardRectangle(MainModel.ActiveKeyboard, Scale, 0, 0, new List<Color>
{
ColorHelpers.MediaColorToDrawingColor(Settings.MainColor),
ColorHelpers.MediaColorToDrawingColor(Settings.SecondaryColor)
@ -129,7 +129,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
SoundRectangles[i].Width = (int) Math.Ceiling((double) Lines/Settings.Bars);
if (Settings.FromBottom)
SoundRectangles[i].Y = (Scale*8) - SoundRectangles[i].Height;
SoundRectangles[i].Y = (Scale*MainModel.ActiveKeyboard.Height) - SoundRectangles[i].Height;
}
_generating = false;
}
@ -145,7 +145,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
return null;
}
var bitmap = new Bitmap(21*Scale, 6*Scale);
var bitmap = MainModel.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap))
{
foreach (var soundRectangle in SoundRectangles)

View File

@ -18,7 +18,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
AudioVisualizerSettings = new AudioVisualizerSettings();
// Create effect model and add it to MainModel
AudioVisualizerModel = new AudioVisualizerModel(AudioVisualizerSettings);
AudioVisualizerModel = new AudioVisualizerModel(mainModel, AudioVisualizerSettings);
MainModel.EffectModels.Add(AudioVisualizerModel);
}

View File

@ -8,23 +8,11 @@ namespace Artemis.Modules.Effects.Debug
{
internal class DebugEffectModel : EffectModel
{
public DebugEffectModel(DebugEffectSettings settings)
public DebugEffectModel(MainModel mainModel, DebugEffectSettings settings) : base(mainModel)
{
Name = "Debug Effect";
Settings = settings;
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; }
@ -39,6 +27,16 @@ namespace Artemis.Modules.Effects.Debug
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()

View File

@ -26,7 +26,7 @@ namespace Artemis.Modules.Effects.Debug
DebugEffectSettings = new DebugEffectSettings();
// Create effect model and add it to MainModel
DebugEffectModel = new DebugEffectModel(DebugEffectSettings);
DebugEffectModel = new DebugEffectModel(mainModel, DebugEffectSettings);
MainModel.EffectModels.Add(DebugEffectModel);
}

View File

@ -5,7 +5,7 @@ namespace Artemis.Modules.Effects.TypeHole
{
public class TypeHoleModel : EffectModel
{
public TypeHoleModel()
public TypeHoleModel(MainModel mainModel) : base(mainModel)
{
Name = "TypeHole";
}

View File

@ -13,7 +13,7 @@ namespace Artemis.Modules.Effects.TypeHole
MainModel.Events.Subscribe(this);
// Create effect model and add it to MainModel
TypeHoleModel = new TypeHoleModel();
TypeHoleModel = new TypeHoleModel(mainModel);
MainModel.EffectModels.Add(TypeHoleModel);
}

View File

@ -13,7 +13,7 @@ namespace Artemis.Modules.Effects.TypeWave
{
public class TypeWaveModel : EffectModel
{
public TypeWaveModel(TypeWaveSettings settings)
public TypeWaveModel(MainModel mainModel, TypeWaveSettings settings) : base(mainModel)
{
Name = "TypeWave";
Waves = new List<Wave>();

View File

@ -18,7 +18,7 @@ namespace Artemis.Modules.Effects.TypeWave
TypeWaveSettings = new TypeWaveSettings();
// Create effect model and add it to MainModel
TypeWaveModel = new TypeWaveModel(TypeWaveSettings);
TypeWaveModel = new TypeWaveModel(mainModel, TypeWaveSettings);
MainModel.EffectModels.Add(TypeWaveModel);
}

View File

@ -15,25 +15,13 @@ namespace Artemis.Modules.Games.CounterStrike
public class CounterStrikeModel : GameModel
{
private readonly CounterStrikeSettings _counterStrikeSettings;
private readonly MainModel _mainModel;
public CounterStrikeModel(CounterStrikeSettings counterStrikeSettings, MainModel mainModel)
public CounterStrikeModel(MainModel mainModel, CounterStrikeSettings counterStrikeSettings) : base(mainModel)
{
_counterStrikeSettings = counterStrikeSettings;
_mainModel = mainModel;
Name = "CounterStrike";
ProcessName = "csgo";
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; }
@ -48,12 +36,16 @@ namespace Artemis.Modules.Games.CounterStrike
public override void Dispose()
{
_mainModel.GameStateWebServer.GameDataReceived -= HandleGameData;
MainModel.GameStateWebServer.GameDataReceived -= HandleGameData;
}
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()

View File

@ -18,7 +18,7 @@ namespace Artemis.Modules.Games.CounterStrike
CounterStrikeSettings = new CounterStrikeSettings();
// Create effect model and add it to MainModel
CounterStrikeModel = new CounterStrikeModel(CounterStrikeSettings, MainModel);
CounterStrikeModel = new CounterStrikeModel(mainModel, CounterStrikeSettings);
MainModel.EffectModels.Add(CounterStrikeModel);
PlaceConfigFile();
}

View File

@ -16,29 +16,22 @@ namespace Artemis.Modules.Games.RocketLeague
{
public class RocketLeagueModel : GameModel
{
private readonly KeyboardRectangle _boostRect;
private readonly RocketLeagueSettings _settings;
private KeyboardRectangle _boostRect;
private int _boostAmount;
private bool _boostGrowing;
private Memory _memory;
private GamePointersCollectionModel _pointer;
private int _previousBoost;
public RocketLeagueModel(RocketLeagueSettings settings)
public RocketLeagueModel(MainModel mainModel, RocketLeagueSettings settings) : base(mainModel)
{
Name = "RocketLeague";
ProcessName = "RocketLeague";
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;
_settings = settings;
}
public int Scale { get; set; }
@ -50,6 +43,12 @@ namespace Artemis.Modules.Games.RocketLeague
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();
_pointer = JsonConvert
.DeserializeObject<GamePointersCollectionModel>(Offsets.Default.RocketLeague);

View File

@ -15,7 +15,7 @@ namespace Artemis.Modules.Games.RocketLeague
RocketLeagueSettings = new RocketLeagueSettings();
// Create effect model and add it to MainModel
RocketLeagueModel = new RocketLeagueModel(RocketLeagueSettings);
RocketLeagueModel = new RocketLeagueModel(mainModel, RocketLeagueSettings);
MainModel.EffectModels.Add(RocketLeagueModel);
}

View File

@ -15,24 +15,17 @@ namespace Artemis.Modules.Games.Witcher3
{
public class Witcher3Model : GameModel
{
private readonly KeyboardRectangle _signRect;
private KeyboardRectangle _signRect;
private IntPtr _baseAddress;
private GamePointersCollectionModel _pointer;
private RemoteProcess _process;
public Witcher3Model(RocketLeagueSettings settings)
public Witcher3Model(MainModel mainModel, RocketLeagueSettings settings) : base(mainModel)
{
Name = "Witcher3";
ProcessName = "witcher3";
Scale = 4;
_signRect = new KeyboardRectangle(Scale, 0, 0, 84, 24, new List<Color>(), LinearGradientMode.Horizontal)
{
Rotate = true,
LoopSpeed = 0.5
};
Enabled = settings.Enabled;
}
@ -45,6 +38,11 @@ namespace Artemis.Modules.Games.Witcher3
public override void Enable()
{
_signRect = new KeyboardRectangle(MainModel.ActiveKeyboard, Scale, 0, 0, new List<Color>(), LinearGradientMode.Horizontal)
{
Rotate = true,
LoopSpeed = 0.5
};
MemoryHelpers.GetPointers();
_pointer = JsonConvert
.DeserializeObject<GamePointersCollectionModel>(Offsets.Default.Witcher3);
@ -123,7 +121,7 @@ namespace Artemis.Modules.Games.Witcher3
public override Bitmap GenerateBitmap()
{
var bitmap = new Bitmap(21, 6);
var bitmap = MainModel.ActiveKeyboard.KeyboardBitmap();
using (var g = Graphics.FromImage(bitmap))
{
g.Clear(Color.Transparent);

View File

@ -16,7 +16,7 @@ namespace Artemis.Modules.Games.Witcher3
RocketLeagueSettings = new RocketLeagueSettings();
// Create effect model and add it to MainModel
Witcher3Model = new Witcher3Model(RocketLeagueSettings);
Witcher3Model = new Witcher3Model(mainModel, RocketLeagueSettings);
MainModel.EffectModels.Add(Witcher3Model);
}

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using Artemis.Models;
using Artemis.Utilities;
using Artemis.Utilities.Keyboard;
@ -9,13 +10,16 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
{
public class VolumeDisplay
{
public VolumeDisplay(VolumeDisplaySettings settings)
public VolumeDisplay(MainModel mainModel, VolumeDisplaySettings settings)
{
MainModel = mainModel;
Settings = settings;
Transparancy = 255;
Scale = 4;
}
public MainModel MainModel { get; set; }
public VolumeDisplaySettings Settings { get; set; }
public int Scale { get; set; }
@ -27,7 +31,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
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>
{
ColorHelpers.MediaColorToDrawingColor(Settings.MainColor),

View File

@ -12,7 +12,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
{
private bool _enabled;
public VolumeDisplayModel(VolumeDisplaySettings settings)
public VolumeDisplayModel(MainModel mainModel, VolumeDisplaySettings settings) : base(mainModel)
{
Settings = settings;
Name = "VolumeDisplay";
@ -22,7 +22,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
Enabled = Settings.Enabled;
VolumeDisplay = new VolumeDisplay(settings);
VolumeDisplay = new VolumeDisplay(mainModel, settings);
}
public VolumeDisplay VolumeDisplay { get; set; }

View File

@ -15,7 +15,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
VolumeDisplaySettings = new VolumeDisplaySettings();
// Create effect model and add it to MainModel
VolumeDisplayModel = new VolumeDisplayModel(VolumeDisplaySettings);
VolumeDisplayModel = new VolumeDisplayModel(mainModel, VolumeDisplaySettings);
MainModel.EffectModels.Add(VolumeDisplayModel);
}

View File

@ -5,34 +5,37 @@ using System.Drawing.Drawing2D;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Artemis.KeyboardProviders;
namespace Artemis.Utilities.Keyboard
{
public class KeyboardRectangle
{
private readonly BackgroundWorker _blinkWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
private readonly KeyboardProvider _keyboard;
private int _blinkDelay;
private List<Color> _colors;
private double _rotationProgress;
/// <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>
/// <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="x"></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="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)
{
_keyboard = keyboard;
Scale = scale;
X = x;
Y = y;
Width = width;
Height = height;
Width = keyboard.Width*Scale;
Height = keyboard.Height*Scale;
Colors = colors;
GradientMode = gradientMode;
@ -40,7 +43,7 @@ namespace Artemis.Utilities.Keyboard
Rotate = false;
LoopSpeed = 1;
Visible = true;
ContainedBrush = true;
ContainedBrush = false;
_rotationProgress = 0;
_blinkWorker.DoWork += BlinkWorker_DoWork;
@ -53,6 +56,10 @@ namespace Artemis.Utilities.Keyboard
public int Y { get; set; }
public int Width { 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
{
@ -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)
{
_blinkDelay = delay;
@ -118,43 +113,26 @@ namespace Artemis.Utilities.Keyboard
if (!Visible || Height < 1 || Width < 1 || !Colors.Any())
return;
var brush = ContainedBrush
? CreateContainedBrush()
: CreateBrush();
var colorBlend = CreateColorBlend();
var brush = CreateBrush();
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)
return;
_rotationProgress = _rotationProgress + LoopSpeed;
if (_rotationProgress > Width)
if (ContainedBrush && _rotationProgress > Width)
_rotationProgress = LoopSpeed;
else if (!ContainedBrush && _rotationProgress > _keyboard.Width*Scale)
_rotationProgress = LoopSpeed;
}
private LinearGradientBrush CreateContainedBrush()
{
//throw new NotImplementedException();
return null;
}
private LinearGradientBrush CreateBrush()
{
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)
return new LinearGradientBrush(rect, Colors[0], Colors[1], GradientMode)

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

View File

@ -0,0 +1,13 @@
using MahApps.Metro.Controls;
namespace Artemis.ViewModels.Flyouts
{
public class FlyoutSettingsViewModel : FlyoutBaseViewModel
{
public FlyoutSettingsViewModel()
{
Header = "settings";
Position = Position.Right;
}
}
}

View File

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

View File

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

View 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>

View File

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

View File

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

View File

@ -16,15 +16,19 @@
GlowBrush="{DynamicResource AccentColorBrush}">
<Controls:MetroWindow.RightWindowCommands>
<Controls:WindowCommands>
<Button Content="settings" />
<StackPanel Orientation="Horizontal">
<ToggleButton x:Name="EffectsEnabled" Width="25" Height="25"
Style="{DynamicResource MetroCircleToggleButtonStyle}"
ToolTip="Toggle all effects"
cal:Message.Attach="[Event Click] = [Action ToggleEffects]"
IsChecked="{Binding Path=EffectsEnabled, Mode=OneWay}" />
<TextBlock VerticalAlignment="Center" Text="master switch" />
</StackPanel>
<Button x:Name="Settings">
<StackPanel Orientation="Horizontal">
<Rectangle Width="10" Height="10"
Fill="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}">
<Rectangle.OpacityMask>
<VisualBrush Stretch="Fill" Visual="{StaticResource appbar_settings}" />
</Rectangle.OpacityMask>
</Rectangle>
<TextBlock Margin="4 -3 0 0"
VerticalAlignment="Center"
Text="settings" />
</StackPanel>
</Button>
</Controls:WindowCommands>
</Controls:MetroWindow.RightWindowCommands>
<Grid>