1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 21:38:38 +00:00

Layer preview WIP (Also means actual drawing is being worked on)

This commit is contained in:
SpoinkyNL 2016-04-01 22:30:57 +02:00
parent 1a6c4d55da
commit 6cad16ccd5
11 changed files with 448 additions and 93 deletions

View File

@ -188,6 +188,7 @@
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<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\StickyValue.cs" />
<Compile Include="Utilities\Updater.cs" />
<Compile Include="Utilities\ValueConverters.cs" />
<Compile Include="ViewModels\Abstract\EffectViewModel.cs" />
<Compile Include="ViewModels\Abstract\GameViewModel.cs" />
<Compile Include="ViewModels\EffectsViewModel.cs" />

View File

@ -1,10 +1,8 @@
using System;
using System.Drawing;
using System.Drawing;
using Artemis.KeyboardProviders.Razer.Utilities;
using Corale.Colore.Core;
using Corale.Colore.Razer.Keyboard;
using ColoreColor = Corale.Colore.Core.Color;
using KeyboardCustom = Corale.Colore.Razer.Keyboard.Effects.Custom;
using Corale.Colore.Razer;
using Constants = Corale.Colore.Razer.Keyboard.Constants;
namespace Artemis.KeyboardProviders.Razer
{
@ -24,9 +22,9 @@ namespace Artemis.KeyboardProviders.Razer
return false;
// 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 blackWidowTeFound = Chroma.Instance.Query(Corale.Colore.Razer.Devices.BlackwidowTe).Connected;
return (blackWidowFound || blackWidowTeFound);
var blackWidowFound = Chroma.Instance.Query(Devices.Blackwidow).Connected;
var blackWidowTeFound = Chroma.Instance.Query(Devices.BlackwidowTe).Connected;
return blackWidowFound || blackWidowTeFound;
}
public override void Enable()
@ -48,7 +46,7 @@ namespace Artemis.KeyboardProviders.Razer
public override void DrawBitmap(Bitmap bitmap)
{
var razerArray = RazerUtilities.BitmapColorArray(bitmap, Height, Width);
Chroma.Instance.Keyboard.SetCustom(razerArray);
}
}

View File

@ -1,5 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Media;
@ -24,7 +24,7 @@ namespace Artemis.Models.Profiles
LayerConditions = new List<LayerConditionModel>();
LayerProperties = new List<LayerDynamicPropertiesModel>();
_drawer = new LayerDrawer(this);
_drawer = new LayerDrawer(this, 4);
}
public string Name { get; set; }
@ -36,36 +36,41 @@ namespace Artemis.Models.Profiles
public List<LayerDynamicPropertiesModel> LayerProperties { get; set; }
[JsonIgnore]
public LayerPropertiesModel LayerCalculatedProperties { get; }
public LayerPropertiesModel LayerCalculatedProperties { get; set; }
[JsonIgnore]
public ImageSource LayerImage => _drawer.GetPreviewImage();
public ImageSource LayerImage => _drawer.GetThumbnail();
public bool ConditionsMet<T>(IGameDataModel 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)
{
if (!ConditionsMet<T>(dataModel))
return;
Update<T>(dataModel);
switch (LayerType)
{
case LayerType.Folder:
DrawChildren<T>(dataModel, g);
break;
case LayerType.Rectangle:
_drawer.DrawRectangle(g);
break;
case LayerType.Ellipse:
_drawer.DrawEllipse(g);
break;
default:
throw new ArgumentOutOfRangeException();
}
if (LayerType == LayerType.Folder)
DrawChildren<T>(dataModel, g);
else if (LayerType == LayerType.KeyboardRectangle || LayerType == LayerType.KeyboardEllipse)
_drawer.Draw(g);
else if (LayerType == LayerType.KeyboardGif)
_drawer.DrawGif(g);
else if (LayerType == LayerType.Mouse)
_drawer.UpdateMouse();
else if (LayerType == LayerType.Headset)
_drawer.UpdateHeadset();
}
private void Update<T>(IGameDataModel dataModel)
@ -84,8 +89,11 @@ namespace Artemis.Models.Profiles
public enum LayerType
{
Folder,
Rectangle,
Ellipse
[Description("Folder")] Folder,
[Description("Keyboard - Rectangle")] KeyboardRectangle,
[Description("Keyboard - Ellipse")] KeyboardEllipse,
[Description("Keyboard - GIF")] KeyboardGif,
[Description("Mouse")] Mouse,
[Description("Headset")] Headset
}
}

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Media;
using System.Drawing.Drawing2D;
namespace Artemis.Models.Profiles
@ -12,7 +13,7 @@ namespace Artemis.Models.Profiles
public int Height { get; set; }
public int Opacity { get; set; }
public bool ContainedBrush { get; set; }
public LinearGradientMode GradientMode { get; set; }
public LayerColorMode ColorMode { get; set; }
public bool Rotate { get; set; }
public double RotateSpeed { get; set; }
public List<Color> Colors { get; set; }
@ -22,4 +23,16 @@ namespace Artemis.Models.Profiles
Colors = new List<Color>();
}
}
public enum LayerColorMode
{
[Description("Left to right")]
Horizontal,
[Description("Top to bottom")]
Vertical,
[Description("Shift")]
Shift,
[Description("Pulse")]
Pulse,
}
}

