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

Replaced debug effect with profile for Windows

This commit is contained in:
SpoinkyNL 2016-06-07 01:25:31 +02:00
parent afb8c60851
commit 6436942e47
22 changed files with 231 additions and 337 deletions

View File

@ -335,7 +335,12 @@
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerModel.cs" />
<Compile Include="Modules\Effects\AudioVisualizer\Utilities\FftEventArgs.cs" />
<Compile Include="Modules\Effects\AudioVisualizer\Utilities\SampleAggregator.cs" />
<Compile Include="Modules\Effects\Debug\DebugEffectModel.cs" />
<Compile Include="Modules\Effects\WindowsProfile\WindowsProfileView.xaml.cs">
<DependentUpon>WindowsProfileView.xaml</DependentUpon>
</Compile>
<Compile Include="Modules\Effects\WindowsProfile\WindowsProfileViewModel.cs" />
<Compile Include="Modules\Effects\WindowsProfile\WindowsProfileDataModel.cs" />
<Compile Include="Modules\Effects\WindowsProfile\WindowsProfileModel.cs" />
<Compile Include="Modules\Effects\ProfilePreview\ProfilePreviewModel.cs" />
<Compile Include="Modules\Effects\TypeWave\TypeWave.Designer.cs">
<DependentUpon>TypeWave.settings</DependentUpon>
@ -408,7 +413,6 @@
</Compile>
<Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplayModel.cs" />
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerSettings.cs" />
<Compile Include="Modules\Effects\Debug\DebugEffectSettings.cs" />
<Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplaySettings.cs" />
<Compile Include="Modules\Games\RocketLeague\RocketLeagueSettings.cs" />
<Compile Include="Modules\Effects\TypeWave\TypeWaveSettings.cs" />
@ -468,7 +472,6 @@
<Compile Include="ViewModels\Abstract\GameViewModel.cs" />
<Compile Include="ViewModels\EffectsViewModel.cs" />
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerViewModel.cs" />
<Compile Include="Modules\Effects\Debug\DebugEffectViewModel.cs" />
<Compile Include="Modules\Effects\TypeWave\TypeWaveViewModel.cs" />
<Compile Include="ViewModels\FlyoutBaseViewModel.cs" />
<Compile Include="ViewModels\Flyouts\FlyoutSettingsViewModel.cs" />
@ -498,9 +501,6 @@
<Compile Include="Views\Flyouts\FlyoutSettingsView.xaml.cs">
<DependentUpon>FlyoutSettingsView.xaml</DependentUpon>
</Compile>
<Compile Include="Modules\Effects\Debug\DebugEffectView.xaml.cs">
<DependentUpon>DebugEffectView.xaml</DependentUpon>
</Compile>
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerView.xaml.cs">
<DependentUpon>AudioVisualizerView.xaml</DependentUpon>
</Compile>
@ -658,6 +658,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Modules\Effects\WindowsProfile\WindowsProfileView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Modules\Games\Overwatch\OverwatchView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -686,10 +690,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Modules\Effects\Debug\DebugEffectView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Modules\Effects\AudioVisualizer\AudioVisualizerView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -31,7 +31,7 @@ namespace Artemis.DAL
/// <param name="game">The game to match</param>
/// <param name="keyboard">The keyboard to match</param>
/// <returns>All profiles matching the provided game</returns>
public static List<ProfileModel> GetAll(GameModel game, KeyboardProvider keyboard)
public static List<ProfileModel> GetAll(EffectModel game, KeyboardProvider keyboard)
{
if (game == null)
throw new ArgumentNullException(nameof(game));

View File

@ -58,7 +58,8 @@ namespace Artemis.DeviceProviders.Corsair
ledIndex++;
}
CueSDK.HeadsetSDK.Update();
// Flush is required for headset to work reliably on CUE2 for some reason
CueSDK.HeadsetSDK.Update(true);
}
private static bool CanInitializeSdk()

View File

@ -8,6 +8,6 @@ namespace Artemis.InjectionFactories
public interface IProfileEditorVmFactory
{
ProfileEditorViewModel CreateProfileEditorVm(IEventAggregator events, MainManager mainManager,
GameModel gameModel, string lastProfile);
EffectModel gameModel, string lastProfile);
}
}

View File

