本文整理汇总了C#中Xwt.Drawing.Context.SetLineWidth方法的典型用法代码示例。如果您正苦于以下问题:C# Context.SetLineWidth方法的具体用法?C# Context.SetLineWidth怎么用?C# Context.SetLineWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Xwt.Drawing.Context
的用法示例。
在下文中一共展示了Context.SetLineWidth方法的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: 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 ();
}
示例4: InitBlank
protected void InitBlank (int width = 50, int height = 50)
{
if (builder != null)
builder.Dispose ();
builder = new ImageBuilder (width, height);
context = builder.Context;
context.Rectangle (0, 0, width, height);
context.SetColor (Colors.White);
context.Fill ();
context.SetColor (Colors.Black);
context.SetLineWidth (1);
}
示例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 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);
}
示例7: 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 ();
}
示例8: 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
}
示例9: Draw
/// <summary>
/// Draw the axis. This involves three steps:
/// (1) Draw the axis line.
/// (2) Draw the tick marks.
/// (3) Draw the label.
/// </summary>
/// <param name="ctx">The Drawing Context with which to draw.</param>
/// <param name="physicalMin">The physical position corresponding to the world minimum of the axis.</param>
/// <param name="physicalMax">The physical position corresponding to the world maximum of the axis.</param>
/// <param name="boundingBox">out The bounding rectangle of the axis including axis line, label, tick marks and tick mark labels</param>
public virtual void Draw(Context ctx, Point physicalMin, Point physicalMax, out Rectangle boundingBox)
{
// calculate the bounds of the axis line only.
double x1 = Math.Min (physicalMin.X, physicalMax.X);
double x2 = Math.Max (physicalMin.X, physicalMax.X);
double y1 = Math.Min (physicalMin.Y, physicalMax.Y);
double y2 = Math.Max (physicalMin.Y, physicalMax.Y);
Rectangle bounds = new Rectangle (x1, y1, x2-x1, y2-y1);
if (!Hidden) {
// (1) Draw the axis line.
ctx.Save ();
ctx.SetLineWidth (1);
ctx.SetColor (LineColor);
ctx.MoveTo (physicalMin.X+0.5, physicalMin.Y+0.5);
ctx.LineTo (physicalMax.X+0.5, physicalMax.Y+0.5);
ctx.Stroke ();
ctx.Restore ();
// (2) draw tick marks (subclass responsibility).
object labelOffset;
object tickBounds;
DrawTicks (ctx, physicalMin, physicalMax, out labelOffset, out tickBounds);
// (3) draw the axis label
object labelBounds = null;
if (!HideTickText) {
labelBounds = DrawLabel (ctx, (Point)labelOffset, physicalMin, physicalMax);
}
// (4) merge bounds and return.
if (labelBounds != null) {
bounds = Rectangle.Union (bounds, (Rectangle)labelBounds);
}
if (tickBounds != null) {
bounds = Rectangle.Union (bounds, (Rectangle)tickBounds);
}
}
boundingBox = bounds;
}
示例10: Draw
/// <summary>
/// Draws the step plot using a Drawing Context against the provided x and y axes.
/// </summary>
/// <param name="ctx">The Drawing 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 virtual void Draw(Context ctx, PhysicalAxis xAxis, PhysicalAxis yAxis )
{
SequenceAdapter data =
new SequenceAdapter (DataSource, DataMember, OrdinateData, AbscissaData);
double leftCutoff = xAxis.PhysicalToWorld(xAxis.PhysicalMin, false);
double rightCutoff = xAxis.PhysicalToWorld(xAxis.PhysicalMax, false);
for (int i=0; i<data.Count; ++i) {
Point p1 = data[i];
if (Double.IsNaN(p1.X) || Double.IsNaN(p1.Y)) {
continue;
}
Point p2;
Point p3;
if (i+1 != data.Count) {
p2 = data[i+1];
if (Double.IsNaN(p2.X) || Double.IsNaN(p2.Y)) {
continue;
}
p2.Y = p1.Y;
p3 = data[i+1];
}
else {
// Check that we are not dealing with a DataSource of 1 point.
// This check is done here so it is only checked on the end
// condition and not for every point in the DataSource.
if (data.Count > 1) {
p2 = data[i - 1];
}
else {
// TODO: Once log4net is set up post a message to the user that a step-plot of 1 really does not make any sense.
p2 = p1;
}
double offset = p1.X - p2.X;
p2.X = p1.X + offset;
p2.Y = p1.Y;
p3 = p2;
}
if (center_) {
double offset = ( p2.X - p1.X ) / 2.0;
p1.X -= offset;
p2.X -= offset;
p3.X -= offset;
}
Point xPos1 = xAxis.WorldToPhysical (p1.X, false);
Point yPos1 = yAxis.WorldToPhysical (p1.Y, false);
Point xPos2 = xAxis.WorldToPhysical (p2.X, false);
Point yPos2 = yAxis.WorldToPhysical (p2.Y, false);
Point xPos3 = xAxis.WorldToPhysical (p3.X, false);
Point yPos3 = yAxis.WorldToPhysical (p3.Y, false);
// do horizontal clipping here, to speed up
if ((p1.X<leftCutoff && p2.X<leftCutoff && p3.X<leftCutoff) || (p1.X>rightCutoff && p2.X>rightCutoff && p3.X>rightCutoff)) {
continue;
}
ctx.Save ();
ctx.SetColor (Color);
ctx.SetLineWidth (1);
if (!this.hideHorizontalSegments_) {
if (scale_ != 1) {
double middle = (xPos2.X + xPos1.X) / 2;
double width = xPos2.X - xPos1.X;
width *= this.scale_;
ctx.MoveTo (middle-width/2, yPos1.Y);
ctx.LineTo (middle+width/2, yPos2.Y);
}
else {
ctx.MoveTo (xPos1.X, yPos1.Y);
ctx.LineTo (xPos2.X, yPos2.Y);
}
ctx.Stroke ();
}
if (!this.hideVerticalSegments_) {
ctx.MoveTo (xPos2.X, yPos2.Y);
ctx.LineTo (xPos3.X, yPos3.Y);
ctx.Stroke ();
}
ctx.Restore ();
}
}
示例11: OnDraw
protected override void OnDraw(Context ctx, Rectangle cellArea)
{
ctx.Rectangle (BackgroundBounds);
ctx.SetColor (new Color (0.9, 0.9, 0.9));
ctx.Fill ();
ctx.Rectangle (Bounds);
ctx.SetColor (new Color (0.7, 0.7, 0.7));
ctx.Fill ();
var pct = GetValue (ValueField);
var size = (cellArea.Width * pct.Value) / 100f;
cellArea.Width = (int) size;
ctx.SetLineWidth (1);
ctx.Rectangle (cellArea.Inflate (-0.5, -0.5));
ctx.SetColor (Selected ? Colors.Blue : Colors.LightBlue);
ctx.FillPreserve ();
ctx.SetColor (Colors.Gray);
ctx.Stroke ();
if (pct.YPos != -1) {
ctx.MoveTo (cellArea.Right, Bounds.Y + pct.YPos);
ctx.Arc (cellArea.Right, Bounds.Y + pct.YPos, 2.5, 0, 360);
ctx.SetColor (Colors.Red);
ctx.Fill ();
}
}
示例12: DrawFocus
void DrawFocus(Context ctx, Point p)
{
// Draw a 'zoom'-style Focus at specified point
double focusRadius = 32;
double r = 12, w = focusRadius - 1;
Point o = Point.Zero; // Drawing origin
// Align single-thickness lines on 0.5 pixel coords
o.X += 0.5;
o.Y += 0.5;
ctx.Save ();
ctx.Translate (p); // Final translation
// Hairlines in X-direction
ctx.MoveTo (o.X + r, o.Y);
ctx.LineTo (o.X + w, o.Y);
ctx.MoveTo (o.X - r, o.Y);
ctx.LineTo (o.X - w, o.Y);
// Hairlines in Y-direction
ctx.MoveTo (o.X, o.Y + r);
ctx.LineTo (o.X, o.Y + w);
ctx.MoveTo (o.X, o.Y - r);
ctx.LineTo (o.X, o.Y - w);
// Inner single-thickness circle
ctx.MoveTo (o.X + r, o.Y);
ctx.Arc (o.X, o.Y, r, 0, 360);
ctx.SetColor (Colors.Black);
ctx.SetLineWidth (1);
ctx.Stroke ();
// Double thickness outer arcs. Draw at (0,0) and rotate
o = Point.Zero;
r = 22;
ctx.Rotate (5);
ctx.MoveTo (r, 0);
ctx.Arc (o.X, o.Y, r, 0, 80);
ctx.MoveTo (o.X, r);
ctx.Arc (o.X, o.Y, r, 90, 170);
ctx.MoveTo (-r, o.Y);
ctx.Arc (o.X, o.Y, r, 180, 260);
ctx.MoveTo (o.X, -r);
ctx.Arc (o.X, o.Y, r, 270, 350);
ctx.SetLineWidth (2);
ctx.Stroke ();
ctx.Restore ();
}
示例13: 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 ();
}
示例14: 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 ();
}
示例15: 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 ();
}