当前位置: 首页>>代码示例>>C#>>正文


C# Drawing.Context类代码示例

本文整理汇总了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);
        }
开发者ID:parnham,项目名称:NPlot,代码行数:27,代码来源:LogAxisTest.cs

示例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);
        }
开发者ID:hwthomas,项目名称:XwPlot,代码行数:25,代码来源:TradingDateTimeAxisTest.cs

示例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 ();
        }
开发者ID:RevolutionSmythe,项目名称:xwt,代码行数:25,代码来源:DrawingFigures.cs

示例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));
        }
开发者ID:KIV-ASWI-PL2014,项目名称:Director,代码行数:26,代码来源:InfoBox.cs

示例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));
 }
开发者ID:pabloescribano,项目名称:xwt,代码行数:7,代码来源:ImageBuilder.cs

示例6: using

 void ICanvasCellViewFrontend.Draw(object ctxBackend, Rectangle cellArea)
 {
     using (var ctx = new Context (ctxBackend, Toolkit.CurrentEngine)) {
         ctx.Reset (null);
         OnDraw (ctx, cellArea);
     }
 }
开发者ID:shines77,项目名称:xwt,代码行数:7,代码来源:CanvasCellView.cs

示例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));
		}
开发者ID:m13253,项目名称:xwt,代码行数:27,代码来源:ImageScaling.cs

示例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);
 }
开发者ID:chkn,项目名称:xwt,代码行数:8,代码来源:TextLayoutBackendHandler.cs

示例9: Init

 public void Init()
 {
     ib = new ImageBuilder (1, 1);
     context = ib.Context;
     Matrix m1 = Matrix.Identity;
     Matrix m2 = context.GetCTM ();
     CheckMatrix (m1, m2);
 }
开发者ID:nite2006,项目名称:xwt,代码行数:8,代码来源:TransformTests.cs

示例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);
 }
开发者ID:garuma,项目名称:xwt,代码行数:8,代码来源:ImageBuilder.cs

示例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();
 }
开发者ID:cra0zy,项目名称:XwtPlus.TextEditor,代码行数:8,代码来源:LineNumberMargin.cs

示例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 ();
		}
开发者ID:TheBrainTech,项目名称:xwt,代码行数:8,代码来源:VectorImage.cs

示例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;
 }
开发者ID:samclarke,项目名称:xwt,代码行数:8,代码来源:ImageBuilder.cs

示例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();
                }
            }
        }
开发者ID:cra0zy,项目名称:XwtPlus.TextEditor,代码行数:57,代码来源:TextViewMargin.cs

示例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);
     }
 }
开发者ID:hwthomas,项目名称:XwPlot,代码行数:9,代码来源:OverlayTest.cs


注:本文中的Xwt.Drawing.Context类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。