@ -3,8 +3,8 @@ using Artemis.DeviceProviders.Corsair;
using Artemis.DeviceProviders.Logitech;
using Artemis.DeviceProviders.Razer;
using Artemis.Modules.Effects.AudioVisualizer;
using Artemis.Modules.Effects.Debug;
using Artemis.Modules.Effects.TypeWave;
using Artemis.Modules.Effects.WindowsProfile;
using Artemis.Modules.Games.CounterStrike;
using Artemis.Modules.Games.Dota2;
using Artemis.Modules.Games.Overwatch;
@ -25,8 +25,8 @@ namespace Artemis.InjectionModules
// Effects
Bind<EffectViewModel>().To<AudioVisualizerViewModel>().InSingletonScope();
Bind<EffectViewModel>().To<DebugEffectViewModel>().InSingletonScope();
Bind<EffectViewModel>().To<TypeWaveViewModel>().InSingletonScope();
Bind<EffectViewModel>().To<WindowsProfileViewModel>().InSingletonScope();
//Bind<EffectViewModel>().To<AmbientLightningEffectViewModel>().InSingletonScope();
// Games

View File

@ -82,6 +82,7 @@ namespace Artemis.Managers
_processTimer.Stop();
_processTimer.Dispose();
LoopManager.Stop();
EffectManager.ActiveEffect.Dispose();
GameStateWebServer.Stop();
PipeServer.Stop();
}

View File

@ -51,6 +51,8 @@ namespace Artemis.Modules.Effects.AudioVisualizer
_sampleAggregator.PerformFFT = false;
_sampleAggregator.FftCalculated -= FftCalculated;
if (_waveIn == null)
return;
_waveIn.StopRecording();
_waveIn.DataAvailable -= OnDataAvailable;
_waveIn = null;

View File

@ -11,9 +11,10 @@ namespace Artemis.Modules.Effects.AudioVisualizer
: base(main, new AudioVisualizerModel(main, new AudioVisualizerSettings()))
{
DisplayName = "Audio Visualization";
events.Subscribe(this);
MainManager.EffectManager.EffectModels.Add(EffectModel);
EffectSettings = ((AudioVisualizerModel)EffectModel).Settings;
}
public void Handle(ActiveEffectChanged message)

View File

@ -1,75 +0,0 @@
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Models.Profiles;
using Artemis.Utilities.Keyboard;
using Brush = System.Windows.Media.Brush;
namespace Artemis.Modules.Effects.Debug
{
// TODO: Remove
internal class DebugEffectModel : EffectModel
{
public DebugEffectModel(MainManager mainManager, DebugEffectSettings settings) : base(mainManager, null)
{
Name = "Debug Effect";
Settings = settings;
Scale = 4;
Initialized = false;
}
public int Scale { get; set; }
public DebugEffectSettings Settings { get; set; }
public KeyboardRectangle KeyboardRectangle { get; set; }
public override void Dispose()
{
Initialized = false;
}
public override void Enable()
{
Initialized = false;
KeyboardRectangle = new KeyboardRectangle(MainManager.DeviceManager.ActiveKeyboard, 0, 0, new List<Color>
{
Color.FromArgb(0, 226, 190),
Color.FromArgb(0, 208, 255)
}, LinearGradientMode.Horizontal);
Initialized = true;
}
public override void Update()
{
KeyboardRectangle.Height = Settings.Height;
KeyboardRectangle.Width = Settings.Width;
KeyboardRectangle.GradientMode = Settings.Type;
KeyboardRectangle.Rotate = Settings.Rotate;
KeyboardRectangle.Scale = Settings.Scale;
Scale = Settings.Scale;
}
public override List<LayerModel> GetRenderLayers(bool renderMice, bool renderHeadsets)
{
return null;
}
public override void Render(out Bitmap keyboard, out Brush mouse, out Brush headset, bool renderMice, bool renderHeadsets)
{
mouse = null;
headset = null;
keyboard = MainManager.DeviceManager.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(keyboard))
{
g.Clear(Color.Transparent);
KeyboardRectangle.Draw(g);
}
}
}
}

View File

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

View File

