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


C# Context.GetTarget方法代码示例

本文整理汇总了C#中Cairo.Context.GetTarget方法的典型用法代码示例。如果您正苦于以下问题:C# Context.GetTarget方法的具体用法?C# Context.GetTarget怎么用?C# Context.GetTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cairo.Context的用法示例。


在下文中一共展示了Context.GetTarget方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Render

        public void Render(DrawingArea area, SettingsModel settings)
        {
            var width = area.Allocation.Width;
            var height = area.Allocation.Height;

            var kaleidoscope = _factory.Get (settings.Type);
            var rootNode = kaleidoscope.Generate (
                settings.GeometyWidth,
                settings.ImageUri,
                width, height);

            ImageSurface surface = new ImageSurface(Format.Argb32, width, height);

            using (var context = new Context (surface)) {
                context.Translate(width / 2, height / 2);
                rootNode.Render (context);
            }
            rootNode.Geometry.Dispose ();

            using (Context context = Gdk.CairoHelper.Create (area.GdkWindow)) {
                context.Rectangle(0, 0, width, height);
                context.SetSource(surface);
                context.Fill();
                context.GetTarget ().Dispose ();
            }
            surface.Dispose ();
        }
开发者ID:imagineblueeyes,项目名称:KaleidoscopeGenerator,代码行数:27,代码来源:CairoRenderer.cs

示例2: CreateSurfaceForPixbuf

        public static Surface CreateSurfaceForPixbuf (Context cr, Pixbuf pixbuf)
        {
			Surface surface;
			using (var t = cr.GetTarget ()) {
				surface = t.CreateSimilar (t.Content, pixbuf.Width, pixbuf.Height);
			}
			using (Context surface_cr = new Context (surface)) {
				CairoHelper.SetSourcePixbuf (surface_cr, pixbuf, 0, 0);
				surface_cr.Paint ();
				surface_cr.Dispose ();
			}
            return surface;
        }
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:13,代码来源:CairoExtensions.cs

示例3: Form1_Shown

        private void Form1_Shown(object sender, EventArgs e)
        {
            Debug.WriteLine("Form1_Shown");

            surface = new Win32Surface(this.CreateGraphics().GetHdc());
            context = new Context(surface);

            textFormat = DWriteCairo.CreateTextFormat(
                "Consolas",
                FontWeight.Normal,
                FontStyle.Normal,
                FontStretch.Normal,
                12);

            textFormat.TextAlignment = TextAlignment.Center;
            
            float left, top, width, height;

            // get actual size of the text
            var measureLayout = DWriteCairo.CreateTextLayout(s, textFormat, 4096, 4096);
            measureLayout.GetRect(out left, out top, out width, out height);
            measureLayout.Dispose();

            // build text context against the size and format
            textLayout = DWriteCairo.CreateTextLayout(s, textFormat, (int)Math.Ceiling(width), (int)Math.Ceiling(height));

            Debug.WriteLine("showing layout");
            Path path = DWriteCairo.RenderLayoutToCairoPath(context, textLayout);
            context.AppendPath(path);
            context.Fill();

            textLayout.GetRect(out left, out top, out width, out height);
            textRect = new System.Drawing.RectangleF(left, top, width, height);
            context.Rectangle(left, top, width, height);
            context.Stroke();

            context.GetTarget().Flush();
        }
开发者ID:zwcloud,项目名称:ZWCloud.DwriteCairo,代码行数:38,代码来源:Form1.cs

示例4: FillChecks

	void FillChecks (Context cr, int x, int y, int width, int height)
	{
		int CHECK_SIZE = 32;
		
		cr.Save ();
		Surface check;
		using (var target = cr.GetTarget ()) {
			check = target.CreateSimilar (Content.Color, 2 * CHECK_SIZE, 2 * CHECK_SIZE);
		}
		
		// draw the check
		using (Context cr2 = new Context (check)) {
			cr2.Operator = Operator.Source;
			cr2.SetSourceRGB (0.4, 0.4, 0.4);
			cr2.Rectangle (0, 0, 2 * CHECK_SIZE, 2 * CHECK_SIZE);
			cr2.Fill ();

			cr2.SetSourceRGB (0.7, 0.7, 0.7);
			cr2.Rectangle (x, y, CHECK_SIZE, CHECK_SIZE);
			cr2.Fill ();

			cr2.Rectangle (x + CHECK_SIZE, y + CHECK_SIZE, CHECK_SIZE, CHECK_SIZE);
			cr2.Fill ();
		}

		// Fill the whole surface with the check
		SurfacePattern check_pattern = new SurfacePattern (check);
		check_pattern.Extend = Extend.Repeat;
		cr.SetSource (check_pattern);
		cr.Rectangle (0, 0, width, height);
		cr.Fill ();

		check_pattern.Dispose ();
		check.Dispose ();
		cr.Restore ();
	}
