mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
commit
5aaaab98d6
@ -9,6 +9,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Razer2Artemis", "Razer2Arte
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnrealTournament2Artemis", "UnrealTournament2Artemis\UnrealTournament2Artemis.vcxproj", "{3541864F-1662-4BD6-8328-2C87AE61D152}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorBox", "ColorBox\ColorBox.csproj", "{40085232-ACED-4CBE-945B-90BA8153C151}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
CD_ROM|Any CPU = CD_ROM|Any CPU
|
||||
@ -114,6 +116,36 @@ Global
|
||||
{3541864F-1662-4BD6-8328-2C87AE61D152}.SingleImage|x64.Build.0 = Release|x64
|
||||
{3541864F-1662-4BD6-8328-2C87AE61D152}.SingleImage|x86.ActiveCfg = Release|Win32
|
||||
{3541864F-1662-4BD6-8328-2C87AE61D152}.SingleImage|x86.Build.0 = Release|Win32
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.CD_ROM|Any CPU.Build.0 = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.CD_ROM|x64.ActiveCfg = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.CD_ROM|x64.Build.0 = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.CD_ROM|x86.ActiveCfg = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.CD_ROM|x86.Build.0 = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.DVD-5|Any CPU.Build.0 = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.DVD-5|x64.ActiveCfg = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.DVD-5|x64.Build.0 = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.DVD-5|x86.ActiveCfg = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.DVD-5|x86.Build.0 = Debug|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Release|x64.Build.0 = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.Release|x86.Build.0 = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.SingleImage|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.SingleImage|Any CPU.Build.0 = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.SingleImage|x64.ActiveCfg = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.SingleImage|x64.Build.0 = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.SingleImage|x86.ActiveCfg = Release|Any CPU
|
||||
{40085232-ACED-4CBE-945B-90BA8153C151}.SingleImage|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@ -333,6 +333,10 @@
|
||||
<assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="DeltaCompressionDotNet.MsDelta" publicKeyToken="46b2138a390abf55" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
||||
|
||||
@ -143,36 +143,32 @@
|
||||
<HintPath>..\packages\Castle.Core.3.3.3\lib\net45\Castle.Core.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="ColorBox, Version=1.1.0.0, Culture=neutral, PublicKeyToken=f971124b2576acfc, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>lib\ColorBox.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Corale.Colore, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Colore.5.0.0\lib\net35\Corale.Colore.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="CUE.NET, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\CUE.NET.1.1.0\lib\net45\CUE.NET.dll</HintPath>
|
||||
<Reference Include="CUE.NET, Version=1.1.0.2, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\CUE.NET.1.1.0.2\lib\net45\CUE.NET.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="DeltaCompressionDotNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1d14d6e5194e7f4a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.dll</HintPath>
|
||||
<Reference Include="DeltaCompressionDotNet, Version=1.1.0.0, Culture=neutral, PublicKeyToken=1d14d6e5194e7f4a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="DeltaCompressionDotNet.MsDelta, Version=1.0.0.0, Culture=neutral, PublicKeyToken=46b2138a390abf55, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.MsDelta.dll</HintPath>
|
||||
<Reference Include="DeltaCompressionDotNet.MsDelta, Version=1.1.0.0, Culture=neutral, PublicKeyToken=46b2138a390abf55, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.MsDelta.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="DeltaCompressionDotNet.PatchApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3e8888ee913ed789, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DeltaCompressionDotNet.1.0.0\lib\net45\DeltaCompressionDotNet.PatchApi.dll</HintPath>
|
||||
<Reference Include="DeltaCompressionDotNet.PatchApi, Version=1.1.0.0, Culture=neutral, PublicKeyToken=3e8888ee913ed789, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.PatchApi.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="DynamicExpresso.Core, Version=1.3.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DynamicExpresso.Core.1.3.1.0\lib\net40\DynamicExpresso.Core.dll</HintPath>
|
||||
<Reference Include="DynamicExpresso.Core, Version=1.3.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\DynamicExpresso.Core.1.3.3.4\lib\net40\DynamicExpresso.Core.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="GongSolutions.Wpf.DragDrop, Version=0.1.4.3, Culture=neutral, PublicKeyToken=d19974ea350ccea1, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\gong-wpf-dragdrop.0.1.4.3\lib\net40\GongSolutions.Wpf.DragDrop.dll</HintPath>
|
||||
<Reference Include="GongSolutions.Wpf.DragDrop, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\gong-wpf-dragdrop.1.0.0\lib\net46\GongSolutions.Wpf.DragDrop.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Hardcodet.Wpf.TaskbarNotification, Version=1.0.5.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
@ -187,27 +183,27 @@
|
||||
<HintPath>..\packages\log4net.2.0.5\lib\net45-full\log4net.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="MahApps.Metro, Version=1.2.4.0, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MahApps.Metro.1.2.4.0\lib\net45\MahApps.Metro.dll</HintPath>
|
||||
<Reference Include="MahApps.Metro, Version=1.3.0.0, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MahApps.Metro.1.3.0\lib\net45\MahApps.Metro.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.dll</HintPath>
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Mdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Mdb.dll</HintPath>
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.Mdb.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Pdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Pdb.dll</HintPath>
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.Pdb.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Rocks, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Rocks.dll</HintPath>
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.Rocks.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="NAudio, Version=1.7.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
@ -239,7 +235,7 @@
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NLog.4.3.7\lib\net45\NLog.dll</HintPath>
|
||||
<HintPath>..\packages\NLog.4.3.9\lib\net45\NLog.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="NuGet.Squirrel, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
@ -247,7 +243,7 @@
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Process.NET, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Process.NET.1.0.1\lib\Process.NET.dll</HintPath>
|
||||
<HintPath>..\packages\Process.NET.1.0.5\lib\Process.NET.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Splat, Version=1.6.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
@ -255,7 +251,7 @@
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="SpotifyAPI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SpotifyAPI-NET.2.11.0\lib\SpotifyAPI.dll</HintPath>
|
||||
<HintPath>..\packages\SpotifyAPI-NET.2.12.0\lib\SpotifyAPI.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Squirrel, Version=1.4.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
@ -273,7 +269,7 @@
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Caliburn.Micro.3.0.1\lib\net45\System.Windows.Interactivity.dll</HintPath>
|
||||
<HintPath>..\packages\MahApps.Metro.1.3.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
@ -296,30 +292,6 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="Xceed.Wpf.AvalonDock, Version=2.9.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.2.9\lib\net40\Xceed.Wpf.AvalonDock.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Aero, Version=2.9.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.2.9\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Metro, Version=2.9.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.2.9\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Xceed.Wpf.AvalonDock.Themes.VS2010, Version=2.9.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.2.9\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Xceed.Wpf.DataGrid, Version=2.9.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.2.9\lib\net40\Xceed.Wpf.DataGrid.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Xceed.Wpf.Toolkit, Version=2.9.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.2.9\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
@ -652,6 +624,9 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<None Include="NLog.xsd">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="Resources\keypress.png" />
|
||||
<None Include="Resources\mousemat.png" />
|
||||
<EmbeddedResource Include="Modules\Games\UnrealTournament\Resources\ut-plugin.zip" />
|
||||
@ -659,9 +634,6 @@
|
||||
<None Include="app.manifest">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="NLog.xsd">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="Resources\generic.png" />
|
||||
<None Include="Resources\Keyboards\g810.png" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
@ -678,8 +650,11 @@
|
||||
</None>
|
||||
<AppDesigner Include="Properties\" />
|
||||
<Resource Include="Resources\bow.png" />
|
||||
<Content Include="lib\ColorBox.dll" />
|
||||
<Content Include="lib\CUE.NET.dll" />
|
||||
<Content Include="lib\Ets2SdkClient.dll" />
|
||||
<Content Include="LogitechLedEnginesWrapper.dll">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="logo.ico">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
@ -865,9 +840,6 @@
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="LogitechLedEnginesWrapper.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="Modules\Games\UnrealTournament\Resources\redeemer.gif" />
|
||||
<None Include="Modules\Games\EurotruckSimulator2\Resources\Win32\ets2-telemetry-server.dll" />
|
||||
<None Include="Modules\Games\EurotruckSimulator2\Resources\Win64\ets2-telemetry-server.dll" />
|
||||
@ -886,14 +858,19 @@
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ColorBox\ColorBox.csproj">
|
||||
<Project>{40085232-aced-4cbe-945b-90ba8153c151}</Project>
|
||||
<Name>ColorBox</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\CUE.NET.1.1.0\build\net45\CUE.NET.targets" Condition="Exists('..\packages\CUE.NET.1.1.0\build\net45\CUE.NET.targets')" />
|
||||
<Import Project="..\packages\CUE.NET.1.1.0.2\build\net45\CUE.NET.targets" Condition="Exists('..\packages\CUE.NET.1.1.0.2\build\net45\CUE.NET.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\CUE.NET.1.1.0\build\net45\CUE.NET.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CUE.NET.1.1.0\build\net45\CUE.NET.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\CUE.NET.1.1.0.2\build\net45\CUE.NET.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CUE.NET.1.1.0.2\build\net45\CUE.NET.targets'))" />
|
||||
</Target>
|
||||
<!-- 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.
|
||||
|
||||
@ -106,6 +106,8 @@ namespace Artemis.DAL
|
||||
private static void ReadProfiles()
|
||||
{
|
||||
CheckProfiles();
|
||||
InstallDefaults();
|
||||
|
||||
lock (Profiles)
|
||||
{
|
||||
Profiles.Clear();
|
||||
@ -139,7 +141,6 @@ namespace Artemis.DAL
|
||||
}
|
||||
}
|
||||
}
|
||||
InstallDefaults();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -1,17 +1,21 @@
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.DAL;
|
||||
using Artemis.DeviceProviders.Logitech.Utilities;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Settings;
|
||||
|
||||
namespace Artemis.DeviceProviders.Logitech
|
||||
{
|
||||
internal class G810 : LogitechKeyboard
|
||||
{
|
||||
private GeneralSettings _generalSettings;
|
||||
|
||||
public G810()
|
||||
{
|
||||
Name = "Logitech G810 RGB";
|
||||
Slug = "logitech-g910"; // Shares slugs with the G910 because the layout is identical
|
||||
Slug = "logitech-g810";
|
||||
CantEnableText = "Couldn't connect to your Logitech G810.\n" +
|
||||
"Please check your cables and updating the Logitech Gaming Software\n" +
|
||||
"A minimum version of 8.81.15 is required.\n\n" +
|
||||
@ -19,11 +23,14 @@ namespace Artemis.DeviceProviders.Logitech
|
||||
Height = 6;
|
||||
Width = 21;
|
||||
PreviewSettings = new PreviewSettings(675, 185, new Thickness(0, 35, 0, 0), Resources.g810);
|
||||
_generalSettings = SettingsProvider.Load<GeneralSettings>();
|
||||
}
|
||||
|
||||
public override KeyMatch? GetKeyPosition(Keys keyCode)
|
||||
{
|
||||
return KeyMap.UsEnglishOrionKeys.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
return _generalSettings.Layout == "Qwerty"
|
||||
? KeyMap.QwertyLayout.FirstOrDefault(k => k.KeyCode == keyCode)
|
||||
: KeyMap.AzertyLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,19 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.DAL;
|
||||
using Artemis.DeviceProviders.Logitech.Utilities;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Settings;
|
||||
|
||||
namespace Artemis.DeviceProviders.Logitech
|
||||
{
|
||||
internal class G910 : LogitechKeyboard
|
||||
{
|
||||
private readonly GeneralSettings _generalSettings;
|
||||
|
||||
public G910()
|
||||
{
|
||||
Name = "Logitech G910 RGB";
|
||||
@ -16,14 +22,70 @@ namespace Artemis.DeviceProviders.Logitech
|
||||
"Please check your cables and updating the Logitech Gaming Software\n" +
|
||||
"A minimum version of 8.81.15 is required.\n\n" +
|
||||
"If needed, you can select a different keyboard in Artemis under settings.";
|
||||
Height = 6;
|
||||
Width = 21;
|
||||
PreviewSettings = new PreviewSettings(540, 154, new Thickness(25, -80, 0, 0), Resources.g910);
|
||||
Height = 7;
|
||||
Width = 22;
|
||||
PreviewSettings = new PreviewSettings(570, 175, new Thickness(-10, -105, 0, 0), Resources.g910);
|
||||
_generalSettings = SettingsProvider.Load<GeneralSettings>();
|
||||
}
|
||||
|
||||
public override KeyMatch? GetKeyPosition(Keys keyCode)
|
||||
{
|
||||
return KeyMap.UsEnglishOrionKeys.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
var value = _generalSettings.Layout == "Qwerty"
|
||||
? KeyMap.QwertyLayout.FirstOrDefault(k => k.KeyCode == keyCode)
|
||||
: KeyMap.AzertyLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
|
||||
// Adjust the distance by 1 on both x and y for the G910
|
||||
return new KeyMatch(value.KeyCode, value.X + 1, value.Y + 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The G910 also updates the G-logo, G-badge and G-keys
|
||||
/// </summary>
|
||||
/// <param name="bitmap"></param>
|
||||
public override void DrawBitmap(Bitmap bitmap)
|
||||
{
|
||||
using (var croppedBitmap = new Bitmap(21*4, 6*4))
|
||||
{
|
||||
// Deal with non-standard DPI
|
||||
croppedBitmap.SetResolution(96, 96);
|
||||
// Don't forget that the image is upscaled 4 times
|
||||
using (var g = Graphics.FromImage(croppedBitmap))
|
||||
{
|
||||
g.DrawImage(bitmap, new Rectangle(0, 0, 84, 24), new Rectangle(4, 4, 84, 24), GraphicsUnit.Pixel);
|
||||
}
|
||||
|
||||
base.DrawBitmap(croppedBitmap);
|
||||
}
|
||||
|
||||
using (var resized = OrionUtilities.ResizeImage(bitmap, 22, 7))
|
||||
{
|
||||
// Color the extra keys on the left side of the keyboard
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_LOGO, 0, 1);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_1, 0, 2);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_2, 0, 3);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_3, 0, 4);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_4, 0, 5);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_5, 0, 6);
|
||||
|
||||
// Color the extra keys on the top of the keyboard
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_6, 3, 0);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_7, 4, 0);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_8, 5, 0);
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_9, 6, 0);
|
||||
|
||||
// Color the G-badge
|
||||
SetLogitechColorFromCoordinates(resized, KeyboardNames.G_BADGE, 5, 6);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetLogitechColorFromCoordinates(Bitmap bitmap, KeyboardNames key, int x, int y)
|
||||
{
|
||||
var color = bitmap.GetPixel(x, y);
|
||||
var rPer = (int) Math.Round(color.R/2.55);
|
||||
var gPer = (int) Math.Round(color.G/2.55);
|
||||
var bPer = (int) Math.Round(color.B/2.55);
|
||||
|
||||
LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(key, rPer, gPer, bPer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -16,7 +16,7 @@ namespace Artemis.DeviceProviders.Logitech
|
||||
@"SOFTWARE\Classes\Installer\Dependencies\{ca67548a-5ebe-413a-b50c-4b9ceb6d66c6}") == null)
|
||||
{
|
||||
CantEnableText = "Couldn't connect to your Logitech keyboard.\n" +
|
||||
"The Visual C 2012 Redistributable could not be found, which is required.\n" +
|
||||
"The Visual C++ 2012 Redistributable could not be found, which is required.\n" +
|
||||
"Please download it by going to the following URL:\n\n" +
|
||||
"https://www.microsoft.com/download/confirmation.aspx?id=30679";
|
||||
|
||||
@ -33,7 +33,7 @@ namespace Artemis.DeviceProviders.Logitech
|
||||
|
||||
// Turn it into one long number...
|
||||
var version = int.Parse($"{majorNum}{minorNum}{buildNum}");
|
||||
CantEnableText = "Couldn't connect to your Logitech G910.\n" +
|
||||
CantEnableText = "Couldn't connect to your Logitech keyboard.\n" +
|
||||
"Please check your cables and updating the Logitech Gaming Software\n" +
|
||||
$"A minimum version of 8.81.15 is required (detected {majorNum}.{minorNum}.{buildNum}).\n\n" +
|
||||
"If the detected version differs from the version LGS is reporting, reinstall LGS or see the FAQ.\n\n" +
|
||||
@ -58,10 +58,7 @@ namespace Artemis.DeviceProviders.Logitech
|
||||
Thread.Sleep(200);
|
||||
|
||||
LogitechGSDK.LogiLedSaveCurrentLighting();
|
||||
|
||||
// Disable keys we can't color
|
||||
LogitechGSDK.LogiLedSetTargetDevice(LogitechGSDK.LOGI_DEVICETYPE_PERKEY_RGB);
|
||||
LogitechGSDK.LogiLedSetLighting(0, 0, 0);
|
||||
}
|
||||
|
||||
public override void Disable()
|
||||
|
||||
@ -8,26 +8,25 @@ namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
static KeyMap()
|
||||
{
|
||||
// There are several keyboard layouts
|
||||
// TODO: Implemented more layouts and an option to select them
|
||||
UsEnglishOrionKeys = new List<KeyMatch>
|
||||
QwertyLayout = new List<KeyMatch>
|
||||
{
|
||||
// Row 1
|
||||
new KeyMatch(Keys.Escape, 0, 0),
|
||||
new KeyMatch(Keys.F1, 1, 0),
|
||||
new KeyMatch(Keys.F2, 2, 0),
|
||||
new KeyMatch(Keys.F3, 3, 0),
|
||||
new KeyMatch(Keys.F4, 4, 0),
|
||||
new KeyMatch(Keys.F5, 5, 0),
|
||||
new KeyMatch(Keys.F6, 6, 0),
|
||||
new KeyMatch(Keys.F7, 7, 0),
|
||||
new KeyMatch(Keys.F8, 8, 0),
|
||||
new KeyMatch(Keys.F9, 9, 0),
|
||||
new KeyMatch(Keys.F10, 10, 0),
|
||||
new KeyMatch(Keys.F11, 11, 0),
|
||||
new KeyMatch(Keys.F12, 12, 0),
|
||||
new KeyMatch(Keys.PrintScreen, 13, 0),
|
||||
new KeyMatch(Keys.Scroll, 14, 0),
|
||||
new KeyMatch(Keys.Pause, 15, 0),
|
||||
new KeyMatch(Keys.F1, 2, 0),
|
||||
new KeyMatch(Keys.F2, 3, 0),
|
||||
new KeyMatch(Keys.F3, 4, 0),
|
||||
new KeyMatch(Keys.F4, 5, 0),
|
||||
new KeyMatch(Keys.F5, 6, 0),
|
||||
new KeyMatch(Keys.F6, 7, 0),
|
||||
new KeyMatch(Keys.F7, 8, 0),
|
||||
new KeyMatch(Keys.F8, 9, 0),
|
||||
new KeyMatch(Keys.F9, 11, 0),
|
||||
new KeyMatch(Keys.F10, 12, 0),
|
||||
new KeyMatch(Keys.F11, 13, 0),
|
||||
new KeyMatch(Keys.F12, 14, 0),
|
||||
new KeyMatch(Keys.PrintScreen, 15, 0),
|
||||
new KeyMatch(Keys.Scroll, 16, 0),
|
||||
new KeyMatch(Keys.Pause, 17, 0),
|
||||
|
||||
// Row 2
|
||||
new KeyMatch(Keys.Oemtilde, 0, 1),
|
||||
@ -57,15 +56,15 @@ namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
new KeyMatch(Keys.Q, 1, 2),
|
||||
new KeyMatch(Keys.W, 2, 2),
|
||||
new KeyMatch(Keys.E, 3, 2),
|
||||
new KeyMatch(Keys.R, 4, 2),
|
||||
new KeyMatch(Keys.T, 5, 2),
|
||||
new KeyMatch(Keys.Y, 6, 2),
|
||||
new KeyMatch(Keys.U, 7, 2),
|
||||
new KeyMatch(Keys.I, 8, 2),
|
||||
new KeyMatch(Keys.O, 9, 2),
|
||||
new KeyMatch(Keys.P, 10, 2),
|
||||
new KeyMatch(Keys.OemOpenBrackets, 11, 2),
|
||||
new KeyMatch(Keys.Oem6, 12, 2),
|
||||
new KeyMatch(Keys.R, 5, 2),
|
||||
new KeyMatch(Keys.T, 6, 2),
|
||||
new KeyMatch(Keys.Y, 7, 2),
|
||||
new KeyMatch(Keys.U, 8, 2),
|
||||
new KeyMatch(Keys.I, 9, 2),
|
||||
new KeyMatch(Keys.O, 10, 2),
|
||||
new KeyMatch(Keys.P, 11, 2),
|
||||
new KeyMatch(Keys.OemOpenBrackets, 12, 2),
|
||||
new KeyMatch(Keys.Oem6, 13, 2),
|
||||
new KeyMatch(Keys.Delete, 14, 2),
|
||||
new KeyMatch(Keys.End, 15, 2),
|
||||
new KeyMatch(Keys.Next, 16, 2),
|
||||
@ -77,18 +76,18 @@ namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
// Row 4
|
||||
new KeyMatch(Keys.Capital, 0, 3),
|
||||
new KeyMatch(Keys.A, 1, 3),
|
||||
new KeyMatch(Keys.S, 2, 3),
|
||||
new KeyMatch(Keys.D, 3, 3),
|
||||
new KeyMatch(Keys.F, 4, 3),
|
||||
new KeyMatch(Keys.G, 5, 3),
|
||||
new KeyMatch(Keys.H, 6, 3),
|
||||
new KeyMatch(Keys.J, 7, 3),
|
||||
new KeyMatch(Keys.K, 8, 3),
|
||||
new KeyMatch(Keys.L, 9, 3),
|
||||
new KeyMatch(Keys.Oem1, 10, 3),
|
||||
new KeyMatch(Keys.Oem7, 11, 3),
|
||||
new KeyMatch(Keys.Oem5, 12, 3),
|
||||
new KeyMatch(Keys.Return, 13, 3),
|
||||
new KeyMatch(Keys.S, 3, 3),
|
||||
new KeyMatch(Keys.D, 4, 3),
|
||||
new KeyMatch(Keys.F, 5, 3),
|
||||
new KeyMatch(Keys.G, 6, 3),
|
||||
new KeyMatch(Keys.H, 7, 3),
|
||||
new KeyMatch(Keys.J, 8, 3),
|
||||
new KeyMatch(Keys.K, 9, 3),
|
||||
new KeyMatch(Keys.L, 10, 3),
|
||||
new KeyMatch(Keys.Oem1, 11, 3),
|
||||
new KeyMatch(Keys.Oem7, 12, 3),
|
||||
new KeyMatch(Keys.Oem5, 13, 3),
|
||||
new KeyMatch(Keys.Return, 14, 3),
|
||||
new KeyMatch(Keys.NumPad4, 17, 3),
|
||||
new KeyMatch(Keys.NumPad5, 18, 3),
|
||||
new KeyMatch(Keys.NumPad6, 19, 3),
|
||||
@ -117,8 +116,129 @@ namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
// Row 6
|
||||
new KeyMatch(Keys.LControlKey, 0, 5),
|
||||
new KeyMatch(Keys.LWin, 1, 5),
|
||||
new KeyMatch(Keys.LMenu, 2, 5),
|
||||
new KeyMatch(Keys.Space, 5, 5),
|
||||
new KeyMatch(Keys.LMenu, 3, 5),
|
||||
new KeyMatch(Keys.Space, 6, 5),
|
||||
new KeyMatch(Keys.RMenu, 11, 5),
|
||||
new KeyMatch(Keys.RWin, 12, 5),
|
||||
new KeyMatch(Keys.Apps, 13, 5),
|
||||
new KeyMatch(Keys.RControlKey, 14, 5),
|
||||
new KeyMatch(Keys.Left, 15, 5),
|
||||
new KeyMatch(Keys.Down, 16, 5),
|
||||
new KeyMatch(Keys.Right, 17, 5),
|
||||
new KeyMatch(Keys.NumPad0, 18, 5),
|
||||
new KeyMatch(Keys.Decimal, 19, 5)
|
||||
};
|
||||
|
||||
AzertyLayout = new List<KeyMatch>
|
||||
{
|
||||
// Row 1
|
||||
new KeyMatch(Keys.Escape, 0, 0),
|
||||
new KeyMatch(Keys.F1, 2, 0),
|
||||
new KeyMatch(Keys.F2, 3, 0),
|
||||
new KeyMatch(Keys.F3, 4, 0),
|
||||
new KeyMatch(Keys.F4, 5, 0),
|
||||
new KeyMatch(Keys.F5, 6, 0),
|
||||
new KeyMatch(Keys.F6, 7, 0),
|
||||
new KeyMatch(Keys.F7, 8, 0),
|
||||
new KeyMatch(Keys.F8, 9, 0),
|
||||
new KeyMatch(Keys.F9, 11, 0),
|
||||
new KeyMatch(Keys.F10, 12, 0),
|
||||
new KeyMatch(Keys.F11, 13, 0),
|
||||
new KeyMatch(Keys.F12, 14, 0),
|
||||
new KeyMatch(Keys.PrintScreen, 15, 0),
|
||||
new KeyMatch(Keys.Scroll, 16, 0),
|
||||
new KeyMatch(Keys.Pause, 17, 0),
|
||||
|
||||
// Row 2
|
||||
new KeyMatch(Keys.Oemtilde, 0, 1),
|
||||
new KeyMatch(Keys.D1, 1, 1),
|
||||
new KeyMatch(Keys.D2, 2, 1),
|
||||
new KeyMatch(Keys.D3, 3, 1),
|
||||
new KeyMatch(Keys.D4, 4, 1),
|
||||
new KeyMatch(Keys.D5, 5, 1),
|
||||
new KeyMatch(Keys.D6, 6, 1),
|
||||
new KeyMatch(Keys.D7, 7, 1),
|
||||
new KeyMatch(Keys.D8, 8, 1),
|
||||
new KeyMatch(Keys.D9, 9, 1),
|
||||
new KeyMatch(Keys.D0, 10, 1),
|
||||
new KeyMatch(Keys.OemMinus, 11, 1),
|
||||
new KeyMatch(Keys.Oemplus, 12, 1),
|
||||
new KeyMatch(Keys.Back, 13, 1),
|
||||
new KeyMatch(Keys.Insert, 14, 1),
|
||||
new KeyMatch(Keys.Home, 15, 1),
|
||||
new KeyMatch(Keys.PageUp, 16, 1),
|
||||
new KeyMatch(Keys.NumLock, 17, 1),
|
||||
new KeyMatch(Keys.Divide, 18, 1),
|
||||
new KeyMatch(Keys.Multiply, 19, 1),
|
||||
new KeyMatch(Keys.Subtract, 20, 1),
|
||||
|
||||
// Row 3
|
||||
new KeyMatch(Keys.Tab, 0, 2),
|
||||
new KeyMatch(Keys.A, 1, 2),
|
||||
new KeyMatch(Keys.Z, 2, 2),
|
||||
new KeyMatch(Keys.E, 3, 2),
|
||||
new KeyMatch(Keys.R, 5, 2),
|
||||
new KeyMatch(Keys.T, 6, 2),
|
||||
new KeyMatch(Keys.Y, 7, 2),
|
||||
new KeyMatch(Keys.U, 8, 2),
|
||||
new KeyMatch(Keys.I, 9, 2),
|
||||
new KeyMatch(Keys.O, 10, 2),
|
||||
new KeyMatch(Keys.P, 11, 2),
|
||||
new KeyMatch(Keys.OemQuotes, 12, 2),
|
||||
new KeyMatch(Keys.Oem6, 13, 2),
|
||||
new KeyMatch(Keys.Delete, 14, 2),
|
||||
new KeyMatch(Keys.End, 15, 2),
|
||||
new KeyMatch(Keys.Next, 16, 2),
|
||||
new KeyMatch(Keys.NumPad7, 17, 2),
|
||||
new KeyMatch(Keys.NumPad8, 18, 2),
|
||||
new KeyMatch(Keys.NumPad9, 19, 2),
|
||||
new KeyMatch(Keys.Add, 20, 2),
|
||||
|
||||
// Row 4
|
||||
new KeyMatch(Keys.Capital, 0, 3),
|
||||
new KeyMatch(Keys.Q, 1, 3),
|
||||
new KeyMatch(Keys.S, 3, 3),
|
||||
new KeyMatch(Keys.D, 4, 3),
|
||||
new KeyMatch(Keys.F, 5, 3),
|
||||
new KeyMatch(Keys.G, 6, 3),
|
||||
new KeyMatch(Keys.H, 7, 3),
|
||||
new KeyMatch(Keys.J, 8, 3),
|
||||
new KeyMatch(Keys.K, 9, 3),
|
||||
new KeyMatch(Keys.L, 10, 3),
|
||||
new KeyMatch(Keys.M, 11, 3),
|
||||
new KeyMatch(Keys.Oem7, 12, 3),
|
||||
new KeyMatch(Keys.Oem5, 13, 3),
|
||||
new KeyMatch(Keys.Return, 14, 3),
|
||||
new KeyMatch(Keys.NumPad4, 17, 3),
|
||||
new KeyMatch(Keys.NumPad5, 18, 3),
|
||||
new KeyMatch(Keys.NumPad6, 19, 3),
|
||||
|
||||
// Row 5
|
||||
new KeyMatch(Keys.LShiftKey, 1, 4),
|
||||
new KeyMatch(Keys.OemBackslash, 2, 4),
|
||||
new KeyMatch(Keys.W, 2, 4),
|
||||
new KeyMatch(Keys.X, 3, 4),
|
||||
new KeyMatch(Keys.C, 4, 4),
|
||||
new KeyMatch(Keys.V, 5, 4),
|
||||
new KeyMatch(Keys.B, 6, 4),
|
||||
new KeyMatch(Keys.N, 7, 4),
|
||||
new KeyMatch(Keys.OemQuestion, 8, 4),
|
||||
new KeyMatch(Keys.Oemcomma, 9, 4),
|
||||
new KeyMatch(Keys.OemPeriod, 10, 4),
|
||||
new KeyMatch(Keys.OemQuestion, 11, 4),
|
||||
new KeyMatch(Keys.RShiftKey, 13, 4),
|
||||
new KeyMatch(Keys.Up, 15, 4),
|
||||
new KeyMatch(Keys.NumPad1, 17, 4),
|
||||
new KeyMatch(Keys.NumPad2, 18, 4),
|
||||
new KeyMatch(Keys.NumPad3, 19, 4),
|
||||
// Both returns return "Return" (Yes...)
|
||||
// new OrionKey(System.Windows.Forms.Keys.Return, 20, 4),
|
||||
|
||||
// Row 6
|
||||
new KeyMatch(Keys.LControlKey, 0, 5),
|
||||
new KeyMatch(Keys.LWin, 1, 5),
|
||||
new KeyMatch(Keys.LMenu, 3, 5),
|
||||
new KeyMatch(Keys.Space, 6, 5),
|
||||
new KeyMatch(Keys.RMenu, 11, 5),
|
||||
new KeyMatch(Keys.RWin, 12, 5),
|
||||
new KeyMatch(Keys.Apps, 13, 5),
|
||||
@ -130,7 +250,8 @@ namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
new KeyMatch(Keys.Decimal, 19, 5)
|
||||
};
|
||||
}
|
||||
|
||||
public static List<KeyMatch> UsEnglishOrionKeys { get; set; }
|
||||
|
||||
public static List<KeyMatch> QwertyLayout { get; set; }
|
||||
public static List<KeyMatch> AzertyLayout { get; set; }
|
||||
}
|
||||
}
|
||||
@ -106,6 +106,16 @@ namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
ARROW_RIGHT = 0x14D,
|
||||
NUM_ZERO = 0x52,
|
||||
NUM_PERIOD = 0x53,
|
||||
TEST = 0x1
|
||||
G_1 = 0xFFF1,
|
||||
G_2 = 0xFFF2,
|
||||
G_3 = 0xFFF3,
|
||||
G_4 = 0xFFF4,
|
||||
G_5 = 0xFFF5,
|
||||
G_6 = 0xFFF6,
|
||||
G_7 = 0xFFF7,
|
||||
G_8 = 0xFFF8,
|
||||
G_9 = 0xFFF9,
|
||||
G_LOGO = 0xFFFF1,
|
||||
G_BADGE = 0xFFFF2
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
using System.Text;
|
||||
|
||||
namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
{
|
||||
@ -26,6 +25,25 @@ namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedInit();
|
||||
|
||||
//Config option functions
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedGetConfigOptionNumber([MarshalAs(UnmanagedType.LPWStr)] string configPath,
|
||||
ref double defaultNumber);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedGetConfigOptionBool([MarshalAs(UnmanagedType.LPWStr)] string configPath,
|
||||
ref bool defaultRed);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedGetConfigOptionColor([MarshalAs(UnmanagedType.LPWStr)] string configPath,
|
||||
ref int defaultRed, ref int defaultGreen, ref int defaultBlue);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedGetConfigOptionKeyInput([MarshalAs(UnmanagedType.LPWStr)] string configPath,
|
||||
StringBuilder buffer, int bufsize);
|
||||
|
||||
/////////////////////
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedSetTargetDevice(int targetDevice);
|
||||
|
||||
@ -52,6 +70,9 @@ namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedStopEffects();
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedExcludeKeysFromBitmap(KeyboardNames[] keyList, int listCount);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedSetLightingFromBitmap(byte[] bitmap);
|
||||
|
||||
@ -68,7 +89,7 @@ namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
int greenPercentage, int bluePercentage);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool LogiLedSetLightingForKeyWithKeyName(int keyCode, int redPercentage,
|
||||
public static extern bool LogiLedSetLightingForKeyWithKeyName(KeyboardNames keyCode, int redPercentage,
|
||||
int greenPercentage, int bluePercentage);
|
||||
|
||||
[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
|
||||
|
||||
@ -180,6 +180,7 @@ namespace Artemis.DeviceProviders.Logitech.Utilities
|
||||
remapped[firstTByte + j] = pixels[firstSByte + j];
|
||||
}
|
||||
|
||||
b.Dispose();
|
||||
return remapped;
|
||||
}
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ namespace Artemis.DeviceProviders.Razer
|
||||
public override KeyMatch? GetKeyPosition(Keys keyCode)
|
||||
{
|
||||
// TODO: Needs it's own keymap or a way to get it from the Chroma SDK
|
||||
return KeyMap.UsEnglishOrionKeys.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
return KeyMap.QwertyLayout.FirstOrDefault(k => k.KeyCode == keyCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows;
|
||||
using Artemis.DAL;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Models;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
@ -14,7 +15,7 @@ namespace Artemis.Modules.Effects.Bubbles
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
public BubblesModel(MainManager mainManager) : base(mainManager, new BubblesSettings(), null)
|
||||
public BubblesModel(MainManager mainManager) : base(mainManager, SettingsProvider.Load<BubblesSettings>(), null)
|
||||
{
|
||||
Name = "Bubbles";
|
||||
Initialized = false;
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
xmlns:cal="http://www.caliburnproject.org"
|
||||
xmlns:ncore="http://schemas.ncore.com/wpf/xaml/colorbox"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="476.986" d:DesignWidth="538.772">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
|
||||
@ -56,11 +57,9 @@
|
||||
Height="16" Margin="0,8">
|
||||
Bubble color
|
||||
</TextBlock>
|
||||
<xctk:ColorPicker x:Name="MiddleColor"
|
||||
SelectedColor="{Binding Path=EffectSettings.BubbleColor, Mode=TwoWay}"
|
||||
Grid.Row="1" Grid.Column="1" Width="110" HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" />
|
||||
|
||||
<ncore:ColorBox Brush="{Binding BubbleColor, Mode=TwoWay}" Grid.Row="1" Grid.Column="1" Width="110"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,5,-1,5" Height="22"
|
||||
ShowNone="False" ShowLinear="False" ShowRadial="False"/>
|
||||
<!-- Random colors -->
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Height="16" Margin="0,8">
|
||||
|
||||
@ -1,13 +1,35 @@
|
||||
using Artemis.Managers;
|
||||
using System.Windows.Media;
|
||||
using Artemis.Managers;
|
||||
using Artemis.ViewModels.Abstract;
|
||||
|
||||
namespace Artemis.Modules.Effects.Bubbles
|
||||
{
|
||||
public sealed class BubblesViewModel : EffectViewModel
|
||||
{
|
||||
private readonly BubblesModel _model;
|
||||
private SolidColorBrush _bubbleColor;
|
||||
|
||||
public BubblesViewModel(MainManager main, BubblesModel model) : base(main, model)
|
||||
{
|
||||
_model = model;
|
||||
DisplayName = "Bubbles";
|
||||
BubbleColor = new SolidColorBrush(model.Settings.BubbleColor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The bubble color wrapped in a brush to allow color selection using ColorBox
|
||||
/// </summary>
|
||||
public Brush BubbleColor
|
||||
{
|
||||
get { return _bubbleColor; }
|
||||
set
|
||||
{
|
||||
if (Equals(value, _bubbleColor)) return;
|
||||
_bubbleColor = (SolidColorBrush) value;
|
||||
|
||||
_model.Settings.BubbleColor = _bubbleColor.Color;
|
||||
NotifyOfPropertyChange(() => BubbleColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using Artemis.Models.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Artemis.Modules.Games.CounterStrike
|
||||
{
|
||||
@ -47,6 +48,10 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
|
||||
public class State
|
||||
{
|
||||
[JsonIgnore]
|
||||
public bool made_kill { get; set; }
|
||||
[JsonIgnore]
|
||||
public bool made_headshot { get; set; }
|
||||
public int health { get; set; }
|
||||
public int armor { get; set; }
|
||||
public bool helmet { get; set; }
|
||||
@ -58,15 +63,8 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
public int round_killhs { get; set; }
|
||||
}
|
||||
|
||||
public class Weapon0
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string paintkit { get; set; }
|
||||
public string type { get; set; }
|
||||
public string state { get; set; }
|
||||
}
|
||||
|
||||
public class Weapon1
|
||||
public class Weapon
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string paintkit { get; set; }
|
||||
@ -77,19 +75,12 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
public string state { get; set; }
|
||||
}
|
||||
|
||||
public class Weapon2
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string paintkit { get; set; }
|
||||
public string type { get; set; }
|
||||
public string state { get; set; }
|
||||
}
|
||||
|
||||
public class Weapons
|
||||
{
|
||||
public Weapon0 weapon_0 { get; set; }
|
||||
public Weapon1 weapon_1 { get; set; }
|
||||
public Weapon2 weapon_2 { get; set; }
|
||||
public Weapon active_weapon { get; set; }
|
||||
public Weapon weapon_0 { get; set; }
|
||||
public Weapon weapon_1 { get; set; }
|
||||
public Weapon weapon_2 { get; set; }
|
||||
}
|
||||
|
||||
public class MatchStats
|
||||
|
||||
@ -12,6 +12,11 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
{
|
||||
public class CounterStrikeModel : GameModel
|
||||
{
|
||||
private DateTime _lastHeadshot;
|
||||
private int _lastHeadshots;
|
||||
private DateTime _lastKill;
|
||||
private int _lastKills;
|
||||
|
||||
public CounterStrikeModel(MainManager mainManager)
|
||||
: base(mainManager, SettingsProvider.Load<CounterStrikeSettings>(), new CounterStrikeDataModel())
|
||||
{
|
||||
@ -42,7 +47,46 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
// TODO: Set up active weapon in the datamodel
|
||||
if (DataModel == null)
|
||||
return;
|
||||
|
||||
var dm = (CounterStrikeDataModel) DataModel;
|
||||
if (dm.player != null)
|
||||
{
|
||||
// Detect active weapon
|
||||
if (dm.player.weapons.weapon_0?.state == "active")
|
||||
dm.player.weapons.active_weapon = dm.player.weapons.weapon_0;
|
||||
else if (dm.player.weapons.weapon_1?.state == "active")
|
||||
dm.player.weapons.active_weapon = dm.player.weapons.weapon_1;
|
||||
else if (dm.player.weapons.weapon_2?.state == "active")
|
||||
dm.player.weapons.active_weapon = dm.player.weapons.weapon_2;
|
||||
|
||||
// Detect a kill
|
||||
if (dm.player.state.round_kills > _lastKills)
|
||||
{
|
||||
dm.player.state.made_kill = true;
|
||||
_lastKill = DateTime.Now;
|
||||
}
|
||||
else if (dm.player.state.made_kill && (DateTime.Now - _lastKill > TimeSpan.FromMilliseconds(500)))
|
||||
dm.player.state.made_kill = false;
|
||||
_lastKills = dm.player.state.round_kills;
|
||||
|
||||
// Detect a headshot
|
||||
if (dm.player.state.round_killhs > _lastHeadshots)
|
||||
{
|
||||
dm.player.state.made_headshot = true;
|
||||
_lastHeadshot = DateTime.Now;
|
||||
}
|
||||
else if (dm.player.state.made_headshot && (DateTime.Now - _lastHeadshot > TimeSpan.FromMilliseconds(500)))
|
||||
dm.player.state.made_headshot = false;
|
||||
_lastHeadshots = dm.player.state.round_killhs;
|
||||
|
||||
// Detect a round win
|
||||
|
||||
// Detect a round loss
|
||||
}
|
||||
|
||||
DataModel = dm;
|
||||
}
|
||||
|
||||
public void HandleGameData(object sender, GameDataReceivedEventArgs e)
|
||||
@ -56,7 +100,9 @@ namespace Artemis.Modules.Games.CounterStrike
|
||||
// Parse the JSON
|
||||
try
|
||||
{
|
||||
DataModel = JsonConvert.DeserializeObject<CounterStrikeDataModel>(jsonString);
|
||||
if (DataModel == null)
|
||||
DataModel = new CounterStrikeDataModel();
|
||||
JsonConvert.PopulateObject(jsonString, DataModel);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.DAL;
|
||||
using Artemis.Managers;
|
||||
@ -7,6 +8,7 @@ using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Settings;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.Utilities.Memory;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Artemis.Modules.Games.RocketLeague
|
||||
{
|
||||
@ -25,20 +27,20 @@ namespace Artemis.Modules.Games.RocketLeague
|
||||
Initialized = false;
|
||||
|
||||
// Generate a new offset when the game is updated
|
||||
// var offset = new GamePointersCollection
|
||||
// {
|
||||
// Game = "RocketLeague",
|
||||
// GameVersion = "1.21",
|
||||
// GameAddresses = new List<GamePointer>
|
||||
// {
|
||||
// new GamePointer
|
||||
// {
|
||||
// Description = "Boost",
|
||||
// BasePointer = new IntPtr(0x016AD528),
|
||||
// Offsets = new[] {0x304, 0x8, 0x50, 0x720, 0x224}
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//var offset = new GamePointersCollection
|
||||
//{
|
||||
// Game = "RocketLeague",
|
||||
// GameVersion = "1.24",
|
||||
// GameAddresses = new List<GamePointer>
|
||||
// {
|
||||
// new GamePointer
|
||||
// {
|
||||
// Description = "Boost",
|
||||
// BasePointer = new IntPtr(0x016BBFB4),
|
||||
// Offsets = new[] { 0xc4, 0x210, 0x320, 0x734, 0x224}
|
||||
// }
|
||||
// }
|
||||
//};
|
||||
//var res = JsonConvert.SerializeObject(offset, Formatting.Indented);
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,9 @@ using Artemis.Modules.Games.WoW.Data;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Settings;
|
||||
using Artemis.Utilities.Memory;
|
||||
using Newtonsoft.Json;
|
||||
using Process.NET;
|
||||
using Process.NET.Memory;
|
||||
|
||||
namespace Artemis.Modules.Games.WoW
|
||||
{
|
||||
@ -31,25 +33,36 @@ namespace Artemis.Modules.Games.WoW
|
||||
|
||||
Initialized = false;
|
||||
|
||||
// TODO: Retrieve from GitHub
|
||||
_pointer = new GamePointersCollection
|
||||
{
|
||||
Game = "WorldOfWarcraft",
|
||||
GameVersion = "7.0.3.22522",
|
||||
GameAddresses = new List<GamePointer>
|
||||
{
|
||||
new GamePointer
|
||||
{
|
||||
Description = "ObjectManager",
|
||||
BasePointer = new IntPtr(0x1575E10)
|
||||
},
|
||||
new GamePointer
|
||||
{
|
||||
Description = "LocalPlayer",
|
||||
BasePointer = new IntPtr(0x169BCB0)
|
||||
}
|
||||
}
|
||||
};
|
||||
_pointer = SettingsProvider.Load<OffsetSettings>().WorldOfWarcraft;
|
||||
//_pointer = new GamePointersCollection
|
||||
//{
|
||||
// Game = "WorldOfWarcraft",
|
||||
// GameVersion = "7.0.3.22810",
|
||||
// GameAddresses = new List<GamePointer>
|
||||
// {
|
||||
// new GamePointer
|
||||
// {
|
||||
// Description = "ObjectManager",
|
||||
// BasePointer = new IntPtr(0x1578070)
|
||||
// },
|
||||
// new GamePointer
|
||||
// {
|
||||
// Description = "LocalPlayer",
|
||||
// BasePointer = new IntPtr(0x169DF10)
|
||||
// },
|
||||
// new GamePointer
|
||||
// {
|
||||
// Description = "NameCache",
|
||||
// BasePointer = new IntPtr(0x151DCE8)
|
||||
// },
|
||||
// new GamePointer
|
||||
// {
|
||||
// Description = "TargetGuid",
|
||||
// BasePointer = new IntPtr(0x179C940)
|
||||
// }
|
||||
// }
|
||||
//};
|
||||
//var res = JsonConvert.SerializeObject(_pointer, Formatting.Indented);
|
||||
}
|
||||
|
||||
public int Scale { get; set; }
|
||||
@ -68,8 +81,7 @@ namespace Artemis.Modules.Games.WoW
|
||||
if (tempProcess == null)
|
||||
return;
|
||||
|
||||
_process = new ProcessSharp(tempProcess);
|
||||
_process.Memory = new ExternalProcessMemory(_process.Handle);
|
||||
_process = new ProcessSharp(tempProcess, MemoryType.Remote);
|
||||
|
||||
Initialized = true;
|
||||
}
|
||||
@ -83,10 +95,11 @@ namespace Artemis.Modules.Games.WoW
|
||||
|
||||
var objectManager = new WoWObjectManager(_process,
|
||||
_pointer.GameAddresses.First(a => a.Description == "ObjectManager").BasePointer);
|
||||
var nameCache = new WoWNameCache(_process, new IntPtr(0x151BA88));
|
||||
var nameCache = new WoWNameCache(_process,
|
||||
_pointer.GameAddresses.First(a => a.Description == "NameCache").BasePointer);
|
||||
var player = new WoWPlayer(_process,
|
||||
_pointer.GameAddresses.First(a => a.Description == "LocalPlayer").BasePointer, new IntPtr(0x179A6E0),
|
||||
true);
|
||||
_pointer.GameAddresses.First(a => a.Description == "LocalPlayer").BasePointer,
|
||||
_pointer.GameAddresses.First(a => a.Description == "TargetGuid").BasePointer, true);
|
||||
|
||||
dataModel.Player = player;
|
||||
if (dataModel.Player != null && dataModel.Player.Guid != Guid.Empty)
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.DAL;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Models;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
@ -12,13 +13,15 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
||||
{
|
||||
public class VolumeDisplayModel : OverlayModel
|
||||
{
|
||||
public VolumeDisplayModel(MainManager mainManager) : base(mainManager, new VolumeDisplaySettings())
|
||||
public VolumeDisplayModel(MainManager mainManager)
|
||||
: base(mainManager, SettingsProvider.Load<VolumeDisplaySettings>())
|
||||
{
|
||||
Name = "VolumeDisplay";
|
||||
|
||||
VolumeDisplay = new VolumeBar(MainManager.DeviceManager, (VolumeDisplaySettings) Settings);
|
||||
Settings = (VolumeDisplaySettings) base.Settings;
|
||||
VolumeDisplay = new VolumeBar(MainManager.DeviceManager, Settings);
|
||||
}
|
||||
|
||||
public new VolumeDisplaySettings Settings { get; set; }
|
||||
public VolumeBar VolumeDisplay { get; set; }
|
||||
|
||||
public override void Dispose()
|
||||
@ -67,7 +70,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
||||
|
||||
private void KeyPressTask(KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode != Keys.VolumeUp && e.KeyCode != Keys.VolumeDown)
|
||||
if ((e.KeyCode != Keys.VolumeUp) && (e.KeyCode != Keys.VolumeDown))
|
||||
return;
|
||||
|
||||
VolumeDisplay.Ttl = 1000;
|
||||
@ -76,7 +79,7 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
||||
|
||||
public override void RenderOverlay(RenderFrame frame, bool keyboardOnly)
|
||||
{
|
||||
if (MainManager.DeviceManager.ActiveKeyboard == null || VolumeDisplay == null || VolumeDisplay.Ttl < 1)
|
||||
if ((MainManager.DeviceManager.ActiveKeyboard == null) || (VolumeDisplay == null) || (VolumeDisplay.Ttl < 1))
|
||||
return;
|
||||
|
||||
using (var g = Graphics.FromImage(frame.KeyboardBitmap))
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
using System.Windows.Media;
|
||||
using Artemis.DAL;
|
||||
using Artemis.Settings;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Artemis.Modules.Overlays.VolumeDisplay
|
||||
{
|
||||
@ -7,5 +9,19 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
|
||||
{
|
||||
public Color MainColor { get; set; }
|
||||
public Color SecondaryColor { get; set; }
|
||||
|
||||
public new void Reset(bool save = false)
|
||||
{
|
||||
JsonConvert.PopulateObject("{}", this, new JsonSerializerSettings
|
||||
{
|
||||
ObjectCreationHandling = ObjectCreationHandling.Reuse
|
||||
});
|
||||
|
||||
MainColor = Colors.Red;
|
||||
SecondaryColor = Colors.GreenYellow;
|
||||
|
||||
if (save)
|
||||
SettingsProvider.Save(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
xmlns:cal="http://www.caliburnproject.org"
|
||||
xmlns:ncore="http://schemas.ncore.com/wpf/xaml/colorbox"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="476.986" d:DesignWidth="538.772">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
|
||||
@ -42,21 +43,19 @@
|
||||
Margin="0,8">
|
||||
Main volume display color
|
||||
</TextBlock>
|
||||
<xctk:ColorPicker x:Name="MainColor"
|
||||
SelectedColor="{Binding Path=OverlaySettings.MainColor, Mode=TwoWay}"
|
||||
Grid.Row="1" Grid.Column="1" Width="110" HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" />
|
||||
|
||||
<ncore:ColorBox Brush="{Binding MainColor, Mode=TwoWay}" Grid.Row="1" Grid.Column="1" Width="110"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,5,-1,5" Height="22"
|
||||
ShowNone="False" ShowLinear="False" ShowRadial="False" />
|
||||
|
||||
<!-- Secondary color -->
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" Height="16"
|
||||
Margin="0,8">
|
||||
Secondary volume display color
|
||||
</TextBlock>
|
||||
<xctk:ColorPicker x:Name="SecondaryColor"
|
||||
SelectedColor="{Binding Path=OverlaySettings.SecondaryColor, Mode=TwoWay}"
|
||||
Grid.Row="2" Grid.Column="1" Width="110" HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" />
|
||||
|
||||
<ncore:ColorBox Brush="{Binding SecondaryColor, Mode=TwoWay}" Grid.Row="2" Grid.Column="1" Width="110"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,5,-1,5" Height="22"
|
||||
ShowNone="False" ShowLinear="False" ShowRadial="False" />
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,8"
|
||||
TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="Segoe UI Semibold"
|
||||
MaxWidth="520" TextAlignment="Justify">
|
||||
|
||||
@ -1,13 +1,48 @@
|
||||
using Artemis.Managers;
|
||||
using System.Windows.Media;
|
||||
using Artemis.Managers;
|
||||
using Artemis.ViewModels.Abstract;
|
||||
|
||||
namespace Artemis.Modules.Overlays.VolumeDisplay
|
||||
{
|
||||
public sealed class VolumeDisplayViewModel : OverlayViewModel
|
||||
{
|
||||
private readonly VolumeDisplayModel _model;
|
||||
private SolidColorBrush _mainColor;
|
||||
private SolidColorBrush _secondaryColor;
|
||||
|
||||
public VolumeDisplayViewModel(MainManager mainManager, VolumeDisplayModel model) : base(mainManager, model)
|
||||
{
|
||||
_model = model;
|
||||
DisplayName = "Volume Display";
|
||||
|
||||
MainColor = new SolidColorBrush(model.Settings.MainColor);
|
||||
SecondaryColor = new SolidColorBrush(model.Settings.SecondaryColor);
|
||||
}
|
||||
|
||||
public Brush MainColor
|
||||
{
|
||||
get { return _mainColor; }
|
||||
set
|
||||
{
|
||||
if (Equals(value, _mainColor)) return;
|
||||
_mainColor = (SolidColorBrush) value;
|
||||
|
||||
_model.Settings.MainColor = _mainColor.Color;
|
||||
NotifyOfPropertyChange(() => MainColor);
|
||||
}
|
||||
}
|
||||
|
||||
public Brush SecondaryColor
|
||||
{
|
||||
get { return _secondaryColor; }
|
||||
set
|
||||
{
|
||||
if (Equals(value, _secondaryColor)) return;
|
||||
_secondaryColor = (SolidColorBrush) value;
|
||||
|
||||
_model.Settings.SecondaryColor = _secondaryColor.Color;
|
||||
NotifyOfPropertyChange(() => SecondaryColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -368,6 +368,7 @@
|
||||
<xs:element name="name" minOccurs="0" maxOccurs="1" type="xs:string" />
|
||||
<xs:element name="encoding" minOccurs="0" maxOccurs="1" type="xs:string" />
|
||||
<xs:element name="layout" minOccurs="0" maxOccurs="1" type="Layout" />
|
||||
<xs:element name="lineEnding" minOccurs="0" maxOccurs="1" type="LineEndingMode" />
|
||||
<xs:element name="maxMessageSize" minOccurs="0" maxOccurs="1" type="xs:integer" />
|
||||
<xs:element name="newLine" minOccurs="0" maxOccurs="1" type="xs:boolean" />
|
||||
<xs:element name="onConnectionOverflow" minOccurs="0" maxOccurs="1" type="NLog.Targets.NetworkTargetConnectionsOverflowAction" />
|
||||
@ -401,6 +402,11 @@
|
||||
<xs:documentation>Instance of that is used to format log messages.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="lineEnding" type="LineEndingMode">
|
||||
<xs:annotation>
|
||||
<xs:documentation>End of line value if a newline is appended at the end of log message .</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="maxMessageSize" type="xs:integer">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Maximum message size in bytes.</xs:documentation>
|
||||
@ -1021,8 +1027,11 @@
|
||||
<xs:element name="archiveAboveSize" minOccurs="0" maxOccurs="1" type="xs:long" />
|
||||
<xs:element name="enableArchiveFileCompression" minOccurs="0" maxOccurs="1" type="xs:boolean" />
|
||||
<xs:element name="maxArchiveFiles" minOccurs="0" maxOccurs="1" type="xs:integer" />
|
||||
<xs:element name="forceManaged" minOccurs="0" maxOccurs="1" type="xs:boolean" />
|
||||
<xs:element name="fileNameKind" minOccurs="0" maxOccurs="1" type="NLog.Targets.FilePathKind" />
|
||||
<xs:element name="archiveFileKind" minOccurs="0" maxOccurs="1" type="NLog.Targets.FilePathKind" />
|
||||
<xs:element name="cleanupFileName" minOccurs="0" maxOccurs="1" type="xs:boolean" />
|
||||
<xs:element name="forceManaged" minOccurs="0" maxOccurs="1" type="xs:boolean" />
|
||||
<xs:element name="writeFooterOnArchivingOnly" minOccurs="0" maxOccurs="1" type="xs:boolean" />
|
||||
<xs:element name="fileName" minOccurs="0" maxOccurs="1" type="Layout" />
|
||||
<xs:element name="archiveDateFormat" minOccurs="0" maxOccurs="1" type="xs:string" />
|
||||
<xs:element name="archiveOldFileOnStartup" minOccurs="0" maxOccurs="1" type="xs:boolean" />
|
||||
@ -1032,15 +1041,15 @@
|
||||
<xs:element name="deleteOldFileOnStartup" minOccurs="0" maxOccurs="1" type="xs:boolean" />
|
||||
<xs:element name="replaceFileContentsOnEachWrite" minOccurs="0" maxOccurs="1" type="xs:boolean" />
|
||||
<xs:element name="concurrentWrites" minOccurs="0" maxOccurs="1" type="xs:boolean" />
|
||||
<xs:element name="concurrentWriteAttemptDelay" minOccurs="0" maxOccurs="1" type="xs:integer" />
|
||||
<xs:element name="keepFileOpen" minOccurs="0" maxOccurs="1" type="xs:boolean" />
|
||||
<xs:element name="maxLogFilenames" minOccurs="0" maxOccurs="1" type="xs:integer" />
|
||||
<xs:element name="networkWrites" minOccurs="0" maxOccurs="1" type="xs:boolean" />
|
||||
<xs:element name="openFileCacheSize" minOccurs="0" maxOccurs="1" type="xs:integer" />
|
||||
<xs:element name="openFileCacheTimeout" minOccurs="0" maxOccurs="1" type="xs:integer" />
|
||||
<xs:element name="bufferSize" minOccurs="0" maxOccurs="1" type="xs:integer" />
|
||||
<xs:element name="autoFlush" minOccurs="0" maxOccurs="1" type="xs:boolean" />
|
||||
<xs:element name="concurrentWriteAttemptDelay" minOccurs="0" maxOccurs="1" type="xs:integer" />
|
||||
<xs:element name="concurrentWriteAttempts" minOccurs="0" maxOccurs="1" type="xs:integer" />
|
||||
<xs:element name="keepFileOpen" minOccurs="0" maxOccurs="1" type="xs:boolean" />
|
||||
</xs:choice>
|
||||
<xs:attribute name="name" type="xs:string">
|
||||
<xs:annotation>
|
||||
@ -1102,9 +1111,14 @@
|
||||
<xs:documentation>Maximum number of archive files that should be kept.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="forceManaged" type="xs:boolean">
|
||||
<xs:attribute name="fileNameKind" type="NLog.Targets.FilePathKind">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Gets or set a value indicating whether a managed file stream is forced, instead of used the native implementation.</xs:documentation>
|
||||
<xs:documentation>Is the an absolute or relative path?</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="archiveFileKind" type="NLog.Targets.FilePathKind">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Is the an absolute or relative path?</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="cleanupFileName" type="xs:boolean">
|
||||
@ -1112,6 +1126,16 @@
|
||||
<xs:documentation>Cleanup invalid values in a filename, e.g. slashes in a filename. If set to true, this can impact the performance of massive writes. If set to false, nothing gets written when the filename is wrong.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="forceManaged" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Gets or set a value indicating whether a managed file stream is forced, instead of used the native implementation.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="writeFooterOnArchivingOnly" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Indicates whether the footer should be written only when the file is archived.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="fileName" type="SimpleLayoutAttribute">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Name of the file to write to.</xs:documentation>
|
||||
@ -1157,9 +1181,9 @@
|
||||
<xs:documentation>Indicates whether concurrent writes to the log file by multiple processes on the same host.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="concurrentWriteAttemptDelay" type="xs:integer">
|
||||
<xs:attribute name="keepFileOpen" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Delay in milliseconds to wait before attempting to write to the file again.</xs:documentation>
|
||||
<xs:documentation>Indicates whether to keep log file open instead of opening and closing it on each logging event.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="maxLogFilenames" type="xs:integer">
|
||||
@ -1192,16 +1216,16 @@
|
||||
<xs:documentation>Indicates whether to automatically flush the file buffers after each log message.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="concurrentWriteAttemptDelay" type="xs:integer">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Delay in milliseconds to wait before attempting to write to the file again.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="concurrentWriteAttempts" type="xs:integer">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Number of times the write is appended on the file before NLog discards the log message.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="keepFileOpen" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Indicates whether to keep log file open instead of opening and closing it on each logging event.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
@ -1223,6 +1247,13 @@
|
||||
<xs:enumeration value="Minute" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="NLog.Targets.FilePathKind">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="Unknown" />
|
||||
<xs:enumeration value="Relative" />
|
||||
<xs:enumeration value="Absolute" />
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="NLog.Targets.Win32FileAttributes">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="ReadOnly" />
|
||||
@ -1703,6 +1734,7 @@
|
||||
<xs:element name="name" minOccurs="0" maxOccurs="1" type="xs:string" />
|
||||
<xs:element name="layout" minOccurs="0" maxOccurs="1" type="Layout" />
|
||||
<xs:element name="encoding" minOccurs="0" maxOccurs="1" type="xs:string" />
|
||||
<xs:element name="lineEnding" minOccurs="0" maxOccurs="1" type="LineEndingMode" />
|
||||
<xs:element name="maxMessageSize" minOccurs="0" maxOccurs="1" type="xs:integer" />
|
||||
<xs:element name="newLine" minOccurs="0" maxOccurs="1" type="xs:boolean" />
|
||||
<xs:element name="onConnectionOverflow" minOccurs="0" maxOccurs="1" type="NLog.Targets.NetworkTargetConnectionsOverflowAction" />
|
||||
@ -1728,6 +1760,11 @@
|
||||
<xs:documentation>Encoding to be used.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="lineEnding" type="LineEndingMode">
|
||||
<xs:annotation>
|
||||
<xs:documentation>End of line value if a newline is appended at the end of log message .</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="maxMessageSize" type="xs:integer">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Maximum message size in bytes.</xs:documentation>
|
||||
@ -1783,6 +1820,7 @@
|
||||
<xs:element name="name" minOccurs="0" maxOccurs="1" type="xs:string" />
|
||||
<xs:element name="encoding" minOccurs="0" maxOccurs="1" type="xs:string" />
|
||||
<xs:element name="layout" minOccurs="0" maxOccurs="1" type="Layout" />
|
||||
<xs:element name="lineEnding" minOccurs="0" maxOccurs="1" type="LineEndingMode" />
|
||||
<xs:element name="maxMessageSize" minOccurs="0" maxOccurs="1" type="xs:integer" />
|
||||
<xs:element name="newLine" minOccurs="0" maxOccurs="1" type="xs:boolean" />
|
||||
<xs:element name="onConnectionOverflow" minOccurs="0" maxOccurs="1" type="NLog.Targets.NetworkTargetConnectionsOverflowAction" />
|
||||
@ -1816,6 +1854,11 @@
|
||||
<xs:documentation>Instance of that is used to format log messages.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="lineEnding" type="LineEndingMode">
|
||||
<xs:annotation>
|
||||
<xs:documentation>End of line value if a newline is appended at the end of log message .</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="maxMessageSize" type="xs:integer">
|
||||
<xs:annotation>
|
||||
<xs:documentation>Maximum message size in bytes.</xs:documentation>
|
||||
|
||||
@ -9,13 +9,16 @@ namespace Artemis.Profiles.Layers.Conditions
|
||||
{
|
||||
public bool ConditionsMet(LayerModel layer, IDataModel dataModel)
|
||||
{
|
||||
var conditionsMet = layer.Properties.Conditions.All(cm => cm.ConditionMet(dataModel));
|
||||
layer.EventProperties.Update(layer, conditionsMet);
|
||||
lock (layer.Properties.Conditions)
|
||||
{
|
||||
var conditionsMet = layer.Properties.Conditions.All(cm => cm.ConditionMet(dataModel));
|
||||
layer.EventProperties.Update(layer, conditionsMet);
|
||||
|
||||
if (conditionsMet && layer.EventProperties.MustTrigger)
|
||||
layer.EventProperties.TriggerEvent(layer);
|
||||
if (conditionsMet && layer.EventProperties.CanTrigger)
|
||||
layer.EventProperties.TriggerEvent(layer);
|
||||
|
||||
return conditionsMet && layer.EventProperties.MustDraw;
|
||||
return layer.EventProperties.MustDraw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Models
|
||||
@ -10,10 +12,10 @@ namespace Artemis.Profiles.Layers.Models
|
||||
public TimeSpan TriggerDelay { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool MustTrigger { get; set; }
|
||||
public bool CanTrigger { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public DateTime AnimationStart { get; set; }
|
||||
public DateTime EventTriggerTime { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool MustDraw { get; set; }
|
||||
@ -21,23 +23,70 @@ namespace Artemis.Profiles.Layers.Models
|
||||
/// <summary>
|
||||
/// Resets the event's properties and triggers it
|
||||
/// </summary>
|
||||
public abstract void TriggerEvent(LayerModel layer);
|
||||
public virtual void TriggerEvent(LayerModel layer)
|
||||
{
|
||||
if (!CanTrigger)
|
||||
return;
|
||||
|
||||
if (TriggerDelay > TimeSpan.Zero)
|
||||
{
|
||||
if (EventCanTriggerTime == DateTime.MinValue)
|
||||
EventCanTriggerTime = DateTime.Now;
|
||||
|
||||
if (DateTime.Now - EventCanTriggerTime < TriggerDelay)
|
||||
return;
|
||||
|
||||
EventCanTriggerTime = DateTime.MinValue;
|
||||
}
|
||||
|
||||
CanTrigger = false;
|
||||
MustDraw = true;
|
||||
EventTriggerTime = DateTime.Now;
|
||||
layer.Properties.AnimationProgress = 0.0;
|
||||
}
|
||||
|
||||
public DateTime EventCanTriggerTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the event should stop
|
||||
/// </summary>
|
||||
/// <param name="layer"></param>
|
||||
/// <returns></returns>
|
||||
public abstract bool MustStop(LayerModel layer);
|
||||
public virtual bool MustStop(LayerModel layer)
|
||||
{
|
||||
if (ExpirationType == ExpirationType.Time)
|
||||
{
|
||||
if (EventTriggerTime == DateTime.MinValue)
|
||||
return false;
|
||||
return DateTime.Now - EventTriggerTime > Length;
|
||||
}
|
||||
if (ExpirationType == ExpirationType.Animation)
|
||||
return (layer.LayerAnimation == null) || layer.LayerAnimation.MustExpire(layer);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Called every frame, if parent conditions met.
|
||||
public void Update(LayerModel layerModel, bool conditionsMet)
|
||||
{
|
||||
if (MustStop(layerModel))
|
||||
if (EventCanTriggerTime > DateTime.MinValue && (DateTime.Now - EventCanTriggerTime > TriggerDelay))
|
||||
{
|
||||
CanTrigger = true;
|
||||
TriggerEvent(layerModel);
|
||||
return;
|
||||
}
|
||||
|
||||
if (MustDraw && MustStop(layerModel))
|
||||
MustDraw = false;
|
||||
|
||||
if (!conditionsMet)
|
||||
MustTrigger = true;
|
||||
CanTrigger = true;
|
||||
}
|
||||
|
||||
protected bool DelayExpired()
|
||||
{
|
||||
return EventCanTriggerTime > DateTime.MinValue && DateTime.Now - EventCanTriggerTime >= TriggerDelay;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Artemis.Profiles.Layers.Types.Keyboard;
|
||||
using Artemis.Profiles.Layers.Types.KeyboardGif;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Models
|
||||
@ -8,40 +7,23 @@ namespace Artemis.Profiles.Layers.Models
|
||||
{
|
||||
public override void TriggerEvent(LayerModel layer)
|
||||
{
|
||||
var keyboardProperties = layer.Properties as KeyboardPropertiesModel;
|
||||
if (keyboardProperties == null)
|
||||
throw new ArgumentException("Layer's properties cannot be null " +
|
||||
"and must be of type KeyboardPropertiesModel");
|
||||
if (!MustTrigger)
|
||||
return;
|
||||
if (CanTrigger && DelayExpired())
|
||||
{
|
||||
if (layer.GifImage != null)
|
||||
layer.GifImage.CurrentFrame = 0;
|
||||
}
|
||||
|
||||
MustTrigger = false;
|
||||
MustDraw = true;
|
||||
keyboardProperties.AnimationProgress = 0.0;
|
||||
if (layer.GifImage != null)
|
||||
layer.GifImage.CurrentFrame = 0;
|
||||
base.TriggerEvent(layer);
|
||||
}
|
||||
|
||||
public override bool MustStop(LayerModel layer)
|
||||
{
|
||||
var keyboardProperties = layer.Properties as KeyboardPropertiesModel;
|
||||
if (keyboardProperties == null)
|
||||
throw new ArgumentException("Layer's properties cannot be null " +
|
||||
"and must be of type KeyboardPropertiesModel");
|
||||
if (ExpirationType != ExpirationType.Animation)
|
||||
return base.MustStop(layer);
|
||||
|
||||
switch (ExpirationType)
|
||||
{
|
||||
case ExpirationType.Time:
|
||||
if (AnimationStart == DateTime.MinValue)
|
||||
return false;
|
||||
return DateTime.Now - Length > AnimationStart;
|
||||
case ExpirationType.Animation:
|
||||
if (layer.LayerType is KeyboardGifType)
|
||||
return layer.GifImage?.CurrentFrame >= layer.GifImage?.FrameCount - 1;
|
||||
return layer.LayerAnimation == null || layer.LayerAnimation.MustExpire(layer);
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
if (layer.LayerType is KeyboardGifType)
|
||||
return layer.GifImage?.CurrentFrame >= layer.GifImage?.FrameCount - 1;
|
||||
return (layer.LayerAnimation == null) || layer.LayerAnimation.MustExpire(layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -242,5 +242,13 @@ namespace Artemis.Profiles.Layers.Models
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void SetupCondition()
|
||||
{
|
||||
if (IsEvent && !(LayerCondition is EventCondition))
|
||||
LayerCondition = new EventCondition();
|
||||
else if (!IsEvent && !(LayerCondition is DataModelCondition))
|
||||
LayerCondition = new DataModelCondition();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,10 @@
|
||||
<UserControl x:Class="Artemis.Profiles.Layers.Types.Generic.GenericPropertiesView"
|
||||
<UserControl
|
||||
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: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"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="600" d:DesignWidth="500">
|
||||
<Grid>
|
||||
@ -23,54 +24,46 @@
|
||||
</Grid.RowDefinitions>
|
||||
<!-- Animation -->
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Margin="10" FontSize="13.333" Text="Animation:"
|
||||
VerticalAlignment="Center"
|
||||
Height="18" />
|
||||
VerticalAlignment="Center"
|
||||
Height="18" />
|
||||
<ComboBox Grid.Row="0" Grid.Column="1" Margin="10,10,10,0" x:Name="LayerAnimations" VerticalAlignment="Top"
|
||||
Height="22">
|
||||
Height="22">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Path=Name, Mode=OneWay}" />
|
||||
<TextBlock Text="{Binding 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" />
|
||||
VerticalAlignment="Center" Height="18" />
|
||||
<Slider x:Name="RotationSpeed" 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" />
|
||||
TickPlacement="None" TickFrequency="0.05"
|
||||
Value="{Binding LayerModel.Properties.AnimationSpeed, Mode=TwoWay}" Minimum="0.05" Maximum="3"
|
||||
SmallChange="0" IsSnapToTickEnabled="True" Margin="10,12,10,2" Height="24" />
|
||||
|
||||
<!-- Colors -->
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal" x:Name="ShowBrush">
|
||||
<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}"
|
||||
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
|
||||
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" Height="24" Width="134" />
|
||||
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
|
||||
<ncore:ColorBox Brush="{Binding Brush, Mode=TwoWay}" Height="24" Width="134"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Dynamic -->
|
||||
<Label Grid.Row="3" Grid.Column="0" FontSize="20" HorizontalAlignment="Left"
|
||||
Content="Dynamic" Width="97" VerticalAlignment="Bottom" />
|
||||
Content="Dynamic" Width="97" VerticalAlignment="Bottom" />
|
||||
|
||||
<!-- Dynamic property views -->
|
||||
<ContentControl Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" x:Name="OpacityProperties" />
|
||||
|
||||
<!-- Note -->
|
||||
<TextBlock Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" Margin="10,2,10,10" FontSize="13.333"
|
||||
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
|
||||
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>
|
||||
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
|
||||
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>
|
||||
</UserControl>
|
||||
@ -1,13 +1,16 @@
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Profiles.Layers.Abstract;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
using Caliburn.Micro;
|
||||
using ColorBox;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.Generic
|
||||
{
|
||||
public class GenericPropertiesViewModel : LayerPropertiesViewModel
|
||||
{
|
||||
private IEnumerable<BrushTypes> _availableBrushTypes;
|
||||
private ILayerAnimation _selectedLayerAnimation;
|
||||
|
||||
public GenericPropertiesViewModel(LayerEditorViewModel editorVm) : base(editorVm)
|
||||
|
||||
@ -60,7 +60,7 @@
|
||||
VerticalAlignment="Top" Height="18" Width="130" />
|
||||
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
|
||||
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}" Height="24" Width="134"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
@ -52,5 +52,5 @@ using System.Windows;
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
[assembly: AssemblyVersion("1.3.3.0")]
|
||||
[assembly: AssemblyFileVersion("1.3.3.0")]
|
||||
[assembly: AssemblyVersion("1.4.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.4.0.0")]
|
||||
Binary file not shown.
@ -27,6 +27,10 @@ namespace Artemis.Settings
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
||||
public string LastKeyboard { get; set; }
|
||||
|
||||
[DefaultValue("Qwerty")]
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
||||
public string Layout { get; set; }
|
||||
|
||||
[DefaultValue(true)]
|
||||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
|
||||
public bool EnablePointersUpdate { get; set; }
|
||||
|
||||
@ -7,6 +7,7 @@ namespace Artemis.Settings
|
||||
public class OffsetSettings : IArtemisSettings
|
||||
{
|
||||
public GamePointersCollection RocketLeague { get; set; }
|
||||
public GamePointersCollection WorldOfWarcraft { get; set; }
|
||||
|
||||
public void Save()
|
||||
{
|
||||
|
||||
@ -207,7 +207,7 @@
|
||||
<!-- Available brush types -->
|
||||
<ListBox x:Name="listAvailableBrushType" HorizontalContentAlignment="Center"
|
||||
SelectedItem="{Binding BrushType, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
||||
ItemsSource="{Binding AvailableBrushTypes, RelativeSource={RelativeSource TemplatedParent}}">
|
||||
ItemsSource="{Binding AvailableBrushTypes, RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Center">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<UniformGrid Rows="1" Columns="4" />
|
||||
@ -219,7 +219,7 @@
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBoxItem">
|
||||
<Border x:Name="Border" Background="Transparent"
|
||||
Padding="0,3">
|
||||
Padding="0,3" Margin="3,0">
|
||||
<Path x:Name="Icon" Height="12" Width="20"
|
||||
Stretch="Fill" Fill="#FF403C3C"
|
||||
StrokeThickness="1"
|
||||
@ -627,14 +627,123 @@
|
||||
</DockPanel.Style>
|
||||
|
||||
<UniformGrid Rows="5" DockPanel.Dock="Left" Margin="0,0,5,0">
|
||||
<TextBlock Text="Presets" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Direction" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Start Point" VerticalAlignment="Center" />
|
||||
<TextBlock Text="End Point" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Mapping Mode" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Spread Method" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Opacity" VerticalAlignment="Center" />
|
||||
</UniformGrid>
|
||||
|
||||
<UniformGrid Rows="5" DockPanel.Dock="Right">
|
||||
<!-- Presets -->
|
||||
<UniformGrid Rows="1">
|
||||
<Button ToolTip="Rainbow"
|
||||
Command="{x:Static nc:ColorBox.SelectPreset}"
|
||||
CommandParameter="{x:Static nc:ColorBox.RainbowPreset}"
|
||||
VerticalAlignment="Top" Width="25"
|
||||
Background="{x:Static nc:ColorBox.RainbowPreset}" />
|
||||
<Button ToolTip="Police"
|
||||
Command="{x:Static nc:ColorBox.SelectPreset}"
|
||||
CommandParameter="{x:Static nc:ColorBox.PolicePreset}"
|
||||
VerticalAlignment="Top" Width="25"
|
||||
Background="{x:Static nc:ColorBox.PolicePreset}" />
|
||||
<Button ToolTip="Artemis"
|
||||
Command="{x:Static nc:ColorBox.SelectPreset}"
|
||||
CommandParameter="{x:Static nc:ColorBox.ArtemisPreset}"
|
||||
VerticalAlignment="Top" Width="25"
|
||||
Background="{x:Static nc:ColorBox.ArtemisPreset}" />
|
||||
<Button ToolTip="Hello Kitty"
|
||||
Command="{x:Static nc:ColorBox.SelectPreset}"
|
||||
CommandParameter="{x:Static nc:ColorBox.HelloKittyPreset}"
|
||||
VerticalAlignment="Top" Width="25"
|
||||
Background="{x:Static nc:ColorBox.HelloKittyPreset}" />
|
||||
<Button ToolTip="Green to red"
|
||||
Command="{x:Static nc:ColorBox.SelectPreset}"
|
||||
CommandParameter="{x:Static nc:ColorBox.GreenToRedPreset}"
|
||||
VerticalAlignment="Top" Width="25"
|
||||
Background="{x:Static nc:ColorBox.GreenToRedPreset}" />
|
||||
</UniformGrid>
|
||||
|
||||
<!-- Directions -->
|
||||
<UniformGrid Rows="1">
|
||||
<Button ToolTip="Horizontal"
|
||||
Command="{x:Static nc:ColorBox.DirectionHorizontal}"
|
||||
VerticalAlignment="Top" Width="32">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="4" Height="14">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush
|
||||
Visual="{StaticResource appbar_minus}"
|
||||
Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
<Rectangle.RenderTransform>
|
||||
<RotateTransform CenterX="2" CenterY="7"
|
||||
Angle="-90" />
|
||||
</Rectangle.RenderTransform>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
|
||||
<Button ToolTip="Vertical"
|
||||
Command="{x:Static nc:ColorBox.DirectionVertical}"
|
||||
VerticalAlignment="Top" Width="32">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="4" Height="14">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush
|
||||
Visual="{StaticResource appbar_minus}"
|
||||
Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
|
||||
<Button ToolTip="Top left to bottom right"
|
||||
Command="{x:Static nc:ColorBox.DirectionTopLeftBottomRight}"
|
||||
VerticalAlignment="Top" Width="32">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="4" Height="14">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush
|
||||
Visual="{StaticResource appbar_minus}"
|
||||
Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
<Rectangle.RenderTransform>
|
||||
<RotateTransform CenterX="2" CenterY="7"
|
||||
Angle="-45" />
|
||||
</Rectangle.RenderTransform>
|
||||
</Rectangle>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
|
||||
<Button ToolTip="Top right to bottom left"
|
||||
Command="{x:Static nc:ColorBox.DirectionTopRightBottomLeft}"
|
||||
VerticalAlignment="Top" Width="32">
|
||||
<Button.Content>
|
||||
<Rectangle
|
||||
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}"
|
||||
Width="4" Height="14">
|
||||
<Rectangle.OpacityMask>
|
||||
<VisualBrush
|
||||
Visual="{StaticResource appbar_minus}"
|
||||
Stretch="Fill" />
|
||||
</Rectangle.OpacityMask>
|
||||
<Rectangle.RenderTransform>
|
||||
<RotateTransform CenterX="2" CenterY="7"
|
||||
Angle="45" />
|
||||
</Rectangle.RenderTransform>
|
||||
</Rectangle>
|
||||
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</UniformGrid>
|
||||
|
||||
<UniformGrid Rows="1">
|
||||
<nc:DoubleUpDown
|
||||
Value="{Binding StartX, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
@ -649,14 +758,6 @@
|
||||
Value="{Binding EndY, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</UniformGrid>
|
||||
|
||||
<ComboBox Margin="2"
|
||||
ItemsSource="{Binding MappingModeTypes, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
SelectedItem="{Binding MappingMode, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
|
||||
<ComboBox Margin="2"
|
||||
ItemsSource="{Binding SpreadMethodTypes, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
SelectedItem="{Binding SpreadMethod, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
|
||||
<Slider Style="{StaticResource OpacitySliderStyle}" />
|
||||
</UniformGrid>
|
||||
</DockPanel>
|
||||
@ -676,17 +777,15 @@
|
||||
</Style>
|
||||
</DockPanel.Style>
|
||||
|
||||
<UniformGrid Rows="7" DockPanel.Dock="Left" Margin="0,0,5,0">
|
||||
<UniformGrid Rows="5" DockPanel.Dock="Left" Margin="0,0,5,0">
|
||||
<TextBlock Text="Gradient Origin" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Center" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Radius X" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Radius Y" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Mapping Mode" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Spread Method" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Opacity" VerticalAlignment="Center" />
|
||||
</UniformGrid>
|
||||
|
||||
<UniformGrid Rows="7" DockPanel.Dock="Right">
|
||||
<UniformGrid Rows="5" DockPanel.Dock="Right">
|
||||
<UniformGrid Rows="1">
|
||||
<nc:DoubleUpDown
|
||||
Value="{Binding GradientOriginX, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
@ -707,14 +806,6 @@
|
||||
<nc:DoubleUpDown
|
||||
Value="{Binding RadiusY, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
|
||||
<ComboBox Margin="2"
|
||||
ItemsSource="{Binding MappingModeTypes, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
SelectedItem="{Binding MappingMode, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
|
||||
<ComboBox Margin="2"
|
||||
ItemsSource="{Binding SpreadMethodTypes, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
SelectedItem="{Binding SpreadMethod, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
|
||||
<Slider Style="{StaticResource OpacitySliderStyle}" />
|
||||
</UniformGrid>
|
||||
</DockPanel>
|
||||
|
||||
@ -27,9 +27,10 @@ namespace Artemis.Utilities
|
||||
debuggerTarget.Layout = @"${logger:shortName=True} - ${uppercase:${level}}: ${message}";
|
||||
fileTarget.FileName = "${specialfolder:folder=MyDocuments}/Artemis/logs/${shortdate}.txt";
|
||||
fileTarget.Layout = "${longdate}|${level:uppercase=true}|${logger}|${message} ${exception:format=tostring}";
|
||||
fileTarget.ArchiveEvery = FileArchivePeriod.Day;
|
||||
fileTarget.EnableFileDelete = true;
|
||||
fileTarget.MaxArchiveFiles = 7;
|
||||
|
||||
fileTarget.ArchiveEvery = FileArchivePeriod.Minute;
|
||||
|
||||
// Step 4. Define rules
|
||||
var rule1 = new LoggingRule("*", logLevel, debuggerTarget);
|
||||
config.LoggingRules.Add(rule1);
|
||||
|
||||
@ -147,6 +147,8 @@ namespace Artemis.Utilities
|
||||
// Assign each pointer to the settings file
|
||||
if (pointers.FirstOrDefault(p => p.Game == "RocketLeague") != null)
|
||||
offsetSettings.RocketLeague = pointers.FirstOrDefault(p => p.Game == "RocketLeague");
|
||||
if (pointers.FirstOrDefault(p => p.Game == "WorldOfWarcraft") != null)
|
||||
offsetSettings.WorldOfWarcraft = pointers.FirstOrDefault(p => p.Game == "WorldOfWarcraft");
|
||||
|
||||
offsetSettings.Save();
|
||||
}
|
||||
|
||||
@ -86,6 +86,12 @@ namespace Artemis.ViewModels.Flyouts
|
||||
"Corsair Dark"
|
||||
};
|
||||
|
||||
public BindableCollection<string> Layouts => new BindableCollection<string>
|
||||
{
|
||||
"Qwerty",
|
||||
"Azerty"
|
||||
};
|
||||
|
||||
public string VersionText => "Artemis " + Assembly.GetExecutingAssembly().GetName().Version;
|
||||
|
||||
public BindableCollection<string> LogLevels { get; set; }
|
||||
@ -101,6 +107,17 @@ namespace Artemis.ViewModels.Flyouts
|
||||
}
|
||||
}
|
||||
|
||||
public string SelectedLayout
|
||||
{
|
||||
get { return GeneralSettings.Layout; }
|
||||
set
|
||||
{
|
||||
if (value == GeneralSettings.Layout) return;
|
||||
GeneralSettings.Layout = value;
|
||||
NotifyOfPropertyChange(() => SelectedLayout);
|
||||
}
|
||||
}
|
||||
|
||||
public string SelectedLogLevel
|
||||
{
|
||||
get { return GeneralSettings.LogLevel; }
|
||||
|
||||
@ -5,6 +5,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using Artemis.Models.Interfaces;
|
||||
using Artemis.Profiles.Layers.Abstract;
|
||||
using Artemis.Profiles.Layers.Conditions;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Profiles.Layers.Types.Keyboard;
|
||||
@ -175,7 +176,9 @@ namespace Artemis.ViewModels.Profiles
|
||||
// TODO: EventPropVM must have layer too
|
||||
if (EventPropertiesViewModel != null)
|
||||
Layer.EventProperties = EventPropertiesViewModel.GetAppliedProperties();
|
||||
|
||||
|
||||
Layer.SetupCondition();
|
||||
|
||||
// Don't bother checking for a GIF path unless the type is GIF
|
||||
if (!(Layer.LayerType is KeyboardGifType))
|
||||
return;
|
||||
@ -215,6 +218,11 @@ namespace Artemis.ViewModels.Profiles
|
||||
// that would upset the child layers' relations (sounds like Dr. Phil amirite?)
|
||||
var currentObj = Clone(Layer);
|
||||
currentObj.Children.Clear();
|
||||
|
||||
// Apply the IsEvent boolean
|
||||
currentObj.SetupCondition();
|
||||
ProposedLayer.SetupCondition();
|
||||
|
||||
var current = JsonConvert.SerializeObject(currentObj, Formatting.Indented);
|
||||
var proposed = JsonConvert.SerializeObject(ProposedLayer, Formatting.Indented);
|
||||
|
||||
|
||||
@ -546,8 +546,13 @@ namespace Artemis.ViewModels.Profiles
|
||||
return;
|
||||
|
||||
var newProfile = GeneralHelpers.Clone(SelectedProfile);
|
||||
newProfile.Name =
|
||||
await DialogService.ShowInputDialog("Duplicate profile", "Please enter a unique profile name");
|
||||
newProfile.Name = await DialogService
|
||||
.ShowInputDialog("Duplicate profile", "Please enter a unique profile name");
|
||||
|
||||
// Null when the user cancelled
|
||||
if (string.IsNullOrEmpty(newProfile.Name))
|
||||
return;
|
||||
|
||||
// Verify the name
|
||||
while (ProfileProvider.GetAll().Contains(newProfile))
|
||||
{
|
||||
@ -555,7 +560,7 @@ namespace Artemis.ViewModels.Profiles
|
||||
await DialogService.ShowInputDialog("Name already in use", "Please enter a unique profile name");
|
||||
|
||||
// Null when the user cancelled
|
||||
if (string.IsNullOrEmpty(SelectedProfile.Name))
|
||||
if (string.IsNullOrEmpty(newProfile.Name))
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
xmlns:cal="http://www.caliburnproject.org"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="600" d:DesignWidth="300"
|
||||
Width="300">
|
||||
Width="270">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
@ -31,23 +31,27 @@
|
||||
<!-- Master switch -->
|
||||
<Label Grid.Row="0" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
|
||||
Content="Enable Artemis:" />
|
||||
<controls:ToggleSwitch Grid.Row="0" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Right" Width="125"
|
||||
IsChecked="{Binding Path=Enabled, Mode=TwoWay}" />
|
||||
<controls:ToggleSwitchButton Grid.Row="0" Grid.Column="1" Margin="5,5,10,5" VerticalAlignment="Center"
|
||||
IsChecked="{Binding Path=Enabled, Mode=TwoWay}"
|
||||
Style="{StaticResource MahApps.Metro.Styles.ToggleSwitchButton.Win10}"
|
||||
HorizontalAlignment="Right" />
|
||||
|
||||
<!-- Startup with Windows -->
|
||||
<Label Grid.Row="1" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
|
||||
Content="Startup with Windows:" />
|
||||
<controls:ToggleSwitch Grid.Row="1" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No"
|
||||
IsChecked="{Binding Path=GeneralSettings.Autorun, Mode=TwoWay}"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Right" Width="125" />
|
||||
Content="Auto startup:" />
|
||||
<controls:ToggleSwitchButton Grid.Row="1" Grid.Column="1" Margin="5,5,10,5" VerticalAlignment="Center"
|
||||
IsChecked="{Binding Path=GeneralSettings.Autorun, Mode=TwoWay}"
|
||||
Style="{StaticResource MahApps.Metro.Styles.ToggleSwitchButton.Win10}"
|
||||
HorizontalAlignment="Right" />
|
||||
|
||||
|
||||
<!-- Show on startup -->
|
||||
<Label Grid.Row="2" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
|
||||
Content="Show on startup:" />
|
||||
<controls:ToggleSwitch Grid.Row="2" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No"
|
||||
IsChecked="{Binding Path=GeneralSettings.ShowOnStartup, Mode=TwoWay}"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Right" Width="125" />
|
||||
<controls:ToggleSwitchButton Grid.Row="2" Grid.Column="1" Margin="5,5,10,5" VerticalAlignment="Center"
|
||||
IsChecked="{Binding Path=GeneralSettings.ShowOnStartup, Mode=TwoWay}"
|
||||
Style="{StaticResource MahApps.Metro.Styles.ToggleSwitchButton.Win10}"
|
||||
HorizontalAlignment="Right" />
|
||||
|
||||
<!-- Theme selection -->
|
||||
<Label Grid.Row="3" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
|
||||
@ -63,26 +67,28 @@
|
||||
HorizontalAlignment="Right"
|
||||
Width="140" />
|
||||
|
||||
<!-- Gamestate port -->
|
||||
<!-- Layout selection -->
|
||||
<Label Grid.Row="5" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
|
||||
Content="Gamestate server port:" />
|
||||
<controls:NumericUpDown Grid.Row="5" Grid.Column="1" Margin="10" VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right" Width="120"
|
||||
Content="Layout:" />
|
||||
<ComboBox Grid.Row="5" Grid.Column="1" x:Name="Layouts" Margin="10" VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"
|
||||
Width="140" />
|
||||
|
||||
<!-- Gamestate port -->
|
||||
<Label Grid.Row="6" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
|
||||
Content="Gamestate port:" />
|
||||
<controls:NumericUpDown Grid.Row="6" Grid.Column="1" Margin="10" VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right" Width="140"
|
||||
Value="{Binding Path=GeneralSettings.GamestatePort, Mode=TwoWay}" />
|
||||
|
||||
<!-- Updates check -->
|
||||
<Label Grid.Row="6" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
|
||||
Content="Auto-update:" />
|
||||
<controls:ToggleSwitch Grid.Row="6" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Right" Width="125"
|
||||
IsChecked="{Binding Path=GeneralSettings.AutoUpdate, Mode=TwoWay}" />
|
||||
|
||||
<!-- Update pointers -->
|
||||
<Label Grid.Row="7" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
|
||||
Content="Download pointers:" />
|
||||
<controls:ToggleSwitch Grid.Row="7" Grid.Column="1" Margin="5" OnLabel="Yes" OffLabel="No"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Right" Width="125"
|
||||
IsChecked="{Binding Path=GeneralSettings.EnablePointersUpdate, Mode=TwoWay}" />
|
||||
Content="Auto-update:" />
|
||||
<controls:ToggleSwitchButton Grid.Row="7" Grid.Column="1" Margin="5,5,10,5" VerticalAlignment="Center"
|
||||
IsChecked="{Binding Path=GeneralSettings.AutoUpdate, Mode=TwoWay}"
|
||||
Style="{StaticResource MahApps.Metro.Styles.ToggleSwitchButton.Win10}"
|
||||
HorizontalAlignment="Right" />
|
||||
|
||||
|
||||
<!-- Logging -->
|
||||
<Label Grid.Row="8" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
|
||||
@ -91,15 +97,15 @@
|
||||
HorizontalAlignment="Right"
|
||||
Width="140" />
|
||||
<Button Grid.Row="9" Grid.Column="1" Margin="10" x:Name="ShowDebug" Content="Show debugger"
|
||||
VerticalAlignment="Center"
|
||||
VerticalAlignment="Center" Width="90" HorizontalAlignment="Right"
|
||||
Style="{DynamicResource SquareButtonStyle}" />
|
||||
|
||||
<!-- Buttons -->
|
||||
<Button Grid.Row="10" Grid.Column="0" Margin="10" x:Name="ResetSettings" Content="Reset settings"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Left" Width="120"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Left" Width="90"
|
||||
Style="{DynamicResource SquareButtonStyle}" />
|
||||
<Button Grid.Row="10" Grid.Column="1" Margin="10" x:Name="SaveSettings" Content="Save changes"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Right" Width="120"
|
||||
<Button Grid.Row="10" Grid.Column="1" Margin="11" x:Name="SaveSettings" Content="Save changes"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Right" Width="90"
|
||||
Style="{DynamicResource SquareButtonStyle}" />
|
||||
|
||||
<!-- Version -->
|
||||
|
||||
@ -17,7 +17,31 @@
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup>
|
||||
<GeometryDrawing Brush="{DynamicResource IdealForegroundColorBrush}"
|
||||
Geometry="M1518 3378 c-48 -63 -61 -101 -66 -184 -4 -70 -1 -91 27 -170 l31 -89 -27 -20 c-32 -24 -849 -601 -981 -693 l-93 -64 -87 40 c-48 22 -91 37 -95 32 -5 -4 9 -41 29 -83 l37 -75 -28 -24 c-23 -20 -29 -35 -33 -81 l-4 -56 -82 -19 c-109 -25 -109 -41 4 -91 l85 -38 7 -64 c15 -137 90 -1279 85 -1293 -3 -7 -35 -24 -70 -35 -159 -53 -257 -168 -257 -302 0 -35 2 -38 47 -53 54 -18 185 -21 232 -5 29 10 31 14 31 58 0 26 6 56 14 66 13 18 15 18 46 -8 44 -37 78 -35 119 7 l34 35 -17 41 c-9 23 -12 39 -6 35 6 -4 43 -1 83 6 39 6 219 14 398 18 l327 6 113 57 c158 78 256 166 317 282 24 46 27 62 27 152 0 98 -1 103 -41 184 l-42 83 44 69 c24 37 51 68 59 68 9 0 44 -14 78 -32 l62 -31 -93 -44 c-58 -26 -92 -48 -90 -55 9 -27 353 -68 570 -68 108 0 108 0 108 24 0 34 -105 171 -220 286 -122 122 -238 216 -250 204 -6 -6 -1 -42 16 -98 14 -49 23 -91 19 -94 -3 -3 -36 9 -73 27 l-69 33 24 71 c13 39 23 76 23 82 0 6 28 17 63 24 279 58 399 300 314 632 -32 121 -49 155 -134 255 -37 45 -106 126 -152 180 -73 87 -241 326 -241 343 0 3 15 13 32 21 21 10 35 25 40 45 15 60 -16 103 -81 108 -43 3 -39 22 14 74 l45 43 -25 50 c-35 69 -77 114 -130 139 -63 30 -88 27 -117 -11z m215 -835 c188 -279 250 -417 250 -548 0 -133 -74 -214 -243 -265 l-55 -16 -37 -138 c-21 -76 -39 -140 -40 -141 -6 -5 -814 377 -823 390 -6 7 -19 46 -29 86 -10 41 -25 81 -33 91 -8 9 -57 35 -109 59 -52 23 -93 46 -92 51 2 4 233 169 513 366 l510 358 26 -46 c15 -25 88 -136 162 -247z m-1108 -898 c61 21 88 26 107 19 14 -5 204 -92 421 -194 l395 -185 -27 -35 c-15 -19 -53 -72 -84 -117 l-57 -81 30 -90 c39 -117 40 -179 2 -253 -45 -90 -147 -145 -347 -189 -71 -15 -435 -59 -600 -73 l-29 -2 -37 540 c-20 297 -40 581 -43 632 l-7 92 98 -46 97 -46 81 28z" />
|
||||
Geometry="M1518 3378 c-48 -63 -61 -101 -66 -184 -4 -70 -1 -91 27
|
||||
-170 l31 -89 -27 -20 c-32 -24 -849 -601 -981 -693 l-93 -64 -87 40
|
||||
c-48 22 -91 37 -95 32 -5 -4 9 -41 29 -83 l37 -75 -28 -24 c-23 -20
|
||||
-29 -35 -33 -81 l-4 -56 -82 -19 c-109 -25 -109 -41 4 -91 l85 -38 7
|
||||
-64 c15 -137 90 -1279 85 -1293 -3 -7 -35 -24 -70 -35 -159 -53 -257
|
||||
-168 -257 -302 0 -35 2 -38 47 -53 54 -18 185 -21 232 -5 29 10 31
|
||||
14 31 58 0 26 6 56 14 66 13 18 15 18 46 -8 44 -37 78 -35 119 7 l34
|
||||
35 -17 41 c-9 23 -12 39 -6 35 6 -4 43 -1 83 6 39 6 219 14 398 18
|
||||
l327 6 113 57 c158 78 256 166 317 282 24 46 27 62 27 152 0 98 -1
|
||||
103 -41 184 l-42 83 44 69 c24 37 51 68 59 68 9 0 44 -14 78 -32 l62
|
||||
-31 -93 -44 c-58 -26 -92 -48 -90 -55 9 -27 353 -68 570 -68 108 0
|
||||
108 0 108 24 0 34 -105 171 -220 286 -122 122 -238 216 -250 204 -6
|
||||
-6 -1 -42 16 -98 14 -49 23 -91 19 -94 -3 -3 -36 9 -73 27 l-69 33 24
|
||||
71 c13 39 23 76 23 82 0 6 28 17 63 24 279 58 399 300 314 632 -32
|
||||
121 -49 155 -134 255 -37 45 -106 126 -152 180 -73 87 -241 326 -241
|
||||
343 0 3 15 13 32 21 21 10 35 25 40 45 15 60 -16 103 -81 108 -43 3
|
||||
-39 22 14 74 l45 43 -25 50 c-35 69 -77 114 -130 139 -63 30 -88 27
|
||||
-117 -11z m215 -835 c188 -279 250 -417 250 -548 0 -133 -74 -214 -243
|
||||
-265 l-55 -16 -37 -138 c-21 -76 -39 -140 -40 -141 -6 -5 -814 377 -823
|
||||
390 -6 7 -19 46 -29 86 -10 41 -25 81 -33 91 -8 9 -57 35 -109 59 -52
|
||||
23 -93 46 -92 51 2 4 233 169 513 366 l510 358 26 -46 c15 -25 88 -136
|
||||
162 -247z m-1108 -898 c61 21 88 26 107 19 14 -5 204 -92 421 -194 l395
|
||||
-185 -27 -35 c-15 -19 -53 -72 -84 -117 l-57 -81 30 -90 c39 -117 40
|
||||
-179 2 -253 -45 -90 -147 -145 -347 -189 -71 -15 -435 -59 -600 -73 l
|
||||
-29 -2 -37 540 c-20 297 -40 581 -43 632 l-7 92 98 -46 97 -46 81 28z" />
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
@ -32,6 +56,9 @@
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</Controls:MetroWindow.IconTemplate>
|
||||
<Controls:MetroWindow.WindowButtonCommands>
|
||||
<Controls:WindowButtonCommands Style="{DynamicResource MahApps.Metro.Styles.WindowButtonCommands.Win10}" />
|
||||
</Controls:MetroWindow.WindowButtonCommands>
|
||||
<Controls:MetroWindow.RightWindowCommands>
|
||||
<Controls:WindowCommands>
|
||||
<Button cal:Message.Attach="Settings">
|
||||
@ -42,9 +69,7 @@
|
||||
<VisualBrush Stretch="Fill" Visual="{StaticResource appbar_settings}" />
|
||||
</Rectangle.OpacityMask>
|
||||
</Rectangle>
|
||||
<TextBlock Margin="4 -3 0 0"
|
||||
VerticalAlignment="Center"
|
||||
Text="settings" />
|
||||
<TextBlock Margin="4 -3 0 0" VerticalAlignment="Center" Text="settings" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</Controls:WindowCommands>
|
||||
|
||||
Binary file not shown.
@ -4,16 +4,15 @@
|
||||
<package id="Caliburn.Micro.Core" version="3.0.1" targetFramework="net452" />
|
||||
<package id="Castle.Core" version="3.3.3" targetFramework="net452" />
|
||||
<package id="Colore" version="5.0.0" targetFramework="net461" />
|
||||
<package id="CUE.NET" version="1.1.0" targetFramework="net461" />
|
||||
<package id="DeltaCompressionDotNet" version="1.0.0" targetFramework="net461" />
|
||||
<package id="DynamicExpresso.Core" version="1.3.1.0" targetFramework="net452" />
|
||||
<package id="Extended.Wpf.Toolkit" version="2.9" targetFramework="net461" />
|
||||
<package id="gong-wpf-dragdrop" version="0.1.4.3" targetFramework="net452" />
|
||||
<package id="CUE.NET" version="1.1.0.2" targetFramework="net461" />
|
||||
<package id="DeltaCompressionDotNet" version="1.1.0" targetFramework="net461" />
|
||||
<package id="DynamicExpresso.Core" version="1.3.3.4" targetFramework="net461" />
|
||||
<package id="gong-wpf-dragdrop" version="1.0.0" targetFramework="net461" />
|
||||
<package id="Hardcodet.NotifyIcon.Wpf" version="1.0.8" targetFramework="net452" />
|
||||
<package id="log4net" version="2.0.5" targetFramework="net452" />
|
||||
<package id="MahApps.Metro" version="1.2.4.0" targetFramework="net452" />
|
||||
<package id="MahApps.Metro" version="1.3.0" targetFramework="net461" />
|
||||
<package id="MahApps.Metro.Resources" version="0.6.1.0" targetFramework="net452" />
|
||||
<package id="Mono.Cecil" version="0.9.6.1" targetFramework="net461" />
|
||||
<package id="Mono.Cecil" version="0.9.6.4" targetFramework="net461" />
|
||||
<package id="NAudio" version="1.7.3" targetFramework="net452" />
|
||||
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net461" />
|
||||
<package id="Ninject" version="3.2.2.0" targetFramework="net452" />
|
||||
@ -21,11 +20,11 @@
|
||||
<package id="Ninject.Extensions.Factory" version="3.2.1.0" targetFramework="net452" />
|
||||
<package id="Ninject.Extensions.Logging" version="3.2.3.0" targetFramework="net452" />
|
||||
<package id="Ninject.Extensions.Logging.nlog4" version="3.2.3.0" targetFramework="net452" />
|
||||
<package id="NLog" version="4.3.7" targetFramework="net461" />
|
||||
<package id="NLog.Schema" version="4.3.7" targetFramework="net461" />
|
||||
<package id="Process.NET" version="1.0.1" targetFramework="net461" />
|
||||
<package id="NLog" version="4.3.9" targetFramework="net461" />
|
||||
<package id="NLog.Schema" version="4.3.9" targetFramework="net461" />
|
||||
<package id="Process.NET" version="1.0.5" targetFramework="net461" />
|
||||
<package id="Splat" version="1.6.2" targetFramework="net461" />
|
||||
<package id="SpotifyAPI-NET" version="2.11.0" targetFramework="net461" />
|
||||
<package id="SpotifyAPI-NET" version="2.12.0" targetFramework="net461" />
|
||||
<package id="squirrel.windows" version="1.4.4" targetFramework="net461" />
|
||||
<package id="VirtualInput" version="1.0.1" targetFramework="net452" />
|
||||
<package id="WpfExceptionViewer" version="1.0.0.0" targetFramework="net452" />
|
||||
|
||||
134
Artemis/ColorBox/AlphaSelector.cs
Normal file
134
Artemis/ColorBox/AlphaSelector.cs
Normal file
@ -0,0 +1,134 @@
|
||||
/***************** NCore Softwares Pvt. Ltd., India **************************
|
||||
|
||||
ColorBox
|
||||
|
||||
Copyright (C) 2013 NCore Softwares Pvt. Ltd.
|
||||
|
||||
This program is provided to you under the terms of the Microsoft Public
|
||||
License (Ms-PL) as published at http://colorbox.codeplex.com/license
|
||||
|
||||
***********************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace ColorBox
|
||||
{
|
||||
public class AlphaSelector : BaseSelector
|
||||
{
|
||||
public static readonly DependencyProperty AlphaProperty =
|
||||
DependencyProperty.Register("Alpha", typeof(double), typeof(AlphaSelector),
|
||||
new FrameworkPropertyMetadata(1.0, AlphaChanged, AlphaCoerce));
|
||||
|
||||
public static readonly DependencyProperty AlphaOffsetProperty =
|
||||
DependencyProperty.Register("AlphaOffset", typeof(double), typeof(AlphaSelector),
|
||||
new UIPropertyMetadata(0.0));
|
||||
|
||||
public double Alpha
|
||||
{
|
||||
get { return (double) GetValue(AlphaProperty); }
|
||||
set { SetValue(AlphaProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
public double AlphaOffset
|
||||
{
|
||||
get { return (double) GetValue(AlphaOffsetProperty); }
|
||||
private set { SetValue(AlphaOffsetProperty, value); }
|
||||
}
|
||||
|
||||
public static void AlphaChanged(object o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var h = (AlphaSelector) o;
|
||||
h.SetAlphaOffset();
|
||||
h.SetColor();
|
||||
}
|
||||
|
||||
public static object AlphaCoerce(DependencyObject d, object brightness)
|
||||
{
|
||||
var v = (double) brightness;
|
||||
if (v < 0) return 0.0;
|
||||
if (v > 1) return 1.0;
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
var p = e.GetPosition(this);
|
||||
|
||||
if (Orientation == Orientation.Vertical)
|
||||
Alpha = 1 - p.Y/ActualHeight;
|
||||
else
|
||||
Alpha = 1 - p.X/ActualWidth;
|
||||
}
|
||||
base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
var p = e.GetPosition(this);
|
||||
|
||||
if (Orientation == Orientation.Vertical)
|
||||
Alpha = 1 - p.Y/ActualHeight;
|
||||
else
|
||||
Alpha = 1 - p.X/ActualWidth;
|
||||
}
|
||||
Mouse.Capture(this);
|
||||
base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseButtonEventArgs e)
|
||||
{
|
||||
ReleaseMouseCapture();
|
||||
base.OnMouseUp(e);
|
||||
}
|
||||
|
||||
protected override void OnRender(DrawingContext dc)
|
||||
{
|
||||
var lb = new LinearGradientBrush();
|
||||
|
||||
lb.StartPoint = new Point(0, 0);
|
||||
|
||||
if (Orientation == Orientation.Vertical)
|
||||
lb.EndPoint = new Point(0, 1);
|
||||
else
|
||||
lb.EndPoint = new Point(1, 0);
|
||||
|
||||
lb.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x00, 0x00, 0x00), 0.00));
|
||||
lb.GradientStops.Add(new GradientStop(Color.FromArgb(0x00, 0x00, 0x00, 0x00), 1.00));
|
||||
|
||||
dc.DrawRectangle(lb, null, new Rect(0, 0, ActualWidth, ActualHeight));
|
||||
|
||||
SetAlphaOffset();
|
||||
}
|
||||
|
||||
protected override Size ArrangeOverride(Size finalSize)
|
||||
{
|
||||
SetAlphaOffset();
|
||||
return base.ArrangeOverride(finalSize);
|
||||
}
|
||||
|
||||
|
||||
private void SetAlphaOffset()
|
||||
{
|
||||
var length = ActualHeight;
|
||||
if (Orientation == Orientation.Horizontal)
|
||||
length = ActualWidth;
|
||||
AlphaOffset = length - length*Alpha;
|
||||
}
|
||||
|
||||
private void SetColor()
|
||||
{
|
||||
Color = Color.FromArgb((byte) Math.Round(Alpha*255), 0, 0, 0);
|
||||
//Brush = new SolidColorBrush(Color);
|
||||
}
|
||||
}
|
||||
}
|
||||
39
Artemis/ColorBox/BaseSelector.cs
Normal file
39
Artemis/ColorBox/BaseSelector.cs
Normal file
@ -0,0 +1,39 @@
|
||||
/***************** NCore Softwares Pvt. Ltd., India **************************
|
||||
|
||||
ColorBox
|
||||
|
||||
Copyright (C) 2013 NCore Softwares Pvt. Ltd.
|
||||
|
||||
This program is provided to you under the terms of the Microsoft Public
|
||||
License (Ms-PL) as published at http://colorbox.codeplex.com/license
|
||||
|
||||
***********************************************************************************/
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace ColorBox
|
||||
{
|
||||
public abstract class BaseSelector : FrameworkElement
|
||||
{
|
||||
public static readonly DependencyProperty OrientationProperty =
|
||||
DependencyProperty.Register("Orientation", typeof(Orientation), typeof(BaseSelector),
|
||||
new UIPropertyMetadata(Orientation.Vertical));
|
||||
|
||||
public static readonly DependencyProperty ColorProperty =
|
||||
DependencyProperty.Register("Color", typeof(Color), typeof(BaseSelector), new UIPropertyMetadata(Colors.Red));
|
||||
|
||||
public Orientation Orientation
|
||||
{
|
||||
get { return (Orientation) GetValue(OrientationProperty); }
|
||||
set { SetValue(OrientationProperty, value); }
|
||||
}
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get { return (Color) GetValue(ColorProperty); }
|
||||
protected set { SetValue(ColorProperty, value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
24
Artemis/ColorBox/BrushTypes.cs
Normal file
24
Artemis/ColorBox/BrushTypes.cs
Normal file
@ -0,0 +1,24 @@
|
||||
/***************** NCore Softwares Pvt. Ltd., India **************************
|
||||
|
||||
ColorBox
|
||||
|
||||
Copyright (C) 2013 NCore Softwares Pvt. Ltd.
|
||||
|
||||
This program is provided to you under the terms of the Microsoft Public
|
||||
License (Ms-PL) as published at http://colorbox.codeplex.com/license
|
||||
|
||||
***********************************************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace ColorBox
|
||||
{
|
||||
[Flags]
|
||||
public enum BrushTypes
|
||||
{
|
||||
None,
|
||||
Solid,
|
||||
Linear,
|
||||
Radial
|
||||
}
|
||||
}
|
||||
1024
Artemis/ColorBox/ColorBox.cs
Normal file
1024
Artemis/ColorBox/ColorBox.cs
Normal file
File diff suppressed because it is too large
Load Diff
93
Artemis/ColorBox/ColorBox.csproj
Normal file
93
Artemis/ColorBox/ColorBox.csproj
Normal file
@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.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>{40085232-ACED-4CBE-945B-90BA8153C151}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ColorBox</RootNamespace>
|
||||
<AssemblyName>ColorBox</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<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' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>ColorBox.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xaml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AlphaSelector.cs" />
|
||||
<Compile Include="BaseSelector.cs" />
|
||||
<Compile Include="ColorBox.cs" />
|
||||
<Compile Include="ColorChangedEventArgs.cs" />
|
||||
<Compile Include="BrushTypes.cs" />
|
||||
<Compile Include="DoubleUpDown.cs" />
|
||||
<Compile Include="Enums.cs" />
|
||||
<Compile Include="GradientStopAdder.cs" />
|
||||
<Compile Include="GradientStopSlider.cs" />
|
||||
<Compile Include="HueSelector.cs" />
|
||||
<Compile Include="SaturationBrightnessSelector.cs" />
|
||||
<Compile Include="SpinEventArgs .cs" />
|
||||
<Compile Include="Spinner.cs" />
|
||||
<Compile Include="Utils\TextBoxBehavior.cs" />
|
||||
<Compile Include="UpDownBase.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Utils\ColorHelper.cs" />
|
||||
<Compile Include="Utils\InputValidationErrorEventArgs .cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="Themes\Generic.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ColorBox.snk" />
|
||||
</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>
|
||||
BIN
Artemis/ColorBox/ColorBox.snk
Normal file
BIN
Artemis/ColorBox/ColorBox.snk
Normal file
Binary file not shown.
27
Artemis/ColorBox/ColorChangedEventArgs.cs
Normal file
27
Artemis/ColorBox/ColorChangedEventArgs.cs
Normal file
@ -0,0 +1,27 @@
|
||||
/***************** NCore Softwares Pvt. Ltd., India **************************
|
||||
|
||||
ColorBox
|
||||
|
||||
Copyright (C) 2013 NCore Softwares Pvt. Ltd.
|
||||
|
||||
This program is provided to you under the terms of the Microsoft Public
|
||||
License (Ms-PL) as published at http://colorbox.codeplex.com/license
|
||||
|
||||
***********************************************************************************/
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace ColorBox
|
||||
{
|
||||
public class ColorChangedEventArgs : RoutedEventArgs
|
||||
{
|
||||
public ColorChangedEventArgs(RoutedEvent routedEvent, Color color)
|
||||
{
|
||||
RoutedEvent = routedEvent;
|
||||
Color = color;
|
||||
}
|
||||
|
||||
public Color Color { get; set; }
|
||||
}
|
||||
}
|
||||
201
Artemis/ColorBox/DoubleUpDown.cs
Normal file
201
Artemis/ColorBox/DoubleUpDown.cs
Normal file
@ -0,0 +1,201 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Extended WPF Toolkit
|
||||
|
||||
Copyright (C) 2007-2013 Xceed Software Inc.
|
||||
|
||||
This program is provided to you under the terms of the Microsoft Public
|
||||
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
|
||||
|
||||
For more features, controls, and fast professional support,
|
||||
pick up the Plus Edition at http://xceed.com/wpf_toolkit
|
||||
|
||||
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
|
||||
|
||||
***********************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
|
||||
namespace ColorBox
|
||||
{
|
||||
public class DoubleUpDown : UpDownBase
|
||||
{
|
||||
private readonly FromDecimal _fromDecimal;
|
||||
private readonly Func<double, double, bool> _fromGreaterThan;
|
||||
private readonly Func<double, double, bool> _fromLowerThan;
|
||||
|
||||
private readonly FromText _fromText;
|
||||
|
||||
protected DoubleUpDown(FromText fromText, FromDecimal fromDecimal, Func<double, double, bool> fromLowerThan,
|
||||
Func<double, double, bool> fromGreaterThan)
|
||||
{
|
||||
if (fromText == null)
|
||||
throw new ArgumentNullException("parseMethod");
|
||||
|
||||
if (fromDecimal == null)
|
||||
throw new ArgumentNullException("fromDecimal");
|
||||
|
||||
if (fromLowerThan == null)
|
||||
throw new ArgumentNullException("fromLowerThan");
|
||||
|
||||
if (fromGreaterThan == null)
|
||||
throw new ArgumentNullException("fromGreaterThan");
|
||||
|
||||
_fromText = fromText;
|
||||
_fromDecimal = fromDecimal;
|
||||
_fromLowerThan = fromLowerThan;
|
||||
_fromGreaterThan = fromGreaterThan;
|
||||
}
|
||||
|
||||
protected static void UpdateMetadata(Type type, double? increment, double? minValue, double? maxValue)
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(type, new FrameworkPropertyMetadata(type));
|
||||
IncrementProperty.OverrideMetadata(type, new FrameworkPropertyMetadata(increment));
|
||||
MaximumProperty.OverrideMetadata(type, new FrameworkPropertyMetadata(maxValue));
|
||||
MinimumProperty.OverrideMetadata(type, new FrameworkPropertyMetadata(minValue));
|
||||
}
|
||||
|
||||
private bool IsLowerThan(double? value1, double? value2)
|
||||
{
|
||||
if ((value1 == null) || (value2 == null))
|
||||
return false;
|
||||
|
||||
return _fromLowerThan(value1.Value, value2.Value);
|
||||
}
|
||||
|
||||
private bool IsGreaterThan(double? value1, double? value2)
|
||||
{
|
||||
if ((value1 == null) || (value2 == null))
|
||||
return false;
|
||||
|
||||
return _fromGreaterThan(value1.Value, value2.Value);
|
||||
}
|
||||
|
||||
private bool HandleNullSpin()
|
||||
{
|
||||
if (!Value.HasValue)
|
||||
{
|
||||
var forcedValue = DefaultValue.HasValue
|
||||
? DefaultValue.Value
|
||||
: default(double);
|
||||
|
||||
Value = CoerceValueMinMax(forcedValue);
|
||||
|
||||
return true;
|
||||
}
|
||||
if (!Increment.HasValue)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private double CoerceValueMinMax(double value)
|
||||
{
|
||||
if (IsLowerThan(value, Minimum))
|
||||
return Minimum;
|
||||
if (IsGreaterThan(value, Maximum))
|
||||
return Maximum;
|
||||
return value;
|
||||
}
|
||||
|
||||
private void ValidateDefaultMinMax(double? value)
|
||||
{
|
||||
if (Equals(value, DefaultValue))
|
||||
return;
|
||||
|
||||
if (IsLowerThan(value, Minimum))
|
||||
throw new ArgumentOutOfRangeException("Minimum",
|
||||
string.Format("Value must be greater than MinValue of {0}", Minimum));
|
||||
if (IsGreaterThan(value, Maximum))
|
||||
throw new ArgumentOutOfRangeException("Maximum",
|
||||
string.Format("Value must be less than MaxValue of {0}", Maximum));
|
||||
}
|
||||
|
||||
protected delegate double FromText(string s, NumberStyles style, IFormatProvider provider);
|
||||
|
||||
protected delegate double FromDecimal(decimal d);
|
||||
|
||||
#region Base Class Overrides
|
||||
|
||||
protected override void OnIncrement()
|
||||
{
|
||||
if (!HandleNullSpin())
|
||||
{
|
||||
double? result = Value.Value + Increment.Value;
|
||||
Value = CoerceValueMinMax(result.Value);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDecrement()
|
||||
{
|
||||
if (!HandleNullSpin())
|
||||
{
|
||||
double? result = Value.Value - Increment.Value;
|
||||
Value = CoerceValueMinMax(result.Value);
|
||||
}
|
||||
}
|
||||
|
||||
protected override string ConvertValueToText()
|
||||
{
|
||||
if (Value == null)
|
||||
return string.Empty;
|
||||
|
||||
return Value.Value.ToString(FormatString, CultureInfo);
|
||||
}
|
||||
|
||||
protected override double? ConvertTextToValue(string text)
|
||||
{
|
||||
double? result = 0;
|
||||
|
||||
if (string.IsNullOrEmpty(text))
|
||||
return result;
|
||||
|
||||
var currentValueText = ConvertValueToText();
|
||||
if (Equals(currentValueText, text))
|
||||
return Value;
|
||||
|
||||
result = FormatString.Contains("P")
|
||||
? _fromDecimal(ParsePercent(text, CultureInfo))
|
||||
: _fromText(text, ParsingNumberStyle, CultureInfo);
|
||||
|
||||
ValidateDefaultMinMax(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
protected override void SetValidSpinDirection()
|
||||
{
|
||||
var validDirections = ValidSpinDirections.None;
|
||||
|
||||
if ((Increment != null) && !IsReadOnly)
|
||||
{
|
||||
if (IsLowerThan(Value, Maximum) || !Value.HasValue)
|
||||
validDirections = validDirections | ValidSpinDirections.Increase;
|
||||
|
||||
if (IsGreaterThan(Value, Minimum) || !Value.HasValue)
|
||||
validDirections = validDirections | ValidSpinDirections.Decrease;
|
||||
}
|
||||
|
||||
if (Spinner != null)
|
||||
Spinner.ValidSpinDirection = validDirections;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
static DoubleUpDown()
|
||||
{
|
||||
UpdateMetadata(typeof(DoubleUpDown), 1d, double.NegativeInfinity, double.PositiveInfinity);
|
||||
}
|
||||
|
||||
public DoubleUpDown()
|
||||
: this(double.Parse, decimal.ToDouble, (v1, v2) => v1 < v2, (v1, v2) => v1 > v2)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
43
Artemis/ColorBox/Enums.cs
Normal file
43
Artemis/ColorBox/Enums.cs
Normal file
@ -0,0 +1,43 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Extended WPF Toolkit
|
||||
|
||||
Copyright (C) 2007-2013 Xceed Software Inc.
|
||||
|
||||
This program is provided to you under the terms of the Microsoft Public
|
||||
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
|
||||
|
||||
For more features, controls, and fast professional support,
|
||||
pick up the Plus Edition at http://xceed.com/wpf_toolkit
|
||||
|
||||
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
|
||||
|
||||
***********************************************************************************/
|
||||
|
||||
namespace ColorBox
|
||||
{
|
||||
public enum SpinDirection
|
||||
{
|
||||
Increase,
|
||||
Decrease
|
||||
}
|
||||
|
||||
|
||||
public enum ValidSpinDirections
|
||||
{
|
||||
None,
|
||||
Increase,
|
||||
Decrease
|
||||
}
|
||||
|
||||
|
||||
internal enum AllowedSpecialValues
|
||||
{
|
||||
None = 0,
|
||||
NaN = 1,
|
||||
PositiveInfinity = 2,
|
||||
NegativeInfinity = 4,
|
||||
AnyInfinity = PositiveInfinity | NegativeInfinity,
|
||||
Any = NaN | AnyInfinity
|
||||
}
|
||||
}
|
||||
82
Artemis/ColorBox/GradientStopAdder.cs
Normal file
82
Artemis/ColorBox/GradientStopAdder.cs
Normal file
@ -0,0 +1,82 @@
|
||||
/***************** NCore Softwares Pvt. Ltd., India **************************
|
||||
|
||||
ColorBox
|
||||
|
||||
Copyright (C) 2013 NCore Softwares Pvt. Ltd.
|
||||
|
||||
This program is provided to you under the terms of the Microsoft Public
|
||||
License (Ms-PL) as published at http://colorbox.codeplex.com/license
|
||||
|
||||
***********************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace ColorBox
|
||||
{
|
||||
public class GradientStopAdder : Button
|
||||
{
|
||||
public static readonly DependencyProperty ColorBoxProperty =
|
||||
DependencyProperty.Register("ColorBox", typeof(ColorBox), typeof(GradientStopAdder));
|
||||
|
||||
public ColorBox ColorBox
|
||||
{
|
||||
get { return (ColorBox) GetValue(ColorBoxProperty); }
|
||||
set { SetValue(ColorBoxProperty, value); }
|
||||
}
|
||||
|
||||
protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
|
||||
{
|
||||
base.OnPreviewMouseLeftButtonDown(e);
|
||||
|
||||
if (e.Source is GradientStopAdder && (ColorBox != null))
|
||||
{
|
||||
var btn = e.Source as Button;
|
||||
|
||||
var gs = new GradientStop();
|
||||
gs.Offset = Mouse.GetPosition(btn).X/btn.ActualWidth;
|
||||
//_gs.Color = this.ColorBox.Color;
|
||||
gs.Color = GetColorFromImage(e.GetPosition(this));
|
||||
ColorBox.Gradients.Add(gs);
|
||||
ColorBox.SelectedGradient = gs;
|
||||
ColorBox.Color = gs.Color;
|
||||
ColorBox.SetBrush();
|
||||
}
|
||||
}
|
||||
|
||||
private Color GetColorFromImage(Point p)
|
||||
{
|
||||
try
|
||||
{
|
||||
var bounds = VisualTreeHelper.GetDescendantBounds(this);
|
||||
var rtb = new RenderTargetBitmap((int) bounds.Width, (int) bounds.Height, 96, 96, PixelFormats.Default);
|
||||
rtb.Render(this);
|
||||
|
||||
byte[] arr;
|
||||
var png = new PngBitmapEncoder();
|
||||
png.Frames.Add(BitmapFrame.Create(rtb));
|
||||
using (var stream = new MemoryStream())
|
||||
{
|
||||
png.Save(stream);
|
||||
arr = stream.ToArray();
|
||||
}
|
||||
|
||||
BitmapSource bitmap = BitmapFrame.Create(new MemoryStream(arr));
|
||||
|
||||
var pixels = new byte[4];
|
||||
var cb = new CroppedBitmap(bitmap, new Int32Rect((int) p.X, (int) p.Y, 1, 1));
|
||||
cb.CopyPixels(pixels, 4, 0);
|
||||
return Color.FromArgb(pixels[3], pixels[2], pixels[1], pixels[0]);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return ColorBox.Color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
74
Artemis/ColorBox/GradientStopSlider.cs
Normal file
74
Artemis/ColorBox/GradientStopSlider.cs
Normal file
@ -0,0 +1,74 @@
|
||||
/***************** NCore Softwares Pvt. Ltd., India **************************
|
||||
|
||||
ColorBox
|
||||
|
||||
Copyright (C) 2013 NCore Softwares Pvt. Ltd.
|
||||
|
||||
This program is provided to you under the terms of the Microsoft Public
|
||||
License (Ms-PL) as published at http://colorbox.codeplex.com/license
|
||||
|
||||
***********************************************************************************/
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace ColorBox
|
||||
{
|
||||
public class GradientStopSlider : Slider
|
||||
{
|
||||
public static readonly DependencyProperty ColorBoxProperty =
|
||||
DependencyProperty.Register("ColorBox", typeof(ColorBox), typeof(GradientStopSlider));
|
||||
|
||||
public static readonly DependencyProperty SelectedGradientProperty =
|
||||
DependencyProperty.Register("SelectedGradient", typeof(GradientStop), typeof(GradientStopSlider));
|
||||
|
||||
public ColorBox ColorBox
|
||||
{
|
||||
get { return (ColorBox) GetValue(ColorBoxProperty); }
|
||||
set { SetValue(ColorBoxProperty, value); }
|
||||
}
|
||||
|
||||
public GradientStop SelectedGradient
|
||||
{
|
||||
get { return (GradientStop) GetValue(SelectedGradientProperty); }
|
||||
set { SetValue(SelectedGradientProperty, value); }
|
||||
}
|
||||
|
||||
protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
|
||||
{
|
||||
base.OnPreviewMouseLeftButtonDown(e);
|
||||
|
||||
if (ColorBox != null)
|
||||
{
|
||||
ColorBox.BrushSetInternally = true;
|
||||
ColorBox.UpdateBrush = false;
|
||||
|
||||
ColorBox.SelectedGradient = SelectedGradient;
|
||||
ColorBox.Color = SelectedGradient.Color;
|
||||
|
||||
ColorBox.UpdateBrush = true;
|
||||
//this.ColorBox._BrushSetInternally = false;
|
||||
|
||||
//e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnValueChanged(double oldValue, double newValue)
|
||||
{
|
||||
base.OnValueChanged(oldValue, newValue);
|
||||
|
||||
if (ColorBox != null)
|
||||
{
|
||||
//this.ColorBox._HSBSetInternally = true;
|
||||
//this.ColorBox._RGBSetInternally = true;
|
||||
ColorBox.BrushSetInternally = true;
|
||||
ColorBox.SetBrush();
|
||||
ColorBox.HsbSetInternally = false;
|
||||
//this.ColorBox._RGBSetInternally = false;
|
||||
//this.ColorBox._BrushSetInternally = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
138
Artemis/ColorBox/HueSelector.cs
Normal file
138
Artemis/ColorBox/HueSelector.cs
Normal file
@ -0,0 +1,138 @@
|
||||
/***************** NCore Softwares Pvt. Ltd., India **************************
|
||||
|
||||
ColorBox
|
||||
|
||||
Copyright (C) 2013 NCore Softwares Pvt. Ltd.
|
||||
|
||||
This program is provided to you under the terms of the Microsoft Public
|
||||
License (Ms-PL) as published at http://colorbox.codeplex.com/license
|
||||
|
||||
***********************************************************************************/
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace ColorBox
|
||||
{
|
||||
public class HueSelector : BaseSelector
|
||||
{
|
||||
public static readonly DependencyProperty HueProperty =
|
||||
DependencyProperty.Register("Hue", typeof(double), typeof(HueSelector),
|
||||
new FrameworkPropertyMetadata(0.0, HueChanged, HueCoerce));
|
||||
|
||||
public static readonly DependencyProperty HueOffsetProperty =
|
||||
DependencyProperty.Register("HueOffset", typeof(double), typeof(HueSelector), new UIPropertyMetadata(0.0));
|
||||
|
||||
public double Hue
|
||||
{
|
||||
get { return (double) GetValue(HueProperty); }
|
||||
set { SetValue(HueProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
public double HueOffset
|
||||
{
|
||||
get { return (double) GetValue(HueOffsetProperty); }
|
||||
private set { SetValue(HueOffsetProperty, value); }
|
||||
}
|
||||
|
||||
public static void HueChanged(object o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var h = (HueSelector) o;
|
||||
h.SetHueOffset();
|
||||
h.SetColor();
|
||||
}
|
||||
|
||||
public static object HueCoerce(DependencyObject d, object brightness)
|
||||
{
|
||||
var v = (double) brightness;
|
||||
if (v < 0) return 0.0;
|
||||
if (v > 1) return 1.0;
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
var p = e.GetPosition(this);
|
||||
|
||||
if (Orientation == Orientation.Vertical)
|
||||
Hue = 1 - p.Y/ActualHeight;
|
||||
else
|
||||
Hue = 1 - p.X/ActualWidth;
|
||||
}
|
||||
base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
var p = e.GetPosition(this);
|
||||
|
||||
if (Orientation == Orientation.Vertical)
|
||||
Hue = 1 - p.Y/ActualHeight;
|
||||
else
|
||||
Hue = 1 - p.X/ActualWidth;
|
||||
}
|
||||
Mouse.Capture(this);
|
||||
base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseButtonEventArgs e)
|
||||
{
|
||||
ReleaseMouseCapture();
|
||||
base.OnMouseUp(e);
|
||||
}
|
||||
|
||||
protected override void OnRender(DrawingContext dc)
|
||||
{
|
||||
var lb = new LinearGradientBrush();
|
||||
|
||||
lb.StartPoint = new Point(0, 0);
|
||||
|
||||
if (Orientation == Orientation.Vertical)
|
||||
lb.EndPoint = new Point(0, 1);
|
||||
else
|
||||
lb.EndPoint = new Point(1, 0);
|
||||
|
||||
lb.GradientStops.Add(new GradientStop(Color.FromRgb(0xFF, 0x00, 0x00), 1.00));
|
||||
lb.GradientStops.Add(new GradientStop(Color.FromRgb(0xFF, 0xFF, 0x00), 0.85));
|
||||
lb.GradientStops.Add(new GradientStop(Color.FromRgb(0x00, 0xFF, 0x00), 0.76));
|
||||
lb.GradientStops.Add(new GradientStop(Color.FromRgb(0x00, 0xFF, 0xFF), 0.50));
|
||||
lb.GradientStops.Add(new GradientStop(Color.FromRgb(0x00, 0x00, 0xFF), 0.33));
|
||||
lb.GradientStops.Add(new GradientStop(Color.FromRgb(0xFF, 0x00, 0xFF), 0.16));
|
||||
lb.GradientStops.Add(new GradientStop(Color.FromRgb(0xFF, 0x00, 0x00), 0.00));
|
||||
|
||||
dc.DrawRectangle(lb, null, new Rect(0, 0, ActualWidth, ActualHeight));
|
||||
|
||||
SetHueOffset();
|
||||
}
|
||||
|
||||
protected override Size ArrangeOverride(Size finalSize)
|
||||
{
|
||||
SetHueOffset();
|
||||
return base.ArrangeOverride(finalSize);
|
||||
}
|
||||
|
||||
|
||||
private void SetHueOffset()
|
||||
{
|
||||
var length = ActualHeight;
|
||||
if (Orientation == Orientation.Horizontal)
|
||||
length = ActualWidth;
|
||||
|
||||
HueOffset = length - length*Hue;
|
||||
}
|
||||
|
||||
private void SetColor()
|
||||
{
|
||||
Color = ColorHelper.ColorFromHsb(Hue, 1, 1);
|
||||
//base.Brush = new SolidColorBrush(Color);
|
||||
}
|
||||
}
|
||||
}
|
||||
38
Artemis/ColorBox/Properties/AssemblyInfo.cs
Normal file
38
Artemis/ColorBox/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,38 @@
|
||||
/***************** NCore Softwares Pvt. Ltd., India **************************
|
||||
|
||||
ColorBox
|
||||
|
||||
Copyright (C) 2013 NCore Softwares Pvt. Ltd.
|
||||
|
||||
This program is provided to you under the terms of the Microsoft Public
|
||||
License (Ms-PL) as published at http://colorbox.codeplex.com/license
|
||||
|
||||
***********************************************************************************/
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Markup;
|
||||
|
||||
// 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("ColorBox Library")]
|
||||
[assembly:
|
||||
AssemblyDescription(
|
||||
"This assembly implements a solid and gradient brush picker control for Windows Presentation Foundation. ")]
|
||||
[assembly: AssemblyCompany("NCore Softwares Pvt. Ltd.")]
|
||||
[assembly: AssemblyProduct("ColorBox")]
|
||||
[assembly: AssemblyCopyright("Copyright © NCore Softwares Pvt. Ltd. 2013")]
|
||||
[assembly: ThemeInfo(ResourceDictionaryLocation.SourceAssembly, ResourceDictionaryLocation.SourceAssembly)]
|
||||
|
||||
// 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)]
|
||||
[assembly: AssemblyVersion("1.1")]
|
||||
[assembly: AssemblyFileVersion("1.1")]
|
||||
[assembly: XmlnsPrefix("http://schemas.ncore.com/wpf/xaml/colorbox", "ncore")]
|
||||
[assembly: XmlnsDefinition("http://schemas.ncore.com/wpf/xaml/colorbox", "ColorBox")]
|
||||
189
Artemis/ColorBox/SaturationBrightnessSelector.cs
Normal file
189
Artemis/ColorBox/SaturationBrightnessSelector.cs
Normal file
@ -0,0 +1,189 @@
|
||||
/***************** NCore Softwares Pvt. Ltd., India **************************
|
||||
|
||||
ColorBox
|
||||
|
||||
Copyright (C) 2013 NCore Softwares Pvt. Ltd.
|
||||
|
||||
This program is provided to you under the terms of the Microsoft Public
|
||||
License (Ms-PL) as published at http://colorbox.codeplex.com/license
|
||||
|
||||
***********************************************************************************/
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace ColorBox
|
||||
{
|
||||
public class SaturationBrightnessSelector : BaseSelector
|
||||
{
|
||||
public static readonly DependencyProperty OffsetPaddingProperty =
|
||||
DependencyProperty.Register("OffsetPadding", typeof(Thickness), typeof(SaturationBrightnessSelector),
|
||||
new UIPropertyMetadata(new Thickness(0.0)));
|
||||
|
||||
public static readonly DependencyProperty HueProperty =
|
||||
DependencyProperty.Register("Hue", typeof(double), typeof(SaturationBrightnessSelector), new
|
||||
FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender, HueChanged));
|
||||
|
||||
public static readonly DependencyProperty SaturationOffsetProperty =
|
||||
DependencyProperty.Register("SaturationOffset", typeof(double), typeof(SaturationBrightnessSelector),
|
||||
new UIPropertyMetadata(0.0));
|
||||
|
||||
public static readonly DependencyProperty SaturationProperty =
|
||||
DependencyProperty.Register("Saturation", typeof(double), typeof(SaturationBrightnessSelector),
|
||||
new FrameworkPropertyMetadata(0.0, SaturationChanged, SaturationCoerce));
|
||||
|
||||
public static readonly DependencyProperty BrightnessOffsetProperty =
|
||||
DependencyProperty.Register("BrightnessOffset", typeof(double), typeof(SaturationBrightnessSelector),
|
||||
new UIPropertyMetadata(0.0));
|
||||
|
||||
public static readonly DependencyProperty BrightnessProperty =
|
||||
DependencyProperty.Register("Brightness", typeof(double), typeof(SaturationBrightnessSelector),
|
||||
new FrameworkPropertyMetadata(0.0, BrightnessChanged, BrightnessCoerce));
|
||||
|
||||
public Thickness OffsetPadding
|
||||
{
|
||||
get { return (Thickness) GetValue(OffsetPaddingProperty); }
|
||||
set { SetValue(OffsetPaddingProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
public double Hue
|
||||
{
|
||||
private get { return (double) GetValue(HueProperty); }
|
||||
set { SetValue(HueProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
public double SaturationOffset
|
||||
{
|
||||
get { return (double) GetValue(SaturationOffsetProperty); }
|
||||
set { SetValue(SaturationOffsetProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
public double Saturation
|
||||
{
|
||||
get { return (double) GetValue(SaturationProperty); }
|
||||
set { SetValue(SaturationProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
public double BrightnessOffset
|
||||
{
|
||||
get { return (double) GetValue(BrightnessOffsetProperty); }
|
||||
set { SetValue(BrightnessOffsetProperty, value); }
|
||||
}
|
||||
|
||||
|
||||
public double Brightness
|
||||
{
|
||||
get { return (double) GetValue(BrightnessProperty); }
|
||||
set { SetValue(BrightnessProperty, value); }
|
||||
}
|
||||
|
||||
public static void HueChanged(object o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var h = (SaturationBrightnessSelector) o;
|
||||
h.SetColor();
|
||||
}
|
||||
|
||||
public static void SaturationChanged(object o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var h = (SaturationBrightnessSelector) o;
|
||||
h.SetSaturationOffset();
|
||||
}
|
||||
|
||||
public static object SaturationCoerce(DependencyObject d, object brightness)
|
||||
{
|
||||
var v = (double) brightness;
|
||||
if (v < 0) return 0.0;
|
||||
if (v > 1) return 1.0;
|
||||
return v;
|
||||
}
|
||||
|
||||
public static void BrightnessChanged(object o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var h = (SaturationBrightnessSelector) o;
|
||||
h.SetBrightnessOffset();
|
||||
}
|
||||
|
||||
public static object BrightnessCoerce(DependencyObject d, object brightness)
|
||||
{
|
||||
var v = (double) brightness;
|
||||
if (v < 0) return 0.0;
|
||||
if (v > 1) return 1.0;
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
var p = e.GetPosition(this);
|
||||
Saturation = p.X/(ActualWidth - OffsetPadding.Right);
|
||||
Brightness = (ActualHeight - OffsetPadding.Bottom - p.Y)/(ActualHeight - OffsetPadding.Bottom);
|
||||
SetColor();
|
||||
}
|
||||
base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseButtonEventArgs e)
|
||||
{
|
||||
var p = e.GetPosition(this);
|
||||
Saturation = p.X/(ActualWidth - OffsetPadding.Right);
|
||||
Brightness = (ActualHeight - OffsetPadding.Bottom - p.Y)/(ActualHeight - OffsetPadding.Bottom);
|
||||
SetColor();
|
||||
|
||||
Mouse.Capture(this);
|
||||
base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseButtonEventArgs e)
|
||||
{
|
||||
ReleaseMouseCapture();
|
||||
base.OnMouseUp(e);
|
||||
}
|
||||
|
||||
protected override void OnRender(DrawingContext dc)
|
||||
{
|
||||
var h = new LinearGradientBrush();
|
||||
h.StartPoint = new Point(0, 0);
|
||||
h.EndPoint = new Point(1, 0);
|
||||
h.GradientStops.Add(new GradientStop(Colors.White, 0.00));
|
||||
h.GradientStops.Add(new GradientStop(ColorHelper.ColorFromHsb(Hue, 1, 1), 1.0));
|
||||
dc.DrawRectangle(h, null, new Rect(0, 0, ActualWidth, ActualHeight));
|
||||
|
||||
var v = new LinearGradientBrush();
|
||||
v.StartPoint = new Point(0, 0);
|
||||
v.EndPoint = new Point(0, 1);
|
||||
v.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0, 0, 0), 1.00));
|
||||
v.GradientStops.Add(new GradientStop(Color.FromArgb(0x80, 0, 0, 0), 0.50));
|
||||
v.GradientStops.Add(new GradientStop(Color.FromArgb(0x00, 0, 0, 0), 0.00));
|
||||
dc.DrawRectangle(v, null, new Rect(0, 0, ActualWidth, ActualHeight));
|
||||
|
||||
SetSaturationOffset();
|
||||
SetBrightnessOffset();
|
||||
}
|
||||
|
||||
private void SetSaturationOffset()
|
||||
{
|
||||
SaturationOffset = OffsetPadding.Left +
|
||||
(ActualWidth - (OffsetPadding.Right + OffsetPadding.Left))*Saturation;
|
||||
}
|
||||
|
||||
private void SetBrightnessOffset()
|
||||
{
|
||||
BrightnessOffset = OffsetPadding.Top +
|
||||
(ActualHeight - (OffsetPadding.Bottom + OffsetPadding.Top) -
|
||||
(ActualHeight - (OffsetPadding.Bottom + OffsetPadding.Top))*Brightness);
|
||||
}
|
||||
|
||||
public void SetColor()
|
||||
{
|
||||
Color = ColorHelper.ColorFromHsb(Hue, Saturation, Brightness);
|
||||
//Brush = new SolidColorBrush(Color);
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Artemis/ColorBox/SpinEventArgs .cs
Normal file
30
Artemis/ColorBox/SpinEventArgs .cs
Normal file
@ -0,0 +1,30 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Extended WPF Toolkit
|
||||
|
||||
Copyright (C) 2007-2013 Xceed Software Inc.
|
||||
|
||||
This program is provided to you under the terms of the Microsoft Public
|
||||
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
|
||||
|
||||
For more features, controls, and fast professional support,
|
||||
pick up the Plus Edition at http://xceed.com/wpf_toolkit
|
||||
|
||||
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
|
||||
|
||||
***********************************************************************************/
|
||||
|
||||
using System.Windows;
|
||||
|
||||
namespace ColorBox
|
||||
{
|
||||
public class SpinEventArgs : RoutedEventArgs
|
||||
{
|
||||
public SpinEventArgs(SpinDirection direction)
|
||||
{
|
||||
Direction = direction;
|
||||
}
|
||||
|
||||
public SpinDirection Direction { get; private set; }
|
||||
}
|
||||
}
|
||||
56
Artemis/ColorBox/Spinner.cs
Normal file
56
Artemis/ColorBox/Spinner.cs
Normal file
@ -0,0 +1,56 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Extended WPF Toolkit
|
||||
|
||||
Copyright (C) 2007-2013 Xceed Software Inc.
|
||||
|
||||
This program is provided to you under the terms of the Microsoft Public
|
||||
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
|
||||
|
||||
For more features, controls, and fast professional support,
|
||||
pick up the Plus Edition at http://xceed.com/wpf_toolkit
|
||||
|
||||
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
|
||||
|
||||
***********************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace ColorBox
|
||||
{
|
||||
public class Spinner : ContentControl
|
||||
{
|
||||
public static readonly DependencyProperty ValidSpinDirectionProperty =
|
||||
DependencyProperty.Register("ValidSpinDirection", typeof(ValidSpinDirections), typeof(Spinner),
|
||||
new PropertyMetadata(ValidSpinDirections.Increase | ValidSpinDirections.Decrease,
|
||||
OnValidSpinDirectionPropertyChanged));
|
||||
|
||||
static Spinner()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(Spinner), new FrameworkPropertyMetadata(typeof(Spinner)));
|
||||
}
|
||||
|
||||
public ValidSpinDirections ValidSpinDirection
|
||||
{
|
||||
get { return (ValidSpinDirections) GetValue(ValidSpinDirectionProperty); }
|
||||
set { SetValue(ValidSpinDirectionProperty, value); }
|
||||
}
|
||||
|
||||
public static void OnValidSpinDirectionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var oldvalue = (ValidSpinDirections) e.OldValue;
|
||||
var newvalue = (ValidSpinDirections) e.NewValue;
|
||||
}
|
||||
|
||||
public event EventHandler<SpinEventArgs> Spin;
|
||||
|
||||
public virtual void OnSpin(SpinEventArgs e)
|
||||
{
|
||||
var handler = Spin;
|
||||
if (handler != null)
|
||||
handler(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
759
Artemis/ColorBox/Themes/Generic.xaml
Normal file
759
Artemis/ColorBox/Themes/Generic.xaml
Normal file
@ -0,0 +1,759 @@
|
||||
<!--***************** NCore Softwares Pvt. Ltd., India **************************
|
||||
|
||||
ColorBox
|
||||
|
||||
Copyright (C) 2013 NCore Softwares Pvt. Ltd.
|
||||
|
||||
This program is provided to you under the terms of the Microsoft Public
|
||||
License (Ms-PL) as published at http://colorbox.codeplex.com/license
|
||||
|
||||
*********************************************************************************** -->
|
||||
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:ColorBox">
|
||||
|
||||
<Geometry x:Key="SkewIcon">M456.021,227.816L545.590,227.816L456.021,362.171L366.452,362.171L456.021,227.816</Geometry>
|
||||
<Geometry x:Key="TranslateIcon">M384,289.828L384,363L457.171,363M384,363L457.171,289.828M480,267L480,310.011L435.711,267L480,267</Geometry>
|
||||
<Geometry x:Key="RotateIcon">F1 M 32.0034,13.0019L 35.0033,16.002L 35.0034,24.0019L 27.0033,24.002L 24.0034,21.0019L 29.5944,21.0014C 28.2209,19.4668 26.2249,18.501 24.0033,18.501C 19.8606,18.501 16.5022,21.8593 16.5022,26.002C 16.5022,28.0734 17.3418,29.9486 18.6992,31.3061L 16.2241,33.7812C 14.2332,31.7903 13.0018,29.0399 13.0018,26.0019C 13.0018,19.926 17.9274,15.0004 24.0033,15.0004C 27.1557,15.0004 29.9984,16.3263 32.0042,18.4508L 32.0034,13.0019 Z</Geometry>
|
||||
<Geometry x:Key="ScaleIcon">F1 M 28,13L 36,13L 36,21L 33,24L 33,18.5L 24,27.5L 21.5,25L 30.5,16L 25,16L 28,13 Z M 13,18L 26,18L 23,21L 16,21L 16,33L 28,33L 28,26L 31,23L 31,36L 13,36L 13,18 Z</Geometry>
|
||||
<Geometry x:Key="CenterIcon">M502.672,272.601C502.672,298.366 481.785,319.252 456.021,319.252 430.257,319.252 409.370,298.366 409.370,272.601 409.370,246.837 430.257,225.950 456.021,225.950 481.785,225.950 502.672,246.837 502.672,272.601zM502.672,272.601C502.672,298.366 481.785,319.252 456.021,319.252 430.257,319.252 409.370,298.366 409.370,272.601 409.370,246.837 430.257,225.950 456.021,225.950 481.785,225.950 502.672,246.837 502.672,272.601zM470.531,272.601C470.531,280.615 464.035,287.111 456.021,287.111 448.007,287.111 441.511,280.615 441.511,272.601 441.511,264.588 448.007,258.091 456.021,258.091 464.035,258.091 470.531,264.588 470.531,272.601z</Geometry>
|
||||
<Geometry x:Key="FlipIcon">M384,267L384,363L480,363M384,363L459.026,286.973L438,267L479.000,267L479.000,307.000L459.026,286.973</Geometry>
|
||||
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVis" />
|
||||
|
||||
<VisualBrush x:Key="AlphaBrush" Stretch="None" TileMode="Tile" ViewportUnits="Absolute" Viewport="0,0,8,8">
|
||||
<VisualBrush.Visual>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="4" />
|
||||
<ColumnDefinition Width="4" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="4" />
|
||||
<RowDefinition Height="4" />
|
||||
</Grid.RowDefinitions>
|
||||
<Rectangle Fill="#FFF" Grid.Row="0" Grid.Column="0" />
|
||||
<Rectangle Fill="#AAA" Grid.Row="0" Grid.Column="1" />
|
||||
<Rectangle Fill="#AAA" Grid.Row="1" Grid.Column="0" />
|
||||
<Rectangle Fill="#FFF" Grid.Row="1" Grid.Column="1" />
|
||||
</Grid>
|
||||
</VisualBrush.Visual>
|
||||
</VisualBrush>
|
||||
|
||||
<Style TargetType="Path" x:Key="IconStyle">
|
||||
<Setter Property="Height" Value="16" />
|
||||
<Setter Property="Width" Value="16" />
|
||||
<Setter Property="Fill" Value="#000000" />
|
||||
<Setter Property="Stretch" Value="Fill" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Slider" x:Key="OpacitySliderStyle">
|
||||
<Setter Property="Value"
|
||||
Value="{Binding Brush.Opacity, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" />
|
||||
<Setter Property="IsMoveToPointEnabled" Value="True" />
|
||||
<Setter Property="Margin" Value="2" />
|
||||
<Setter Property="Minimum" Value="0" />
|
||||
<Setter Property="Maximum" Value="1" />
|
||||
</Style>
|
||||
|
||||
<!-- Gradient Stop Thumb Style -->
|
||||
<Style x:Key="SliderThumbStyle" TargetType="Thumb">
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="BorderBrush" Value="#000000" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Thumb">
|
||||
<Grid>
|
||||
<Path Data="M468.9,240 A71.7,71.7,0,1,0,593, 240 M468.9,240 L531,152 L593,240"
|
||||
Height="16" Width="14" Stretch="Fill"
|
||||
Fill="#FFFFFF" Stroke="{TemplateBinding BorderBrush}" />
|
||||
|
||||
<Path Data="M468.9,240 A71.7,71.7,0,1,0,593,240 M468.9,240 L531,152 L593,240"
|
||||
Height="12" Width="8" Stretch="Fill"
|
||||
Fill="{TemplateBinding Background}" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- Gradient Stop Slider Style -->
|
||||
<Style x:Key="GradientStopSliderStyle" TargetType="Slider">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Slider">
|
||||
<Track x:Name="PART_Track">
|
||||
<Track.Thumb>
|
||||
<Thumb Style="{StaticResource SliderThumbStyle}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}" />
|
||||
</Track.Thumb>
|
||||
</Track>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
|
||||
<!-- ******* DoubleUpDown ******* -->
|
||||
|
||||
<Style x:Key="NumericUpDown" TargetType="{x:Type local:UpDownBase}">
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="Foreground" Value="#000000" />
|
||||
<Setter Property="Background" Value="#FFFFFF" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="IsTabStop" Value="False" />
|
||||
<Setter Property="Margin" Value="2" />
|
||||
<Setter Property="Padding" Value="5,1" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="local:UpDownBase">
|
||||
<local:Spinner IsTabStop="False"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
|
||||
<TextBox x:Name="PART_TextBox"
|
||||
FocusVisualStyle="{x:Null}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
ContextMenu="{TemplateBinding ContextMenu}"
|
||||
FontFamily="{TemplateBinding FontFamily}"
|
||||
FontSize="{TemplateBinding FontSize}"
|
||||
FontStretch="{TemplateBinding FontStretch}"
|
||||
FontStyle="{TemplateBinding FontStyle}"
|
||||
FontWeight="{TemplateBinding FontWeight}"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
MinWidth="20"
|
||||
AcceptsReturn="False"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
TabIndex="{TemplateBinding TabIndex}"
|
||||
local:TextBoxBehavior.SelectAllTextOnFocus="True" />
|
||||
</local:Spinner>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="{x:Type local:DoubleUpDown}" BasedOn="{StaticResource NumericUpDown}">
|
||||
<Setter Property="Increment" Value=".1" />
|
||||
<Setter Property="FormatString" Value="F1" />
|
||||
</Style>
|
||||
|
||||
|
||||
<!-- ******* Spinner ******* -->
|
||||
|
||||
<Style TargetType="{x:Type local:Spinner}">
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="Background" Value="#FFFFFF" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Focusable" Value="False" />
|
||||
<Setter Property="IsTabStop" Value="True" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type local:Spinner}">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}">
|
||||
<ContentPresenter />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
|
||||
<!-- ******* ColorBox ******* -->
|
||||
<Style TargetType="{x:Type local:ColorBox}">
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="Background" Value="#E7E8E8" />
|
||||
<Setter Property="BorderBrush" Value="#000000" />
|
||||
<Setter Property="VerticalAlignment" Value="Top" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type local:ColorBox}">
|
||||
<Border x:Name="PART_Root"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<Border.InputBindings>
|
||||
<KeyBinding Key="Delete" Command="{x:Static local:ColorBox.RemoveGradientStop}" />
|
||||
</Border.InputBindings>
|
||||
|
||||
<StackPanel Margin="5">
|
||||
|
||||
<StackPanel.Resources>
|
||||
<Style x:Key="TbStyle" TargetType="TextBlock">
|
||||
<Setter Property="Margin" Value="2" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
|
||||
<ListBox x:Name="listAvailableBrushType"
|
||||
HorizontalContentAlignment="Center"
|
||||
SelectedItem="{Binding BrushType, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
||||
ItemsSource="{Binding AvailableBrushTypes, RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<UniformGrid Rows="1" Columns="4" />
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBoxItem">
|
||||
<Border x:Name="Border" Background="Transparent" Padding="0,3">
|
||||
<Path x:Name="Icon" Height="12" Width="20" Stretch="Fill"
|
||||
Fill="#FF403C3C" StrokeThickness="1" Stroke="#000000"
|
||||
Data="M371,190L557,190 557,293 371,293 371,190z" />
|
||||
</Border>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="Gray"
|
||||
TargetName="Border" />
|
||||
<Setter Property="Foreground" Value="#FFFFFF" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="Gray"
|
||||
TargetName="Border" />
|
||||
<Setter Property="Foreground" Value="#FFFFFF" />
|
||||
</Trigger>
|
||||
|
||||
<DataTrigger Binding="{Binding}" Value="None">
|
||||
<Setter Property="ToolTip" Value="No Brush" />
|
||||
<Setter Property="StrokeThickness" TargetName="Icon"
|
||||
Value="0" />
|
||||
<Setter TargetName="Icon" Property="Data">
|
||||
<Setter.Value>
|
||||
<Geometry>M612,189L452.949,189L452.949,266.024L612,189 M612,196.999L452.949,273.999L612,273.999L612,196.999</Geometry>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding}" Value="Solid">
|
||||
<Setter Property="ToolTip" Value="Solid Color Brush" />
|
||||
<Setter Property="Fill" TargetName="Icon" Value="#FF403C3C" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding}" Value="Linear">
|
||||
<Setter Property="ToolTip" Value="Linear Gradient Brush" />
|
||||
<Setter Property="Fill" TargetName="Icon">
|
||||
<Setter.Value>
|
||||
<LinearGradientBrush StartPoint="0,.5"
|
||||
EndPoint="1,.5">
|
||||
<GradientStop Color="#FF403C3C" Offset="0" />
|
||||
<GradientStop Color="#FFFFFF" Offset="1" />
|
||||
</LinearGradientBrush>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding}" Value="Radial">
|
||||
<Setter Property="ToolTip" Value="Radial Gradient Brush" />
|
||||
<Setter Property="Fill" TargetName="Icon">
|
||||
<Setter.Value>
|
||||
<RadialGradientBrush>
|
||||
<GradientStop Color="#FF403C3C" Offset="1" />
|
||||
<GradientStop Color="#FFFFFF" />
|
||||
</RadialGradientBrush>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</DataTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
|
||||
</ListBox>
|
||||
|
||||
<ScrollViewer Margin="0,5,0,5" HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="Disabled">
|
||||
<ScrollViewer.Style>
|
||||
<Style TargetType="ScrollViewer">
|
||||
<Style.Triggers>
|
||||
<DataTrigger
|
||||
Binding="{Binding ElementName=listAvailableBrushType, Path=SelectedValue}"
|
||||
Value="None">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ScrollViewer.Style>
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition Width="20" />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition Width="20" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- saturation / brightness selector -->
|
||||
<Grid Grid.Column="0" ClipToBounds="true">
|
||||
<local:SaturationBrightnessSelector x:Name="SV" MinHeight="128"
|
||||
Saturation="{Binding Path=Saturation,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Brightness="{Binding Path=Brightness,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Hue="{Binding ElementName=H,Path=Hue}" />
|
||||
|
||||
<Grid VerticalAlignment="Top" HorizontalAlignment="Left" Margin="-6,-6,0,0"
|
||||
Width="12" Height="12">
|
||||
<Ellipse Stroke="#000000" />
|
||||
<Ellipse Stroke="#FFFFFF" Margin="1" />
|
||||
<Grid.RenderTransform>
|
||||
<TranslateTransform X="{Binding ElementName=SV,Path=SaturationOffset}"
|
||||
Y="{Binding ElementName=SV,Path=BrightnessOffset}" />
|
||||
</Grid.RenderTransform>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<!-- hue selector -->
|
||||
<local:HueSelector x:Name="H" Grid.Column="2"
|
||||
Hue="{Binding Path=Hue,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
<Path Grid.Column="2" HorizontalAlignment="Left" Margin="0,-5,0,5" Stroke="#FFFFFF"
|
||||
Fill="#000000" Data="M 0 0 L 7 5 L 0 10Z">
|
||||
<Path.RenderTransform>
|
||||
<TranslateTransform Y="{Binding ElementName=H,Path=HueOffset}" />
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
<Path Grid.Column="2" HorizontalAlignment="Right" Margin="0,-5,0,5"
|
||||
Stroke="#FFFFFF" Fill="#000000" Data="M 0 5 L 7 0 L 7 10 Z">
|
||||
<Path.RenderTransform>
|
||||
<TranslateTransform Y="{Binding ElementName=H,Path=HueOffset}" />
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
|
||||
<!-- alpha selector -->
|
||||
<Rectangle Grid.Column="4" Fill="{StaticResource AlphaBrush}" />
|
||||
<local:AlphaSelector x:Name="A" Grid.Column="4"
|
||||
Alpha="{Binding Path=Alpha,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
<Path Grid.Column="4" HorizontalAlignment="Left" Margin="0,-5,0,5" Stroke="#FFFFFF"
|
||||
Fill="#000000" Data="M 0 0 L 7 5 L 0 10Z">
|
||||
<Path.RenderTransform>
|
||||
<TranslateTransform Y="{Binding ElementName=A,Path=AlphaOffset}" />
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
<Path Grid.Column="4" HorizontalAlignment="Right" Margin="0,-5,0,5"
|
||||
Stroke="#FFFFFF" Fill="#000000" Data="M 0 5 L 7 0 L 7 10 Z">
|
||||
<Path.RenderTransform>
|
||||
<TranslateTransform Y="{Binding ElementName=A,Path=AlphaOffset}" />
|
||||
</Path.RenderTransform>
|
||||
</Path>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
|
||||
<Grid Height="20">
|
||||
|
||||
<!-- Hide when brush type is None -->
|
||||
<Grid.Style>
|
||||
<Style TargetType="Grid">
|
||||
<Style.Triggers>
|
||||
<DataTrigger
|
||||
Binding="{Binding ElementName=listAvailableBrushType, Path=SelectedValue}"
|
||||
Value="None">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Grid.Style>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Rectangle>
|
||||
<Rectangle.Fill>
|
||||
<SolidColorBrush
|
||||
Color="{Binding Color, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
|
||||
<TextBox x:Name="PART_CurrentColor"
|
||||
Text="{Binding Color, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
local:TextBoxBehavior.SelectAllTextOnFocus="True"
|
||||
Grid.Column="2" MinWidth="100">
|
||||
<TextBox.Style>
|
||||
<Style TargetType="TextBox">
|
||||
<Setter Property="BorderBrush"
|
||||
Value="{Binding BorderBrush, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="TextBox">
|
||||
<Border BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="1" Padding="0">
|
||||
<ScrollViewer x:Name="PART_ContentHost" Margin="0" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</TextBox.Style>
|
||||
</TextBox>
|
||||
|
||||
</Grid>
|
||||
|
||||
<Grid Margin="0,5,0,0" Focusable="False">
|
||||
|
||||
<Grid.Style>
|
||||
<Style TargetType="Grid">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger
|
||||
Binding="{Binding ElementName=listAvailableBrushType, Path=SelectedValue}"
|
||||
Value="Linear">
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
</DataTrigger>
|
||||
<DataTrigger
|
||||
Binding="{Binding ElementName=listAvailableBrushType, Path=SelectedValue}"
|
||||
Value="Radial">
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Grid.Style>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition Width="Auto" MinWidth="45" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="0" Focusable="False">
|
||||
|
||||
<!-- Click to add gradient stop -->
|
||||
<local:GradientStopAdder Height="20" Margin="7,0"
|
||||
Focusable="False"
|
||||
IsTabStop="False"
|
||||
FocusVisualStyle="{x:Null}"
|
||||
ColorBox="{Binding RelativeSource={RelativeSource TemplatedParent}}">
|
||||
<local:GradientStopAdder.Background>
|
||||
<LinearGradientBrush
|
||||
GradientStops="{Binding Brush.GradientStops, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
StartPoint="0,.5" EndPoint="1,.5" />
|
||||
</local:GradientStopAdder.Background>
|
||||
<Button.Style>
|
||||
<Style TargetType="Button">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border BorderThickness="0"
|
||||
Background="{TemplateBinding Background}" />
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</local:GradientStopAdder>
|
||||
|
||||
<!-- gradient stops -->
|
||||
<ListBox x:Name="lbGradientStops"
|
||||
ItemsSource="{Binding Path=Gradients, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
SelectedItem="{Binding SelectedGradient,RelativeSource={RelativeSource TemplatedParent}}"
|
||||
Background="{x:Null}" Style="{x:Null}" BorderThickness="0"
|
||||
FocusVisualStyle="{x:Null}" Focusable="False" IsTabStop="False">
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
<Setter Property="IsTabStop" Value="False" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBoxItem">
|
||||
<local:GradientStopSlider x:Name="PART_Slider"
|
||||
BorderBrush="#000000"
|
||||
IsTabStop="False"
|
||||
Style="{StaticResource GradientStopSliderStyle}"
|
||||
Value="{Binding Offset}"
|
||||
Minimum="0" Maximum="1"
|
||||
ColorBox="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ColorBox}}}"
|
||||
SelectedGradient="{Binding}"
|
||||
Margin="0,0,0,2">
|
||||
<local:GradientStopSlider.Background>
|
||||
<SolidColorBrush Color="{Binding Color}" />
|
||||
</local:GradientStopSlider.Background>
|
||||
</local:GradientStopSlider>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="BorderBrush"
|
||||
TargetName="PART_Slider" Value="Orange" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="BorderBrush"
|
||||
TargetName="PART_Slider" Value="Blue" />
|
||||
<Setter Property="Effect" TargetName="PART_Slider">
|
||||
<Setter.Value>
|
||||
<DropShadowEffect ShadowDepth="2"
|
||||
BlurRadius="2"
|
||||
Direction="270" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Grid IsItemsHost="True" />
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
|
||||
</ListBox>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<Button Grid.Column="2"
|
||||
Command="{x:Static local:ColorBox.ReverseGradientStop}"
|
||||
Background="Transparent"
|
||||
BorderBrush="{Binding BorderBrush, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
ToolTip="Reverse gradient stops">
|
||||
<Button.Style>
|
||||
<Style TargetType="Button">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Name="Border"
|
||||
BorderThickness="1"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
Background="{TemplateBinding Background}">
|
||||
<Path x:Name="Icon"
|
||||
Data="F1 M 10.0001,27L 10,16L 29.25,16L 25,12L 31.5,12L 38,18L 31.5,24L 25,24L 29.25,20L 14,20L 14,23.5L 10.0001,27 Z M 38,21L 38,32L 18.75,32L 23,36L 16.5,36L 10,30L 16.5,24L 23,24L 18.75,28L 34,28L 34,24.5L 38,21 Z"
|
||||
StrokeThickness="0" Fill="#000000" Height="16"
|
||||
Width="20" Stretch="Fill" />
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="Icon" Property="Fill">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush
|
||||
Color="{Binding Color, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ColorBox}}}" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="BorderBrush" TargetName="Border">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush
|
||||
Color="{Binding Color, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ColorBox}}}" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
|
||||
</Grid>
|
||||
|
||||
<StackPanel Margin="0,5,0,0">
|
||||
<StackPanel.Style>
|
||||
<Style TargetType="StackPanel">
|
||||
<Style.Triggers>
|
||||
<DataTrigger
|
||||
Binding="{Binding ElementName=listAvailableBrushType, Path=SelectedValue}"
|
||||
Value="None">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</StackPanel.Style>
|
||||
|
||||
<ToggleButton x:Name="PART_AdditionalPropertyOpen"
|
||||
BorderBrush="{Binding BorderBrush, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
ToolTip="Additional Properties"
|
||||
Height="20">
|
||||
<ToggleButton.Style>
|
||||
<Style TargetType="ToggleButton">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<Border x:Name="Border"
|
||||
BorderThickness="1"
|
||||
Background="Transparent"
|
||||
BorderBrush="{TemplateBinding BorderBrush}">
|
||||
<Path x:Name="Icon"
|
||||
Data="M518.000,395.000C509.500,377.166,484.333,306.833,467.000,288C449.666,269.166,405.500,262.000,414,282C422.499,301.999,484.166,408,518.000,408C551.833,408,609,301.999,617.000,282C625.000,262.000,582.500,269.166,566.000,288C549.500,306.833,526.000,377.166,518.000,395.000"
|
||||
Height="12" Width="18"
|
||||
Fill="{TemplateBinding Foreground}"
|
||||
Stretch="Fill"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
RenderTransformOrigin=".5,.5" />
|
||||
</Border>
|
||||
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter TargetName="Icon" Property="RenderTransform">
|
||||
<Setter.Value>
|
||||
<ScaleTransform ScaleY="-1" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="Icon" Property="Fill">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush
|
||||
Color="{Binding Color, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ColorBox}}}" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ToggleButton.Style>
|
||||
</ToggleButton>
|
||||
|
||||
|
||||
<StackPanel Margin="0,5,0,0"
|
||||
Visibility="{Binding ElementName=PART_AdditionalPropertyOpen, Path=IsChecked, Converter={StaticResource BoolToVis}}">
|
||||
|
||||
<!-- Solid brush -->
|
||||
<DockPanel Margin="0,2">
|
||||
<DockPanel.Style>
|
||||
<Style TargetType="DockPanel">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger
|
||||
Binding="{Binding ElementName=listAvailableBrushType, Path=SelectedValue}"
|
||||
Value="Solid">
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DockPanel.Style>
|
||||
|
||||
<TextBlock Text="Opacity" VerticalAlignment="Center" />
|
||||
<Slider Style="{StaticResource OpacitySliderStyle}" Margin="10,0,0,0" />
|
||||
</DockPanel>
|
||||
|
||||
<!-- Linear brush -->
|
||||
<DockPanel>
|
||||
<DockPanel.Style>
|
||||
<Style TargetType="DockPanel">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger
|
||||
Binding="{Binding ElementName=listAvailableBrushType, Path=SelectedValue}"
|
||||
Value="Linear">
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DockPanel.Style>
|
||||
|
||||
<UniformGrid Rows="5" DockPanel.Dock="Left" Margin="0,0,5,0">
|
||||
<TextBlock Text="Start Point" VerticalAlignment="Center" />
|
||||
<TextBlock Text="End Point" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Mapping Mode" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Spread Method" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Opacity" VerticalAlignment="Center" />
|
||||
</UniformGrid>
|
||||
|
||||
<UniformGrid Rows="5" DockPanel.Dock="Right">
|
||||
<UniformGrid Rows="1">
|
||||
<local:DoubleUpDown
|
||||
Value="{Binding StartX, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
<local:DoubleUpDown
|
||||
Value="{Binding StartY, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</UniformGrid>
|
||||
|
||||
<UniformGrid Rows="1">
|
||||
<local:DoubleUpDown
|
||||
Value="{Binding EndX, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
<local:DoubleUpDown
|
||||
Value="{Binding EndY, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</UniformGrid>
|
||||
|
||||
<ComboBox Margin="2"
|
||||
ItemsSource="{Binding MappingModeTypes, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
SelectedItem="{Binding MappingMode, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
|
||||
<ComboBox Margin="2"
|
||||
ItemsSource="{Binding SpreadMethodTypes, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
SelectedItem="{Binding SpreadMethod, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
|
||||
<Slider Style="{StaticResource OpacitySliderStyle}" />
|
||||
</UniformGrid>
|
||||
</DockPanel>
|
||||
|
||||
<!-- Radial brush -->
|
||||
<DockPanel>
|
||||
<DockPanel.Style>
|
||||
<Style TargetType="DockPanel">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger
|
||||
Binding="{Binding ElementName=listAvailableBrushType, Path=SelectedValue}"
|
||||
Value="Radial">
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DockPanel.Style>
|
||||
|
||||
<UniformGrid Rows="7" DockPanel.Dock="Left" Margin="0,0,5,0">
|
||||
<TextBlock Text="Gradient Origin" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Center" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Radius X" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Radius Y" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Mapping Mode" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Spread Method" VerticalAlignment="Center" />
|
||||
<TextBlock Text="Opacity" VerticalAlignment="Center" />
|
||||
</UniformGrid>
|
||||
|
||||
<UniformGrid Rows="7" DockPanel.Dock="Right">
|
||||
<UniformGrid Rows="1">
|
||||
<local:DoubleUpDown
|
||||
Value="{Binding GradientOriginX, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
<local:DoubleUpDown
|
||||
Value="{Binding GradientOriginY, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</UniformGrid>
|
||||
|
||||
<UniformGrid Rows="1">
|
||||
<local:DoubleUpDown
|
||||
Value="{Binding CenterX, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
<local:DoubleUpDown
|
||||
Value="{Binding CenterY, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</UniformGrid>
|
||||
|
||||
<local:DoubleUpDown
|
||||
Value="{Binding RadiusX, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
|
||||
<local:DoubleUpDown
|
||||
Value="{Binding RadiusY, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
|
||||
<ComboBox Margin="2"
|
||||
ItemsSource="{Binding MappingModeTypes, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
SelectedItem="{Binding MappingMode, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
|
||||
<ComboBox Margin="2"
|
||||
ItemsSource="{Binding SpreadMethodTypes, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
SelectedItem="{Binding SpreadMethod, RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
|
||||
<Slider Style="{StaticResource OpacitySliderStyle}" />
|
||||
</UniformGrid>
|
||||
</DockPanel>
|
||||
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
653
Artemis/ColorBox/UpDownBase.cs
Normal file
653
Artemis/ColorBox/UpDownBase.cs
Normal file
@ -0,0 +1,653 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Extended WPF Toolkit
|
||||
|
||||
Copyright (C) 2007-2013 Xceed Software Inc.
|
||||
|
||||
This program is provided to you under the terms of the Microsoft Public
|
||||
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
|
||||
|
||||
For more features, controls, and fast professional support,
|
||||
pick up the Plus Edition at http://xceed.com/wpf_toolkit
|
||||
|
||||
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
|
||||
|
||||
***********************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace ColorBox
|
||||
{
|
||||
[TemplatePart(Name = PartTextBox, Type = typeof(TextBox))]
|
||||
[TemplatePart(Name = PartSpinner, Type = typeof(Spinner))]
|
||||
public abstract class UpDownBase : Control, IValidateInput
|
||||
{
|
||||
#region Event Handlers
|
||||
|
||||
private void OnSpinnerSpin(object sender, SpinEventArgs e)
|
||||
{
|
||||
if (AllowSpin && !IsReadOnly)
|
||||
OnSpin(e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Members
|
||||
|
||||
internal const string PartTextBox = "PART_TextBox";
|
||||
internal const string PartSpinner = "PART_Spinner";
|
||||
private bool _isSyncingTextAndValueProperties;
|
||||
private bool _isTextChangedFromUi;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
internal Spinner Spinner { get; private set; }
|
||||
|
||||
internal TextBox TextBox { get; private set; }
|
||||
|
||||
#region CultureInfo
|
||||
|
||||
public static readonly DependencyProperty CultureInfoProperty = DependencyProperty.Register("CultureInfo",
|
||||
typeof(CultureInfo), typeof(UpDownBase),
|
||||
new UIPropertyMetadata(CultureInfo.CurrentCulture, OnCultureInfoChanged));
|
||||
|
||||
public CultureInfo CultureInfo
|
||||
{
|
||||
get { return (CultureInfo) GetValue(CultureInfoProperty); }
|
||||
set { SetValue(CultureInfoProperty, value); }
|
||||
}
|
||||
|
||||
private static void OnCultureInfoChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var inputBase = o as UpDownBase;
|
||||
if (inputBase != null)
|
||||
inputBase.OnCultureInfoChanged((CultureInfo) e.OldValue, (CultureInfo) e.NewValue);
|
||||
}
|
||||
|
||||
#endregion //CultureInfo
|
||||
|
||||
#region IsReadOnly
|
||||
|
||||
public static readonly DependencyProperty IsReadOnlyProperty = DependencyProperty.Register("IsReadOnly",
|
||||
typeof(bool), typeof(UpDownBase), new UIPropertyMetadata(false, OnReadOnlyChanged));
|
||||
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get { return (bool) GetValue(IsReadOnlyProperty); }
|
||||
set { SetValue(IsReadOnlyProperty, value); }
|
||||
}
|
||||
|
||||
private static void OnReadOnlyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var inputBase = o as UpDownBase;
|
||||
if (inputBase != null)
|
||||
inputBase.OnReadOnlyChanged((bool) e.OldValue, (bool) e.NewValue);
|
||||
}
|
||||
|
||||
#endregion //IsReadOnly
|
||||
|
||||
#region Text
|
||||
|
||||
public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string),
|
||||
typeof(UpDownBase),
|
||||
new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
||||
OnTextChanged, null, false, UpdateSourceTrigger.LostFocus));
|
||||
|
||||
public string Text
|
||||
{
|
||||
get { return (string) GetValue(TextProperty); }
|
||||
set { SetValue(TextProperty, value); }
|
||||
}
|
||||
|
||||
private static void OnTextChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var inputBase = o as UpDownBase;
|
||||
if (inputBase != null)
|
||||
inputBase.OnTextChanged((string) e.OldValue, (string) e.NewValue);
|
||||
}
|
||||
|
||||
#endregion //Text
|
||||
|
||||
#region FormatString
|
||||
|
||||
public static readonly DependencyProperty FormatStringProperty = DependencyProperty.Register("FormatString",
|
||||
typeof(string), typeof(UpDownBase), new UIPropertyMetadata(string.Empty, OnFormatStringChanged));
|
||||
|
||||
public string FormatString
|
||||
{
|
||||
get { return (string) GetValue(FormatStringProperty); }
|
||||
set { SetValue(FormatStringProperty, value); }
|
||||
}
|
||||
|
||||
private static void OnFormatStringChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var numericUpDown = o as UpDownBase;
|
||||
if (numericUpDown != null)
|
||||
numericUpDown.OnFormatStringChanged((string) e.OldValue, (string) e.NewValue);
|
||||
}
|
||||
|
||||
protected virtual void OnFormatStringChanged(string oldValue, string newValue)
|
||||
{
|
||||
if (IsInitialized)
|
||||
SyncTextAndValue(false, null);
|
||||
}
|
||||
|
||||
#endregion //FormatString
|
||||
|
||||
#region Increment
|
||||
|
||||
public static readonly DependencyProperty IncrementProperty = DependencyProperty.Register("Increment",
|
||||
typeof(double?), typeof(UpDownBase),
|
||||
new PropertyMetadata(default(double), OnIncrementChanged, OnCoerceIncrement));
|
||||
|
||||
public double? Increment
|
||||
{
|
||||
get { return (double?) GetValue(IncrementProperty); }
|
||||
set { SetValue(IncrementProperty, value); }
|
||||
}
|
||||
|
||||
private static void OnIncrementChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var numericUpDown = o as UpDownBase;
|
||||
if (numericUpDown != null)
|
||||
numericUpDown.OnIncrementChanged((double) e.OldValue, (double) e.NewValue);
|
||||
}
|
||||
|
||||
protected virtual void OnIncrementChanged(double oldValue, double newValue)
|
||||
{
|
||||
if (IsInitialized)
|
||||
SetValidSpinDirection();
|
||||
}
|
||||
|
||||
private static object OnCoerceIncrement(DependencyObject d, object baseValue)
|
||||
{
|
||||
var numericUpDown = d as UpDownBase;
|
||||
if (numericUpDown != null)
|
||||
return numericUpDown.OnCoerceIncrement((double) baseValue);
|
||||
|
||||
return baseValue;
|
||||
}
|
||||
|
||||
protected virtual double? OnCoerceIncrement(double? baseValue)
|
||||
{
|
||||
return baseValue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Maximum
|
||||
|
||||
public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register("Maximum",
|
||||
typeof(double), typeof(UpDownBase),
|
||||
new UIPropertyMetadata(default(double), OnMaximumChanged, OnCoerceMaximum));
|
||||
|
||||
public double Maximum
|
||||
{
|
||||
get { return (double) GetValue(MaximumProperty); }
|
||||
set { SetValue(MaximumProperty, value); }
|
||||
}
|
||||
|
||||
private static void OnMaximumChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var numericUpDown = o as UpDownBase;
|
||||
if (numericUpDown != null)
|
||||
numericUpDown.OnMaximumChanged((double) e.OldValue, (double) e.NewValue);
|
||||
}
|
||||
|
||||
protected virtual void OnMaximumChanged(double oldValue, double newValue)
|
||||
{
|
||||
if (IsInitialized)
|
||||
SetValidSpinDirection();
|
||||
}
|
||||
|
||||
private static object OnCoerceMaximum(DependencyObject d, object baseValue)
|
||||
{
|
||||
var numericUpDown = d as UpDownBase;
|
||||
if (numericUpDown != null)
|
||||
return numericUpDown.OnCoerceMaximum((double) baseValue);
|
||||
|
||||
return baseValue;
|
||||
}
|
||||
|
||||
protected virtual double OnCoerceMaximum(double baseValue)
|
||||
{
|
||||
return baseValue;
|
||||
}
|
||||
|
||||
#endregion //Maximum
|
||||
|
||||
#region Minimum
|
||||
|
||||
public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register("Minimum",
|
||||
typeof(double), typeof(UpDownBase),
|
||||
new UIPropertyMetadata(default(double), OnMinimumChanged, OnCoerceMinimum));
|
||||
|
||||
public double Minimum
|
||||
{
|
||||
get { return (double) GetValue(MinimumProperty); }
|
||||
set { SetValue(MinimumProperty, value); }
|
||||
}
|
||||
|
||||
private static void OnMinimumChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var numericUpDown = o as UpDownBase;
|
||||
if (numericUpDown != null)
|
||||
numericUpDown.OnMinimumChanged((double) e.OldValue, (double) e.NewValue);
|
||||
}
|
||||
|
||||
protected virtual void OnMinimumChanged(double oldValue, double newValue)
|
||||
{
|
||||
if (IsInitialized)
|
||||
SetValidSpinDirection();
|
||||
}
|
||||
|
||||
private static object OnCoerceMinimum(DependencyObject d, object baseValue)
|
||||
{
|
||||
var numericUpDown = d as UpDownBase;
|
||||
if (numericUpDown != null)
|
||||
return numericUpDown.OnCoerceMinimum((double) baseValue);
|
||||
|
||||
return baseValue;
|
||||
}
|
||||
|
||||
protected virtual double? OnCoerceMinimum(double baseValue)
|
||||
{
|
||||
return baseValue;
|
||||
}
|
||||
|
||||
#endregion //Minimum
|
||||
|
||||
#region AllowSpin
|
||||
|
||||
public static readonly DependencyProperty AllowSpinProperty = DependencyProperty.Register("AllowSpin",
|
||||
typeof(bool), typeof(UpDownBase), new UIPropertyMetadata(true));
|
||||
|
||||
public bool AllowSpin
|
||||
{
|
||||
get { return (bool) GetValue(AllowSpinProperty); }
|
||||
set { SetValue(AllowSpinProperty, value); }
|
||||
}
|
||||
|
||||
#endregion //AllowSpin
|
||||
|
||||
#region DefaultValue
|
||||
|
||||
public static readonly DependencyProperty DefaultValueProperty = DependencyProperty.Register("DefaultValue",
|
||||
typeof(double?), typeof(UpDownBase), new UIPropertyMetadata(default(double), OnDefaultValueChanged));
|
||||
|
||||
public double? DefaultValue
|
||||
{
|
||||
get { return (double?) GetValue(DefaultValueProperty); }
|
||||
set { SetValue(DefaultValueProperty, value); }
|
||||
}
|
||||
|
||||
private static void OnDefaultValueChanged(DependencyObject source, DependencyPropertyChangedEventArgs args)
|
||||
{
|
||||
((UpDownBase) source).OnDefaultValueChanged((double) args.OldValue, (double) args.NewValue);
|
||||
}
|
||||
|
||||
private void OnDefaultValueChanged(double oldValue, double newValue)
|
||||
{
|
||||
if (IsInitialized && string.IsNullOrEmpty(Text))
|
||||
SyncTextAndValue(true, Text);
|
||||
}
|
||||
|
||||
#endregion //DefaultValue
|
||||
|
||||
#region AllowInputSpecialValues
|
||||
|
||||
private static readonly DependencyProperty AllowInputSpecialValuesProperty =
|
||||
DependencyProperty.Register("AllowInputSpecialValues", typeof(AllowedSpecialValues), typeof(UpDownBase),
|
||||
new UIPropertyMetadata(AllowedSpecialValues.None));
|
||||
|
||||
private AllowedSpecialValues AllowInputSpecialValues
|
||||
{
|
||||
get { return (AllowedSpecialValues) GetValue(AllowInputSpecialValuesProperty); }
|
||||
set { SetValue(AllowInputSpecialValuesProperty, value); }
|
||||
}
|
||||
|
||||
#endregion //AllowInputSpecialValues
|
||||
|
||||
#region ParsingNumberStyle
|
||||
|
||||
public static readonly DependencyProperty ParsingNumberStyleProperty =
|
||||
DependencyProperty.Register("ParsingNumberStyle", typeof(NumberStyles), typeof(UpDownBase),
|
||||
new UIPropertyMetadata(NumberStyles.Any));
|
||||
|
||||
public NumberStyles ParsingNumberStyle
|
||||
{
|
||||
get { return (NumberStyles) GetValue(ParsingNumberStyleProperty); }
|
||||
set { SetValue(ParsingNumberStyleProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Value
|
||||
|
||||
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(double?),
|
||||
typeof(UpDownBase),
|
||||
new FrameworkPropertyMetadata(default(double), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
||||
OnValueChanged, OnCoerceValue, false, UpdateSourceTrigger.PropertyChanged));
|
||||
|
||||
public double? Value
|
||||
{
|
||||
get { return (double?) GetValue(ValueProperty); }
|
||||
set { SetValue(ValueProperty, value); }
|
||||
}
|
||||
|
||||
private static object OnCoerceValue(DependencyObject o, object basevalue)
|
||||
{
|
||||
return ((UpDownBase) o).OnCoerceValue(basevalue);
|
||||
}
|
||||
|
||||
protected virtual object OnCoerceValue(object newValue)
|
||||
{
|
||||
return newValue;
|
||||
}
|
||||
|
||||
private static void OnValueChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var upDownBase = o as UpDownBase;
|
||||
if (upDownBase != null)
|
||||
upDownBase.OnValueChanged((double) e.OldValue, (double) e.NewValue);
|
||||
}
|
||||
|
||||
protected virtual void OnValueChanged(double oldValue, double newValue)
|
||||
{
|
||||
if (IsInitialized)
|
||||
SyncTextAndValue(false, null);
|
||||
|
||||
SetValidSpinDirection();
|
||||
|
||||
var args = new RoutedPropertyChangedEventArgs<object>(oldValue, newValue);
|
||||
args.RoutedEvent = ValueChangedEvent;
|
||||
RaiseEvent(args);
|
||||
}
|
||||
|
||||
#endregion //Value
|
||||
|
||||
#endregion //Properties
|
||||
|
||||
#region Base Class Overrides
|
||||
|
||||
protected override void OnAccessKey(AccessKeyEventArgs e)
|
||||
{
|
||||
if (TextBox != null)
|
||||
TextBox.Focus();
|
||||
|
||||
base.OnAccessKey(e);
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
TextBox = GetTemplateChild(PartTextBox) as TextBox;
|
||||
if (TextBox != null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Text))
|
||||
TextBox.Text = "0.0";
|
||||
else
|
||||
TextBox.Text = Text;
|
||||
|
||||
TextBox.LostFocus += TextBox_LostFocus;
|
||||
TextBox.TextChanged += TextBox_TextChanged;
|
||||
}
|
||||
|
||||
if (Spinner != null)
|
||||
Spinner.Spin -= OnSpinnerSpin;
|
||||
|
||||
Spinner = GetTemplateChild(PartSpinner) as Spinner;
|
||||
|
||||
if (Spinner != null)
|
||||
Spinner.Spin += OnSpinnerSpin;
|
||||
|
||||
SetValidSpinDirection();
|
||||
}
|
||||
|
||||
protected override void OnGotFocus(RoutedEventArgs e)
|
||||
{
|
||||
if (TextBox != null)
|
||||
TextBox.Focus();
|
||||
}
|
||||
|
||||
protected override void OnPreviewKeyDown(KeyEventArgs e)
|
||||
{
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.Up:
|
||||
{
|
||||
if (AllowSpin && !IsReadOnly)
|
||||
DoIncrement();
|
||||
e.Handled = true;
|
||||
break;
|
||||
}
|
||||
case Key.Down:
|
||||
{
|
||||
if (AllowSpin && !IsReadOnly)
|
||||
DoDecrement();
|
||||
e.Handled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.Enter:
|
||||
{
|
||||
var commitSuccess = CommitInput();
|
||||
e.Handled = !commitSuccess;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseWheel(MouseWheelEventArgs e)
|
||||
{
|
||||
base.OnMouseWheel(e);
|
||||
|
||||
if (!e.Handled && AllowSpin && !IsReadOnly && TextBox.IsFocused)
|
||||
{
|
||||
if (e.Delta < 0)
|
||||
DoDecrement();
|
||||
else if (0 < e.Delta)
|
||||
DoIncrement();
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnTextChanged(string oldValue, string newValue)
|
||||
{
|
||||
if (IsInitialized)
|
||||
SyncTextAndValue(true, Text);
|
||||
}
|
||||
|
||||
protected void OnCultureInfoChanged(CultureInfo oldValue, CultureInfo newValue)
|
||||
{
|
||||
if (IsInitialized)
|
||||
SyncTextAndValue(false, null);
|
||||
}
|
||||
|
||||
protected void OnReadOnlyChanged(bool oldValue, bool newValue)
|
||||
{
|
||||
SetValidSpinDirection();
|
||||
}
|
||||
|
||||
public void OnSpin(SpinEventArgs e)
|
||||
{
|
||||
if (e == null)
|
||||
throw new ArgumentNullException("e");
|
||||
|
||||
if (e.Direction == SpinDirection.Increase)
|
||||
DoIncrement();
|
||||
else
|
||||
DoDecrement();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
public event InputValidationErrorEventHandler InputValidationError;
|
||||
|
||||
#region ValueChanged Event
|
||||
|
||||
public static readonly RoutedEvent ValueChangedEvent = EventManager.RegisterRoutedEvent("ValueChanged",
|
||||
RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler<object>), typeof(UpDownBase));
|
||||
|
||||
public event RoutedPropertyChangedEventHandler<object> ValueChanged
|
||||
{
|
||||
add { AddHandler(ValueChangedEvent, value); }
|
||||
remove { RemoveHandler(ValueChangedEvent, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion //Events
|
||||
|
||||
#region Methods
|
||||
|
||||
private void DoDecrement()
|
||||
{
|
||||
if (Spinner == null)
|
||||
OnDecrement();
|
||||
}
|
||||
|
||||
private void DoIncrement()
|
||||
{
|
||||
if (Spinner == null)
|
||||
OnIncrement();
|
||||
}
|
||||
|
||||
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_isTextChangedFromUi = true;
|
||||
Text = ((TextBox) sender).Text;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isTextChangedFromUi = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void TextBox_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CommitInput();
|
||||
}
|
||||
|
||||
private void RaiseInputValidationError(Exception e)
|
||||
{
|
||||
if (InputValidationError != null)
|
||||
{
|
||||
var args = new InputValidationErrorEventArgs(e);
|
||||
InputValidationError(this, args);
|
||||
if (args.ThrowException)
|
||||
throw args.Exception;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CommitInput()
|
||||
{
|
||||
return SyncTextAndValue(true, Text);
|
||||
}
|
||||
|
||||
protected bool SyncTextAndValue(bool updateValueFromText, string text)
|
||||
{
|
||||
if (_isSyncingTextAndValueProperties)
|
||||
return true;
|
||||
|
||||
_isSyncingTextAndValueProperties = true;
|
||||
var parsedTextIsValid = true;
|
||||
try
|
||||
{
|
||||
if (updateValueFromText)
|
||||
if (string.IsNullOrEmpty(text))
|
||||
Value = DefaultValue;
|
||||
else
|
||||
try
|
||||
{
|
||||
Value = ConvertTextToValue(text);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
parsedTextIsValid = false;
|
||||
|
||||
// From the UI, just allow any input.
|
||||
if (!_isTextChangedFromUi)
|
||||
RaiseInputValidationError(e);
|
||||
}
|
||||
|
||||
// Do not touch the ongoing text input from user.
|
||||
if (!_isTextChangedFromUi)
|
||||
{
|
||||
// Don't replace the empty Text with the non-empty representation of DefaultValue.
|
||||
var shouldKeepEmpty = string.IsNullOrEmpty(Text) && Equals(Value, DefaultValue);
|
||||
if (!shouldKeepEmpty)
|
||||
Text = ConvertValueToText();
|
||||
|
||||
// Sync Text and textBox
|
||||
if (TextBox != null)
|
||||
if (string.IsNullOrEmpty(Text))
|
||||
TextBox.Text = "0.0";
|
||||
else
|
||||
TextBox.Text = Text;
|
||||
}
|
||||
|
||||
if (_isTextChangedFromUi && !parsedTextIsValid)
|
||||
{
|
||||
//// Text input was made from the user and the text
|
||||
//// repesents an invalid value. Disable the spinner
|
||||
//// in this case.
|
||||
if (Spinner != null)
|
||||
Spinner.ValidSpinDirection = ValidSpinDirections.None;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetValidSpinDirection();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isSyncingTextAndValueProperties = false;
|
||||
}
|
||||
return parsedTextIsValid;
|
||||
}
|
||||
|
||||
protected static decimal ParsePercent(string text, IFormatProvider cultureInfo)
|
||||
{
|
||||
var info = NumberFormatInfo.GetInstance(cultureInfo);
|
||||
|
||||
text = text.Replace(info.PercentSymbol, null);
|
||||
|
||||
var result = decimal.Parse(text, NumberStyles.Any, info);
|
||||
result = result/100;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Abstract
|
||||
|
||||
protected abstract double? ConvertTextToValue(string text);
|
||||
protected abstract string ConvertValueToText();
|
||||
protected abstract void OnIncrement();
|
||||
protected abstract void OnDecrement();
|
||||
protected abstract void SetValidSpinDirection();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
209
Artemis/ColorBox/Utils/ColorHelper.cs
Normal file
209
Artemis/ColorBox/Utils/ColorHelper.cs
Normal file
@ -0,0 +1,209 @@
|
||||
/***************** NCore Softwares Pvt. Ltd., India **************************
|
||||
|
||||
ColorBox
|
||||
|
||||
Copyright (C) 2013 NCore Softwares Pvt. Ltd.
|
||||
|
||||
This program is provided to you under the terms of the Microsoft Public
|
||||
License (Ms-PL) as published at http://colorbox.codeplex.com/license
|
||||
|
||||
***********************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace ColorBox
|
||||
{
|
||||
internal static class ColorHelper
|
||||
{
|
||||
private static readonly char[] HexArray =
|
||||
{
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D',
|
||||
'E', 'F'
|
||||
};
|
||||
|
||||
public static string MakeValidColorString(string S)
|
||||
{
|
||||
var s = S;
|
||||
|
||||
for (var i = 0; i < s.Length; i++)
|
||||
{
|
||||
var c = s[i];
|
||||
|
||||
if (!((c >= 'a') && (c <= 'f')) && !((c >= 'A') && (c <= 'F')) && !((c >= '0') && (c <= '9')))
|
||||
{
|
||||
s = s.Remove(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
if (s.Length > 8) s = s.Substring(0, 8);
|
||||
|
||||
while ((s.Length <= 8) && (s.Length != 3) && (s.Length != 4) && (s.Length != 6) && (s.Length != 8))
|
||||
s = s + "0";
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
public static Color ColorFromString(string S)
|
||||
{
|
||||
var s = MakeValidColorString(S);
|
||||
|
||||
byte a = 255;
|
||||
byte r = 0;
|
||||
byte g = 0;
|
||||
byte b = 0;
|
||||
|
||||
if (s.Length == 3)
|
||||
{
|
||||
r = byte.Parse(s.Substring(0, 1) + s.Substring(0, 1), NumberStyles.HexNumber);
|
||||
g = byte.Parse(s.Substring(1, 1) + s.Substring(1, 1), NumberStyles.HexNumber);
|
||||
b = byte.Parse(s.Substring(2, 1) + s.Substring(2, 1), NumberStyles.HexNumber);
|
||||
}
|
||||
|
||||
if (s.Length == 4)
|
||||
{
|
||||
a = byte.Parse(s.Substring(0, 1) + s.Substring(0, 1), NumberStyles.HexNumber);
|
||||
r = byte.Parse(s.Substring(1, 1) + s.Substring(1, 1), NumberStyles.HexNumber);
|
||||
g = byte.Parse(s.Substring(2, 1) + s.Substring(2, 1), NumberStyles.HexNumber);
|
||||
b = byte.Parse(s.Substring(3, 1) + s.Substring(3, 1), NumberStyles.HexNumber);
|
||||
}
|
||||
|
||||
if (s.Length == 6)
|
||||
{
|
||||
r = byte.Parse(s.Substring(0, 2), NumberStyles.HexNumber);
|
||||
g = byte.Parse(s.Substring(1, 2), NumberStyles.HexNumber);
|
||||
b = byte.Parse(s.Substring(2, 2), NumberStyles.HexNumber);
|
||||
}
|
||||
|
||||
if (s.Length == 8)
|
||||
{
|
||||
a = byte.Parse(s.Substring(0, 2), NumberStyles.HexNumber);
|
||||
r = byte.Parse(s.Substring(1, 2), NumberStyles.HexNumber);
|
||||
g = byte.Parse(s.Substring(2, 2), NumberStyles.HexNumber);
|
||||
b = byte.Parse(s.Substring(3, 2), NumberStyles.HexNumber);
|
||||
}
|
||||
|
||||
return Color.FromArgb(a, r, g, b);
|
||||
}
|
||||
|
||||
public static string StringFromColor(Color c)
|
||||
{
|
||||
var bytes = new byte[4] {c.A, c.R, c.G, c.B};
|
||||
|
||||
var chars = new char[bytes.Length*2];
|
||||
|
||||
for (var i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
int b = bytes[i];
|
||||
chars[i*2] = HexArray[b >> 4];
|
||||
chars[i*2 + 1] = HexArray[b & 0xF];
|
||||
}
|
||||
|
||||
return new string(chars);
|
||||
}
|
||||
|
||||
public static Color ColorFromHsb(double H, double S, double b)
|
||||
{
|
||||
double red = 0.0, green = 0.0, blue = 0.0;
|
||||
|
||||
if (S == 0.0)
|
||||
{
|
||||
red = green = blue = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
var h = H*360;
|
||||
while (h >= 360.0)
|
||||
h -= 360.0;
|
||||
|
||||
h = h/60.0;
|
||||
var i = (int) h;
|
||||
|
||||
var f = h - i;
|
||||
var r = b*(1.0 - S);
|
||||
var s = b*(1.0 - S*f);
|
||||
var t = b*(1.0 - S*(1.0 - f));
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
red = b;
|
||||
green = t;
|
||||
blue = r;
|
||||
break;
|
||||
case 1:
|
||||
red = s;
|
||||
green = b;
|
||||
blue = r;
|
||||
break;
|
||||
case 2:
|
||||
red = r;
|
||||
green = b;
|
||||
blue = t;
|
||||
break;
|
||||
case 3:
|
||||
red = r;
|
||||
green = s;
|
||||
blue = b;
|
||||
break;
|
||||
case 4:
|
||||
red = t;
|
||||
green = r;
|
||||
blue = b;
|
||||
break;
|
||||
case 5:
|
||||
red = b;
|
||||
green = r;
|
||||
blue = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
byte iRed = (byte) (red*255.0), iGreen = (byte) (green*255.0), iBlue = (byte) (blue*255.0);
|
||||
return Color.FromRgb(iRed, iGreen, iBlue);
|
||||
}
|
||||
|
||||
public static void HsbFromColor(Color c, ref double h, ref double s, ref double b)
|
||||
{
|
||||
var red = c.R;
|
||||
var green = c.G;
|
||||
var blue = c.B;
|
||||
|
||||
int imax = red, imin = red;
|
||||
|
||||
if (green > imax) imax = green;
|
||||
else if (green < imin) imin = green;
|
||||
if (blue > imax) imax = blue;
|
||||
else if (blue < imin) imin = blue;
|
||||
double max = imax/255.0, min = imin/255.0;
|
||||
|
||||
var value = max;
|
||||
var saturation = max > 0 ? (max - min)/max : 0.0;
|
||||
double hue = 0;
|
||||
|
||||
if (imax > imin)
|
||||
{
|
||||
var f = 1.0/((max - min)*255.0);
|
||||
hue = imax == red
|
||||
? 0.0 + f*(green - blue)
|
||||
: imax == green ? 2.0 + f*(blue - red) : 4.0 + f*(red - green);
|
||||
hue = hue*60.0;
|
||||
if (hue < 0.0)
|
||||
hue += 360.0;
|
||||
}
|
||||
|
||||
h = hue/360;
|
||||
s = saturation;
|
||||
b = value;
|
||||
}
|
||||
|
||||
public static Color ColorFromAhsb(double a, double h, double s, double b)
|
||||
{
|
||||
var r = ColorFromHsb(h, s, b);
|
||||
r.A = (byte) Math.Round(a*255);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
}
|
||||
41
Artemis/ColorBox/Utils/InputValidationErrorEventArgs .cs
Normal file
41
Artemis/ColorBox/Utils/InputValidationErrorEventArgs .cs
Normal file
@ -0,0 +1,41 @@
|
||||
/*************************************************************************************
|
||||
|
||||
Extended WPF Toolkit
|
||||
|
||||
Copyright (C) 2007-2013 Xceed Software Inc.
|
||||
|
||||
This program is provided to you under the terms of the Microsoft Public
|
||||
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license
|
||||
|
||||
For more features, controls, and fast professional support,
|
||||
pick up the Plus Edition at http://xceed.com/wpf_toolkit
|
||||
|
||||
Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids
|
||||
|
||||
***********************************************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace ColorBox
|
||||
{
|
||||
public delegate void InputValidationErrorEventHandler(object sender, InputValidationErrorEventArgs e);
|
||||
|
||||
public class InputValidationErrorEventArgs : EventArgs
|
||||
{
|
||||
public InputValidationErrorEventArgs(Exception e)
|
||||
{
|
||||
Exception = e;
|
||||
}
|
||||
|
||||
|
||||
public Exception Exception { get; private set; }
|
||||
|
||||
public bool ThrowException { get; set; }
|
||||
}
|
||||
|
||||
internal interface IValidateInput
|
||||
{
|
||||
event InputValidationErrorEventHandler InputValidationError;
|
||||
bool CommitInput();
|
||||
}
|
||||
}
|
||||
61
Artemis/ColorBox/Utils/TextBoxBehavior.cs
Normal file
61
Artemis/ColorBox/Utils/TextBoxBehavior.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace ColorBox
|
||||
{
|
||||
public class TextBoxBehavior
|
||||
{
|
||||
public static readonly DependencyProperty SelectAllTextOnFocusProperty =
|
||||
DependencyProperty.RegisterAttached(
|
||||
"SelectAllTextOnFocus",
|
||||
typeof(bool),
|
||||
typeof(TextBoxBehavior),
|
||||
new UIPropertyMetadata(false, OnSelectAllTextOnFocusChanged));
|
||||
|
||||
public static bool GetSelectAllTextOnFocus(TextBox textBox)
|
||||
{
|
||||
return (bool) textBox.GetValue(SelectAllTextOnFocusProperty);
|
||||
}
|
||||
|
||||
public static void SetSelectAllTextOnFocus(TextBox textBox, bool value)
|
||||
{
|
||||
textBox.SetValue(SelectAllTextOnFocusProperty, value);
|
||||
}
|
||||
|
||||
private static void OnSelectAllTextOnFocusChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var textBox = d as TextBox;
|
||||
if (textBox == null) return;
|
||||
|
||||
if (e.NewValue is bool == false) return;
|
||||
|
||||
if ((bool) e.NewValue)
|
||||
{
|
||||
textBox.GotFocus += SelectAll;
|
||||
textBox.PreviewMouseDown += IgnoreMouseButton;
|
||||
}
|
||||
else
|
||||
{
|
||||
textBox.GotFocus -= SelectAll;
|
||||
textBox.PreviewMouseDown -= IgnoreMouseButton;
|
||||
}
|
||||
}
|
||||
|
||||
private static void SelectAll(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var textBox = e.OriginalSource as TextBox;
|
||||
if (textBox == null) return;
|
||||
textBox.SelectAll();
|
||||
}
|
||||
|
||||
private static void IgnoreMouseButton(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var textBox = sender as TextBox;
|
||||
if ((textBox == null) || textBox.IsKeyboardFocusWithin) return;
|
||||
|
||||
e.Handled = true;
|
||||
textBox.Focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user