mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Layer preview WIP (Also means actual drawing is being worked on)
This commit is contained in:
parent
1a6c4d55da
commit
6cad16ccd5
@ -188,6 +188,7 @@
|
|||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.Linq.Dynamic, Version=1.0.5840.25917, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="System.Linq.Dynamic, Version=1.0.5840.25917, Culture=neutral, processorArchitecture=MSIL">
|
||||||
@ -397,6 +398,7 @@
|
|||||||
<Compile Include="Utilities\ShellLink.cs" />
|
<Compile Include="Utilities\ShellLink.cs" />
|
||||||
<Compile Include="Utilities\StickyValue.cs" />
|
<Compile Include="Utilities\StickyValue.cs" />
|
||||||
<Compile Include="Utilities\Updater.cs" />
|
<Compile Include="Utilities\Updater.cs" />
|
||||||
|
<Compile Include="Utilities\ValueConverters.cs" />
|
||||||
<Compile Include="ViewModels\Abstract\EffectViewModel.cs" />
|
<Compile Include="ViewModels\Abstract\EffectViewModel.cs" />
|
||||||
<Compile Include="ViewModels\Abstract\GameViewModel.cs" />
|
<Compile Include="ViewModels\Abstract\GameViewModel.cs" />
|
||||||
<Compile Include="ViewModels\EffectsViewModel.cs" />
|
<Compile Include="ViewModels\EffectsViewModel.cs" />
|
||||||
|
|||||||
@ -1,10 +1,8 @@
|
|||||||
using System;
|
using System.Drawing;
|
||||||
using System.Drawing;
|
|
||||||
using Artemis.KeyboardProviders.Razer.Utilities;
|
using Artemis.KeyboardProviders.Razer.Utilities;
|
||||||
using Corale.Colore.Core;
|
using Corale.Colore.Core;
|
||||||
using Corale.Colore.Razer.Keyboard;
|
using Corale.Colore.Razer;
|
||||||
using ColoreColor = Corale.Colore.Core.Color;
|
using Constants = Corale.Colore.Razer.Keyboard.Constants;
|
||||||
using KeyboardCustom = Corale.Colore.Razer.Keyboard.Effects.Custom;
|
|
||||||
|
|
||||||
namespace Artemis.KeyboardProviders.Razer
|
namespace Artemis.KeyboardProviders.Razer
|
||||||
{
|
{
|
||||||
@ -24,9 +22,9 @@ namespace Artemis.KeyboardProviders.Razer
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Some people have Synapse installed, but not a Chroma keyboard, deal with this
|
// Some people have Synapse installed, but not a Chroma keyboard, deal with this
|
||||||
var blackWidowFound = Chroma.Instance.Query(Corale.Colore.Razer.Devices.Blackwidow).Connected;
|
var blackWidowFound = Chroma.Instance.Query(Devices.Blackwidow).Connected;
|
||||||
var blackWidowTeFound = Chroma.Instance.Query(Corale.Colore.Razer.Devices.BlackwidowTe).Connected;
|
var blackWidowTeFound = Chroma.Instance.Query(Devices.BlackwidowTe).Connected;
|
||||||
return (blackWidowFound || blackWidowTeFound);
|
return blackWidowFound || blackWidowTeFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Enable()
|
public override void Enable()
|
||||||
@ -48,7 +46,7 @@ namespace Artemis.KeyboardProviders.Razer
|
|||||||
public override void DrawBitmap(Bitmap bitmap)
|
public override void DrawBitmap(Bitmap bitmap)
|
||||||
{
|
{
|
||||||
var razerArray = RazerUtilities.BitmapColorArray(bitmap, Height, Width);
|
var razerArray = RazerUtilities.BitmapColorArray(bitmap, Height, Width);
|
||||||
|
|
||||||
Chroma.Instance.Keyboard.SetCustom(razerArray);
|
Chroma.Instance.Keyboard.SetCustom(razerArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
@ -24,7 +24,7 @@ namespace Artemis.Models.Profiles
|
|||||||
LayerConditions = new List<LayerConditionModel>();
|
LayerConditions = new List<LayerConditionModel>();
|
||||||
LayerProperties = new List<LayerDynamicPropertiesModel>();
|
LayerProperties = new List<LayerDynamicPropertiesModel>();
|
||||||
|
|
||||||
_drawer = new LayerDrawer(this);
|
_drawer = new LayerDrawer(this, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
@ -36,36 +36,41 @@ namespace Artemis.Models.Profiles
|
|||||||
public List<LayerDynamicPropertiesModel> LayerProperties { get; set; }
|
public List<LayerDynamicPropertiesModel> LayerProperties { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public LayerPropertiesModel LayerCalculatedProperties { get; }
|
public LayerPropertiesModel LayerCalculatedProperties { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public ImageSource LayerImage => _drawer.GetPreviewImage();
|
public ImageSource LayerImage => _drawer.GetThumbnail();
|
||||||
|
|
||||||
public bool ConditionsMet<T>(IGameDataModel dataModel)
|
public bool ConditionsMet<T>(IGameDataModel dataModel)
|
||||||
{
|
{
|
||||||
return LayerConditions.All(cm => cm.ConditionMet<T>(dataModel));
|
return LayerConditions.All(cm => cm.ConditionMet<T>(dataModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DrawPreview(Graphics g)
|
||||||
|
{
|
||||||
|
if (LayerType == LayerType.KeyboardRectangle || LayerType == LayerType.KeyboardEllipse)
|
||||||
|
_drawer.Draw(g);
|
||||||
|
else if (LayerType == LayerType.KeyboardGif)
|
||||||
|
_drawer.DrawGif(g);
|
||||||
|
}
|
||||||
|
|
||||||
public void Draw<T>(IGameDataModel dataModel, Graphics g)
|
public void Draw<T>(IGameDataModel dataModel, Graphics g)
|
||||||
{
|
{
|
||||||
if (!ConditionsMet<T>(dataModel))
|
if (!ConditionsMet<T>(dataModel))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Update<T>(dataModel);
|
Update<T>(dataModel);
|
||||||
switch (LayerType)
|
|
||||||
{
|
if (LayerType == LayerType.Folder)
|
||||||
case LayerType.Folder:
|
DrawChildren<T>(dataModel, g);
|
||||||
DrawChildren<T>(dataModel, g);
|
else if (LayerType == LayerType.KeyboardRectangle || LayerType == LayerType.KeyboardEllipse)
|
||||||
break;
|
_drawer.Draw(g);
|
||||||
case LayerType.Rectangle:
|
else if (LayerType == LayerType.KeyboardGif)
|
||||||
_drawer.DrawRectangle(g);
|
_drawer.DrawGif(g);
|
||||||
break;
|
else if (LayerType == LayerType.Mouse)
|
||||||
case LayerType.Ellipse:
|
_drawer.UpdateMouse();
|
||||||
_drawer.DrawEllipse(g);
|
else if (LayerType == LayerType.Headset)
|
||||||
break;
|
_drawer.UpdateHeadset();
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update<T>(IGameDataModel dataModel)
|
private void Update<T>(IGameDataModel dataModel)
|
||||||
@ -84,8 +89,11 @@ namespace Artemis.Models.Profiles
|
|||||||
|
|
||||||
public enum LayerType
|
public enum LayerType
|
||||||
{
|
{
|
||||||
Folder,
|
[Description("Folder")] Folder,
|
||||||
Rectangle,
|
[Description("Keyboard - Rectangle")] KeyboardRectangle,
|
||||||
Ellipse
|
[Description("Keyboard - Ellipse")] KeyboardEllipse,
|
||||||
|
[Description("Keyboard - GIF")] KeyboardGif,
|
||||||
|
[Description("Mouse")] Mouse,
|
||||||
|
[Description("Headset")] Headset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.ComponentModel;
|
||||||
|
using System.Windows.Media;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
|
|
||||||
namespace Artemis.Models.Profiles
|
namespace Artemis.Models.Profiles
|
||||||
@ -12,7 +13,7 @@ namespace Artemis.Models.Profiles
|
|||||||
public int Height { get; set; }
|
public int Height { get; set; }
|
||||||
public int Opacity { get; set; }
|
public int Opacity { get; set; }
|
||||||
public bool ContainedBrush { get; set; }
|
public bool ContainedBrush { get; set; }
|
||||||
public LinearGradientMode GradientMode { get; set; }
|
public LayerColorMode ColorMode { get; set; }
|
||||||
public bool Rotate { get; set; }
|
public bool Rotate { get; set; }
|
||||||
public double RotateSpeed { get; set; }
|
public double RotateSpeed { get; set; }
|
||||||
public List<Color> Colors { get; set; }
|
public List<Color> Colors { get; set; }
|
||||||
@ -22,4 +23,16 @@ namespace Artemis.Models.Profiles
|
|||||||
Colors = new List<Color>();
|
Colors = new List<Color>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum LayerColorMode
|
||||||
|
{
|
||||||
|
[Description("Left to right")]
|
||||||
|
Horizontal,
|
||||||
|
[Description("Top to bottom")]
|
||||||
|
Vertical,
|
||||||
|
[Description("Shift")]
|
||||||
|
Shift,
|
||||||
|
[Description("Pulse")]
|
||||||
|
Pulse,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -4,9 +4,25 @@ namespace Artemis.Utilities
|
|||||||
{
|
{
|
||||||
public static class ExtensionMethods
|
public static class ExtensionMethods
|
||||||
{
|
{
|
||||||
|
#region String
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Takes a string LikeThisOne and turns it into Like This One.
|
||||||
|
/// ZombieSheep - http://stackoverflow.com/a/5796793/5015269
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static string SplitCamelCase(this string str)
|
public static string SplitCamelCase(this string str)
|
||||||
{
|
{
|
||||||
return Regex.Replace(Regex.Replace(str, @"(\P{Ll})(\P{Ll}\p{Ll})", "$1 $2"), @"(\p{Ll})(\P{Ll})", "$1 $2");
|
return Regex.Replace(Regex.Replace(str, @"(\P{Ll})(\P{Ll}\p{Ll})", "$1 $2"), @"(\p{Ll})(\P{Ll})", "$1 $2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Color
|
||||||
|
|
||||||
|
// TODO: Convert ColorHelpers to ExtensionMethods
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -13,33 +13,36 @@ namespace Artemis.Utilities
|
|||||||
internal class LayerDrawer
|
internal class LayerDrawer
|
||||||
{
|
{
|
||||||
private readonly LayerModel _layerModel;
|
private readonly LayerModel _layerModel;
|
||||||
|
private LinearGradientBrush _brush;
|
||||||
private Rectangle _rectangle;
|
private Rectangle _rectangle;
|
||||||
private double _rotationProgress;
|
private double _rotationProgress;
|
||||||
private Rectangle _userRectangle;
|
private Rectangle _userRectangle;
|
||||||
|
|
||||||
public LayerDrawer(LayerModel layerModel)
|
public LayerDrawer(LayerModel layerModel, int scale)
|
||||||
{
|
{
|
||||||
|
Scale = scale;
|
||||||
_layerModel = layerModel;
|
_layerModel = layerModel;
|
||||||
_rotationProgress = 0;
|
_rotationProgress = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(Graphics graphics)
|
public int Scale { get; set; }
|
||||||
{
|
|
||||||
_rectangle = new Rectangle(
|
|
||||||
_layerModel.LayerCalculatedProperties.X,
|
|
||||||
_layerModel.LayerCalculatedProperties.Y,
|
|
||||||
_layerModel.LayerCalculatedProperties.Width,
|
|
||||||
_layerModel.LayerCalculatedProperties.Height);
|
|
||||||
_userRectangle = new Rectangle(
|
|
||||||
_layerModel.LayerUserProperties.X,
|
|
||||||
_layerModel.LayerUserProperties.Y,
|
|
||||||
_layerModel.LayerUserProperties.Width,
|
|
||||||
_layerModel.LayerUserProperties.Height);
|
|
||||||
|
|
||||||
if (_layerModel.LayerType == LayerType.Ellipse)
|
public void Draw(Graphics g)
|
||||||
DrawEllipse(graphics);
|
{
|
||||||
else if (_layerModel.LayerType == LayerType.Ellipse)
|
// Set up variables for this frame
|
||||||
DrawRectangle(graphics);
|
_rectangle = new Rectangle(_layerModel.LayerCalculatedProperties.X*Scale,
|
||||||
|
_layerModel.LayerCalculatedProperties.Y*Scale, _layerModel.LayerCalculatedProperties.Width*Scale,
|
||||||
|
_layerModel.LayerCalculatedProperties.Height*Scale);
|
||||||
|
_userRectangle = new Rectangle(_layerModel.LayerUserProperties.X*Scale,
|
||||||
|
_layerModel.LayerUserProperties.Y*Scale, _layerModel.LayerUserProperties.Width*Scale,
|
||||||
|
_layerModel.LayerUserProperties.Height*Scale);
|
||||||
|
_brush = CreateGradientBrush(
|
||||||
|
_layerModel.LayerCalculatedProperties.Colors.Select(ColorHelpers.ToDrawingColor).ToList());
|
||||||
|
|
||||||
|
if (_layerModel.LayerType == LayerType.KeyboardRectangle)
|
||||||
|
DrawRectangle(g);
|
||||||
|
else if (_layerModel.LayerType == LayerType.KeyboardEllipse)
|
||||||
|
DrawEllipse(g);
|
||||||
|
|
||||||
// Update the rotation progress
|
// Update the rotation progress
|
||||||
_rotationProgress = _rotationProgress + _layerModel.LayerCalculatedProperties.RotateSpeed;
|
_rotationProgress = _rotationProgress + _layerModel.LayerCalculatedProperties.RotateSpeed;
|
||||||
@ -50,23 +53,24 @@ namespace Artemis.Utilities
|
|||||||
_rotationProgress = _layerModel.LayerCalculatedProperties.RotateSpeed;
|
_rotationProgress = _layerModel.LayerCalculatedProperties.RotateSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BitmapImage GetPreviewImage()
|
public BitmapImage GetThumbnail()
|
||||||
{
|
{
|
||||||
_rectangle = new Rectangle(0, 0, 18, 18);
|
_rectangle = new Rectangle(0, 0, 18, 18);
|
||||||
_userRectangle = new Rectangle(0, 0, 18, 18);
|
_userRectangle = new Rectangle(0, 0, 18, 18);
|
||||||
_layerModel.LayerCalculatedProperties.Opacity = 255;
|
_layerModel.LayerCalculatedProperties.Opacity = 255;
|
||||||
var brush = CreateGradientBrush(_layerModel.LayerUserProperties.Colors);
|
var brush =
|
||||||
|
CreateGradientBrush(_layerModel.LayerUserProperties.Colors.Select(ColorHelpers.ToDrawingColor).ToList());
|
||||||
var bitmap = new Bitmap(18, 18);
|
var bitmap = new Bitmap(18, 18);
|
||||||
|
|
||||||
using (var g = Graphics.FromImage(bitmap))
|
using (var g = Graphics.FromImage(bitmap))
|
||||||
{
|
{
|
||||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||||
if (_layerModel.LayerType == LayerType.Ellipse)
|
if (_layerModel.LayerType == LayerType.KeyboardEllipse)
|
||||||
{
|
{
|
||||||
g.FillEllipse(brush, _rectangle);
|
g.FillEllipse(brush, _rectangle);
|
||||||
g.DrawEllipse(new Pen(Color.Black, 1), 0, 0, 17, 17);
|
g.DrawEllipse(new Pen(Color.Black, 1), 0, 0, 17, 17);
|
||||||
}
|
}
|
||||||
else if (_layerModel.LayerType == LayerType.Rectangle)
|
else if (_layerModel.LayerType == LayerType.KeyboardRectangle)
|
||||||
{
|
{
|
||||||
g.FillRectangle(brush, _rectangle);
|
g.FillRectangle(brush, _rectangle);
|
||||||
g.DrawRectangle(new Pen(Color.Black, 1), 0, 0, 17, 17);
|
g.DrawRectangle(new Pen(Color.Black, 1), 0, 0, 17, 17);
|
||||||
@ -90,11 +94,17 @@ namespace Artemis.Utilities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawRectangle(Graphics graphics)
|
public void DrawRectangle(Graphics g)
|
||||||
{
|
{
|
||||||
|
g.FillRectangle(_brush, _rectangle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawEllipse(Graphics graphics)
|
public void DrawEllipse(Graphics g)
|
||||||
|
{
|
||||||
|
g.FillEllipse(_brush, _rectangle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DrawGif(Graphics g)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,8 +162,12 @@ namespace Artemis.Utilities
|
|||||||
? new Rectangle(_rectangle.X, _rectangle.Y, _rectangle.Width, _rectangle.Height)
|
? new Rectangle(_rectangle.X, _rectangle.Y, _rectangle.Width, _rectangle.Height)
|
||||||
: new Rectangle(_userRectangle.X, _userRectangle.Y, _userRectangle.Width, _userRectangle.Height);
|
: new Rectangle(_userRectangle.X, _userRectangle.Y, _userRectangle.Width, _userRectangle.Height);
|
||||||
|
|
||||||
return new LinearGradientBrush(rect, Color.Transparent, Color.Transparent,
|
if (_layerModel.LayerCalculatedProperties.ColorMode == LayerColorMode.Horizontal)
|
||||||
_layerModel.LayerCalculatedProperties.GradientMode)
|
return new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, LinearGradientMode.Horizontal)
|
||||||
|
{
|
||||||
|
InterpolationColors = colorBlend
|
||||||
|
};
|
||||||
|
return new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, LinearGradientMode.Vertical)
|
||||||
{
|
{
|
||||||
InterpolationColors = colorBlend
|
InterpolationColors = colorBlend
|
||||||
};
|
};
|
||||||
@ -169,5 +183,13 @@ namespace Artemis.Utilities
|
|||||||
tilebleColors.Add(sourceColors.FirstOrDefault());
|
tilebleColors.Add(sourceColors.FirstOrDefault());
|
||||||
return tilebleColors;
|
return tilebleColors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateMouse()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateHeadset()
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
39
Artemis/Artemis/Utilities/ValueConverters.cs
Normal file
39
Artemis/Artemis/Utilities/ValueConverters.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Windows.Data;
|
||||||
|
|
||||||
|
namespace Artemis.Utilities
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Fredrik Hedblad - http://stackoverflow.com/a/3987099/5015269
|
||||||
|
/// </summary>
|
||||||
|
public class EnumDescriptionConverter : IValueConverter
|
||||||
|
{
|
||||||
|
object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
var myEnum = (Enum) value;
|
||||||
|
var description = GetEnumDescription(myEnum);
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetEnumDescription(Enum enumObj)
|
||||||
|
{
|
||||||
|
var fieldInfo = enumObj.GetType().GetField(enumObj.ToString());
|
||||||
|
|
||||||
|
var attribArray = fieldInfo.GetCustomAttributes(false);
|
||||||
|
|
||||||
|
if (attribArray.Length == 0)
|
||||||
|
{
|
||||||
|
return enumObj.ToString();
|
||||||
|
}
|
||||||
|
var attrib = attribArray[0] as DescriptionAttribute;
|
||||||
|
return attrib?.Description;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,29 +1,55 @@
|
|||||||
using System.Linq;
|
using System;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
using Artemis.Models.Profiles;
|
using Artemis.Models.Profiles;
|
||||||
using Artemis.Utilities;
|
using Artemis.Utilities;
|
||||||
using Artemis.ViewModels.LayerEditor;
|
using Artemis.ViewModels.LayerEditor;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
|
using Color = System.Windows.Media.Color;
|
||||||
|
|
||||||
namespace Artemis.ViewModels
|
namespace Artemis.ViewModels
|
||||||
{
|
{
|
||||||
public class LayerEditorViewModel<T> : Screen
|
public class LayerEditorViewModel<T> : Screen
|
||||||
{
|
{
|
||||||
|
private readonly BackgroundWorker _previewWorker;
|
||||||
private LayerModel _layer;
|
private LayerModel _layer;
|
||||||
|
private LayerPropertiesModel _proposedProperties;
|
||||||
|
|
||||||
public LayerEditorViewModel(LayerModel layer)
|
public LayerEditorViewModel(LayerModel layer)
|
||||||
{
|
{
|
||||||
Layer = layer;
|
Layer = layer;
|
||||||
|
|
||||||
DataModelProps = new BindableCollection<GeneralHelpers.PropertyCollection>();
|
DataModelProps = new BindableCollection<GeneralHelpers.PropertyCollection>();
|
||||||
|
ProposedColors = new BindableCollection<Color>();
|
||||||
|
ProposedProperties = new LayerPropertiesModel();
|
||||||
|
ProposedColors.CollectionChanged += UpdateColors;
|
||||||
DataModelProps.AddRange(GeneralHelpers.GenerateTypeMap<T>());
|
DataModelProps.AddRange(GeneralHelpers.GenerateTypeMap<T>());
|
||||||
|
|
||||||
LayerConditionVms =
|
LayerConditionVms =
|
||||||
new BindableCollection<LayerConditionViewModel<T>>(
|
new BindableCollection<LayerConditionViewModel<T>>(
|
||||||
layer.LayerConditions.Select(c => new LayerConditionViewModel<T>(this, c, DataModelProps)));
|
layer.LayerConditions.Select(c => new LayerConditionViewModel<T>(this, c, DataModelProps)));
|
||||||
|
|
||||||
ProposedProperties = new LayerPropertiesModel();
|
_previewWorker = new BackgroundWorker();
|
||||||
GeneralHelpers.CopyProperties(ProposedProperties, Layer.LayerUserProperties);
|
_previewWorker.WorkerSupportsCancellation = true;
|
||||||
|
_previewWorker.DoWork += PreviewWorkerOnDoWork;
|
||||||
|
|
||||||
|
_previewWorker.RunWorkerAsync();
|
||||||
|
PreSelect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BindableCollection<GeneralHelpers.PropertyCollection> DataModelProps { get; set; }
|
||||||
|
|
||||||
|
public BindableCollection<string> LayerTypes => new BindableCollection<string>();
|
||||||
|
|
||||||
|
public BindableCollection<Color> ProposedColors { get; set; }
|
||||||
|
|
||||||
public BindableCollection<LayerConditionViewModel<T>> LayerConditionVms { get; set; }
|
public BindableCollection<LayerConditionViewModel<T>> LayerConditionVms { get; set; }
|
||||||
|
|
||||||
public LayerModel Layer
|
public LayerModel Layer
|
||||||
@ -37,9 +63,66 @@ namespace Artemis.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BindableCollection<GeneralHelpers.PropertyCollection> DataModelProps { get; set; }
|
public LayerPropertiesModel ProposedProperties
|
||||||
|
{
|
||||||
|
get { return _proposedProperties; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (Equals(value, _proposedProperties)) return;
|
||||||
|
_proposedProperties = value;
|
||||||
|
NotifyOfPropertyChange(() => ProposedProperties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public LayerPropertiesModel ProposedProperties { get; set; }
|
public ImageSource LayerImage
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
// For the preview, put the proposed properties into the calculated properties
|
||||||
|
_layer.LayerCalculatedProperties = ProposedProperties;
|
||||||
|
var bitmap = new Bitmap(ProposedProperties.Width, ProposedProperties.Height);
|
||||||
|
|
||||||
|
using (var g = Graphics.FromImage(bitmap))
|
||||||
|
{
|
||||||
|
_layer.DrawPreview(g);
|
||||||
|
}
|
||||||
|
|
||||||
|
using (var memory = new MemoryStream())
|
||||||
|
{
|
||||||
|
bitmap.Save(memory, ImageFormat.Png);
|
||||||
|
memory.Position = 0;
|
||||||
|
|
||||||
|
var bitmapImage = new BitmapImage();
|
||||||
|
bitmapImage.BeginInit();
|
||||||
|
bitmapImage.StreamSource = memory;
|
||||||
|
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
|
||||||
|
bitmapImage.EndInit();
|
||||||
|
|
||||||
|
return bitmapImage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateColors(object sender, NotifyCollectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
ProposedProperties.Colors = ProposedColors.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PreviewWorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
|
||||||
|
{
|
||||||
|
while (!_previewWorker.CancellationPending)
|
||||||
|
{
|
||||||
|
NotifyOfPropertyChange(() => LayerImage);
|
||||||
|
Thread.Sleep(1000/25);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PreSelect()
|
||||||
|
{
|
||||||
|
GeneralHelpers.CopyProperties(ProposedProperties, Layer.LayerUserProperties);
|
||||||
|
ProposedColors.Clear();
|
||||||
|
ProposedColors.AddRange(ProposedProperties.Colors);
|
||||||
|
}
|
||||||
|
|
||||||
public void AddCondition()
|
public void AddCondition()
|
||||||
{
|
{
|
||||||
@ -48,15 +131,32 @@ namespace Artemis.ViewModels
|
|||||||
LayerConditionVms.Add(new LayerConditionViewModel<T>(this, condition, DataModelProps));
|
LayerConditionVms.Add(new LayerConditionViewModel<T>(this, condition, DataModelProps));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddColor()
|
||||||
|
{
|
||||||
|
ProposedColors.Add(ColorHelpers.ToMediaColor(ColorHelpers.GetRandomRainbowColor()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteColor(Color c)
|
||||||
|
{
|
||||||
|
ProposedColors.Remove(c);
|
||||||
|
}
|
||||||
|
|
||||||
public void Apply()
|
public void Apply()
|
||||||
{
|
{
|
||||||
GeneralHelpers.CopyProperties(Layer.LayerUserProperties, ProposedProperties);
|
GeneralHelpers.CopyProperties(Layer.LayerUserProperties, ProposedProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteCondition(LayerConditionViewModel<T> layerConditionViewModel, LayerConditionModel layerConditionModel)
|
public void DeleteCondition(LayerConditionViewModel<T> layerConditionViewModel,
|
||||||
|
LayerConditionModel layerConditionModel)
|
||||||
{
|
{
|
||||||
LayerConditionVms.Remove(layerConditionViewModel);
|
LayerConditionVms.Remove(layerConditionViewModel);
|
||||||
Layer.LayerConditions.Remove(layerConditionModel);
|
Layer.LayerConditions.Remove(layerConditionModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void CanClose(Action<bool> callback)
|
||||||
|
{
|
||||||
|
_previewWorker.CancelAsync();
|
||||||
|
base.CanClose(callback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<!-- Left -->
|
<!-- Left -->
|
||||||
<ComboBox x:Name="DataModelProps" Grid.Column="0" Width="229" MaxDropDownHeight="125"
|
<ComboBox x:Name="DataModelProps" Grid.Column="0" Width="210" MaxDropDownHeight="125"
|
||||||
HorizontalAlignment="Center" VerticalAlignment="Top">
|
HorizontalAlignment="Center" VerticalAlignment="Top">
|
||||||
<ComboBox.ItemTemplate>
|
<ComboBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
@ -40,13 +40,13 @@
|
|||||||
VerticalAlignment="Top" DisplayMemberPath="Display" />
|
VerticalAlignment="Top" DisplayMemberPath="Display" />
|
||||||
|
|
||||||
<!-- Right -->
|
<!-- Right -->
|
||||||
<Grid Grid.Column="3" HorizontalAlignment="Left" Margin="10,0,0,0" Width="152">
|
<Grid Grid.Column="3" HorizontalAlignment="Left" Margin="10,0,0,0" Width="148">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="125"/>
|
<ColumnDefinition Width="120"/>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<StackPanel Grid.Column="0" x:Name="UserValueIsVisible" HorizontalAlignment="Left" VerticalAlignment="Top">
|
<StackPanel Grid.Column="0" x:Name="UserValueIsVisible" HorizontalAlignment="Left" VerticalAlignment="Top">
|
||||||
<TextBox x:Name="UserValue" VerticalAlignment="Center" HorizontalAlignment="Left" Width="115"/>
|
<TextBox x:Name="UserValue" VerticalAlignment="Center" HorizontalAlignment="Left" Width="110"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Button Grid.Column="1" x:Name="Delete" Width="26" Height="26" Style="{DynamicResource SquareButtonStyle}" VerticalAlignment="Top" HorizontalAlignment="Right" >
|
<Button Grid.Column="1" x:Name="Delete" Width="26" Height="26" Style="{DynamicResource SquareButtonStyle}" VerticalAlignment="Top" HorizontalAlignment="Right" >
|
||||||
<Button.Content>
|
<Button.Content>
|
||||||
|
|||||||
@ -3,18 +3,39 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:Artemis.Views"
|
|
||||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||||
xmlns:cal="http://www.caliburnproject.org"
|
xmlns:cal="http://www.caliburnproject.org"
|
||||||
|
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||||
|
xmlns:utilities="clr-namespace:Artemis.Utilities"
|
||||||
|
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Artemis | Edit Layer" Height="800" Width="630"
|
Title="Artemis | Edit Layer" Height="750" Width="630"
|
||||||
|
xmlns:profileEnumerations="clr-namespace:Artemis.Models.Profiles"
|
||||||
GlowBrush="{DynamicResource AccentColorBrush}" Icon="../logo.ico" ResizeMode="NoResize">
|
GlowBrush="{DynamicResource AccentColorBrush}" Icon="../logo.ico" ResizeMode="NoResize">
|
||||||
|
<controls:MetroWindow.Resources>
|
||||||
|
<utilities:EnumDescriptionConverter x:Key="HEnumDescriptionConverter" />
|
||||||
|
<ObjectDataProvider MethodName="GetValues"
|
||||||
|
ObjectType="{x:Type sys:Enum}"
|
||||||
|
x:Key="LayerEnumValues">
|
||||||
|
<ObjectDataProvider.MethodParameters>
|
||||||
|
<x:Type TypeName="profileEnumerations:LayerType" />
|
||||||
|
</ObjectDataProvider.MethodParameters>
|
||||||
|
</ObjectDataProvider>
|
||||||
|
<ObjectDataProvider MethodName="GetValues"
|
||||||
|
ObjectType="{x:Type sys:Enum}"
|
||||||
|
x:Key="ColorEnumValues">
|
||||||
|
<ObjectDataProvider.MethodParameters>
|
||||||
|
<x:Type TypeName="profileEnumerations:LayerColorMode" />
|
||||||
|
</ObjectDataProvider.MethodParameters>
|
||||||
|
</ObjectDataProvider>
|
||||||
|
</controls:MetroWindow.Resources>
|
||||||
|
|
||||||
<Grid Margin="10,0">
|
<Grid Margin="10,0">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="25*" />
|
<ColumnDefinition Width="65*" />
|
||||||
<ColumnDefinition Width="53*" />
|
<ColumnDefinition Width="86*" />
|
||||||
<ColumnDefinition Width="25*" />
|
<ColumnDefinition Width="65*" />
|
||||||
<ColumnDefinition Width="53*" />
|
<ColumnDefinition Width="86*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
@ -23,11 +44,17 @@
|
|||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" MinHeight="42" />
|
||||||
|
<RowDefinition Height="Auto" MinHeight="128" />
|
||||||
|
<RowDefinition />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<!-- Header -->
|
<!-- Header -->
|
||||||
<Label Grid.Row="0" Grid.ColumnSpan="4" FontSize="20" HorizontalAlignment="Left">
|
<Label Grid.Row="0" Grid.ColumnSpan="4" FontSize="20">
|
||||||
<Label.Content>
|
<Label.Content>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBlock Text="{Binding Path=Layer.Name}" />
|
<TextBlock Text="{Binding Path=Layer.Name}" />
|
||||||
@ -37,29 +64,159 @@
|
|||||||
</Label>
|
</Label>
|
||||||
|
|
||||||
<!-- Layer name -->
|
<!-- Layer name -->
|
||||||
<TextBlock Grid.Row="1" Grid.Column="0" Margin="10" FontSize="16" Text="Name:" />
|
<TextBlock Grid.Row="1" Grid.Column="0" Margin="10,12" FontSize="13.333" Text="Name:"
|
||||||
<TextBox Grid.Row="1" Grid.Column="1" x:Name="Name" Margin="10" />
|
VerticalAlignment="Center" Height="18" />
|
||||||
|
<TextBox Grid.Row="1" Grid.Column="1" x:Name="Name" Margin="10" Text="{Binding Path=Layer.Name}" />
|
||||||
|
|
||||||
<!-- Layer type -->
|
<!-- Layer type -->
|
||||||
<TextBlock Grid.Row="1" Grid.Column="2" Margin="10" FontSize="16" Text="Type:" />
|
<TextBlock Grid.Row="1" Grid.Column="2" Margin="10,12" FontSize="13.333" Text="Type:"
|
||||||
<ComboBox Grid.Row="1" Grid.Column="3" x:Name="Operators" Margin="10" />
|
VerticalAlignment="Center" Height="18" />
|
||||||
|
|
||||||
|
<ComboBox Grid.Row="1" Grid.Column="3" ItemsSource="{Binding Source={StaticResource LayerEnumValues}}"
|
||||||
|
Margin="10" SelectedItem="{Binding Path=Layer.LayerType}">
|
||||||
|
<ComboBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<TextBlock Text="{Binding Converter={StaticResource HEnumDescriptionConverter}}" />
|
||||||
|
</DataTemplate>
|
||||||
|
</ComboBox.ItemTemplate>
|
||||||
|
</ComboBox>
|
||||||
|
|
||||||
<!-- Condition editor -->
|
<!-- Condition editor -->
|
||||||
<Label Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="4" FontSize="20" Content="Display if.." />
|
<Label Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="4" FontSize="20" Content="Display if.." />
|
||||||
<ScrollViewer Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" Height="145">
|
<Border Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" BorderThickness="1"
|
||||||
<ListBox x:Name="LayerConditionVms" />
|
BorderBrush="{StaticResource GrayBrush7}" Margin="10,0">
|
||||||
</ScrollViewer>
|
<ListBox Height="138" x:Name="LayerConditionVms" ScrollViewer.VerticalScrollBarVisibility="Visible">
|
||||||
<Button Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" x:Name="AddCondition" Content="Add condition" VerticalAlignment="Top"
|
<ListBox.Template>
|
||||||
Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Left" Margin="10,10,0,0"
|
<ControlTemplate>
|
||||||
Height="20" />
|
<ScrollViewer>
|
||||||
|
<ItemsPresenter />
|
||||||
|
</ScrollViewer>
|
||||||
|
</ControlTemplate>
|
||||||
|
</ListBox.Template>
|
||||||
|
</ListBox>
|
||||||
|
</Border>
|
||||||
|
<Button Grid.Row="4" Grid.Column="3" x:Name="AddCondition" Content="Add condition"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Right" Height="30"
|
||||||
|
Margin="0,10,10,27" ScrollViewer.VerticalScrollBarVisibility="Auto" Grid.RowSpan="2" />
|
||||||
|
|
||||||
<!-- Advanced -->
|
<!-- Advanced -->
|
||||||
<Label Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" FontSize="20" HorizontalAlignment="Left"
|
<Label Grid.Row="5" Grid.Column="0" FontSize="20" HorizontalAlignment="Left"
|
||||||
Content="Advanced" />
|
Content="Advanced" Width="97" />
|
||||||
|
|
||||||
<Button Grid.Row="6" Grid.Column="0" x:Name="Apply" Content="Apply" VerticalAlignment="Bottom"
|
<!-- X -->
|
||||||
Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Left" Margin="10,0,0,10"
|
<TextBlock Grid.Row="6" Grid.Column="0" Margin="10" FontSize="13.333" Text="X Position:"
|
||||||
Height="20" Grid.ColumnSpan="2" />
|
VerticalAlignment="Center" Height="18" />
|
||||||
|
<TextBox Grid.Row="6" Grid.Column="1" Margin="10" Text="{Binding Path=ProposedProperties.X}" />
|
||||||
|
|
||||||
|
<!-- Y -->
|
||||||
|
<TextBlock Grid.Row="6" Grid.Column="2" Margin="10" FontSize="13.333" Text="Y Position:"
|
||||||
|
VerticalAlignment="Center" Height="18" />
|
||||||
|
<TextBox Grid.Row="6" Grid.Column="3" Margin="10" Text="{Binding Path=ProposedProperties.Y}" />
|
||||||
|
|
||||||
|
<!-- Height -->
|
||||||
|
<TextBlock Grid.Row="7" Grid.Column="0" Margin="10" FontSize="13.333" Text="Height:" VerticalAlignment="Center"
|
||||||
|
Height="18" />
|
||||||
|
<TextBox Grid.Row="7" Grid.Column="1" Margin="10" Text="{Binding Path=ProposedProperties.Height}" />
|
||||||
|
|
||||||
|
<!-- Width -->
|
||||||
|
<TextBlock Grid.Row="7" Grid.Column="2" Margin="10" FontSize="13.333" Text="Width:" VerticalAlignment="Center"
|
||||||
|
Height="18" />
|
||||||
|
<TextBox Grid.Row="7" Grid.Column="3" Margin="10" Text="{Binding Path=ProposedProperties.Width}" />
|
||||||
|
|
||||||
|
<!-- Opacity -->
|
||||||
|
<TextBlock Grid.Row="8" Grid.Column="0" Margin="10" FontSize="13.333" Text="Opacity:"
|
||||||
|
VerticalAlignment="Center" Height="18" />
|
||||||
|
<Slider x:Name="Sensitivity" Grid.Row="8" Grid.Column="1" VerticalAlignment="Center"
|
||||||
|
TickPlacement="BottomRight" TickFrequency="20"
|
||||||
|
Value="{Binding Path=ProposedProperties.Opacity, Mode=TwoWay}" Minimum="1" Maximum="255"
|
||||||
|
SmallChange="1" Margin="10,7" Height="24" />
|
||||||
|
|
||||||
|
<!-- ContainedBrush -->
|
||||||
|
<TextBlock Grid.Row="8" Grid.Column="2" Margin="10" FontSize="13.333" Text="Contained colors:"
|
||||||
|
VerticalAlignment="Center" Height="18" />
|
||||||
|
<controls:ToggleSwitch IsChecked="{Binding Path=ProposedProperties.ContainedBrush, Mode=TwoWay}" Grid.Row="8"
|
||||||
|
Grid.Column="3" OnLabel="Yes" OffLabel="No" Margin="10,1,5,1" VerticalAlignment="Center"
|
||||||
|
Height="36" />
|
||||||
|
|
||||||
|
<!-- Rotate -->
|
||||||
|
<TextBlock Grid.Row="9" Grid.Column="0" Margin="10" FontSize="13.333" Text="Rotate:" VerticalAlignment="Center"
|
||||||
|
Height="18" />
|
||||||
|
<controls:ToggleSwitch IsChecked="{Binding Path=ProposedProperties.Rotate, Mode=TwoWay}" Grid.Row="9"
|
||||||
|
Grid.Column="1" OnLabel="Yes" OffLabel="No" Margin="10,1,5,1" VerticalAlignment="Center"
|
||||||
|
Height="36" />
|
||||||
|
|
||||||
|
<!-- RotateSpeed -->
|
||||||
|
<TextBlock Grid.Row="9" Grid.Column="2" Margin="10" FontSize="13.333" Text="Rotation speed:"
|
||||||
|
VerticalAlignment="Center" Height="18" />
|
||||||
|
<Slider x:Name="RotationSpeed" Grid.Row="9" Grid.Column="3" VerticalAlignment="Center"
|
||||||
|
TickPlacement="BottomRight" TickFrequency="1"
|
||||||
|
Value="{Binding Path=ProposedProperties.RotateSpeed, Mode=TwoWay}" Minimum="1" Maximum="10"
|
||||||
|
SmallChange="1" IsSnapToTickEnabled="True" Margin="10,7" Height="24" />
|
||||||
|
|
||||||
|
<!-- Color direction -->
|
||||||
|
<TextBlock Grid.Row="10" Grid.Column="0" Margin="10,13,10,0" FontSize="13.333" Text="Color direction:"
|
||||||
|
VerticalAlignment="Top" Height="18" />
|
||||||
|
<ComboBox Grid.Row="10" Grid.Column="1" ItemsSource="{Binding Source={StaticResource ColorEnumValues}}"
|
||||||
|
Margin="10,10,10,0" SelectedItem="{Binding Path=ProposedProperties.ColorMode}"
|
||||||
|
VerticalAlignment="Top" Height="22">
|
||||||
|
<ComboBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<TextBlock Text="{Binding Converter={StaticResource HEnumDescriptionConverter}}" />
|
||||||
|
</DataTemplate>
|
||||||
|
</ComboBox.ItemTemplate>
|
||||||
|
</ComboBox>
|
||||||
|
|
||||||
|
<!-- Colors -->
|
||||||
|
<TextBlock Grid.Row="10" Grid.Column="2" Margin="10,13,10,0" FontSize="13.333" Text="Colors:"
|
||||||
|
VerticalAlignment="Top" Height="18" />
|
||||||
|
<StackPanel Grid.Row="10" Grid.Column="3" Grid.RowSpan="2">
|
||||||
|
<Border BorderThickness="1" BorderBrush="{StaticResource GrayBrush7}" Margin="10">
|
||||||
|
<ListBox Height="108" ItemsSource="{Binding Path=ProposedColors}"
|
||||||
|
ScrollViewer.VerticalScrollBarVisibility="Visible" VerticalAlignment="Top">
|
||||||
|
<ListBox.Template>
|
||||||
|
<ControlTemplate>
|
||||||
|
<ScrollViewer>
|
||||||
|
<ItemsPresenter />
|
||||||
|
</ScrollViewer>
|
||||||
|
</ControlTemplate>
|
||||||
|
</ListBox.Template>
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<xctk:ColorPicker x:Name="Bottom" SelectedColor="{Binding Path=., Mode=TwoWay}"
|
||||||
|
VerticalAlignment="Center" Width="100" Height="26" />
|
||||||
|
<Button x:Name="Delete" Width="26" Height="26"
|
||||||
|
Style="{DynamicResource SquareButtonStyle}"
|
||||||
|
VerticalAlignment="Top" HorizontalAlignment="Right" Margin="5,5,0,5"
|
||||||
|
cal:Message.Attach="DeleteColor($datacontext)">
|
||||||
|
<Button.Content>
|
||||||
|
<Rectangle Fill="Black" Width="12" Height="12">
|
||||||
|
<Rectangle.OpacityMask>
|
||||||
|
<VisualBrush Visual="{StaticResource appbar_delete}" Stretch="Fill" />
|
||||||
|
</Rectangle.OpacityMask>
|
||||||
|
</Rectangle>
|
||||||
|
</Button.Content>
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
</Border>
|
||||||
|
<Button x:Name="AddColor" Content="Add color"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Right" Height="30"
|
||||||
|
Margin="10,0,10,10" ScrollViewer.VerticalScrollBarVisibility="Auto" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Preview -->
|
||||||
|
<TextBlock Grid.Row="11" Grid.Column="0" Margin="10,13,10,0" FontSize="13.333" Text="Preview:"
|
||||||
|
VerticalAlignment="Top" Height="18" />
|
||||||
|
<Image Grid.Row="11" Grid.Column="1" Grid.ColumnSpan="2" Margin="10" Source="{Binding LayerImage}" />
|
||||||
|
|
||||||
|
<Button Grid.Row="12" Grid.Column="0" x:Name="Apply" Content="Apply" VerticalAlignment="Bottom"
|
||||||
|
Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Left" Margin="10,0,0,20"
|
||||||
|
Height="30" />
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
</controls:MetroWindow>
|
</controls:MetroWindow>
|
||||||
@ -7,7 +7,7 @@
|
|||||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||||
xmlns:cal="http://www.caliburnproject.org"
|
xmlns:cal="http://www.caliburnproject.org"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="772.5" d:DesignWidth="1335">
|
d:DesignHeight="482.812" d:DesignWidth="1029.95">
|
||||||
<Grid Width="Auto" Height="Auto">
|
<Grid Width="Auto" Height="Auto">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user