开发者ID:akrisiun,项目名称:gtk-sharp,代码行数:36,代码来源:CairoSample.cs

示例5: OnMouseRelease

        //Getting end of the would-be line, kept for possible re-use of lines
        void OnMouseRelease(object source, ButtonReleaseEventArgs args)
        {
            End.X = args.Event.X;
            End.Y = args.Event.Y;

            isDrawing = false;

            using (Context ctx = new Context(surface))
            {
                Painter(ctx, Start, End);
                ((IDisposable) ctx.GetTarget()).Dispose ();
                ((IDisposable)ctx).Dispose ();
            }

            dArea.QueueDraw();
        }
开发者ID:justingruber,项目名称:Protractor,代码行数:17,代码来源:Launcher.cs

示例6: OnMouseMotion

        //Updates every time the mouse is moved while button is pressed
        void OnMouseMotion(object source, MotionNotifyEventArgs args)
        {
            if (isDrawing)
            {
                End.X = args.Event.X;
                End.Y = args.Event.Y;

                using (Context ctx = new Context (surface)) {
                    //Reset of end's points so there are no accidental
                    if (isDot) {
                        Start.X = args.Event.X;
                        Start.Y = args.Event.Y;
                    }
                    Painter (ctx, Start, End);
                    ((IDisposable) ctx.GetTarget()).Dispose ();
                    ((IDisposable)ctx).Dispose ();
                }

                dArea.QueueDraw();
            }
        }
开发者ID:justingruber,项目名称:Protractor,代码行数:22,代码来源:Launcher.cs

示例7: Draw

	void Draw (Context cr, int width, int height)
	{
		double radius = 0.5 * Math.Min (width, height) - 10;
		int xc = width / 2;
		int yc = height / 2;

		Surface overlay, punch, circles;
		using (var target = cr.GetTarget ()) {
			overlay = target.CreateSimilar (Content.ColorAlpha, width, height);
			punch   = target.CreateSimilar (Content.Alpha, width, height);
			circles = target.CreateSimilar (Content.ColorAlpha, width, height);
		}

		FillChecks (cr, 0, 0, width, height);
		cr.Save ();

		// Draw a black circle on the overlay
		using (Context cr_overlay = new Context (overlay)) {
			cr_overlay.SetSourceRGB (0.0, 0.0, 0.0);
			OvalPath (cr_overlay, xc, yc, radius, radius);
			cr_overlay.Fill ();

			// Draw 3 circles to the punch surface, then cut
			// that out of the main circle in the overlay
			using (Context cr_tmp = new Context (punch))
				Draw3Circles (cr_tmp, xc, yc, radius, 1.0);

			cr_overlay.Operator = Operator.DestOut;
			cr_overlay.SetSourceSurface (punch, 0, 0);
			cr_overlay.Paint ();

			// Now draw the 3 circles in a subgroup again
			// at half intensity, and use OperatorAdd to join up
			// without seams.
			using (Context cr_circles = new Context (circles)) {
				cr_circles.Operator = Operator.Over;
				Draw3Circles (cr_circles, xc, yc, radius, 0.5);
			}

			cr_overlay.Operator = Operator.Add;
			cr_overlay.SetSourceSurface (circles, 0, 0);
			cr_overlay.Paint ();
		}

		cr.SetSourceSurface (overlay, 0, 0);
		cr.Paint ();

		overlay.Dispose ();
		punch.Dispose ();
		circles.Dispose ();
	}
开发者ID:akrisiun,项目名称:gtk-sharp,代码行数:51,代码来源:CairoSample.cs

示例8: draw

        private void draw()
        {
            if (viewSurface != null)
            {
                viewSurface.Dispose();
            }

            viewSurface = new ImageSurface(Format.ARGB32, winWidth, winHeight);

            //Context cr = Gdk.CairoHelper.Create(drawArea.GdkWindow);
            Context cr = new Context(viewSurface);

            clearDrawArea (cr);

            Drawer.DrawPoints (points,cr);

            foreach (VertexStructure vs in vertexStructs) {
                Drawer.DrawVertexStructure (vs,cr);
            }

            foreach (IGameObject go in gos) {
                if (go.needsDrawing ()) {
                    go.draw (cr);
                }
            }

            ((IDisposable) cr.GetTarget()).Dispose();
            ((IDisposable) cr).Dispose();

            using (Context cr2 = Gdk.CairoHelper.Create(drawArea.GdkWindow))
            {
                cr2.SetSourceSurface(viewSurface, 0, 0);
                cr2.Paint();
            }

            drawArea.QueueDraw ();
        }
开发者ID:latestversion,项目名称:projects,代码行数:37,代码来源:Demo.cs


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