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

You can now see selected layers that are behind other layers. Selecting a layer also selects it in the list now.

This commit is contained in:
SpoinkyNL 2016-04-18 18:21:42 +02:00
parent 8aeee846b4
commit b3ac975c5f
12 changed files with 1435 additions and 1394 deletions

View File

@ -120,10 +120,6 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup /> <PropertyGroup />
<ItemGroup> <ItemGroup>
<Reference Include="Antlr3.Runtime, Version=3.5.0.2, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
<HintPath>..\packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Autofac, Version=4.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL"> <Reference Include="Autofac, Version=4.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
<HintPath>..\packages\Autofac.4.0.0-rc1-177\lib\net45\Autofac.dll</HintPath> <HintPath>..\packages\Autofac.4.0.0-rc1-177\lib\net45\Autofac.dll</HintPath>
<Private>True</Private> <Private>True</Private>
@ -152,12 +148,8 @@
<HintPath>..\packages\CUE.NET.1.0.2.2\lib\net45\CUE.NET.dll</HintPath> <HintPath>..\packages\CUE.NET.1.0.2.2\lib\net45\CUE.NET.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="ExpressionEvaluator, Version=2.0.4.0, Culture=neutral, PublicKeyToken=90d9f15d622e2348, processorArchitecture=MSIL">
<HintPath>..\packages\ExpressionEvaluator.2.0.4.0\lib\net40\ExpressionEvaluator.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Hardcodet.Wpf.TaskbarNotification, Version=1.0.5.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Hardcodet.Wpf.TaskbarNotification, Version=1.0.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Hardcodet.NotifyIcon.Wpf.1.0.5\lib\net451\Hardcodet.Wpf.TaskbarNotification.dll</HintPath> <HintPath>..\packages\Hardcodet.NotifyIcon.Wpf.1.0.8\lib\net451\Hardcodet.Wpf.TaskbarNotification.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Kaliko.ImageLibrary, Version=2.0.4.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Kaliko.ImageLibrary, Version=2.0.4.0, Culture=neutral, processorArchitecture=MSIL">
@ -180,11 +172,7 @@
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Screna, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Screna.0.1.3\lib\Screna.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="SharpDX, Version=3.0.2.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL"> <Reference Include="SharpDX, Version=3.0.2.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
@ -231,28 +219,28 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
<Reference Include="Xceed.Wpf.AvalonDock, Version=2.6.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL"> <Reference Include="Xceed.Wpf.AvalonDock, Version=2.7.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.AvalonDock.dll</HintPath> <HintPath>..\packages\Extended.Wpf.Toolkit.2.7\lib\net40\Xceed.Wpf.AvalonDock.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Aero, Version=2.6.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL"> <Reference Include="Xceed.Wpf.AvalonDock.Themes.Aero, Version=2.7.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll</HintPath> <HintPath>..\packages\Extended.Wpf.Toolkit.2.7\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Metro, Version=2.6.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL"> <Reference Include="Xceed.Wpf.AvalonDock.Themes.Metro, Version=2.7.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll</HintPath> <HintPath>..\packages\Extended.Wpf.Toolkit.2.7\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Xceed.Wpf.AvalonDock.Themes.VS2010, Version=2.6.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL"> <Reference Include="Xceed.Wpf.AvalonDock.Themes.VS2010, Version=2.7.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll</HintPath> <HintPath>..\packages\Extended.Wpf.Toolkit.2.7\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Xceed.Wpf.DataGrid, Version=2.6.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL"> <Reference Include="Xceed.Wpf.DataGrid, Version=2.7.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.DataGrid.dll</HintPath> <HintPath>..\packages\Extended.Wpf.Toolkit.2.7\lib\net40\Xceed.Wpf.DataGrid.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Xceed.Wpf.Toolkit, Version=2.6.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL"> <Reference Include="Xceed.Wpf.Toolkit, Version=2.7.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath> <HintPath>..\packages\Extended.Wpf.Toolkit.2.7\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
@ -538,14 +526,13 @@
<None Include="packages.config" /> <None Include="packages.config" />
<AppDesigner Include="Properties\" /> <AppDesigner Include="Properties\" />
<Resource Include="Resources\bow.png" /> <Resource Include="Resources\bow.png" />
<Resource Include="Resources\WindowsIcons-license.txt" />
<Resource Include="Resources\Entypo-license.txt" />
<Content Include="logo.ico"> <Content Include="logo.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Resource Include="Resources\logo.ico" /> <Resource Include="Resources\logo.ico" />
<Resource Include="Resources\logo-disabled.ico" /> <Resource Include="Resources\logo-disabled.ico" />
<Resource Include="Resources\Dota2\dotaGamestateConfiguration.txt" /> <Resource Include="Resources\Dota2\dotaGamestateConfiguration.txt" />
<Resource Include="Resources\Entypo.ttf" />
<None Include="Resources\LogitechLED.dll" /> <None Include="Resources\LogitechLED.dll" />
<None Include="Resources\folder.png" /> <None Include="Resources\folder.png" />
<Resource Include="Resources\Keyboards\k65.png" /> <Resource Include="Resources\Keyboards\k65.png" />
@ -553,9 +540,10 @@
<Resource Include="Resources\Keyboards\k95.png" /> <Resource Include="Resources\Keyboards\k95.png" />
<Resource Include="Resources\Keyboards\strafe.png" /> <Resource Include="Resources\Keyboards\strafe.png" />
<Resource Include="Resources\Keyboards\g910.png" /> <Resource Include="Resources\Keyboards\g910.png" />
<Resource Include="Resources\WindowsIcons-license.txt" />
<Resource Include="Resources\Entypo-license.txt" />
<Content Include="Resources\Witcher3\playerWitcher.txt" /> <Content Include="Resources\Witcher3\playerWitcher.txt" />
<Content Include="Resources\Witcher3\artemis.txt" /> <Content Include="Resources\Witcher3\artemis.txt" />
<Resource Include="Resources\Entypo.ttf" />
<None Include="Settings\Offsets.settings"> <None Include="Settings\Offsets.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Offsets.Designer.cs</LastGenOutput> <LastGenOutput>Offsets.Designer.cs</LastGenOutput>

