mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Added ShowAll toggle to profile editor
This commit is contained in:
parent
6f1c1c4245
commit
841979098c
@ -77,6 +77,11 @@ namespace Artemis.DeviceProviders.Corsair
|
||||
break;
|
||||
}
|
||||
|
||||
// Height = 7;
|
||||
// Width = 18;
|
||||
// Slug = "corsair-k65-rgb";
|
||||
// PreviewSettings = new PreviewSettings(610, 240, new Thickness(0, -30, 0, 0), Resources.k65);
|
||||
|
||||
Logger.Debug("Corsair SDK reported device as: {0}", _keyboard.DeviceInfo.Model);
|
||||
_keyboard.Brush = _keyboardBrush ?? (_keyboardBrush = new ImageBrush());
|
||||
}
|
||||
|
||||
@ -73,6 +73,7 @@ namespace Artemis.Managers
|
||||
// LoopManager might be running, this method won't do any harm in that case.
|
||||
_loopManager.StartAsync();
|
||||
|
||||
ProfilePreviewModel.ProfileViewModel = activePreview.ProfileEditor.ProfileViewModel;
|
||||
if (!ReferenceEquals(ProfilePreviewModel.Profile, activePreview.ProfileEditor.SelectedProfile))
|
||||
ProfilePreviewModel.Profile = activePreview.ProfileEditor.SelectedProfile;
|
||||
}
|
||||
|
||||
@ -7,6 +7,8 @@ using Artemis.Models;
|
||||
using Artemis.Models.Interfaces;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.ViewModels.Profiles;
|
||||
using Castle.Components.DictionaryAdapter;
|
||||
|
||||
namespace Artemis.Modules.Effects.ProfilePreview
|
||||
{
|
||||
@ -17,6 +19,8 @@ namespace Artemis.Modules.Effects.ProfilePreview
|
||||
Name = "Profile Preview";
|
||||
}
|
||||
|
||||
public ProfileViewModel ProfileViewModel { get; set; }
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Initialized = false;
|
||||
@ -33,7 +37,7 @@ namespace Artemis.Modules.Effects.ProfilePreview
|
||||
|
||||
public override List<LayerModel> GetRenderLayers(bool keyboardOnly)
|
||||
{
|
||||
return Profile.GetRenderLayers(DataModel, keyboardOnly, true);
|
||||
return ProfileViewModel != null ? ProfileViewModel.GetRenderLayers() : new EditableList<LayerModel>();
|
||||
}
|
||||
|
||||
public override void Render(RenderFrame frame, bool keyboardOnly)
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
@ -10,9 +11,11 @@ using Artemis.Managers;
|
||||
using Artemis.Modules.Effects.ProfilePreview;
|
||||
using Artemis.Profiles;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Profiles.Layers.Types.Folder;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using Caliburn.Micro;
|
||||
using Castle.Components.DictionaryAdapter;
|
||||
using MahApps.Metro;
|
||||
|
||||
namespace Artemis.ViewModels.Profiles
|
||||
@ -29,6 +32,7 @@ namespace Artemis.ViewModels.Profiles
|
||||
private Cursor _keyboardPreviewCursor;
|
||||
private bool _resizing;
|
||||
private LayerModel _selectedLayer;
|
||||
private bool _showAll;
|
||||
|
||||
public ProfileViewModel(IEventAggregator events, DeviceManager deviceManager)
|
||||
{
|
||||
@ -36,6 +40,8 @@ namespace Artemis.ViewModels.Profiles
|
||||
_deviceManager = deviceManager;
|
||||
|
||||
PreviewTimer = new Timer(40);
|
||||
ShowAll = false;
|
||||
|
||||
PreviewTimer.Elapsed += InvokeUpdateKeyboardPreview;
|
||||
}
|
||||
|
||||
@ -75,6 +81,17 @@ namespace Artemis.ViewModels.Profiles
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowAll
|
||||
{
|
||||
get { return _showAll; }
|
||||
set
|
||||
{
|
||||
if (value == _showAll) return;
|
||||
_showAll = value;
|
||||
NotifyOfPropertyChange(() => ShowAll);
|
||||
}
|
||||
}
|
||||
|
||||
public ImageSource KeyboardImage => ImageUtilities
|
||||
.BitmapToBitmapImage(_deviceManager.ActiveKeyboard?.PreviewSettings.Image ?? Resources.none);
|
||||
|
||||
@ -92,7 +109,7 @@ namespace Artemis.ViewModels.Profiles
|
||||
_blurProgress = _blurProgress + 0.025;
|
||||
BlurRadius = (Math.Sin(_blurProgress*Math.PI) + 1)*10 + 10;
|
||||
|
||||
if (SelectedProfile == null || _deviceManager.ActiveKeyboard == null)
|
||||
if (SelectedProfile == null || _deviceManager.ActiveKeyboard == null || (!ShowAll && SelectedLayer == null))
|
||||
{
|
||||
var preview = new DrawingImage();
|
||||
preview.Freeze();
|
||||
@ -100,6 +117,7 @@ namespace Artemis.ViewModels.Profiles
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var keyboardRect = _deviceManager.ActiveKeyboard.KeyboardRectangle(4);
|
||||
var visual = new DrawingVisual();
|
||||
using (var drawingContext = visual.RenderOpen())
|
||||
@ -108,8 +126,10 @@ namespace Artemis.ViewModels.Profiles
|
||||
drawingContext.PushClip(new RectangleGeometry(keyboardRect));
|
||||
drawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), null, keyboardRect);
|
||||
|
||||
// Get the layers that must be drawn
|
||||
var drawLayers = GetRenderLayers();
|
||||
|
||||
// Draw the layers
|
||||
var drawLayers = SelectedProfile.GetRenderLayers(new ProfilePreviewDataModel(), false, true);
|
||||
foreach (var layer in drawLayers)
|
||||
{
|
||||
layer.Update(null, true, false);
|
||||
@ -120,7 +140,12 @@ namespace Artemis.ViewModels.Profiles
|
||||
// Get the selection color
|
||||
var accentColor = ThemeManager.DetectAppStyle(Application.Current)?.Item2?.Resources["AccentColor"];
|
||||
if (accentColor == null)
|
||||
{
|
||||
var preview = new DrawingImage();
|
||||
preview.Freeze();
|
||||
KeyboardPreview = preview;
|
||||
return;
|
||||
}
|
||||
|
||||
var pen = new Pen(new SolidColorBrush((Color) accentColor), 0.4);
|
||||
|
||||
@ -198,8 +223,7 @@ namespace Artemis.ViewModels.Profiles
|
||||
var x = pos.X/((double) keyboard.PreviewSettings.Width/keyboard.Width);
|
||||
var y = pos.Y/((double) keyboard.PreviewSettings.Height/keyboard.Height);
|
||||
|
||||
var hoverLayer = SelectedProfile.GetLayers()
|
||||
.Where(l => l.MustDraw())
|
||||
var hoverLayer = GetLayers().Where(l => l.MustDraw())
|
||||
.FirstOrDefault(l => l.Properties.GetRect(1).Contains(x, y));
|
||||
|
||||
SelectedLayer = hoverLayer;
|
||||
@ -218,8 +242,7 @@ namespace Artemis.ViewModels.Profiles
|
||||
var keyboard = _deviceManager.ActiveKeyboard;
|
||||
var x = pos.X/((double) keyboard.PreviewSettings.Width/keyboard.Width);
|
||||
var y = pos.Y/((double) keyboard.PreviewSettings.Height/keyboard.Height);
|
||||
var hoverLayer = SelectedProfile.GetLayers()
|
||||
.Where(l => l.MustDraw())
|
||||
var hoverLayer = GetLayers().Where(l => l.MustDraw())
|
||||
.FirstOrDefault(l => l.Properties.GetRect(1).Contains(x, y));
|
||||
|
||||
HandleDragging(e, x, y, hoverLayer);
|
||||
@ -308,6 +331,39 @@ namespace Artemis.ViewModels.Profiles
|
||||
}
|
||||
}
|
||||
|
||||
public List<LayerModel> GetRenderLayers()
|
||||
{
|
||||
// Get the layers that must be drawn
|
||||
List<LayerModel> drawLayers;
|
||||
if (ShowAll)
|
||||
return SelectedProfile.GetRenderLayers(new ProfilePreviewDataModel(), false, true);
|
||||
|
||||
if (SelectedLayer == null)
|
||||
return new EditableList<LayerModel>();
|
||||
|
||||
if (SelectedLayer.LayerType is FolderType)
|
||||
drawLayers = SelectedLayer.GetRenderLayers(new ProfilePreviewDataModel(), false, true);
|
||||
else
|
||||
drawLayers = new List<LayerModel> {SelectedLayer};
|
||||
|
||||
return drawLayers;
|
||||
}
|
||||
|
||||
|
||||
private List<LayerModel> GetLayers()
|
||||
{
|
||||
// Get the layers that must be drawn
|
||||
List<LayerModel> drawLayers;
|
||||
if (ShowAll)
|
||||
drawLayers = SelectedProfile.GetLayers();
|
||||
else if (SelectedLayer.LayerType is FolderType)
|
||||
drawLayers = SelectedLayer.GetLayers().ToList();
|
||||
else
|
||||
drawLayers = new List<LayerModel> { SelectedLayer };
|
||||
|
||||
return drawLayers;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -9,6 +9,7 @@
|
||||
xmlns:utilities="clr-namespace:Artemis.Utilities"
|
||||
xmlns:dragDrop="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop"
|
||||
xmlns:converters="clr-namespace:Artemis.Utilities.Converters"
|
||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="510" Width="1055">
|
||||
<UserControl.Resources>
|
||||
@ -23,6 +24,7 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Preview Background="#FF232323" -->
|
||||
@ -147,7 +149,14 @@
|
||||
</StackPanel>
|
||||
|
||||
<!-- Layer list -->
|
||||
<Label Grid.Column="1" Grid.Row="0" FontSize="20" HorizontalAlignment="Left" Content="Layers" Margin="10,0,0,0" />
|
||||
<StackPanel Grid.Column="1" Grid.Row="0" Orientation="Horizontal">
|
||||
<Label FontSize="20" HorizontalAlignment="Left" Content="Layers" Margin="10,0,0,0" />
|
||||
<Label HorizontalAlignment="Right" Content="Show all" Margin="88,0,0,0" VerticalAlignment="Center" />
|
||||
<ToggleButton x:Name="ShowAll" Margin="0 3 0 0" Width="25" Height="25"
|
||||
IsChecked="{Binding Path=ProfileViewModel.ShowAll, Mode=TwoWay}"
|
||||
Style="{DynamicResource MetroCircleToggleButtonStyle}" HorizontalAlignment="Right" />
|
||||
</StackPanel>
|
||||
|
||||
<Border Grid.Column="1" Grid.Row="1" Background="#FF232323" BorderBrush="{DynamicResource HighlightBrush}"
|
||||
BorderThickness="3" Margin="10,0,0,0" Height="400" Width="233">
|
||||
<TreeView x:Name="ProfileTree"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user