本文整理汇总了C#中PdfSharp.Drawing.XMatrix.RotateAtPrepend方法的典型用法代码示例。如果您正苦于以下问题:C# XMatrix.RotateAtPrepend方法的具体用法?C# XMatrix.RotateAtPrepend怎么用?C# XMatrix.RotateAtPrepend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PdfSharp.Drawing.XMatrix
的用法示例。
在下文中一共展示了XMatrix.RotateAtPrepend方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RotateAtTransform
/// <summary>
/// Applies the specified rotation operation to the transformation matrix of this object by
/// prepending it to the object's transformation matrix.
/// </summary>
public void RotateAtTransform(double angle, XPoint point)
{
//RotateAtTransform(angle, point, XMatrixOrder.Prepend);
XMatrix matrix = new XMatrix(); //XMatrix.Identity;
matrix.RotateAtPrepend(angle, point);
AddTransform(matrix, XMatrixOrder.Prepend);
}
示例2: Draw
/// <summary>
///
/// </summary>
/// <param name="gfx"></param>
/// <param name="line"></param>
/// <param name="dx"></param>
/// <param name="dy"></param>
/// <param name="db"></param>
/// <param name="r"></param>
public void Draw(object gfx, Kaliber3D.Render.XLine line, double dx, double dy, ImmutableArray<Kaliber3D.Render.ShapeProperty> db, Kaliber3D.Render.Record r)
{
if (!line.IsStroked)
return;
var _gfx = gfx as XGraphics;
XPen strokeLine = ToXPen(line.Style, _scaleToPage);
XSolidBrush fillStartArrow = ToXSolidBrush(line.Style.StartArrowStyle.Fill);
XPen strokeStartArrow = ToXPen(line.Style.StartArrowStyle, _scaleToPage);
XSolidBrush fillEndArrow = ToXSolidBrush(line.Style.EndArrowStyle.Fill);
XPen strokeEndArrow = ToXPen(line.Style.EndArrowStyle, _scaleToPage);
double _x1 = line.Start.X + dx;
double _y1 = line.Start.Y + dy;
double _x2 = line.End.X + dx;
double _y2 = line.End.Y + dy;
Kaliber3D.Render.XLine.SetMaxLength(line, ref _x1, ref _y1, ref _x2, ref _y2);
double x1 = _scaleToPage(_x1);
double y1 = _scaleToPage(_y1);
double x2 = _scaleToPage(_x2);
double y2 = _scaleToPage(_y2);
var sas = line.Style.StartArrowStyle;
var eas = line.Style.EndArrowStyle;
double a1 = Math.Atan2(y1 - y2, x1 - x2) * 180.0 / Math.PI;
double a2 = Math.Atan2(y2 - y1, x2 - x1) * 180.0 / Math.PI;
var t1 = new XMatrix();
var c1 = new XPoint(x1, y1);
t1.RotateAtPrepend(a1, c1);
var t2 = new XMatrix();
var c2 = new XPoint(x2, y2);
t2.RotateAtPrepend(a2, c2);
XPoint pt1;
XPoint pt2;
double radiusX1 = sas.RadiusX;
double radiusY1 = sas.RadiusY;
double sizeX1 = 2.0 * radiusX1;
double sizeY1 = 2.0 * radiusY1;
switch (sas.ArrowType)
{
default:
case Kaliber3D.Render.ArrowType.None:
{
pt1 = new XPoint(x1, y1);
}
break;
case Kaliber3D.Render.ArrowType.Rectangle:
{
pt1 = t1.Transform(new XPoint(x1 - sizeX1, y1));
var rect = new XRect(x1 - sizeX1, y1 - radiusY1, sizeX1, sizeY1);
_gfx.Save();
_gfx.RotateAtTransform(a1, c1);
DrawRectangleInternal(_gfx, fillStartArrow, strokeStartArrow, sas.IsStroked, sas.IsFilled, ref rect);
_gfx.Restore();
}
break;
case Kaliber3D.Render.ArrowType.Ellipse:
{
pt1 = t1.Transform(new XPoint(x1 - sizeX1, y1));
_gfx.Save();
_gfx.RotateAtTransform(a1, c1);
var rect = new XRect(x1 - sizeX1, y1 - radiusY1, sizeX1, sizeY1);
DrawEllipseInternal(_gfx, fillStartArrow, strokeStartArrow, sas.IsStroked, sas.IsFilled, ref rect);
_gfx.Restore();
}
break;
case Kaliber3D.Render.ArrowType.Arrow:
{
pt1 = t1.Transform(new XPoint(x1, y1));
var p11 = t1.Transform(new XPoint(x1 - sizeX1, y1 + sizeY1));
var p21 = t1.Transform(new XPoint(x1, y1));
var p12 = t1.Transform(new XPoint(x1 - sizeX1, y1 - sizeY1));
var p22 = t1.Transform(new XPoint(x1, y1));
DrawLineInternal(_gfx, strokeStartArrow, sas.IsStroked, ref p11, ref p21);
DrawLineInternal(_gfx, strokeStartArrow, sas.IsStroked, ref p12, ref p22);
}
break;
}
double radiusX2 = eas.RadiusX;
double radiusY2 = eas.RadiusY;
//.........这里部分代码省略.........
示例3: DrawLineArrowInternal
private static XPoint DrawLineArrowInternal(XGraphics gfx, XPen pen, XSolidBrush brush, double x, double y, double angle, Core2D.Style.ArrowStyle style)
{
XPoint pt;
var rt = new XMatrix();
var c = new XPoint(x, y);
rt.RotateAtPrepend(angle, c);
double rx = style.RadiusX;
double ry = style.RadiusY;
double sx = 2.0 * rx;
double sy = 2.0 * ry;
switch (style.ArrowType)
{
default:
case Core2D.Style.ArrowType.None:
{
pt = new XPoint(x, y);
}
break;
case Core2D.Style.ArrowType.Rectangle:
{
pt = rt.Transform(new XPoint(x - sx, y));
var rect = new XRect(x - sx, y - ry, sx, sy);
gfx.Save();
gfx.RotateAtTransform(angle, c);
DrawRectangleInternal(gfx, brush, pen, style.IsStroked, style.IsFilled, ref rect);
gfx.Restore();
}
break;
case Core2D.Style.ArrowType.Ellipse:
{
pt = rt.Transform(new XPoint(x - sx, y));
gfx.Save();
gfx.RotateAtTransform(angle, c);
var rect = new XRect(x - sx, y - ry, sx, sy);
DrawEllipseInternal(gfx, brush, pen, style.IsStroked, style.IsFilled, ref rect);
gfx.Restore();
}
break;
case Core2D.Style.ArrowType.Arrow:
{
pt = rt.Transform(new XPoint(x, y));
var p11 = rt.Transform(new XPoint(x - sx, y + sy));
var p21 = rt.Transform(new XPoint(x, y));
var p12 = rt.Transform(new XPoint(x - sx, y - sy));
var p22 = rt.Transform(new XPoint(x, y));
DrawLineInternal(gfx, pen, style.IsStroked, ref p11, ref p21);
DrawLineInternal(gfx, pen, style.IsStroked, ref p12, ref p22);
}
break;
}
return pt;
}
示例4: PdfFormXObject
//.........这里部分代码省略.........
Debug.Assert(iref.Document == this.Owner);
// replace external object by the already clone counterpart
resources[idx] = iref.Value;
}
else
{
// External object was not imported ealier and must be cloned
PdfObject clone = obj.Clone();
Debug.Assert(clone.Reference == null);
clone.Document = this.Owner;
if (obj.Reference != null)
{
// add it to this (the importer) document
this.Owner.irefTable.Add(clone);
Debug.Assert(clone.Reference != null);
// save old object identifier
importedObjectTable.Add(obj.ObjectID, clone.Reference);
//Debug.WriteLine("Cloned: " + obj.ObjectID.ToString());
}
else
{
// The root object (the /Resources value) is not an indirect object
Debug.Assert(idx == 0);
// add it to this (the importer) document
this.Owner.irefTable.Add(clone);
Debug.Assert(clone.Reference != null);
}
// replace external object by its clone
resources[idx] = clone;
}
}
#if DEBUG_
for (int idx = 0; idx < count; idx++)
{
Debug.Assert(resources[idx].XRef != null);
Debug.Assert(resources[idx].XRef.Document != null);
Debug.Assert(resources[idx].Document != null);
if (resources[idx].ObjectID.ObjectNumber == 12)
GetType();
}
#endif
// 2nd step. Fix up indirect references that still refers to the import document.
for (int idx = 0; idx < count; idx++)
{
PdfObject obj = resources[idx];
Debug.Assert(obj.Owner != null);
FixUpObject(importedObjectTable, importedObjectTable.Owner, obj);
}
// Set resources key to the root of the clones
Elements["/Resources"] = resources[0].Reference;
#endif
}
// Take /Rotate into account
PdfRectangle rect = importPage.Elements.GetRectangle(PdfPage.Keys.MediaBox);
int rotate = importPage.Elements.GetInteger(PdfPage.Keys.Rotate);
//rotate = 0;
if (rotate == 0)
{
// Set bounding box to media box
this.Elements["/BBox"] = rect;
}
else
{
// TODO: Have to adjust bounding box? (I think not, but I'm not sure -> wait for problem)
this.Elements["/BBox"] = rect;
// Rotate the image such that it is upright
XMatrix matrix = new XMatrix(); //XMatrix.Identity;
double width = rect.Width;
double height = rect.Height;
matrix.RotateAtPrepend(-rotate, new XPoint(width / 2, height / 2));
// Translate the image such that its center lies on the center of the rotated bounding box
double offset = (height - width) / 2;
if (height > width)
matrix.TranslatePrepend(offset, offset);
else
matrix.TranslatePrepend(-offset, -offset);
//string item = "[" + PdfEncoders.ToString(matrix) + "]";
//Elements[Keys.Matrix] = new PdfLiteral(item);
Elements.SetMatrix(Keys.Matrix, matrix);
}
// Preserve filter because the content keeps unmodified
PdfContent content = importPage.Contents.CreateSingleContent();
#if !DEBUG
content.Compressed = true;
#endif
PdfItem filter = content.Elements["/Filter"];
if (filter != null)
this.Elements["/Filter"] = filter.Clone();
// (no cloning needed because the bytes keep untouched)
this.Stream = content.Stream; // new PdfStream(bytes, this);
Elements.SetInteger("/Length", content.Stream.Value.Length);
}
示例5: WriteGlyphs
/// <summary>
/// Writes a Glyphs to the content stream.
/// </summary>
private void WriteGlyphs(Glyphs glyphs)
{
WriteSaveState("begin Glyphs", glyphs.Name);
// Transform also affects clipping and opacity mask
bool transformed = glyphs.RenderTransform != null;
if (transformed)
WriteRenderTransform(glyphs.RenderTransform);
bool clipped = glyphs.Clip != null;
if (clipped)
WriteClip(glyphs.Clip);
if (glyphs.Opacity < 1)
MultiplyOpacity(glyphs.Opacity);
if (glyphs.OpacityMask != null)
WriteOpacityMask(glyphs.OpacityMask);
XForm xform = null;
XImage ximage = null;
RealizeFill(glyphs.Fill, ref xform, ref ximage);
RealizeFont(glyphs);
double x = glyphs.OriginX;
double y = glyphs.OriginY;
//switch (format.Alignment)
//{
// case XStringAlignment.Near:
// // nothing to do
// break;
// case XStringAlignment.Center:
// x += (rect.Width - width) / 2;
// break;
// case XStringAlignment.Far:
// x += rect.Width - width;
// break;
//}
PdfFont realizedFont = this.graphicsState.realizedFont;
Debug.Assert(realizedFont != null);
realizedFont.AddChars(glyphs.UnicodeString);
TrueTypeDescriptor descriptor = realizedFont.FontDescriptor.descriptor;
//if (bold && !descriptor.IsBoldFace)
//{
// // TODO: emulate bold by thicker outline
//}
//if (italic && !descriptor.IsBoldFace)
//{
// // TODO: emulate italic by shearing transformation
//}
string s2 = "";
string s = glyphs.UnicodeString;
if (!String.IsNullOrEmpty(s))
{
int length = s.Length;
for (int idx = 0; idx < length; idx++)
{
char ch = s[idx];
int glyphID = 0;
if (descriptor.fontData.cmap.symbol)
{
glyphID = (int)ch + (descriptor.fontData.os2.usFirstCharIndex & 0xFF00);
glyphID = descriptor.CharCodeToGlyphIndex((char)glyphID);
}
else
glyphID = descriptor.CharCodeToGlyphIndex(ch);
s2 += (char)glyphID;
}
}
s = s2;
byte[] bytes = PdfEncoders.RawUnicodeEncoding.GetBytes(s);
bytes = PdfEncoders.FormatStringLiteral(bytes, true, false, true, null);
string text = PdfEncoders.RawEncoding.GetString(bytes);
if (glyphs.IsSideways)
{
XMatrix textMatrix = new XMatrix();
textMatrix.RotateAtPrepend(-90, new XPoint(x, y));
XPoint pos = new XPoint(x, y);
AdjustTextMatrix(ref pos);
WriteTextTransform(textMatrix);
WriteLiteral("{0} Tj\n", text);
}
else
{
XPoint pos = new XPoint(x, y);
AdjustTextMatrix(ref pos);
WriteLiteral("{0:0.###} {1:0.###} Td {2} Tj\n", pos.x, pos.y, text);
//.........这里部分代码省略.........
示例6: WriteGlyphs
//.........这里部分代码省略.........
{
textMatrix.SkewPrepend(-20, 0);
}
XForm xform = null;
XImage ximage = null;
RealizeFill(glyphs.Fill, ref xform, ref ximage);
RealizeFont(glyphs);
if (boldSimulation)
WriteLiteral("2 Tr\n", 1);
double x = glyphs.OriginX;
double y = glyphs.OriginY;
//switch (format.Alignment)
//{
// case XStringAlignment.Near:
// // nothing to do
// break;
// case XStringAlignment.Center:
// x += (rect.Width - width) / 2;
// break;
// case XStringAlignment.Far:
// x += rect.Width - width;
// break;
//}
PdfFont realizedFont = this.graphicsState.realizedFont;
Debug.Assert(realizedFont != null);
realizedFont.AddChars(glyphs.UnicodeString);
OpenTypeDescriptor descriptor = realizedFont.FontDescriptor.descriptor;
//if (bold && !descriptor.IsBoldFace)
//{
// // TODO: emulate bold by thicker outline
//}
//if (italic && !descriptor.IsBoldFace)
//{
// // TODO: emulate italic by shearing transformation
//}
#if true
string s2 = "";
string s = glyphs.UnicodeString;
if (!String.IsNullOrEmpty(s))
{
int length = s.Length;
for (int idx = 0; idx < length; idx++)
{
char ch = s[idx];
int glyphID = 0;
if (descriptor.fontData.cmap.symbol)
{
glyphID = (int)ch + (descriptor.fontData.os2.usFirstCharIndex & 0xFF00);
glyphID = descriptor.CharCodeToGlyphIndex((char)glyphID);
}
else
glyphID = descriptor.CharCodeToGlyphIndex(ch);
s2 += (char)glyphID;
}
}
s = s2;
#endif
byte[] bytes = PdfEncoders.RawUnicodeEncoding.GetBytes(s);
bytes = PdfEncoders.FormatStringLiteral(bytes, true, false, true, null);
string text = PdfEncoders.RawEncoding.GetString(bytes);
if (glyphs.IsSideways)
{
textMatrix.RotateAtPrepend(-90, new XPoint(x, y));
XPoint pos = new XPoint(x, y);
AdjustTextMatrix(ref pos);
//WriteTextTransform(textMatrix);
WriteLiteral("{0} Tj\n", text);
}
else
{
#if true
//if (glyphs.BidiLevel % 2 == 1)
// WriteLiteral("-1 Tc\n");
if (!textMatrix.IsIdentity)
WriteTextTransform(textMatrix);
WriteGlyphsInternal(glyphs, null);
#else
XPoint pos = new XPoint(x, y);
AdjustTextMatrix(ref pos);
WriteLiteral("{0:0.###} {1:0.###} Td {2} Tj\n", pos.x, pos.y, text);
//PdfEncoders.ToStringLiteral(s, PdfStringEncoding.RawEncoding, null));
#endif
}
WriteRestoreState("end Glyphs", glyphs.Name);
}