本文整理汇总了C#中Xwt.Drawing.Context.Stroke方法的典型用法代码示例。如果您正苦于以下问题:C# Context.Stroke方法的具体用法?C# Context.Stroke怎么用?C# Context.Stroke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xwt.Drawing.Context
的用法示例。
在下文中一共展示了Context.Stroke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDraw
protected override void OnDraw(Context ctx)
{
ctx.SetLineWidth (5);
ctx.SetColor (new Color (1.0f, 0f, 0.5f));
ctx.Rectangle (5, 5, 200, 100);
ctx.FillPreserve ();
ctx.SetColor (new Color (0f, 0f, 1f));
ctx.Stroke ();
}
示例2: PatternsAndImages
public void PatternsAndImages (Context ctx, double x, double y)
{
ctx.Save ();
ctx.Translate (x, y);
ctx.SetColor (Colors.Black);
// Dashed lines
ctx.SetLineWidth (2);
ctx.SetLineDash (15, 10, 10, 5, 5);
ctx.Rectangle (10, 10, 100, 100);
ctx.Stroke ();
ctx.SetLineDash (0);
// Image
var arcColor = new Color (1, 0, 1);
ImageBuilder ib = new ImageBuilder (30, 30);
ib.Context.Arc (15, 15, 15, 0, 360);
ib.Context.SetColor (arcColor);
ib.Context.Fill ();
ib.Context.SetColor (Colors.DarkKhaki);
ib.Context.Rectangle (0, 0, 5, 5);
ib.Context.Fill ();
var img = ib.ToVectorImage ();
ctx.DrawImage (img, 0, 0);
ctx.DrawImage (img, 0, 50, 50, 10);
ctx.Arc (100, 100, 15, 0, 360);
arcColor.Alpha = 0.4;
ctx.SetColor (arcColor);
ctx.Fill ();
// ImagePattern
ctx.Save ();
ctx.Translate (x + 130, y);
ctx.Pattern = new ImagePattern (img);
ctx.Rectangle (0, 0, 100, 100);
ctx.Fill ();
ctx.Restore ();
ctx.Restore ();
// Setting pixels
ctx.SetLineWidth (1);
for (int i=0; i<50;i++) {
for (var j=0; j<50;j++) {
Color c = Color.FromHsl (0.5, (double)i / 50d, (double)j / 50d);
ctx.Rectangle (i, j, 1, 1);
ctx.SetColor (c);
ctx.Fill ();
}
}
}
示例3: OnDraw
protected override void OnDraw(Context ctx, Rectangle dirtyRect)
{
if (Window?.DrawRedDebugOutline ?? false)
{
ctx.SetColor(Colors.Blue);
ctx.Rectangle(0, 0, Bounds.Width, Bounds.Height);
ctx.Stroke();
ctx.SetColor(Colors.Black);
}
}
示例4: 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 ();
}
示例5: OnDraw
protected override void OnDraw(Context ctx, Rectangle cellArea)
{
var pct = GetValue (ValueField);
var size = (cellArea.Width * pct) / 100f;
cellArea.Width = (int) size;
ctx.SetLineWidth (1);
ctx.Rectangle (cellArea.Inflate (-0.5, -0.5));
ctx.SetColor (Colors.LightBlue);
ctx.FillPreserve ();
ctx.SetColor (Colors.Gray);
ctx.Stroke ();
}
示例6: OnDraw
protected override void OnDraw (Context ctx, Rectangle bounds)
{
var lineWidth = bounds.Width / 32d;
var section = ((bounds.Width / 2) - lineWidth / 2) / 3;
ctx.SetLineWidth (lineWidth);
ctx.SetColor (Colors.Black);
ctx.Arc (bounds.Center.X, bounds.Center.Y, 1, 0, 360);
ctx.Stroke ();
ctx.SetColor (Colors.Red);
ctx.Arc (bounds.Center.X, bounds.Center.Y, section, 0, 360);
ctx.Stroke ();
ctx.SetColor (Colors.Green);
ctx.Arc (bounds.Center.X, bounds.Center.Y, section * 2, 0, 360);
ctx.Stroke ();
ctx.SetColor (Colors.Blue);
ctx.Arc (bounds.Center.X, bounds.Center.Y, section * 3, 0, 360);
ctx.Stroke ();
}
示例7: Draw
internal protected override void Draw (Context win, Rectangle area, long line, double x, double y)
{
win.Rectangle (x, y, Width, Editor.LineHeight);
win.SetColor (Style.IconBarBg);
win.Fill ();
win.MoveTo (x + Width - 1, y);
win.LineTo (x + Width - 1, y + Editor.LineHeight);
win.SetColor (Style.IconBarSeperator);
win.Stroke ();
foreach (long bookmark in Data.Bookmarks) {
if (line * Editor.BytesInRow <= bookmark && bookmark < line * Editor.BytesInRow + Editor.BytesInRow) {
DrawBookmark (win, x, y);
return;
}
}
}
示例8: OnDraw
protected override void OnDraw(Context ctx, Rectangle dirtyRect)
{
base.OnDraw(ctx, dirtyRect);
ctx.SetColor(Colors.Gray);
ctx.SetLineWidth(1);
ctx.RoundRectangle(0, Padding.Top / 2 - .5, Width - 4.5, Height - Padding.Bottom * 1.5, 3);
ctx.Stroke();
var tl = new TextLayout(this) { Text = title, Width = Width - Padding.Left - Padding.Right / 2 };
ctx.SetColor(Colors.White);
ctx.Rectangle(Padding.Left, 0, tl.GetSize().Width, Padding.Top);
ctx.Fill();
ctx.SetColor(Colors.Black);
ctx.DrawTextLayout(tl, Padding.Left, 0);
}
示例9: 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 ();
}
示例10: Path
public void Path (Context ctx, double px, double py)
{
ctx.Save ();
ctx.Translate (px, py);
var path = new DrawingPath ();
path.MoveTo (0.44, 18);
path.LineTo (-1, 18);
path.LineTo (-1, 26);
path.LineTo (0.44, 26);
path.LineTo (0, 42);
path.LineTo (29, 21.98);
path.LineTo (29, 21.98);
path.LineTo (0, 2);
path.LineTo (0.44, 18);
ctx.AppendPath (path);
ctx.SetColor (Colors.Black);
ctx.SetLineWidth (2);
ctx.Stroke ();
var path2 = path.CopyPath ();
path2.LineTo (15, 8);
path2.ClosePath ();
ctx.Rotate (180);
ctx.AppendPath (path2);
ctx.SetColor (Colors.Red);
ctx.SetLineDash (0, 5);
ctx.Stroke ();
ctx.Restore ();
}
示例11: 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 ();
}
}
示例12: Draw
//.........这里部分代码省略.........
}
// determine height of legend in items count units.
int heightInItemCount = 0;
if (extendingHorizontally) {
if (labelCount >= numberItemsVertically_) {
heightInItemCount = numberItemsVertically_;
}
else {
heightInItemCount = labelCount;
}
}
else { // extendingVertically
heightInItemCount = labelCount / numberItemsHorizontally_;
if (labelCount % numberItemsHorizontally_ != 0)
heightInItemCount += 1;
}
double lineLength = 20;
double hSpacing = (int)(5.0f * scale);
double vSpacing = (int)(3.0f * scale);
double boxWidth = (int) ((float)widthInItemCount * (lineLength + maxWd + hSpacing * 2.0f ) + hSpacing);
double boxHeight = (int)((float)heightInItemCount * (maxHt + vSpacing) + vSpacing);
double totalWidth = boxWidth;
double totalHeight = boxHeight;
// draw box around the legend.
if (BorderStyle == BorderType.Line) {
ctx.SetColor (bgColor_);
ctx.Rectangle (position.X, position.Y, boxWidth, boxHeight);
ctx.FillPreserve ();
ctx.SetColor (borderColor_);
ctx.Stroke ();
}
else if (BorderStyle == BorderType.Shadow) {
double offset = (4.0 * scale);
Color shade = Colors.Gray;
shade.Alpha = 0.5;
ctx.SetColor (Colors.Gray);
ctx.Rectangle (position.X+offset, position.Y+offset, boxWidth, boxHeight);
ctx.Fill ();
ctx.SetColor (bgColor_);
ctx.Rectangle (position.X, position.Y, boxWidth, boxHeight);
ctx.FillPreserve ();
ctx.SetColor (borderColor_);
ctx.Stroke ();
totalWidth += offset;
totalHeight += offset;
}
/*
else if ( this.BorderStyle == BorderType.Curved )
{
// TODO. make this nice.
}
*/
else {
// do nothing.
}
// now draw entries in box..
labelCount = 0;
unnamedCount = 0;
示例13: Curves2
public virtual void Curves2 (Context ctx, double sx, double sy)
{
ctx.Save ();
ctx.Translate (sx, sy);
ctx.SetColor (Colors.Black);
double x = 0, y = 40;
double x1 = y - x, y1 = x1 + y, x2 = x + y, y2 = x, x3 = y1, y3 = y;
ctx.MoveTo (x, y);
ctx.CurveTo (x1, y1, x2, y2, x3, y3);
ctx.SetLineWidth (2.0);
ctx.Stroke ();
ctx.SetColor (new Color (1, 0.2, 0.2, 0.6));
ctx.SetLineWidth (1.0);
ctx.MoveTo (x, y);
ctx.LineTo (x1, y1);
ctx.MoveTo (x2, y2);
ctx.LineTo (x3, y3);
ctx.Stroke ();
ctx.Restore ();
}
示例14: Draw
/// <summary>
/// Draws the horizontal line plot using the Context and the x and y axes specified
/// </summary>
/// <param name="ctx">The Context with which to draw.</param>
/// <param name="xAxis">The X-Axis to draw against.</param>
/// <param name="yAxis">The Y-Axis to draw against.</param>
public void Draw(Context ctx, PhysicalAxis xAxis, PhysicalAxis yAxis)
{
double xMin = xAxis.PhysicalMin.X;
double xMax = xAxis.PhysicalMax.X;
xMin += pixelIndent_;
xMax -= pixelIndent_;
double length = Math.Abs (xMax - xMin);
double lengthDiff = length - length*scale_;
double indentAmount = lengthDiff/2;
xMin += indentAmount;
xMax -= indentAmount;
double yPos = yAxis.WorldToPhysical (value_, false).Y;
ctx.Save ();
ctx.SetLineWidth (1);
ctx.SetColor (color_);
ctx.MoveTo (xMin, yPos);
ctx.LineTo (xMax, yPos);
ctx.Stroke ();
ctx.Restore ();
// todo: clip and proper logic for flipped axis min max.
}
示例15: OnDraw
protected override void OnDraw(Context ctx, Rectangle dirtyRect)
{
base.OnDraw(ctx, dirtyRect);
if (image != null) {
if (Heighlighted && IsThumbnail) {
ctx.RoundRectangle(new Rectangle(Point.Zero, image.Size), 3);
ctx.SetColor(Colors.LightSteelBlue);
ctx.Fill();
}
ctx.DrawImage(image, (new Rectangle(Point.Zero, image.Size)).Inflate(-3, -3));
if (mask != null && ShowMask) {
ctx.DrawImage(MaskBitmap, (new Rectangle(Point.Zero, image.Size)).Inflate(-3, -3), 0.6);
}
}
if (isEditMode) {
Point scaleFactor = new Point(
scan.Size.Width / image.Size.Width,
scan.Size.Height / image.Size.Height);
ctx.SetColor(Mask.maskColor);
foreach (MaskEntry p in scan.Mask.MaskPositions) {
switch (p.type) {
case MaskEntryType.Point:
ctx.SetLineWidth(p.pointerSize / scaleFactor.Y * 2);
ctx.LineTo(p.position.X / scaleFactor.X, p.position.Y / scaleFactor.Y);
ctx.Stroke();
ctx.Arc(
p.position.X / scaleFactor.X, p.position.Y / scaleFactor.Y,
p.pointerSize / scaleFactor.Y, 0, 360);
ctx.Fill();
ctx.MoveTo(p.position.X / scaleFactor.X, p.position.Y / scaleFactor.Y);
break;
case MaskEntryType.Space:
ctx.Stroke();
ctx.ClosePath();
break;
case MaskEntryType.Delete:
ctx.Arc(
p.position.X / scaleFactor.X, p.position.Y / scaleFactor.Y,
p.pointerSize / scaleFactor.Y, 0, 360);
ctx.Save();
ctx.Clip();
int newX = (int) Math.Min(Math.Max(
p.position.X / scaleFactor.X - pointerSize / scaleFactor.Y, 0), scan.Size.Width);
int newY = (int) Math.Min(Math.Max(
p.position.Y / scaleFactor.Y - pointerSize / scaleFactor.Y, 0), scan.Size.Height);
using (ImageBuilder ib =
new ImageBuilder((pointerSize / scaleFactor.Y * 2), (pointerSize / scaleFactor.Y * 2))) {
BitmapImage bi = ib.ToBitmap();
image.WithBoxSize(image.Size).ToBitmap().CopyArea(
newX, newY,
(int) (pointerSize / scaleFactor.Y * 2), (int) (pointerSize / scaleFactor.Y * 2),
bi, 0, 0);
ctx.DrawImage(bi, new Point(newX, newY));
}
ctx.Restore();
ctx.ClosePath();
break;
}
}
ctx.Stroke();
if (mousePosition != Point.Zero) {
ctx.Arc(mousePosition.X, mousePosition.Y, pointerSize / Math.Max(scaleFactor.X, scaleFactor.Y), 0, 360);
ctx.Fill();
if (mousePositionStart != Point.Zero) {
ctx.SetLineWidth((pointerSize / Math.Max(scaleFactor.X, scaleFactor.Y)) * 2);
ctx.SetColor(Mask.maskColor);
ctx.Arc(mousePositionStart.X, mousePositionStart.Y, pointerSize / Math.Max(scaleFactor.X, scaleFactor.Y), 0, 360);
ctx.Fill();
ctx.MoveTo(mousePosition);
ctx.LineTo(mousePositionStart);
ctx.Stroke();
}
}
}
}