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

Merge branch 'development'

This commit is contained in:
SpoinkyNL 2021-02-02 20:06:02 +01:00
commit 49d1fc072d
16 changed files with 123 additions and 54 deletions

View File

@ -570,7 +570,7 @@ namespace Artemis.Core
List<ArtemisLed> leds = new();
// Get the surface LEDs for this layer
List<ArtemisLed> availableLeds = surface.Devices.SelectMany(d => d.Leds).ToList();
List<ArtemisLed> availableLeds = surface.Devices.Where(d => d.IsEnabled).SelectMany(d => d.Leds).ToList();
foreach (LedEntity ledEntity in LayerEntity.Leds)
{
ArtemisLed? match = availableLeds.FirstOrDefault(a => a.Device.RgbDevice.GetDeviceIdentifier() == ledEntity.DeviceIdentifier &&

View File

@ -30,7 +30,8 @@ namespace Artemis.Core
RedScale = 1;
GreenScale = 1;
BlueScale = 1;
IsEnabled = true;
deviceProvider.DeviceLayoutPaths.TryGetValue(rgbDevice, out string? layoutPath);
LayoutPath = layoutPath;
@ -213,6 +214,19 @@ namespace Artemis.Core
}
}
/// <summary>
/// Gets or sets a boolean indicating whether this devices is enabled or not
/// </summary>
public bool IsEnabled
{
get => DeviceEntity.IsEnabled;
set
{
DeviceEntity.IsEnabled = value;
OnPropertyChanged(nameof(IsEnabled));
}
}
/// <summary>
/// Gets the path to where the layout of the device was (attempted to be) loaded from
/// </summary>

View File

@ -98,7 +98,7 @@ namespace Artemis.Core
internal void UpdateLedMap()
{
LedMap = new ReadOnlyDictionary<Led, ArtemisLed>(
_devices.SelectMany(d => d.Leds.Select(al => new KeyValuePair<Led, ArtemisLed>(al.RgbLed, al))).ToDictionary(kvp => kvp.Key, kvp => kvp.Value)
_devices.Where(d => d.IsEnabled).SelectMany(d => d.Leds.Select(al => new KeyValuePair<Led, ArtemisLed>(al.RgbLed, al))).ToDictionary(kvp => kvp.Key, kvp => kvp.Value)
);
}

View File

@ -270,7 +270,10 @@ namespace Artemis.Core.Services
string? mainFile = plugin.ResolveRelativePath(plugin.Info.Main);
if (!File.Exists(mainFile))
throw new ArtemisPluginException(plugin, "Couldn't find the plugins main entry at " + mainFile);
FileInfo[] fileInfos = directory.GetFiles();
if (!fileInfos.Any(f => string.Equals(f.Name, plugin.Info.Main, StringComparison.InvariantCulture)))
throw new ArtemisPluginException(plugin, "Plugin main entry casing mismatch at " + plugin.Info.Main);
// Load the plugin, all types implementing Plugin and register them with DI
plugin.PluginLoader = PluginLoader.CreateFromAssemblyFile(mainFile!, configure =>
{

View File

@ -117,7 +117,7 @@ namespace Artemis.Core.Services
{
// Apply the application wide brush and decorator
BitmapBrush = new BitmapBrush(new Scale(_renderScaleSetting.Value), _sampleSizeSetting);
_surfaceLedGroup = new ListLedGroup(Surface.Leds) {Brush = BitmapBrush};
_surfaceLedGroup = new ListLedGroup(artemisSurface.LedMap.Select(l => l.Key)) {Brush = BitmapBrush};
return;
}
@ -129,7 +129,7 @@ namespace Artemis.Core.Services
// Apply the application wide brush and decorator
BitmapBrush.Scale = new Scale(_renderScaleSetting.Value);
BitmapBrush.Surface = artemisSurface;
_surfaceLedGroup = new ListLedGroup(Surface.Leds) {Brush = BitmapBrush};
_surfaceLedGroup = new ListLedGroup(artemisSurface.LedMap.Select(l => l.Key)) {Brush = BitmapBrush};
}
}

View File

@ -18,6 +18,7 @@ namespace Artemis.Storage.Entities.Surface
public double RedScale { get; set; }
public double GreenScale { get; set; }
public double BlueScale { get; set; }
public bool IsEnabled { get; set; }
public List<DeviceInputIdentifierEntity> InputIdentifiers { get; set; }
}