View File

@ -37,13 +37,13 @@ namespace Artemis.ItemBehaviours
set { SetValue(SelectedItemProperty, value); } set { SetValue(SelectedItemProperty, value); }
} }
public static readonly DependencyProperty SelectedItemProperty = public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register("SelectedItem",
DependencyProperty.Register("SelectedItem", typeof (object), typeof (BindableSelectedItemBehavior), typeof (object), typeof (BindableSelectedItemBehavior), new UIPropertyMetadata(null, OnSelectedItemChanged));
new UIPropertyMetadata(null, OnSelectedItemChanged));
private static void OnSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) private static void OnSelectedItemChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{ {
var item = e.NewValue as TreeViewItem; var item = ((BindableSelectedItemBehavior) sender).AssociatedObject
.ItemContainerGenerator.ContainerFromItem(e.NewValue) as TreeViewItem;
item?.SetValue(TreeViewItem.IsSelectedProperty, true); item?.SetValue(TreeViewItem.IsSelectedProperty, true);
} }

View File

@ -50,8 +50,8 @@ namespace Artemis.Managers
GameStateWebServer.Start(); GameStateWebServer.Start();
// Start the named pipe // Start the named pipe
//PipeServer = new PipeServer(); PipeServer = new PipeServer();
//PipeServer.Start("artemis"); PipeServer.Start("artemis");
} }
public PipeServer PipeServer { get; set; } public PipeServer PipeServer { get; set; }

View File

@ -11,7 +11,7 @@ namespace Artemis.Models.Profiles
public class LayerModel public class LayerModel
{ {
[XmlIgnore] private readonly LayerDrawer _drawer; [XmlIgnore] private readonly LayerDrawer _drawer;
private bool _mustDraw; [XmlIgnore] private bool _mustDraw;
public LayerModel() public LayerModel()
{ {

View File

@ -1,5 +1,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Media; using System.Windows.Media;
using System.Xml.Serialization;
using Artemis.Utilities;
using CUE.NET.Helper;
namespace Artemis.Models.Profiles namespace Artemis.Models.Profiles
{ {
@ -42,5 +45,32 @@ namespace Artemis.Models.Profiles
return hashCode; return hashCode;
} }
} }
/// <summary>
/// Adds a new layer with default settings to the profile
/// </summary>
/// <returns>The newly added layer</returns>
public LayerModel AddLayer()
{
var layer = new LayerModel
{
Name = "New layer",
Enabled = true,
LayerType = LayerType.KeyboardRectangle,
UserProps = new LayerPropertiesModel
{
Brush = new SolidColorBrush(ColorHelpers.GetRandomRainbowMediaColor()),
Animation = LayerAnimation.None,
Height = 1,
Width = 1,
X = 0,
Y = 0,
Opacity = 1
}
};
Layers.Add(layer);
return layer;
}
} }
} }

