mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 01:42:02 +00:00
Add layer copy paste across profiles with Ctrl+C/Ctrl+V for #194
This commit is contained in:
parent
e8e6e084a7
commit
650e506266
@ -653,7 +653,6 @@
|
|||||||
<Compile Include="Utilities\Converters\NinjectCustomConverter.cs" />
|
<Compile Include="Utilities\Converters\NinjectCustomConverter.cs" />
|
||||||
<Compile Include="Utilities\Converters\ValueConverters.cs" />
|
<Compile Include="Utilities\Converters\ValueConverters.cs" />
|
||||||
<Compile Include="Utilities\DataReaders\DllManager.cs" />
|
<Compile Include="Utilities\DataReaders\DllManager.cs" />
|
||||||
<Compile Include="Utilities\EditorHelper.cs" />
|
|
||||||
<Compile Include="Utilities\ExtensionMethods.cs" />
|
<Compile Include="Utilities\ExtensionMethods.cs" />
|
||||||
<Compile Include="Utilities\GameState\GameDataReceivedEventArgs.cs" />
|
<Compile Include="Utilities\GameState\GameDataReceivedEventArgs.cs" />
|
||||||
<Compile Include="Utilities\GameState\GameStateWebServer.cs" />
|
<Compile Include="Utilities\GameState\GameStateWebServer.cs" />
|
||||||
|
|||||||
@ -59,7 +59,7 @@ namespace Artemis.DeviceProviders.CoolerMaster
|
|||||||
using (var b = ImageUtilities.ResizeImage(bitmap, Width, Height))
|
using (var b = ImageUtilities.ResizeImage(bitmap, Width, Height))
|
||||||
{
|
{
|
||||||
// Create an empty matrix
|
// Create an empty matrix
|
||||||
var matrix = new COLOR_MATRIX { KeyColor = new KEY_COLOR[6, 22] };
|
var matrix = new COLOR_MATRIX {KeyColor = new KEY_COLOR[6, 22]};
|
||||||
|
|
||||||
// Map the bytes to the matix
|
// Map the bytes to the matix
|
||||||
for (var x = 0; x < Width; x++)
|
for (var x = 0; x < Width; x++)
|
||||||
|
|||||||
@ -195,7 +195,12 @@ namespace Artemis.Profiles
|
|||||||
|
|
||||||
public void Deactivate(LuaManager luaManager)
|
public void Deactivate(LuaManager luaManager)
|
||||||
{
|
{
|
||||||
KeybindManager.Clear();
|
foreach (var layerModel in Layers)
|
||||||
|
{
|
||||||
|
for (var index = 0; index < layerModel.Properties.Conditions.Count; index++)
|
||||||
|
KeybindManager.Remove($"{GameName}-{Name}-{layerModel.Name}-{index}");
|
||||||
|
}
|
||||||
|
|
||||||
luaManager.ClearLua();
|
luaManager.ClearLua();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,6 +225,7 @@ namespace Artemis.Profiles
|
|||||||
public void ApplyKeybinds()
|
public void ApplyKeybinds()
|
||||||
{
|
{
|
||||||
foreach (var layerModel in Layers)
|
foreach (var layerModel in Layers)
|
||||||
|
{
|
||||||
for (var index = 0; index < layerModel.Properties.Conditions.Count; index++)
|
for (var index = 0; index < layerModel.Properties.Conditions.Count; index++)
|
||||||
{
|
{
|
||||||
var condition = layerModel.Properties.Conditions[index];
|
var condition = layerModel.Properties.Conditions[index];
|
||||||
@ -231,6 +237,7 @@ namespace Artemis.Profiles
|
|||||||
var kb = new KeybindModel($"{GameName}-{Name}-{layerModel.Name}-{index}", condition.HotKey, action);
|
var kb = new KeybindModel($"{GameName}-{Name}-{layerModel.Name}-{index}", condition.HotKey, action);
|
||||||
KeybindManager.AddOrUpdate(kb);
|
KeybindManager.AddOrUpdate(kb);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Compare
|
#region Compare
|
||||||
|
|||||||
@ -53,7 +53,7 @@ using System.Windows;
|
|||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
|
||||||
[assembly: AssemblyVersion("1.8.1.0")]
|
[assembly: AssemblyVersion("1.8.2.0")]
|
||||||
[assembly: AssemblyFileVersion("1.8.1.0")]
|
[assembly: AssemblyFileVersion("1.8.2.0")]
|
||||||
[assembly: InternalsVisibleTo("Artemis.Explorables")]
|
[assembly: InternalsVisibleTo("Artemis.Explorables")]
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Artemis.Utilities
|
|
||||||
{
|
|
||||||
public static class EditorHelper
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -4,6 +4,8 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Windows;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using static System.String;
|
using static System.String;
|
||||||
@ -126,5 +128,13 @@ namespace Artemis.Utilities
|
|||||||
public List<PropertyCollection> Children { get; set; }
|
public List<PropertyCollection> Children { get; set; }
|
||||||
public string DisplayType { get; set; }
|
public string DisplayType { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ExecuteSta(Action action)
|
||||||
|
{
|
||||||
|
var thread = new Thread(action.Invoke);
|
||||||
|
thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA
|
||||||
|
thread.Start();
|
||||||
|
thread.Join();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -28,9 +28,12 @@ using Caliburn.Micro;
|
|||||||
using Castle.Components.DictionaryAdapter;
|
using Castle.Components.DictionaryAdapter;
|
||||||
using GongSolutions.Wpf.DragDrop;
|
using GongSolutions.Wpf.DragDrop;
|
||||||
using MahApps.Metro;
|
using MahApps.Metro;
|
||||||
|
using MahApps.Metro.Controls;
|
||||||
using MahApps.Metro.Controls.Dialogs;
|
using MahApps.Metro.Controls.Dialogs;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using NuGet;
|
using NuGet;
|
||||||
using Application = System.Windows.Application;
|
using Application = System.Windows.Application;
|
||||||
|
using Clipboard = System.Windows.Clipboard;
|
||||||
using Cursor = System.Windows.Input.Cursor;
|
using Cursor = System.Windows.Input.Cursor;
|
||||||
using Cursors = System.Windows.Input.Cursors;
|
using Cursors = System.Windows.Input.Cursors;
|
||||||
using DragDropEffects = System.Windows.DragDropEffects;
|
using DragDropEffects = System.Windows.DragDropEffects;
|
||||||
@ -44,6 +47,8 @@ namespace Artemis.ViewModels
|
|||||||
{
|
{
|
||||||
private readonly DeviceManager _deviceManager;
|
private readonly DeviceManager _deviceManager;
|
||||||
private readonly MetroDialogService _dialogService;
|
private readonly MetroDialogService _dialogService;
|
||||||
|
private KeybindModel _copyKeybind;
|
||||||
|
private KeybindModel _pasteKeybind;
|
||||||
private readonly LoopManager _loopManager;
|
private readonly LoopManager _loopManager;
|
||||||
private readonly ModuleModel _moduleModel;
|
private readonly ModuleModel _moduleModel;
|
||||||
private ImageSource _keyboardPreview;
|
private ImageSource _keyboardPreview;
|
||||||
@ -60,6 +65,8 @@ namespace Artemis.ViewModels
|
|||||||
_loopManager = loopManager;
|
_loopManager = loopManager;
|
||||||
_moduleModel = moduleModel;
|
_moduleModel = moduleModel;
|
||||||
_dialogService = dialogService;
|
_dialogService = dialogService;
|
||||||
|
_copyKeybind = new KeybindModel("copy", new HotKey(Key.C, ModifierKeys.Control), LayerToClipboard);
|
||||||
|
_pasteKeybind = new KeybindModel("paste", new HotKey(Key.V, ModifierKeys.Control), ClipboardToLayer);
|
||||||
|
|
||||||
ProfileNames = new ObservableCollection<string>();
|
ProfileNames = new ObservableCollection<string>();
|
||||||
Layers = new ObservableCollection<LayerModel>();
|
Layers = new ObservableCollection<LayerModel>();
|
||||||
@ -69,6 +76,7 @@ namespace Artemis.ViewModels
|
|||||||
PropertyChanged += EditorStateHandler;
|
PropertyChanged += EditorStateHandler;
|
||||||
_deviceManager.OnKeyboardChanged += DeviceManagerOnOnKeyboardChanged;
|
_deviceManager.OnKeyboardChanged += DeviceManagerOnOnKeyboardChanged;
|
||||||
_moduleModel.ProfileChanged += ModuleModelOnProfileChanged;
|
_moduleModel.ProfileChanged += ModuleModelOnProfileChanged;
|
||||||
|
|
||||||
LoadProfiles();
|
LoadProfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,6 +85,8 @@ namespace Artemis.ViewModels
|
|||||||
base.OnActivate();
|
base.OnActivate();
|
||||||
|
|
||||||
_loopManager.RenderCompleted += LoopManagerOnRenderCompleted;
|
_loopManager.RenderCompleted += LoopManagerOnRenderCompleted;
|
||||||
|
KeybindManager.AddOrUpdate(_copyKeybind);
|
||||||
|
KeybindManager.AddOrUpdate(_pasteKeybind);
|
||||||
}
|
}
|
||||||
|
|
||||||
public new void OnDeactivate(bool close)
|
public new void OnDeactivate(bool close)
|
||||||
@ -85,6 +95,8 @@ namespace Artemis.ViewModels
|
|||||||
|
|
||||||
SaveSelectedProfile();
|
SaveSelectedProfile();
|
||||||
_loopManager.RenderCompleted -= LoopManagerOnRenderCompleted;
|
_loopManager.RenderCompleted -= LoopManagerOnRenderCompleted;
|
||||||
|
KeybindManager.Remove(_copyKeybind);
|
||||||
|
KeybindManager.Remove(_pasteKeybind);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region LUA
|
#region LUA
|
||||||
@ -302,6 +314,38 @@ namespace Artemis.ViewModels
|
|||||||
UpdateLayerList(clone);
|
UpdateLayerList(clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LayerToClipboard()
|
||||||
|
{
|
||||||
|
if (SelectedLayer == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Probably not how the cool kids do it but leveraging on JsonConvert gives flawless serialization
|
||||||
|
GeneralHelpers.ExecuteSta(() => Clipboard.SetData("layer", JsonConvert.SerializeObject(SelectedLayer)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ClipboardToLayer()
|
||||||
|
{
|
||||||
|
GeneralHelpers.ExecuteSta(() =>
|
||||||
|
{
|
||||||
|
var data = (string) Clipboard.GetData("layer");
|
||||||
|
if (data == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var layerModel = JsonConvert.DeserializeObject<LayerModel>(data);
|
||||||
|
if (layerModel == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (SelectedLayer != null)
|
||||||
|
SelectedLayer.InsertAfter(layerModel);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SelectedProfile.Layers.Add(layerModel);
|
||||||
|
SelectedProfile.FixOrder();
|
||||||
|
}
|
||||||
|
Execute.OnUIThread(() => UpdateLayerList(layerModel));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateLayerList(LayerModel selectModel)
|
private void UpdateLayerList(LayerModel selectModel)
|
||||||
{
|
{
|
||||||
// Update the UI
|
// Update the UI
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user