Fixed device rotation/scaling in UI

This commit is contained in:
Robert committed 2019-11-22 17:30:07 +01:00
1 parent 1935b72199
commit 2287ab3071
14 files changed
+130 -108

No files matched your search

+2 -5
View File
@@ -218,16 +218,13 @@
<ItemGroup>
<Folder Include="ProfileElements\Interfaces\" />
</ItemGroup>
<ItemGroup>
<Resource Include="FodyWeavers.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.6.0.5\build\Fody.targets" Condition="Exists('..\packages\Fody.6.0.5\build\Fody.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\PropertyChanged.Fody.3.1.3\build\PropertyChanged.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\PropertyChanged.Fody.3.1.3\build\PropertyChanged.Fody.props'))" />
<Error Condition="!Exists('..\packages\Fody.6.0.5\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.0.5\build\Fody.targets'))" />
<Error Condition="!Exists('..\packages\PropertyChanged.Fody.3.1.3\build\PropertyChanged.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\PropertyChanged.Fody.3.1.3\build\PropertyChanged.Fody.props'))" />
</Target>
<Import Project="..\packages\Fody.6.0.5\build\Fody.targets" Condition="Exists('..\packages\Fody.6.0.5\build\Fody.targets')" />
</Project>
+9 -9
View File
@@ -1,7 +1,5 @@
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing.Drawing2D;
using System.Linq;
using Artemis.Core.Extensions;
@@ -24,6 +22,7 @@ namespace Artemis.Core.Models.Surface
Leds = rgbDevice.Select(l => new DeviceLed(l, this)).ToList().AsReadOnly();
Rotation = 0;
Scale = 1;
ZIndex = 1;
ApplyToEntity();
@@ -42,10 +41,10 @@ namespace Artemis.Core.Models.Surface
public Rectangle RenderRectangle { get; private set; }
public GraphicsPath RenderPath { get; private set; }
public IRGBDevice RgbDevice { get; private set; }
public IRGBDevice RgbDevice { get; }
public Plugin Plugin { get; }
public Surface Surface { get; private set; }
public DeviceEntity DeviceEntity { get; private set; }
public Surface Surface { get; }
public DeviceEntity DeviceEntity { get; }
public ReadOnlyCollection<DeviceLed> Leds { get; set; }
public double X
@@ -77,7 +76,7 @@ namespace Artemis.Core.Models.Surface
get => DeviceEntity.ZIndex;
set => DeviceEntity.ZIndex = value;
}
internal void ApplyToEntity()
{
// Other properties are computed
@@ -99,8 +98,8 @@ namespace Artemis.Core.Models.Surface
RenderRectangle = new Rectangle(
(int) Math.Round(RgbDevice.Location.X * Surface.Scale, MidpointRounding.AwayFromZero),
(int) Math.Round(RgbDevice.Location.Y * Surface.Scale, MidpointRounding.AwayFromZero),
(int) Math.Round(RgbDevice.Size.Width * Surface.Scale, MidpointRounding.AwayFromZero),
(int) Math.Round(RgbDevice.Size.Height * Surface.Scale, MidpointRounding.AwayFromZero)
(int) Math.Round(RgbDevice.DeviceRectangle.Size.Width * Surface.Scale, MidpointRounding.AwayFromZero),
(int) Math.Round(RgbDevice.DeviceRectangle.Size.Height * Surface.Scale, MidpointRounding.AwayFromZero)
);
if (!Leds.Any())
@@ -114,13 +113,14 @@ namespace Artemis.Core.Models.Surface
path.FillMode = FillMode.Winding;
RenderPath = path;
}
public override string ToString()
{
return $"[{RgbDevice.DeviceInfo.DeviceType}] {RgbDevice.DeviceInfo.DeviceName} - {X}.{Y}.{ZIndex}";
}
public event EventHandler DeviceUpdated;
protected virtual void OnDeviceUpdated()
{
DeviceUpdated?.Invoke(this, EventArgs.Empty);