View File

@ -4,9 +4,25 @@ namespace Artemis.Utilities
{
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)
{
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
}
}

View File

@ -13,33 +13,36 @@ namespace Artemis.Utilities
internal class LayerDrawer
{
private readonly LayerModel _layerModel;
private LinearGradientBrush _brush;
private Rectangle _rectangle;
private double _rotationProgress;
private Rectangle _userRectangle;
public LayerDrawer(LayerModel layerModel)
public LayerDrawer(LayerModel layerModel, int scale)
{
Scale = scale;
_layerModel = layerModel;
_rotationProgress = 0;
}
public void Draw(Graphics graphics)
{
_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);
public int Scale { get; set; }
if (_layerModel.LayerType == LayerType.Ellipse)
DrawEllipse(graphics);
else if (_layerModel.LayerType == LayerType.Ellipse)
DrawRectangle(graphics);
public void Draw(Graphics g)
{
// Set up variables for this frame
_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
_rotationProgress = _rotationProgress + _layerModel.LayerCalculatedProperties.RotateSpeed;
@ -50,23 +53,24 @@ namespace Artemis.Utilities
_rotationProgress = _layerModel.LayerCalculatedProperties.RotateSpeed;
}
public BitmapImage GetPreviewImage()
public BitmapImage GetThumbnail()
{
_rectangle = new Rectangle(0, 0, 18, 18);
_userRectangle = new Rectangle(0, 0, 18, 18);
_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);
using (var g = Graphics.FromImage(bitmap))
{
g.SmoothingMode = SmoothingMode.AntiAlias;
if (_layerModel.LayerType == LayerType.Ellipse)
if (_layerModel.LayerType == LayerType.KeyboardEllipse)
{
g.FillEllipse(brush, _rectangle);
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.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(_userRectangle.X, _userRectangle.Y, _userRectangle.Width, _userRectangle.Height);
return new LinearGradientBrush(rect, Color.Transparent, Color.Transparent,
_layerModel.LayerCalculatedProperties.GradientMode)
if (_layerModel.LayerCalculatedProperties.ColorMode == LayerColorMode.Horizontal)
return new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, LinearGradientMode.Horizontal)
{
InterpolationColors = colorBlend
};
return new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, LinearGradientMode.Vertical)
{
InterpolationColors = colorBlend
};
@ -169,5 +183,13 @@ namespace Artemis.Utilities
tilebleColors.Add(sourceColors.FirstOrDefault());
return tilebleColors;
}
public void UpdateMouse()
{
}
public void UpdateHeadset()
{
}
}
}

View 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;
}
}
}

View File

