本文整理汇总了C#中Xwt.Drawing.Context.RelLineTo方法的典型用法代码示例。如果您正苦于以下问题:C# Context.RelLineTo方法的具体用法?C# Context.RelLineTo怎么用?C# Context.RelLineTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xwt.Drawing.Context
的用法示例。
在下文中一共展示了Context.RelLineTo方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Lines
/// <summary>
/// Visual test for pixel alignment and odd/even line widths
/// </summary>
public void Lines (Context ctx)
{
ctx.Save ();
ctx.SetColor (Colors.Black);
int nPairs = 4;
double length = 90;
double gap = 2;
// set half-pixel y-coordinate for sharp single-pixel-wide line
// on first line of Canvas, extending to match line pairs below
ctx.SetLineWidth (1);
double x = 0;
double y = 0.5;
double end = x + 2*(length - 1) + gap;
ctx.MoveTo (x, y);
ctx.LineTo (end, y);
ctx.Stroke ();
// draw pairs of lines with odd and even widths,
// each pair aligned on half-pixel y-coordinates
y = 4.5;
for (int w = 1; w <= nPairs; ++w) {
x = 0;
ctx.SetLineWidth (w);
ctx.MoveTo (x, y);
ctx.RelLineTo (length-1, 0);
ctx.Stroke ();
ctx.SetLineWidth (w + 1);
x += (gap + length - 1);
ctx.MoveTo (x, y);
ctx.RelLineTo (length-1, 0);
ctx.Stroke ();
y += w * 2 + gap;
}
ctx.Restore ();
}
示例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: DrawRoundRectangle
public static void DrawRoundRectangle (Context cr, double x, double y, double r, double w, double h)
{
const double ARC_TO_BEZIER = 0.55228475;
double radius_x = r;
double radius_y = r / 4;
if (radius_x > w - radius_x)
radius_x = w / 2;
if (radius_y > h - radius_y)
radius_y = h / 2;
double c1 = ARC_TO_BEZIER * radius_x;
double c2 = ARC_TO_BEZIER * radius_y;
cr.NewPath ();
cr.MoveTo (x + radius_x, y);
cr.RelLineTo (w - 2 * radius_x, 0.0);
cr.RelCurveTo (c1, 0.0, radius_x, c2, radius_x, radius_y);
cr.RelLineTo (0, h - 2 * radius_y);
cr.RelCurveTo (0.0, c2, c1 - radius_x, radius_y, -radius_x, radius_y);
cr.RelLineTo (-w + 2 * radius_x, 0);
cr.RelCurveTo (-c1, 0, -radius_x, -c2, -radius_x, -radius_y);
cr.RelLineTo (0, -h + 2 * radius_y);
cr.RelCurveTo (0.0, -c2, radius_x - c1, -radius_y, radius_x, -radius_y);
cr.ClosePath ();
}
示例4: DrawCursor
void DrawCursor (Context ctx, ChartCursor cursor)
{
ctx.SetColor (cursor.Color);
double x, y;
GetPoint (cursor.Value, cursor.Value, out x, out y);
if (cursor.Dimension == AxisDimension.X) {
double cy = top - AreaBorderWidth - 1;
ctx.MoveTo (x, cy);
ctx.LineTo (x + (cursor.HandleSize/2), cy - cursor.HandleSize + 1);
ctx.LineTo (x - (cursor.HandleSize/2), cy - cursor.HandleSize + 1);
ctx.ClosePath ();
if (activeCursor == cursor)
ctx.FillPreserve ();
ctx.Stroke ();
ctx.MoveTo (x, top);
ctx.RelLineTo (0, height);
ctx.Stroke ();
} else {
throw new NotSupportedException ();
}
}
示例5: OnDraw
protected override void OnDraw(Context ctx, Rectangle dirtyRect)
{
base.OnDraw(ctx, dirtyRect);
for (int i = 0; i < Size.Width / checkerboard.Width; i++)
{
for (int j = 0; j < Size.Height / checkerboard.Height; j++)
{
ctx.DrawImage(checkerboard, i * checkerboard.Width, j * checkerboard.Height);
}
}
ctx.SetLineWidth(1);
ctx.SetColor(color);
ctx.Rectangle(0, 0, Size.Width - 20, Size.Height);
ctx.Fill();
ctx.SetColor(DefaultColor);
ctx.Rectangle(Size.Width - 20, 0, 20, Size.Height);
ctx.Fill();
ctx.SetColor(Colors.Black);
ctx.Rectangle(0, 0, Size.Width, Size.Height);
ctx.Stroke();
//ctx.SetColor(Color.Brightness > .5 ? Colors.White : Colors.Black);
ctx.SetColor(((-1 * Color.Brightness) + 1) * 1.15 + (Color.Alpha) > 1.2 ? Colors.White : Colors.Black);
ctx.DrawTextLayout(new TextLayout(this) { Text = Color.ToHexString().ToUpper() }, 2, 3);
if (mover && (IsDefaultColor || mx <= Size.Width - 20))
{
ctx.SetColor(new Color(1, 1, 1, .33));
ctx.Rectangle(0, 0, Size.Width - (IsDefaultColor ? 0 : 20), Size.Height);
ctx.Fill();
}
if (!IsDefaultColor)
{
if (mover && mx > Size.Width - 20)
{
ctx.SetColor(new Color(1, 1, 1, .33));
ctx.Rectangle(Size.Width - 20, 0, 20, Size.Height);
ctx.Fill();
}
ctx.SetColor(Colors.Black);
ctx.MoveTo(Size.Width - 19.5, 0);
ctx.RelLineTo(0, Size.Height);
ctx.Stroke();
if (mover)
ctx.DrawImage(resetImage, Size.Width - 18, (Size.Height - 16) / 2, 16, 16);
}
}
示例6: OnDraw
protected override void OnDraw(Context ctx, Rectangle dirtyRect)
{
base.OnDraw (ctx, dirtyRect);
FrameBox parent = (FrameBox)Parent;
var border = parent.borderWidth;
var r = Bounds;
//ctx.SetLineDash (0);
ctx.SetColor (parent.borderColor);
if (border.Top > 0) {
ctx.MoveTo (r.X, r.Y + border.Top / 2);
ctx.RelLineTo (r.Width, 0);
ctx.SetLineWidth (border.Top);
ctx.Stroke ();
}
if (border.Bottom > 0) {
ctx.MoveTo (r.X, r.Bottom - border.Bottom / 2);
ctx.RelLineTo (r.Width, 0);
ctx.SetLineWidth (border.Bottom);
ctx.Stroke ();
}
if (border.Left > 0) {
ctx.MoveTo (r.X + border.Left / 2, r.Y + border.Top);
ctx.RelLineTo (0, r.Height - border.Top - border.Bottom);
ctx.SetLineWidth (border.Left);
ctx.Stroke ();
}
if (border.Right > 0) {
ctx.MoveTo (r.Right - border.Right / 2, r.Y + border.Top);
ctx.RelLineTo (0, r.Height - border.Top - border.Bottom);
ctx.SetLineWidth (border.Right);
ctx.Stroke ();
}
}
示例7: DrawFocus
void DrawFocus( Context ctx, double x, double y )
{
if (!cursorVisible)
return;
double r = 16;
ctx.Save ();
x += 0.5;
y += 0.5;
ctx.SetLineWidth (3);
ctx.SetColor (new Color (0, 0, 0, 0.5));
ctx.Arc (x, y, r, 0, 360);
ctx.Stroke ();
ctx.SetLineWidth (1);
ctx.MoveTo (x+r, y);
ctx.RelLineTo (r, 0);
ctx.MoveTo (x-r, y);
ctx.RelLineTo (-r, 0);
ctx.MoveTo (x, y+r);
ctx.RelLineTo (0, r);
ctx.MoveTo (x, y-r);
ctx.RelLineTo (0, -r);
ctx.Stroke ();
r += 10;
ctx.Arc (x, y, r, 10, 80);
ctx.Stroke ();
ctx.Arc (x, y, r, 100, 170);
ctx.Stroke ();
ctx.Arc (x, y, r, 190, 260);
ctx.Stroke ();
ctx.Arc (x, y, r, 280, 350);
ctx.Stroke ();
ctx.Restore ();
}
示例8: 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);
}
}
}
//.........这里部分代码省略.........