View File

@ -89,8 +89,6 @@ namespace Artemis.Modules.Games.CounterStrike
if (!jsonString.Contains("Counter-Strike: Global Offensive")) if (!jsonString.Contains("Counter-Strike: Global Offensive"))
return; return;
Debug.WriteLine("Received data");
// Parse the JSON // Parse the JSON
GameDataModel = JsonConvert.DeserializeObject<CounterStrikeDataModel>(jsonString); GameDataModel = JsonConvert.DeserializeObject<CounterStrikeDataModel>(jsonString);
} }

View File

@ -1,4 +1,5 @@
using System.IO; using System.ComponentModel;
using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using Artemis.Managers; using Artemis.Managers;
using Artemis.Properties; using Artemis.Properties;
@ -22,10 +23,16 @@ namespace Artemis.Modules.Games.CounterStrike
PlaceConfigFile(); PlaceConfigFile();
ProfileEditor = new ProfileEditorViewModel<CounterStrikeDataModel>(MainManager, GameModel); ProfileEditor = new ProfileEditorViewModel<CounterStrikeDataModel>(MainManager, GameModel);
ProfileEditor.PropertyChanged += ProfileUpdater;
GameModel.Profile = ProfileEditor.SelectedProfile; GameModel.Profile = ProfileEditor.SelectedProfile;
} }
private void ProfileUpdater(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "SelectedProfile")
GameModel.Profile = ProfileEditor.SelectedProfile;
}
public ProfileEditorViewModel<CounterStrikeDataModel> ProfileEditor { get; set; } public ProfileEditorViewModel<CounterStrikeDataModel> ProfileEditor { get; set; }
public static string Name => "CS:GO"; public static string Name => "CS:GO";

File diff suppressed because one or more lines are too long

View File

