本文整理汇总了C#中Xwt.Drawing.Context.StrokePreserve方法的典型用法代码示例。如果您正苦于以下问题:C# Context.StrokePreserve方法的具体用法?C# Context.StrokePreserve怎么用?C# Context.StrokePreserve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xwt.Drawing.Context
的用法示例。
在下文中一共展示了Context.StrokePreserve方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Curves1
public virtual void Curves1(Context ctx, double x, double y)
{
ctx.Save ();
ctx.Translate (x, y);
ctx.SetLineWidth (1);
Action curve1 = () => {
ctx.MoveTo (0, 30);
ctx.CurveTo (20, 0, 50, 0, 60, 25);
};
// curve2 with lineTo; curve1 is closed
Action curve2 = () => {
ctx.LineTo (0, 0);
ctx.CurveTo (20, 30, 50, 30, 60, 5);
};
Action paint = () => {
curve1 ();
curve2 ();
ctx.ClosePath ();
ctx.SetColor (new Color (0, 0, 0, .5));
ctx.StrokePreserve ();
ctx.SetColor (new Color (1, 0, 1, .5));
ctx.Fill ();
};
paint ();
ctx.Translate (0, 40);
// curve2 with moveTo; curve1 is open
curve2 = () => {
ctx.MoveTo (0, 0);
ctx.CurveTo (20, 30, 50, 30, 60, 5);
};
paint ();
ctx.Restore ();
//Todo: same stuff with arc
}
示例2: Rectangles
public virtual void Rectangles (Context ctx, double x, double y)
{
ctx.Save ();
ctx.Translate (x, y);
// Simple rectangles
ctx.SetLineWidth (1);
ctx.Rectangle (0, 0, 10, 10);
ctx.SetColor (Colors.Black);
ctx.Fill ();
ctx.Rectangle (15, 0, 10, 10);
ctx.SetColor (Colors.Black);
ctx.Stroke ();
ctx.SetLineWidth (3);
ctx.Rectangle (0, 15, 10, 10);
ctx.SetColor (Colors.Black);
ctx.Fill ();
ctx.Rectangle (15, 15, 10, 10);
ctx.SetColor (Colors.Black);
ctx.Stroke ();
ctx.Restore ();
// Rectangle with hole
ctx.Save ();
ctx.Translate (x + 50, y);
ctx.Rectangle (0, 0, 40, 40);
ctx.MoveTo (35, 35);
ctx.RelLineTo (0, -20);
ctx.RelLineTo (-20, 0);
ctx.RelLineTo (0, 20);
ctx.ClosePath ();
ctx.SetColor (Colors.Black);
ctx.Fill ();
ctx.Restore ();
// Rounded Rectangle with Arcs
ctx.Save ();
ctx.Translate (x + 120, y);
var r = 5;
var l = 0;
var t = 0;
var w = 50;
var h = 30;
ctx.SetColor (Colors.Black);
// top left
ctx.Arc (l + r, t + r, r, 180, 270);
// top right
ctx.Arc (l + w - r, t + r, r, 270, 0);
// bottom right
ctx.Arc (l + w - r, t + h - r, r, 0, 90);
// bottom left
ctx.Arc (l + r, t + h - r, r, 90, 180);
ctx.ClosePath ();
ctx.StrokePreserve ();
ctx.SetColor (Colors.AntiqueWhite);
ctx.Fill ();
ctx.Restore ();
}
示例3: DrawPopover
void DrawPopover(Context ctx)
{
lock (trackerLock)
{
if (actualTrackerHitResult != null)
{
var trackerSettings = DefaultTrackerSettings;
if (actualTrackerHitResult.Series != null && !string.IsNullOrEmpty(actualTrackerHitResult.Series.TrackerKey))
trackerSettings = trackerDefinitions[actualTrackerHitResult.Series.TrackerKey];
if (trackerSettings.Enabled)
{
var extents = actualTrackerHitResult.LineExtents;
if (Math.Abs(extents.Width) < double.Epsilon)
{
extents = new OxyRect(actualTrackerHitResult.XAxis.ScreenMin.X, extents.Top, actualTrackerHitResult.XAxis.ScreenMax.X - actualTrackerHitResult.XAxis.ScreenMin.X, extents.Height);
}
if (Math.Abs(extents.Height) < double.Epsilon)
{
extents = new OxyRect(extents.Left, actualTrackerHitResult.YAxis.ScreenMin.Y, extents.Width, actualTrackerHitResult.YAxis.ScreenMax.Y - actualTrackerHitResult.YAxis.ScreenMin.Y);
}
var pos = actualTrackerHitResult.Position;
if (trackerSettings.HorizontalLineVisible)
{
renderContext.DrawLine(
new[] { new ScreenPoint(extents.Left, pos.Y), new ScreenPoint(extents.Right, pos.Y) },
trackerSettings.HorizontalLineColor,
trackerSettings.HorizontalLineWidth,
trackerSettings.HorizontalLineActualDashArray,
LineJoin.Miter,
true);
}
if (trackerSettings.VerticalLineVisible)
{
renderContext.DrawLine(
new[] { new ScreenPoint(pos.X, extents.Top), new ScreenPoint(pos.X, extents.Bottom) },
trackerSettings.VerticalLineColor,
trackerSettings.VerticalLineWidth,
trackerSettings.VerticalLineActualDashArray,
LineJoin.Miter,
true);
}
TextLayout text = new TextLayout();
text.Font = trackerSettings.Font;
text.Text = actualTrackerHitResult.Text;
var arrowTop = actualTrackerHitResult.Position.Y <= Bounds.Height / 2;
const int arrowPadding = 10;
var textSize = text.GetSize();
var outerSize = new Size(textSize.Width + (trackerSettings.Padding * 2),
textSize.Height + (trackerSettings.Padding * 2) + arrowPadding);
var trackerBounds = new Rectangle(pos.X - (outerSize.Width / 2),
0,
outerSize.Width,
outerSize.Height - arrowPadding);
if (arrowTop)
trackerBounds.Y = pos.Y + arrowPadding + trackerSettings.BorderWidth;
else
trackerBounds.Y = pos.Y - outerSize.Height - trackerSettings.BorderWidth;
var borderColor = trackerSettings.BorderColor.ToXwtColor();
ctx.RoundRectangle(trackerBounds, 6);
ctx.SetLineWidth(trackerSettings.BorderWidth);
ctx.SetColor(borderColor);
ctx.StrokePreserve();
ctx.SetColor(trackerSettings.Background.ToXwtColor());
ctx.Fill();
ctx.Save();
var arrowX = trackerBounds.Center.X;
var arrowY = arrowTop ? trackerBounds.Top : trackerBounds.Bottom;
ctx.NewPath();
ctx.MoveTo(arrowX, arrowY);
var triangleSide = 2 * arrowPadding / Math.Sqrt(3);
var halfSide = triangleSide / 2;
var verticalModifier = arrowTop ? -1 : 1;
ctx.RelMoveTo(-halfSide, 0);
ctx.RelLineTo(halfSide, verticalModifier * arrowPadding);
ctx.RelLineTo(halfSide, verticalModifier * -arrowPadding);
ctx.SetColor(borderColor);
ctx.StrokePreserve();
ctx.ClosePath();
ctx.SetColor(trackerSettings.Background.ToXwtColor());
ctx.Fill();
ctx.Restore();
ctx.SetColor(trackerSettings.TextColor.ToXwtColor());
ctx.DrawTextLayout(text,
trackerBounds.Left + trackerSettings.Padding,
trackerBounds.Top + trackerSettings.Padding);
}
}
}
//.........这里部分代码省略.........
示例4: DrawBackground
void DrawBackground(Context ctx)
{
// draw shadow
ctx.RoundRectangle(bound.Inflate(-1, -1).Offset(1, 3), NodeRadius);
ctx.SetColor(NodeColorShadow);
ctx.SetLineWidth(4);
ctx.Stroke();
// border
ctx.RoundRectangle(bound.Inflate(-1, -1), NodeRadius);
ctx.SetColor(NodeColorBorder);
ctx.SetLineWidth(2);
ctx.StrokePreserve();
// background
ctx.SetColor(NodeColor);
ctx.Fill();
if (hover) { // draw glow
ctx.RoundRectangle(bound.Inflate(1, 1), NodeRadius * 2);
ctx.SetColor(NodeColorGlow);
ctx.SetLineWidth(1);
ctx.Stroke();
}
}
示例5: Draw
/// <summary>
/// Draws a edge from one marker, to another
/// </summary>
/// <param name="ctx">Context.</param>
/// <param name="from">From.</param>
public void Draw(Context ctx, MarkerNode from)
{
MarkerNode toNode = to as MarkerNode;
if (toNode != null) {
ComputeStroke(ctx, from, new Point(2.5, 2.5));
ctx.SetLineWidth(4.5);
ctx.SetColor(Colors.DimGray.WithAlpha(0.3));
ctx.Stroke();
ComputeStroke(ctx, from);
ctx.SetLineWidth(6);
ctx.SetColor(Colors.DimGray.WithAlpha(0.7));
ctx.StrokePreserve();
ctx.SetLineWidth(4.0);
ctx.SetColor(from.NodeColor.BlendWith(toNode.NodeColor, 0.5).WithAlpha(1.0));
ctx.Stroke();
}
}