mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Fixed device rotation/scaling in UI
This commit is contained in:
parent
1935b72199
commit
2287ab3071
@ -218,16 +218,13 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="ProfileElements\Interfaces\" />
|
<Folder Include="ProfileElements\Interfaces\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Resource Include="FodyWeavers.xml" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<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">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
<PropertyGroup>
|
<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>
|
<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>
|
</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\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>
|
</Target>
|
||||||
<Import Project="..\packages\Fody.6.0.5\build\Fody.targets" Condition="Exists('..\packages\Fody.6.0.5\build\Fody.targets')" />
|
|
||||||
</Project>
|
</Project>
|
||||||
@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Artemis.Core.Extensions;
|
using Artemis.Core.Extensions;
|
||||||
@ -24,6 +22,7 @@ namespace Artemis.Core.Models.Surface
|
|||||||
Leds = rgbDevice.Select(l => new DeviceLed(l, this)).ToList().AsReadOnly();
|
Leds = rgbDevice.Select(l => new DeviceLed(l, this)).ToList().AsReadOnly();
|
||||||
|
|
||||||
Rotation = 0;
|
Rotation = 0;
|
||||||
|
Scale = 1;
|
||||||
ZIndex = 1;
|
ZIndex = 1;
|
||||||
|
|
||||||
ApplyToEntity();
|
ApplyToEntity();
|
||||||
@ -42,10 +41,10 @@ namespace Artemis.Core.Models.Surface
|
|||||||
public Rectangle RenderRectangle { get; private set; }
|
public Rectangle RenderRectangle { get; private set; }
|
||||||
public GraphicsPath RenderPath { get; private set; }
|
public GraphicsPath RenderPath { get; private set; }
|
||||||
|
|
||||||
public IRGBDevice RgbDevice { get; private set; }
|
public IRGBDevice RgbDevice { get; }
|
||||||
public Plugin Plugin { get; }
|
public Plugin Plugin { get; }
|
||||||
public Surface Surface { get; private set; }
|
public Surface Surface { get; }
|
||||||
public DeviceEntity DeviceEntity { get; private set; }
|
public DeviceEntity DeviceEntity { get; }
|
||||||
public ReadOnlyCollection<DeviceLed> Leds { get; set; }
|
public ReadOnlyCollection<DeviceLed> Leds { get; set; }
|
||||||
|
|
||||||
public double X
|
public double X
|
||||||
@ -99,8 +98,8 @@ namespace Artemis.Core.Models.Surface
|
|||||||
RenderRectangle = new Rectangle(
|
RenderRectangle = new Rectangle(
|
||||||
(int) Math.Round(RgbDevice.Location.X * Surface.Scale, MidpointRounding.AwayFromZero),
|
(int) Math.Round(RgbDevice.Location.X * Surface.Scale, MidpointRounding.AwayFromZero),
|
||||||
(int) Math.Round(RgbDevice.Location.Y * 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.DeviceRectangle.Size.Width * Surface.Scale, MidpointRounding.AwayFromZero),
|
||||||
(int) Math.Round(RgbDevice.Size.Height * Surface.Scale, MidpointRounding.AwayFromZero)
|
(int) Math.Round(RgbDevice.DeviceRectangle.Size.Height * Surface.Scale, MidpointRounding.AwayFromZero)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!Leds.Any())
|
if (!Leds.Any())
|
||||||
@ -121,6 +120,7 @@ namespace Artemis.Core.Models.Surface
|
|||||||
}
|
}
|
||||||
|
|
||||||
public event EventHandler DeviceUpdated;
|
public event EventHandler DeviceUpdated;
|
||||||
|
|
||||||
protected virtual void OnDeviceUpdated()
|
protected virtual void OnDeviceUpdated()
|
||||||
{
|
{
|
||||||
DeviceUpdated?.Invoke(this, EventArgs.Empty);
|
DeviceUpdated?.Invoke(this, EventArgs.Empty);
|
||||||
|
|||||||
@ -6,6 +6,7 @@ using System.Linq;
|
|||||||
using Artemis.Core.Models.Surface;
|
using Artemis.Core.Models.Surface;
|
||||||
using Artemis.Core.Plugins.Abstract;
|
using Artemis.Core.Plugins.Abstract;
|
||||||
using Artemis.Core.Plugins.Models;
|
using Artemis.Core.Plugins.Models;
|
||||||
|
using Artemis.Core.Services.Storage.Interfaces;
|
||||||
using Artemis.Plugins.Modules.General.ViewModels;
|
using Artemis.Plugins.Modules.General.ViewModels;
|
||||||
using Device = Artemis.Core.Models.Surface.Device;
|
using Device = Artemis.Core.Models.Surface.Device;
|
||||||
|
|
||||||
@ -16,7 +17,7 @@ namespace Artemis.Plugins.Modules.General
|
|||||||
private readonly ColorBlend _rainbowColorBlend;
|
private readonly ColorBlend _rainbowColorBlend;
|
||||||
private readonly PluginSettings _settings;
|
private readonly PluginSettings _settings;
|
||||||
|
|
||||||
public GeneralModule(PluginInfo pluginInfo, PluginSettings settings) : base(pluginInfo)
|
public GeneralModule(PluginInfo pluginInfo, PluginSettings settings, ISurfaceService surfaceService) : base(pluginInfo)
|
||||||
{
|
{
|
||||||
_settings = settings;
|
_settings = settings;
|
||||||
DisplayName = "General";
|
DisplayName = "General";
|
||||||
@ -38,6 +39,8 @@ namespace Artemis.Plugins.Modules.General
|
|||||||
else
|
else
|
||||||
_rainbowColorBlend.Colors[i] = ColorHelpers.ColorFromHSV(0, 1, 1);
|
_rainbowColorBlend.Colors[i] = ColorHelpers.ColorFromHSV(0, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
surfaceService.SurfaceConfigurationUpdated += (sender, args) => DeviceBrushes.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] Hues { get; set; }
|
public int[] Hues { get; set; }
|
||||||
|
|||||||
@ -150,6 +150,7 @@
|
|||||||
<Compile Include="Converters\NullToImageConverter.cs" />
|
<Compile Include="Converters\NullToImageConverter.cs" />
|
||||||
<Compile Include="Converters\NullToVisibilityConverter.cs" />
|
<Compile Include="Converters\NullToVisibilityConverter.cs" />
|
||||||
<Compile Include="Extensions\RgbColorExtensions.cs" />
|
<Compile Include="Extensions\RgbColorExtensions.cs" />
|
||||||
|
<Compile Include="Extensions\RgbRectangleExtensions.cs" />
|
||||||
<Compile Include="Ninject\Factories\IModuleViewModelFactory.cs" />
|
<Compile Include="Ninject\Factories\IModuleViewModelFactory.cs" />
|
||||||
<Compile Include="Ninject\Factories\IProfileEditorViewModelFactory.cs" />
|
<Compile Include="Ninject\Factories\IProfileEditorViewModelFactory.cs" />
|
||||||
<Compile Include="Ninject\UIModule.cs" />
|
<Compile Include="Ninject\UIModule.cs" />
|
||||||
@ -375,12 +376,12 @@
|
|||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
</PostBuildEvent>
|
</PostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<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">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
<PropertyGroup>
|
<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>
|
<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>
|
</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\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>
|
</Target>
|
||||||
<Import Project="..\packages\Fody.6.0.5\build\Fody.targets" Condition="Exists('..\packages\Fody.6.0.5\build\Fody.targets')" />
|
|
||||||
</Project>
|
</Project>
|
||||||
18
src/Artemis.UI/Extensions/RgbRectangleExtensions.cs
Normal file
18
src/Artemis.UI/Extensions/RgbRectangleExtensions.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System.Windows;
|
||||||
|
using RGB.NET.Core;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Extensions
|
||||||
|
{
|
||||||
|
public static class RgbRectangleExtensions
|
||||||
|
{
|
||||||
|
public static Rect ToWindowsRect(this Rectangle rectangle, double scale)
|
||||||
|
{
|
||||||
|
return new Rect(
|
||||||
|
(int) (rectangle.Location.X * scale),
|
||||||
|
(int) (rectangle.Location.Y * scale),
|
||||||
|
(int) (rectangle.Size.Width * scale),
|
||||||
|
(int) (rectangle.Size.Height * scale)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -20,7 +20,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
|
|||||||
{
|
{
|
||||||
private readonly IProfileService _profileService;
|
private readonly IProfileService _profileService;
|
||||||
private readonly IDialogService _dialogService;
|
private readonly IDialogService _dialogService;
|
||||||
private Profile _selectedProfile;
|
|
||||||
|
|
||||||
public ProfileEditorViewModel(ProfileModule module, ICollection<ProfileEditorPanelViewModel> viewModels, IProfileService profileService, IDialogService dialogService)
|
public ProfileEditorViewModel(ProfileModule module, ICollection<ProfileEditorPanelViewModel> viewModels, IProfileService profileService, IDialogService dialogService)
|
||||||
{
|
{
|
||||||
@ -50,28 +49,24 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
|
|||||||
public ProfileViewModel ProfileViewModel { get; }
|
public ProfileViewModel ProfileViewModel { get; }
|
||||||
|
|
||||||
public BindableCollection<Profile> Profiles { get; set; }
|
public BindableCollection<Profile> Profiles { get; set; }
|
||||||
|
|
||||||
public Profile SelectedProfile
|
public Profile SelectedProfile
|
||||||
{
|
{
|
||||||
get => _selectedProfile;
|
get => Module.ActiveProfile;
|
||||||
set
|
set => ChangeSelectedProfile(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeSelectedProfile(Profile profile)
|
||||||
{
|
{
|
||||||
if (_selectedProfile == value)
|
if (profile == Module.ActiveProfile)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var old = _selectedProfile;
|
var oldProfile = Module.ActiveProfile;
|
||||||
_selectedProfile = value;
|
Module.ChangeActiveProfile(profile);
|
||||||
ChangeActiveProfile(old);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ChangeActiveProfile(Profile oldProfile)
|
|
||||||
{
|
|
||||||
Module.ChangeActiveProfile(_selectedProfile);
|
|
||||||
if (_selectedProfile != null)
|
|
||||||
_profileService.UpdateProfile(_selectedProfile, false);
|
|
||||||
if (oldProfile != null)
|
if (oldProfile != null)
|
||||||
_profileService.UpdateProfile(oldProfile, false);
|
_profileService.UpdateProfile(oldProfile, false);
|
||||||
|
if (profile != null)
|
||||||
|
_profileService.UpdateProfile(profile, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanDeleteActiveProfile => SelectedProfile != null && Profiles.Count > 1;
|
public bool CanDeleteActiveProfile => SelectedProfile != null && Profiles.Count > 1;
|
||||||
@ -107,7 +102,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
|
|||||||
var newActiveProfile = index - 1 > -1 ? Profiles[index - 1] : Profiles[index + 1];
|
var newActiveProfile = index - 1 > -1 ? Profiles[index - 1] : Profiles[index + 1];
|
||||||
|
|
||||||
// Activate the new active profile
|
// Activate the new active profile
|
||||||
Module.ChangeActiveProfile(newActiveProfile);
|
SelectedProfile = newActiveProfile;
|
||||||
|
|
||||||
// Remove the old one
|
// Remove the old one
|
||||||
Profiles.Remove(profile);
|
Profiles.Remove(profile);
|
||||||
|
|||||||
@ -13,16 +13,21 @@
|
|||||||
<converters:NullToImageConverter x:Key="NullToImageConverter" />
|
<converters:NullToImageConverter x:Key="NullToImageConverter" />
|
||||||
<converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
|
<converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Grid>
|
|
||||||
|
<Grid Width="{Binding Device.RgbDevice.ActualSize.Width}" Height="{Binding Device.RgbDevice.ActualSize.Height}">
|
||||||
|
<Grid.LayoutTransform>
|
||||||
|
<RotateTransform Angle="{Binding Device.Rotation}" />
|
||||||
|
</Grid.LayoutTransform>
|
||||||
|
|
||||||
<!-- Device image with fallback -->
|
<!-- Device image with fallback -->
|
||||||
<Image Source="{Binding Device.RgbDevice.DeviceInfo.Image, Converter={StaticResource NullToImageConverter}, Mode=OneWay}" />
|
<Image Source="{Binding Device.RgbDevice.DeviceInfo.Image, Converter={StaticResource NullToImageConverter}}" VerticalAlignment="Top" HorizontalAlignment="Left" />
|
||||||
|
|
||||||
<Rectangle Fill="{DynamicResource ControlBackgroundBrush}"
|
<Rectangle Fill="{DynamicResource ControlBackgroundBrush}"
|
||||||
Stroke="{DynamicResource ControlBorderBrush}"
|
Stroke="{DynamicResource ControlBorderBrush}"
|
||||||
StrokeThickness="1"
|
StrokeThickness="1"
|
||||||
Visibility="{Binding Device.RgbDevice.DeviceInfo.Image, ConverterParameter=Inverted, Converter={StaticResource NullToVisibilityConverter}, Mode=OneWay}" />
|
Visibility="{Binding Device.RgbDevice.DeviceInfo.Image, ConverterParameter=Inverted, Converter={StaticResource NullToVisibilityConverter}}" />
|
||||||
<TextBlock Text="{Binding Device.RgbDevice.DeviceInfo.DeviceName}"
|
<TextBlock Text="{Binding Device.RgbDevice.DeviceInfo.DeviceName}"
|
||||||
Visibility="{Binding Device.RgbDevice.DeviceInfo.Image, ConverterParameter=Inverted, Converter={StaticResource NullToVisibilityConverter}, Mode=OneWay}"
|
Visibility="{Binding Device.RgbDevice.DeviceInfo.Image, ConverterParameter=Inverted, Converter={StaticResource NullToVisibilityConverter}}"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
@ -37,13 +42,13 @@
|
|||||||
</ItemsControl.ItemsPanel>
|
</ItemsControl.ItemsPanel>
|
||||||
<ItemsControl.ItemContainerStyle>
|
<ItemsControl.ItemContainerStyle>
|
||||||
<Style TargetType="{x:Type ContentPresenter}">
|
<Style TargetType="{x:Type ContentPresenter}">
|
||||||
<Setter Property="Canvas.Left" Value="{Binding X, Mode=OneWay}" />
|
<Setter Property="Canvas.Left" Value="{Binding X}" />
|
||||||
<Setter Property="Canvas.Top" Value="{Binding Y, Mode=OneWay}" />
|
<Setter Property="Canvas.Top" Value="{Binding Y}" />
|
||||||
</Style>
|
</Style>
|
||||||
</ItemsControl.ItemContainerStyle>
|
</ItemsControl.ItemContainerStyle>
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<ContentControl Width="{Binding Width, Mode=OneWay}" Height="{Binding Height, Mode=OneWay}" s:View.Model="{Binding}" />
|
<ContentControl Width="{Binding Width}" Height="{Binding Height}" s:View.Model="{Binding}" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<converters:NullToImageConverter x:Key="NullToImageConverter" />
|
<converters:NullToImageConverter x:Key="NullToImageConverter" />
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Canvas Width="{Binding Width, Mode=OneWay}" Height="{Binding Height, Mode=OneWay}">
|
<Canvas Width="{Binding Led.ActualSize.Width, Mode=OneWay}" Height="{Binding Led.ActualSize.Height, Mode=OneWay}">
|
||||||
<Canvas.Background>
|
<Canvas.Background>
|
||||||
<ImageBrush AlignmentX="Center" AlignmentY="Center" Stretch="Fill"
|
<ImageBrush AlignmentX="Center" AlignmentY="Center" Stretch="Fill"
|
||||||
ImageSource="{Binding Led.Image, Converter={StaticResource NullToImageConverter}, Mode=OneWay}" />
|
ImageSource="{Binding Led.Image, Converter={StaticResource NullToImageConverter}, Mode=OneWay}" />
|
||||||
|
|||||||
@ -13,10 +13,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
|||||||
public ProfileLedViewModel(Led led)
|
public ProfileLedViewModel(Led led)
|
||||||
{
|
{
|
||||||
Led = led;
|
Led = led;
|
||||||
X = Led.Location.X;
|
|
||||||
Y = Led.Location.Y;
|
// Don't want ActualLocation here since rotation is done in XAML
|
||||||
Width = Led.Size.Width;
|
X = Led.Location.X * Led.Device.Scale.Horizontal;
|
||||||
Height = Led.Size.Height;
|
Y = Led.Location.Y * Led.Device.Scale.Vertical;
|
||||||
|
Width = Led.ActualSize.Width;
|
||||||
|
Height = Led.ActualSize.Height;
|
||||||
|
|
||||||
Execute.OnUIThread(CreateLedGeometry);
|
Execute.OnUIThread(CreateLedGeometry);
|
||||||
}
|
}
|
||||||
@ -63,17 +65,18 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
|||||||
|
|
||||||
private void CreateRectangleGeometry()
|
private void CreateRectangleGeometry()
|
||||||
{
|
{
|
||||||
DisplayGeometry = new RectangleGeometry(new Rect(0.5, 0.5, Led.Size.Width - 1, Led.Size.Height - 1));
|
|
||||||
|
DisplayGeometry = new RectangleGeometry(new Rect(0.5, 0.5, Width - 1, Height - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateCircleGeometry()
|
private void CreateCircleGeometry()
|
||||||
{
|
{
|
||||||
DisplayGeometry = new EllipseGeometry(new Rect(0.5, 0.5, Led.Size.Width - 1, Led.Size.Height - 1));
|
DisplayGeometry = new EllipseGeometry(new Rect(0.5, 0.5, Width - 1, Height - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateKeyCapGeometry()
|
private void CreateKeyCapGeometry()
|
||||||
{
|
{
|
||||||
DisplayGeometry = new RectangleGeometry(new Rect(1, 1, Led.Size.Width - 2, Led.Size.Height - 2), 1.6, 1.6);
|
DisplayGeometry = new RectangleGeometry(new Rect(1, 1, Width - 2, Height - 2), 1.6, 1.6);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateCustomGeometry(double deflateAmount)
|
private void CreateCustomGeometry(double deflateAmount)
|
||||||
@ -88,7 +91,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
|||||||
{
|
{
|
||||||
Children = new TransformCollection
|
Children = new TransformCollection
|
||||||
{
|
{
|
||||||
new ScaleTransform(Led.Size.Width - deflateAmount, Led.Size.Height - deflateAmount),
|
new ScaleTransform(Width - deflateAmount, Height - deflateAmount),
|
||||||
new TranslateTransform(deflateAmount / 2, deflateAmount / 2)
|
new TranslateTransform(deflateAmount / 2, deflateAmount / 2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,8 +43,7 @@
|
|||||||
MouseDown="{s:Action EditorGridMouseClick}"
|
MouseDown="{s:Action EditorGridMouseClick}"
|
||||||
MouseMove="{s:Action EditorGridMouseMove}">
|
MouseMove="{s:Action EditorGridMouseMove}">
|
||||||
<Grid.Background>
|
<Grid.Background>
|
||||||
<VisualBrush TileMode="Tile" Stretch="Uniform"
|
<VisualBrush TileMode="Tile" Stretch="Uniform" Viewport="{Binding PanZoomViewModel.BackgroundViewport}" ViewportUnits="Absolute">
|
||||||
Viewport="{Binding PanZoomViewModel.BackgroundViewport}" ViewportUnits="Absolute">
|
|
||||||
<VisualBrush.Visual>
|
<VisualBrush.Visual>
|
||||||
<Grid Width="20" Height="20">
|
<Grid Width="20" Height="20">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
@ -102,9 +101,7 @@
|
|||||||
</ItemsControl.ItemContainerStyle>
|
</ItemsControl.ItemContainerStyle>
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<ContentControl Width="{Binding Device.RgbDevice.Size.Width}"
|
<ContentControl s:View.Model="{Binding}" />
|
||||||
Height="{Binding Device.RgbDevice.Size.Height}"
|
|
||||||
s:View.Model="{Binding}" />
|
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
|
|||||||
@ -50,8 +50,7 @@
|
|||||||
MouseMove="{s:Action EditorGridMouseMove}"
|
MouseMove="{s:Action EditorGridMouseMove}"
|
||||||
Cursor="{Binding Cursor}">
|
Cursor="{Binding Cursor}">
|
||||||
<Grid.Background>
|
<Grid.Background>
|
||||||
<VisualBrush TileMode="Tile" Stretch="Uniform"
|
<VisualBrush TileMode="Tile" Stretch="Uniform" Viewport="{Binding PanZoomViewModel.BackgroundViewport}" ViewportUnits="Absolute">
|
||||||
Viewport="{Binding PanZoomViewModel.BackgroundViewport}" ViewportUnits="Absolute">
|
|
||||||
<VisualBrush.Visual>
|
<VisualBrush.Visual>
|
||||||
<Grid Width="20" Height="20">
|
<Grid Width="20" Height="20">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
@ -91,8 +90,7 @@
|
|||||||
<Grid Name="EditorDisplayGrid">
|
<Grid Name="EditorDisplayGrid">
|
||||||
<Grid.RenderTransform>
|
<Grid.RenderTransform>
|
||||||
<TransformGroup>
|
<TransformGroup>
|
||||||
<ScaleTransform ScaleX="{Binding PanZoomViewModel.Zoom}"
|
<ScaleTransform ScaleX="{Binding PanZoomViewModel.Zoom}" ScaleY="{Binding PanZoomViewModel.Zoom}" />
|
||||||
ScaleY="{Binding PanZoomViewModel.Zoom}" />
|
|
||||||
<TranslateTransform X="{Binding PanZoomViewModel.PanX}" Y="{Binding PanZoomViewModel.PanY}" />
|
<TranslateTransform X="{Binding PanZoomViewModel.PanX}" Y="{Binding PanZoomViewModel.PanY}" />
|
||||||
</TransformGroup>
|
</TransformGroup>
|
||||||
</Grid.RenderTransform>
|
</Grid.RenderTransform>
|
||||||
@ -110,9 +108,7 @@
|
|||||||
</ItemsControl.ItemContainerStyle>
|
</ItemsControl.ItemContainerStyle>
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<ContentControl Width="{Binding Device.RgbDevice.DeviceRectangle.Size.Width}"
|
<ContentControl s:View.Model="{Binding}">
|
||||||
Height="{Binding Device.RgbDevice.DeviceRectangle.Size.Height}"
|
|
||||||
s:View.Model="{Binding}">
|
|
||||||
<ContentControl.ContextMenu>
|
<ContentControl.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<MenuItem Header="Bring to Front" Command="{s:Action BringToFront}" CommandParameter="{Binding}">
|
<MenuItem Header="Bring to Front" Command="{s:Action BringToFront}" CommandParameter="{Binding}">
|
||||||
|
|||||||
@ -19,12 +19,14 @@
|
|||||||
<converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
|
<converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<!-- Device image with fallback -->
|
<!-- Content -->
|
||||||
<Image Source="{Binding Device.RgbDevice.DeviceInfo.Image, Converter={StaticResource NullToImageConverter}}" VerticalAlignment="Top" HorizontalAlignment="Left">
|
<Grid Width="{Binding Device.RgbDevice.ActualSize.Width}" Height="{Binding Device.RgbDevice.ActualSize.Height}">
|
||||||
<Image.LayoutTransform>
|
<Grid.LayoutTransform>
|
||||||
<RotateTransform Angle="{Binding Device.Rotation}" />
|
<RotateTransform Angle="{Binding Device.Rotation}" />
|
||||||
</Image.LayoutTransform>
|
</Grid.LayoutTransform>
|
||||||
</Image>
|
|
||||||
|
<!-- Device image with fallback -->
|
||||||
|
<Image Source="{Binding Device.RgbDevice.DeviceInfo.Image, Converter={StaticResource NullToImageConverter}}" VerticalAlignment="Top" HorizontalAlignment="Left" />
|
||||||
|
|
||||||
<Rectangle Fill="{DynamicResource ControlBackgroundBrush}"
|
<Rectangle Fill="{DynamicResource ControlBackgroundBrush}"
|
||||||
Stroke="{DynamicResource ControlBorderBrush}"
|
Stroke="{DynamicResource ControlBorderBrush}"
|
||||||
@ -39,9 +41,6 @@
|
|||||||
|
|
||||||
<!-- LEDs -->
|
<!-- LEDs -->
|
||||||
<ItemsControl ItemsSource="{Binding Leds}">
|
<ItemsControl ItemsSource="{Binding Leds}">
|
||||||
<ItemsControl.LayoutTransform>
|
|
||||||
<RotateTransform Angle="{Binding Device.Rotation}" />
|
|
||||||
</ItemsControl.LayoutTransform>
|
|
||||||
<ItemsControl.ItemsPanel>
|
<ItemsControl.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<Canvas />
|
<Canvas />
|
||||||
@ -55,10 +54,11 @@
|
|||||||
</ItemsControl.ItemContainerStyle>
|
</ItemsControl.ItemContainerStyle>
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<ContentControl Width="{Binding Width}" Height="{Binding Height}" s:View.Model="{Binding}" />
|
<ContentControl s:View.Model="{Binding}" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<!-- Selection rectangle -->
|
<!-- Selection rectangle -->
|
||||||
<Rectangle Width="Auto" Height="Auto" StrokeThickness="2">
|
<Rectangle Width="Auto" Height="Auto" StrokeThickness="2">
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using Artemis.Core.Models.Surface;
|
using Artemis.Core.Models.Surface;
|
||||||
@ -35,7 +33,7 @@ namespace Artemis.UI.Screens.SurfaceEditor.Visualization
|
|||||||
|
|
||||||
public Rect DeviceRectangle => Device.RgbDevice == null
|
public Rect DeviceRectangle => Device.RgbDevice == null
|
||||||
? new Rect()
|
? new Rect()
|
||||||
: new Rect(Device.X, Device.Y, Device.RgbDevice.Size.Width, Device.RgbDevice.Size.Height);
|
: new Rect(Device.X, Device.Y, Device.RgbDevice.DeviceRectangle.Size.Width, Device.RgbDevice.DeviceRectangle.Size.Height);
|
||||||
|
|
||||||
public void StartMouseDrag(Point mouseStartPosition)
|
public void StartMouseDrag(Point mouseStartPosition)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using RGB.NET.Core;
|
using System.ComponentModel;
|
||||||
|
using RGB.NET.Core;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.SurfaceEditor.Visualization
|
namespace Artemis.UI.Screens.SurfaceEditor.Visualization
|
||||||
@ -9,6 +10,8 @@ namespace Artemis.UI.Screens.SurfaceEditor.Visualization
|
|||||||
{
|
{
|
||||||
Led = led;
|
Led = led;
|
||||||
ApplyLedToViewModel();
|
ApplyLedToViewModel();
|
||||||
|
|
||||||
|
Led.PropertyChanged += OnLedOnPropertyChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Led Led { get; set; }
|
public Led Led { get; set; }
|
||||||
@ -18,12 +21,18 @@ namespace Artemis.UI.Screens.SurfaceEditor.Visualization
|
|||||||
public double Width { get; set; }
|
public double Width { get; set; }
|
||||||
public double Height { get; set; }
|
public double Height { get; set; }
|
||||||
|
|
||||||
|
private void OnLedOnPropertyChanged(object sender, PropertyChangedEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.PropertyName == "Location" || args.PropertyName == "ActualSize") ApplyLedToViewModel();
|
||||||
|
}
|
||||||
|
|
||||||
public void ApplyLedToViewModel()
|
public void ApplyLedToViewModel()
|
||||||
{
|
{
|
||||||
X = Led.Location.X;
|
// Don't want ActualLocation here since rotation is done in XAML
|
||||||
Y = Led.Location.Y;
|
X = Led.Location.X * Led.Device.Scale.Horizontal;
|
||||||
Width = Led.Size.Width;
|
Y = Led.Location.Y * Led.Device.Scale.Vertical;
|
||||||
Height = Led.Size.Height;
|
Width = Led.ActualSize.Width;
|
||||||
|
Height = Led.ActualSize.Height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user