This commit is contained in:
lytico 2012-03-27 21:45:49 +02:00 коммит произвёл Lluis Sanchez
Родитель 6de73c72f5
Коммит c1f47d09c8
4 изменённых файлов: 31 добавлений и 27 удалений

Просмотреть файл

@ -102,11 +102,11 @@ namespace Samples
// proofing rotate, and printing size to see the values
ctx.Save ();
text = new TextLayout (ctx);
text.Font = this.Font.WithSize (10);
text.Text = string.Format ("Size 1 {0}\r\nSize 2 {1}\r\nSize 3 {2} Scale {3}",
size1, size2, size3, scale);
//text.Width = -1; // this clears textsize
text.Width = -1; // this clears textsize
ctx.Rotate (5);
// maybe someone knows a formula with angle and textsize to calculyte ty
var ty = 30;

Просмотреть файл

@ -63,9 +63,11 @@ namespace Xwt.WPFBackend
public void Arc (object backend, double xc, double yc, double radius, double angle1, double angle2)
{
var c = (DrawingContext) backend;
c.Path.AddArc ((float) (xc - radius), (float) (yc - radius), (float) radius * 2, (float) radius * 2, (float) angle1,
(float) (angle2 - angle1));
var c = (DrawingContext)backend;
if (angle1 > 0 && angle2 == 0)
angle2 = 360;
c.Path.AddArc ((float)(xc - radius), (float)(yc - radius), (float)radius * 2, (float)radius * 2, (float)angle1,
(float)(angle2 - angle1));
var current = c.Path.GetLastPoint ();
c.CurrentX = current.X;
@ -95,24 +97,13 @@ namespace Xwt.WPFBackend
public void CurveTo (object backend, double x1, double y1, double x2, double y2, double x3, double y3)
{
var c = (DrawingContext) backend;
bool moved = false;
if (c.Path.PointCount != 0) {
var lastPoint = c.Path.GetLastPoint ();
moved = lastPoint.X != c.CurrentX && lastPoint.Y != c.CurrentY;
}
var path = moved ? new GraphicsPath () : c.Path;
path.AddBezier (c.CurrentX, c.CurrentY,
(float) x1, (float) y1,
(float) x2, (float) y2,
(float) x3, (float) y3);
if (moved)
c.Path.AddPath (path, connect: false);
c.CurrentX = (float) x3;
c.CurrentY = (float) y3;
var c = (DrawingContext)backend;
c.Path.AddBezier (c.CurrentX, c.CurrentY,
(float)x1, (float)y1,
(float)x2, (float)y2,
(float)x3, (float)y3);
c.CurrentX = (float)x3;
c.CurrentY = (float)y3;
}
public void Fill (object backend)
@ -165,6 +156,13 @@ namespace Xwt.WPFBackend
public void RelCurveTo (object backend, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3)
{
var c = (DrawingContext)backend;
c.Path.AddBezier (c.CurrentX, c.CurrentY,
(float)(c.CurrentX + dx1), (float)(c.CurrentY + dy1),
(float)(c.CurrentX + dx2), (float)(c.CurrentY + dy2),
(float)(c.CurrentX + dx3), (float)(c.CurrentY + dy3));
c.CurrentX = (float)(c.CurrentX + dx3);
c.CurrentY = (float)(c.CurrentX + dy3);
}
public void RelLineTo (object backend, double dx, double dy)
@ -269,10 +267,10 @@ namespace Xwt.WPFBackend
{
var c = (DrawingContext) backend;
var sfont = layout.Font.ToDrawingFont ();
var measure = c.Graphics.MeasureString (layout.Text, sfont);
var measure = layout.GetSize ();
c.Graphics.DrawString (layout.Text, layout.Font.ToDrawingFont (), c.Brush,
new RectangleF ((float) x, (float) y, (float)layout.Width, measure.Height));
new RectangleF ((float)x, (float)y, (float)measure.Width, (float)measure.Height), TextLayoutContext.StringFormat);
}
public void DrawImage (object backend, object img, double x, double y, double alpha)

Просмотреть файл

@ -86,7 +86,7 @@ namespace Xwt.Drawing
/// begins at angle1 and proceeds in the direction
/// of increasing angles to end at angle2.
/// If angle2 is less than angle1,
/// it will be progressively increased by 2*Math.PI until it is greater than angle1.
/// it will be progressively increased by 1 degree until it is greater than angle1.
/// If there is a current point, an initial line segment will be added to the path
/// to connect the current point to the beginning of the arc.
/// If this initial line is undesired,

Просмотреть файл

@ -71,6 +71,12 @@ namespace Xwt.Drawing
handler.SetText (Backend, text); }
}
/// <summary>
/// Gets or sets the desired width.
/// </summary>
/// <value>
/// The width. A value of -1 uses GetSize().Width on drawings
/// </value>
public double Width {
get { return width; }
set { width = value; handler.SetWidth (Backend, value); }