本文整理汇总了C#中IRenderContext.DrawPath方法的典型用法代码示例。如果您正苦于以下问题:C# IRenderContext.DrawPath方法的具体用法?C# IRenderContext.DrawPath怎么用?C# IRenderContext.DrawPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRenderContext
的用法示例。
在下文中一共展示了IRenderContext.DrawPath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderFromXml
public static bool RenderFromXml(Stream xmlStream, IRenderContext renderContext, out Size imageSize)
{
XmlDocument doc = new XmlDocument();
doc.Load(xmlStream);
XmlNamespaceManager namespaceManager = new XmlNamespaceManager(doc.NameTable);
namespaceManager.AddNamespace("p", PreviewNamespace);
XmlNode previewNode = doc.SelectSingleNode("/p:preview", namespaceManager);
imageSize = new Size(double.Parse(previewNode.Attributes["width"].InnerText), double.Parse(previewNode.Attributes["height"].InnerText));
XmlNodeList renderNodes = previewNode.ChildNodes;
foreach (XmlNode renderNode in renderNodes)
{
XmlElement renderElement = renderNode as XmlElement;
if (renderElement == null)
continue;
if (renderElement.Name == "line")
{
Point start = Point.Parse(renderElement.Attributes["start"].InnerText);
Point end = Point.Parse(renderElement.Attributes["end"].InnerText);
double thickness = double.Parse(renderElement.Attributes["thickness"].InnerText);
renderContext.DrawLine(start, end, thickness);
}
else if (renderElement.Name == "rect")
{
Point start = Point.Parse(renderElement.Attributes["start"].InnerText);
Size size = Size.Parse(renderElement.Attributes["size"].InnerText);
double thickness = double.Parse(renderElement.Attributes["thickness"].InnerText);
bool fill = bool.Parse(renderElement.Attributes["fill"].InnerText);
renderContext.DrawRectangle(start, size, thickness, fill);
}
else if (renderElement.Name == "ellipse")
{
Point centre = Point.Parse(renderElement.Attributes["centre"].InnerText);
double radiusx = double.Parse(renderElement.Attributes["rx"].InnerText);
double radiusy = double.Parse(renderElement.Attributes["ry"].InnerText);
double thickness = double.Parse(renderElement.Attributes["thickness"].InnerText);
bool fill = bool.Parse(renderElement.Attributes["fill"].InnerText);
renderContext.DrawEllipse(centre, radiusx, radiusy, thickness, fill);
}
else if (renderElement.Name == "path")
{
Point start = Point.Parse(renderElement.Attributes["start"].InnerText);
double thickness = double.Parse(renderElement.Attributes["thickness"].InnerText);
bool fill = bool.Parse(renderElement.Attributes["fill"].InnerText);
string data = renderElement.InnerText;
List<IPathCommand> pathCommands = new List<IPathCommand>();
using (MemoryStream dataStream = new MemoryStream(Convert.FromBase64String(data)))
{
BinaryReader reader = new BinaryReader(dataStream);
int numCommands = reader.ReadInt32();
for (int l = 0; l < numCommands; l++)
{
CommandType pType = (CommandType)reader.ReadInt32();
IPathCommand theCommand = null;
switch (pType)
{
case CommandType.MoveTo:
theCommand = new MoveTo();
break;
case CommandType.LineTo:
theCommand = new LineTo();
break;
case CommandType.CurveTo:
theCommand = new CurveTo();
break;
case CommandType.EllipticalArcTo:
theCommand = new EllipticalArcTo();
break;
case CommandType.QuadraticBeizerCurveTo:
theCommand = new QuadraticBeizerCurveTo();
break;
case CommandType.SmoothCurveTo:
theCommand = new SmoothCurveTo();
break;
case CommandType.SmoothQuadraticBeizerCurveTo:
theCommand = new SmoothQuadraticBeizerCurveTo();
break;
default:
theCommand = new ClosePath();
break;
}
theCommand.Read(reader);
pathCommands.Add(theCommand);
}
}
renderContext.DrawPath(start, pathCommands, thickness, fill);
}
else if (renderElement.Name == "text")
{
Point anchor = Point.Parse(renderElement.Attributes["anchor"].InnerText);
TextAlignment alignment = (TextAlignment)Enum.Parse(typeof(TextAlignment), renderElement.Attributes["alignment"].InnerText);
List<TextRun> runs = new List<TextRun>();
foreach (XmlNode runNode in renderElement.ChildNodes)
{
//.........这里部分代码省略.........