Browse Source

Parse paths more correctly.

pull/4/head
Steven Kirk 12 years ago
parent
commit
e3de24fd20
  1. 2
      Perspex.Direct2D1/Media/StreamGeometryContextImpl.cs
  2. 19
      Perspex/Controls/Decorator.cs
  3. 25
      Perspex/Media/Brushes.cs
  4. 16
      Perspex/Media/PathMarkupParser.cs
  5. 1
      Perspex/Perspex.csproj
  6. 6
      Perspex/Themes/Default/CheckBoxStyle.cs
  7. 40
      TestApplication/Program.cs

2
Perspex.Direct2D1/Media/StreamGeometryContextImpl.cs

@ -6,10 +6,8 @@
namespace Perspex.Direct2D1.Media
{
using System;
using Perspex.Media;
using SharpDX.Direct2D1;
using Splat;
public class StreamGeometryContextImpl : IStreamGeometryContextImpl
{

19
Perspex/Controls/Decorator.cs

@ -77,6 +77,9 @@ namespace Perspex.Controls
protected override Size MeasureContent(Size availableSize)
{
double width = 0;
double height = 0;
if (this.Visibility != Visibility.Collapsed)
{
Control content = this.Content;
@ -84,11 +87,23 @@ namespace Perspex.Controls
if (content != null)
{
content.Measure(availableSize);
return content.DesiredSize.Value.Inflate(this.Padding);
Size s = content.DesiredSize.Value.Inflate(this.Padding);
width = s.Width;
height = s.Height;
}
if (this.Width > 0)
{
width = this.Width;
}
if (this.Height > 0)
{
height = this.Height;
}
}
return new Size();
return new Size(width, height);
}
}
}

25
Perspex/Media/Brushes.cs

@ -0,0 +1,25 @@
// -----------------------------------------------------------------------
// <copyright file="Brushes.cs" company="Steven Kirk">
// Copyright 2013 MIT Licence. See licence.md for more information.
// </copyright>
// -----------------------------------------------------------------------
namespace Perspex.Media
{
/// <summary>
/// Predefined brushes.
/// </summary>
public static class Brushes
{
static Brushes()
{
Black = new SolidColorBrush(0xff000000);
}
public static SolidColorBrush Black
{
get;
private set;
}
}
}

16
Perspex/Media/PathMarkupParser.cs

@ -67,7 +67,6 @@ namespace Perspex.Media
{
Command lastCommand = Command.None;
Command command;
Point startPoint = new Point();
Point point = new Point();
while ((command = ReadCommand(reader, lastCommand)) != Command.Eof)
@ -81,7 +80,12 @@ namespace Perspex.Media
case Command.Move:
case Command.MoveRelative:
point = startPoint = ReadPoint(reader);
if (openFigure)
{
this.context.EndFigure(false);
}
point = ReadPoint(reader);
this.context.BeginFigure(point, true);
openFigure = true;
break;
@ -139,7 +143,7 @@ namespace Perspex.Media
if (openFigure)
{
this.context.EndFigure(true);
this.context.EndFigure(false);
}
}
}
@ -158,7 +162,6 @@ namespace Perspex.Media
{
char c = (char)i;
Command command = Command.None;
bool canMove = lastCommand == Command.None || lastCommand == Command.FillRule || lastCommand == Command.Close;
if (!Commands.TryGetValue(c, out command))
{
@ -173,11 +176,6 @@ namespace Perspex.Media
}
}
if (!canMove && command <= Command.MoveRelative)
{
command += 2;
}
reader.Read();
return command;
}

1
Perspex/Perspex.csproj

@ -82,6 +82,7 @@
<Compile Include="Input\InputManager.cs" />
<Compile Include="Input\Raw\RawInputEventArgs.cs" />
<Compile Include="Input\Raw\RawMouseEventArgs.cs" />
<Compile Include="Media\Brushes.cs" />
<Compile Include="Media\IStreamGeometryContextImpl.cs" />
<Compile Include="Media\IGeometryImpl.cs" />
<Compile Include="Media\IStreamGeometryImpl.cs" />

6
Perspex/Themes/Default/CheckBoxStyle.cs

@ -56,13 +56,13 @@ namespace Perspex.Themes.Default
new Border
{
BorderThickness = 2,
BorderBrush = new SolidColorBrush(Color.FromUInt32(0xff000000)),
BorderBrush = Brushes.Black,
Padding = new Thickness(8),
Content = new Path
{
Id = "checkMark",
Data = StreamGeometry.Parse("M0,0 L10,10 Z M10,0 L0,10"),
Stroke = new SolidColorBrush(Color.FromUInt32(0xff000000)),
Data = StreamGeometry.Parse("M0,0 L10,10 M10,0 L0,10"),
Stroke = Brushes.Black,
StrokeThickness = 2,
VerticalAlignment = VerticalAlignment.Center,
},

40
TestApplication/Program.cs

@ -9,6 +9,7 @@ using Perspex;
using Perspex.Controls;
using Perspex.Input;
using Perspex.Media;
using Perspex.Shapes;
using Perspex.Styling;
using Perspex.Themes.Default;
using Perspex.Windows;
@ -43,23 +44,36 @@ namespace TestApplication
Window window = new Window
{
Content = new StackPanel
{
Content = new StackPanel
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Orientation = Orientation.Vertical,
Gap = 6,
Children = new PerspexList<Control>
{
//new Button
//{
// Content = "Button",
//},
//new Button
//{
// Content = "Explict Background",
// Background = new SolidColorBrush(0xffa0a0ff),
//},
Children = new PerspexList<Control>
{
new Border
{
BorderBrush = Brushes.Black,
BorderThickness = 1,
Width = 10,
Height = 10,
},
new Path
{
Data = StreamGeometry.Parse("M0,0 L10,0"),
Stroke = Brushes.Black,
StrokeThickness = 1,
},
new Button
{
Content = "Button",
},
new Button
{
Content = "Explict Background",
Background = new SolidColorBrush(0xffa0a0ff),
},
new CheckBox
{
Content = "Checkbox",

Loading…
Cancel
Save