本文整理汇总了C#中Xwt.Drawing.Context类的典型用法代码示例。如果您正苦于以下问题:C# Context类的具体用法?C# Context怎么用?C# Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Context类属于Xwt.Drawing命名空间,在下文中一共展示了Context类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawAxisTests
private void DrawAxisTests(Context ctx, Rectangle bounds)
{
Rectangle boundingBox;
Point tl = Point.Zero;
Point br = Point.Zero;;
tl.X = bounds.Left + 30; tl.Y = bounds.Top + 20;
br.X = bounds.Right - 30; br.Y = bounds.Top + 20;
LogAxis log = new LogAxis (1, 10000);
log.Draw (ctx, tl, br, out boundingBox);
log.Reversed = true;
tl.Y += 50; br.Y += 50;
log.Draw (ctx, br, tl, out boundingBox);
// Test for default TicksAngle on positive X-axis, ie Ticks below X-axis
LogAxis lx = new LogAxis (100, 100000);
lx.NumberFormat = "{0:0.0E+0}";
tl.X = bounds.Left + 30; tl.Y = bounds.Bottom - 60;
br.X = bounds.Right - 30; br.Y = bounds.Bottom - 60;
lx.Draw (ctx, tl, br, out boundingBox);
}
示例2: DrawAxisTests
private void DrawAxisTests(Context ctx, Rectangle bounds)
{
Rectangle boundingBox;
Point tl = Point.Zero;
Point br = Point.Zero;
tl.X = bounds.Left + 30; tl.Y = bounds.Top + 20;
br.X = bounds.Right - 30; br.Y = bounds.Top + 20;
DateTime timeMin = new DateTime (2003, 10, 22, 15, 00, 00);
DateTime timeMax = new DateTime (2004, 03, 12, 13, 30, 00);
TradingDateTimeAxis axis = new TradingDateTimeAxis ();
axis.WorldMin = (double)timeMin.Ticks;
axis.WorldMax = (double)timeMax.Ticks;
axis.Draw (ctx, tl, br, out boundingBox);
timeMin = new DateTime (2013, 09, 17, 12, 30, 10);
timeMax = new DateTime (2014, 01, 23, 12, 59, 30);
axis.WorldMin = (double)timeMin.Ticks;
axis.WorldMax = (double)timeMax.Ticks;
tl.Y += 50; br.Y += 50;
axis.Draw (ctx, tl, br, out boundingBox);
}
示例3: 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 ();
}
示例4: OnDraw
protected override void OnDraw(Context ctx, Rectangle dirtyRect)
{
// Line arround
ctx.SetColor(Colors.DarkGray);
// Drive line arround
ctx.Rectangle(Bounds);
ctx.Fill();
ctx.SetColor(Colors.Gray);
ctx.Rectangle(Bounds.Inflate(-margin, -margin));
ctx.Fill();
// Draw image
ctx.DrawImage(Image.FromResource(Logo), 5.0, 5.0);
// Draw text
ctx.SetColor(Colors.White);
TextLayout _layout = new TextLayout();
_layout.Font = Font.WithSize(22);
_layout.Text = Label;
_layout.SetFontWeight(FontWeight.Bold, 0, Label.Length);
// Cocoa layouts
ctx.DrawTextLayout(_layout, 45, ((Config.Cocoa || Config.Gtk) ? 5 : 2));
}
示例5: ImageBuilder
public ImageBuilder(int width, int height, ImageFormat format)
{
this.width = width;
this.height = height;
backend = handler.CreateImageBuilder (width, height, format);
ctx = new Context (handler.CreateContext (backend));
}
示例6: using
void ICanvasCellViewFrontend.Draw(object ctxBackend, Rectangle cellArea)
{
using (var ctx = new Context (ctxBackend, Toolkit.CurrentEngine)) {
ctx.Reset (null);
OnDraw (ctx, cellArea);
}
}
示例7: OnDraw
protected override void OnDraw (Context ctx, Rectangle dirtyRect)
{
Image image = new CustomImage ();
int x = 0;
for (int n=4; n < 50; n += 4) {
ctx.DrawImage (image.WithSize (n, n), x, 0);
x += n;
}
int maxSize = 48;
var warn = StockIcons.Error;
x = 0;
for (int n=8; n <= maxSize; n += 2) {
ctx.DrawImage (warn, x, 50, n, n);
x += n;
}
warn = StockIcons.Error.WithSize (maxSize).ToBitmap ();
x = 0;
for (int n=8; n <= maxSize; n += 2) {
ctx.DrawImage (warn, x, 100, n, n);
x += n;
}
ctx.DrawImage (image.WithSize (1000), new Rectangle (400, 0, 200, 1000), new Rectangle (0, 200, 200, 200));
ctx.DrawImage (image.WithSize (1000), new Rectangle (400, 0, 200, 50), new Rectangle (210, 200, 200, 200));
}
示例8: Create
public object Create(Context context)
{
if (context != null) {
GtkContext c = (GtkContext) WidgetRegistry.GetBackend (context);
return Pango.CairoHelper.CreateLayout (c.Context);
} else
return Pango.CairoHelper.CreateLayout (SharedContext);
}
示例9: Init
public void Init()
{
ib = new ImageBuilder (1, 1);
context = ib.Context;
Matrix m1 = Matrix.Identity;
Matrix m2 = context.GetCTM ();
CheckMatrix (m1, m2);
}
示例10: ImageBuilder
public ImageBuilder(int width, int height, ImageFormat format)
{
handler = ToolkitEngine.ImageBuilderBackendHandler;
this.width = width;
this.height = height;
backend = handler.CreateImageBuilder (width, height, format);
ctx = new Context (handler.CreateContext (backend), ToolkitEngine);
}
示例11: DrawBackground
protected internal override void DrawBackground(Context cr, Xwt.Rectangle area, DocumentLine line, int lineNumber, double x, double y, double height)
{
cr.Save();
cr.SetColor(Colors.LightGray);
cr.Rectangle(x, y, Width, height + 1);
cr.Fill();
cr.Restore();
}
示例12: OnDraw
protected override void OnDraw (Context ctx, Rectangle bounds)
{
ctx.Save ();
ctx.Translate (bounds.Location);
ctx.Scale (bounds.Width / Size.Width, bounds.Height / Size.Height);
ToolkitEngine.VectorImageRecorderContextHandler.Draw (ctx.Handler, Toolkit.GetBackend (ctx), data);
ctx.Restore ();
}
示例13: ImageBuilder
public ImageBuilder(double width, double height)
{
backend = new VectorContextBackend ();
ctx = new Context (backend, ToolkitEngine, vectorImageRecorderContextHandler);
ctx.Reset (null);
this.width = width;
this.height = height;
}
示例14: Draw
protected internal override void Draw(Context cr, Xwt.Rectangle area, DocumentLine line, int lineNumber, double x, double y, double height)
{
if (line != null)
{
TextLayout layout;
if (!layoutDict.TryGetValue(line, out layout))
{
var mode = editor.Document.SyntaxMode;
var style = SyntaxModeService.DefaultColorStyle;
var chunks = GetCachedChunks(mode, editor.Document, style, line, line.Offset, line.Length);
layout = new TextLayout();
layout.Font = editor.Options.EditorFont;
string lineText = editor.Document.GetLineText(lineNumber);
var stringBuilder = new StringBuilder(lineText.Length);
int currentVisualColumn = 1;
for (int i = 0; i < lineText.Length; ++i)
{
char chr = lineText[i];
if (chr == '\t')
{
int length = GetNextTabstop(editor, currentVisualColumn) - currentVisualColumn;
stringBuilder.Append(' ', length);
currentVisualColumn += length;
}
else
{
stringBuilder.Append(chr);
if (!char.IsLowSurrogate(chr))
{
++currentVisualColumn;
}
}
}
layout.Text = stringBuilder.ToString();
int visualOffset = 1;
foreach (var chunk in chunks)
{
var chunkStyle = style.GetChunkStyle(chunk);
visualOffset = DrawLinePortion(cr, chunkStyle, layout, line, visualOffset, chunk.Length);
}
//layoutDict[line] = layout;
}
cr.DrawTextLayout(layout, x, y);
if (editor.CaretVisible && editor.Caret.Line == lineNumber)
{
cr.SetColor(Colors.Black);
cr.Rectangle(x + ColumnToX(line, editor.Caret.Column), y, caretWidth, LineHeight);
cr.Fill();
}
}
}
示例15: OnDrawOverlay
protected override void OnDrawOverlay(Context ctx, Rectangle dirtyArea)
{
// check if sufficiently inside Canvas
// only draw once inside focusRadius
if (lastCursor.X > focusRadius && lastCursor.X < Bounds.Right - focusRadius &&
lastCursor.Y > focusRadius && lastCursor.Y < Bounds.Bottom - focusRadius) {
DrawFocus (ctx, lastCursor);
}
}