本文整理汇总了C#中IRenderContext.DrawEllipse方法的典型用法代码示例。如果您正苦于以下问题:C# IRenderContext.DrawEllipse方法的具体用法?C# IRenderContext.DrawEllipse怎么用?C# IRenderContext.DrawEllipse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRenderContext
的用法示例。
在下文中一共展示了IRenderContext.DrawEllipse方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
{
//.........这里部分代码省略.........
示例2: Render
/// <summary>
/// Renders the icon on the specified render context.
/// </summary>
/// <param name="rc">The render context.</param>
/// <param name="size">The size.</param>
public override void Render(IRenderContext rc, double size)
{
var m = size * 0.05;
var rect = new OxyRect(m, m, size - m * 2, size - m * 2);
rc.DrawEllipse(rect, OxyColors.Black, OxyColors.Black, 0);
rc.DrawText(new ScreenPoint(size * 0.52, size * 0.32), "XY", OxyColors.White, "Arial", size * 0.25, FontWeights.Bold, 0, HorizontalAlignment.Center, VerticalAlignment.Middle);
rc.DrawText(new ScreenPoint(size * 0.52, size * 0.64), "PLOT", OxyColors.White, "Arial", size * 0.25, FontWeights.Bold, 0, HorizontalAlignment.Center, VerticalAlignment.Middle);
}
示例3: Render
//.........这里部分代码省略.........
var topWhiskerTop = this.Transform(item.X, item.UpperWhisker);
var topWhiskerBottom = this.Transform(item.X, item.BoxTop);
var bottomWhiskerTop = this.Transform(item.X, item.BoxBottom);
var bottomWhiskerBottom = this.Transform(item.X, item.LowerWhisker);
rc.DrawClippedLine(
clippingRect,
new[] { topWhiskerTop, topWhiskerBottom },
0,
strokeColor,
this.StrokeThickness,
dashArray,
OxyPenLineJoin.Miter,
true);
rc.DrawClippedLine(
clippingRect,
new[] { bottomWhiskerTop, bottomWhiskerBottom },
0,
strokeColor,
this.StrokeThickness,
dashArray,
OxyPenLineJoin.Miter,
true);
// Draw the whiskers
if (this.WhiskerWidth > 0)
{
var topWhiskerLine1 = this.Transform(item.X - halfWhiskerWidth, item.UpperWhisker);
var topWhiskerLine2 = this.Transform(item.X + halfWhiskerWidth, item.UpperWhisker);
var bottomWhiskerLine1 = this.Transform(item.X - halfWhiskerWidth, item.LowerWhisker);
var bottomWhiskerLine2 = this.Transform(item.X + halfWhiskerWidth, item.LowerWhisker);
rc.DrawClippedLine(
clippingRect,
new[] { topWhiskerLine1, topWhiskerLine2 },
0,
strokeColor,
this.StrokeThickness,
null,
OxyPenLineJoin.Miter,
true);
rc.DrawClippedLine(
clippingRect,
new[] { bottomWhiskerLine1, bottomWhiskerLine2 },
0,
strokeColor,
this.StrokeThickness,
null,
OxyPenLineJoin.Miter,
true);
}
if (this.ShowBox)
{
// Draw the box
var rect = this.GetBoxRect(item);
rc.DrawClippedRectangleAsPolygon(clippingRect, rect, fillColor, strokeColor, this.StrokeThickness);
}
if (!this.ShowMedianAsDot)
{
// Draw the median line
var medianLeft = this.Transform(item.X - halfBoxWidth, item.Median);
var medianRight = this.Transform(item.X + halfBoxWidth, item.Median);
rc.DrawClippedLine(
clippingRect,
new[] { medianLeft, medianRight },
0,
strokeColor,
this.StrokeThickness * this.MedianThickness,
null,
OxyPenLineJoin.Miter,
true);
}
else
{
var mc = this.Transform(item.X, item.Median);
if (clippingRect.Contains(mc))
{
var ellipseRect = new OxyRect(
mc.X - this.MedianPointSize,
mc.Y - this.MedianPointSize,
this.MedianPointSize * 2,
this.MedianPointSize * 2);
rc.DrawEllipse(ellipseRect, fillColor, OxyColors.Undefined, 0);
}
}
}
// Draw the outlier(s)
var markerSizes = outlierScreenPoints.Select(o => this.OutlierSize).ToList();
rc.DrawMarkers(
clippingRect,
outlierScreenPoints,
this.OutlierType,
null,
markerSizes,
fillColor,
strokeColor,
this.StrokeThickness);
}
示例4: RenderLegend
/// <summary>
/// Renders the legend symbol on the specified rendering context.
/// </summary>
/// <param name="rc">The rendering context.</param>
/// <param name="legendBox">The legend rectangle.</param>
public override void RenderLegend(IRenderContext rc, OxyRect legendBox)
{
double xmid = (legendBox.Left + legendBox.Right) / 2;
double ybottom = legendBox.Top + ((legendBox.Bottom - legendBox.Top) * 0.7);
double ytop = legendBox.Top + ((legendBox.Bottom - legendBox.Top) * 0.3);
double ymid = (ybottom + ytop) * 0.5;
var halfBoxWidth = legendBox.Width * 0.24;
var halfWhiskerWidth = halfBoxWidth * this.WhiskerWidth;
const double LegendStrokeThickness = 1;
var strokeColor = this.GetSelectableColor(this.Stroke);
var fillColor = this.GetSelectableFillColor(this.Fill);
rc.DrawLine(
new[] { new ScreenPoint(xmid, legendBox.Top), new ScreenPoint(xmid, ytop) },
strokeColor,
LegendStrokeThickness,
LineStyle.Solid.GetDashArray(),
OxyPenLineJoin.Miter,
true);
rc.DrawLine(
new[] { new ScreenPoint(xmid, ybottom), new ScreenPoint(xmid, legendBox.Bottom) },
strokeColor,
LegendStrokeThickness,
LineStyle.Solid.GetDashArray(),
OxyPenLineJoin.Miter,
true);
if (this.WhiskerWidth > 0)
{
// top whisker
rc.DrawLine(
new[]
{
new ScreenPoint(xmid - halfWhiskerWidth - 1, legendBox.Bottom),
new ScreenPoint(xmid + halfWhiskerWidth, legendBox.Bottom)
},
strokeColor,
LegendStrokeThickness,
LineStyle.Solid.GetDashArray(),
OxyPenLineJoin.Miter,
true);
// bottom whisker
rc.DrawLine(
new[]
{
new ScreenPoint(xmid - halfWhiskerWidth - 1, legendBox.Top),
new ScreenPoint(xmid + halfWhiskerWidth, legendBox.Top)
},
strokeColor,
LegendStrokeThickness,
LineStyle.Solid.GetDashArray(),
OxyPenLineJoin.Miter,
true);
}
if (this.ShowBox)
{
// box
rc.DrawRectangleAsPolygon(
new OxyRect(xmid - halfBoxWidth, ytop, 2 * halfBoxWidth, ybottom - ytop),
fillColor,
strokeColor,
LegendStrokeThickness);
}
// median
if (!this.ShowMedianAsDot)
{
rc.DrawLine(
new[] { new ScreenPoint(xmid - halfBoxWidth, ymid), new ScreenPoint(xmid + halfBoxWidth, ymid) },
strokeColor,
LegendStrokeThickness * this.MedianThickness,
LineStyle.Solid.GetDashArray(),
OxyPenLineJoin.Miter,
true);
}
else
{
var ellipseRect = new OxyRect(
xmid - this.MedianPointSize,
ymid - this.MedianPointSize,
this.MedianPointSize * 2,
this.MedianPointSize * 2);
rc.DrawEllipse(ellipseRect, fillColor, OxyColors.Undefined);
}
}
示例5: Render
/// <summary>
/// Renders the document using the specified renderer.
/// </summary>
/// <param name="dc">The renderer to use.</param>
public void Render(IRenderContext dc)
{
// Render components
foreach (Component component in Components)
foreach (var renderDescription in component.Description.RenderDescriptions)
if (renderDescription.Conditions.IsMet(component))
foreach (CircuitDiagram.Components.Description.Render.IRenderCommand renderCommand in renderDescription.Value)
renderCommand.Render(component, dc, true);
// Determine connections
List<ConnectionCentre> connectionCentres = new List<ConnectionCentre>();
List<Point> connectionPoints = new List<Point>();
foreach (Component component in Components)
{
foreach (var connection in component.GetConnections())
{
if (connection.Value.IsConnected && !connectionCentres.Contains(connection.Value.Centre))
{
bool draw = false;
if (connection.Value.ConnectedTo.Length >= 3)
draw = true;
foreach (Connection connectedConnection in connection.Value.ConnectedTo)
{
if ((connectedConnection.Flags & ConnectionFlags.Horizontal) == ConnectionFlags.Horizontal && (connection.Value.Flags & ConnectionFlags.Vertical) == ConnectionFlags.Vertical && (connection.Value.Flags & ConnectionFlags.Edge) != (connectedConnection.Flags & ConnectionFlags.Edge))
draw = true;
else if ((connectedConnection.Flags & ConnectionFlags.Vertical) == ConnectionFlags.Vertical && (connection.Value.Flags & ConnectionFlags.Horizontal) == ConnectionFlags.Horizontal && (connection.Value.Flags & ConnectionFlags.Edge) != (connectedConnection.Flags & ConnectionFlags.Edge))
draw = true;
if (draw)
break;
}
if (draw)
{
connectionCentres.Add(connection.Value.Centre);
connectionPoints.Add(Point.Add(connection.Key, component.Location));
}
}
}
}
// Render connections
foreach (Point connectionPoint in connectionPoints)
dc.DrawEllipse(connectionPoint, 2d, 2d, 2d, true);
}