@ -28,6 +28,23 @@ namespace Artemis.Utilities
return returnColor; return returnColor;
} }
public static System.Windows.Media.Color GetRandomRainbowMediaColor()
{
var colors = new List<byte>();
var rand = new Random();
for (var i = 0; i < 3; i++)
colors.Add((byte) rand.Next(0, 256));
var highest = colors.Max();
var lowest = colors.Min();
colors[colors.FindIndex(c => c == highest)] = 255;
colors[colors.FindIndex(c => c == lowest)] = 0;
var returnColor = System.Windows.Media.Color.FromArgb(255, colors[0], colors[1], colors[2]);
return returnColor;
}
public static Color ShiftColor(Color c, int shiftAmount) public static Color ShiftColor(Color c, int shiftAmount)
{ {
int newRed = c.R; int newRed = c.R;

View File

@ -30,8 +30,8 @@ namespace Artemis.ViewModels
private LayerEditorViewModel<T> _editorVm; private LayerEditorViewModel<T> _editorVm;
private Cursor _keyboardPreviewCursor; private Cursor _keyboardPreviewCursor;
private BindableCollection<LayerModel> _layers; private BindableCollection<LayerModel> _layers;
private BindableCollection<ProfileModel> _profileModels; private BindableCollection<ProfileModel> _profiles;
private bool _resizeSourceRect; private bool _resizing;
private LayerModel _selectedLayer; private LayerModel _selectedLayer;
private ProfileModel _selectedProfile; private ProfileModel _selectedProfile;
@ -40,7 +40,7 @@ namespace Artemis.ViewModels
_mainManager = mainManager; _mainManager = mainManager;
_gameModel = gameModel; _gameModel = gameModel;
ProfileModels = new BindableCollection<ProfileModel>(); Profiles = new BindableCollection<ProfileModel>();
Layers = new BindableCollection<LayerModel>(); Layers = new BindableCollection<LayerModel>();
_mainManager.Events.Subscribe(this); _mainManager.Events.Subscribe(this);
@ -48,14 +48,14 @@ namespace Artemis.ViewModels
LoadProfiles(); LoadProfiles();
} }
public BindableCollection<ProfileModel> ProfileModels public BindableCollection<ProfileModel> Profiles
{ {
get { return _profileModels; } get { return _profiles; }
set set
{ {
if (Equals(value, _profileModels)) return; if (Equals(value, _profiles)) return;
_profileModels = value; _profiles = value;
NotifyOfPropertyChange(() => ProfileModels); NotifyOfPropertyChange(() => Profiles);
} }
} }
@ -101,7 +101,7 @@ namespace Artemis.ViewModels
{ {
get get
{ {
if (_selectedProfile == null) if (_selectedProfile == null || ActiveKeyboard == null)
return null; return null;
var keyboardRect = ActiveKeyboard.KeyboardRectangle(4); var keyboardRect = ActiveKeyboard.KeyboardRectangle(4);
@ -112,18 +112,21 @@ namespace Artemis.ViewModels
drawingContext.PushClip(new RectangleGeometry(keyboardRect)); drawingContext.PushClip(new RectangleGeometry(keyboardRect));
drawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), null, keyboardRect); drawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), null, keyboardRect);
// Get the selection color // Draw the layers
var penColor = (Color)ThemeManager.DetectAppStyle(Application.Current).Item2.Resources["AccentColor"];
var pen = new Pen(new SolidColorBrush(penColor), 0.4);
// Draw the layer
foreach (var layerModel in _selectedProfile.Layers) foreach (var layerModel in _selectedProfile.Layers)
{
layerModel.DrawPreview(drawingContext); layerModel.DrawPreview(drawingContext);
if (layerModel != SelectedLayer || !layerModel.Enabled)
continue;
var layerRect = layerModel.UserProps.GetRect(); // Get the selection color
var color = (Color) ThemeManager.DetectAppStyle(Application.Current).Item2.Resources["AccentColor"];
var pen = new Pen(new SolidColorBrush(color), 0.4);
// Draw the selection outline and resize indicator
if (SelectedLayer != null && SelectedLayer.Enabled)
{
var layerRect = SelectedLayer.UserProps.GetRect();
// Deflate the rect so that the border is drawn on the inside
layerRect.Inflate(-0.2, -0.2);
// Draw an outline around the selected layer // Draw an outline around the selected layer
drawingContext.DrawRectangle(null, pen, layerRect); drawingContext.DrawRectangle(null, pen, layerRect);
// Draw a resize indicator in the bottom-right // Draw a resize indicator in the bottom-right
@ -153,7 +156,7 @@ namespace Artemis.ViewModels
{ {
using (var memory = new MemoryStream()) using (var memory = new MemoryStream())
{ {
if (ActiveKeyboard?.PreviewSettings == null || ActiveKeyboard?.PreviewSettings.Image == null) if (ActiveKeyboard?.PreviewSettings.Image == null)
return null; return null;
ActiveKeyboard.PreviewSettings.Image.Save(memory, ImageFormat.Png); ActiveKeyboard.PreviewSettings.Image.Save(memory, ImageFormat.Png);
memory.Position = 0; memory.Position = 0;
@ -194,23 +197,21 @@ namespace Artemis.ViewModels
private void PreviewRefresher(object sender, PropertyChangedEventArgs e) private void PreviewRefresher(object sender, PropertyChangedEventArgs e)
{ {
if (e.PropertyName == "SelectedLayer" || e.PropertyName == "ProfileTree") if (e.PropertyName != "KeyboardPreview")
NotifyOfPropertyChange(() => KeyboardPreview); NotifyOfPropertyChange(() => KeyboardPreview);
} }
private void LoadProfiles() private void LoadProfiles()
{ {
ProfileModels.Clear(); Profiles.Clear();
ProfileModels.AddRange(ProfileProvider.GetAll(_gameModel)); Profiles.AddRange(ProfileProvider.GetAll(_gameModel));
SelectedProfile = ProfileModels.FirstOrDefault(); SelectedProfile = Profiles.FirstOrDefault();
} }
public async void AddProfile() public async void AddProfile()
{ {
var name = var name = await _mainManager.DialogService.ShowInputDialog("Add new profile",
await "Please provide a profile name unique to this game and keyboard.");
_mainManager.DialogService.ShowInputDialog("Add new profile",
"Please provide a profile name unique to this game and keyboard.");
if (name.Length < 1) if (name.Length < 1)
{ {
_mainManager.DialogService.ShowMessageBox("Invalid profile name", "Please provide a valid profile name"); _mainManager.DialogService.ShowMessageBox("Invalid profile name", "Please provide a valid profile name");
@ -223,12 +224,11 @@ namespace Artemis.ViewModels
KeyboardName = ActiveKeyboard.Name, KeyboardName = ActiveKeyboard.Name,
GameName = _gameModel.Name GameName = _gameModel.Name
}; };
if (ProfileProvider.GetAll().Contains(profile)) if (ProfileProvider.GetAll().Contains(profile))
{ {
var overwrite = var overwrite = await _mainManager.DialogService.ShowQuestionMessageBox("Overwrite existing profile",
await "A profile with this name already exists for this game. Would you like to overwrite it?");
_mainManager.DialogService.ShowQuestionMessageBox("Overwrite existing profile",
"A profile with this name already exists for this game. Would you like to overwrite it?");
if (!overwrite.Value) if (!overwrite.Value)
return; return;
} }
@ -247,8 +247,7 @@ namespace Artemis.ViewModels
public void LayerEditor(LayerModel layer) public void LayerEditor(LayerModel layer)
{ {
IWindowManager manager = new WindowManager(); IWindowManager manager = new WindowManager();
_editorVm = new LayerEditorViewModel<T>(ActiveKeyboard, SelectedProfile, _editorVm = new LayerEditorViewModel<T>(ActiveKeyboard, SelectedProfile, layer);
layer);
dynamic settings = new ExpandoObject(); dynamic settings = new ExpandoObject();
settings.Title = "Artemis | Edit " + layer.Name; settings.Title = "Artemis | Edit " + layer.Name;
@ -258,7 +257,6 @@ namespace Artemis.ViewModels
public void SetSelectedLayer(LayerModel layer) public void SetSelectedLayer(LayerModel layer)
{ {
SelectedLayer = layer; SelectedLayer = layer;
NotifyOfPropertyChange(() => KeyboardPreview);
} }
public void AddLayer() public void AddLayer()
@ -266,23 +264,19 @@ namespace Artemis.ViewModels
if (_selectedProfile == null) if (_selectedProfile == null)
return; return;
var layer = new LayerModel var layer = SelectedProfile.AddLayer();
{
Name = "Layer " + (_selectedProfile.Layers.Count + 1),
LayerType = LayerType.KeyboardRectangle,
UserProps = new LayerPropertiesModel
{
Brush = new SolidColorBrush(Colors.Red),
Animation = LayerAnimation.None,
Height = 1,
Width = 1,
X = 0,
Y = 0,
Opacity = 1
}
};
SelectedProfile.Layers.Add(layer);
Layers.Add(layer); Layers.Add(layer);
SelectedLayer = layer;
}
public void RemoveLayer()
{
if (_selectedProfile == null || _selectedLayer == null)
return;
SelectedProfile.Layers.Remove(_selectedLayer);
Layers.Remove(_selectedLayer);
} }
public void MouseDownKeyboardPreview(MouseButtonEventArgs e) public void MouseDownKeyboardPreview(MouseButtonEventArgs e)
@ -294,17 +288,17 @@ namespace Artemis.ViewModels
public void MouseUpKeyboardPreview(MouseButtonEventArgs e) public void MouseUpKeyboardPreview(MouseButtonEventArgs e)
{ {
var timeSinceDown = DateTime.Now - _downTime; var timeSinceDown = DateTime.Now - _downTime;
if (timeSinceDown.TotalMilliseconds < 500) if (!(timeSinceDown.TotalMilliseconds < 500))
{ return;
var pos = e.GetPosition((Image) e.OriginalSource);
var x = pos.X/((double) ActiveKeyboard.PreviewSettings.Width/ActiveKeyboard.Width);
var y = pos.Y/((double) ActiveKeyboard.PreviewSettings.Height/ActiveKeyboard.Height);
var hoverLayer = SelectedProfile.Layers.Where(l => l.Enabled) var pos = e.GetPosition((Image) e.OriginalSource);
.FirstOrDefault(l => l.UserProps.GetRect(1).Contains(x, y)); var x = pos.X/((double) ActiveKeyboard.PreviewSettings.Width/ActiveKeyboard.Width);
if (hoverLayer != null) var y = pos.Y/((double) ActiveKeyboard.PreviewSettings.Height/ActiveKeyboard.Height);
SelectedLayer = hoverLayer;
} var hoverLayer = SelectedProfile.Layers.Where(l => l.Enabled)
.FirstOrDefault(l => l.UserProps.GetRect(1).Contains(x, y));
if (hoverLayer != null)
SelectedLayer = hoverLayer;
} }
public void MouseMoveKeyboardPreview(MouseEventArgs e) public void MouseMoveKeyboardPreview(MouseEventArgs e)
@ -327,11 +321,11 @@ namespace Artemis.ViewModels
// Turn the mouse pointer into a hand if hovering over an active layer // Turn the mouse pointer into a hand if hovering over an active layer
if (hoverLayer == SelectedLayer) if (hoverLayer == SelectedLayer)
{ {
var layerRect = hoverLayer.UserProps.GetRect(1); var rect = hoverLayer.UserProps.GetRect(1);
if (Math.Sqrt(Math.Pow(x - layerRect.BottomRight.X, 2) + Math.Pow(y - layerRect.BottomRight.Y, 2)) < 0.6) KeyboardPreviewCursor =
KeyboardPreviewCursor = Cursors.SizeNWSE; Math.Sqrt(Math.Pow(x - rect.BottomRight.X, 2) + Math.Pow(y - rect.BottomRight.Y, 2)) < 0.6
else ? Cursors.SizeNWSE
KeyboardPreviewCursor = Cursors.SizeAll; : Cursors.SizeAll;
} }
else else
KeyboardPreviewCursor = Cursors.Hand; KeyboardPreviewCursor = Cursors.Hand;
@ -358,16 +352,16 @@ namespace Artemis.ViewModels
_draggingLayerOffset = new Point(x - SelectedLayer.UserProps.X, y - SelectedLayer.UserProps.Y); _draggingLayerOffset = new Point(x - SelectedLayer.UserProps.X, y - SelectedLayer.UserProps.Y);
_draggingLayer = hoverLayer; _draggingLayer = hoverLayer;
if (Math.Sqrt(Math.Pow(x - layerRect.BottomRight.X, 2) + Math.Pow(y - layerRect.BottomRight.Y, 2)) < 0.6) if (Math.Sqrt(Math.Pow(x - layerRect.BottomRight.X, 2) + Math.Pow(y - layerRect.BottomRight.Y, 2)) < 0.6)
_resizeSourceRect = true; _resizing = true;
else else
_resizeSourceRect = false; _resizing = false;
} }
if (_draggingLayerOffset == null || _draggingLayer == null || (_draggingLayer != SelectedLayer)) if (_draggingLayerOffset == null || _draggingLayer == null || (_draggingLayer != SelectedLayer))
return; return;
// If no setup or reset was done, handle the actual dragging action // If no setup or reset was done, handle the actual dragging action
if (_resizeSourceRect) if (_resizing)
{ {
_draggingLayer.UserProps.Width = (int) Math.Round(x - _draggingLayer.UserProps.X); _draggingLayer.UserProps.Width = (int) Math.Round(x - _draggingLayer.UserProps.X);
_draggingLayer.UserProps.Height = (int) Math.Round(y - _draggingLayer.UserProps.Y); _draggingLayer.UserProps.Height = (int) Math.Round(y - _draggingLayer.UserProps.Y);

View File

@ -3,8 +3,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.Views"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:cal="http://www.caliburnproject.org" xmlns:cal="http://www.caliburnproject.org"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:itemBehaviours="clr-namespace:Artemis.ItemBehaviours" xmlns:itemBehaviours="clr-namespace:Artemis.ItemBehaviours"
@ -28,13 +26,10 @@
<Border> <Border>
<Border.Effect> <Border.Effect>
<!-- TODO: Pulse 10-20 --> <!-- TODO: Pulse 10-20 -->
<DropShadowEffect ShadowDepth="0" <DropShadowEffect ShadowDepth="0" Color="{DynamicResource HighlightColor}" Opacity="1"
Color="{DynamicResource HighlightColor}"
Opacity="1"
BlurRadius="20" /> BlurRadius="20" />
</Border.Effect> </Border.Effect>
<Grid> <Grid>
<Image Grid.Column="0" Grid.Row="0" Source="{Binding Path=KeyboardImage}" Margin="50" /> <Image Grid.Column="0" Grid.Row="0" Source="{Binding Path=KeyboardImage}" Margin="50" />
<Image Grid.Column="0" Grid.Row="0" Source="{Binding Path=KeyboardPreview}" Opacity="0.8" <Image Grid.Column="0" Grid.Row="0" Source="{Binding Path=KeyboardPreview}" Opacity="0.8"
Width="{Binding Path=PreviewSettings.Width}" Width="{Binding Path=PreviewSettings.Width}"
@ -44,26 +39,23 @@
cal:Message.Attach="[Event MouseMove] = [Action MouseMoveKeyboardPreview($eventArgs)]; cal:Message.Attach="[Event MouseMove] = [Action MouseMoveKeyboardPreview($eventArgs)];
[Event MouseDown] = [Action MouseDownKeyboardPreview($eventArgs)]; [Event MouseDown] = [Action MouseDownKeyboardPreview($eventArgs)];
[Event MouseUp] = [Action MouseUpKeyboardPreview($eventArgs)]" /> [Event MouseUp] = [Action MouseUpKeyboardPreview($eventArgs)]" />
</Grid> </Grid>
</Border> </Border>
</Border> </Border>
<!-- Profile management --> <!-- Profile management -->
<StackPanel Grid.Column="0" Grid.Row="2" Orientation="Horizontal" Margin="0,5,0,0"> <StackPanel Grid.Column="0" Grid.Row="2" Orientation="Horizontal" Margin="0,5,0,0">
<Label Content="Active profile" /> <Label Content="Active profile" />
<ComboBox Grid.Row="1" Grid.Column="1" Width="110" VerticalAlignment="Top" x:Name="ProfileModels" <ComboBox Width="110" VerticalAlignment="Top" x:Name="Profiles" DisplayMemberPath="Name"
DisplayMemberPath="Name" Margin="5,0,0,0" /> Margin="5,0,0,0" />
<Button x:Name="AddProfile" Content="Add profile" VerticalAlignment="Top" <Button x:Name="AddProfile" Content="Add profile" VerticalAlignment="Top"
Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Left" Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Left" Margin="10,0,0,0" />
Margin="10,0,0,0" />
<Button x:Name="RemoveProfile" Content="Remove profile" VerticalAlignment="Top" <Button x:Name="RemoveProfile" Content="Remove profile" VerticalAlignment="Top"
Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Right" Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Right"
Margin="10,0,0,0" /> Margin="10,0,0,0" />
</StackPanel> </StackPanel>
<!-- Layer list --> <!-- Layer list -->
<Label Grid.Column="1" Grid.Row="0" FontSize="20" HorizontalAlignment="Left" Content="Layers" <Label Grid.Column="1" Grid.Row="0" FontSize="20" HorizontalAlignment="Left" Content="Layers" Margin="10,0,0,0" />
Margin="10,0,0,0" />
<Border Grid.Column="1" Grid.Row="1" Background="#FF232323" BorderBrush="{DynamicResource HighlightBrush}" <Border Grid.Column="1" Grid.Row="1" Background="#FF232323" BorderBrush="{DynamicResource HighlightBrush}"
BorderThickness="3" Margin="10,0,0,0" Height="400" Width="250"> BorderThickness="3" Margin="10,0,0,0" Height="400" Width="250">
<TreeView x:Name="ProfileTree" ItemsSource="{Binding Path=Layers}"> <TreeView x:Name="ProfileTree" ItemsSource="{Binding Path=Layers}">
@ -95,10 +87,20 @@
</TreeView> </TreeView>
</Border> </Border>
<Grid Grid.Column="1" Grid.Row="2" Margin="10,5,0,0"> <Grid Grid.Column="1" Grid.Row="2" Margin="10,5,0,0">
<Button x:Name="AddLayer" Content="Add layer" VerticalAlignment="Top" <Grid.ColumnDefinitions>
Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Left" /> <ColumnDefinition />
<Button x:Name="RemoveLayer" Content="Remove layer" VerticalAlignment="Top" <ColumnDefinition />
Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Right" /> <ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Grid.Column="0" x:Name="AddLayer" Content="Add layer" VerticalAlignment="Top"
Style="{DynamicResource SquareButtonStyle}" Width="95" />
<Button Grid.Column="1" x:Name="LayerUp" Content="^" VerticalAlignment="Top"
Style="{DynamicResource SquareButtonStyle}" Width="26" Margin="2,0,0,0" />
<Button Grid.Column="2" x:Name="LayerDown" Content="v" VerticalAlignment="Top"
Style="{DynamicResource SquareButtonStyle}" Width="26" Margin="0,0,2,0" />
<Button Grid.Column="3" x:Name="RemoveLayer" Content="Remove layer" VerticalAlignment="Top"
Style="{DynamicResource SquareButtonStyle}" Width="95" />
</Grid> </Grid>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -1,22 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net452" />
<package id="Autofac" version="4.0.0-rc1-177" targetFramework="net452" /> <package id="Autofac" version="4.0.0-rc1-177" targetFramework="net452" />
<package id="Caliburn.Micro" version="2.0.2" targetFramework="net452" /> <package id="Caliburn.Micro" version="2.0.2" targetFramework="net452" />
<package id="Caliburn.Micro.AutofacBootstrap" version="2.0.9-beta" targetFramework="net452" /> <package id="Caliburn.Micro.AutofacBootstrap" version="2.0.9-beta" targetFramework="net452" />
<package id="Caliburn.Micro.Core" version="2.0.2" targetFramework="net452" /> <package id="Caliburn.Micro.Core" version="2.0.2" targetFramework="net452" />
<package id="Colore" version="4.0.0" targetFramework="net452" /> <package id="Colore" version="4.0.0" targetFramework="net452" />
<package id="CUE.NET" version="1.0.2.2" targetFramework="net452" /> <package id="CUE.NET" version="1.0.2.2" targetFramework="net452" />
<package id="ExpressionEvaluator" version="2.0.4.0" targetFramework="net452" /> <package id="Extended.Wpf.Toolkit" version="2.7" targetFramework="net452" />
<package id="Extended.Wpf.Toolkit" version="2.6" targetFramework="net452" /> <package id="Hardcodet.NotifyIcon.Wpf" version="1.0.8" targetFramework="net452" />
<package id="Hardcodet.NotifyIcon.Wpf" version="1.0.5" targetFramework="net452" />
<package id="ImageLibrary" version="2.0.5" targetFramework="net452" /> <package id="ImageLibrary" version="2.0.5" targetFramework="net452" />
<package id="log4net" version="2.0.5" targetFramework="net452" /> <package id="log4net" version="2.0.5" targetFramework="net452" />
<package id="MahApps.Metro" version="1.2.4.0" targetFramework="net452" /> <package id="MahApps.Metro" version="1.2.4.0" targetFramework="net452" />
<package id="MahApps.Metro.Resources" version="0.4.0.0" targetFramework="net452" /> <package id="MahApps.Metro.Resources" version="0.5.0.0" targetFramework="net452" />
<package id="NAudio" version="1.7.3" targetFramework="net452" /> <package id="NAudio" version="1.7.3" targetFramework="net452" />
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net452" /> <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net452" />
<package id="Screna" version="0.1.3" targetFramework="net452" />
<package id="SharpDX" version="3.0.2" targetFramework="net452" /> <package id="SharpDX" version="3.0.2" targetFramework="net452" />
<package id="SharpDX.Direct3D11" version="3.0.2" targetFramework="net452" /> <package id="SharpDX.Direct3D11" version="3.0.2" targetFramework="net452" />
<package id="SharpDX.DXGI" version="3.0.2" targetFramework="net452" /> <package id="SharpDX.DXGI" version="3.0.2" targetFramework="net452" />