mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 09:43:46 +00:00
Drag and drop polish
This commit is contained in:
parent
cc10f46e63
commit
d9ab9d5af3
@ -6,19 +6,27 @@ using Artemis.Utilities;
|
|||||||
using CUE.NET;
|
using CUE.NET;
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
using CUE.NET.Devices.Generic.Enums;
|
||||||
using CUE.NET.Exceptions;
|
using CUE.NET.Exceptions;
|
||||||
|
using Ninject.Extensions.Logging;
|
||||||
|
|
||||||
namespace Artemis.DeviceProviders.Corsair
|
namespace Artemis.DeviceProviders.Corsair
|
||||||
{
|
{
|
||||||
internal class CorsairMice : DeviceProvider
|
internal class CorsairMice : DeviceProvider
|
||||||
{
|
{
|
||||||
public CorsairMice()
|
public ILogger Logger { get; set; }
|
||||||
|
|
||||||
|
public CorsairMice(ILogger logger)
|
||||||
{
|
{
|
||||||
|
Logger = logger;
|
||||||
Type = DeviceType.Mouse;
|
Type = DeviceType.Mouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool TryEnable()
|
public override bool TryEnable()
|
||||||
{
|
{
|
||||||
CanUse = CanInitializeSdk();
|
CanUse = CanInitializeSdk();
|
||||||
|
if (CanUse)
|
||||||
|
CueSDK.MouseSDK.UpdateMode = UpdateMode.Manual;
|
||||||
|
|
||||||
|
Logger.Debug("Attempted to enable Corsair mice. CanUse: {0}", CanUse);
|
||||||
return CanUse;
|
return CanUse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +42,7 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var leds = CueSDK.MouseSDK.Leds.Count();
|
var leds = CueSDK.MouseSDK.Leds.Count();
|
||||||
var rect = new Rect(new Size(leds*5, leds*5));
|
var rect = new Rect(new Size(leds*20, leds* 20));
|
||||||
var img = brush.Dispatcher.Invoke(() =>
|
var img = brush.Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
var visual = new DrawingVisual();
|
var visual = new DrawingVisual();
|
||||||
@ -47,9 +55,12 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
// Color each LED according to one of the pixels
|
// Color each LED according to one of the pixels
|
||||||
foreach (var corsairLed in CueSDK.MouseSDK.Leds)
|
foreach (var corsairLed in CueSDK.MouseSDK.Leds)
|
||||||
{
|
{
|
||||||
corsairLed.Color = img.GetPixel(ledIndex*5, ledIndex*5);
|
corsairLed.Color = ledIndex == 0
|
||||||
|
? img.GetPixel(0, 0)
|
||||||
|
: img.GetPixel((ledIndex + 1) * 20 - 1, (ledIndex + 1) * 20 - 1);
|
||||||
ledIndex++;
|
ledIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
CueSDK.MouseSDK.Update(true);
|
CueSDK.MouseSDK.Update(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -70,22 +70,22 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
case "K95 RGB":
|
case "K95 RGB":
|
||||||
Height = 7;
|
Height = 7;
|
||||||
Width = 25;
|
Width = 25;
|
||||||
PreviewSettings = new PreviewSettings(626, 175, new Thickness(0, -15, 0, 0), Resources.k95);
|
PreviewSettings = new PreviewSettings(676, 190, new Thickness(0, -15, 0, 0), Resources.k95);
|
||||||
break;
|
break;
|
||||||
case "K70 RGB":
|
case "K70 RGB":
|
||||||
Height = 7;
|
Height = 7;
|
||||||
Width = 21;
|
Width = 21;
|
||||||
PreviewSettings = new PreviewSettings(626, 195, new Thickness(0, -25, 0, 0), Resources.k70);
|
PreviewSettings = new PreviewSettings(676, 195, new Thickness(0, -25, 0, 0), Resources.k70);
|
||||||
break;
|
break;
|
||||||
case "K65 RGB":
|
case "K65 RGB":
|
||||||
Height = 7;
|
Height = 7;
|
||||||
Width = 18;
|
Width = 18;
|
||||||
PreviewSettings = new PreviewSettings(610, 240, new Thickness(0, -30, 0, 0), Resources.k65);
|
PreviewSettings = new PreviewSettings(660, 240, new Thickness(0, -30, 0, 0), Resources.k65);
|
||||||
break;
|
break;
|
||||||
case "STRAFE RGB":
|
case "STRAFE RGB":
|
||||||
Height = 6;
|
Height = 6;
|
||||||
Width = 22;
|
Width = 22;
|
||||||
PreviewSettings = new PreviewSettings(620, 215, new Thickness(0, -15, 0, 0), Resources.strafe);
|
PreviewSettings = new PreviewSettings(670, 215, new Thickness(0, -15, 0, 0), Resources.strafe);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,19 +6,27 @@ using Artemis.Utilities;
|
|||||||
using CUE.NET;
|
using CUE.NET;
|
||||||
using CUE.NET.Devices.Generic.Enums;
|
using CUE.NET.Devices.Generic.Enums;
|
||||||
using CUE.NET.Exceptions;
|
using CUE.NET.Exceptions;
|
||||||
|
using Ninject.Extensions.Logging;
|
||||||
|
|
||||||
namespace Artemis.DeviceProviders.Corsair
|
namespace Artemis.DeviceProviders.Corsair
|
||||||
{
|
{
|
||||||
internal class CorsairHeadsets : DeviceProvider
|
internal class CorsairHeadsets : DeviceProvider
|
||||||
{
|
{
|
||||||
public CorsairHeadsets()
|
public CorsairHeadsets(ILogger logger)
|
||||||
{
|
{
|
||||||
|
Logger = logger;
|
||||||
Type = DeviceType.Headset;
|
Type = DeviceType.Headset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ILogger Logger { get; set; }
|
||||||
|
|
||||||
public override bool TryEnable()
|
public override bool TryEnable()
|
||||||
{
|
{
|
||||||
CanUse = CanInitializeSdk();
|
CanUse = CanInitializeSdk();
|
||||||
|
if (CanUse)
|
||||||
|
CueSDK.HeadsetSDK.UpdateMode = UpdateMode.Manual;
|
||||||
|
|
||||||
|
Logger.Debug("Attempted to enable Corsair headset. CanUse: {0}", CanUse);
|
||||||
return CanUse;
|
return CanUse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +42,7 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var leds = CueSDK.HeadsetSDK.Leds.Count();
|
var leds = CueSDK.HeadsetSDK.Leds.Count();
|
||||||
var rect = new Rect(new Size(leds * 5, leds * 5));
|
var rect = new Rect(new Size(leds*20, leds*20));
|
||||||
var img = brush.Dispatcher.Invoke(() =>
|
var img = brush.Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
var visual = new DrawingVisual();
|
var visual = new DrawingVisual();
|
||||||
@ -47,7 +55,9 @@ namespace Artemis.DeviceProviders.Corsair
|
|||||||
// Color each LED according to one of the pixels
|
// Color each LED according to one of the pixels
|
||||||
foreach (var corsairLed in CueSDK.HeadsetSDK.Leds)
|
foreach (var corsairLed in CueSDK.HeadsetSDK.Leds)
|
||||||
{
|
{
|
||||||
corsairLed.Color = img.GetPixel(ledIndex * 5, ledIndex * 5);
|
corsairLed.Color = ledIndex == 0
|
||||||
|
? img.GetPixel(0, 0)
|
||||||
|
: img.GetPixel((ledIndex + 1)*20 - 1, (ledIndex + 1)*20 - 1);
|
||||||
ledIndex++;
|
ledIndex++;
|
||||||
}
|
}
|
||||||
CueSDK.HeadsetSDK.Update(true);
|
CueSDK.HeadsetSDK.Update(true);
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|||||||
@ -74,7 +74,12 @@ namespace Artemis.Models.Profiles.Properties
|
|||||||
|
|
||||||
private void ApplyHeight(KeyboardPropertiesModel properties, double percentage)
|
private void ApplyHeight(KeyboardPropertiesModel properties, double percentage)
|
||||||
{
|
{
|
||||||
properties.Height = percentage*properties.Height;
|
var newHeight = percentage*properties.Height;
|
||||||
|
var difference = properties.Height - newHeight;
|
||||||
|
properties.Height = newHeight;
|
||||||
|
|
||||||
|
if (LayerPropertyOptions == LayerPropertyOptions.Downwards)
|
||||||
|
properties.Y = properties.Y + difference;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyOpacity(KeyboardPropertiesModel properties, double percentage)
|
private void ApplyOpacity(KeyboardPropertiesModel properties, double percentage)
|
||||||
|
|||||||
@ -14,7 +14,7 @@ namespace Artemis.Utilities.Layers
|
|||||||
if (animateProperties.Animation == LayerAnimation.SlideRight ||
|
if (animateProperties.Animation == LayerAnimation.SlideRight ||
|
||||||
animateProperties.Animation == LayerAnimation.SlideLeft)
|
animateProperties.Animation == LayerAnimation.SlideLeft)
|
||||||
{
|
{
|
||||||
if (progress > animateProperties.Width*scale)
|
if (progress + 1 >= animateProperties.Width*scale)
|
||||||
progress = 0;
|
progress = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ namespace Artemis.Utilities.Layers
|
|||||||
if (animateProperties.Animation == LayerAnimation.SlideDown ||
|
if (animateProperties.Animation == LayerAnimation.SlideDown ||
|
||||||
animateProperties.Animation == LayerAnimation.SlideUp)
|
animateProperties.Animation == LayerAnimation.SlideUp)
|
||||||
{
|
{
|
||||||
if (progress > animateProperties.Height*scale)
|
if (progress + 1 >= animateProperties.Height*scale)
|
||||||
progress = 0;
|
progress = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -154,13 +154,13 @@ namespace Artemis.ViewModels
|
|||||||
|
|
||||||
public void DragOver(IDropInfo dropInfo)
|
public void DragOver(IDropInfo dropInfo)
|
||||||
{
|
{
|
||||||
var sourceItem = dropInfo.Data as LayerModel;
|
var source = dropInfo.Data as LayerModel;
|
||||||
var targetItem = dropInfo.TargetItem as LayerModel;
|
var target = dropInfo.TargetItem as LayerModel;
|
||||||
if (sourceItem == null || targetItem == null)
|
if (source == null || target == null || source == target)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (dropInfo.InsertPosition == RelativeInsertPosition.TargetItemCenter &&
|
if (dropInfo.InsertPosition == RelativeInsertPosition.TargetItemCenter &&
|
||||||
targetItem.LayerType == LayerType.Folder)
|
target.LayerType == LayerType.Folder)
|
||||||
{
|
{
|
||||||
dropInfo.DropTargetAdorner = typeof(DropTargetMetroHighlightAdorner);
|
dropInfo.DropTargetAdorner = typeof(DropTargetMetroHighlightAdorner);
|
||||||
dropInfo.Effects = DragDropEffects.Copy;
|
dropInfo.Effects = DragDropEffects.Copy;
|
||||||
@ -174,42 +174,45 @@ namespace Artemis.ViewModels
|
|||||||
|
|
||||||
public void Drop(IDropInfo dropInfo)
|
public void Drop(IDropInfo dropInfo)
|
||||||
{
|
{
|
||||||
var sourceItem = dropInfo.Data as LayerModel;
|
var source = dropInfo.Data as LayerModel;
|
||||||
var targetItem = dropInfo.TargetItem as LayerModel;
|
var target = dropInfo.TargetItem as LayerModel;
|
||||||
if (sourceItem == null || targetItem == null || sourceItem == targetItem)
|
if (source == null || target == null || source == target)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (dropInfo.InsertPosition == RelativeInsertPosition.TargetItemCenter &&
|
// Don't allow a folder to become it's own child, that's just weird
|
||||||
targetItem.LayerType == LayerType.Folder)
|
if (target.Parent == source)
|
||||||
{
|
|
||||||
// Insert into folder
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// Remove the source from it's old profile/parent
|
// Remove the source from it's old profile/parent
|
||||||
if (sourceItem.Parent == null)
|
if (source.Parent == null)
|
||||||
sourceItem.Profile.Layers.Remove(sourceItem);
|
source.Profile.Layers.Remove(source);
|
||||||
else
|
else
|
||||||
sourceItem.Parent.Children.Remove(sourceItem);
|
source.Parent.Children.Remove(source);
|
||||||
|
|
||||||
// Insert the source into it's new profile/parent and update the order
|
if (dropInfo.InsertPosition == RelativeInsertPosition.TargetItemCenter &&
|
||||||
if (dropInfo.InsertPosition == RelativeInsertPosition.AfterTargetItem)
|
target.LayerType == LayerType.Folder)
|
||||||
sourceItem.Order = targetItem.Order + 1;
|
|
||||||
else
|
|
||||||
sourceItem.Order = targetItem.Order - 1;
|
|
||||||
if (targetItem.Parent == null)
|
|
||||||
{
|
{
|
||||||
targetItem.Profile.Layers.Add(sourceItem);
|
// Insert into folder
|
||||||
targetItem.Profile.FixOrder();
|
source.Order = -1;
|
||||||
|
target.Children.Add(source);
|
||||||
|
target.FixOrder();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
targetItem.Parent.Children.Add(sourceItem);
|
// Insert the source into it's new profile/parent and update the order
|
||||||
targetItem.Parent.FixOrder();
|
if (dropInfo.InsertPosition == RelativeInsertPosition.AfterTargetItem)
|
||||||
|
source.Order = target.Order + 1;
|
||||||
|
else
|
||||||
|
source.Order = target.Order - 1;
|
||||||
|
if (target.Parent == null)
|
||||||
|
target.Profile.Layers.Add(source);
|
||||||
|
else
|
||||||
|
target.Parent.Children.Add(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateLayerList(sourceItem);
|
target.Profile?.FixOrder();
|
||||||
|
target.Parent?.FixOrder();
|
||||||
|
UpdateLayerList(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -424,7 +427,6 @@ namespace Artemis.ViewModels
|
|||||||
var y = pos.Y/((double) ActiveKeyboard.PreviewSettings.Height/ActiveKeyboard.Height);
|
var y = pos.Y/((double) ActiveKeyboard.PreviewSettings.Height/ActiveKeyboard.Height);
|
||||||
|
|
||||||
var hoverLayer = SelectedProfile.GetEnabledLayers()
|
var hoverLayer = SelectedProfile.GetEnabledLayers()
|
||||||
.OrderBy(l => l.Order)
|
|
||||||
.Where(l => l.MustDraw())
|
.Where(l => l.MustDraw())
|
||||||
.FirstOrDefault(l => ((KeyboardPropertiesModel) l.Properties)
|
.FirstOrDefault(l => ((KeyboardPropertiesModel) l.Properties)
|
||||||
.GetRect(1)
|
.GetRect(1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user