@ -1,116 +0,0 @@
<UserControl x:Class="Artemis.Modules.Effects.Debug.DebugEffectView"
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:cal="http://www.caliburnproject.org"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d"
d:DesignHeight="476.986" d:DesignWidth="538.772">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<Grid Margin="15, 5, 15, 5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="0,0,1,0">
<Label FontSize="20" MaxWidth="500" HorizontalAlignment="Left">
<Label.Content>
<AccessText TextWrapping="Wrap"
Text="A few debugging options, also lets you see what is being sent to the keyboard" />
</Label.Content>
</Label>
<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"
Style="{DynamicResource MetroCircleToggleButtonStyle}"
cal:Message.Attach="[Event Click] = [Action ToggleEffect]"
ToolTip="Note: You can't enable an effect when Artemis is disabled"
ToolTipService.ShowOnDisabled="True" />
</StackPanel>
</StackPanel>
<!-- Direction -->
<TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
Height="16" Margin="0,8">
Color gradient direction
</TextBlock>
<ComboBox Grid.Row="1" Grid.Column="1" Width="110" HorizontalAlignment="Right" VerticalAlignment="Center"
x:Name="RectangleTypes" />
<!-- Width -->
<TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
Height="16" Margin="0,8">
Debug-rectangle width
</TextBlock>
<Slider x:Name="Width" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1"
Value="{Binding Path=EffectSettings.Width, Mode=TwoWay}" Minimum="0" Maximum="84"
SmallChange="1" IsSnapToTickEnabled="True" />
<!-- Height -->
<TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
Height="16" Margin="0,8">
Debug-rectangle height
</TextBlock>
<Slider x:Name="Height" Grid.Row="3" Grid.Column="1" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1"
Value="{Binding Path=EffectSettings.Height, Mode=TwoWay}" Minimum="0" Maximum="24"
SmallChange="1" IsSnapToTickEnabled="True" />
<!-- Scale -->
<TextBlock Grid.Row="4" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
Height="16" Margin="0,8">
Debug-rectangle scale (higher means more fluent)
</TextBlock>
<Slider x:Name="Scale" Grid.Row="4" Grid.Column="1" VerticalAlignment="Center"
HorizontalAlignment="Right" Width="110" TickPlacement="BottomRight" TickFrequency="1"
Value="{Binding Path=EffectSettings.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">
Rotate colors on debug-rectangle
</TextBlock>
<controls:ToggleSwitch IsChecked="{Binding Path=EffectSettings.Rotate, Mode=TwoWay}"
Grid.Row="5" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes"
OffLabel="No"
Margin="0,0,-5,0" Width="114" />
<!-- Preview panel -->
<StackPanel Grid.Row="6" Grid.Column="0" HorizontalAlignment="Left" Margin="0,25,0,0">
<TextBlock>
<InlineUIContainer>
<GroupBox Header="Preview" Margin="0" Height="70" Width="118">
<Image Source="{Binding ImageSource}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Stretch="Fill" />
</GroupBox>
</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"
Style="{DynamicResource SquareButtonStyle}" />
<Button x:Name="SaveSettings" Content="Save changes" VerticalAlignment="Top" Width="100"
Margin="10,0,0,0"
Style="{DynamicResource SquareButtonStyle}" />
</StackPanel>
</Grid>
</ScrollViewer>
</UserControl>

View File

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

View File

@ -1,63 +0,0 @@
using System;
using System.Drawing.Drawing2D;
using System.Windows.Media;
using Artemis.Events;
using Artemis.Managers;
using Artemis.Utilities;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro;
namespace Artemis.Modules.Effects.Debug
{
internal sealed class DebugEffectViewModel : EffectViewModel, IHandle<ChangeBitmap>, IHandle<ActiveEffectChanged>
{
private ImageSource _imageSource;
private string _selectedRectangleType;
public DebugEffectViewModel(MainManager main, IEventAggregator events)
: base(main, new DebugEffectModel(main, new DebugEffectSettings()))
{
DisplayName = "Debug Effect";
events.Subscribe(this);
MainManager.EffectManager.EffectModels.Add(EffectModel);
}
public BindableCollection<string> RectangleTypes
=> new BindableCollection<string>(Enum.GetNames(typeof(LinearGradientMode)));
public string SelectedRectangleType
{
get { return _selectedRectangleType; }
set
{
if (value == _selectedRectangleType) return;
_selectedRectangleType = value;
NotifyOfPropertyChange(() => SelectedRectangleType);
((DebugEffectSettings) EffectSettings).Type =
(LinearGradientMode) Enum.Parse(typeof(LinearGradientMode), value);
}
}
public ImageSource ImageSource
{
get { return _imageSource; }
set
{
_imageSource = value;
NotifyOfPropertyChange(() => ImageSource);
}
}
public void Handle(ActiveEffectChanged message)
{
NotifyOfPropertyChange(() => EffectEnabled);
}
public void Handle(ChangeBitmap message)
{
ImageSource = ImageUtilities.BitmapToBitmapImage(message.Bitmap);
}
}
}

View File