View File

@ -207,7 +207,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
private void ApplySurfaceConfiguration(ArtemisSurface surface)
{
Devices.Clear();
Devices.AddRange(surface.Devices.OrderBy(d => d.ZIndex));
Devices.AddRange(surface.Devices.Where(d => d.IsEnabled).OrderBy(d => d.ZIndex));
}
private void UpdateLedsDimStatus()

View File

@ -5,43 +5,51 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.Settings.Tabs.About"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance local:AboutTabViewModel}">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<StackPanel Margin="15" MaxWidth="800">
<TextBlock Style="{StaticResource MaterialDesignHeadline2TextBlock}">
Artemis 2
</TextBlock>
<StackPanel Orientation="Horizontal">
<shared:ArtemisIcon SvgSource="/Resources/Images/Logo/bow.svg" Width="60" Height="80" Margin="0 0 20 0" />
<TextBlock Style="{StaticResource MaterialDesignHeadline2TextBlock}">
Artemis 2
</TextBlock>
</StackPanel>
<TextBlock Style="{StaticResource MaterialDesignSubtitle1TextBlock}" Foreground="{DynamicResource MaterialDesignBodyLight}" Text="{Binding Version}" />
<materialDesign:Card Margin="0 25 0 0">
<StackPanel Margin="15">
<TextBlock Style="{StaticResource MaterialDesignHeadline4TextBlock}">
Lead developer
</TextBlock>
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">
Spoinky (Robert Beekman)
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Account" Width="60" Height="40" />
<TextBlock Style="{StaticResource MaterialDesignHeadline4TextBlock}">
Lead developer
</TextBlock>
</StackPanel>
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Margin="10 0 0 0">
- Spoinky (Robert Beekman)
</TextBlock>
<TextBlock Style="{StaticResource MaterialDesignHeadline4TextBlock}" Margin="0 25 0 0">
Main contributors
<StackPanel Orientation="Horizontal" Margin="0 25 0 0">
<materialDesign:PackIcon Kind="AccountGroup" Width="60" Height="40" />
<TextBlock Style="{StaticResource MaterialDesignHeadline4TextBlock}">
Main contributors
</TextBlock>
</StackPanel>
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" LineHeight="25" Margin="10 0 0 0">
- DarthAffe <LineBreak />
- DrMeteor (Diogo Trindade)
</TextBlock>
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">
DarthAffe
</TextBlock>
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">
DrMeteor (Diogo Trindade)
</TextBlock>
<TextBlock Style="{StaticResource MaterialDesignHeadline4TextBlock}" Margin="0 25 0 0">
Special thanks
</TextBlock>
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">
All the people on Discord provinding feedback and testing
</TextBlock>
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">
Aureshion - Default device images
<StackPanel Orientation="Horizontal" Margin="0 25 0 0">
<materialDesign:PackIcon Kind="AccountHeart" Width="60" Height="40" />
<TextBlock Style="{StaticResource MaterialDesignHeadline4TextBlock}">
Special thanks
</TextBlock>
</StackPanel>
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" LineHeight="25" Margin="10 0 0 0">
- All the people on Discord providing feedback and testing<LineBreak />
- Aureshion - Default device images
</TextBlock>
</StackPanel>
</materialDesign:Card>

View File

@ -10,7 +10,14 @@
d:DataContext="{d:DesignInstance local:DeviceSettingsTabViewModel}">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0 12 0 0">
<DockPanel Margin="15" MaxWidth="1230" HorizontalAlignment="Center">
<TextBlock DockPanel.Dock="Top">Below you view and manage the devices that were detected by Artemis</TextBlock>
<StackPanel DockPanel.Dock="Top">
<TextBlock Style="{StaticResource MaterialDesignHeadline5TextBlock}">Device management</TextBlock>
<TextBlock Style="{StaticResource MaterialDesignTextBlock}">
Below you view and manage the devices that were detected by Artemis. <LineBreak/>
Disabling a device will cause it to stop updating. Some SDKs will even go back to using manufacturer lighting (Artemis restart may be required).
</TextBlock>
</StackPanel>
<ItemsControl ItemsSource="{Binding Items}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>

View File

