Moved skin designer from plugin to application. Implemented many things.

This commit is contained in:
2014-10-11 10:38:47 +03:00
parent 180e4bb9fd
commit 7ed85169e8
30 changed files with 638 additions and 1041 deletions

View File

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Media;
namespace RainmeterStudio.Editor.SkinDesigner.Controls
{
public class HoverAdorner : Adorner
{
public HoverAdorner(UIElement adornedElement)
: base(adornedElement)
{
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
// Calculate DPI factor
Matrix matrix = PresentationSource.FromVisual(this).CompositionTarget.TransformToDevice;
double dpiFactor = 1.0 / matrix.M11;
// Rectangle
Rect rect = new Rect(AdornedElement.DesiredSize);
Rect selectionRect = new Rect(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2);
// Create pen
Pen pen = new Pen(Brushes.Gray, 1 * dpiFactor);
pen.DashStyle = DashStyles.Dash;
// Create a guidelines set for on-pixel drawing
GuidelineSet guidelines = new GuidelineSet();
guidelines.GuidelinesX.Add(selectionRect.Left + pen.Thickness / 2);
guidelines.GuidelinesX.Add(selectionRect.Right + pen.Thickness / 2);
guidelines.GuidelinesY.Add(selectionRect.Top + pen.Thickness / 2);
guidelines.GuidelinesY.Add(selectionRect.Bottom + pen.Thickness / 2);
// Draw
drawingContext.PushGuidelineSet(guidelines);
drawingContext.DrawRectangle(null, pen, selectionRect);
drawingContext.Pop();
}
}
}

View File

@ -0,0 +1,11 @@
<UserControl x:Class="RainmeterStudio.Editor.SkinDesigner.Controls.MeterControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Canvas Name="canvas">
</Canvas>
</UserControl>

View File

@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using RainmeterStudio.Rainmeter;
namespace RainmeterStudio.Editor.SkinDesigner.Controls
{
/// <summary>
/// Interaction logic for MeterControl.xaml
/// </summary>
public partial class MeterControl : UserControl
{
private Skin _skin;
/// <summary>
/// Gets or sets the skin being edited
/// </summary>
public Skin Skin
{
get
{
return Skin;
}
set
{
_skin = value;
Reset();
}
}
/// <summary>
/// Gets an enumerable with the meter items
/// </summary>
public IEnumerable<Meter> Items { get { return Skin.Meters; } }
/// <summary>
/// Gets a collection with the currently selected items
/// </summary>
public ObservableCollection<Meter> SelectedItems { get; private set; }
/// <summary>
/// Gets or sets the currently selected item
/// </summary>
public Meter SelectedItem { get; set; }
/// <summary>
/// Gets or sets the selected item index
/// </summary>
public int SelectedIndex { get; set; }
/// <summary>
/// Initializes the meter control
/// </summary>
public MeterControl()
{
InitializeComponent();
Loaded += MeterControl_Loaded;
}
void MeterControl_Loaded(object sender, RoutedEventArgs e)
{
//AdornerLayer.GetAdornerLayer(ellipse).Add(new SelectAdorner(ellipse));
}
private void Reset()
{
}
}
}

View File

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Media;
namespace RainmeterStudio.Editor.SkinDesigner.Controls
{
public class SelectAdorner : Adorner
{
public SelectAdorner(UIElement adornedElement)
: base(adornedElement)
{
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
// Calculate DPI factor
Matrix matrix = PresentationSource.FromVisual(this).CompositionTarget.TransformToDevice;
double dpiFactor = 1.0 / matrix.M11;
// Rectangle
Rect rect = new Rect(AdornedElement.DesiredSize);
Rect selectionRect = new Rect(rect.X - 1, rect.Y - 1, rect.Width + 2, rect.Height + 2);
// Create pen
Pen pen = new Pen(Brushes.Blue, 1 * dpiFactor);
// Create a guidelines set for on-pixel drawing
GuidelineSet guidelines = new GuidelineSet();
guidelines.GuidelinesX.Add(selectionRect.Left + pen.Thickness / 2);
guidelines.GuidelinesX.Add(selectionRect.Right + pen.Thickness / 2);
guidelines.GuidelinesY.Add(selectionRect.Top + pen.Thickness / 2);
guidelines.GuidelinesY.Add(selectionRect.Bottom + pen.Thickness / 2);
// Draw
drawingContext.PushGuidelineSet(guidelines);
drawingContext.DrawRectangle(null, pen, selectionRect);
drawingContext.Pop();
}
}
}