@ -11,9 +11,10 @@ namespace Artemis.Modules.Effects.TypeWave
: base(main, new TypeWaveModel(main, new TypeWaveSettings()))
{
DisplayName = "Type Waves";
events.Subscribe(this);
MainManager.EffectManager.EffectModels.Add(EffectModel);
EffectSettings = ((TypeWaveModel)EffectModel).Settings;
}
public void Handle(ActiveEffectChanged message)

View File

@ -0,0 +1,8 @@
using Artemis.Models.Interfaces;
namespace Artemis.Modules.Effects.WindowsProfile
{
public class WindowsProfileDataModel : IDataModel
{
}
}

View File

@ -0,0 +1,38 @@
using System.Collections.Generic;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Models.Profiles;
namespace Artemis.Modules.Effects.WindowsProfile
{
public class WindowsProfileModel : EffectModel
{
public WindowsProfileModel(MainManager mainManager, WindowsProfileSettings settings)
: base(mainManager, new WindowsProfileDataModel())
{
Name = "WindowsProfile";
Settings = settings;
}
public WindowsProfileSettings Settings { get; set; }
public override void Dispose()
{
Initialized = false;
}
public override void Enable()
{
Initialized = true;
}
public override void Update()
{
}
public override List<LayerModel> GetRenderLayers(bool renderMice, bool renderHeadsets)
{
return Profile.GetRenderLayers<WindowsProfileDataModel>(DataModel, renderMice, renderHeadsets, true);
}
}
}

View File

@ -0,0 +1,56 @@
<UserControl x:Class="Artemis.Modules.Effects.WindowsProfile.WindowsProfileView"
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:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:cal="http://www.caliburnproject.org"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d"
d:DesignHeight="476.986" d:DesignWidth="538.772">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<Grid Margin="15, 5, 15, 5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="0,0,1,0">
<Label FontSize="20" HorizontalAlignment="Left">
<Label.Content>
<AccessText TextWrapping="Wrap"
Text="Allows you to create layers shown while not gaming" />
</Label.Content>
</Label>
<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"
IsChecked="{Binding Path=GameSettings.Enabled, Mode=TwoWay}"
Style="{DynamicResource MetroCircleToggleButtonStyle}"
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
</StackPanel>
</StackPanel>
<!-- Profile editor -->
<ContentControl Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" x:Name="ProfileEditor" Margin="0,0,-30,0" />
<!-- Buttons -->
<StackPanel Grid.Column="0" Grid.Row="9" Orientation="Horizontal" VerticalAlignment="Bottom">
<Button x:Name="ResetSettings" Content="Reset effect" VerticalAlignment="Top" Width="100"
Style="{DynamicResource SquareButtonStyle}" />
<Button x:Name="SaveSettings" Content="Save changes" VerticalAlignment="Top" Width="100"
Margin="10,0,0,0"
Style="{DynamicResource SquareButtonStyle}" />
</StackPanel>
</Grid>
</ScrollViewer>
</UserControl>

View File

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

View File

@ -0,0 +1,76 @@
using System.ComponentModel;
using Artemis.InjectionFactories;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Modules.Effects.ProfilePreview;
using Artemis.ViewModels.Abstract;
using Artemis.ViewModels.Profiles;
using Caliburn.Micro;
namespace Artemis.Modules.Effects.WindowsProfile
{
// TODO: This effect is a hybrid between a regular effect and a game, may want to clean this up
public sealed class WindowsProfileViewModel : EffectViewModel
{
public WindowsProfileViewModel(MainManager main, IEventAggregator events, IProfileEditorVmFactory pFactory,
ProfilePreviewModel profilePreviewModel)
: base(main, new WindowsProfileModel(main, new WindowsProfileSettings()))
{
DisplayName = "Windows Profile";
PFactory = pFactory;
ProfilePreviewModel = profilePreviewModel;
EffectSettings = ((WindowsProfileModel) EffectModel).Settings;
ProfileEditor = PFactory.CreateProfileEditorVm(events, main, (WindowsProfileModel) EffectModel,
((WindowsProfileSettings) EffectSettings).LastProfile);
ProfilePreviewModel.Profile = ProfileEditor.SelectedProfile;
ProfileEditor.PropertyChanged += ProfileUpdater;
}
public ProfileEditorViewModel ProfileEditor { get; set; }
public IProfileEditorVmFactory PFactory { get; set; }
public ProfilePreviewModel ProfilePreviewModel { get; set; }
private void ProfileUpdater(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName != "SelectedProfile" && IsActive)
return;
EffectModel.Profile = ProfileEditor.SelectedProfile;
ProfilePreviewModel.Profile = ProfileEditor.SelectedProfile;
if (e.PropertyName != "SelectedProfile" || !ProfileEditor.ProfileViewModel.Activated ||
ProfileEditor.ProfileViewModel.SelectedProfile == null)
return;
((WindowsProfileSettings) EffectSettings).LastProfile = ProfileEditor.ProfileViewModel.SelectedProfile.Name;
EffectSettings.Save();
}
protected override void OnActivate()
{
base.OnActivate();
ProfileEditor.ProfileViewModel.Activate();
}
protected override void OnDeactivate(bool close)
{
base.OnDeactivate(close);
ProfileEditor.ProfileViewModel.Deactivate();
}
}
public class WindowsProfileSettings : GameSettings
{
public override void Load()
{
}
public override void Save()
{
}
public override void ToDefault()
{
}
}
}