@ -3,6 +3,7 @@ using System.Linq;
using System.Threading.Tasks;
using Artemis.Core.Services;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Shared.Services;
using Stylet;
namespace Artemis.UI.Screens.Settings.Tabs.Devices
@ -11,19 +12,22 @@ namespace Artemis.UI.Screens.Settings.Tabs.Devices
{
private readonly ISettingsVmFactory _settingsVmFactory;
private readonly ISurfaceService _surfaceService;
private readonly IDialogService _dialogService;
private bool _confirmedDisable;
public DeviceSettingsTabViewModel(ISurfaceService surfaceService, ISettingsVmFactory settingsVmFactory)
public DeviceSettingsTabViewModel(ISurfaceService surfaceService, IDialogService dialogService, ISettingsVmFactory settingsVmFactory)
{
DisplayName = "DEVICES";
_surfaceService = surfaceService;
_dialogService = dialogService;
_settingsVmFactory = settingsVmFactory;
}
protected override void OnActivate()
{
// Take it off the UI thread to avoid freezing on tab change
Task.Run(async () =>
Task.Run(async () =>
{
Items.Clear();
await Task.Delay(200);
@ -35,5 +39,21 @@ namespace Artemis.UI.Screens.Settings.Tabs.Devices
base.OnActivate();
}
public async Task<bool> ShowDeviceDisableDialog()
{
if (_confirmedDisable)
return true;
bool confirmed = await _dialogService.ShowConfirmDialog(
"Disabling device",
"Disabling a device will cause it to stop updating. " +
"\r\nSome SDKs will even go back to using manufacturer lighting (Artemis restart may be required)."
);
if (confirmed)
_confirmedDisable = true;
return confirmed;
}
}
}

View File

@ -29,7 +29,7 @@
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Rectangle Grid.Row="0" Height="140" Width="196" Fill="{DynamicResource MaterialDesignPaper}" />
<Rectangle Grid.Row="0" Fill="{DynamicResource MaterialDesignPaper}" />
<shared:DeviceVisualizer Device="{Binding Device}" RenderOptions.BitmapScalingMode="HighQuality" Grid.Row="0" Height="130" Width="190" />
<Button Grid.Row="0"
Style="{StaticResource MaterialDesignFloatingActionMiniButton}"
@ -56,26 +56,26 @@
<StackPanel>
<Button Command="{s:Action ShowDeviceDebugger}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Tools" Margin="0 0 10 0 " VerticalAlignment="Center"/>
<materialDesign:PackIcon Kind="Tools" Margin="0 0 10 0 " VerticalAlignment="Center" />
<TextBlock VerticalAlignment="Center">Show device debugger</TextBlock>
</StackPanel>
</Button>
<Button Command="{s:Action OpenPluginDirectory}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="FolderOpen" Margin="0 0 10 0 " VerticalAlignment="Center"/>
<materialDesign:PackIcon Kind="FolderOpen" Margin="0 0 10 0 " VerticalAlignment="Center" />
<TextBlock VerticalAlignment="Center">Open plugin directory</TextBlock>
</StackPanel>
</Button>
<Separator/>
<Separator />
<Button Command="{s:Action DetectInput}" ToolTip="Teach Artemis which keypresses and/or button presses belong to this device">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="GestureDoubleTap" Margin="0 0 10 0 " VerticalAlignment="Center"/>
<materialDesign:PackIcon Kind="GestureDoubleTap" Margin="0 0 10 0 " VerticalAlignment="Center" />
<TextBlock VerticalAlignment="Center">Identify input</TextBlock>
</StackPanel>
</Button>
<Button Command="{s:Action ViewProperties}">
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon Kind="Gear" Margin="0 0 10 0 " VerticalAlignment="Center"/>
<materialDesign:PackIcon Kind="Gear" Margin="0 0 10 0 " VerticalAlignment="Center" />
<TextBlock VerticalAlignment="Center">View surface properties</TextBlock>
</StackPanel>
</Button>

View File

@ -14,14 +14,13 @@ using Stylet;
namespace Artemis.UI.Screens.Settings.Tabs.Devices
{
public class DeviceSettingsViewModel : PropertyChangedBase
public class DeviceSettingsViewModel : Screen
{
private readonly IDeviceDebugVmFactory _deviceDebugVmFactory;
private readonly ISurfaceService _surfaceService;
private readonly IDeviceService _deviceService;
private readonly IDialogService _dialogService;
private readonly IWindowManager _windowManager;
private bool _isDeviceEnabled;
public DeviceSettingsViewModel(ArtemisDevice device,
IDeviceService deviceService,
@ -40,9 +39,6 @@ namespace Artemis.UI.Screens.Settings.Tabs.Devices
Type = Device.RgbDevice.DeviceInfo.DeviceType.ToString().Humanize();
Name = Device.RgbDevice.DeviceInfo.Model;
Manufacturer = Device.RgbDevice.DeviceInfo.Manufacturer;
// TODO: Implement this bad boy
IsDeviceEnabled = true;
}
public ArtemisDevice Device { get; }
@ -56,8 +52,27 @@ namespace Artemis.UI.Screens.Settings.Tabs.Devices
public bool IsDeviceEnabled
{
get => _isDeviceEnabled;
set => SetAndNotify(ref _isDeviceEnabled, value);
get => Device.IsEnabled;
set
{
Task.Run(() => UpdateIsDeviceEnabled(value));
}
}
private async Task UpdateIsDeviceEnabled(bool value)
{
if (!value)
value = !await ((DeviceSettingsTabViewModel)Parent).ShowDeviceDisableDialog();
Device.IsEnabled = value;
NotifyOfPropertyChange(nameof(IsDeviceEnabled));
SaveDevice();
}
private void SaveDevice()
{
_surfaceService.UpdateSurfaceConfiguration(_surfaceService.ActiveSurface, true);
}
public void IdentifyDevice()
@ -85,10 +100,10 @@ namespace Artemis.UI.Screens.Settings.Tabs.Devices
public async Task DetectInput()
{
object madeChanges = await _dialogService.ShowDialog<SurfaceDeviceDetectInputViewModel>(
new Dictionary<string, object> { { "device", Device } }
new Dictionary<string, object> {{"device", Device}}
);
if ((bool)madeChanges)
if ((bool) madeChanges)
_surfaceService.UpdateSurfaceConfiguration(_surfaceService.ActiveSurface, true);
}

View File

@ -19,6 +19,7 @@
</Grid.RowDefinitions>
<StackPanel>
<TextBlock Style="{StaticResource MaterialDesignHeadline5TextBlock}" Margin="0 15 0 0">Module priority</TextBlock>
<TextBlock TextWrapping="Wrap" Style="{StaticResource MaterialDesignTextBlock}">
Drag and drop the modules below to change their rendering priority. <LineBreak /><LineBreak />
- Like in the profile editor, the modules at the top render over modules at the bottom <LineBreak />

View File

@ -94,7 +94,7 @@ namespace Artemis.UI.Screens.Shared
Zoom *= 0.9;
// Limit to a min of 0.1 and a max of 2.5 (10% - 250% in the view)
Zoom = Math.Max(0.1, Math.Min(2.5, Zoom));
Zoom = Math.Max(0.1, Zoom);
// Update the PanX/Y to enable zooming relative to cursor
if (LimitToZero)

View File

@ -176,7 +176,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
List<SurfaceDeviceViewModel> deviceViewModels = new();
// Add missing/update existing
foreach (ArtemisDevice surfaceDeviceConfiguration in SelectedSurface.Devices.OrderBy(d => d.ZIndex).ToList())
foreach (ArtemisDevice surfaceDeviceConfiguration in SelectedSurface.Devices.Where(d => d.IsEnabled).OrderBy(d => d.ZIndex).ToList())
{
// Create VMs for missing devices
SurfaceDeviceViewModel viewModel = existing.FirstOrDefault(vm => vm.Device.RgbDevice == surfaceDeviceConfiguration.RgbDevice);

View File

@ -116,7 +116,7 @@ namespace Artemis.UI.Screens.SurfaceEditor.Visualization
.Select(l => SKRect.Create(l.Rectangle.Left + x, l.Rectangle.Top + y, l.Rectangle.Width, l.Rectangle.Height))
.ToList();
List<SKRect> others = Device.Surface.Devices
.Where(d => d != Device)
.Where(d => d != Device && d.IsEnabled)
.SelectMany(d => d.Leds)
.Select(l => SKRect.Create(l.Rectangle.Left + (float) l.Device.X, l.Rectangle.Top + (float) l.Device.Y, l.Rectangle.Width, l.Rectangle.Height))
.ToList();