mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-01 18:23:32 +00:00
commit
a9fc996bc6
@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorBox", "ColorBox\ColorB
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LogiLed2Artemis", "LogiLed2Artemis\LogiLed2Artemis.vcxproj", "{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LogiLed2Artemis", "LogiLed2Artemis\LogiLed2Artemis.vcxproj", "{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis86Wrapper", "Artemis86Wrapper\Artemis86Wrapper.csproj", "{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
CD_ROM|Any CPU = CD_ROM|Any CPU
|
CD_ROM|Any CPU = CD_ROM|Any CPU
|
||||||
@ -146,6 +148,36 @@ Global
|
|||||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.SingleImage|x64.Build.0 = Release|x64
|
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.SingleImage|x64.Build.0 = Release|x64
|
||||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.SingleImage|x86.ActiveCfg = Release|Win32
|
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.SingleImage|x86.ActiveCfg = Release|Win32
|
||||||
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.SingleImage|x86.Build.0 = Release|Win32
|
{D2EDB8F3-F0CB-4670-B472-0B46D5800D2C}.SingleImage|x86.Build.0 = Release|Win32
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.CD_ROM|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.CD_ROM|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.CD_ROM|x64.Build.0 = Release|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.CD_ROM|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.CD_ROM|x86.Build.0 = Release|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.DVD-5|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.DVD-5|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.DVD-5|x64.Build.0 = Debug|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.DVD-5|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.DVD-5|x86.Build.0 = Debug|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.SingleImage|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.SingleImage|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.SingleImage|x64.Build.0 = Release|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.SingleImage|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.SingleImage|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@ -38,7 +38,7 @@ namespace Artemis
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ExceptionViewer GetArtemisExceptionViewer(Exception e)
|
public static ExceptionViewer GetArtemisExceptionViewer(Exception e)
|
||||||
{
|
{
|
||||||
var logger = LogManager.GetCurrentClassLogger();
|
var logger = LogManager.GetCurrentClassLogger();
|
||||||
logger.Fatal(e, "Unhandled exception, showing dialog and shutting down.");
|
logger.Fatal(e, "Unhandled exception, showing dialog and shutting down.");
|
||||||
|
|||||||
@ -127,6 +127,10 @@
|
|||||||
<TargetZone>LocalIntranet</TargetZone>
|
<TargetZone>LocalIntranet</TargetZone>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="Betwixt, Version=1.4.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Betwixt.1.4.1\lib\net35\Betwixt.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Caliburn.Micro, Version=3.0.1.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
|
<Reference Include="Caliburn.Micro, Version=3.0.1.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Caliburn.Micro.Core.3.0.1\lib\net45\Caliburn.Micro.dll</HintPath>
|
<HintPath>..\packages\Caliburn.Micro.Core.3.0.1\lib\net45\Caliburn.Micro.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
@ -318,10 +322,11 @@
|
|||||||
<Compile Include="DAL\ProfileProvider.cs" />
|
<Compile Include="DAL\ProfileProvider.cs" />
|
||||||
<Compile Include="DAL\SettingsProvider.cs" />
|
<Compile Include="DAL\SettingsProvider.cs" />
|
||||||
<Compile Include="DeviceProviders\CoolerMaster\MasterkeysProL.cs" />
|
<Compile Include="DeviceProviders\CoolerMaster\MasterkeysProL.cs" />
|
||||||
|
<Compile Include="DeviceProviders\CoolerMaster\MasterkeysProS.cs" />
|
||||||
<Compile Include="DeviceProviders\CoolerMaster\Utilities\CmSdk.cs" />
|
<Compile Include="DeviceProviders\CoolerMaster\Utilities\CmSdk.cs" />
|
||||||
<Compile Include="DeviceProviders\Corsair\CorsairMice.cs" />
|
<Compile Include="DeviceProviders\Corsair\CorsairMouse.cs" />
|
||||||
<Compile Include="DeviceProviders\Corsair\CorsairHeadsets.cs" />
|
<Compile Include="DeviceProviders\Corsair\CorsairHeadset.cs" />
|
||||||
<Compile Include="DeviceProviders\Corsair\CorsairMousemats.cs" />
|
<Compile Include="DeviceProviders\Corsair\CorsairMousemat.cs" />
|
||||||
<Compile Include="DeviceProviders\Corsair\Utilities\KeyMap.cs" />
|
<Compile Include="DeviceProviders\Corsair\Utilities\KeyMap.cs" />
|
||||||
<Compile Include="DeviceProviders\DeviceProvider.cs" />
|
<Compile Include="DeviceProviders\DeviceProvider.cs" />
|
||||||
<Compile Include="DeviceProviders\Logitech\G810.cs" />
|
<Compile Include="DeviceProviders\Logitech\G810.cs" />
|
||||||
@ -339,7 +344,7 @@
|
|||||||
<Compile Include="InjectionModules\EffectModules.cs" />
|
<Compile Include="InjectionModules\EffectModules.cs" />
|
||||||
<Compile Include="InjectionModules\ProfileModules.cs" />
|
<Compile Include="InjectionModules\ProfileModules.cs" />
|
||||||
<Compile Include="ItemBehaviours\BindableSelectedItemBehavior.cs" />
|
<Compile Include="ItemBehaviours\BindableSelectedItemBehavior.cs" />
|
||||||
<Compile Include="DeviceProviders\Corsair\CorsairKeyboards.cs" />
|
<Compile Include="DeviceProviders\Corsair\CorsairKeyboard.cs" />
|
||||||
<Compile Include="DeviceProviders\KeyboardProvider.cs" />
|
<Compile Include="DeviceProviders\KeyboardProvider.cs" />
|
||||||
<Compile Include="DeviceProviders\Logitech\G910.cs" />
|
<Compile Include="DeviceProviders\Logitech\G910.cs" />
|
||||||
<Compile Include="DeviceProviders\Logitech\Utilities\KeyboardNames.cs" />
|
<Compile Include="DeviceProviders\Logitech\Utilities\KeyboardNames.cs" />
|
||||||
@ -403,6 +408,7 @@
|
|||||||
<Compile Include="Profiles\Layers\Animations\NoneAnimation.cs" />
|
<Compile Include="Profiles\Layers\Animations\NoneAnimation.cs" />
|
||||||
<Compile Include="Profiles\Layers\Models\EventPropertiesModel.cs" />
|
<Compile Include="Profiles\Layers\Models\EventPropertiesModel.cs" />
|
||||||
<Compile Include="Profiles\Layers\Models\KeyboardEventPropertiesModel.cs" />
|
<Compile Include="Profiles\Layers\Models\KeyboardEventPropertiesModel.cs" />
|
||||||
|
<Compile Include="Profiles\Layers\Models\TweenModel.cs" />
|
||||||
<Compile Include="Profiles\Layers\Types\AmbientLight\AmbienceCreator\AmbienceCreatorExtend.cs" />
|
<Compile Include="Profiles\Layers\Types\AmbientLight\AmbienceCreator\AmbienceCreatorExtend.cs" />
|
||||||
<Compile Include="Profiles\Layers\Types\AmbientLight\AmbienceCreator\AmbienceCreatorMirror.cs" />
|
<Compile Include="Profiles\Layers\Types\AmbientLight\AmbienceCreator\AmbienceCreatorMirror.cs" />
|
||||||
<Compile Include="Profiles\Layers\Types\AmbientLight\AmbienceCreator\AvgColor.cs" />
|
<Compile Include="Profiles\Layers\Types\AmbientLight\AmbienceCreator\AvgColor.cs" />
|
||||||
@ -425,6 +431,7 @@
|
|||||||
<Compile Include="Profiles\Layers\Types\AmbientLight\ScreenCapturing\DX9ScreenCapture.cs" />
|
<Compile Include="Profiles\Layers\Types\AmbientLight\ScreenCapturing\DX9ScreenCapture.cs" />
|
||||||
<Compile Include="Profiles\Layers\Types\AmbientLight\ScreenCapturing\IScreenCapture.cs" />
|
<Compile Include="Profiles\Layers\Types\AmbientLight\ScreenCapturing\IScreenCapture.cs" />
|
||||||
<Compile Include="Profiles\Layers\Types\AmbientLight\ScreenCapturing\ScreenCaptureManager.cs" />
|
<Compile Include="Profiles\Layers\Types\AmbientLight\ScreenCapturing\ScreenCaptureManager.cs" />
|
||||||
|
<Compile Include="Profiles\Layers\Types\Audio\AudioCapturing\AudioCaptureManager.cs" />
|
||||||
<Compile Include="Profiles\Layers\Types\Audio\AudioPropertiesModel.cs" />
|
<Compile Include="Profiles\Layers\Types\Audio\AudioPropertiesModel.cs" />
|
||||||
<Compile Include="Profiles\Layers\Types\Audio\AudioPropertiesView.xaml.cs">
|
<Compile Include="Profiles\Layers\Types\Audio\AudioPropertiesView.xaml.cs">
|
||||||
<DependentUpon>AudioPropertiesView.xaml</DependentUpon>
|
<DependentUpon>AudioPropertiesView.xaml</DependentUpon>
|
||||||
@ -597,6 +604,7 @@
|
|||||||
<Compile Include="Modules\Games\Dota2\Dota2ViewModel.cs" />
|
<Compile Include="Modules\Games\Dota2\Dota2ViewModel.cs" />
|
||||||
<Compile Include="Modules\Games\RocketLeague\RocketLeagueViewModel.cs" />
|
<Compile Include="Modules\Games\RocketLeague\RocketLeagueViewModel.cs" />
|
||||||
<Compile Include="Modules\Games\Witcher3\Witcher3ViewModel.cs" />
|
<Compile Include="Modules\Games\Witcher3\Witcher3ViewModel.cs" />
|
||||||
|
<Compile Include="ViewModels\Profiles\LayerTweenViewModel.cs" />
|
||||||
<Compile Include="ViewModels\Profiles\Events\EventPropertiesViewModel.cs" />
|
<Compile Include="ViewModels\Profiles\Events\EventPropertiesViewModel.cs" />
|
||||||
<Compile Include="ViewModels\Profiles\ProfileViewModel.cs" />
|
<Compile Include="ViewModels\Profiles\ProfileViewModel.cs" />
|
||||||
<Compile Include="Profiles\Layers\Types\Keyboard\KeyboardPropertiesViewModel.cs" />
|
<Compile Include="Profiles\Layers\Types\Keyboard\KeyboardPropertiesViewModel.cs" />
|
||||||
@ -669,6 +677,9 @@
|
|||||||
<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\Profiles\LayerTweenView.xaml.cs">
|
||||||
|
<DependentUpon>LayerTweenView.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Views\Profiles\ProfileEditorView.xaml.cs">
|
<Compile Include="Views\Profiles\ProfileEditorView.xaml.cs">
|
||||||
<DependentUpon>ProfileEditorView.xaml</DependentUpon>
|
<DependentUpon>ProfileEditorView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -686,6 +697,7 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<None Include="Resources\Keyboards\masterkeys-pro-s.png" />
|
||||||
<None Include="Resources\Keyboards\masterkeys-pro-l.png" />
|
<None Include="Resources\Keyboards\masterkeys-pro-l.png" />
|
||||||
<Resource Include="Resources\Kottke Silkscreen License.txt" />
|
<Resource Include="Resources\Kottke Silkscreen License.txt" />
|
||||||
<None Include="Resources\lua-placeholder.lua" />
|
<None Include="Resources\lua-placeholder.lua" />
|
||||||
@ -911,6 +923,10 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="Views\Profiles\LayerTweenView.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\Profiles\ProfileEditorView.xaml">
|
<Page Include="Views\Profiles\ProfileEditorView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
@ -8,9 +8,9 @@ using Artemis.InjectionModules;
|
|||||||
using Artemis.Settings;
|
using Artemis.Settings;
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using Artemis.Utilities.Converters;
|
using Artemis.Utilities.Converters;
|
||||||
|
using Artemis.Utilities.DataReaders;
|
||||||
using Artemis.ViewModels;
|
using Artemis.ViewModels;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
using MoonSharp.Interpreter;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
|
|
||||||
@ -24,6 +24,8 @@ namespace Artemis
|
|||||||
{
|
{
|
||||||
// Start logging before anything else
|
// Start logging before anything else
|
||||||
Logging.SetupLogging(SettingsProvider.Load<GeneralSettings>().LogLevel);
|
Logging.SetupLogging(SettingsProvider.Load<GeneralSettings>().LogLevel);
|
||||||
|
// Restore DDLs before interacting with any SDKs
|
||||||
|
DllManager.RestoreLogitechDll();
|
||||||
|
|
||||||
Initialize();
|
Initialize();
|
||||||
BindSpecialValues();
|
BindSpecialValues();
|
||||||
|
|||||||
@ -58,7 +58,7 @@ namespace Artemis.DeviceProviders.CoolerMaster
|
|||||||
using (var b = ImageUtilities.ResizeImage(bitmap, Width, Height))
|
using (var b = ImageUtilities.ResizeImage(bitmap, Width, Height))
|
||||||
{
|
{
|
||||||
// Create an empty matrix
|
// Create an empty matrix
|
||||||
var matrix = new COLOR_MATRIX {KeyColor = new KEY_COLOR[Height, Width]};
|
var matrix = new COLOR_MATRIX {KeyColor = new KEY_COLOR[6, 22]};
|
||||||
|
|
||||||
// Map the bytes to the matix
|
// Map the bytes to the matix
|
||||||
for (var x = 0; x < Width; x++)
|
for (var x = 0; x < Width; x++)
|
||||||
|
|||||||
@ -0,0 +1,91 @@
|
|||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using Artemis.DAL;
|
||||||
|
using Artemis.DeviceProviders.CoolerMaster.Utilities;
|
||||||
|
using Artemis.DeviceProviders.Logitech.Utilities;
|
||||||
|
using Artemis.Properties;
|
||||||
|
using Artemis.Settings;
|
||||||
|
using Artemis.Utilities;
|
||||||
|
|
||||||
|
namespace Artemis.DeviceProviders.CoolerMaster
|
||||||
|
{
|
||||||
|
public class MasterkeysProS : KeyboardProvider
|
||||||
|
{
|
||||||
|
private GeneralSettings _generalSettings;
|
||||||
|
|
||||||
|
public MasterkeysProS()
|
||||||
|
{
|
||||||
|
Name = "CM Masterkeys Pro S";
|
||||||
|
Slug = "cm-masterkeys-pro-s";
|
||||||
|
|
||||||
|
CantEnableText = "Couldn't connect to your CM Masterkeys Pro S.\n" +
|
||||||
|
"Please check your cables and try updating your CM software.\n\n" +
|
||||||
|
"If needed, you can select a different keyboard in Artemis under settings.";
|
||||||
|
|
||||||
|
Height = 6;
|
||||||
|
Width = 18;
|
||||||
|
|
||||||
|
PreviewSettings = new PreviewSettings(683, 242, new Thickness(0, 0, 0, 0), Resources.masterkeys_pro_s);
|
||||||
|
_generalSettings = SettingsProvider.Load<GeneralSettings>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Disable()
|
||||||
|
{
|
||||||
|
CmSdk.EnableLedControl(false);
|
||||||
|
Thread.Sleep(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CanEnable()
|
||||||
|
{
|
||||||
|
CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MKeys_L);
|
||||||
|
|
||||||
|
// Doesn't seem reliable but better than nothing I suppose
|
||||||
|
return CmSdk.IsDevicePlug();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Enable()
|
||||||
|
{
|
||||||
|
CmSdk.SetControlDevice(DEVICE_INDEX.DEV_MKeys_S);
|
||||||
|
CmSdk.EnableLedControl(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DrawBitmap(Bitmap bitmap)
|
||||||
|
{
|
||||||
|
// Resize the bitmap
|
||||||
|
using (var b = ImageUtilities.ResizeImage(bitmap, Width, Height))
|
||||||
|
{
|
||||||
|
// Create an empty matrix
|
||||||
|
var matrix = new COLOR_MATRIX { KeyColor = new KEY_COLOR[6, 22] };
|
||||||
|
|
||||||
|
// Map the bytes to the matix
|
||||||
|
for (var x = 0; x < Width; x++)
|
||||||
|
{
|
||||||
|
for (var y = 0; y < Height; y++)
|
||||||
|
{
|
||||||
|
var c = b.GetPixel(x, y);
|
||||||
|
matrix.KeyColor[y, x] = new KEY_COLOR(c.R, c.G, c.B);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the matrix to the keyboard
|
||||||
|
CmSdk.SetAllLedColor(matrix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override KeyMatch? GetKeyPosition(Keys keyCode)
|
||||||
|
{
|
||||||
|
switch (_generalSettings.Layout)
|
||||||
|
{
|
||||||
|
case "Qwerty":
|
||||||
|
return KeyMap.QwertyLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||||
|
case "Qwertz":
|
||||||
|
return KeyMap.QwertzLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||||
|
default:
|
||||||
|
return KeyMap.AzertyLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,9 +8,9 @@ using Ninject.Extensions.Logging;
|
|||||||
|
|
||||||
namespace Artemis.DeviceProviders.Corsair
|
namespace Artemis.DeviceProviders.Corsair
|
||||||
{
|
{
|
||||||
internal class CorsairHeadsets : DeviceProvider
|
internal class CorsairHeadset : DeviceProvider
|
||||||
{
|
{
|
||||||
public CorsairHeadsets(ILogger logger)
|
public CorsairHeadset(ILogger logger)
|
||||||
{
|
{
|
||||||
Logger = logger;
|
Logger = logger;
|
||||||
Type = DeviceType.Headset;
|
Type = DeviceType.Headset;
|
||||||
@ -10,19 +10,18 @@ using CUE.NET;
|
|||||||
using CUE.NET.Brushes;
|
using CUE.NET.Brushes;
|
||||||
using CUE.NET.Devices.Generic;
|
using CUE.NET.Devices.Generic;
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
using CUE.NET.Devices.Generic.Enums;
|
||||||
using CUE.NET.Devices.Keyboard;
|
|
||||||
using CUE.NET.Helper;
|
using CUE.NET.Helper;
|
||||||
using Ninject.Extensions.Logging;
|
using Ninject.Extensions.Logging;
|
||||||
using Point = System.Drawing.Point;
|
using Point = System.Drawing.Point;
|
||||||
|
|
||||||
namespace Artemis.DeviceProviders.Corsair
|
namespace Artemis.DeviceProviders.Corsair
|
||||||
{
|
{
|
||||||
public class CorsairKeyboards : KeyboardProvider
|
public class CorsairKeyboard : KeyboardProvider
|
||||||
{
|
{
|
||||||
private CorsairKeyboard _keyboard;
|
private CUE.NET.Devices.Keyboard.CorsairKeyboard _keyboard;
|
||||||
private ImageBrush _keyboardBrush;
|
private ImageBrush _keyboardBrush;
|
||||||
|
|
||||||
public CorsairKeyboards(ILogger logger)
|
public CorsairKeyboard(ILogger logger)
|
||||||
{
|
{
|
||||||
Logger = logger;
|
Logger = logger;
|
||||||
Name = "Corsair RGB Keyboards";
|
Name = "Corsair RGB Keyboards";
|
||||||
@ -83,7 +82,6 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
}
|
}
|
||||||
|
|
||||||
Logger.Debug("Corsair SDK reported device as: {0}", _keyboard.DeviceInfo.Model);
|
Logger.Debug("Corsair SDK reported device as: {0}", _keyboard.DeviceInfo.Model);
|
||||||
|
|
||||||
_keyboard.Brush = _keyboardBrush ?? (_keyboardBrush = new ImageBrush());
|
_keyboard.Brush = _keyboardBrush ?? (_keyboardBrush = new ImageBrush());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,8 +98,8 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
/// <param name="bitmap"></param>
|
/// <param name="bitmap"></param>
|
||||||
public override void DrawBitmap(Bitmap bitmap)
|
public override void DrawBitmap(Bitmap bitmap)
|
||||||
{
|
{
|
||||||
var image = ImageUtilities.ResizeImage(bitmap, Width, Height);
|
using (var image = ImageUtilities.ResizeImage(bitmap, Width, Height))
|
||||||
|
{
|
||||||
// For STRAFE, stretch the image on row 2.
|
// For STRAFE, stretch the image on row 2.
|
||||||
if (_keyboard.DeviceInfo.Model == "STRAFE RGB")
|
if (_keyboard.DeviceInfo.Model == "STRAFE RGB")
|
||||||
{
|
{
|
||||||
@ -110,18 +108,20 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
using (var g = Graphics.FromImage(strafeBitmap))
|
using (var g = Graphics.FromImage(strafeBitmap))
|
||||||
{
|
{
|
||||||
g.DrawImage(image, new Point(0, 0));
|
g.DrawImage(image, new Point(0, 0));
|
||||||
g.DrawImage(image, new Rectangle(0, 3, 22, 7), new Rectangle(0, 2, 22, 7), GraphicsUnit.Pixel);
|
g.DrawImage(image, new Rectangle(0, 3, 22, 7), new Rectangle(0, 2, 22, 7),
|
||||||
}
|
GraphicsUnit.Pixel);
|
||||||
|
|
||||||
image.Dispose();
|
_keyboardBrush.Image = strafeBitmap;
|
||||||
image = strafeBitmap;
|
_keyboard.Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_keyboardBrush.Image = image;
|
_keyboardBrush.Image = image;
|
||||||
_keyboard.Update();
|
_keyboard.Update();
|
||||||
|
}
|
||||||
image.Dispose();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override KeyMatch? GetKeyPosition(Keys keyCode)
|
public override KeyMatch? GetKeyPosition(Keys keyCode)
|
||||||
@ -144,7 +144,7 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
var center = cueLed.LedRectangle.GetCenter();
|
var center = cueLed.LedRectangle.GetCenter();
|
||||||
return new KeyMatch(keyCode, (int) (center.X*widthMultiplier),(int) (center.Y*heightMultiplier));
|
return new KeyMatch(keyCode, (int) (center.X*widthMultiplier), (int) (center.Y*heightMultiplier));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8,9 +8,9 @@ using Ninject.Extensions.Logging;
|
|||||||
|
|
||||||
namespace Artemis.DeviceProviders.Corsair
|
namespace Artemis.DeviceProviders.Corsair
|
||||||
{
|
{
|
||||||
internal class CorsairMice : DeviceProvider
|
internal class CorsairMouse : DeviceProvider
|
||||||
{
|
{
|
||||||
public CorsairMice(ILogger logger)
|
public CorsairMouse(ILogger logger)
|
||||||
{
|
{
|
||||||
Logger = logger;
|
Logger = logger;
|
||||||
Type = DeviceType.Mouse;
|
Type = DeviceType.Mouse;
|
||||||
@ -4,14 +4,13 @@ using System.Linq;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using CUE.NET;
|
using CUE.NET;
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
using CUE.NET.Devices.Generic.Enums;
|
||||||
using CUE.NET.Devices.Mousemat.Enums;
|
|
||||||
using Ninject.Extensions.Logging;
|
using Ninject.Extensions.Logging;
|
||||||
|
|
||||||
namespace Artemis.DeviceProviders.Corsair
|
namespace Artemis.DeviceProviders.Corsair
|
||||||
{
|
{
|
||||||
internal class CorsairMousemats : DeviceProvider
|
internal class CorsairMousemat : DeviceProvider
|
||||||
{
|
{
|
||||||
public CorsairMousemats(ILogger logger)
|
public CorsairMousemat(ILogger logger)
|
||||||
{
|
{
|
||||||
Logger = logger;
|
Logger = logger;
|
||||||
Type = DeviceType.Mousemat;
|
Type = DeviceType.Mousemat;
|
||||||
@ -40,7 +39,7 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
|
|
||||||
public override void UpdateDevice(Bitmap bitmap)
|
public override void UpdateDevice(Bitmap bitmap)
|
||||||
{
|
{
|
||||||
if (!CanUse || bitmap == null)
|
if (!CanUse || (bitmap == null))
|
||||||
return;
|
return;
|
||||||
if (bitmap.Width != bitmap.Height)
|
if (bitmap.Width != bitmap.Height)
|
||||||
throw new ArgumentException("Bitmap must be a perfect square");
|
throw new ArgumentException("Bitmap must be a perfect square");
|
||||||
@ -1,6 +1,5 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows;
|
|
||||||
using Artemis.DeviceProviders.Logitech.Utilities;
|
using Artemis.DeviceProviders.Logitech.Utilities;
|
||||||
using Artemis.Utilities.DataReaders;
|
using Artemis.Utilities.DataReaders;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
@ -23,8 +22,17 @@ namespace Artemis.DeviceProviders.Logitech
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DllManager.RestoreLogitechDll())
|
if (DllManager.DllPlaced())
|
||||||
RestoreDll();
|
{
|
||||||
|
CantEnableText =
|
||||||
|
"Artemis couldn't enable your Logitech keyboard, because the required files are not in place.\n\n" +
|
||||||
|
"This happens when you run The Division or GTA and shut down Artemis before shutting down The Division\n" +
|
||||||
|
"Artemis tries to fix this automatically on startup but because the files may have been in use it failed.\n\n" +
|
||||||
|
"To try again, restart Artemis or check out the FAQ.";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int majorNum = 0, minorNum = 0, buildNum = 0;
|
int majorNum = 0, minorNum = 0, buildNum = 0;
|
||||||
|
|
||||||
LogitechGSDK.LogiLedInit();
|
LogitechGSDK.LogiLedInit();
|
||||||
@ -42,15 +50,6 @@ namespace Artemis.DeviceProviders.Logitech
|
|||||||
return version >= 88115;
|
return version >= 88115;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RestoreDll()
|
|
||||||
{
|
|
||||||
MessageBox.Show(
|
|
||||||
"Artemis couldn't enable your Logitech keyboard, because the required files are not in place.\n\n" +
|
|
||||||
"This happens when you run The Division and shut down Artemis before shutting down The Division\n" +
|
|
||||||
"It can be fixed automatically by clicking OK, but to avoid this message in the future please\n" +
|
|
||||||
"shut down The Division before shutting down Artemis.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Enable()
|
public override void Enable()
|
||||||
{
|
{
|
||||||
// Initialize the SDK
|
// Initialize the SDK
|
||||||
|
|||||||
@ -16,8 +16,6 @@ namespace Artemis.Dialogs
|
|||||||
public static readonly DependencyProperty MarkdownProperty = DependencyProperty.Register("Markdown",
|
public static readonly DependencyProperty MarkdownProperty = DependencyProperty.Register("Markdown",
|
||||||
typeof(string), typeof(MarkdownDialog), new PropertyMetadata(default(string)));
|
typeof(string), typeof(MarkdownDialog), new PropertyMetadata(default(string)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public MarkdownDialog(MetroWindow parentWindow)
|
public MarkdownDialog(MetroWindow parentWindow)
|
||||||
{
|
{
|
||||||
ParentWindow = parentWindow;
|
ParentWindow = parentWindow;
|
||||||
|
|||||||
@ -12,20 +12,21 @@ namespace Artemis.InjectionModules
|
|||||||
public override void Load()
|
public override void Load()
|
||||||
{
|
{
|
||||||
// Keyboards
|
// Keyboards
|
||||||
Bind<DeviceProvider>().To<CorsairKeyboards>().InSingletonScope();
|
Bind<DeviceProvider>().To<CorsairKeyboard>().InSingletonScope();
|
||||||
Bind<DeviceProvider>().To<G910>().InSingletonScope();
|
Bind<DeviceProvider>().To<G910>().InSingletonScope();
|
||||||
Bind<DeviceProvider>().To<G810>().InSingletonScope();
|
Bind<DeviceProvider>().To<G810>().InSingletonScope();
|
||||||
Bind<DeviceProvider>().To<BlackWidow>().InSingletonScope();
|
Bind<DeviceProvider>().To<BlackWidow>().InSingletonScope();
|
||||||
Bind<DeviceProvider>().To<MasterkeysProL>().InSingletonScope();
|
Bind<DeviceProvider>().To<MasterkeysProL>().InSingletonScope();
|
||||||
|
Bind<DeviceProvider>().To<MasterkeysProS>().InSingletonScope();
|
||||||
|
|
||||||
// Mice
|
// Mice
|
||||||
Bind<DeviceProvider>().To<CorsairMice>().InSingletonScope();
|
Bind<DeviceProvider>().To<CorsairMouse>().InSingletonScope();
|
||||||
|
|
||||||
// Headsets
|
// Headsets
|
||||||
Bind<DeviceProvider>().To<CorsairHeadsets>().InSingletonScope();
|
Bind<DeviceProvider>().To<CorsairHeadset>().InSingletonScope();
|
||||||
|
|
||||||
// Mousemats
|
// Mousemats
|
||||||
Bind<DeviceProvider>().To<CorsairMousemats>().InSingletonScope();
|
Bind<DeviceProvider>().To<CorsairMousemat>().InSingletonScope();
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
Bind<DeviceProvider>().To<LogitechGeneric>().InSingletonScope();
|
Bind<DeviceProvider>().To<LogitechGeneric>().InSingletonScope();
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using Artemis.Profiles.Layers.Conditions;
|
|||||||
using Artemis.Profiles.Layers.Interfaces;
|
using Artemis.Profiles.Layers.Interfaces;
|
||||||
using Artemis.Profiles.Layers.Types.AmbientLight;
|
using Artemis.Profiles.Layers.Types.AmbientLight;
|
||||||
using Artemis.Profiles.Layers.Types.Audio;
|
using Artemis.Profiles.Layers.Types.Audio;
|
||||||
|
using Artemis.Profiles.Layers.Types.Audio.AudioCapturing;
|
||||||
using Artemis.Profiles.Layers.Types.Folder;
|
using Artemis.Profiles.Layers.Types.Folder;
|
||||||
using Artemis.Profiles.Layers.Types.Generic;
|
using Artemis.Profiles.Layers.Types.Generic;
|
||||||
using Artemis.Profiles.Layers.Types.Headset;
|
using Artemis.Profiles.Layers.Types.Headset;
|
||||||
@ -48,6 +49,9 @@ namespace Artemis.InjectionModules
|
|||||||
Bind<KeyPressType>().ToSelf();
|
Bind<KeyPressType>().ToSelf();
|
||||||
Bind<AudioType>().ToSelf();
|
Bind<AudioType>().ToSelf();
|
||||||
Bind<AmbientLightType>().ToSelf();
|
Bind<AmbientLightType>().ToSelf();
|
||||||
|
|
||||||
|
// Type helpers
|
||||||
|
Bind<AudioCaptureManager>().ToSelf().InSingletonScope();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4,6 +4,8 @@ using System.Linq;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Threading;
|
||||||
using Artemis.DeviceProviders;
|
using Artemis.DeviceProviders;
|
||||||
using Ninject.Extensions.Logging;
|
using Ninject.Extensions.Logging;
|
||||||
using Timer = System.Timers.Timer;
|
using Timer = System.Timers.Timer;
|
||||||
@ -19,21 +21,44 @@ namespace Artemis.Managers
|
|||||||
private readonly EffectManager _effectManager;
|
private readonly EffectManager _effectManager;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly Timer _loopTimer;
|
private readonly Timer _loopTimer;
|
||||||
|
private bool _canShowException;
|
||||||
|
|
||||||
public LoopManager(ILogger logger, EffectManager effectManager, DeviceManager deviceManager)
|
public LoopManager(ILogger logger, EffectManager effectManager, DeviceManager deviceManager)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_effectManager = effectManager;
|
_effectManager = effectManager;
|
||||||
_deviceManager = deviceManager;
|
_deviceManager = deviceManager;
|
||||||
|
_canShowException = true;
|
||||||
|
|
||||||
// Setup timers
|
// Setup timers
|
||||||
_loopTimer = new Timer(40);
|
_loopTimer = new Timer(40);
|
||||||
_loopTimer.Elapsed += Render;
|
_loopTimer.Elapsed += LoopTimerOnElapsed;
|
||||||
_loopTimer.Start();
|
_loopTimer.Start();
|
||||||
|
|
||||||
_logger.Info("Intialized LoopManager");
|
_logger.Info("Intialized LoopManager");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LoopTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Render();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (_canShowException)
|
||||||
|
{
|
||||||
|
Caliburn.Micro.Execute.OnUIThread(delegate
|
||||||
|
{
|
||||||
|
_canShowException = false;
|
||||||
|
_loopTimer.Stop();
|
||||||
|
App.GetArtemisExceptionViewer(e).ShowDialog();
|
||||||
|
Environment.Exit(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets whether the loop is running
|
/// Gets whether the loop is running
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -95,7 +120,7 @@ namespace Artemis.Managers
|
|||||||
_deviceManager.ReleaseActiveKeyboard();
|
_deviceManager.ReleaseActiveKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Render(object sender, ElapsedEventArgs e)
|
private void Render()
|
||||||
{
|
{
|
||||||
if (!Running || _deviceManager.ChangingKeyboard)
|
if (!Running || _deviceManager.ChangingKeyboard)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -46,6 +46,8 @@ namespace Artemis.Modules.Games.Overwatch
|
|||||||
Lúcio,
|
Lúcio,
|
||||||
Mercy,
|
Mercy,
|
||||||
Symmetra,
|
Symmetra,
|
||||||
Zenyatta
|
Zenyatta,
|
||||||
|
Ana,
|
||||||
|
Sombra
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10,14 +10,16 @@ using Artemis.Profiles.Layers.Models;
|
|||||||
using Artemis.Services;
|
using Artemis.Services;
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using Artemis.Utilities.DataReaders;
|
using Artemis.Utilities.DataReaders;
|
||||||
|
using Artemis.ViewModels;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
|
||||||
namespace Artemis.Modules.Games.Overwatch
|
namespace Artemis.Modules.Games.Overwatch
|
||||||
{
|
{
|
||||||
public class OverwatchModel : GameModel
|
public class OverwatchModel : GameModel
|
||||||
{
|
{
|
||||||
private readonly PipeServer _pipeServer;
|
private readonly DebugViewModel _debugViewModel;
|
||||||
private readonly MetroDialogService _dialogService;
|
private readonly MetroDialogService _dialogService;
|
||||||
|
private readonly PipeServer _pipeServer;
|
||||||
private DateTime _characterChange;
|
private DateTime _characterChange;
|
||||||
private string _lastMessage;
|
private string _lastMessage;
|
||||||
// Using sticky values on these since they can cause flickering
|
// Using sticky values on these since they can cause flickering
|
||||||
@ -27,11 +29,13 @@ namespace Artemis.Modules.Games.Overwatch
|
|||||||
private DateTime _ultimateReady;
|
private DateTime _ultimateReady;
|
||||||
private DateTime _ultimateUsed;
|
private DateTime _ultimateUsed;
|
||||||
|
|
||||||
public OverwatchModel(DeviceManager deviceManager, PipeServer pipeServer, MetroDialogService dialogService)
|
public OverwatchModel(DeviceManager deviceManager, PipeServer pipeServer, MetroDialogService dialogService,
|
||||||
|
DebugViewModel debugViewModel)
|
||||||
: base(deviceManager, SettingsProvider.Load<OverwatchSettings>(), new OverwatchDataModel())
|
: base(deviceManager, SettingsProvider.Load<OverwatchSettings>(), new OverwatchDataModel())
|
||||||
{
|
{
|
||||||
_pipeServer = pipeServer;
|
_pipeServer = pipeServer;
|
||||||
_dialogService = dialogService;
|
_dialogService = dialogService;
|
||||||
|
_debugViewModel = debugViewModel;
|
||||||
Name = "Overwatch";
|
Name = "Overwatch";
|
||||||
ProcessName = "Overwatch";
|
ProcessName = "Overwatch";
|
||||||
Scale = 4;
|
Scale = 4;
|
||||||
@ -70,7 +74,9 @@ namespace Artemis.Modules.Games.Overwatch
|
|||||||
new CharacterColor {Character = OverwatchCharacter.Lúcio, Color = Color.FromRgb(34, 142, 2)},
|
new CharacterColor {Character = OverwatchCharacter.Lúcio, Color = Color.FromRgb(34, 142, 2)},
|
||||||
new CharacterColor {Character = OverwatchCharacter.Mercy, Color = Color.FromRgb(243, 226, 106)},
|
new CharacterColor {Character = OverwatchCharacter.Mercy, Color = Color.FromRgb(243, 226, 106)},
|
||||||
new CharacterColor {Character = OverwatchCharacter.Symmetra, Color = Color.FromRgb(46, 116, 148)},
|
new CharacterColor {Character = OverwatchCharacter.Symmetra, Color = Color.FromRgb(46, 116, 148)},
|
||||||
new CharacterColor {Character = OverwatchCharacter.Zenyatta, Color = Color.FromRgb(248, 218, 26)}
|
new CharacterColor {Character = OverwatchCharacter.Zenyatta, Color = Color.FromRgb(248, 218, 26)},
|
||||||
|
new CharacterColor {Character = OverwatchCharacter.Ana, Color = Color.FromRgb(16, 36, 87)},
|
||||||
|
new CharacterColor {Character = OverwatchCharacter.Sombra, Color = Color.FromRgb(20, 5, 101)}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,8 +133,7 @@ namespace Artemis.Modules.Games.Overwatch
|
|||||||
if (colors == null)
|
if (colors == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO: Get the debug viewmodel and update the color array
|
_debugViewModel.UpdateRazerDisplay(colors);
|
||||||
//_events.PublishOnUIThread(new RazerColorArrayChanged(colors));
|
|
||||||
|
|
||||||
// Determine general game state
|
// Determine general game state
|
||||||
ParseGameSate(gameDataModel, colors);
|
ParseGameSate(gameDataModel, colors);
|
||||||
@ -276,7 +281,10 @@ namespace Artemis.Modules.Games.Overwatch
|
|||||||
|
|
||||||
public void FindOverwatch()
|
public void FindOverwatch()
|
||||||
{
|
{
|
||||||
var gameSettings = (OverwatchSettings) Settings;
|
var gameSettings = Settings as OverwatchSettings;
|
||||||
|
if (gameSettings == null)
|
||||||
|
return;
|
||||||
|
|
||||||
// If already propertly set up, don't do anything
|
// If already propertly set up, don't do anything
|
||||||
if ((gameSettings.GameDirectory != null) && File.Exists(gameSettings.GameDirectory + "Overwatch.exe") &&
|
if ((gameSettings.GameDirectory != null) && File.Exists(gameSettings.GameDirectory + "Overwatch.exe") &&
|
||||||
File.Exists(gameSettings.GameDirectory + "RzChromaSDK64.dll"))
|
File.Exists(gameSettings.GameDirectory + "RzChromaSDK64.dll"))
|
||||||
@ -284,11 +292,9 @@ namespace Artemis.Modules.Games.Overwatch
|
|||||||
|
|
||||||
var key = Registry.LocalMachine.OpenSubKey(
|
var key = Registry.LocalMachine.OpenSubKey(
|
||||||
@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Overwatch");
|
@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Overwatch");
|
||||||
if (key == null)
|
var path = key?.GetValue("DisplayIcon")?.ToString();
|
||||||
return;
|
|
||||||
|
|
||||||
var path = key.GetValue("DisplayIcon").ToString();
|
if (string.IsNullOrEmpty(path) || !File.Exists(path))
|
||||||
if (!File.Exists(path))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gameSettings.GameDirectory = path.Substring(0, path.Length - 14);
|
gameSettings.GameDirectory = path.Substring(0, path.Length - 14);
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Artemis.Profiles.Layers.Interfaces;
|
using Artemis.Profiles.Layers.Interfaces;
|
||||||
using Artemis.Profiles.Layers.Models;
|
using Artemis.Profiles.Layers.Models;
|
||||||
@ -8,16 +7,16 @@ namespace Artemis.Profiles.Layers.Animations
|
|||||||
{
|
{
|
||||||
public class GrowAnimation : ILayerAnimation
|
public class GrowAnimation : ILayerAnimation
|
||||||
{
|
{
|
||||||
public string Name { get; } = "Grow";
|
public string Name => "Grow";
|
||||||
|
|
||||||
public void Update(LayerModel layerModel, bool updateAnimations)
|
public void Update(LayerModel layerModel, bool updateAnimations)
|
||||||
{
|
{
|
||||||
// TODO: Generic implementation
|
// TODO: Generic implementation
|
||||||
// Reset animation progress if layer wasn't drawn for 100ms
|
// Reset animation progress if layer wasn't drawn for 100ms
|
||||||
if ((new TimeSpan(0, 0, 0, 0, 100) < DateTime.Now - layerModel.LastRender) && updateAnimations)
|
if ((new TimeSpan(0, 0, 0, 0, 100) < DateTime.Now - layerModel.LastRender) && updateAnimations)
|
||||||
layerModel.Properties.AnimationProgress = 0;
|
layerModel.AnimationProgress = 0;
|
||||||
|
|
||||||
var progress = layerModel.Properties.AnimationProgress;
|
var progress = layerModel.AnimationProgress;
|
||||||
|
|
||||||
if (MustExpire(layerModel))
|
if (MustExpire(layerModel))
|
||||||
progress = 0;
|
progress = 0;
|
||||||
@ -25,43 +24,42 @@ namespace Artemis.Profiles.Layers.Animations
|
|||||||
|
|
||||||
// If not previewing, store the animation progress in the actual model for the next frame
|
// If not previewing, store the animation progress in the actual model for the next frame
|
||||||
if (updateAnimations)
|
if (updateAnimations)
|
||||||
layerModel.Properties.AnimationProgress = progress;
|
layerModel.AnimationProgress = progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c)
|
public void Draw(LayerModel layerModel, DrawingContext c)
|
||||||
{
|
{
|
||||||
if (applied?.Brush == null)
|
if (layerModel.Brush == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int scale = 4;
|
|
||||||
// Set up variables for this frame
|
// Set up variables for this frame
|
||||||
var rect = applied.Contain
|
var rect = layerModel.Properties.Contain
|
||||||
? new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale)
|
? layerModel.LayerRect()
|
||||||
: new Rect(props.X*scale, props.Y*scale, props.Width*scale, props.Height*scale);
|
: layerModel.Properties.PropertiesRect();
|
||||||
|
|
||||||
var clip = new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale);
|
var clip = layerModel.LayerRect();
|
||||||
|
|
||||||
// Take an offset of 4 to allow layers to slightly leave their bounds
|
// Take an offset of 4 to allow layers to slightly leave their bounds
|
||||||
var progress = (6.0 - props.AnimationProgress)*10.0;
|
var progress = (6.0 - layerModel.AnimationProgress)*10.0;
|
||||||
if (progress < 0)
|
if (progress < 0)
|
||||||
{
|
{
|
||||||
// Can't meddle with the original brush because it's frozen.
|
// Can't meddle with the original brush because it's frozen.
|
||||||
var brush = applied.Brush.Clone();
|
var brush = layerModel.Brush.Clone();
|
||||||
brush.Opacity = 1 + 0.025*progress;
|
brush.Opacity = 1 + 0.025*progress;
|
||||||
if (brush.Opacity < 0)
|
if (brush.Opacity < 0)
|
||||||
brush.Opacity = 0;
|
brush.Opacity = 0;
|
||||||
if (brush.Opacity > 1)
|
if (brush.Opacity > 1)
|
||||||
brush.Opacity = 1;
|
brush.Opacity = 1;
|
||||||
applied.Brush = brush;
|
layerModel.Brush = brush;
|
||||||
}
|
}
|
||||||
rect.Inflate(-rect.Width/100.0*progress, -rect.Height/100.0*progress);
|
rect.Inflate(-rect.Width/100.0*progress, -rect.Height/100.0*progress);
|
||||||
clip.Inflate(-clip.Width/100.0*progress, -clip.Height/100.0*progress);
|
clip.Inflate(-clip.Width/100.0*progress, -clip.Height/100.0*progress);
|
||||||
|
|
||||||
c.PushClip(new RectangleGeometry(clip));
|
c.PushClip(new RectangleGeometry(clip));
|
||||||
c.DrawRectangle(applied.Brush, null, rect);
|
c.DrawRectangle(layerModel.Brush, null, rect);
|
||||||
c.Pop();
|
c.Pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool MustExpire(LayerModel layer) => layer.Properties.AnimationProgress > 10;
|
public bool MustExpire(LayerModel layer) => layer.AnimationProgress > 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6,13 +6,13 @@ namespace Artemis.Profiles.Layers.Animations
|
|||||||
{
|
{
|
||||||
public class NoneAnimation : ILayerAnimation
|
public class NoneAnimation : ILayerAnimation
|
||||||
{
|
{
|
||||||
public string Name { get; } = "None";
|
public string Name => "None";
|
||||||
|
|
||||||
public void Update(LayerModel layerModel, bool updateAnimations)
|
public void Update(LayerModel layerModel, bool updateAnimations)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c)
|
public void Draw(LayerModel layerModel, DrawingContext c)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Artemis.Profiles.Layers.Interfaces;
|
using Artemis.Profiles.Layers.Interfaces;
|
||||||
using Artemis.Profiles.Layers.Models;
|
using Artemis.Profiles.Layers.Models;
|
||||||
@ -8,16 +7,16 @@ namespace Artemis.Profiles.Layers.Animations
|
|||||||
{
|
{
|
||||||
public class PulseAnimation : ILayerAnimation
|
public class PulseAnimation : ILayerAnimation
|
||||||
{
|
{
|
||||||
public string Name { get; } = "Pulse";
|
public string Name => "Pulse";
|
||||||
|
|
||||||
public void Update(LayerModel layerModel, bool updateAnimations)
|
public void Update(LayerModel layerModel, bool updateAnimations)
|
||||||
{
|
{
|
||||||
// TODO: Generic implementation
|
// TODO: Generic implementation
|
||||||
// Reset animation progress if layer wasn't drawn for 100ms
|
// Reset animation progress if layer wasn't drawn for 100ms
|
||||||
if ((new TimeSpan(0, 0, 0, 0, 100) < DateTime.Now - layerModel.LastRender) && updateAnimations)
|
if ((new TimeSpan(0, 0, 0, 0, 100) < DateTime.Now - layerModel.LastRender) && updateAnimations)
|
||||||
layerModel.Properties.AnimationProgress = 0;
|
layerModel.AnimationProgress = 0;
|
||||||
|
|
||||||
var progress = layerModel.Properties.AnimationProgress;
|
var progress = layerModel.AnimationProgress;
|
||||||
|
|
||||||
if (MustExpire(layerModel))
|
if (MustExpire(layerModel))
|
||||||
progress = 0;
|
progress = 0;
|
||||||
@ -25,32 +24,31 @@ namespace Artemis.Profiles.Layers.Animations
|
|||||||
|
|
||||||
// If not previewing, store the animation progress in the actual model for the next frame
|
// If not previewing, store the animation progress in the actual model for the next frame
|
||||||
if (updateAnimations)
|
if (updateAnimations)
|
||||||
layerModel.Properties.AnimationProgress = progress;
|
layerModel.AnimationProgress = progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c)
|
public void Draw(LayerModel layerModel, DrawingContext c)
|
||||||
{
|
{
|
||||||
if (applied.Brush == null)
|
if (layerModel.Brush == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int scale = 4;
|
|
||||||
// Set up variables for this frame
|
// Set up variables for this frame
|
||||||
var rect = applied.Contain
|
var rect = layerModel.Properties.Contain
|
||||||
? new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale)
|
? layerModel.LayerRect()
|
||||||
: new Rect(props.X*scale, props.Y*scale, props.Width*scale, props.Height*scale);
|
: layerModel.Properties.PropertiesRect();
|
||||||
|
|
||||||
var clip = new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale);
|
var clip = layerModel.LayerRect();
|
||||||
|
|
||||||
// Can't meddle with the original brush because it's frozen.
|
// Can't meddle with the original brush because it's frozen.
|
||||||
var brush = applied.Brush.Clone();
|
var brush = layerModel.Brush.Clone();
|
||||||
brush.Opacity = (Math.Sin(props.AnimationProgress*Math.PI) + 1)*(props.Opacity/2);
|
brush.Opacity = (Math.Sin(layerModel.AnimationProgress*Math.PI) + 1)*(layerModel.Opacity/2);
|
||||||
applied.Brush = brush;
|
layerModel.Brush = brush;
|
||||||
|
|
||||||
c.PushClip(new RectangleGeometry(clip));
|
c.PushClip(new RectangleGeometry(clip));
|
||||||
c.DrawRectangle(applied.Brush, null, rect);
|
c.DrawRectangle(layerModel.Brush, null, rect);
|
||||||
c.Pop();
|
c.Pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool MustExpire(LayerModel layer) => layer.Properties.AnimationProgress > 2;
|
public bool MustExpire(LayerModel layer) => layer.AnimationProgress > 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,45 +7,46 @@ namespace Artemis.Profiles.Layers.Animations
|
|||||||
{
|
{
|
||||||
public class SlideDownAnimation : ILayerAnimation
|
public class SlideDownAnimation : ILayerAnimation
|
||||||
{
|
{
|
||||||
public string Name { get; } = "Slide down";
|
public string Name => "Slide down";
|
||||||
|
|
||||||
public void Update(LayerModel layerModel, bool updateAnimations)
|
public void Update(LayerModel layerModel, bool updateAnimations)
|
||||||
{
|
{
|
||||||
var progress = layerModel.Properties.AnimationProgress;
|
var progress = layerModel.AnimationProgress;
|
||||||
if (MustExpire(layerModel))
|
if (MustExpire(layerModel))
|
||||||
progress = 0;
|
progress = 0;
|
||||||
progress = progress + layerModel.Properties.AnimationSpeed*2;
|
progress = progress + layerModel.Properties.AnimationSpeed*2;
|
||||||
|
|
||||||
// If not previewing, store the animation progress in the actual model for the next frame
|
// If not previewing, store the animation progress in the actual model for the next frame
|
||||||
if (updateAnimations)
|
if (updateAnimations)
|
||||||
layerModel.Properties.AnimationProgress = progress;
|
layerModel.AnimationProgress = progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c)
|
public void Draw(LayerModel layerModel, DrawingContext c)
|
||||||
{
|
{
|
||||||
if (applied.Brush == null)
|
if (layerModel.Brush == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int scale = 4;
|
|
||||||
// Set up variables for this frame
|
// Set up variables for this frame
|
||||||
var rect = applied.Contain
|
var rect = layerModel.Properties.Contain
|
||||||
? new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale)
|
? layerModel.LayerRect()
|
||||||
: new Rect(props.X*scale, props.Y*scale, props.Width*scale, props.Height*scale);
|
: layerModel.Properties.PropertiesRect();
|
||||||
|
|
||||||
var s1 = new Rect(new Point(rect.X, rect.Y + props.AnimationProgress), new Size(rect.Width, rect.Height));
|
var s1 = new Rect(new Point(rect.X, rect.Y + layerModel.AnimationProgress),
|
||||||
var s2 = new Rect(new Point(s1.X, s1.Y - rect.Height), new Size(rect.Width, rect.Height + .5));
|
new Size(rect.Width, rect.Height));
|
||||||
|
var s2 = new Rect(new Point(s1.X, s1.Y - rect.Height),
|
||||||
|
new Size(rect.Width, rect.Height + .5));
|
||||||
|
|
||||||
var clip = new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale);
|
var clip = layerModel.LayerRect();
|
||||||
|
|
||||||
c.PushClip(new RectangleGeometry(clip));
|
c.PushClip(new RectangleGeometry(clip));
|
||||||
c.DrawRectangle(applied.Brush, null, s1);
|
c.DrawRectangle(layerModel.Brush, null, s1);
|
||||||
c.DrawRectangle(applied.Brush, null, s2);
|
c.DrawRectangle(layerModel.Brush, null, s2);
|
||||||
c.Pop();
|
c.Pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool MustExpire(LayerModel layer)
|
public bool MustExpire(LayerModel layer)
|
||||||
{
|
{
|
||||||
return layer.Properties.AnimationProgress + layer.Properties.AnimationSpeed*2 >= layer.Properties.Height*4;
|
return layer.AnimationProgress + layer.Properties.AnimationSpeed*2 >= layer.Properties.Height*4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,46 +7,46 @@ namespace Artemis.Profiles.Layers.Animations
|
|||||||
{
|
{
|
||||||
public class SlideLeftAnimation : ILayerAnimation
|
public class SlideLeftAnimation : ILayerAnimation
|
||||||
{
|
{
|
||||||
public string Name { get; } = "Slide left";
|
public string Name => "Slide left";
|
||||||
|
|
||||||
public void Update(LayerModel layerModel, bool updateAnimations)
|
public void Update(LayerModel layerModel, bool updateAnimations)
|
||||||
{
|
{
|
||||||
var progress = layerModel.Properties.AnimationProgress;
|
var progress = layerModel.AnimationProgress;
|
||||||
if (MustExpire(layerModel))
|
if (MustExpire(layerModel))
|
||||||
progress = 0;
|
progress = 0;
|
||||||
progress = progress + layerModel.Properties.AnimationSpeed*2;
|
progress = progress + layerModel.Properties.AnimationSpeed*2;
|
||||||
|
|
||||||
// If not previewing, store the animation progress in the actual model for the next frame
|
// If not previewing, store the animation progress in the actual model for the next frame
|
||||||
if (updateAnimations)
|
if (updateAnimations)
|
||||||
layerModel.Properties.AnimationProgress = progress;
|
layerModel.AnimationProgress = progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c)
|
public void Draw(LayerModel layerModel, DrawingContext c)
|
||||||
{
|
{
|
||||||
if (applied.Brush == null)
|
if (layerModel.Brush == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int scale = 4;
|
|
||||||
// Set up variables for this frame
|
// Set up variables for this frame
|
||||||
var rect = applied.Contain
|
var rect = layerModel.Properties.Contain
|
||||||
? new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale)
|
? layerModel.LayerRect()
|
||||||
: new Rect(props.X*scale, props.Y*scale, props.Width*scale, props.Height*scale);
|
: layerModel.Properties.PropertiesRect();
|
||||||
|
|
||||||
var s1 = new Rect(new Point(rect.X - props.AnimationProgress, rect.Y),
|
var s1 = new Rect(new Point(rect.X - layerModel.AnimationProgress, rect.Y),
|
||||||
new Size(rect.Width + .5, rect.Height));
|
new Size(rect.Width + .5, rect.Height));
|
||||||
var s2 = new Rect(new Point(s1.X + rect.Width, rect.Y), new Size(rect.Width, rect.Height));
|
var s2 = new Rect(new Point(s1.X + rect.Width, rect.Y),
|
||||||
|
new Size(rect.Width, rect.Height));
|
||||||
|
|
||||||
var clip = new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale);
|
var clip = layerModel.LayerRect();
|
||||||
|
|
||||||
c.PushClip(new RectangleGeometry(clip));
|
c.PushClip(new RectangleGeometry(clip));
|
||||||
c.DrawRectangle(applied.Brush, null, s1);
|
c.DrawRectangle(layerModel.Brush, null, s1);
|
||||||
c.DrawRectangle(applied.Brush, null, s2);
|
c.DrawRectangle(layerModel.Brush, null, s2);
|
||||||
c.Pop();
|
c.Pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool MustExpire(LayerModel layer)
|
public bool MustExpire(LayerModel layer)
|
||||||
{
|
{
|
||||||
return layer.Properties.AnimationProgress + layer.Properties.AnimationSpeed*2 >= layer.Properties.Width*4;
|
return layer.AnimationProgress + layer.Properties.AnimationSpeed*2 >= layer.Properties.Width*4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,45 +7,46 @@ namespace Artemis.Profiles.Layers.Animations
|
|||||||
{
|
{
|
||||||
public class SlideRightAnimation : ILayerAnimation
|
public class SlideRightAnimation : ILayerAnimation
|
||||||
{
|
{
|
||||||
public string Name { get; } = "Slide right";
|
public string Name => "Slide right";
|
||||||
|
|
||||||
public void Update(LayerModel layerModel, bool updateAnimations)
|
public void Update(LayerModel layerModel, bool updateAnimations)
|
||||||
{
|
{
|
||||||
var progress = layerModel.Properties.AnimationProgress;
|
var progress = layerModel.AnimationProgress;
|
||||||
if (MustExpire(layerModel))
|
if (MustExpire(layerModel))
|
||||||
progress = 0;
|
progress = 0;
|
||||||
progress = progress + layerModel.Properties.AnimationSpeed*2;
|
progress = progress + layerModel.Properties.AnimationSpeed*2;
|
||||||
|
|
||||||
// If not previewing, store the animation progress in the actual model for the next frame
|
// If not previewing, store the animation progress in the actual model for the next frame
|
||||||
if (updateAnimations)
|
if (updateAnimations)
|
||||||
layerModel.Properties.AnimationProgress = progress;
|
layerModel.AnimationProgress = progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c)
|
public void Draw(LayerModel layerModel, DrawingContext c)
|
||||||
{
|
{
|
||||||
if (applied.Brush == null)
|
if (layerModel.Brush == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int scale = 4;
|
|
||||||
// Set up variables for this frame
|
// Set up variables for this frame
|
||||||
var rect = applied.Contain
|
var rect = layerModel.Properties.Contain
|
||||||
? new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale)
|
? layerModel.LayerRect()
|
||||||
: new Rect(props.X*scale, props.Y*scale, props.Width*scale, props.Height*scale);
|
: layerModel.Properties.PropertiesRect();
|
||||||
|
|
||||||
var s1 = new Rect(new Point(rect.X + props.AnimationProgress, rect.Y), new Size(rect.Width, rect.Height));
|
var s1 = new Rect(new Point(rect.X + layerModel.AnimationProgress, rect.Y),
|
||||||
var s2 = new Rect(new Point(s1.X - rect.Width, rect.Y), new Size(rect.Width + .5, rect.Height));
|
new Size(rect.Width, rect.Height));
|
||||||
|
var s2 = new Rect(new Point(s1.X - rect.Width, rect.Y),
|
||||||
|
new Size(rect.Width + .5, rect.Height));
|
||||||
|
|
||||||
var clip = new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale);
|
var clip = layerModel.LayerRect();
|
||||||
|
|
||||||
c.PushClip(new RectangleGeometry(clip));
|
c.PushClip(new RectangleGeometry(clip));
|
||||||
c.DrawRectangle(applied.Brush, null, s1);
|
c.DrawRectangle(layerModel.Brush, null, s1);
|
||||||
c.DrawRectangle(applied.Brush, null, s2);
|
c.DrawRectangle(layerModel.Brush, null, s2);
|
||||||
c.Pop();
|
c.Pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool MustExpire(LayerModel layer)
|
public bool MustExpire(LayerModel layer)
|
||||||
{
|
{
|
||||||
return layer.Properties.AnimationProgress + layer.Properties.AnimationSpeed*2 >= layer.Properties.Width*4;
|
return layer.AnimationProgress + layer.Properties.AnimationSpeed*2 >= layer.Properties.Width*4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,46 +7,45 @@ namespace Artemis.Profiles.Layers.Animations
|
|||||||
{
|
{
|
||||||
public class SlideUpAnimation : ILayerAnimation
|
public class SlideUpAnimation : ILayerAnimation
|
||||||
{
|
{
|
||||||
public string Name { get; } = "Slide up";
|
public string Name => "Slide up";
|
||||||
|
|
||||||
public void Update(LayerModel layerModel, bool updateAnimations)
|
public void Update(LayerModel layerModel, bool updateAnimations)
|
||||||
{
|
{
|
||||||
var progress = layerModel.Properties.AnimationProgress;
|
var progress = layerModel.AnimationProgress;
|
||||||
if (MustExpire(layerModel))
|
if (MustExpire(layerModel))
|
||||||
progress = 0;
|
progress = 0;
|
||||||
progress = progress + layerModel.Properties.AnimationSpeed*2;
|
progress = progress + layerModel.Properties.AnimationSpeed*2;
|
||||||
|
|
||||||
// If not previewing, store the animation progress in the actual model for the next frame
|
// If not previewing, store the animation progress in the actual model for the next frame
|
||||||
if (updateAnimations)
|
if (updateAnimations)
|
||||||
layerModel.Properties.AnimationProgress = progress;
|
layerModel.AnimationProgress = progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c)
|
public void Draw(LayerModel layerModel, DrawingContext c)
|
||||||
{
|
{
|
||||||
if (applied.Brush == null)
|
if (layerModel.Brush == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const int scale = 4;
|
|
||||||
// Set up variables for this frame
|
// Set up variables for this frame
|
||||||
var rect = applied.Contain
|
var rect = layerModel.Properties.Contain
|
||||||
? new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale)
|
? layerModel.LayerRect()
|
||||||
: new Rect(props.X*scale, props.Y*scale, props.Width*scale, props.Height*scale);
|
: layerModel.Properties.PropertiesRect();
|
||||||
|
|
||||||
var s1 = new Rect(new Point(rect.X, rect.Y - props.AnimationProgress),
|
var s1 = new Rect(new Point(rect.X, rect.Y - layerModel.AnimationProgress),
|
||||||
new Size(rect.Width, rect.Height + .5));
|
new Size(rect.Width, rect.Height + .5));
|
||||||
var s2 = new Rect(new Point(s1.X, s1.Y + rect.Height), new Size(rect.Width, rect.Height));
|
var s2 = new Rect(new Point(s1.X, s1.Y + rect.Height), new Size(rect.Width, rect.Height));
|
||||||
|
|
||||||
var clip = new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale);
|
var clip = layerModel.LayerRect();
|
||||||
|
|
||||||
c.PushClip(new RectangleGeometry(clip));
|
c.PushClip(new RectangleGeometry(clip));
|
||||||
c.DrawRectangle(applied.Brush, null, s1);
|
c.DrawRectangle(layerModel.Brush, null, s1);
|
||||||
c.DrawRectangle(applied.Brush, null, s2);
|
c.DrawRectangle(layerModel.Brush, null, s2);
|
||||||
c.Pop();
|
c.Pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool MustExpire(LayerModel layer)
|
public bool MustExpire(LayerModel layer)
|
||||||
{
|
{
|
||||||
return layer.Properties.AnimationProgress + layer.Properties.AnimationSpeed*2 >= layer.Properties.Height*4;
|
return layer.AnimationProgress + layer.Properties.AnimationSpeed*2 >= layer.Properties.Height*4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,11 +7,11 @@ namespace Artemis.Profiles.Layers.Conditions
|
|||||||
{
|
{
|
||||||
public class DataModelCondition : ILayerCondition
|
public class DataModelCondition : ILayerCondition
|
||||||
{
|
{
|
||||||
public bool ConditionsMet(LayerModel layer, IDataModel dataModel)
|
public bool ConditionsMet(LayerModel layerModel, IDataModel dataModel)
|
||||||
{
|
{
|
||||||
lock (layer.Properties.Conditions)
|
lock (layerModel.Properties.Conditions)
|
||||||
{
|
{
|
||||||
return layer.Properties.Conditions.All(cm => cm.ConditionMet(dataModel));
|
return layerModel.Properties.Conditions.All(cm => cm.ConditionMet(dataModel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,17 +7,17 @@ namespace Artemis.Profiles.Layers.Conditions
|
|||||||
{
|
{
|
||||||
public class EventCondition : ILayerCondition
|
public class EventCondition : ILayerCondition
|
||||||
{
|
{
|
||||||
public bool ConditionsMet(LayerModel layer, IDataModel dataModel)
|
public bool ConditionsMet(LayerModel layerModel, IDataModel dataModel)
|
||||||
{
|
{
|
||||||
lock (layer.Properties.Conditions)
|
lock (layerModel.Properties.Conditions)
|
||||||
{
|
{
|
||||||
var conditionsMet = layer.Properties.Conditions.All(cm => cm.ConditionMet(dataModel));
|
var conditionsMet = layerModel.Properties.Conditions.All(cm => cm.ConditionMet(dataModel));
|
||||||
layer.EventProperties.Update(layer, conditionsMet);
|
layerModel.EventProperties.Update(layerModel, conditionsMet);
|
||||||
|
|
||||||
if (conditionsMet && layer.EventProperties.CanTrigger)
|
if (conditionsMet && layerModel.EventProperties.CanTrigger)
|
||||||
layer.EventProperties.TriggerEvent(layer);
|
layerModel.EventProperties.TriggerEvent(layerModel);
|
||||||
|
|
||||||
return layer.EventProperties.MustDraw;
|
return layerModel.EventProperties.MustDraw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ namespace Artemis.Profiles.Layers.Interfaces
|
|||||||
string Name { get; }
|
string Name { get; }
|
||||||
|
|
||||||
void Update(LayerModel layerModel, bool updateAnimations);
|
void Update(LayerModel layerModel, bool updateAnimations);
|
||||||
void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c);
|
void Draw(LayerModel layerModel, DrawingContext c);
|
||||||
bool MustExpire(LayerModel layer);
|
bool MustExpire(LayerModel layerModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5,6 +5,6 @@ namespace Artemis.Profiles.Layers.Interfaces
|
|||||||
{
|
{
|
||||||
public interface ILayerCondition
|
public interface ILayerCondition
|
||||||
{
|
{
|
||||||
bool ConditionsMet(LayerModel layer, IDataModel dataModel);
|
bool ConditionsMet(LayerModel layerModel, IDataModel dataModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media;
|
|
||||||
using Artemis.Models.Interfaces;
|
using Artemis.Models.Interfaces;
|
||||||
using Artemis.Profiles.Layers.Abstract;
|
using Artemis.Profiles.Layers.Abstract;
|
||||||
using Artemis.Profiles.Layers.Models;
|
using Artemis.Profiles.Layers.Models;
|
||||||
@ -38,9 +37,9 @@ namespace Artemis.Profiles.Layers.Interfaces
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Draws the layer
|
/// Draws the layer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="layer">The layer to draw</param>
|
/// <param name="layerModel">The layer to draw</param>
|
||||||
/// <param name="c">The drawing context to draw with</param>
|
/// <param name="c">The drawing context to draw with</param>
|
||||||
void Draw(LayerModel layer, DrawingContext c);
|
void Draw(LayerModel layerModel, DrawingContext c);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the provided layer layerModel according to this type
|
/// Updates the provided layer layerModel according to this type
|
||||||
@ -61,7 +60,8 @@ namespace Artemis.Profiles.Layers.Interfaces
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="layerEditorViewModel">The layer editor VM this type resides in</param>
|
/// <param name="layerEditorViewModel">The layer editor VM this type resides in</param>
|
||||||
/// <param name="layerPropertiesViewModel">The current viewmodel</param>
|
/// <param name="layerPropertiesViewModel">The current viewmodel</param>
|
||||||
LayerPropertiesViewModel SetupViewModel(LayerEditorViewModel layerEditorViewModel, LayerPropertiesViewModel layerPropertiesViewModel);
|
LayerPropertiesViewModel SetupViewModel(LayerEditorViewModel layerEditorViewModel,
|
||||||
|
LayerPropertiesViewModel layerPropertiesViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum DrawType
|
public enum DrawType
|
||||||
|
|||||||
@ -37,15 +37,15 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public LayerPropertyOptions LayerPropertyOptions { get; set; }
|
public LayerPropertyOptions LayerPropertyOptions { get; set; }
|
||||||
|
|
||||||
internal void ApplyProperty(IDataModel dataModel, LayerPropertiesModel properties)
|
internal void ApplyProperty(IDataModel dataModel, LayerModel layerModel)
|
||||||
{
|
{
|
||||||
if (LayerPropertyType == LayerPropertyType.PercentageOf)
|
if (LayerPropertyType == LayerPropertyType.PercentageOf)
|
||||||
ApplyPercentageOf(dataModel, properties, PercentageSource);
|
ApplyPercentageOf(dataModel, layerModel, PercentageSource);
|
||||||
if (LayerPropertyType == LayerPropertyType.PercentageOfProperty)
|
if (LayerPropertyType == LayerPropertyType.PercentageOfProperty)
|
||||||
ApplyPercentageOfProperty(dataModel, properties);
|
ApplyPercentageOfProperty(dataModel, layerModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyPercentageOf(IDataModel dataModel, LayerPropertiesModel properties, float src)
|
private void ApplyPercentageOf(IDataModel dataModel, LayerModel layerModel, float src)
|
||||||
{
|
{
|
||||||
if (GameProperty == null)
|
if (GameProperty == null)
|
||||||
return;
|
return;
|
||||||
@ -54,61 +54,61 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
var percentage = gameProperty/src;
|
var percentage = gameProperty/src;
|
||||||
|
|
||||||
if (LayerProperty == "Width")
|
if (LayerProperty == "Width")
|
||||||
ApplyWidth(properties, percentage);
|
ApplyWidth(layerModel, percentage);
|
||||||
else if (LayerProperty == "Height")
|
else if (LayerProperty == "Height")
|
||||||
ApplyHeight(properties, percentage);
|
ApplyHeight(layerModel, percentage);
|
||||||
else if (LayerProperty == "Opacity")
|
else if (LayerProperty == "Opacity")
|
||||||
ApplyOpacity(properties, percentage);
|
ApplyOpacity(layerModel, percentage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyWidth(LayerPropertiesModel properties, float percentage)
|
private void ApplyWidth(LayerModel layerModel, float percentage)
|
||||||
{
|
{
|
||||||
var newWidth = Math.Round(percentage*(float) properties.Width, 2);
|
var newWidth = Math.Round(percentage*(float) layerModel.Width, 2);
|
||||||
var difference = properties.Width - newWidth;
|
var difference = layerModel.Width - newWidth;
|
||||||
if (newWidth < 0)
|
if (newWidth < 0)
|
||||||
newWidth = 0;
|
newWidth = 0;
|
||||||
|
|
||||||
properties.Width = newWidth;
|
layerModel.Width = newWidth;
|
||||||
|
|
||||||
// Apply the right to left option
|
// Apply the right to left option
|
||||||
if (LayerPropertyOptions == LayerPropertyOptions.RightToLeft)
|
if (LayerPropertyOptions == LayerPropertyOptions.RightToLeft)
|
||||||
properties.X = properties.X + difference;
|
layerModel.X = layerModel.X + difference;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyHeight(LayerPropertiesModel properties, float percentage)
|
private void ApplyHeight(LayerModel layerModel, float percentage)
|
||||||
{
|
{
|
||||||
var newHeight = Math.Round(percentage*(float) properties.Height, 2);
|
var newHeight = Math.Round(percentage*(float) layerModel.Height, 2);
|
||||||
var difference = properties.Height - newHeight;
|
var difference = layerModel.Height - newHeight;
|
||||||
if (newHeight < 0)
|
if (newHeight < 0)
|
||||||
newHeight = 0;
|
newHeight = 0;
|
||||||
|
|
||||||
properties.Height = newHeight;
|
layerModel.Height = newHeight;
|
||||||
|
|
||||||
if (LayerPropertyOptions == LayerPropertyOptions.Downwards)
|
if (LayerPropertyOptions == LayerPropertyOptions.Downwards)
|
||||||
properties.Y = properties.Y + difference;
|
layerModel.Y = layerModel.Y + difference;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyOpacity(LayerPropertiesModel properties, float percentage)
|
private void ApplyOpacity(LayerModel layerModel, float percentage)
|
||||||
{
|
{
|
||||||
properties.Opacity = percentage*(float) properties.Opacity;
|
layerModel.Opacity = percentage*(float) layerModel.Opacity;
|
||||||
if (properties.Opacity < 0.0)
|
if (layerModel.Opacity < 0.0)
|
||||||
properties.Opacity = 0.0;
|
layerModel.Opacity = 0.0;
|
||||||
if (properties.Opacity > 1.0)
|
if (layerModel.Opacity > 1.0)
|
||||||
properties.Opacity = 1.0;
|
layerModel.Opacity = 1.0;
|
||||||
|
|
||||||
// Apply the inverse/decrease option
|
// Apply the inverse/decrease option
|
||||||
if (LayerPropertyOptions == LayerPropertyOptions.Decrease)
|
if (LayerPropertyOptions == LayerPropertyOptions.Decrease)
|
||||||
properties.Opacity = 1.0 - properties.Opacity;
|
layerModel.Opacity = 1.0 - layerModel.Opacity;
|
||||||
|
|
||||||
var brush = properties.Brush.Clone();
|
var brush = layerModel.Brush.Clone();
|
||||||
brush.Opacity = properties.Opacity;
|
brush.Opacity = layerModel.Opacity;
|
||||||
properties.Brush = brush;
|
layerModel.Brush = brush;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyPercentageOfProperty(IDataModel dataModel, LayerPropertiesModel properties)
|
private void ApplyPercentageOfProperty(IDataModel dataModel, LayerModel layerModel)
|
||||||
{
|
{
|
||||||
var value = dataModel.GetPropValue<float>(PercentageProperty);
|
var value = dataModel.GetPropValue<float>(PercentageProperty);
|
||||||
ApplyPercentageOf(dataModel, properties, value);
|
ApplyPercentageOf(dataModel, layerModel, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Artemis.Profiles.Layers.Models
|
namespace Artemis.Profiles.Layers.Models
|
||||||
@ -20,6 +18,8 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public bool MustDraw { get; set; }
|
public bool MustDraw { get; set; }
|
||||||
|
|
||||||
|
public DateTime EventCanTriggerTime { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resets the event's properties and triggers it
|
/// Resets the event's properties and triggers it
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -42,11 +42,9 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
CanTrigger = false;
|
CanTrigger = false;
|
||||||
MustDraw = true;
|
MustDraw = true;
|
||||||
EventTriggerTime = DateTime.Now;
|
EventTriggerTime = DateTime.Now;
|
||||||
layer.Properties.AnimationProgress = 0.0;
|
layer.AnimationProgress = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime EventCanTriggerTime { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets whether the event should stop
|
/// Gets whether the event should stop
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Artemis.Models.Interfaces;
|
using Artemis.Models.Interfaces;
|
||||||
using Artemis.Profiles.Layers.Animations;
|
using Artemis.Profiles.Layers.Animations;
|
||||||
@ -18,43 +19,18 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
public LayerModel()
|
public LayerModel()
|
||||||
{
|
{
|
||||||
Children = new ChildItemCollection<LayerModel, LayerModel>(this);
|
Children = new ChildItemCollection<LayerModel, LayerModel>(this);
|
||||||
|
TweenModel = new TweenModel(this);
|
||||||
|
|
||||||
var model = Properties as KeyboardPropertiesModel;
|
var model = Properties as KeyboardPropertiesModel;
|
||||||
if (model != null)
|
if (model != null)
|
||||||
GifImage = new GifImage(model.GifFile);
|
GifImage = new GifImage(model.GifFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILayerType LayerType { get; set; }
|
|
||||||
public ILayerCondition LayerCondition { get; set; }
|
|
||||||
public ILayerAnimation LayerAnimation { get; set; }
|
|
||||||
|
|
||||||
public string Name { get; set; }
|
|
||||||
public int Order { get; set; }
|
|
||||||
|
|
||||||
public bool Enabled { get; set; }
|
|
||||||
public bool Expanded { get; set; }
|
|
||||||
public bool IsEvent { get; set; }
|
|
||||||
public LayerPropertiesModel Properties { get; set; }
|
|
||||||
public EventPropertiesModel EventProperties { get; set; }
|
|
||||||
public ChildItemCollection<LayerModel, LayerModel> Children { get; }
|
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public LayerPropertiesModel AppliedProperties { get; set; }
|
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public ImageSource LayerImage => LayerType.DrawThumbnail(this);
|
public ImageSource LayerImage => LayerType.DrawThumbnail(this);
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public LayerModel Parent { get; internal set; }
|
public TweenModel TweenModel { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public ProfileModel Profile { get; internal set; }
|
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public GifImage GifImage { get; set; }
|
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public DateTime LastRender { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks whether this layers conditions are met.
|
/// Checks whether this layers conditions are met.
|
||||||
@ -68,19 +44,59 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
return Enabled && LayerCondition.ConditionsMet(this, dataModel);
|
return Enabled && LayerCondition.ConditionsMet(this, dataModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update the layer
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dataModel"></param>
|
||||||
|
/// <param name="preview"></param>
|
||||||
|
/// <param name="updateAnimations"></param>
|
||||||
public void Update(IDataModel dataModel, bool preview, bool updateAnimations)
|
public void Update(IDataModel dataModel, bool preview, bool updateAnimations)
|
||||||
{
|
{
|
||||||
LayerType.Update(this, dataModel, preview);
|
LayerType.Update(this, dataModel, preview);
|
||||||
LayerAnimation?.Update(this, updateAnimations);
|
LayerAnimation?.Update(this, updateAnimations);
|
||||||
|
|
||||||
|
if (!preview && updateAnimations)
|
||||||
|
TweenModel.Update();
|
||||||
|
|
||||||
LastRender = DateTime.Now;
|
LastRender = DateTime.Now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applies the saved properties to the current properties
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="advanced">Include advanced properties (opacity, brush)</param>
|
||||||
|
public void ApplyProperties(bool advanced)
|
||||||
|
{
|
||||||
|
X = Properties.X;
|
||||||
|
Y = Properties.Y;
|
||||||
|
Width = Properties.Width;
|
||||||
|
Height = Properties.Height;
|
||||||
|
|
||||||
|
if (!advanced)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Opacity = Properties.Opacity;
|
||||||
|
Brush = Properties.Brush;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draw the layer using the provided context
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dataModel"></param>
|
||||||
|
/// <param name="c"></param>
|
||||||
|
/// <param name="preview"></param>
|
||||||
|
/// <param name="updateAnimations"></param>
|
||||||
public void Draw(IDataModel dataModel, DrawingContext c, bool preview, bool updateAnimations)
|
public void Draw(IDataModel dataModel, DrawingContext c, bool preview, bool updateAnimations)
|
||||||
{
|
{
|
||||||
|
if (Brush == null)
|
||||||
|
return;
|
||||||
|
|
||||||
LayerType.Draw(this, c);
|
LayerType.Draw(this, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tells the current layer type to setup the layer's LayerProperties
|
||||||
|
/// </summary>
|
||||||
public void SetupProperties()
|
public void SetupProperties()
|
||||||
{
|
{
|
||||||
LayerType.SetupProperties(this);
|
LayerType.SetupProperties(this);
|
||||||
@ -97,6 +113,9 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ensures all child layers have a unique order
|
||||||
|
/// </summary>
|
||||||
public void FixOrder()
|
public void FixOrder()
|
||||||
{
|
{
|
||||||
Children.Sort(l => l.Order);
|
Children.Sort(l => l.Order);
|
||||||
@ -158,23 +177,41 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
Width = 1,
|
Width = 1,
|
||||||
X = 0,
|
X = 0,
|
||||||
Y = 0,
|
Y = 0,
|
||||||
Opacity = 1
|
Opacity = 1,
|
||||||
|
HeightEaseTime = 0,
|
||||||
|
HeightEase = "Linear",
|
||||||
|
WidthEaseTime = 0,
|
||||||
|
WidthEase = "Linear",
|
||||||
|
OpacityEaseTime = 0,
|
||||||
|
OpacityEase = "Linear"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Insert this layer before the given layer
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
public void InsertBefore(LayerModel source)
|
public void InsertBefore(LayerModel source)
|
||||||
{
|
{
|
||||||
source.Order = Order;
|
source.Order = Order;
|
||||||
Insert(source);
|
Insert(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Insert this layer after the given layer
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
public void InsertAfter(LayerModel source)
|
public void InsertAfter(LayerModel source)
|
||||||
{
|
{
|
||||||
source.Order = Order + 1;
|
source.Order = Order + 1;
|
||||||
Insert(source);
|
Insert(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Insert the layer as a sibling
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source"></param>
|
||||||
private void Insert(LayerModel source)
|
private void Insert(LayerModel source)
|
||||||
{
|
{
|
||||||
if (Parent != null)
|
if (Parent != null)
|
||||||
@ -197,11 +234,22 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Rect LayerRect(int scale = 4)
|
||||||
|
{
|
||||||
|
var width = Width;
|
||||||
|
var height = Height;
|
||||||
|
if (width < 0)
|
||||||
|
width = 0;
|
||||||
|
if (height < 0)
|
||||||
|
height = 0;
|
||||||
|
|
||||||
|
return new Rect(X*scale, Y*scale, width*scale, height*scale);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generates a flat list containing all layers that must be rendered on the keyboard,
|
/// Generates a flat list containing all layers that must be rendered on the keyboard,
|
||||||
/// the first mouse layer to be rendered and the first headset layer to be rendered
|
/// the first mouse layer to be rendered and the first headset layer to be rendered
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">The game data model to base the conditions on</typeparam>
|
|
||||||
/// <param name="dataModel">Instance of said game data model</param>
|
/// <param name="dataModel">Instance of said game data model</param>
|
||||||
/// <param name="keyboardOnly">Whether or not to ignore anything but keyboards</param>
|
/// <param name="keyboardOnly">Whether or not to ignore anything but keyboards</param>
|
||||||
/// <param name="ignoreConditions"></param>
|
/// <param name="ignoreConditions"></param>
|
||||||
@ -227,6 +275,105 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
return layers;
|
return layers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetupCondition()
|
||||||
|
{
|
||||||
|
if (IsEvent && !(LayerCondition is EventCondition))
|
||||||
|
LayerCondition = new EventCondition();
|
||||||
|
else if (!IsEvent && !(LayerCondition is DataModelCondition))
|
||||||
|
LayerCondition = new DataModelCondition();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
#region Layer type properties
|
||||||
|
|
||||||
|
public ILayerType LayerType { get; set; }
|
||||||
|
public ILayerCondition LayerCondition { get; set; }
|
||||||
|
public ILayerAnimation LayerAnimation { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Generic properties
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
public int Order { get; set; }
|
||||||
|
public bool Enabled { get; set; }
|
||||||
|
public bool Expanded { get; set; }
|
||||||
|
public bool IsEvent { get; set; }
|
||||||
|
public LayerPropertiesModel Properties { get; set; }
|
||||||
|
public EventPropertiesModel EventProperties { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Relational properties
|
||||||
|
|
||||||
|
public ChildItemCollection<LayerModel, LayerModel> Children { get; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public LayerModel Parent { get; internal set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public ProfileModel Profile { get; internal set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Render properties
|
||||||
|
|
||||||
|
[JsonIgnore] private Brush _brush;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public double X { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public double Y { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public double Width { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public double Height { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public double Opacity { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public Brush Brush
|
||||||
|
{
|
||||||
|
get { return _brush; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
_brush = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value.IsFrozen)
|
||||||
|
{
|
||||||
|
_brush = value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clone the brush off of the UI thread and freeze it
|
||||||
|
var cloned = value.Dispatcher.Invoke(value.CloneCurrentValue);
|
||||||
|
cloned.Freeze();
|
||||||
|
_brush = cloned;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public double AnimationProgress { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public GifImage GifImage { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public DateTime LastRender { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region IChildItem<Parent> Members
|
#region IChildItem<Parent> Members
|
||||||
|
|
||||||
LayerModel IChildItem<LayerModel>.Parent
|
LayerModel IChildItem<LayerModel>.Parent
|
||||||
@ -242,13 +389,5 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public void SetupCondition()
|
|
||||||
{
|
|
||||||
if (IsEvent && !(LayerCondition is EventCondition))
|
|
||||||
LayerCondition = new EventCondition();
|
|
||||||
else if (!IsEvent && !(LayerCondition is DataModelCondition))
|
|
||||||
LayerCondition = new DataModelCondition();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -26,6 +26,12 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
Conditions = source.Conditions;
|
Conditions = source.Conditions;
|
||||||
DynamicProperties = source.DynamicProperties;
|
DynamicProperties = source.DynamicProperties;
|
||||||
Brush = source.Brush;
|
Brush = source.Brush;
|
||||||
|
HeightEase = source.HeightEase;
|
||||||
|
WidthEase = source.WidthEase;
|
||||||
|
OpacityEase = source.OpacityEase;
|
||||||
|
HeightEaseTime = source.HeightEaseTime;
|
||||||
|
WidthEaseTime = source.WidthEaseTime;
|
||||||
|
OpacityEaseTime = source.OpacityEaseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double X { get; set; }
|
public double X { get; set; }
|
||||||
@ -35,12 +41,15 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
public bool Contain { get; set; }
|
public bool Contain { get; set; }
|
||||||
public double Opacity { get; set; }
|
public double Opacity { get; set; }
|
||||||
public double AnimationSpeed { get; set; }
|
public double AnimationSpeed { get; set; }
|
||||||
|
public double OpacityEaseTime { get; set; }
|
||||||
|
public double HeightEaseTime { get; set; }
|
||||||
|
public double WidthEaseTime { get; set; }
|
||||||
|
public string WidthEase { set; get; }
|
||||||
|
public string HeightEase { get; set; }
|
||||||
|
public string OpacityEase { get; set; }
|
||||||
public List<LayerConditionModel> Conditions { get; set; } = new List<LayerConditionModel>();
|
public List<LayerConditionModel> Conditions { get; set; } = new List<LayerConditionModel>();
|
||||||
public List<DynamicPropertiesModel> DynamicProperties { get; set; } = new List<DynamicPropertiesModel>();
|
public List<DynamicPropertiesModel> DynamicProperties { get; set; } = new List<DynamicPropertiesModel>();
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
public double AnimationProgress { get; set; }
|
|
||||||
|
|
||||||
[JsonConverter(typeof(BrushJsonConverter))]
|
[JsonConverter(typeof(BrushJsonConverter))]
|
||||||
public Brush Brush
|
public Brush Brush
|
||||||
{
|
{
|
||||||
@ -66,7 +75,7 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rect GetRect(int scale = 4)
|
public Rect PropertiesRect(int scale = 4)
|
||||||
{
|
{
|
||||||
return new Rect(X*scale, Y*scale, Width*scale, Height*scale);
|
return new Rect(X*scale, Y*scale, Width*scale, Height*scale);
|
||||||
}
|
}
|
||||||
|
|||||||
99
Artemis/Artemis/Profiles/Layers/Models/TweenModel.cs
Normal file
99
Artemis/Artemis/Profiles/Layers/Models/TweenModel.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
using System;
|
||||||
|
using Betwixt;
|
||||||
|
|
||||||
|
namespace Artemis.Profiles.Layers.Models
|
||||||
|
{
|
||||||
|
public class TweenModel
|
||||||
|
{
|
||||||
|
private readonly LayerModel _layerModel;
|
||||||
|
private Tweener<float> _xTweener;
|
||||||
|
private Tweener<float> _yTweener;
|
||||||
|
private float _width;
|
||||||
|
private Tweener<float> _widthTweener;
|
||||||
|
private float _height;
|
||||||
|
private Tweener<float> _heightTweener;
|
||||||
|
private float _opacity;
|
||||||
|
private Tweener<float> _opacityTweener;
|
||||||
|
private float _x;
|
||||||
|
private float _y;
|
||||||
|
|
||||||
|
public TweenModel(LayerModel layerModel)
|
||||||
|
{
|
||||||
|
_layerModel = layerModel;
|
||||||
|
_xTweener = new Tweener<float>((float) layerModel.X, (float) layerModel.X, 0);
|
||||||
|
_yTweener = new Tweener<float>((float) layerModel.Y, (float) layerModel.Y, 0);
|
||||||
|
_widthTweener = new Tweener<float>((float) layerModel.Width, (float) layerModel.Width, 0);
|
||||||
|
_heightTweener = new Tweener<float>((float) layerModel.Height, (float) layerModel.Height, 0);
|
||||||
|
_opacityTweener = new Tweener<float>((float) layerModel.Opacity, (float) layerModel.Opacity, 0);
|
||||||
|
|
||||||
|
StoreCurrentValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update()
|
||||||
|
{
|
||||||
|
// Width
|
||||||
|
if (Math.Abs(_layerModel.Width - _width) > 0.001)
|
||||||
|
{
|
||||||
|
var widthFunc = GetEaseFunction(_layerModel.Properties.WidthEase);
|
||||||
|
var widthSpeed = _layerModel.Properties.WidthEaseTime;
|
||||||
|
|
||||||
|
_xTweener = new Tweener<float>(_xTweener.Value, (float) _layerModel.X, widthSpeed, widthFunc);
|
||||||
|
_widthTweener = new Tweener<float>(_widthTweener.Value, (float) _layerModel.Width, widthSpeed, widthFunc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Height
|
||||||
|
if (Math.Abs(_layerModel.Height - _height) > 0.001)
|
||||||
|
{
|
||||||
|
var heightFunc = GetEaseFunction(_layerModel.Properties.HeightEase);
|
||||||
|
var heightSpeed = _layerModel.Properties.HeightEaseTime;
|
||||||
|
_yTweener = new Tweener<float>(_y, (float) _layerModel.Y, heightSpeed, heightFunc);
|
||||||
|
_heightTweener = new Tweener<float>(_height, (float) _layerModel.Height, heightSpeed, heightFunc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Opacity
|
||||||
|
if (Math.Abs(_layerModel.Opacity - _opacity) > 0.001)
|
||||||
|
{
|
||||||
|
_opacityTweener = new Tweener<float>(_opacity, (float) _layerModel.Opacity,
|
||||||
|
_layerModel.Properties.OpacityEaseTime, GetEaseFunction(_layerModel.Properties.OpacityEase));
|
||||||
|
}
|
||||||
|
|
||||||
|
_xTweener.Update(40);
|
||||||
|
_yTweener.Update(40);
|
||||||
|
_widthTweener.Update(40);
|
||||||
|
_heightTweener.Update(40);
|
||||||
|
_opacityTweener.Update(40);
|
||||||
|
|
||||||
|
StoreCurrentValues();
|
||||||
|
|
||||||
|
_layerModel.X = _xTweener.Value;
|
||||||
|
_layerModel.Y = _yTweener.Value;
|
||||||
|
_layerModel.Width = _widthTweener.Value;
|
||||||
|
_layerModel.Height = _heightTweener.Value;
|
||||||
|
_layerModel.Opacity = _opacityTweener.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StoreCurrentValues()
|
||||||
|
{
|
||||||
|
_x = (float) _layerModel.X;
|
||||||
|
_y = (float) _layerModel.Y;
|
||||||
|
_width = (float) _layerModel.Width;
|
||||||
|
_height = (float) _layerModel.Height;
|
||||||
|
_opacity = (float) _layerModel.Opacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static EaseFunc GetEaseFunction(string functionName)
|
||||||
|
{
|
||||||
|
switch (functionName)
|
||||||
|
{
|
||||||
|
case "In":
|
||||||
|
return Ease.Quint.In;
|
||||||
|
case "Out":
|
||||||
|
return Ease.Quint.Out;
|
||||||
|
case "In/out":
|
||||||
|
return Ease.Quint.InOut;
|
||||||
|
default:
|
||||||
|
return Ease.Linear;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -12,31 +12,37 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.AmbienceCreator
|
|||||||
int targetWidth, int targetHeight,
|
int targetWidth, int targetHeight,
|
||||||
AmbientLightPropertiesModel settings)
|
AmbientLightPropertiesModel settings)
|
||||||
{
|
{
|
||||||
AvgColor[] colors = new AvgColor[targetWidth];
|
var colors = new AvgColor[targetWidth];
|
||||||
for (int i = 0; i < colors.Length; i++)
|
for (var i = 0; i < colors.Length; i++)
|
||||||
colors[i] = new AvgColor();
|
colors[i] = new AvgColor();
|
||||||
|
|
||||||
int offsetLeft = settings.OffsetLeft + (settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Left)
|
var offsetLeft = settings.OffsetLeft + (settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Left)
|
||||||
? pixels.DetectBlackBarLeft(sourceWidth, sourceHeight, settings.OffsetLeft, settings.OffsetRight, settings.OffsetTop, settings.OffsetBottom)
|
? pixels.DetectBlackBarLeft(sourceWidth, sourceHeight, settings.OffsetLeft, settings.OffsetRight,
|
||||||
|
settings.OffsetTop, settings.OffsetBottom)
|
||||||
: 0);
|
: 0);
|
||||||
int offsetRight = settings.OffsetRight + (settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Right)
|
var offsetRight = settings.OffsetRight +
|
||||||
? pixels.DetectBlackBarRight(sourceWidth, sourceHeight, settings.OffsetLeft, settings.OffsetRight, settings.OffsetTop, settings.OffsetBottom)
|
(settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Right)
|
||||||
|
? pixels.DetectBlackBarRight(sourceWidth, sourceHeight, settings.OffsetLeft,
|
||||||
|
settings.OffsetRight, settings.OffsetTop, settings.OffsetBottom)
|
||||||
: 0);
|
: 0);
|
||||||
int offsetTop = settings.OffsetTop + (settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Top)
|
var offsetTop = settings.OffsetTop + (settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Top)
|
||||||
? pixels.DetectBlackBarTop(sourceWidth, sourceHeight, settings.OffsetLeft, settings.OffsetRight, settings.OffsetTop, settings.OffsetBottom)
|
? pixels.DetectBlackBarTop(sourceWidth, sourceHeight, settings.OffsetLeft, settings.OffsetRight,
|
||||||
|
settings.OffsetTop, settings.OffsetBottom)
|
||||||
: 0);
|
: 0);
|
||||||
int offsetBottom = settings.OffsetBottom + (settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Bottom)
|
var offsetBottom = settings.OffsetBottom +
|
||||||
? pixels.DetectBlackBarBottom(sourceWidth, sourceHeight, settings.OffsetLeft, settings.OffsetRight, settings.OffsetTop, settings.OffsetBottom)
|
(settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Bottom)
|
||||||
|
? pixels.DetectBlackBarBottom(sourceWidth, sourceHeight, settings.OffsetLeft,
|
||||||
|
settings.OffsetRight, settings.OffsetTop, settings.OffsetBottom)
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
int effectiveSourceWidth = sourceWidth - offsetLeft - offsetRight;
|
var effectiveSourceWidth = sourceWidth - offsetLeft - offsetRight;
|
||||||
int effectiveSourceHeight = sourceHeight - offsetTop - offsetBottom;
|
var effectiveSourceHeight = sourceHeight - offsetTop - offsetBottom;
|
||||||
|
|
||||||
int relevantSourceHeight = (int)Math.Round(effectiveSourceHeight * (settings.MirroredAmount / 100.0));
|
var relevantSourceHeight = (int) Math.Round(effectiveSourceHeight*(settings.MirroredAmount/100.0));
|
||||||
int relevantOffsetTop = sourceHeight - offsetBottom - relevantSourceHeight;
|
var relevantOffsetTop = sourceHeight - offsetBottom - relevantSourceHeight;
|
||||||
|
|
||||||
double widthPixels = effectiveSourceWidth / (double)targetWidth;
|
var widthPixels = effectiveSourceWidth/(double) targetWidth;
|
||||||
double heightPixels = relevantSourceHeight / (double)targetHeight;
|
var heightPixels = relevantSourceHeight/(double) targetHeight;
|
||||||
|
|
||||||
if (widthPixels <= 0 || heightPixels <= 0 || (relevantSourceHeight + relevantOffsetTop > sourceHeight) ||
|
if (widthPixels <= 0 || heightPixels <= 0 || (relevantSourceHeight + relevantOffsetTop > sourceHeight) ||
|
||||||
effectiveSourceWidth > sourceWidth)
|
effectiveSourceWidth > sourceWidth)
|
||||||
@ -45,13 +51,13 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.AmbienceCreator
|
|||||||
return colors.ToBGRArray();
|
return colors.ToBGRArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
int increment = Math.Max(1, Math.Min(20, settings.Downsampling));
|
var increment = Math.Max(1, Math.Min(20, settings.Downsampling));
|
||||||
for (int y = 0; y < relevantSourceHeight; y += increment)
|
for (var y = 0; y < relevantSourceHeight; y += increment)
|
||||||
{
|
{
|
||||||
int targetWidthIndex = 0;
|
var targetWidthIndex = 0;
|
||||||
double widthCounter = widthPixels;
|
var widthCounter = widthPixels;
|
||||||
|
|
||||||
for (int x = 0; x < effectiveSourceWidth; x += increment)
|
for (var x = 0; x < effectiveSourceWidth; x += increment)
|
||||||
{
|
{
|
||||||
if (x >= widthCounter)
|
if (x >= widthCounter)
|
||||||
{
|
{
|
||||||
@ -59,10 +65,10 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.AmbienceCreator
|
|||||||
targetWidthIndex++;
|
targetWidthIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int colorsOffset = targetWidthIndex;
|
var colorsOffset = targetWidthIndex;
|
||||||
int sourceOffset = ((((relevantOffsetTop + y) * sourceWidth) + offsetLeft + x) * 4);
|
var sourceOffset = ((relevantOffsetTop + y)*sourceWidth + offsetLeft + x)*4;
|
||||||
|
|
||||||
AvgColor color = colors[colorsOffset];
|
var color = colors[colorsOffset];
|
||||||
color.AddB(pixels[sourceOffset]);
|
color.AddB(pixels[sourceOffset]);
|
||||||
color.AddG(pixels[sourceOffset + 1]);
|
color.AddG(pixels[sourceOffset + 1]);
|
||||||
color.AddR(pixels[sourceOffset + 2]);
|
color.AddR(pixels[sourceOffset + 2]);
|
||||||
|
|||||||
@ -12,40 +12,47 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.AmbienceCreator
|
|||||||
int targetWidth, int targetHeight,
|
int targetWidth, int targetHeight,
|
||||||
AmbientLightPropertiesModel settings)
|
AmbientLightPropertiesModel settings)
|
||||||
{
|
{
|
||||||
AvgColor[] colors = new AvgColor[targetWidth * targetHeight];
|
var colors = new AvgColor[targetWidth*targetHeight];
|
||||||
for (int i = 0; i < colors.Length; i++)
|
for (var i = 0; i < colors.Length; i++)
|
||||||
colors[i] = new AvgColor();
|
colors[i] = new AvgColor();
|
||||||
|
|
||||||
int offsetLeft = settings.OffsetLeft + (settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Left)
|
var offsetLeft = settings.OffsetLeft + (settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Left)
|
||||||
? pixels.DetectBlackBarLeft(sourceWidth, sourceHeight, settings.OffsetLeft, settings.OffsetRight, settings.OffsetTop, settings.OffsetBottom)
|
? pixels.DetectBlackBarLeft(sourceWidth, sourceHeight, settings.OffsetLeft, settings.OffsetRight,
|
||||||
|
settings.OffsetTop, settings.OffsetBottom)
|
||||||
: 0);
|
: 0);
|
||||||
int offsetRight = settings.OffsetRight + (settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Right)
|
var offsetRight = settings.OffsetRight +
|
||||||
? pixels.DetectBlackBarRight(sourceWidth, sourceHeight, settings.OffsetLeft, settings.OffsetRight, settings.OffsetTop, settings.OffsetBottom)
|
(settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Right)
|
||||||
|
? pixels.DetectBlackBarRight(sourceWidth, sourceHeight, settings.OffsetLeft,
|
||||||
|
settings.OffsetRight, settings.OffsetTop, settings.OffsetBottom)
|
||||||
: 0);
|
: 0);
|
||||||
int offsetTop = settings.OffsetTop + (settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Top)
|
var offsetTop = settings.OffsetTop + (settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Top)
|
||||||
? pixels.DetectBlackBarTop(sourceWidth, sourceHeight, settings.OffsetLeft, settings.OffsetRight, settings.OffsetTop, settings.OffsetBottom)
|
? pixels.DetectBlackBarTop(sourceWidth, sourceHeight, settings.OffsetLeft, settings.OffsetRight,
|
||||||
|
settings.OffsetTop, settings.OffsetBottom)
|
||||||
: 0);
|
: 0);
|
||||||
int offsetBottom = settings.OffsetBottom + (settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Bottom)
|
var offsetBottom = settings.OffsetBottom +
|
||||||
? pixels.DetectBlackBarBottom(sourceWidth, sourceHeight, settings.OffsetLeft, settings.OffsetRight, settings.OffsetTop, settings.OffsetBottom)
|
(settings.BlackBarDetectionMode.HasFlag(BlackBarDetectionMode.Bottom)
|
||||||
|
? pixels.DetectBlackBarBottom(sourceWidth, sourceHeight, settings.OffsetLeft,
|
||||||
|
settings.OffsetRight, settings.OffsetTop, settings.OffsetBottom)
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
int effectiveSourceWidth = sourceWidth - offsetLeft - offsetRight;
|
var effectiveSourceWidth = sourceWidth - offsetLeft - offsetRight;
|
||||||
int effectiveSourceHeight = sourceHeight - offsetTop - offsetBottom;
|
var effectiveSourceHeight = sourceHeight - offsetTop - offsetBottom;
|
||||||
|
|
||||||
int relevantSourceHeight = (int)Math.Round(effectiveSourceHeight * (settings.MirroredAmount / 100.0));
|
var relevantSourceHeight = (int) Math.Round(effectiveSourceHeight*(settings.MirroredAmount/100.0));
|
||||||
int relevantOffsetTop = sourceHeight - offsetBottom - relevantSourceHeight;
|
var relevantOffsetTop = sourceHeight - offsetBottom - relevantSourceHeight;
|
||||||
|
|
||||||
double widthPixels = effectiveSourceWidth / (double)targetWidth;
|
var widthPixels = effectiveSourceWidth/(double) targetWidth;
|
||||||
double heightPixels = relevantSourceHeight / (double)targetHeight;
|
var heightPixels = relevantSourceHeight/(double) targetHeight;
|
||||||
|
|
||||||
if (widthPixels <= 0 || heightPixels <= 0 || (relevantSourceHeight + relevantOffsetTop > sourceHeight) || effectiveSourceWidth > sourceWidth)
|
if (widthPixels <= 0 || heightPixels <= 0 || (relevantSourceHeight + relevantOffsetTop > sourceHeight) ||
|
||||||
|
effectiveSourceWidth > sourceWidth)
|
||||||
return colors.ToBGRArray();
|
return colors.ToBGRArray();
|
||||||
|
|
||||||
int targetHeightIndex = 0;
|
var targetHeightIndex = 0;
|
||||||
double heightCounter = heightPixels;
|
var heightCounter = heightPixels;
|
||||||
|
|
||||||
int increment = Math.Max(1, Math.Min(20, settings.Downsampling));
|
var increment = Math.Max(1, Math.Min(20, settings.Downsampling));
|
||||||
for (int y = 0; y < relevantSourceHeight; y += increment)
|
for (var y = 0; y < relevantSourceHeight; y += increment)
|
||||||
{
|
{
|
||||||
if (y >= heightCounter)
|
if (y >= heightCounter)
|
||||||
{
|
{
|
||||||
@ -53,10 +60,10 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.AmbienceCreator
|
|||||||
targetHeightIndex++;
|
targetHeightIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int targetWidthIndex = 0;
|
var targetWidthIndex = 0;
|
||||||
double widthCounter = widthPixels;
|
var widthCounter = widthPixels;
|
||||||
|
|
||||||
for (int x = 0; x < effectiveSourceWidth; x += increment)
|
for (var x = 0; x < effectiveSourceWidth; x += increment)
|
||||||
{
|
{
|
||||||
if (x >= widthCounter)
|
if (x >= widthCounter)
|
||||||
{
|
{
|
||||||
@ -64,10 +71,10 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.AmbienceCreator
|
|||||||
targetWidthIndex++;
|
targetWidthIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int colorsOffset = (targetHeightIndex * targetWidth) + targetWidthIndex;
|
var colorsOffset = targetHeightIndex*targetWidth + targetWidthIndex;
|
||||||
int sourceOffset = ((((relevantOffsetTop + y) * sourceWidth) + offsetLeft + x) * 4);
|
var sourceOffset = ((relevantOffsetTop + y)*sourceWidth + offsetLeft + x)*4;
|
||||||
|
|
||||||
AvgColor color = colors[colorsOffset];
|
var color = colors[colorsOffset];
|
||||||
color.AddB(pixels[sourceOffset]);
|
color.AddB(pixels[sourceOffset]);
|
||||||
color.AddG(pixels[sourceOffset + 1]);
|
color.AddG(pixels[sourceOffset + 1]);
|
||||||
color.AddR(pixels[sourceOffset + 2]);
|
color.AddR(pixels[sourceOffset + 2]);
|
||||||
|
|||||||
@ -4,16 +4,16 @@
|
|||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
private int _rCount = 0;
|
private int _rCount;
|
||||||
private int _r = 0;
|
private int _r;
|
||||||
private int _gCount = 0;
|
private int _gCount;
|
||||||
private int _g = 0;
|
private int _g;
|
||||||
private int _bCount = 0;
|
private int _bCount;
|
||||||
private int _b = 0;
|
private int _b;
|
||||||
|
|
||||||
public byte R => (byte)(_rCount > 0 ? (_r / _rCount) : 0);
|
public byte R => (byte) (_rCount > 0 ? _r/_rCount : 0);
|
||||||
public byte G => (byte)(_gCount > 0 ? (_g / _gCount) : 0);
|
public byte G => (byte) (_gCount > 0 ? _g/_gCount : 0);
|
||||||
public byte B => (byte)(_bCount > 0 ? (_b / _bCount) : 0);
|
public byte B => (byte) (_bCount > 0 ? _b/_bCount : 0);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
{
|
{
|
||||||
public interface IAmbienceCreator
|
public interface IAmbienceCreator
|
||||||
{
|
{
|
||||||
byte[] GetAmbience(byte[] pixels, int sourceWidth, int sourceHeight, int targetWidth, int targetHeight, AmbientLightPropertiesModel settings);
|
byte[] GetAmbience(byte[] pixels, int sourceWidth, int sourceHeight, int targetWidth, int targetHeight,
|
||||||
|
AmbientLightPropertiesModel settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7,6 +7,16 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight
|
|||||||
{
|
{
|
||||||
public class AmbientLightPropertiesModel : LayerPropertiesModel
|
public class AmbientLightPropertiesModel : LayerPropertiesModel
|
||||||
{
|
{
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
public AmbientLightPropertiesModel(LayerPropertiesModel properties)
|
||||||
|
: base(properties)
|
||||||
|
{
|
||||||
|
Brush = new SolidColorBrush(Color.FromRgb(0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
//HACK DarthAffe 30.10.2016: The 'normal' Brush-Property destoys the profile since Drawing-Brushes cannot be deserialized.
|
//HACK DarthAffe 30.10.2016: The 'normal' Brush-Property destoys the profile since Drawing-Brushes cannot be deserialized.
|
||||||
@ -28,15 +38,5 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight
|
|||||||
public FlipMode FlipMode { get; set; } = FlipMode.Vertical;
|
public FlipMode FlipMode { get; set; } = FlipMode.Vertical;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
|
||||||
|
|
||||||
public AmbientLightPropertiesModel(LayerPropertiesModel properties)
|
|
||||||
: base(properties)
|
|
||||||
{
|
|
||||||
Brush = new SolidColorBrush(Color.FromRgb(0, 0, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,7 +51,8 @@
|
|||||||
<!-- AmbienceCreatorType -->
|
<!-- AmbienceCreatorType -->
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0" Margin="10,13,10,10" FontSize="13.333" Text="Ambilight-Mode:"
|
<TextBlock Grid.Row="0" Grid.Column="0" Margin="10,13,10,10" FontSize="13.333" Text="Ambilight-Mode:"
|
||||||
VerticalAlignment="Top" Height="18" />
|
VerticalAlignment="Top" Height="18" />
|
||||||
<ComboBox Grid.Row="0" Grid.Column="1" ItemsSource="{Binding Source={StaticResource AmbienceCreatorTypeValues}}"
|
<ComboBox Grid.Row="0" Grid.Column="1"
|
||||||
|
ItemsSource="{Binding Source={StaticResource AmbienceCreatorTypeValues}}"
|
||||||
Margin="10,10,10,0" SelectedItem="{Binding Path=LayerModel.Properties.AmbienceCreatorType}"
|
Margin="10,10,10,0" SelectedItem="{Binding Path=LayerModel.Properties.AmbienceCreatorType}"
|
||||||
VerticalAlignment="Top" Height="22">
|
VerticalAlignment="Top" Height="22">
|
||||||
<ComboBox.ItemTemplate>
|
<ComboBox.ItemTemplate>
|
||||||
@ -65,12 +66,14 @@
|
|||||||
<TextBlock Grid.Row="1" Grid.Column="0" Margin="10,13,10,10" FontSize="13.333" Text="Mirrored Amount (%):"
|
<TextBlock Grid.Row="1" Grid.Column="0" Margin="10,13,10,10" FontSize="13.333" Text="Mirrored Amount (%):"
|
||||||
Height="18" VerticalAlignment="Top" />
|
Height="18" VerticalAlignment="Top" />
|
||||||
<controls:NumericUpDown Grid.Row="1" Grid.Column="1" VerticalAlignment="Top" Minimum="0" Maximum="100"
|
<controls:NumericUpDown Grid.Row="1" Grid.Column="1" VerticalAlignment="Top" Minimum="0" Maximum="100"
|
||||||
Value="{Binding Path=LayerModel.Properties.MirroredAmount, Mode=TwoWay}" Margin="10,12,10,2" Height="24" />
|
Value="{Binding Path=LayerModel.Properties.MirroredAmount, Mode=TwoWay}"
|
||||||
|
Margin="10,12,10,2" Height="24" />
|
||||||
|
|
||||||
<TextBlock Grid.Row="1" Grid.Column="2" Margin="10,13,10,10" FontSize="13.333" Text="Downsampling:"
|
<TextBlock Grid.Row="1" Grid.Column="2" Margin="10,13,10,10" FontSize="13.333" Text="Downsampling:"
|
||||||
Height="18" VerticalAlignment="Top" />
|
Height="18" VerticalAlignment="Top" />
|
||||||
<controls:NumericUpDown Grid.Row="1" Grid.Column="3" VerticalAlignment="Top" Minimum="1" Maximum="20"
|
<controls:NumericUpDown Grid.Row="1" Grid.Column="3" VerticalAlignment="Top" Minimum="1" Maximum="20"
|
||||||
Value="{Binding Path=LayerModel.Properties.Downsampling, Mode=TwoWay}" Margin="10,12,10,2" Height="24" />
|
Value="{Binding Path=LayerModel.Properties.Downsampling, Mode=TwoWay}"
|
||||||
|
Margin="10,12,10,2" Height="24" />
|
||||||
|
|
||||||
<!-- SmoothMode -->
|
<!-- SmoothMode -->
|
||||||
<TextBlock Grid.Row="2" Grid.Column="0" Margin="10,13,10,10" FontSize="13.333" Text="Smoothing:"
|
<TextBlock Grid.Row="2" Grid.Column="0" Margin="10,13,10,10" FontSize="13.333" Text="Smoothing:"
|
||||||
@ -105,23 +108,27 @@
|
|||||||
<TextBlock Grid.Row="5" Grid.Column="0" Margin="10,13,10,10" FontSize="13.333" Text="Left:"
|
<TextBlock Grid.Row="5" Grid.Column="0" Margin="10,13,10,10" FontSize="13.333" Text="Left:"
|
||||||
Height="18" VerticalAlignment="Top" />
|
Height="18" VerticalAlignment="Top" />
|
||||||
<controls:NumericUpDown Grid.Row="5" Grid.Column="1" VerticalAlignment="Top" Minimum="0"
|
<controls:NumericUpDown Grid.Row="5" Grid.Column="1" VerticalAlignment="Top" Minimum="0"
|
||||||
Value="{Binding Path=LayerModel.Properties.OffsetLeft, Mode=TwoWay}" Margin="10,12,10,2" Height="24" />
|
Value="{Binding Path=LayerModel.Properties.OffsetLeft, Mode=TwoWay}"
|
||||||
|
Margin="10,12,10,2" Height="24" />
|
||||||
|
|
||||||
<TextBlock Grid.Row="5" Grid.Column="2" Margin="10,13,10,10" FontSize="13.333" Text="Right:"
|
<TextBlock Grid.Row="5" Grid.Column="2" Margin="10,13,10,10" FontSize="13.333" Text="Right:"
|
||||||
Height="18" VerticalAlignment="Top" />
|
Height="18" VerticalAlignment="Top" />
|
||||||
<controls:NumericUpDown Grid.Row="5" Grid.Column="3" VerticalAlignment="Top" Minimum="0"
|
<controls:NumericUpDown Grid.Row="5" Grid.Column="3" VerticalAlignment="Top" Minimum="0"
|
||||||
Value="{Binding Path=LayerModel.Properties.OffsetRight, Mode=TwoWay}" Margin="10,12,10,2" Height="24" />
|
Value="{Binding Path=LayerModel.Properties.OffsetRight, Mode=TwoWay}"
|
||||||
|
Margin="10,12,10,2" Height="24" />
|
||||||
|
|
||||||
<!-- Vertical offsets -->
|
<!-- Vertical offsets -->
|
||||||
<TextBlock Grid.Row="6" Grid.Column="0" Margin="10,13,10,10" FontSize="13.333" Text="Top:"
|
<TextBlock Grid.Row="6" Grid.Column="0" Margin="10,13,10,10" FontSize="13.333" Text="Top:"
|
||||||
Height="18" VerticalAlignment="Top" />
|
Height="18" VerticalAlignment="Top" />
|
||||||
<controls:NumericUpDown Grid.Row="6" Grid.Column="1" VerticalAlignment="Top" Minimum="0"
|
<controls:NumericUpDown Grid.Row="6" Grid.Column="1" VerticalAlignment="Top" Minimum="0"
|
||||||
Value="{Binding Path=LayerModel.Properties.OffsetTop, Mode=TwoWay}" Margin="10,12,10,2" Height="24" />
|
Value="{Binding Path=LayerModel.Properties.OffsetTop, Mode=TwoWay}" Margin="10,12,10,2"
|
||||||
|
Height="24" />
|
||||||
|
|
||||||
<TextBlock Grid.Row="6" Grid.Column="2" Margin="10,13,10,10" FontSize="13.333" Text="Bottom:"
|
<TextBlock Grid.Row="6" Grid.Column="2" Margin="10,13,10,10" FontSize="13.333" Text="Bottom:"
|
||||||
Height="18" VerticalAlignment="Top" />
|
Height="18" VerticalAlignment="Top" />
|
||||||
<controls:NumericUpDown Grid.Row="6" Grid.Column="3" VerticalAlignment="Top" Minimum="0"
|
<controls:NumericUpDown Grid.Row="6" Grid.Column="3" VerticalAlignment="Top" Minimum="0"
|
||||||
Value="{Binding Path=LayerModel.Properties.OffsetBottom, Mode=TwoWay}" Margin="10,12,10,2" Height="24" />
|
Value="{Binding Path=LayerModel.Properties.OffsetBottom, Mode=TwoWay}"
|
||||||
|
Margin="10,12,10,2" Height="24" />
|
||||||
|
|
||||||
<!-- Horizontal BlackBar-detection -->
|
<!-- Horizontal BlackBar-detection -->
|
||||||
<TextBlock Grid.Row="7" Grid.Column="0" Margin="10,20,10,3" FontSize="13.333" Text="Black-Bar detection"
|
<TextBlock Grid.Row="7" Grid.Column="0" Margin="10,20,10,3" FontSize="13.333" Text="Black-Bar detection"
|
||||||
|
|||||||
@ -9,14 +9,16 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight
|
|||||||
|
|
||||||
public AmbientLightPropertiesViewModel(LayerEditorViewModel editorVm)
|
public AmbientLightPropertiesViewModel(LayerEditorViewModel editorVm)
|
||||||
: base(editorVm)
|
: base(editorVm)
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
public override void ApplyProperties()
|
public override void ApplyProperties()
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,13 +26,11 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight
|
|||||||
public bool ShowInEdtor => true;
|
public bool ShowInEdtor => true;
|
||||||
public DrawType DrawType => DrawType.Keyboard;
|
public DrawType DrawType => DrawType.Keyboard;
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore] private AmbienceCreatorType? _lastAmbienceCreatorType;
|
||||||
private AmbienceCreatorType? _lastAmbienceCreatorType = null;
|
|
||||||
[JsonIgnore]
|
|
||||||
private IAmbienceCreator _lastAmbienceCreator;
|
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore] private IAmbienceCreator _lastAmbienceCreator;
|
||||||
private byte[] _lastData;
|
|
||||||
|
[JsonIgnore] private byte[] _lastData;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -56,36 +54,39 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight
|
|||||||
|
|
||||||
public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
|
public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
|
||||||
{
|
{
|
||||||
AmbientLightPropertiesModel properties = layerModel?.Properties as AmbientLightPropertiesModel;
|
var properties = layerModel?.Properties as AmbientLightPropertiesModel;
|
||||||
if (properties == null) return;
|
if (properties == null) return;
|
||||||
|
|
||||||
int width = (int)Math.Round(properties.Width);
|
var width = (int) Math.Round(properties.Width);
|
||||||
int height = (int)Math.Round(properties.Height);
|
var height = (int) Math.Round(properties.Height);
|
||||||
|
|
||||||
byte[] data = ScreenCaptureManager.GetLastScreenCapture();
|
var data = ScreenCaptureManager.GetLastScreenCapture();
|
||||||
byte[] newData = GetAmbienceCreator(properties).GetAmbience(data, ScreenCaptureManager.LastCaptureWidth, ScreenCaptureManager.LastCaptureHeight, width, height, properties);
|
var newData = GetAmbienceCreator(properties)
|
||||||
|
.GetAmbience(data, ScreenCaptureManager.LastCaptureWidth, ScreenCaptureManager.LastCaptureHeight, width,
|
||||||
|
height, properties);
|
||||||
|
|
||||||
_lastData = _lastData?.Blend(newData, properties.SmoothMode) ?? newData;
|
_lastData = _lastData?.Blend(newData, properties.SmoothMode) ?? newData;
|
||||||
int stride = (width * ScreenCaptureManager.LastCapturePixelFormat.BitsPerPixel + 7) / 8;
|
var stride = (width*ScreenCaptureManager.LastCapturePixelFormat.BitsPerPixel + 7)/8;
|
||||||
properties.AmbientLightBrush = new DrawingBrush(new ImageDrawing
|
properties.AmbientLightBrush = new DrawingBrush(new ImageDrawing
|
||||||
(BitmapSource.Create(width, height, 96, 96, ScreenCaptureManager.LastCapturePixelFormat, null, _lastData, stride), new Rect(0, 0, width, height)));
|
(BitmapSource.Create(width, height, 96, 96, ScreenCaptureManager.LastCapturePixelFormat, null, _lastData,
|
||||||
|
stride), new Rect(0, 0, width, height)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(LayerModel layer, DrawingContext c)
|
public void Draw(LayerModel layerModel, DrawingContext c)
|
||||||
{
|
{
|
||||||
Rect rect = new Rect(layer.Properties.X * 4,
|
var rect = new Rect(layerModel.Properties.X*4,
|
||||||
layer.Properties.Y * 4,
|
layerModel.Properties.Y*4,
|
||||||
layer.Properties.Width * 4,
|
layerModel.Properties.Width*4,
|
||||||
layer.Properties.Height * 4);
|
layerModel.Properties.Height*4);
|
||||||
|
|
||||||
c.DrawRectangle(((AmbientLightPropertiesModel)layer.Properties).AmbientLightBrush, null, rect);
|
c.DrawRectangle(((AmbientLightPropertiesModel) layerModel.Properties).AmbientLightBrush, null, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageSource DrawThumbnail(LayerModel layer)
|
public ImageSource DrawThumbnail(LayerModel layer)
|
||||||
{
|
{
|
||||||
Rect thumbnailRect = new Rect(0, 0, 18, 18);
|
var thumbnailRect = new Rect(0, 0, 18, 18);
|
||||||
DrawingVisual visual = new DrawingVisual();
|
var visual = new DrawingVisual();
|
||||||
using (DrawingContext c = visual.RenderOpen())
|
using (var c = visual.RenderOpen())
|
||||||
c.DrawImage(ImageUtilities.BitmapToBitmapImage(Resources.ambilight), thumbnailRect);
|
c.DrawImage(ImageUtilities.BitmapToBitmapImage(Resources.ambilight), thumbnailRect);
|
||||||
|
|
||||||
return new DrawingImage(visual.Drawing);
|
return new DrawingImage(visual.Drawing);
|
||||||
@ -99,9 +100,12 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight
|
|||||||
_lastAmbienceCreatorType = properties.AmbienceCreatorType;
|
_lastAmbienceCreatorType = properties.AmbienceCreatorType;
|
||||||
switch (properties.AmbienceCreatorType)
|
switch (properties.AmbienceCreatorType)
|
||||||
{
|
{
|
||||||
case AmbienceCreatorType.Mirror: return _lastAmbienceCreator = new AmbienceCreatorMirror();
|
case AmbienceCreatorType.Mirror:
|
||||||
case AmbienceCreatorType.Extend: return _lastAmbienceCreator = new AmbienceCreatorExtend();
|
return _lastAmbienceCreator = new AmbienceCreatorMirror();
|
||||||
default: throw new InvalidEnumArgumentException();
|
case AmbienceCreatorType.Extend:
|
||||||
|
return _lastAmbienceCreator = new AmbienceCreatorExtend();
|
||||||
|
default:
|
||||||
|
throw new InvalidEnumArgumentException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,10 +8,13 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Helper
|
|||||||
public class CheckboxEnumFlagHelper
|
public class CheckboxEnumFlagHelper
|
||||||
{
|
{
|
||||||
#region DependencyProperties
|
#region DependencyProperties
|
||||||
|
|
||||||
// ReSharper disable InconsistentNaming
|
// ReSharper disable InconsistentNaming
|
||||||
|
|
||||||
public static readonly DependencyProperty FlagsProperty = DependencyProperty.RegisterAttached(
|
public static readonly DependencyProperty FlagsProperty = DependencyProperty.RegisterAttached(
|
||||||
"Flags", typeof(Enum), typeof(CheckboxEnumFlagHelper), new FrameworkPropertyMetadata(default(Enum), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, FlagsChanged));
|
"Flags", typeof(Enum), typeof(CheckboxEnumFlagHelper),
|
||||||
|
new FrameworkPropertyMetadata(default(Enum), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
||||||
|
FlagsChanged));
|
||||||
|
|
||||||
public static void SetFlags(DependencyObject element, Enum value)
|
public static void SetFlags(DependencyObject element, Enum value)
|
||||||
{
|
{
|
||||||
@ -20,7 +23,7 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Helper
|
|||||||
|
|
||||||
public static Enum GetFlags(DependencyObject element)
|
public static Enum GetFlags(DependencyObject element)
|
||||||
{
|
{
|
||||||
return (Enum)element.GetValue(FlagsProperty);
|
return (Enum) element.GetValue(FlagsProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty ValueProperty = DependencyProperty.RegisterAttached(
|
public static readonly DependencyProperty ValueProperty = DependencyProperty.RegisterAttached(
|
||||||
@ -33,10 +36,11 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Helper
|
|||||||
|
|
||||||
public static Enum GetValue(DependencyObject element)
|
public static Enum GetValue(DependencyObject element)
|
||||||
{
|
{
|
||||||
return (Enum)element.GetValue(ValueProperty);
|
return (Enum) element.GetValue(ValueProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReSharper restore InconsistentNaming
|
// ReSharper restore InconsistentNaming
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
@ -50,7 +54,7 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Helper
|
|||||||
private static void ValueChanged(DependencyObject dependencyObject,
|
private static void ValueChanged(DependencyObject dependencyObject,
|
||||||
DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
|
DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
|
||||||
{
|
{
|
||||||
CheckBox checkbox = dependencyObject as CheckBox;
|
var checkbox = dependencyObject as CheckBox;
|
||||||
if (checkbox == null) return;
|
if (checkbox == null) return;
|
||||||
|
|
||||||
checkbox.Checked -= UpdateSource;
|
checkbox.Checked -= UpdateSource;
|
||||||
@ -69,17 +73,17 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Helper
|
|||||||
{
|
{
|
||||||
if (checkbox == null) return;
|
if (checkbox == null) return;
|
||||||
|
|
||||||
Enum value = GetValue(checkbox);
|
var value = GetValue(checkbox);
|
||||||
checkbox.IsChecked = value != null && (flags?.HasFlag(value) ?? false);
|
checkbox.IsChecked = value != null && (flags?.HasFlag(value) ?? false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UpdateSource(object sender, RoutedEventArgs routedEventArgs)
|
private static void UpdateSource(object sender, RoutedEventArgs routedEventArgs)
|
||||||
{
|
{
|
||||||
CheckBox checkbox = sender as CheckBox;
|
var checkbox = sender as CheckBox;
|
||||||
if (checkbox == null) return;
|
if (checkbox == null) return;
|
||||||
|
|
||||||
Enum flags = GetFlags(checkbox);
|
var flags = GetFlags(checkbox);
|
||||||
Enum value = GetValue(checkbox);
|
var value = GetValue(checkbox);
|
||||||
if (value == null) return;
|
if (value == null) return;
|
||||||
|
|
||||||
if (checkbox.IsChecked ?? false)
|
if (checkbox.IsChecked ?? false)
|
||||||
|
|||||||
@ -4,10 +4,8 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Model
|
|||||||
{
|
{
|
||||||
public enum AmbienceCreatorType
|
public enum AmbienceCreatorType
|
||||||
{
|
{
|
||||||
[Description("Mirror")]
|
[Description("Mirror")] Mirror,
|
||||||
Mirror,
|
|
||||||
|
|
||||||
[Description("Extend")]
|
[Description("Extend")] Extend
|
||||||
Extend
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9,6 +9,6 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Model
|
|||||||
Left = 1 << 0,
|
Left = 1 << 0,
|
||||||
Right = 1 << 1,
|
Right = 1 << 1,
|
||||||
Top = 1 << 2,
|
Top = 1 << 2,
|
||||||
Bottom = 1 << 3,
|
Bottom = 1 << 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -23,10 +23,10 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Model.Extensions
|
|||||||
|
|
||||||
public static AvgColor[] ExtendHeight(this AvgColor[] colors, int height)
|
public static AvgColor[] ExtendHeight(this AvgColor[] colors, int height)
|
||||||
{
|
{
|
||||||
AvgColor[] extended = new AvgColor[colors.Length * height];
|
var extended = new AvgColor[colors.Length*height];
|
||||||
|
|
||||||
for (int i = 0; i < height; i++)
|
for (var i = 0; i < height; i++)
|
||||||
Array.Copy(colors, 0, extended, i * colors.Length, colors.Length);
|
Array.Copy(colors, 0, extended, i*colors.Length, colors.Length);
|
||||||
|
|
||||||
return extended;
|
return extended;
|
||||||
}
|
}
|
||||||
@ -35,9 +35,9 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Model.Extensions
|
|||||||
{
|
{
|
||||||
if (colors == null || width <= 0) return colors;
|
if (colors == null || width <= 0) return colors;
|
||||||
|
|
||||||
AvgColor[] flipped = new AvgColor[colors.Length];
|
var flipped = new AvgColor[colors.Length];
|
||||||
for (int i = 0, j = colors.Length - width; i < colors.Length; i += width, j -= width)
|
for (int i = 0, j = colors.Length - width; i < colors.Length; i += width, j -= width)
|
||||||
for (int k = 0; k < width; ++k)
|
for (var k = 0; k < width; ++k)
|
||||||
flipped[i + k] = colors[j + k];
|
flipped[i + k] = colors[j + k];
|
||||||
|
|
||||||
return flipped;
|
return flipped;
|
||||||
@ -47,8 +47,8 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Model.Extensions
|
|||||||
{
|
{
|
||||||
if (colors == null || width <= 0) return colors;
|
if (colors == null || width <= 0) return colors;
|
||||||
|
|
||||||
AvgColor[] flipped = new AvgColor[colors.Length];
|
var flipped = new AvgColor[colors.Length];
|
||||||
for (int i = 0; i < colors.Length; i += width)
|
for (var i = 0; i < colors.Length; i += width)
|
||||||
for (int j = 0, k = width - 1; j < width; ++j, --k)
|
for (int j = 0, k = width - 1; j < width; ++j, --k)
|
||||||
flipped[i + j] = colors[i + k];
|
flipped[i + j] = colors[i + k];
|
||||||
|
|
||||||
@ -57,9 +57,9 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Model.Extensions
|
|||||||
|
|
||||||
public static byte[] ToBGRArray(this AvgColor[] colors)
|
public static byte[] ToBGRArray(this AvgColor[] colors)
|
||||||
{
|
{
|
||||||
byte[] newData = new byte[colors.Length * 3];
|
var newData = new byte[colors.Length*3];
|
||||||
int counter = 0;
|
var counter = 0;
|
||||||
foreach (AvgColor color in colors)
|
foreach (var color in colors)
|
||||||
{
|
{
|
||||||
newData[counter++] = color.B;
|
newData[counter++] = color.B;
|
||||||
newData[counter++] = color.G;
|
newData[counter++] = color.G;
|
||||||
|
|||||||
@ -10,15 +10,15 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Model.Extensions
|
|||||||
{
|
{
|
||||||
if (e == null || value == null || t == null) return e;
|
if (e == null || value == null || t == null) return e;
|
||||||
|
|
||||||
int eValue = Convert.ToInt32(e);
|
var eValue = Convert.ToInt32(e);
|
||||||
int valueValue = Convert.ToInt32(value);
|
var valueValue = Convert.ToInt32(value);
|
||||||
|
|
||||||
if (set)
|
if (set)
|
||||||
eValue |= valueValue;
|
eValue |= valueValue;
|
||||||
else
|
else
|
||||||
eValue &= ~valueValue;
|
eValue &= ~valueValue;
|
||||||
|
|
||||||
return (Enum)Enum.ToObject(t, eValue);
|
return (Enum) Enum.ToObject(t, eValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -6,17 +6,18 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Model.Extensions
|
|||||||
{
|
{
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
public static int DetectBlackBarLeft(this byte[] pixels, int width, int height, int offsetLeft, int offsetRight, int offsetTop, int offsetBottom)
|
public static int DetectBlackBarLeft(this byte[] pixels, int width, int height, int offsetLeft, int offsetRight,
|
||||||
|
int offsetTop, int offsetBottom)
|
||||||
{
|
{
|
||||||
int bottomBorder = height - offsetBottom;
|
var bottomBorder = height - offsetBottom;
|
||||||
int rightBorder = width - offsetRight;
|
var rightBorder = width - offsetRight;
|
||||||
|
|
||||||
int blackBarWidth = 0;
|
var blackBarWidth = 0;
|
||||||
for (int x = rightBorder - 1; x >= offsetLeft; x--)
|
for (var x = rightBorder - 1; x >= offsetLeft; x--)
|
||||||
{
|
{
|
||||||
for (int y = offsetTop; y < bottomBorder; y++)
|
for (var y = offsetTop; y < bottomBorder; y++)
|
||||||
{
|
{
|
||||||
int offset = ((y * width) + x) * 4;
|
var offset = (y*width + x)*4;
|
||||||
if (pixels[offset] > 15 || pixels[offset + 1] > 15 || pixels[offset + 2] > 15)
|
if (pixels[offset] > 15 || pixels[offset + 1] > 15 || pixels[offset + 2] > 15)
|
||||||
return blackBarWidth;
|
return blackBarWidth;
|
||||||
}
|
}
|
||||||
@ -26,17 +27,18 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Model.Extensions
|
|||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int DetectBlackBarRight(this byte[] pixels, int width, int height, int offsetLeft, int offsetRight, int offsetTop, int offsetBottom)
|
public static int DetectBlackBarRight(this byte[] pixels, int width, int height, int offsetLeft, int offsetRight,
|
||||||
|
int offsetTop, int offsetBottom)
|
||||||
{
|
{
|
||||||
int bottomBorder = height - offsetBottom;
|
var bottomBorder = height - offsetBottom;
|
||||||
int rightBorder = width - offsetRight;
|
var rightBorder = width - offsetRight;
|
||||||
|
|
||||||
int blackBarWidth = 0;
|
var blackBarWidth = 0;
|
||||||
for (int x = offsetLeft; x < rightBorder; x++)
|
for (var x = offsetLeft; x < rightBorder; x++)
|
||||||
{
|
{
|
||||||
for (int y = offsetTop; y < bottomBorder; y++)
|
for (var y = offsetTop; y < bottomBorder; y++)
|
||||||
{
|
{
|
||||||
int offset = ((y * width) + x) * 4;
|
var offset = (y*width + x)*4;
|
||||||
if (pixels[offset] > 15 || pixels[offset + 1] > 15 || pixels[offset + 2] > 15)
|
if (pixels[offset] > 15 || pixels[offset + 1] > 15 || pixels[offset + 2] > 15)
|
||||||
return blackBarWidth;
|
return blackBarWidth;
|
||||||
}
|
}
|
||||||
@ -46,17 +48,18 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Model.Extensions
|
|||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int DetectBlackBarTop(this byte[] pixels, int width, int height, int offsetLeft, int offsetRight, int offsetTop, int offsetBottom)
|
public static int DetectBlackBarTop(this byte[] pixels, int width, int height, int offsetLeft, int offsetRight,
|
||||||
|
int offsetTop, int offsetBottom)
|
||||||
{
|
{
|
||||||
int bottomBorder = height - offsetBottom;
|
var bottomBorder = height - offsetBottom;
|
||||||
int rightBorder = width - offsetRight;
|
var rightBorder = width - offsetRight;
|
||||||
|
|
||||||
int blackBarHeight = 0;
|
var blackBarHeight = 0;
|
||||||
for (int y = offsetTop; y < bottomBorder; y++)
|
for (var y = offsetTop; y < bottomBorder; y++)
|
||||||
{
|
{
|
||||||
for (int x = offsetLeft; x < rightBorder; x++)
|
for (var x = offsetLeft; x < rightBorder; x++)
|
||||||
{
|
{
|
||||||
int offset = ((y * width) + x) * 4;
|
var offset = (y*width + x)*4;
|
||||||
if (pixels[offset] > 15 || pixels[offset + 1] > 15 || pixels[offset + 2] > 15)
|
if (pixels[offset] > 15 || pixels[offset + 1] > 15 || pixels[offset + 2] > 15)
|
||||||
return blackBarHeight;
|
return blackBarHeight;
|
||||||
}
|
}
|
||||||
@ -66,17 +69,18 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Model.Extensions
|
|||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int DetectBlackBarBottom(this byte[] pixels, int width, int height, int offsetLeft, int offsetRight, int offsetTop, int offsetBottom)
|
public static int DetectBlackBarBottom(this byte[] pixels, int width, int height, int offsetLeft,
|
||||||
|
int offsetRight, int offsetTop, int offsetBottom)
|
||||||
{
|
{
|
||||||
int bottomBorder = height - offsetBottom;
|
var bottomBorder = height - offsetBottom;
|
||||||
int rightBorder = width - offsetRight;
|
var rightBorder = width - offsetRight;
|
||||||
|
|
||||||
int blackBarHeight = 0;
|
var blackBarHeight = 0;
|
||||||
for (int y = bottomBorder - 1; y >= offsetTop; y--)
|
for (var y = bottomBorder - 1; y >= offsetTop; y--)
|
||||||
{
|
{
|
||||||
for (int x = offsetLeft; x < rightBorder; x++)
|
for (var x = offsetLeft; x < rightBorder; x++)
|
||||||
{
|
{
|
||||||
int offset = ((y * width) + x) * 4;
|
var offset = (y*width + x)*4;
|
||||||
if (pixels[offset] > 15 || pixels[offset + 1] > 15 || pixels[offset + 2] > 15)
|
if (pixels[offset] > 15 || pixels[offset + 1] > 15 || pixels[offset + 2] > 15)
|
||||||
return blackBarHeight;
|
return blackBarHeight;
|
||||||
}
|
}
|
||||||
@ -90,20 +94,22 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Model.Extensions
|
|||||||
{
|
{
|
||||||
if (smoothMode == SmoothMode.None || pixels.Length != blendPixels.Length) return blendPixels;
|
if (smoothMode == SmoothMode.None || pixels.Length != blendPixels.Length) return blendPixels;
|
||||||
|
|
||||||
double percentage = smoothMode == SmoothMode.Low? 0.25: (smoothMode == SmoothMode.Medium ? 0.075 : 0.025 /*high*/);
|
var percentage = smoothMode == SmoothMode.Low
|
||||||
|
? 0.25
|
||||||
|
: (smoothMode == SmoothMode.Medium ? 0.075 : 0.025 /*high*/);
|
||||||
|
|
||||||
byte[] blended = new byte[pixels.Length];
|
var blended = new byte[pixels.Length];
|
||||||
|
|
||||||
for (int i = 0; i < blended.Length; i++)
|
for (var i = 0; i < blended.Length; i++)
|
||||||
blended[i] = GetIntColor((blendPixels[i] / 255.0) * percentage + (pixels[i] / 255.0) * (1 - percentage));
|
blended[i] = GetIntColor(blendPixels[i]/255.0*percentage + pixels[i]/255.0*(1 - percentage));
|
||||||
|
|
||||||
return blended;
|
return blended;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte GetIntColor(double d)
|
private static byte GetIntColor(double d)
|
||||||
{
|
{
|
||||||
double calcF = Math.Max(0, Math.Min(1, d));
|
var calcF = Math.Max(0, Math.Min(1, d));
|
||||||
return (byte)(calcF.Equals(1) ? 255 : calcF * 256);
|
return (byte) (calcF.Equals(1) ? 255 : calcF*256);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -4,7 +4,6 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Model
|
|||||||
{
|
{
|
||||||
public enum ScreenCaptureMode
|
public enum ScreenCaptureMode
|
||||||
{
|
{
|
||||||
[Description("DirectX 9")]
|
[Description("DirectX 9")] DirectX9
|
||||||
DirectX9
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4,16 +4,12 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.Model
|
|||||||
{
|
{
|
||||||
public enum SmoothMode
|
public enum SmoothMode
|
||||||
{
|
{
|
||||||
[Description("None")]
|
[Description("None")] None,
|
||||||
None,
|
|
||||||
|
|
||||||
[Description("Low")]
|
[Description("Low")] Low,
|
||||||
Low,
|
|
||||||
|
|
||||||
[Description("Medium")]
|
[Description("Medium")] Medium,
|
||||||
Medium,
|
|
||||||
|
|
||||||
[Description("High")]
|
[Description("High")] High
|
||||||
High
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,25 +2,12 @@
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using SharpDX;
|
|
||||||
using SharpDX.Direct3D9;
|
using SharpDX.Direct3D9;
|
||||||
|
|
||||||
namespace Artemis.Profiles.Layers.Types.AmbientLight.ScreenCapturing
|
namespace Artemis.Profiles.Layers.Types.AmbientLight.ScreenCapturing
|
||||||
{
|
{
|
||||||
public class DX9ScreenCapture : IScreenCapture
|
public class DX9ScreenCapture : IScreenCapture
|
||||||
{
|
{
|
||||||
#region Properties & Fields
|
|
||||||
|
|
||||||
private Device _device;
|
|
||||||
private Surface _surface;
|
|
||||||
private byte[] _buffer;
|
|
||||||
|
|
||||||
public int Width { get; }
|
|
||||||
public int Height { get; }
|
|
||||||
public PixelFormat PixelFormat => PixelFormats.Bgr24;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
|
|
||||||
public DX9ScreenCapture()
|
public DX9ScreenCapture()
|
||||||
@ -28,26 +15,39 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.ScreenCapturing
|
|||||||
Width = Screen.PrimaryScreen.Bounds.Width;
|
Width = Screen.PrimaryScreen.Bounds.Width;
|
||||||
Height = Screen.PrimaryScreen.Bounds.Height;
|
Height = Screen.PrimaryScreen.Bounds.Height;
|
||||||
|
|
||||||
PresentParameters presentParams = new PresentParameters(Width, Height)
|
var presentParams = new PresentParameters(Width, Height)
|
||||||
{
|
{
|
||||||
Windowed = true,
|
Windowed = true,
|
||||||
SwapEffect = SwapEffect.Discard
|
SwapEffect = SwapEffect.Discard
|
||||||
};
|
};
|
||||||
|
|
||||||
_device = new Device(new Direct3D(), 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.SoftwareVertexProcessing, presentParams);
|
_device = new Device(new Direct3D(), 0, DeviceType.Hardware, IntPtr.Zero,
|
||||||
|
CreateFlags.SoftwareVertexProcessing, presentParams);
|
||||||
_surface = Surface.CreateOffscreenPlain(_device, Width, Height, Format.A8R8G8B8, Pool.Scratch);
|
_surface = Surface.CreateOffscreenPlain(_device, Width, Height, Format.A8R8G8B8, Pool.Scratch);
|
||||||
_buffer = new byte[Width * Height * 4];
|
_buffer = new byte[Width*Height*4];
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Properties & Fields
|
||||||
|
|
||||||
|
private readonly Device _device;
|
||||||
|
private readonly Surface _surface;
|
||||||
|
private readonly byte[] _buffer;
|
||||||
|
|
||||||
|
public int Width { get; }
|
||||||
|
public int Height { get; }
|
||||||
|
public PixelFormat PixelFormat => PixelFormats.Bgr24;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
public byte[] CaptureScreen()
|
public byte[] CaptureScreen()
|
||||||
{
|
{
|
||||||
_device.GetFrontBufferData(0, _surface);
|
_device.GetFrontBufferData(0, _surface);
|
||||||
|
|
||||||
DataRectangle dr = _surface.LockRectangle(LockFlags.None);
|
var dr = _surface.LockRectangle(LockFlags.None);
|
||||||
Marshal.Copy(dr.DataPointer, _buffer, 0, _buffer.Length);
|
Marshal.Copy(dr.DataPointer, _buffer, 0, _buffer.Length);
|
||||||
_surface.UnlockRectangle();
|
_surface.UnlockRectangle();
|
||||||
|
|
||||||
|
|||||||
@ -14,13 +14,14 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.ScreenCapturing
|
|||||||
private static Thread _worker;
|
private static Thread _worker;
|
||||||
private static DateTime _lastCaptureAccess;
|
private static DateTime _lastCaptureAccess;
|
||||||
private static volatile byte[] _lastScreenCapture;
|
private static volatile byte[] _lastScreenCapture;
|
||||||
private static volatile bool _isRunning = false;
|
private static volatile bool _isRunning;
|
||||||
|
|
||||||
private static ScreenCaptureMode? _lastScreenCaptureMode = null;
|
private static ScreenCaptureMode? _lastScreenCaptureMode;
|
||||||
private static IScreenCapture _screenCapture;
|
private static IScreenCapture _screenCapture;
|
||||||
|
|
||||||
public static double StandByTime { get; set; } = 3;
|
public static double StandByTime { get; set; } = 3;
|
||||||
public static double UpdateRate { get; set; } = 1.0 / 20.0; // DarthAffe 29.10.2016: I think 20 FPS should be enough as default
|
public static double UpdateRate { get; set; } = 1.0/20.0;
|
||||||
|
// DarthAffe 29.10.2016: I think 20 FPS should be enough as default
|
||||||
public static ScreenCaptureMode ScreenCaptureMode { get; set; } = ScreenCaptureMode.DirectX9;
|
public static ScreenCaptureMode ScreenCaptureMode { get; set; } = ScreenCaptureMode.DirectX9;
|
||||||
|
|
||||||
public static int LastCaptureWidth { get; private set; }
|
public static int LastCaptureWidth { get; private set; }
|
||||||
@ -41,8 +42,10 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.ScreenCapturing
|
|||||||
_lastScreenCaptureMode = ScreenCaptureMode;
|
_lastScreenCaptureMode = ScreenCaptureMode;
|
||||||
switch (ScreenCaptureMode)
|
switch (ScreenCaptureMode)
|
||||||
{
|
{
|
||||||
case ScreenCaptureMode.DirectX9: return _screenCapture = new DX9ScreenCapture();
|
case ScreenCaptureMode.DirectX9:
|
||||||
default: throw new InvalidEnumArgumentException();
|
return _screenCapture = new DX9ScreenCapture();
|
||||||
|
default:
|
||||||
|
throw new InvalidEnumArgumentException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +62,7 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.ScreenCapturing
|
|||||||
{
|
{
|
||||||
while ((DateTime.Now - _lastCaptureAccess).TotalSeconds < StandByTime)
|
while ((DateTime.Now - _lastCaptureAccess).TotalSeconds < StandByTime)
|
||||||
{
|
{
|
||||||
DateTime lastCapture = DateTime.Now;
|
var lastCapture = DateTime.Now;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CaptureScreen();
|
CaptureScreen();
|
||||||
@ -69,7 +72,7 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.ScreenCapturing
|
|||||||
Debug.WriteLine("[CaptureLoop]: " + ex.Message);
|
Debug.WriteLine("[CaptureLoop]: " + ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sleep = (int)((UpdateRate - (DateTime.Now - lastCapture).TotalSeconds) * 1000);
|
var sleep = (int) ((UpdateRate - (DateTime.Now - lastCapture).TotalSeconds)*1000);
|
||||||
if (sleep > 0)
|
if (sleep > 0)
|
||||||
Thread.Sleep(sleep);
|
Thread.Sleep(sleep);
|
||||||
}
|
}
|
||||||
@ -83,7 +86,7 @@ namespace Artemis.Profiles.Layers.Types.AmbientLight.ScreenCapturing
|
|||||||
|
|
||||||
private static void CaptureScreen()
|
private static void CaptureScreen()
|
||||||
{
|
{
|
||||||
IScreenCapture screenCapture = GetScreenCapture();
|
var screenCapture = GetScreenCapture();
|
||||||
|
|
||||||
_lastScreenCapture = screenCapture.CaptureScreen();
|
_lastScreenCapture = screenCapture.CaptureScreen();
|
||||||
LastCaptureWidth = screenCapture.Width;
|
LastCaptureWidth = screenCapture.Width;
|
||||||
|
|||||||
@ -0,0 +1,134 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Artemis.Modules.Effects.AudioVisualizer.Utilities;
|
||||||
|
using NAudio.CoreAudioApi;
|
||||||
|
using NAudio.Dsp;
|
||||||
|
using NAudio.Wave;
|
||||||
|
using Ninject.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace Artemis.Profiles.Layers.Types.Audio.AudioCapturing
|
||||||
|
{
|
||||||
|
public class AudioCaptureManager
|
||||||
|
{
|
||||||
|
private readonly SampleAggregator _sampleAggregator = new SampleAggregator(1024);
|
||||||
|
private readonly WasapiLoopbackCapture _waveIn;
|
||||||
|
private Complex[] _fft;
|
||||||
|
private DateTime _lastAudioUpdate;
|
||||||
|
private DateTime _lastRequest;
|
||||||
|
|
||||||
|
public AudioCaptureManager(ILogger logger)
|
||||||
|
{
|
||||||
|
Logger = logger;
|
||||||
|
Device = new MMDeviceEnumerator().EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active).FirstOrDefault();
|
||||||
|
|
||||||
|
_sampleAggregator.FftCalculated += FftCalculated;
|
||||||
|
_sampleAggregator.PerformFFT = true;
|
||||||
|
|
||||||
|
// Start listening for sound data
|
||||||
|
_waveIn = new WasapiLoopbackCapture();
|
||||||
|
_waveIn.DataAvailable += OnDataAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ILogger Logger { get; set; }
|
||||||
|
public MMDevice Device { get; set; }
|
||||||
|
|
||||||
|
public bool Running { get; set; }
|
||||||
|
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
if (Running)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_waveIn.StartRecording();
|
||||||
|
Running = true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Warn(e, "Failed to start WASAPI audio capture");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
if (!Running)
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_waveIn.StopRecording();
|
||||||
|
Running = false;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Warn(e, "Failed to start WASAPI audio capture");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FftCalculated(object sender, FftEventArgs e)
|
||||||
|
{
|
||||||
|
_fft = e.Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDataAvailable(object sender, WaveInEventArgs e)
|
||||||
|
{
|
||||||
|
if (DateTime.Now - _lastAudioUpdate < TimeSpan.FromMilliseconds(40))
|
||||||
|
return;
|
||||||
|
if (DateTime.Now - _lastRequest > TimeSpan.FromSeconds(5))
|
||||||
|
{
|
||||||
|
Stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastAudioUpdate = DateTime.Now;
|
||||||
|
|
||||||
|
var buffer = e.Buffer;
|
||||||
|
var bytesRecorded = e.BytesRecorded;
|
||||||
|
var bufferIncrement = _waveIn.WaveFormat.BlockAlign;
|
||||||
|
|
||||||
|
for (var index = 0; index < bytesRecorded; index += bufferIncrement)
|
||||||
|
{
|
||||||
|
var sample32 = BitConverter.ToSingle(buffer, index);
|
||||||
|
_sampleAggregator.Add(sample32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<byte> GetSpectrumData(int lines)
|
||||||
|
{
|
||||||
|
_lastRequest = DateTime.Now;
|
||||||
|
if (!Running)
|
||||||
|
Start();
|
||||||
|
|
||||||
|
var spectrumData = new List<byte>();
|
||||||
|
|
||||||
|
if (_fft == null)
|
||||||
|
return spectrumData;
|
||||||
|
|
||||||
|
int x;
|
||||||
|
var b0 = 0;
|
||||||
|
|
||||||
|
for (x = 0; x < lines; x++)
|
||||||
|
{
|
||||||
|
float peak = 0;
|
||||||
|
var b1 = (int) Math.Pow(2, x*10.0/(lines - 1));
|
||||||
|
if (b1 > 1023)
|
||||||
|
b1 = 1023;
|
||||||
|
if (b1 <= b0)
|
||||||
|
b1 = b0 + 1;
|
||||||
|
for (; b0 < b1; b0++)
|
||||||
|
if (peak < _fft[1 + b0].X)
|
||||||
|
peak = _fft[1 + b0].X;
|
||||||
|
var y = (int) (Math.Sqrt(peak)*3*255 - 4);
|
||||||
|
if (y > 255)
|
||||||
|
y = 255;
|
||||||
|
if (y < 0)
|
||||||
|
y = 0;
|
||||||
|
spectrumData.Add((byte) y);
|
||||||
|
}
|
||||||
|
|
||||||
|
return spectrumData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -34,37 +34,58 @@
|
|||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
<!-- Animation -->
|
||||||
|
<TextBlock Grid.Row="0" Grid.Column="0" Margin="10" FontSize="13.333" Text="Animation:"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Height="18" />
|
||||||
|
<ComboBox Grid.Row="0" Grid.Column="1" Margin="10,10,10,0" x:Name="LayerAnimations" VerticalAlignment="Top"
|
||||||
|
Height="22">
|
||||||
|
<ComboBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<TextBlock Text="{Binding Path=Name, Mode=OneWay}" />
|
||||||
|
</DataTemplate>
|
||||||
|
</ComboBox.ItemTemplate>
|
||||||
|
</ComboBox>
|
||||||
|
|
||||||
|
<!-- Animation Speed -->
|
||||||
|
<TextBlock Grid.Row="0" Grid.Column="2" Margin="10" FontSize="13.333" Text="Animation speed:"
|
||||||
|
VerticalAlignment="Center" Height="18" />
|
||||||
|
<Slider Grid.Row="0" Grid.Column="3" VerticalAlignment="Center"
|
||||||
|
TickPlacement="None" TickFrequency="0.05"
|
||||||
|
Value="{Binding Path=LayerModel.Properties.AnimationSpeed, Mode=TwoWay}" Minimum="0.05" Maximum="3"
|
||||||
|
SmallChange="0" IsSnapToTickEnabled="True" Margin="10,12,10,2" Height="24" />
|
||||||
|
|
||||||
<!-- Volume sensitivity -->
|
<!-- Volume sensitivity -->
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0" Margin="10,13,10,10" FontSize="13.333" Text="Volume sensitivity:"
|
<TextBlock Grid.Row="1" Grid.Column="0" Margin="10,13,10,10" FontSize="13.333" Text="Volume sensitivity:"
|
||||||
Height="18" VerticalAlignment="Top" />
|
Height="18" VerticalAlignment="Top" />
|
||||||
<Slider x:Name="Scale" Grid.Row="0" Grid.Column="1" VerticalAlignment="Top"
|
<Slider x:Name="Scale" Grid.Row="1" Grid.Column="1" VerticalAlignment="Top"
|
||||||
Value="{Binding Path=LayerModel.Properties.Sensitivity, Mode=TwoWay}" Margin="10,12,10,2" Height="24"
|
Value="{Binding Path=LayerModel.Properties.Sensitivity, Mode=TwoWay}" Margin="10,12,10,2" Height="24"
|
||||||
TickPlacement="BottomRight" TickFrequency="1" Minimum="1" Maximum="10" SmallChange="1"
|
TickPlacement="BottomRight" TickFrequency="1" Minimum="1" Maximum="10" SmallChange="1"
|
||||||
IsSnapToTickEnabled="True" />
|
IsSnapToTickEnabled="True" />
|
||||||
|
|
||||||
<!-- Fade-out speed -->
|
<!-- Fade-out speed -->
|
||||||
<TextBlock Grid.Row="0" Grid.Column="2" Margin="10,13,10,10" FontSize="13.333" Text="Fade-out speed:"
|
<TextBlock Grid.Row="1" Grid.Column="2" Margin="10,13,10,10" FontSize="13.333" Text="Fade-out speed:"
|
||||||
VerticalAlignment="Top" Height="18" />
|
VerticalAlignment="Top" Height="18" />
|
||||||
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Top"
|
<Slider Grid.Row="1" Grid.Column="3" VerticalAlignment="Top"
|
||||||
Value="{Binding Path=LayerModel.Properties.FadeSpeed, Mode=TwoWay}" Margin="10,12,10,2"
|
Value="{Binding Path=LayerModel.Properties.FadeSpeed, Mode=TwoWay}" Margin="10,12,10,2"
|
||||||
Height="24" TickPlacement="BottomRight" TickFrequency="1" Minimum="1" Maximum="3" SmallChange="1"
|
Height="24" TickPlacement="BottomRight" TickFrequency="0.1" Minimum="0.1" Maximum="1" SmallChange="0.1"
|
||||||
IsSnapToTickEnabled="True" />
|
IsSnapToTickEnabled="True" />
|
||||||
|
|
||||||
<!-- Colors -->
|
<!-- Colors -->
|
||||||
<StackPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal" x:Name="ShowBrush">
|
<StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal" x:Name="ShowBrush">
|
||||||
<TextBlock Margin="10,13,10,0" FontSize="13.333" Text="Color(s):"
|
<TextBlock Margin="10,13,10,0" FontSize="13.333" Text="Color(s):"
|
||||||
VerticalAlignment="Top" Height="18" Width="130" />
|
VerticalAlignment="Top" Height="18" Width="130" />
|
||||||
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
|
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
|
||||||
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
|
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
|
||||||
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" Height="24" Width="134"
|
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" ShowNone="False" Height="24" Width="134"
|
||||||
VerticalAlignment="Top" />
|
VerticalAlignment="Top" />
|
||||||
</Border>
|
</Border>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- Bar direction -->
|
<!-- Bar direction -->
|
||||||
<TextBlock Grid.Row="1" Grid.Column="2" Margin="10,13,10,10" FontSize="13.333" Text="Bar direction:"
|
<TextBlock Grid.Row="2" Grid.Column="2" Margin="10,13,10,10" FontSize="13.333" Text="Bar direction:"
|
||||||
VerticalAlignment="Top" Height="18" />
|
VerticalAlignment="Top" Height="18" />
|
||||||
<ComboBox Grid.Row="1" Grid.Column="3" ItemsSource="{Binding Source={StaticResource DirectionEnumValues}}"
|
<ComboBox Grid.Row="2" Grid.Column="3" ItemsSource="{Binding Source={StaticResource DirectionEnumValues}}"
|
||||||
Margin="10,10,10,0" SelectedItem="{Binding Path=LayerModel.Properties.Direction}"
|
Margin="10,10,10,0" SelectedItem="{Binding Path=LayerModel.Properties.Direction}"
|
||||||
VerticalAlignment="Top" Height="22">
|
VerticalAlignment="Top" Height="22">
|
||||||
<ComboBox.ItemTemplate>
|
<ComboBox.ItemTemplate>
|
||||||
|
|||||||
@ -1,17 +1,40 @@
|
|||||||
using Artemis.Profiles.Layers.Abstract;
|
using System.Linq;
|
||||||
|
using Artemis.Profiles.Layers.Abstract;
|
||||||
|
using Artemis.Profiles.Layers.Interfaces;
|
||||||
using Artemis.ViewModels.Profiles;
|
using Artemis.ViewModels.Profiles;
|
||||||
|
using Caliburn.Micro;
|
||||||
|
|
||||||
namespace Artemis.Profiles.Layers.Types.Audio
|
namespace Artemis.Profiles.Layers.Types.Audio
|
||||||
{
|
{
|
||||||
public class AudioPropertiesViewModel : LayerPropertiesViewModel
|
public class AudioPropertiesViewModel : LayerPropertiesViewModel
|
||||||
{
|
{
|
||||||
|
private ILayerAnimation _selectedLayerAnimation;
|
||||||
|
|
||||||
public AudioPropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)
|
public AudioPropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)
|
||||||
{
|
{
|
||||||
|
LayerAnimations = new BindableCollection<ILayerAnimation>(editorVm.LayerAnimations);
|
||||||
|
SelectedLayerAnimation =
|
||||||
|
LayerAnimations.FirstOrDefault(l => l.Name == editorVm.ProposedLayer.LayerAnimation?.Name) ??
|
||||||
|
LayerAnimations.First(l => l.Name == "None");
|
||||||
|
}
|
||||||
|
|
||||||
|
public BindableCollection<ILayerAnimation> LayerAnimations { get; set; }
|
||||||
|
|
||||||
|
public ILayerAnimation SelectedLayerAnimation
|
||||||
|
{
|
||||||
|
get { return _selectedLayerAnimation; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (Equals(value, _selectedLayerAnimation)) return;
|
||||||
|
_selectedLayerAnimation = value;
|
||||||
|
NotifyOfPropertyChange(() => SelectedLayerAnimation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ApplyProperties()
|
public override void ApplyProperties()
|
||||||
{
|
{
|
||||||
LayerModel.Properties.Brush = Brush;
|
LayerModel.Properties.Brush = Brush;
|
||||||
|
LayerModel.LayerAnimation = SelectedLayerAnimation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4,56 +4,35 @@ using System.Linq;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Artemis.Models.Interfaces;
|
using Artemis.Models.Interfaces;
|
||||||
using Artemis.Modules.Effects.AudioVisualizer.Utilities;
|
|
||||||
using Artemis.Profiles.Layers.Abstract;
|
using Artemis.Profiles.Layers.Abstract;
|
||||||
using Artemis.Profiles.Layers.Animations;
|
|
||||||
using Artemis.Profiles.Layers.Interfaces;
|
using Artemis.Profiles.Layers.Interfaces;
|
||||||
using Artemis.Profiles.Layers.Models;
|
using Artemis.Profiles.Layers.Models;
|
||||||
|
using Artemis.Profiles.Layers.Types.Audio.AudioCapturing;
|
||||||
using Artemis.Properties;
|
using Artemis.Properties;
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using Artemis.ViewModels.Profiles;
|
using Artemis.ViewModels.Profiles;
|
||||||
using NAudio.CoreAudioApi;
|
|
||||||
using NAudio.Wave;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NLog;
|
using Ninject;
|
||||||
|
|
||||||
namespace Artemis.Profiles.Layers.Types.Audio
|
namespace Artemis.Profiles.Layers.Types.Audio
|
||||||
{
|
{
|
||||||
internal class AudioType : ILayerType
|
internal class AudioType : ILayerType
|
||||||
{
|
{
|
||||||
private readonly List<LayerModel> _audioLayers = new List<LayerModel>();
|
private readonly List<LayerModel> _audioLayers = new List<LayerModel>();
|
||||||
private readonly MMDevice _device;
|
private readonly IKernel _kernel;
|
||||||
private readonly SampleAggregator _sampleAggregator = new SampleAggregator(1024);
|
|
||||||
private readonly WasapiLoopbackCapture _waveIn;
|
private DateTime _lastUpdate;
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
||||||
private int _lines;
|
private int _lines;
|
||||||
private AudioPropertiesModel _previousSettings;
|
private string _previousSettings;
|
||||||
|
|
||||||
public AudioType()
|
public AudioType(IKernel kernel, AudioCaptureManager audioCaptureManager)
|
||||||
{
|
{
|
||||||
_device = new MMDeviceEnumerator()
|
_kernel = kernel;
|
||||||
.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active).FirstOrDefault();
|
AudioCaptureManager = audioCaptureManager;
|
||||||
|
|
||||||
_sampleAggregator.FftCalculated += FftCalculated;
|
|
||||||
_sampleAggregator.PerformFFT = true;
|
|
||||||
|
|
||||||
// Start listening for sound data
|
|
||||||
_waveIn = new WasapiLoopbackCapture();
|
|
||||||
_waveIn.DataAvailable += OnDataAvailable;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_waveIn.StartRecording();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Logger.Warn(e, "Failed to start WASAPI audio capture");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public List<byte> SpectrumData { get; set; } = new List<byte>();
|
public AudioCaptureManager AudioCaptureManager { get; set; }
|
||||||
|
|
||||||
public string Name => "Keyboard - Audio visualization";
|
public string Name => "Keyboard - Audio visualization";
|
||||||
public bool ShowInEdtor => true;
|
public bool ShowInEdtor => true;
|
||||||
@ -72,9 +51,9 @@ namespace Artemis.Profiles.Layers.Types.Audio
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(LayerModel layer, DrawingContext c)
|
public void Draw(LayerModel layerModel, DrawingContext c)
|
||||||
{
|
{
|
||||||
lock (SpectrumData)
|
lock (_audioLayers)
|
||||||
{
|
{
|
||||||
foreach (var audioLayer in _audioLayers)
|
foreach (var audioLayer in _audioLayers)
|
||||||
{
|
{
|
||||||
@ -84,10 +63,10 @@ namespace Artemis.Profiles.Layers.Types.Audio
|
|||||||
var oldX = audioLayer.Properties.X;
|
var oldX = audioLayer.Properties.X;
|
||||||
var oldY = audioLayer.Properties.Y;
|
var oldY = audioLayer.Properties.Y;
|
||||||
|
|
||||||
audioLayer.Properties.Width = layer.Properties.Width;
|
audioLayer.Properties.Width = layerModel.Properties.Width;
|
||||||
audioLayer.Properties.Height = layer.Properties.Height;
|
audioLayer.Properties.Height = layerModel.Properties.Height;
|
||||||
audioLayer.Properties.X = layer.Properties.X;
|
audioLayer.Properties.X = layerModel.Properties.X;
|
||||||
audioLayer.Properties.Y = layer.Properties.Y;
|
audioLayer.Properties.Y = layerModel.Properties.Y;
|
||||||
audioLayer.LayerType.Draw(audioLayer, c);
|
audioLayer.LayerType.Draw(audioLayer, c);
|
||||||
|
|
||||||
audioLayer.Properties.Width = oldWidth;
|
audioLayer.Properties.Width = oldWidth;
|
||||||
@ -100,21 +79,29 @@ namespace Artemis.Profiles.Layers.Types.Audio
|
|||||||
|
|
||||||
public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
|
public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
|
||||||
{
|
{
|
||||||
if ((_device == null) || isPreview)
|
layerModel.ApplyProperties(true);
|
||||||
|
if (isPreview)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lock (SpectrumData)
|
lock (_audioLayers)
|
||||||
{
|
{
|
||||||
UpdateLayers(layerModel);
|
SetupLayers(layerModel);
|
||||||
|
var spectrumData = AudioCaptureManager.GetSpectrumData(_lines);
|
||||||
if (!SpectrumData.Any())
|
if (!spectrumData.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var settings = (AudioPropertiesModel) layerModel.Properties;
|
var settings = (AudioPropertiesModel) layerModel.Properties;
|
||||||
if ((settings.Direction == Direction.TopToBottom) || (settings.Direction == Direction.BottomToTop))
|
switch (settings.Direction)
|
||||||
ApplyVertical(settings);
|
{
|
||||||
else if ((settings.Direction == Direction.LeftToRight) || (settings.Direction == Direction.RightToLeft))
|
case Direction.TopToBottom:
|
||||||
ApplyHorizontal(settings);
|
case Direction.BottomToTop:
|
||||||
|
ApplyVertical(spectrumData, settings);
|
||||||
|
break;
|
||||||
|
case Direction.LeftToRight:
|
||||||
|
case Direction.RightToLeft:
|
||||||
|
ApplyHorizontal(spectrumData, settings);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,14 +125,14 @@ namespace Artemis.Profiles.Layers.Types.Audio
|
|||||||
return new AudioPropertiesViewModel(layerEditorViewModel);
|
return new AudioPropertiesViewModel(layerEditorViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyVertical(AudioPropertiesModel settings)
|
private void ApplyVertical(List<byte> spectrumData, AudioPropertiesModel settings)
|
||||||
{
|
{
|
||||||
var index = 0;
|
var index = 0;
|
||||||
foreach (var audioLayer in _audioLayers)
|
foreach (var audioLayer in _audioLayers)
|
||||||
{
|
{
|
||||||
int height;
|
int height;
|
||||||
if (SpectrumData.Count > index)
|
if (spectrumData.Count > index)
|
||||||
height = (int) Math.Round(SpectrumData[index]/2.55);
|
height = (int) Math.Round(spectrumData[index]/2.55);
|
||||||
else
|
else
|
||||||
height = 0;
|
height = 0;
|
||||||
|
|
||||||
@ -169,14 +156,14 @@ namespace Artemis.Profiles.Layers.Types.Audio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyHorizontal(AudioPropertiesModel settings)
|
private void ApplyHorizontal(List<byte> spectrumData, AudioPropertiesModel settings)
|
||||||
{
|
{
|
||||||
var index = 0;
|
var index = 0;
|
||||||
foreach (var audioLayer in _audioLayers)
|
foreach (var audioLayer in _audioLayers)
|
||||||
{
|
{
|
||||||
int width;
|
int width;
|
||||||
if (SpectrumData.Count > index)
|
if (spectrumData.Count > index)
|
||||||
width = (int) Math.Round(SpectrumData[index]/2.55);
|
width = (int) Math.Round(spectrumData[index]/2.55);
|
||||||
else
|
else
|
||||||
width = 0;
|
width = 0;
|
||||||
|
|
||||||
@ -220,6 +207,7 @@ namespace Artemis.Profiles.Layers.Types.Audio
|
|||||||
// Fake the height and width and update the animation
|
// Fake the height and width and update the animation
|
||||||
audioLayer.Properties.Width = settings.Width;
|
audioLayer.Properties.Width = settings.Width;
|
||||||
audioLayer.Properties.Height = settings.Height;
|
audioLayer.Properties.Height = settings.Height;
|
||||||
|
audioLayer.LastRender = DateTime.Now;
|
||||||
audioLayer.LayerAnimation?.Update(audioLayer, true);
|
audioLayer.LayerAnimation?.Update(audioLayer, true);
|
||||||
|
|
||||||
// Restore the height and width
|
// Restore the height and width
|
||||||
@ -228,112 +216,79 @@ namespace Artemis.Profiles.Layers.Types.Audio
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the inner layers when the settings have changed
|
/// Sets up the inner layers when the settings have changed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="layerModel"></param>
|
/// <param name="layerModel"></param>
|
||||||
private void UpdateLayers(LayerModel layerModel)
|
private void SetupLayers(LayerModel layerModel)
|
||||||
{
|
{
|
||||||
// TODO: Animation
|
// Checking on settings update is expensive, only do it every second
|
||||||
|
if (DateTime.Now - _lastUpdate < TimeSpan.FromSeconds(1))
|
||||||
|
return;
|
||||||
|
_lastUpdate = DateTime.Now;
|
||||||
|
|
||||||
var settings = (AudioPropertiesModel) layerModel.Properties;
|
var settings = (AudioPropertiesModel) layerModel.Properties;
|
||||||
if ((settings.Direction == _previousSettings?.Direction) &&
|
var currentSettings = JsonConvert.SerializeObject(settings, Formatting.Indented);
|
||||||
(settings.Sensitivity == _previousSettings.Sensitivity) &&
|
var currentType = _audioLayers.FirstOrDefault()?.LayerAnimation?.GetType();
|
||||||
(Math.Abs(settings.FadeSpeed - _previousSettings.FadeSpeed) < 0.001))
|
|
||||||
|
if (currentSettings == _previousSettings && (layerModel.LayerAnimation.GetType() == currentType))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_previousSettings = GeneralHelpers.Clone((AudioPropertiesModel) layerModel.Properties);
|
_previousSettings = JsonConvert.SerializeObject(settings, Formatting.Indented);
|
||||||
|
|
||||||
_audioLayers.Clear();
|
_audioLayers.Clear();
|
||||||
if ((settings.Direction == Direction.TopToBottom) || (settings.Direction == Direction.BottomToTop))
|
switch (settings.Direction)
|
||||||
SetupVertical(settings);
|
{
|
||||||
else if ((settings.Direction == Direction.LeftToRight) || (settings.Direction == Direction.RightToLeft))
|
case Direction.TopToBottom:
|
||||||
SetupHorizontal(settings);
|
case Direction.BottomToTop:
|
||||||
|
SetupVertical(layerModel);
|
||||||
|
break;
|
||||||
|
case Direction.LeftToRight:
|
||||||
|
case Direction.RightToLeft:
|
||||||
|
SetupHorizontal(layerModel);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupVertical(AudioPropertiesModel settings)
|
private void SetupVertical(LayerModel layerModel)
|
||||||
{
|
{
|
||||||
_lines = (int) settings.Width;
|
_lines = (int) layerModel.Properties.Width;
|
||||||
for (var i = 0; i < _lines; i++)
|
for (var i = 0; i < _lines; i++)
|
||||||
{
|
{
|
||||||
var layer = LayerModel.CreateLayer();
|
var layer = LayerModel.CreateLayer();
|
||||||
layer.Properties.X = settings.X + i;
|
layer.Properties.X = layerModel.Properties.X + i;
|
||||||
layer.Properties.Y = settings.Y;
|
layer.Properties.Y = layerModel.Properties.Y;
|
||||||
layer.Properties.Width = 1;
|
layer.Properties.Width = 1;
|
||||||
layer.Properties.Height = 0;
|
layer.Properties.Height = 0;
|
||||||
// TODO: Setup animation
|
layer.Properties.AnimationSpeed = layerModel.Properties.AnimationSpeed;
|
||||||
layer.LayerAnimation = new NoneAnimation();
|
layer.Properties.Brush = layerModel.Properties.Brush;
|
||||||
layer.Properties.Brush = settings.Brush;
|
|
||||||
layer.Properties.Contain = false;
|
layer.Properties.Contain = false;
|
||||||
|
layer.LayerAnimation = (ILayerAnimation) _kernel.Get(layerModel.LayerAnimation.GetType());
|
||||||
|
|
||||||
_audioLayers.Add(layer);
|
_audioLayers.Add(layer);
|
||||||
layer.Update(null, false, true);
|
layer.Update(null, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupHorizontal(AudioPropertiesModel settings)
|
private void SetupHorizontal(LayerModel layerModel)
|
||||||
{
|
{
|
||||||
_lines = (int) settings.Height;
|
_lines = (int) layerModel.Properties.Height;
|
||||||
for (var i = 0; i < _lines; i++)
|
for (var i = 0; i < _lines; i++)
|
||||||
{
|
{
|
||||||
var layer = LayerModel.CreateLayer();
|
var layer = LayerModel.CreateLayer();
|
||||||
layer.Properties.X = settings.X;
|
layer.Properties.X = layerModel.Properties.X;
|
||||||
layer.Properties.Y = settings.Y + i;
|
layer.Properties.Y = layerModel.Properties.Y + i;
|
||||||
layer.Properties.Width = 0;
|
layer.Properties.Width = 0;
|
||||||
layer.Properties.Height = 1;
|
layer.Properties.Height = 1;
|
||||||
// TODO: Setup animation
|
layer.Properties.AnimationSpeed = layerModel.Properties.AnimationSpeed;
|
||||||
layer.LayerAnimation = new NoneAnimation();
|
layer.Properties.Brush = layerModel.Properties.Brush;
|
||||||
layer.Properties.Brush = settings.Brush;
|
|
||||||
layer.Properties.Contain = false;
|
layer.Properties.Contain = false;
|
||||||
|
layer.LayerAnimation = (ILayerAnimation) _kernel.Get(layerModel.LayerAnimation.GetType());
|
||||||
|
|
||||||
_audioLayers.Add(layer);
|
_audioLayers.Add(layer);
|
||||||
layer.Update(null, false, true);
|
layer.Update(null, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void FftCalculated(object sender, FftEventArgs e)
|
|
||||||
{
|
|
||||||
if (_lines == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
lock (SpectrumData)
|
|
||||||
{
|
|
||||||
int x;
|
|
||||||
var b0 = 0;
|
|
||||||
|
|
||||||
SpectrumData.Clear();
|
|
||||||
for (x = 0; x < _lines; x++)
|
|
||||||
{
|
|
||||||
float peak = 0;
|
|
||||||
var b1 = (int) Math.Pow(2, x*10.0/(_lines - 1));
|
|
||||||
if (b1 > 1023)
|
|
||||||
b1 = 1023;
|
|
||||||
if (b1 <= b0)
|
|
||||||
b1 = b0 + 1;
|
|
||||||
for (; b0 < b1; b0++)
|
|
||||||
if (peak < e.Result[1 + b0].X)
|
|
||||||
peak = e.Result[1 + b0].X;
|
|
||||||
var y = (int) (Math.Sqrt(peak)*3*255 - 4);
|
|
||||||
if (y > 255)
|
|
||||||
y = 255;
|
|
||||||
if (y < 0)
|
|
||||||
y = 0;
|
|
||||||
SpectrumData.Add((byte) y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Check how often this is called
|
|
||||||
private void OnDataAvailable(object sender, WaveInEventArgs e)
|
|
||||||
{
|
|
||||||
var buffer = e.Buffer;
|
|
||||||
var bytesRecorded = e.BytesRecorded;
|
|
||||||
var bufferIncrement = _waveIn.WaveFormat.BlockAlign;
|
|
||||||
|
|
||||||
for (var index = 0; index < bytesRecorded; index += bufferIncrement)
|
|
||||||
{
|
|
||||||
var sample32 = BitConverter.ToSingle(buffer, index);
|
|
||||||
_sampleAggregator.Add(sample32);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Windows;
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Artemis.Models.Interfaces;
|
using Artemis.Models.Interfaces;
|
||||||
using Artemis.Profiles.Layers.Abstract;
|
using Artemis.Profiles.Layers.Abstract;
|
||||||
@ -13,7 +12,7 @@ namespace Artemis.Profiles.Layers.Types.Folder
|
|||||||
{
|
{
|
||||||
public class FolderType : ILayerType
|
public class FolderType : ILayerType
|
||||||
{
|
{
|
||||||
public string Name { get; } = "Folder";
|
public string Name => "Folder";
|
||||||
public bool ShowInEdtor { get; } = false;
|
public bool ShowInEdtor { get; } = false;
|
||||||
// FolderType pretents to be a keyboard so it's children get drawn
|
// FolderType pretents to be a keyboard so it's children get drawn
|
||||||
public DrawType DrawType { get; } = DrawType.Keyboard;
|
public DrawType DrawType { get; } = DrawType.Keyboard;
|
||||||
@ -29,7 +28,7 @@ namespace Artemis.Profiles.Layers.Types.Folder
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(LayerModel layer, DrawingContext c)
|
public void Draw(LayerModel layerModel, DrawingContext c)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,8 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:ncore="http://schemas.ncore.com/wpf/xaml/colorbox"
|
xmlns:ncore="http://schemas.ncore.com/wpf/xaml/colorbox"
|
||||||
xmlns:ObjectModel="clr-namespace:System.Collections.ObjectModel;assembly=System" x:Class="Artemis.Profiles.Layers.Types.Generic.GenericPropertiesView"
|
xmlns:ObjectModel="clr-namespace:System.Collections.ObjectModel;assembly=System"
|
||||||
|
x:Class="Artemis.Profiles.Layers.Types.Generic.GenericPropertiesView"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="600" d:DesignWidth="500">
|
d:DesignHeight="600" d:DesignWidth="500">
|
||||||
<Grid>
|
<Grid>
|
||||||
@ -49,7 +50,8 @@
|
|||||||
VerticalAlignment="Top" Height="18" Width="130" />
|
VerticalAlignment="Top" Height="18" Width="130" />
|
||||||
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
|
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
|
||||||
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
|
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
|
||||||
<ncore:ColorBox Brush="{Binding Brush, Mode=TwoWay}" Height="24" Width="134"/>
|
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" ShowNone="False" Height="24" Width="134"
|
||||||
|
VerticalAlignment="Top" />
|
||||||
</Border>
|
</Border>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
@ -63,7 +65,15 @@
|
|||||||
<!-- Note -->
|
<!-- Note -->
|
||||||
<TextBlock Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" Margin="10,2,10,10" FontSize="13.333"
|
<TextBlock Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" Margin="10,2,10,10" FontSize="13.333"
|
||||||
Foreground="{DynamicResource HighlightBrush}"
|
Foreground="{DynamicResource HighlightBrush}"
|
||||||
VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap"><Run Text="Note: Generic devices are devices over which Artemis has limited control." /><LineBreak /><Run /><LineBreak /><Run Text="You can use this layer type to assign a color to all generic devices at once." /><LineBreak /><Run
|
VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap">
|
||||||
Text="Should your generic device have multiple LEDs, Artemis will try to take the colors from the Brush and spread them over the LEDs." /><LineBreak /><Run /><LineBreak /><Run Text="Examples of supported generic devices:" /><LineBreak /><Run Text="- Logitech mice and headsets" /><LineBreak /><Run Text="- Logitech G19" /><LineBreak /><Run Text="- Logitech G510" /><LineBreak /><Run /></TextBlock>
|
<Run Text="Note: Generic devices are devices over which Artemis has limited control." /><LineBreak />
|
||||||
|
<Run /><LineBreak />
|
||||||
|
<Run Text="You can use this layer type to assign a color to all generic devices at once." /><LineBreak />
|
||||||
|
<Run
|
||||||
|
Text="Should your generic device have multiple LEDs, Artemis will try to take the colors from the Brush and spread them over the LEDs." />
|
||||||
|
<LineBreak /><Run /><LineBreak /><Run Text="Examples of supported generic devices:" /><LineBreak />
|
||||||
|
<Run Text="- Logitech mice and headsets" /><LineBreak /><Run Text="- Logitech G19" /><LineBreak />
|
||||||
|
<Run Text="- Logitech G510" /><LineBreak /><Run />
|
||||||
|
</TextBlock>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Linq;
|
||||||
using System.Linq;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Artemis.Models.Interfaces;
|
using Artemis.Models.Interfaces;
|
||||||
@ -15,7 +14,7 @@ namespace Artemis.Profiles.Layers.Types.Generic
|
|||||||
{
|
{
|
||||||
public class GenericType : ILayerType
|
public class GenericType : ILayerType
|
||||||
{
|
{
|
||||||
public string Name { get; } = "Generic (Logitech)";
|
public string Name => "Generic (Logitech)";
|
||||||
public bool ShowInEdtor { get; } = false;
|
public bool ShowInEdtor { get; } = false;
|
||||||
public DrawType DrawType { get; } = DrawType.Generic;
|
public DrawType DrawType { get; } = DrawType.Generic;
|
||||||
|
|
||||||
@ -32,24 +31,21 @@ namespace Artemis.Profiles.Layers.Types.Generic
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(LayerModel layer, DrawingContext c)
|
public void Draw(LayerModel layerModel, DrawingContext c)
|
||||||
{
|
{
|
||||||
// If an animation is present, let it handle the drawing
|
// If an animation is present, let it handle the drawing
|
||||||
if (layer.LayerAnimation != null && !(layer.LayerAnimation is NoneAnimation))
|
if (layerModel.LayerAnimation != null && !(layerModel.LayerAnimation is NoneAnimation))
|
||||||
{
|
{
|
||||||
layer.LayerAnimation.Draw(layer.Properties, layer.AppliedProperties, c);
|
layerModel.LayerAnimation.Draw(layerModel, c);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise draw the rectangle with its applied dimensions and brush
|
// Otherwise draw the rectangle with its applied dimensions and brush
|
||||||
var rect = new Rect(layer.AppliedProperties.X*4,
|
var rect = layerModel.LayerRect();
|
||||||
layer.AppliedProperties.Y*4,
|
|
||||||
layer.AppliedProperties.Width*4,
|
|
||||||
layer.AppliedProperties.Height*4);
|
|
||||||
|
|
||||||
// Can't meddle with the original brush because it's frozen.
|
// Can't meddle with the original brush because it's frozen.
|
||||||
var brush = layer.AppliedProperties.Brush.Clone();
|
var brush = layerModel.Brush.Clone();
|
||||||
brush.Opacity = layer.AppliedProperties.Opacity;
|
brush.Opacity = layerModel.Opacity;
|
||||||
|
|
||||||
c.PushClip(new RectangleGeometry(rect));
|
c.PushClip(new RectangleGeometry(rect));
|
||||||
c.DrawRectangle(brush, null, rect);
|
c.DrawRectangle(brush, null, rect);
|
||||||
@ -65,15 +61,14 @@ namespace Artemis.Profiles.Layers.Types.Generic
|
|||||||
layerModel.Properties.Y = 0;
|
layerModel.Properties.Y = 0;
|
||||||
layerModel.Properties.Contain = true;
|
layerModel.Properties.Contain = true;
|
||||||
|
|
||||||
layerModel.AppliedProperties = new SimplePropertiesModel(layerModel.Properties);
|
layerModel.ApplyProperties(false);
|
||||||
|
|
||||||
if (isPreview || dataModel == null)
|
if (isPreview || dataModel == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If not previewing, apply dynamic properties according to datamodel
|
// If not previewing, apply dynamic properties according to datamodel
|
||||||
var props = (SimplePropertiesModel) layerModel.AppliedProperties;
|
foreach (var dynamicProperty in layerModel.Properties.DynamicProperties)
|
||||||
foreach (var dynamicProperty in props.DynamicProperties)
|
dynamicProperty.ApplyProperty(dataModel, layerModel);
|
||||||
dynamicProperty.ApplyProperty(dataModel, layerModel.AppliedProperties);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetupProperties(LayerModel layerModel)
|
public void SetupProperties(LayerModel layerModel)
|
||||||
|
|||||||
@ -48,7 +48,8 @@
|
|||||||
VerticalAlignment="Top" Height="18" Width="130" />
|
VerticalAlignment="Top" Height="18" Width="130" />
|
||||||
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
|
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
|
||||||
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
|
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
|
||||||
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" Height="24" Width="134" />
|
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" ShowNone="False" Height="24" Width="134"
|
||||||
|
VerticalAlignment="Top" />
|
||||||
</Border>
|
</Border>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Linq;
|
||||||
using System.Linq;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Artemis.Models.Interfaces;
|
using Artemis.Models.Interfaces;
|
||||||
@ -15,7 +14,7 @@ namespace Artemis.Profiles.Layers.Types.Headset
|
|||||||
{
|
{
|
||||||
public class HeadsetType : ILayerType
|
public class HeadsetType : ILayerType
|
||||||
{
|
{
|
||||||
public string Name { get; } = "Headset";
|
public string Name => "Headset";
|
||||||
public bool ShowInEdtor { get; } = false;
|
public bool ShowInEdtor { get; } = false;
|
||||||
public DrawType DrawType { get; } = DrawType.Headset;
|
public DrawType DrawType { get; } = DrawType.Headset;
|
||||||
|
|
||||||
@ -30,24 +29,21 @@ namespace Artemis.Profiles.Layers.Types.Headset
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(LayerModel layer, DrawingContext c)
|
public void Draw(LayerModel layerModel, DrawingContext c)
|
||||||
{
|
{
|
||||||
// If an animation is present, let it handle the drawing
|
// If an animation is present, let it handle the drawing
|
||||||
if (layer.LayerAnimation != null && !(layer.LayerAnimation is NoneAnimation))
|
if (layerModel.LayerAnimation != null && !(layerModel.LayerAnimation is NoneAnimation))
|
||||||
{
|
{
|
||||||
layer.LayerAnimation.Draw(layer.Properties, layer.AppliedProperties, c);
|
layerModel.LayerAnimation.Draw(layerModel, c);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise draw the rectangle with its applied dimensions and brush
|
// Otherwise draw the rectangle with its applied dimensions and brush
|
||||||
var rect = new Rect(layer.AppliedProperties.X*4,
|
var rect = layerModel.LayerRect();
|
||||||
layer.AppliedProperties.Y*4,
|
|
||||||
layer.AppliedProperties.Width*4,
|
|
||||||
layer.AppliedProperties.Height*4);
|
|
||||||
|
|
||||||
// Can't meddle with the original brush because it's frozen.
|
// Can't meddle with the original brush because it's frozen.
|
||||||
var brush = layer.AppliedProperties.Brush.Clone();
|
var brush = layerModel.Brush.Clone();
|
||||||
brush.Opacity = layer.AppliedProperties.Opacity;
|
brush.Opacity = layerModel.Opacity;
|
||||||
|
|
||||||
c.PushClip(new RectangleGeometry(rect));
|
c.PushClip(new RectangleGeometry(rect));
|
||||||
c.DrawRectangle(brush, null, rect);
|
c.DrawRectangle(brush, null, rect);
|
||||||
@ -63,15 +59,14 @@ namespace Artemis.Profiles.Layers.Types.Headset
|
|||||||
layerModel.Properties.Y = 0;
|
layerModel.Properties.Y = 0;
|
||||||
layerModel.Properties.Contain = true;
|
layerModel.Properties.Contain = true;
|
||||||
|
|
||||||
layerModel.AppliedProperties = new SimplePropertiesModel(layerModel.Properties);
|
layerModel.ApplyProperties(true);
|
||||||
|
|
||||||
if (isPreview || dataModel == null)
|
if (isPreview || dataModel == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If not previewing, apply dynamic properties according to datamodel
|
// If not previewing, apply dynamic properties according to datamodel
|
||||||
var props = (SimplePropertiesModel) layerModel.AppliedProperties;
|
foreach (var dynamicProperty in layerModel.Properties.DynamicProperties)
|
||||||
foreach (var dynamicProperty in props.DynamicProperties)
|
dynamicProperty.ApplyProperty(dataModel, layerModel);
|
||||||
dynamicProperty.ApplyProperty(dataModel, layerModel.AppliedProperties);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetupProperties(LayerModel layerModel)
|
public void SetupProperties(LayerModel layerModel)
|
||||||
|
|||||||
@ -44,7 +44,7 @@
|
|||||||
VerticalAlignment="Top" Height="18" Width="130" />
|
VerticalAlignment="Top" Height="18" Width="130" />
|
||||||
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
|
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
|
||||||
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
|
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
|
||||||
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" Height="24" Width="134"
|
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" ShowNone="False" Height="24" Width="134"
|
||||||
VerticalAlignment="Top" />
|
VerticalAlignment="Top" />
|
||||||
</Border>
|
</Border>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@ -32,7 +32,7 @@ namespace Artemis.Profiles.Layers.Types.KeyPress
|
|||||||
public RadialGradientBrush TempBrush { get; set; }
|
public RadialGradientBrush TempBrush { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public string Name { get; } = "Keyboard - Key press";
|
public string Name => "Keyboard - Key press";
|
||||||
public bool ShowInEdtor { get; } = false;
|
public bool ShowInEdtor { get; } = false;
|
||||||
public DrawType DrawType { get; } = DrawType.Keyboard;
|
public DrawType DrawType { get; } = DrawType.Keyboard;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ namespace Artemis.Profiles.Layers.Types.KeyPress
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(LayerModel layer, DrawingContext c)
|
public void Draw(LayerModel layerModel, DrawingContext c)
|
||||||
{
|
{
|
||||||
lock (_keyPressLayers)
|
lock (_keyPressLayers)
|
||||||
{
|
{
|
||||||
@ -67,7 +67,7 @@ namespace Artemis.Profiles.Layers.Types.KeyPress
|
|||||||
layerModel.Properties.Y = 0;
|
layerModel.Properties.Y = 0;
|
||||||
layerModel.Properties.Contain = true;
|
layerModel.Properties.Contain = true;
|
||||||
|
|
||||||
layerModel.AppliedProperties = new KeyPressPropertiesModel(layerModel.Properties);
|
layerModel.ApplyProperties(true);
|
||||||
|
|
||||||
_layerModel = layerModel;
|
_layerModel = layerModel;
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,7 @@
|
|||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<!-- Animation -->
|
<!-- Animation -->
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0" Margin="10" FontSize="13.333" Text="Animation:"
|
<TextBlock Grid.Row="0" Grid.Column="0" Margin="10" FontSize="13.333" Text="Animation:"
|
||||||
@ -60,7 +61,8 @@
|
|||||||
VerticalAlignment="Top" Height="18" Width="130" />
|
VerticalAlignment="Top" Height="18" Width="130" />
|
||||||
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
|
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
|
||||||
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
|
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
|
||||||
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" Height="24" Width="134"/>
|
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" ShowNone="False" Height="24" Width="134"
|
||||||
|
VerticalAlignment="Top" />
|
||||||
</Border>
|
</Border>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
@ -86,8 +88,7 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" Margin="10,2,10,10" FontSize="13.333"
|
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" Margin="10,2,10,10" FontSize="13.333"
|
||||||
Foreground="{DynamicResource HighlightBrush}"
|
Foreground="{DynamicResource HighlightBrush}"
|
||||||
Text="Note: It is recommended to use very tiny gifs (25x7 per example, for size per keyboard see FAQ). Any higher will degrade performance without any noticeable quality difference."
|
VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap" ><Run Text="Note: It is recommended to use very tiny gifs (25x7 per example, for size per keyboard see FAQ). "/><LineBreak/><Run Text="Any higher will degrade performance without any noticeable quality difference."/></TextBlock>
|
||||||
VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap" />
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- Dynamic -->
|
<!-- Dynamic -->
|
||||||
@ -98,5 +99,7 @@
|
|||||||
<ContentControl Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" x:Name="HeightProperties" />
|
<ContentControl Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" x:Name="HeightProperties" />
|
||||||
<ContentControl Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" x:Name="WidthProperties" />
|
<ContentControl Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" x:Name="WidthProperties" />
|
||||||
<ContentControl Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="4" x:Name="OpacityProperties" />
|
<ContentControl Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="4" x:Name="OpacityProperties" />
|
||||||
|
|
||||||
|
<ContentControl Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="4" x:Name="LayerTweenViewModel" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -20,6 +20,7 @@ namespace Artemis.Profiles.Layers.Types.Keyboard
|
|||||||
HeightProperties = new LayerDynamicPropertiesViewModel("Height", editorVm);
|
HeightProperties = new LayerDynamicPropertiesViewModel("Height", editorVm);
|
||||||
WidthProperties = new LayerDynamicPropertiesViewModel("Width", editorVm);
|
WidthProperties = new LayerDynamicPropertiesViewModel("Width", editorVm);
|
||||||
OpacityProperties = new LayerDynamicPropertiesViewModel("Opacity", editorVm);
|
OpacityProperties = new LayerDynamicPropertiesViewModel("Opacity", editorVm);
|
||||||
|
LayerTweenViewModel = new LayerTweenViewModel(editorVm);
|
||||||
|
|
||||||
SelectedLayerAnimation =
|
SelectedLayerAnimation =
|
||||||
LayerAnimations.FirstOrDefault(l => l.Name == editorVm.ProposedLayer.LayerAnimation?.Name) ??
|
LayerAnimations.FirstOrDefault(l => l.Name == editorVm.ProposedLayer.LayerAnimation?.Name) ??
|
||||||
@ -33,6 +34,7 @@ namespace Artemis.Profiles.Layers.Types.Keyboard
|
|||||||
public LayerDynamicPropertiesViewModel HeightProperties { get; set; }
|
public LayerDynamicPropertiesViewModel HeightProperties { get; set; }
|
||||||
public LayerDynamicPropertiesViewModel WidthProperties { get; set; }
|
public LayerDynamicPropertiesViewModel WidthProperties { get; set; }
|
||||||
public LayerDynamicPropertiesViewModel OpacityProperties { get; set; }
|
public LayerDynamicPropertiesViewModel OpacityProperties { get; set; }
|
||||||
|
public LayerTweenViewModel LayerTweenViewModel { get; set; }
|
||||||
|
|
||||||
public bool IsGif
|
public bool IsGif
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Windows;
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Artemis.Models.Interfaces;
|
using Artemis.Models.Interfaces;
|
||||||
using Artemis.Profiles.Layers.Abstract;
|
using Artemis.Profiles.Layers.Abstract;
|
||||||
@ -12,7 +11,7 @@ namespace Artemis.Profiles.Layers.Types.Keyboard
|
|||||||
{
|
{
|
||||||
public class KeyboardType : ILayerType
|
public class KeyboardType : ILayerType
|
||||||
{
|
{
|
||||||
public string Name { get; } = "Keyboard";
|
public string Name => "Keyboard";
|
||||||
public bool ShowInEdtor { get; } = true;
|
public bool ShowInEdtor { get; } = true;
|
||||||
public DrawType DrawType { get; } = DrawType.Keyboard;
|
public DrawType DrawType { get; } = DrawType.Keyboard;
|
||||||
|
|
||||||
@ -34,32 +33,26 @@ namespace Artemis.Profiles.Layers.Types.Keyboard
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(LayerModel layer, DrawingContext c)
|
public void Draw(LayerModel layerModel, DrawingContext c)
|
||||||
{
|
{
|
||||||
// If an animation is present, let it handle the drawing
|
// If an animation is present, let it handle the drawing
|
||||||
if (layer.LayerAnimation != null && !(layer.LayerAnimation is NoneAnimation))
|
if (layerModel.LayerAnimation != null && !(layerModel.LayerAnimation is NoneAnimation))
|
||||||
{
|
{
|
||||||
layer.LayerAnimation.Draw(layer.Properties, layer.AppliedProperties, c);
|
layerModel.LayerAnimation.Draw(layerModel, c);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise draw the rectangle with its layer.AppliedProperties dimensions and brush
|
// Otherwise draw the rectangle with its layer.AppliedProperties dimensions and brush
|
||||||
var rect = layer.AppliedProperties.Contain
|
var rect = layerModel.Properties.Contain
|
||||||
? new Rect(layer.AppliedProperties.X*4,
|
? layerModel.LayerRect()
|
||||||
layer.AppliedProperties.Y*4,
|
: new Rect(layerModel.Properties.X*4, layerModel.Properties.Y*4,
|
||||||
layer.AppliedProperties.Width*4,
|
layerModel.Properties.Width*4, layerModel.Properties.Height*4);
|
||||||
layer.AppliedProperties.Height*4)
|
|
||||||
: new Rect(layer.Properties.X*4,
|
|
||||||
layer.Properties.Y*4,
|
|
||||||
layer.Properties.Width*4,
|
|
||||||
layer.Properties.Height*4);
|
|
||||||
|
|
||||||
var clip = new Rect(layer.AppliedProperties.X*4, layer.AppliedProperties.Y*4,
|
var clip = layerModel.LayerRect();
|
||||||
layer.AppliedProperties.Width*4, layer.AppliedProperties.Height*4);
|
|
||||||
|
|
||||||
// Can't meddle with the original brush because it's frozen.
|
// Can't meddle with the original brush because it's frozen.
|
||||||
var brush = layer.AppliedProperties.Brush.Clone();
|
var brush = layerModel.Brush.Clone();
|
||||||
brush.Opacity = layer.AppliedProperties.Opacity;
|
brush.Opacity = layerModel.Opacity;
|
||||||
|
|
||||||
c.PushClip(new RectangleGeometry(clip));
|
c.PushClip(new RectangleGeometry(clip));
|
||||||
c.DrawRectangle(brush, null, rect);
|
c.DrawRectangle(brush, null, rect);
|
||||||
@ -68,14 +61,13 @@ namespace Artemis.Profiles.Layers.Types.Keyboard
|
|||||||
|
|
||||||
public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
|
public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
|
||||||
{
|
{
|
||||||
layerModel.AppliedProperties = new KeyboardPropertiesModel(layerModel.Properties);
|
layerModel.ApplyProperties(true);
|
||||||
if (isPreview || dataModel == null)
|
if (isPreview || dataModel == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If not previewing, apply dynamic properties according to datamodel
|
// If not previewing, apply dynamic properties according to datamodel
|
||||||
var keyboardProps = (KeyboardPropertiesModel) layerModel.AppliedProperties;
|
foreach (var dynamicProperty in layerModel.Properties.DynamicProperties)
|
||||||
foreach (var dynamicProperty in keyboardProps.DynamicProperties)
|
dynamicProperty.ApplyProperty(dataModel, layerModel);
|
||||||
dynamicProperty.ApplyProperty(dataModel, layerModel.AppliedProperties);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetupProperties(LayerModel layerModel)
|
public void SetupProperties(LayerModel layerModel)
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Drawing;
|
||||||
using System.Drawing;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
@ -16,7 +15,7 @@ namespace Artemis.Profiles.Layers.Types.KeyboardGif
|
|||||||
{
|
{
|
||||||
internal class KeyboardGifType : ILayerType
|
internal class KeyboardGifType : ILayerType
|
||||||
{
|
{
|
||||||
public string Name { get; } = "Keyboard - GIF";
|
public string Name => "Keyboard - GIF";
|
||||||
public bool ShowInEdtor { get; } = true;
|
public bool ShowInEdtor { get; } = true;
|
||||||
public DrawType DrawType { get; } = DrawType.Keyboard;
|
public DrawType DrawType { get; } = DrawType.Keyboard;
|
||||||
|
|
||||||
@ -31,28 +30,25 @@ namespace Artemis.Profiles.Layers.Types.KeyboardGif
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(LayerModel layer, DrawingContext c)
|
public void Draw(LayerModel layerModel, DrawingContext c)
|
||||||
{
|
{
|
||||||
var props = (KeyboardPropertiesModel) layer.Properties;
|
var props = (KeyboardPropertiesModel) layerModel.Properties;
|
||||||
if (string.IsNullOrEmpty(props.GifFile))
|
if (string.IsNullOrEmpty(props.GifFile))
|
||||||
return;
|
return;
|
||||||
if (!File.Exists(props.GifFile))
|
if (!File.Exists(props.GifFile))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Only reconstruct GifImage if the underlying source has changed
|
// Only reconstruct GifImage if the underlying source has changed
|
||||||
if (layer.GifImage == null)
|
if (layerModel.GifImage == null)
|
||||||
layer.GifImage = new GifImage(props.GifFile);
|
layerModel.GifImage = new GifImage(props.GifFile);
|
||||||
if (layer.GifImage.Source != props.GifFile)
|
if (layerModel.GifImage.Source != props.GifFile)
|
||||||
layer.GifImage = new GifImage(props.GifFile);
|
layerModel.GifImage = new GifImage(props.GifFile);
|
||||||
|
|
||||||
var rect = new Rect(layer.AppliedProperties.X*4,
|
var rect = new Rect(layerModel.X*4, layerModel.Y*4, layerModel.Width*4, layerModel.Height*4);
|
||||||
layer.AppliedProperties.Y*4,
|
|
||||||
layer.AppliedProperties.Width*4,
|
|
||||||
layer.AppliedProperties.Height*4);
|
|
||||||
|
|
||||||
lock (layer.GifImage)
|
lock (layerModel.GifImage)
|
||||||
{
|
{
|
||||||
var draw = layer.GifImage.GetNextFrame();
|
var draw = layerModel.GifImage.GetNextFrame();
|
||||||
using (var drawBitmap = new Bitmap(draw))
|
using (var drawBitmap = new Bitmap(draw))
|
||||||
{
|
{
|
||||||
c.DrawImage(ImageUtilities.BitmapToBitmapImage(drawBitmap), rect);
|
c.DrawImage(ImageUtilities.BitmapToBitmapImage(drawBitmap), rect);
|
||||||
@ -62,14 +58,13 @@ namespace Artemis.Profiles.Layers.Types.KeyboardGif
|
|||||||
|
|
||||||
public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
|
public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
|
||||||
{
|
{
|
||||||
layerModel.AppliedProperties = new KeyboardPropertiesModel(layerModel.Properties);
|
layerModel.ApplyProperties(true);
|
||||||
if (isPreview)
|
if (isPreview)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If not previewing, apply dynamic properties according to datamodel
|
// If not previewing, apply dynamic properties according to datamodel
|
||||||
var keyboardProps = (KeyboardPropertiesModel) layerModel.AppliedProperties;
|
foreach (var dynamicProperty in layerModel.Properties.DynamicProperties)
|
||||||
foreach (var dynamicProperty in keyboardProps.DynamicProperties)
|
dynamicProperty.ApplyProperty(dataModel, layerModel);
|
||||||
dynamicProperty.ApplyProperty(dataModel, layerModel.AppliedProperties);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetupProperties(LayerModel layerModel)
|
public void SetupProperties(LayerModel layerModel)
|
||||||
|
|||||||
@ -48,7 +48,8 @@
|
|||||||
VerticalAlignment="Top" Height="18" Width="130" />
|
VerticalAlignment="Top" Height="18" Width="130" />
|
||||||
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
|
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
|
||||||
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
|
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
|
||||||
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" Height="24" Width="134" />
|
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" ShowNone="False" Height="24" Width="134"
|
||||||
|
VerticalAlignment="Top" />
|
||||||
</Border>
|
</Border>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Linq;
|
||||||
using System.Linq;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Artemis.Models.Interfaces;
|
using Artemis.Models.Interfaces;
|
||||||
@ -15,7 +14,7 @@ namespace Artemis.Profiles.Layers.Types.Mouse
|
|||||||
{
|
{
|
||||||
public class MouseType : ILayerType
|
public class MouseType : ILayerType
|
||||||
{
|
{
|
||||||
public string Name { get; } = "Mouse";
|
public string Name => "Mouse";
|
||||||
public bool ShowInEdtor { get; } = false;
|
public bool ShowInEdtor { get; } = false;
|
||||||
public DrawType DrawType { get; } = DrawType.Mouse;
|
public DrawType DrawType { get; } = DrawType.Mouse;
|
||||||
|
|
||||||
@ -32,24 +31,21 @@ namespace Artemis.Profiles.Layers.Types.Mouse
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(LayerModel layer, DrawingContext c)
|
public void Draw(LayerModel layerModel, DrawingContext c)
|
||||||
{
|
{
|
||||||
// If an animation is present, let it handle the drawing
|
// If an animation is present, let it handle the drawing
|
||||||
if (layer.LayerAnimation != null && !(layer.LayerAnimation is NoneAnimation))
|
if (layerModel.LayerAnimation != null && !(layerModel.LayerAnimation is NoneAnimation))
|
||||||
{
|
{
|
||||||
layer.LayerAnimation.Draw(layer.Properties, layer.AppliedProperties, c);
|
layerModel.LayerAnimation.Draw(layerModel, c);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise draw the rectangle with its applied dimensions and brush
|
// Otherwise draw the rectangle with its applied dimensions and brush
|
||||||
var rect = new Rect(layer.AppliedProperties.X*4,
|
var rect = layerModel.LayerRect();
|
||||||
layer.AppliedProperties.Y*4,
|
|
||||||
layer.AppliedProperties.Width*4,
|
|
||||||
layer.AppliedProperties.Height*4);
|
|
||||||
|
|
||||||
// Can't meddle with the original brush because it's frozen.
|
// Can't meddle with the original brush because it's frozen.
|
||||||
var brush = layer.AppliedProperties.Brush.Clone();
|
var brush = layerModel.Brush.Clone();
|
||||||
brush.Opacity = layer.AppliedProperties.Opacity;
|
brush.Opacity = layerModel.Opacity;
|
||||||
|
|
||||||
c.PushClip(new RectangleGeometry(rect));
|
c.PushClip(new RectangleGeometry(rect));
|
||||||
c.DrawRectangle(brush, null, rect);
|
c.DrawRectangle(brush, null, rect);
|
||||||
@ -65,15 +61,14 @@ namespace Artemis.Profiles.Layers.Types.Mouse
|
|||||||
layerModel.Properties.Y = 0;
|
layerModel.Properties.Y = 0;
|
||||||
layerModel.Properties.Contain = true;
|
layerModel.Properties.Contain = true;
|
||||||
|
|
||||||
layerModel.AppliedProperties = new SimplePropertiesModel(layerModel.Properties);
|
layerModel.ApplyProperties(true);
|
||||||
|
|
||||||
if (isPreview || dataModel == null)
|
if (isPreview || dataModel == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If not previewing, apply dynamic properties according to datamodel
|
// If not previewing, apply dynamic properties according to datamodel
|
||||||
var props = (SimplePropertiesModel) layerModel.AppliedProperties;
|
foreach (var dynamicProperty in layerModel.Properties.DynamicProperties)
|
||||||
foreach (var dynamicProperty in props.DynamicProperties)
|
dynamicProperty.ApplyProperty(dataModel, layerModel);
|
||||||
dynamicProperty.ApplyProperty(dataModel, layerModel.AppliedProperties);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetupProperties(LayerModel layerModel)
|
public void SetupProperties(LayerModel layerModel)
|
||||||
|
|||||||
@ -48,7 +48,8 @@
|
|||||||
VerticalAlignment="Top" Height="18" Width="130" />
|
VerticalAlignment="Top" Height="18" Width="130" />
|
||||||
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
|
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
|
||||||
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
|
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
|
||||||
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" Height="24" Width="134" />
|
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" ShowNone="False" Height="24" Width="134"
|
||||||
|
VerticalAlignment="Top" />
|
||||||
</Border>
|
</Border>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Linq;
|
||||||
using System.Linq;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Artemis.Models.Interfaces;
|
using Artemis.Models.Interfaces;
|
||||||
@ -15,7 +14,7 @@ namespace Artemis.Profiles.Layers.Types.Mousemat
|
|||||||
{
|
{
|
||||||
public class MousematType : ILayerType
|
public class MousematType : ILayerType
|
||||||
{
|
{
|
||||||
public string Name { get; } = "Mousemat";
|
public string Name => "Mousemat";
|
||||||
public bool ShowInEdtor { get; } = false;
|
public bool ShowInEdtor { get; } = false;
|
||||||
public DrawType DrawType { get; } = DrawType.Mousemat;
|
public DrawType DrawType { get; } = DrawType.Mousemat;
|
||||||
|
|
||||||
@ -30,24 +29,21 @@ namespace Artemis.Profiles.Layers.Types.Mousemat
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(LayerModel layer, DrawingContext c)
|
public void Draw(LayerModel layerModel, DrawingContext c)
|
||||||
{
|
{
|
||||||
// If an animation is present, let it handle the drawing
|
// If an animation is present, let it handle the drawing
|
||||||
if (layer.LayerAnimation != null && !(layer.LayerAnimation is NoneAnimation))
|
if (layerModel.LayerAnimation != null && !(layerModel.LayerAnimation is NoneAnimation))
|
||||||
{
|
{
|
||||||
layer.LayerAnimation.Draw(layer.Properties, layer.AppliedProperties, c);
|
layerModel.LayerAnimation.Draw(layerModel, c);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise draw the rectangle with its applied dimensions and brush
|
// Otherwise draw the rectangle with its applied dimensions and brush
|
||||||
var rect = new Rect(layer.AppliedProperties.X*4,
|
var rect = layerModel.LayerRect();
|
||||||
layer.AppliedProperties.Y*4,
|
|
||||||
layer.AppliedProperties.Width*4,
|
|
||||||
layer.AppliedProperties.Height*4);
|
|
||||||
|
|
||||||
// Can't meddle with the original brush because it's frozen.
|
// Can't meddle with the original brush because it's frozen.
|
||||||
var brush = layer.AppliedProperties.Brush.Clone();
|
var brush = layerModel.Brush.Clone();
|
||||||
brush.Opacity = layer.AppliedProperties.Opacity;
|
brush.Opacity = layerModel.Opacity;
|
||||||
|
|
||||||
c.PushClip(new RectangleGeometry(rect));
|
c.PushClip(new RectangleGeometry(rect));
|
||||||
c.DrawRectangle(brush, null, rect);
|
c.DrawRectangle(brush, null, rect);
|
||||||
@ -63,15 +59,14 @@ namespace Artemis.Profiles.Layers.Types.Mousemat
|
|||||||
layerModel.Properties.Y = 0;
|
layerModel.Properties.Y = 0;
|
||||||
layerModel.Properties.Contain = true;
|
layerModel.Properties.Contain = true;
|
||||||
|
|
||||||
layerModel.AppliedProperties = new SimplePropertiesModel(layerModel.Properties);
|
layerModel.ApplyProperties(true);
|
||||||
|
|
||||||
if (isPreview || dataModel == null)
|
if (isPreview || dataModel == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If not previewing, apply dynamic properties according to datamodel
|
// If not previewing, apply dynamic properties according to datamodel
|
||||||
var props = (SimplePropertiesModel) layerModel.AppliedProperties;
|
foreach (var dynamicProperty in layerModel.Properties.DynamicProperties)
|
||||||
foreach (var dynamicProperty in props.DynamicProperties)
|
dynamicProperty.ApplyProperty(dataModel, layerModel);
|
||||||
dynamicProperty.ApplyProperty(dataModel, layerModel.AppliedProperties);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetupProperties(LayerModel layerModel)
|
public void SetupProperties(LayerModel layerModel)
|
||||||
|
|||||||
@ -19,8 +19,9 @@ namespace Artemis.Profiles.Lua
|
|||||||
public LuaLayerWrapper(LayerModel layerModel)
|
public LuaLayerWrapper(LayerModel layerModel)
|
||||||
{
|
{
|
||||||
_layerModel = layerModel;
|
_layerModel = layerModel;
|
||||||
|
SavedProperties = new LuaLayerProperties(layerModel);
|
||||||
|
|
||||||
// Triger an update to fill up the AppliedProperties
|
// Triger an update to fill up the Properties
|
||||||
_layerModel.Update(new ProfilePreviewDataModel(), true, false);
|
_layerModel.Update(new ProfilePreviewDataModel(), true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,73 +64,120 @@ namespace Artemis.Profiles.Lua
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Advanced layer properties
|
#region Render layer properties
|
||||||
|
|
||||||
public double X
|
public double X
|
||||||
{
|
{
|
||||||
get { return _layerModel.AppliedProperties.X; }
|
get { return _layerModel.X; }
|
||||||
set { _layerModel.AppliedProperties.X = value; }
|
set { _layerModel.X = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public double Y
|
public double Y
|
||||||
{
|
{
|
||||||
get { return _layerModel.AppliedProperties.Y; }
|
get { return _layerModel.Y; }
|
||||||
set { _layerModel.AppliedProperties.Y = value; }
|
set { _layerModel.Y = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public double Width
|
public double Width
|
||||||
{
|
{
|
||||||
get { return _layerModel.AppliedProperties.Width; }
|
get { return _layerModel.Width; }
|
||||||
set { _layerModel.AppliedProperties.Width = value; }
|
set { _layerModel.Width = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public double Height
|
public double Height
|
||||||
{
|
{
|
||||||
get { return _layerModel.AppliedProperties.Height; }
|
get { return _layerModel.Height; }
|
||||||
set { _layerModel.AppliedProperties.Height = value; }
|
set { _layerModel.Height = value; }
|
||||||
}
|
|
||||||
|
|
||||||
public bool Contain
|
|
||||||
{
|
|
||||||
get { return _layerModel.AppliedProperties.Contain; }
|
|
||||||
set { _layerModel.AppliedProperties.Contain = value; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double Opacity
|
public double Opacity
|
||||||
{
|
{
|
||||||
get { return _layerModel.AppliedProperties.Opacity; }
|
get { return _layerModel.Opacity; }
|
||||||
set { _layerModel.AppliedProperties.Opacity = value; }
|
set { _layerModel.Opacity = value; }
|
||||||
}
|
|
||||||
|
|
||||||
public double AnimationSpeed
|
|
||||||
{
|
|
||||||
get { return _layerModel.AppliedProperties.AnimationSpeed; }
|
|
||||||
set { _layerModel.AppliedProperties.AnimationSpeed = value; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double AnimationProgress
|
public double AnimationProgress
|
||||||
{
|
{
|
||||||
get { return _layerModel.AppliedProperties.AnimationProgress; }
|
get { return _layerModel.AnimationProgress; }
|
||||||
set { _layerModel.AppliedProperties.AnimationProgress = value; }
|
set { _layerModel.AnimationProgress = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string BrushType => _layerModel.AppliedProperties.Brush?.GetType().Name;
|
#endregion
|
||||||
|
|
||||||
|
#region Advanced layer properties
|
||||||
|
|
||||||
|
public LuaLayerProperties SavedProperties { get; set; }
|
||||||
|
|
||||||
|
public string BrushType => _layerModel.Properties.Brush?.GetType().Name;
|
||||||
|
|
||||||
public LuaBrush Brush
|
public LuaBrush Brush
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_layerModel.AppliedProperties.Brush is SolidColorBrush)
|
if (_layerModel.Properties.Brush is SolidColorBrush)
|
||||||
return new LuaSolidColorBrush(_layerModel.AppliedProperties.Brush);
|
return new LuaSolidColorBrush(_layerModel.Properties.Brush);
|
||||||
if (_layerModel.AppliedProperties.Brush is LinearGradientBrush)
|
if (_layerModel.Properties.Brush is LinearGradientBrush)
|
||||||
return new LuaLinearGradientBrush(_layerModel.AppliedProperties.Brush);
|
return new LuaLinearGradientBrush(_layerModel.Properties.Brush);
|
||||||
if (_layerModel.AppliedProperties.Brush is RadialGradientBrush)
|
if (_layerModel.Properties.Brush is RadialGradientBrush)
|
||||||
return new LuaRadialGradientBrush(_layerModel.AppliedProperties.Brush);
|
return new LuaRadialGradientBrush(_layerModel.Properties.Brush);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
set { _layerModel.AppliedProperties.Brush = value?.Brush; }
|
set { _layerModel.Properties.Brush = value?.Brush; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MoonSharpUserData]
|
||||||
|
public class LuaLayerProperties
|
||||||
|
{
|
||||||
|
private readonly LayerModel _layerModel;
|
||||||
|
|
||||||
|
public LuaLayerProperties(LayerModel layerModel)
|
||||||
|
{
|
||||||
|
_layerModel = layerModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double X
|
||||||
|
{
|
||||||
|
get { return _layerModel.Properties.X; }
|
||||||
|
set { _layerModel.Properties.X = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Y
|
||||||
|
{
|
||||||
|
get { return _layerModel.Properties.Y; }
|
||||||
|
set { _layerModel.Properties.Y = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Width
|
||||||
|
{
|
||||||
|
get { return _layerModel.Properties.Width; }
|
||||||
|
set { _layerModel.Properties.Width = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Height
|
||||||
|
{
|
||||||
|
get { return _layerModel.Properties.Height; }
|
||||||
|
set { _layerModel.Properties.Height = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Contain
|
||||||
|
{
|
||||||
|
get { return _layerModel.Properties.Contain; }
|
||||||
|
set { _layerModel.Properties.Contain = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Opacity
|
||||||
|
{
|
||||||
|
get { return _layerModel.Properties.Opacity; }
|
||||||
|
set { _layerModel.Properties.Opacity = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public double AnimationSpeed
|
||||||
|
{
|
||||||
|
get { return _layerModel.Properties.AnimationSpeed; }
|
||||||
|
set { _layerModel.Properties.AnimationSpeed = value; }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -53,8 +53,7 @@ using System.Windows;
|
|||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
|
||||||
[assembly: AssemblyVersion("1.5.0.2")]
|
[assembly: AssemblyVersion("1.6.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.5.0.2")]
|
[assembly: AssemblyFileVersion("1.6.0.0")]
|
||||||
[assembly: InternalsVisibleTo("Artemis.Tests")]
|
|
||||||
[assembly: InternalsVisibleTo("Artemis.Explorables")]
|
[assembly: InternalsVisibleTo("Artemis.Explorables")]
|
||||||
|
|
||||||
|
|||||||
10
Artemis/Artemis/Properties/Resources.Designer.cs
generated
10
Artemis/Artemis/Properties/Resources.Designer.cs
generated
@ -338,6 +338,16 @@ namespace Artemis.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap masterkeys_pro_s {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("masterkeys_pro_s", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -217,4 +217,7 @@
|
|||||||
<data name="masterkeys_pro_l" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="masterkeys_pro_l" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\Keyboards\masterkeys-pro-l.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\Keyboards\masterkeys-pro-l.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="masterkeys_pro_s" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\Keyboards\masterkeys-pro-s.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
Binary file not shown.
BIN
Artemis/Artemis/Resources/Keyboards/masterkeys-pro-s.png
Normal file
BIN
Artemis/Artemis/Resources/Keyboards/masterkeys-pro-s.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 162 KiB |
@ -60,13 +60,15 @@ namespace Artemis.Services
|
|||||||
if (window == null)
|
if (window == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
window.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
var dialog = new MarkdownDialog(window)
|
var dialog = new MarkdownDialog(window)
|
||||||
{
|
{
|
||||||
Markdown = markdown,
|
Markdown = markdown,
|
||||||
Title = title
|
Title = title
|
||||||
};
|
};
|
||||||
|
return window.ShowMetroDialogAsync(dialog);
|
||||||
window.Dispatcher.Invoke(() => window.ShowMetroDialogAsync(dialog));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<bool?> ShowQuestionMessageBox(string title, string message)
|
public override async Task<bool?> ShowQuestionMessageBox(string title, string message)
|
||||||
|
|||||||
@ -33,7 +33,7 @@ namespace Artemis.Utilities.DataReaders
|
|||||||
|
|
||||||
public static bool RestoreLogitechDll()
|
public static bool RestoreLogitechDll()
|
||||||
{
|
{
|
||||||
if (!File.Exists(LogitechPath + @"\LogitechLed.dll") || !File.Exists(LogitechPath + @"\artemis.txt"))
|
if (!DllPlaced())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|||||||
@ -49,9 +49,9 @@ namespace Artemis.Utilities.GameState
|
|||||||
{
|
{
|
||||||
_listener.Start();
|
_listener.Start();
|
||||||
}
|
}
|
||||||
catch (HttpListenerException e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
_logger.Error(e, "Couldn't start the webserver on port {0}.", Port);
|
_logger.Error(e, "Couldn't start the webserver on port {0}. Try selecting a different port", Port);
|
||||||
Running = false;
|
Running = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,9 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using PixelFormat = System.Drawing.Imaging.PixelFormat;
|
|
||||||
using Point = System.Drawing.Point;
|
|
||||||
|
|
||||||
namespace Artemis.Utilities
|
namespace Artemis.Utilities
|
||||||
{
|
{
|
||||||
|
|||||||
18
Artemis/Artemis/ViewModels/Profiles/LayerTweenViewModel.cs
Normal file
18
Artemis/Artemis/ViewModels/Profiles/LayerTweenViewModel.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using Artemis.Profiles.Layers.Models;
|
||||||
|
using Caliburn.Micro;
|
||||||
|
|
||||||
|
namespace Artemis.ViewModels.Profiles
|
||||||
|
{
|
||||||
|
public class LayerTweenViewModel : Screen
|
||||||
|
{
|
||||||
|
public LayerModel LayerModel { get; set; }
|
||||||
|
|
||||||
|
public LayerTweenViewModel(LayerEditorViewModel editorViewModel)
|
||||||
|
{
|
||||||
|
LayerModel = editorViewModel.ProposedLayer;
|
||||||
|
EaseFunctions = new BindableCollection<string> {"Linear", "In", "Out", "In/out"};
|
||||||
|
}
|
||||||
|
|
||||||
|
public BindableCollection<string> EaseFunctions { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -97,7 +97,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
// Draw the selection outline and resize indicator
|
// Draw the selection outline and resize indicator
|
||||||
if (SelectedLayer != null && SelectedLayer.MustDraw())
|
if (SelectedLayer != null && SelectedLayer.MustDraw())
|
||||||
{
|
{
|
||||||
var layerRect = SelectedLayer.Properties.GetRect();
|
var layerRect = SelectedLayer.Properties.PropertiesRect();
|
||||||
// Deflate the rect so that the border is drawn on the inside
|
// Deflate the rect so that the border is drawn on the inside
|
||||||
layerRect.Inflate(-0.2, -0.2);
|
layerRect.Inflate(-0.2, -0.2);
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
var y = pos.Y/((double) keyboard.PreviewSettings.Height/keyboard.Height);
|
var y = pos.Y/((double) keyboard.PreviewSettings.Height/keyboard.Height);
|
||||||
|
|
||||||
var hoverLayer = GetLayers().Where(l => l.MustDraw())
|
var hoverLayer = GetLayers().Where(l => l.MustDraw())
|
||||||
.FirstOrDefault(l => l.Properties.GetRect(1).Contains(x, y));
|
.FirstOrDefault(l => l.Properties.PropertiesRect(1).Contains(x, y));
|
||||||
|
|
||||||
if (hoverLayer != null)
|
if (hoverLayer != null)
|
||||||
SelectedLayer = hoverLayer;
|
SelectedLayer = hoverLayer;
|
||||||
@ -247,7 +247,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
var x = pos.X/((double) keyboard.PreviewSettings.Width/keyboard.Width);
|
var x = pos.X/((double) keyboard.PreviewSettings.Width/keyboard.Width);
|
||||||
var y = pos.Y/((double) keyboard.PreviewSettings.Height/keyboard.Height);
|
var y = pos.Y/((double) keyboard.PreviewSettings.Height/keyboard.Height);
|
||||||
var hoverLayer = GetLayers().Where(l => l.MustDraw())
|
var hoverLayer = GetLayers().Where(l => l.MustDraw())
|
||||||
.FirstOrDefault(l => l.Properties.GetRect(1).Contains(x, y));
|
.FirstOrDefault(l => l.Properties.PropertiesRect(1).Contains(x, y));
|
||||||
|
|
||||||
HandleDragging(e, x, y, hoverLayer);
|
HandleDragging(e, x, y, hoverLayer);
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
// Turn the mouse pointer into a hand if hovering over an active layer
|
// Turn the mouse pointer into a hand if hovering over an active layer
|
||||||
if (hoverLayer == SelectedLayer)
|
if (hoverLayer == SelectedLayer)
|
||||||
{
|
{
|
||||||
var rect = hoverLayer.Properties.GetRect(1);
|
var rect = hoverLayer.Properties.PropertiesRect(1);
|
||||||
KeyboardPreviewCursor =
|
KeyboardPreviewCursor =
|
||||||
Math.Sqrt(Math.Pow(x - rect.BottomRight.X, 2) + Math.Pow(y - rect.BottomRight.Y, 2)) < 0.6
|
Math.Sqrt(Math.Pow(x - rect.BottomRight.X, 2) + Math.Pow(y - rect.BottomRight.Y, 2)) < 0.6
|
||||||
? Cursors.SizeNWSE
|
? Cursors.SizeNWSE
|
||||||
@ -305,7 +305,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
// Setup the dragging state on mouse press
|
// Setup the dragging state on mouse press
|
||||||
if (_draggingLayerOffset == null && hoverLayer != null && e.LeftButton == MouseButtonState.Pressed)
|
if (_draggingLayerOffset == null && hoverLayer != null && e.LeftButton == MouseButtonState.Pressed)
|
||||||
{
|
{
|
||||||
var layerRect = hoverLayer.Properties.GetRect(1);
|
var layerRect = hoverLayer.Properties.PropertiesRect(1);
|
||||||
|
|
||||||
_draggingLayerOffset = new Point(x - SelectedLayer.Properties.X, y - SelectedLayer.Properties.Y);
|
_draggingLayerOffset = new Point(x - SelectedLayer.Properties.X, y - SelectedLayer.Properties.Y);
|
||||||
_draggingLayer = hoverLayer;
|
_draggingLayer = hoverLayer;
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
xmlns:cal="http://www.caliburnproject.org"
|
xmlns:cal="http://www.caliburnproject.org"
|
||||||
GlowBrush="{DynamicResource AccentColorBrush}" Icon="../../Resources/bow.png"
|
GlowBrush="{DynamicResource AccentColorBrush}" Icon="../../Resources/bow.png"
|
||||||
ResizeMode="NoResize">
|
ResizeMode="NoResize">
|
||||||
|
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||||
<Grid Margin="10,0">
|
<Grid Margin="10,0">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
@ -105,5 +106,5 @@
|
|||||||
Height="30" />
|
Height="30" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
</ScrollViewer>
|
||||||
</controls:MetroWindow>
|
</controls:MetroWindow>
|
||||||
47
Artemis/Artemis/Views/Profiles/LayerTweenView.xaml
Normal file
47
Artemis/Artemis/Views/Profiles/LayerTweenView.xaml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<UserControl x:Class="Artemis.Views.Profiles.LayerTweenView"
|
||||||
|
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.Profiles"
|
||||||
|
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="300" d:DesignWidth="900">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="84" />
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="84" />
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<Label Grid.Row="0" Grid.Column="0" FontSize="20" HorizontalAlignment="Left" Content="Easing"
|
||||||
|
VerticalAlignment="Bottom" />
|
||||||
|
|
||||||
|
<!-- Width -->
|
||||||
|
<TextBlock Grid.Row="1" Grid.Column="0" Margin="10" FontSize="13.333" Text="Width:" VerticalAlignment="Center" Height="18" />
|
||||||
|
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal">
|
||||||
|
<ComboBox Margin="10,10,10,0" VerticalAlignment="Top" Height="22" Width="86" ItemsSource="{Binding EaseFunctions}" SelectedItem="{Binding Path=LayerModel.Properties.WidthEase}" />
|
||||||
|
<controls:NumericUpDown Margin="0,10,10,0" Height="22" Width="105" Value="{Binding Path=LayerModel.Properties.WidthEaseTime}" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Height -->
|
||||||
|
<TextBlock Grid.Row="1" Grid.Column="2" Margin="10" FontSize="13.333" Text="Height:" VerticalAlignment="Center" Height="18" />
|
||||||
|
<StackPanel Grid.Row="1" Grid.Column="3" Orientation="Horizontal">
|
||||||
|
<ComboBox Margin="10,10,10,0" VerticalAlignment="Top" Height="22" Width="86" ItemsSource="{Binding EaseFunctions}" SelectedItem="{Binding Path=LayerModel.Properties.HeightEase}" />
|
||||||
|
<controls:NumericUpDown Margin="0,10,10,0" Height="22" Width="105" Value="{Binding Path=LayerModel.Properties.HeightEaseTime}" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Opacity -->
|
||||||
|
<TextBlock Grid.Row="2" Grid.Column="0" Margin="10" FontSize="13.333" Text="Opacity:" VerticalAlignment="Center" Height="18" />
|
||||||
|
<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal">
|
||||||
|
<ComboBox Margin="10,10,10,0" VerticalAlignment="Top" Height="22" Width="86" ItemsSource="{Binding EaseFunctions}" SelectedItem="{Binding Path=LayerModel.Properties.OpacityEase}" />
|
||||||
|
<controls:NumericUpDown Margin="0,10,10,0" Height="22" Width="105" Value="{Binding Path=LayerModel.Properties.OpacityEaseTime}" />
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
28
Artemis/Artemis/Views/Profiles/LayerTweenView.xaml.cs
Normal file
28
Artemis/Artemis/Views/Profiles/LayerTweenView.xaml.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
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.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace Artemis.Views.Profiles
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for LayerTweenView.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class LayerTweenView : UserControl
|
||||||
|
{
|
||||||
|
public LayerTweenView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
|
<package id="Betwixt" version="1.4.1" targetFramework="net461" />
|
||||||
<package id="Caliburn.Micro" version="3.0.1" targetFramework="net452" />
|
<package id="Caliburn.Micro" version="3.0.1" targetFramework="net452" />
|
||||||
<package id="Caliburn.Micro.Core" version="3.0.1" targetFramework="net452" />
|
<package id="Caliburn.Micro.Core" version="3.0.1" targetFramework="net452" />
|
||||||
<package id="Castle.Core" version="3.3.3" targetFramework="net452" />
|
<package id="Castle.Core" version="3.3.3" targetFramework="net452" />
|
||||||
|
|||||||
7
Artemis/Artemis86Wrapper/App.config
Normal file
7
Artemis/Artemis86Wrapper/App.config
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||||
|
</startup>
|
||||||
|
</configuration>
|
||||||
103
Artemis/Artemis86Wrapper/Artemis86Wrapper.csproj
Normal file
103
Artemis/Artemis86Wrapper/Artemis86Wrapper.csproj
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Artemis86Wrapper</RootNamespace>
|
||||||
|
<AssemblyName>Artemis86Wrapper</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
|
<PublishUrl>publish\</PublishUrl>
|
||||||
|
<Install>true</Install>
|
||||||
|
<InstallFrom>Disk</InstallFrom>
|
||||||
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
|
<UpdateInterval>7</UpdateInterval>
|
||||||
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
|
<UpdateRequired>false</UpdateRequired>
|
||||||
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Intergrations\IIntergrationManager.cs" />
|
||||||
|
<Compile Include="Intergrations\IIntergrationModel.cs" />
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Intergrations\Skype\SkypeManager.cs" />
|
||||||
|
<Compile Include="Intergrations\Skype\SkypeModel.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<COMReference Include="SKYPE4COMLib">
|
||||||
|
<Guid>{03282B5D-B38F-469D-849A-09B0A7F4881B}</Guid>
|
||||||
|
<VersionMajor>1</VersionMajor>
|
||||||
|
<VersionMinor>0</VersionMinor>
|
||||||
|
<Lcid>0</Lcid>
|
||||||
|
<WrapperTool>tlbimp</WrapperTool>
|
||||||
|
<Isolated>False</Isolated>
|
||||||
|
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||||
|
</COMReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||||
|
<Install>false</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
namespace Artemis86Wrapper.Intergrations
|
||||||
|
{
|
||||||
|
public interface IIntergrationManager
|
||||||
|
{
|
||||||
|
IIntergrationModel IntergrationModel { get; set; }
|
||||||
|
|
||||||
|
void Start();
|
||||||
|
void Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
namespace Artemis86Wrapper.Intergrations
|
||||||
|
{
|
||||||
|
public interface IIntergrationModel
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
59
Artemis/Artemis86Wrapper/Intergrations/Skype/SkypeManager.cs
Normal file
59
Artemis/Artemis86Wrapper/Intergrations/Skype/SkypeManager.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
using System.Timers;
|
||||||
|
using SKYPE4COMLib;
|
||||||
|
|
||||||
|
namespace Artemis86Wrapper.Intergrations.Skype
|
||||||
|
{
|
||||||
|
public class SkypeManager : IIntergrationManager
|
||||||
|
{
|
||||||
|
public SkypeManager()
|
||||||
|
{
|
||||||
|
IntergrationModel = new SkypeModel();
|
||||||
|
LoopTimer = new Timer(5000);
|
||||||
|
LoopTimer.Elapsed += UpdateSkype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SKYPE4COMLib.Skype Skype { get; set; }
|
||||||
|
public Timer LoopTimer { get; set; }
|
||||||
|
|
||||||
|
public IIntergrationModel IntergrationModel { get; set; }
|
||||||
|
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
Skype = new SKYPE4COMLib.Skype();
|
||||||
|
Skype.Attach();
|
||||||
|
|
||||||
|
LoopTimer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
LoopTimer.Stop();
|
||||||
|
Skype = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateSkype(object sender, ElapsedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = (SkypeModel) IntergrationModel;
|
||||||
|
|
||||||
|
model.Name = Skype.CurrentUser.FullName;
|
||||||
|
model.Status = Skype.CurrentUserStatus;
|
||||||
|
model.MissedCalls = Skype.MissedCalls.Count;
|
||||||
|
model.ActiveCalls = Skype.ActiveCalls.Count;
|
||||||
|
model.UnreadMessages = 0;
|
||||||
|
model.MissedCalls = model.MissedCalls = model.ActiveCalls;
|
||||||
|
foreach (ChatMessage skypeMissedMessage in Skype.MissedMessages)
|
||||||
|
if ((skypeMissedMessage.Type == TChatMessageType.cmeSaid) &&
|
||||||
|
(skypeMissedMessage.Status != TChatMessageStatus.cmsRead) &&
|
||||||
|
(skypeMissedMessage.FromHandle != Skype.CurrentUser.Handle))
|
||||||
|
model.UnreadMessages++;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// TODO: Log exception to main program
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
13
Artemis/Artemis86Wrapper/Intergrations/Skype/SkypeModel.cs
Normal file
13
Artemis/Artemis86Wrapper/Intergrations/Skype/SkypeModel.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using SKYPE4COMLib;
|
||||||
|
|
||||||
|
namespace Artemis86Wrapper.Intergrations.Skype
|
||||||
|
{
|
||||||
|
public class SkypeModel : IIntergrationModel
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public int UnreadMessages { get; set; }
|
||||||
|
public int MissedCalls { get; set; }
|
||||||
|
public int ActiveCalls { get; set; }
|
||||||
|
public TUserStatus Status { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
17
Artemis/Artemis86Wrapper/Program.cs
Normal file
17
Artemis/Artemis86Wrapper/Program.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using Artemis86Wrapper.Intergrations.Skype;
|
||||||
|
|
||||||
|
namespace Artemis86Wrapper
|
||||||
|
{
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
private static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Artemis x86 wrapper");
|
||||||
|
var skypeManager = new SkypeManager();
|
||||||
|
skypeManager.Start();
|
||||||
|
Console.WriteLine("Press any key to quit");
|
||||||
|
Console.ReadKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
39
Artemis/Artemis86Wrapper/Properties/AssemblyInfo.cs
Normal file
39
Artemis/Artemis86Wrapper/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
|
||||||
|
[assembly: AssemblyTitle("Artemis86Wrapper")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Artemis86Wrapper")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2016")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
|
||||||
|
[assembly: Guid("47a9bbfd-4bea-4d7d-8ab7-896e760b2cf2")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
5
Artemis/Artemis86Wrapper/packages.config
Normal file
5
Artemis/Artemis86Wrapper/packages.config
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net461" />
|
||||||
|
</packages>
|
||||||
Loading…
x
Reference in New Issue
Block a user