View File

@ -1,20 +1,18 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Models.Profiles;
using Artemis.Utilities.GameState;
using Newtonsoft.Json;
using Ninject.Extensions.Logging;
using Brush = System.Windows.Media.Brush;
namespace Artemis.Modules.Games.CounterStrike
{
public class CounterStrikeModel : GameModel
{
public CounterStrikeModel(MainManager mainManager, CounterStrikeSettings settings) : base(mainManager, settings, new CounterStrikeDataModel())
public CounterStrikeModel(MainManager mainManager, CounterStrikeSettings settings)
: base(mainManager, settings, new CounterStrikeDataModel())
{
Name = "CounterStrike";
ProcessName = "csgo";
@ -64,12 +62,11 @@ namespace Artemis.Modules.Games.CounterStrike
Logger?.Error(ex, "Failed to deserialize CS:GO JSON");
throw;
}
}
public override List<LayerModel> GetRenderLayers(bool renderMice, bool renderHeadsets)
{
return Profile.GetRenderLayers<CounterStrikeDataModel>(DataModel, renderMice, renderHeadsets);
public override List<LayerModel> GetRenderLayers(bool renderMice, bool renderHeadsets)
{
return Profile.GetRenderLayers<CounterStrikeDataModel>(DataModel, renderMice, renderHeadsets);
}
}
}

View File

@ -31,7 +31,7 @@ namespace Artemis.Utilities.Layers
if (props.Animation == LayerAnimation.SlideRight)
{
s1 = new Rect(new Point(rect.X + props.AnimationProgress, rect.Y), new Size(rect.Width, rect.Height));
s2 = new Rect(new Point(s1.X - rect.Width, rect.Y), new Size(rect.Width + 0.05, rect.Height));
s2 = new Rect(new Point(s1.X - rect.Width, rect.Y), new Size(rect.Width + 1, rect.Height));
}
if (props.Animation == LayerAnimation.SlideLeft)
{
@ -99,7 +99,7 @@ namespace Artemis.Utilities.Layers
}
public static GifImage DrawGif(DrawingContext c, KeyboardPropertiesModel props, AppliedProperties applied,
GifImage gifImage, bool update = true)
GifImage gifImage)
{
if (string.IsNullOrEmpty(props.GifFile))
return null;
@ -117,8 +117,12 @@ namespace Artemis.Utilities.Layers
var gifRect = new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale,
applied.Height*scale);
var draw = update ? gifImage.GetNextFrame() : gifImage.GetFrame(0);
c.DrawImage(ImageUtilities.BitmapToBitmapImage(new Bitmap(draw)), gifRect);
lock (gifImage)
{
var draw = gifImage.GetNextFrame();
c.DrawImage(ImageUtilities.BitmapToBitmapImage(new Bitmap(draw)), gifRect);
}
return gifImage;
}

View File

@ -33,7 +33,7 @@ namespace Artemis.ViewModels.Profiles
{
public sealed class ProfileEditorViewModel : Screen, IHandle<ActiveKeyboardChanged>, IDropTarget
{
private readonly GameModel _gameModel;
private readonly EffectModel _gameModel;
private readonly ILayerEditorVmFactory _layerEditorVmFactory;
private readonly MainManager _mainManager;
private ImageSource _keyboardPreview;
@ -41,7 +41,7 @@ namespace Artemis.ViewModels.Profiles
private BindableCollection<ProfileModel> _profiles;
private ProfileModel _selectedProfile;
public ProfileEditorViewModel(IEventAggregator events, MainManager mainManager, GameModel gameModel,
public ProfileEditorViewModel(IEventAggregator events, MainManager mainManager, EffectModel gameModel,
ProfileViewModel profileViewModel, MetroDialogService dialogService, string lastProfile,
ILayerEditorVmFactory layerEditorVmFactory)
{