@ -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.Utilities;
using Artemis.ViewModels.LayerEditor;
using Caliburn.Micro;
using Color = System.Windows.Media.Color;
namespace Artemis.ViewModels
{
public class LayerEditorViewModel<T> : Screen
{
private readonly BackgroundWorker _previewWorker;
private LayerModel _layer;
private LayerPropertiesModel _proposedProperties;
public LayerEditorViewModel(LayerModel layer)
{
Layer = layer;
DataModelProps = new BindableCollection<GeneralHelpers.PropertyCollection>();
ProposedColors = new BindableCollection<Color>();
ProposedProperties = new LayerPropertiesModel();
ProposedColors.CollectionChanged += UpdateColors;
DataModelProps.AddRange(GeneralHelpers.GenerateTypeMap<T>());
LayerConditionVms =
new BindableCollection<LayerConditionViewModel<T>>(
layer.LayerConditions.Select(c => new LayerConditionViewModel<T>(this, c, DataModelProps)));
ProposedProperties = new LayerPropertiesModel();
GeneralHelpers.CopyProperties(ProposedProperties, Layer.LayerUserProperties);
_previewWorker = new BackgroundWorker();
_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 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()
{
@ -48,15 +131,32 @@ namespace Artemis.ViewModels
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()
{
GeneralHelpers.CopyProperties(Layer.LayerUserProperties, ProposedProperties);
}
public void DeleteCondition(LayerConditionViewModel<T> layerConditionViewModel, LayerConditionModel layerConditionModel)
public void DeleteCondition(LayerConditionViewModel<T> layerConditionViewModel,
LayerConditionModel layerConditionModel)
{
LayerConditionVms.Remove(layerConditionViewModel);
Layer.LayerConditions.Remove(layerConditionModel);
}
public override void CanClose(Action<bool> callback)
{
_previewWorker.CancelAsync();
base.CanClose(callback);
}
}
}

View File

@ -22,7 +22,7 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- 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">
<ComboBox.ItemTemplate>
<DataTemplate>
@ -40,13 +40,13 @@
VerticalAlignment="Top" DisplayMemberPath="Display" />
<!-- 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>
<ColumnDefinition Width="125"/>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<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>
<Button Grid.Column="1" x:Name="Delete" Width="26" Height="26" Style="{DynamicResource SquareButtonStyle}" VerticalAlignment="Top" HorizontalAlignment="Right" >
<Button.Content>

View File

@ -3,18 +3,39 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
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: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"
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">
<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.ColumnDefinitions>
<ColumnDefinition Width="25*" />
<ColumnDefinition Width="53*" />
<ColumnDefinition Width="25*" />
<ColumnDefinition Width="53*" />
<ColumnDefinition Width="65*" />
<ColumnDefinition Width="86*" />
<ColumnDefinition Width="65*" />
<ColumnDefinition Width="86*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
@ -23,11 +44,17 @@
<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>
<!-- Header -->
<Label Grid.Row="0" Grid.ColumnSpan="4" FontSize="20" HorizontalAlignment="Left">
<Label Grid.Row="0" Grid.ColumnSpan="4" FontSize="20">
<Label.Content>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Layer.Name}" />
@ -37,29 +64,159 @@
</Label>
<!-- Layer name -->
<TextBlock Grid.Row="1" Grid.Column="0" Margin="10" FontSize="16" Text="Name:" />
<TextBox Grid.Row="1" Grid.Column="1" x:Name="Name" Margin="10" />
<TextBlock Grid.Row="1" Grid.Column="0" Margin="10,12" FontSize="13.333" Text="Name:"
VerticalAlignment="Center" Height="18" />
<TextBox Grid.Row="1" Grid.Column="1" x:Name="Name" Margin="10" Text="{Binding Path=Layer.Name}" />
<!-- Layer type -->
<TextBlock Grid.Row="1" Grid.Column="2" Margin="10" FontSize="16" Text="Type:" />
<ComboBox Grid.Row="1" Grid.Column="3" x:Name="Operators" Margin="10" />
<TextBlock Grid.Row="1" Grid.Column="2" Margin="10,12" FontSize="13.333" Text="Type:"
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 -->
<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">
<ListBox x:Name="LayerConditionVms" />
</ScrollViewer>
<Button Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" x:Name="AddCondition" Content="Add condition" VerticalAlignment="Top"
Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Left" Margin="10,10,0,0"
Height="20" />
<Border Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" BorderThickness="1"
BorderBrush="{StaticResource GrayBrush7}" Margin="10,0">
<ListBox Height="138" x:Name="LayerConditionVms" ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListBox.Template>
<ControlTemplate>
<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 -->
<Label Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" FontSize="20" HorizontalAlignment="Left"
Content="Advanced" />
<Label Grid.Row="5" Grid.Column="0" FontSize="20" HorizontalAlignment="Left"
Content="Advanced" Width="97" />
<Button Grid.Row="6" Grid.Column="0" x:Name="Apply" Content="Apply" VerticalAlignment="Bottom"
Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Left" Margin="10,0,0,10"
Height="20" Grid.ColumnSpan="2" />
<!-- X -->
<TextBlock Grid.Row="6" Grid.Column="0" Margin="10" FontSize="13.333" Text="X Position:"
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>
</controls:MetroWindow>

View File

@ -7,7 +7,7 @@
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:cal="http://www.caliburnproject.org"
mc:Ignorable="d"
d:DesignHeight="772.5" d:DesignWidth="1335">
d:DesignHeight="482.812" d:DesignWidth="1029.95">
<Grid Width="Auto" Height="Auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />