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


C# Cairo.Clip方法代码示例

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


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

示例1: draw

	static void draw (Cairo.Context gr, int width, int height)
	{
		int w, h;
		ImageSurface image;
		
		gr.Scale (width, height);
		gr.LineWidth = 0.04;
		
		gr.Arc (0.5, 0.5, 0.3, 0, 2*M_PI);
		gr.Clip ();
		gr.NewPath ();
		
		image = new ImageSurface("data/e.png");
		w = image.Width;
		h = image.Height;
		
		gr.Scale (1.0/w, 1.0/h);
		
		image.Show (gr, 0, 0);
		
		image.Destroy();
		
		gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI);
		gr.Clip ();
		
		gr.NewPath ();
		gr.Rectangle (new PointD (0, 0), 1, 1);
		gr.Fill ();
		gr.Color = new Color (0, 1, 0, 1);
		gr.MoveTo ( new PointD (0, 0) );
		gr.LineTo ( new PointD (1, 1) );
		gr.MoveTo ( new PointD (1, 0) );
		gr.LineTo ( new PointD (0, 1) );
		gr.Stroke ();
	}
开发者ID:nlhepler,项目名称:mono,代码行数:35,代码来源:clip_img.cs

示例2: onDraw

        protected override void onDraw(Cairo.Context gr)
        {
            Rectangle rBack = new Rectangle (Slot.Size);

            //rBack.Inflate (-Margin);
            //			if (BorderWidth > 0)
            //				rBack.Inflate (-BorderWidth / 2);

            Background.SetAsSource (gr, rBack);
            CairoHelpers.CairoRectangle(gr, rBack, CornerRadius);
            gr.Fill ();

            if (BorderWidth > 0) {
                Foreground.SetAsSource (gr, rBack);
                CairoHelpers.CairoRectangle(gr, rBack, CornerRadius, BorderWidth);
            }

            gr.Save ();
            if (ClipToClientRect) {
                //clip to client zone
                CairoHelpers.CairoRectangle (gr, ClientRectangle,Math.Max(0.0, CornerRadius-Margin));
                gr.Clip ();
            }

            if (child != null)
                child.Paint (ref gr);
            gr.Restore ();
        }
开发者ID:jpbruyere,项目名称:Crow,代码行数:28,代码来源:Border.cs

示例3: draw

	static void draw (Cairo.Context gr, int width, int height)
	{
		gr.Scale (width, height);
		gr.LineWidth = 0.04;

		gr.Arc (0.5, 0.5, 0.3, 0, 2 * M_PI);
		gr.Clip ();

		gr.NewPath ();
		gr.Rectangle (new PointD (0, 0), 1, 1);
		gr.Fill ();
		gr.Color = new Color (0, 1, 0, 1);
		gr.MoveTo ( new PointD (0, 0) );
	        gr.LineTo ( new PointD (1, 1) );
		gr.MoveTo ( new PointD (1, 0) );
		gr.LineTo ( new PointD (0, 1) );
		gr.Stroke ();
	}
开发者ID:nlhepler,项目名称:mono,代码行数:18,代码来源:clip.cs

示例4: DrawSerie

        void DrawSerie(Cairo.Context ctx, Serie serie)
        {
            ctx.NewPath ();
            ctx.Rectangle (left, top, width + 1, height + 1);
            ctx.Clip ();

            ctx.NewPath ();
            ctx.SetSourceColor (serie.Color);
            ctx.LineWidth = serie.LineWidth;

            bool first = true;
            bool blockMode = serie.DisplayMode == DisplayMode.BlockLine;

            double lastY = 0;

            foreach (Data d in serie.GetData (startX, endX)) {
                double x, y;
                GetPoint (d.X, d.Y, out x, out y);
                if (first) {
                    ctx.MoveTo (x, y);
                    lastY = y;
                    first = false;
                } else {
                    if (blockMode) {
                        if (lastY != y)
                            ctx.LineTo (x, lastY);
                        ctx.LineTo (x, y);
                    } else
                        ctx.LineTo (x, y);
                }
                lastY = y;
            }

            ctx.Stroke ();
        }
开发者ID:Kalnor,项目名称:monodevelop,代码行数:35,代码来源:BasicChart.cs

示例5: RenderLineNumberIcon

		void RenderLineNumberIcon (Widget widget, Cairo.Context cr, Gdk.Rectangle cell_area, int markupHeight, int yOffset)
		{
			if (Frame == null)
				return;

			cr.Save ();

			#if CENTER_ROUNDED_RECTANGLE
			cr.Translate (cell_area.X + Padding, (cell_area.Y + (cell_area.Height - RoundedRectangleHeight) / 2.0));
			#else
			cr.Translate (cell_area.X + Padding, cell_area.Y + Padding + yOffset);
			#endif

			cr.Antialias = Cairo.Antialias.Subpixel;

			cr.RoundedRectangle (0.0, 0.0, RoundedRectangleWidth, RoundedRectangleHeight, RoundedRectangleRadius);
			cr.Clip ();

			if (IsUserCode)
				cr.SetSourceRGBA (0.90, 0.60, 0.87, 1.0); // 230, 152, 223
			else
				cr.SetSourceRGBA (0.77, 0.77, 0.77, 1.0); // 197, 197, 197

			cr.RoundedRectangle (0.0, 0.0, RoundedRectangleWidth, RoundedRectangleHeight, RoundedRectangleRadius);
			cr.Fill ();

			cr.SetSourceRGBA (0.0, 0.0, 0.0, 0.11);
			cr.RoundedRectangle (0.0, 0.0, RoundedRectangleWidth, RoundedRectangleHeight, RoundedRectangleRadius);
			cr.LineWidth = 2;
			cr.Stroke ();

			var lineNumber = !string.IsNullOrEmpty (Frame.File) ? Frame.Line : -1;

			using (var layout = PangoUtil.CreateLayout (widget, lineNumber != -1 ? lineNumber.ToString () : "???")) {
				layout.Alignment = Pango.Alignment.Left;
				layout.FontDescription = LineNumberFont;

				int width, height;
				layout.GetPixelSize (out width, out height);

				double y_offset = (RoundedRectangleHeight - height) / 2.0;
				double x_offset = (RoundedRectangleWidth - width) / 2.0;

				// render the text shadow
				cr.Save ();
				cr.SetSourceRGBA (0.0, 0.0, 0.0, 0.34);
				cr.Translate (x_offset, y_offset + 1);
				cr.ShowLayout (layout);
				cr.Restore ();

				cr.SetSourceRGBA (1.0, 1.0, 1.0, 1.0);
				cr.Translate (x_offset, y_offset);
				cr.ShowLayout (layout);
			}

			cr.Restore ();
		}
开发者ID:zenek-y,项目名称:monodevelop,代码行数:57,代码来源:ExceptionCaughtDialog.cs

示例6: OnRender

		protected override void OnRender (Cairo.Context context)
		{
			OnLayoutOutline (context);
			context.Clip ();
			context.Color = new Cairo.Color (1, 1, 1, Opacity * entryGroup.Opacity);
			context.Paint ();
			
			Gdk.Rectangle region = new Gdk.Rectangle (0, 0, (int)Width, (int)Height); 
			
			context.Save ();
			ClipBackground (context, region);
			base.OnRender (context);
			context.Restore ();
			DrawOutline (context, region, Opacity * entryGroup.Opacity);
		}
开发者ID:jassmith,项目名称:Xamarin.Canvas,代码行数:15,代码来源:SearchBoxCanvasElement.cs

示例7: OnRender

		protected override void OnRender (Cairo.Context context)
		{
			using (var layout = GetLayout ()) {

				int w, h;
				layout.GetPixelSize (out w, out h);

				int textX = 10;
				int textY = ((int)Height - h) / 2;

				if (CaretHighlightOffset != -1) {
					Pango.Rectangle rightStrongRect, rightRect;
					layout.GetCursorPos (Math.Max (CaretOffset, CaretHighlightOffset), out rightStrongRect, out rightRect);

					Pango.Rectangle leftStrongRect, leftRect;
					layout.GetCursorPos (Math.Min (CaretOffset, CaretHighlightOffset), out leftStrongRect, out leftRect);

					context.Rectangle (textX + Pango.Units.ToPixels (leftRect.X), textY + Pango.Units.ToPixels (leftRect.Y), Pango.Units.ToPixels (rightRect.X + rightRect.Width - leftRect.X), Pango.Units.ToPixels (leftRect.Height));
					context.Color = HasFocus ? new Cairo.Color (0.8, 0.9, 1, Opacity) : new Cairo.Color (0.8, 0.8, 0.8, Opacity);
					context.Fill ();
				}

				context.MoveTo (textX, textY);
				context.Color = new Cairo.Color (0, 0, 0, Opacity);
				Pango.CairoHelper.ShowLayout (context, layout);

				if (CaretHighlightOffset == -1 && drawCaret) {
					Pango.Rectangle strongRect, weakRect;
					layout.GetCursorPos (CaretOffset, out strongRect, out weakRect);
					context.Rectangle (textX + Pango.Units.ToPixels (weakRect.X), textY + Pango.Units.ToPixels (weakRect.Y), 1, Pango.Units.ToPixels (weakRect.Height));
					context.Color = new Cairo.Color (0, 0, 0, Opacity);
					context.Fill ();
				}
			}

			OnLayoutOutline (context);
			context.Clip ();
			base.OnRender (context);
		}
开发者ID:jassmith,项目名称:Xamarin.Canvas,代码行数:39,代码来源:EntryCanvasElement.cs

示例8: Draw

		void Draw (Cairo.Context ctx)
		{
			int tabArea = tabEndX - tabStartX;
			int x = GetRenderOffset ();
			int y = 0;
			int n = 0;
			Action<Cairo.Context> drawActive = c => {};
			List<Action<Cairo.Context>> drawCommands = new List<Action<Context>> ();
			for (; n < notebook.Tabs.Count; n++) {
				if (x + TabWidth < tabStartX) {
					x += TabWidth;
					continue;
				}

				if (x > tabEndX)
					break;

				int closingWidth;
				var cmd = DrawClosingTab (n, new Gdk.Rectangle (x, y, 0, Allocation.Height), out closingWidth);
				drawCommands.Add (cmd);
				x += closingWidth;

				var tab = (DockNotebookTab)notebook.Tabs [n];
				bool active = tab == notebook.CurrentTab;

				int width = Math.Min (TabWidth, Math.Max (50, tabEndX - x - 1));
				if (tab == notebook.Tabs.Last ())
					width += LastTabWidthAdjustment;
				width = (int) (width * tab.WidthModifier);

				if (active) {
					int tmp = x;
					drawActive = c => DrawTab (c, tab, Allocation, new Gdk.Rectangle (tmp, y, width, Allocation.Height), true, true, draggingTab, CreateTabLayout (tab));
					tab.Allocation = new Gdk.Rectangle (tmp, Allocation.Y, width, Allocation.Height);
				} else {
					int tmp = x;
					bool highlighted = tab == highlightedTab;

					if (tab.SaveStrength > 0.0f) {
						tmp = (int) (tab.SavedAllocation.X + (tmp - tab.SavedAllocation.X) * (1.0f - tab.SaveStrength));
					}

					drawCommands.Add (c => DrawTab (c, tab, Allocation, new Gdk.Rectangle (tmp, y, width, Allocation.Height), highlighted, false, false, CreateTabLayout (tab)));
					tab.Allocation = new Gdk.Rectangle (tmp, Allocation.Y, width, Allocation.Height);
				}

				x += width;
			}

			Gdk.Rectangle allocation = Allocation;
			int tabWidth;
			drawCommands.Add (DrawClosingTab (n, new Gdk.Rectangle (x, y, 0, allocation.Height), out tabWidth));
			drawCommands.Reverse ();

			DrawBackground (ctx, allocation);

			// Draw breadcrumb bar header
			if (notebook.Tabs.Count > 0) {
				ctx.Rectangle (0, allocation.Height - BottomBarPadding, allocation.Width, BottomBarPadding);
				ctx.SetSourceColor (Styles.BreadcrumbBackgroundColor);
				ctx.Fill ();
			}

			ctx.Rectangle (tabStartX - LeanWidth / 2, allocation.Y, tabArea + LeanWidth, allocation.Height);
			ctx.Clip ();

			foreach (var cmd in drawCommands)
				cmd (ctx);

			ctx.ResetClip ();

			// Redraw the dragging tab here to be sure its on top. We drew it before to get the sizing correct, this should be fixed.
			drawActive (ctx);
		}
开发者ID:alexrp,项目名称:monodevelop,代码行数:74,代码来源:DockNotebook.cs

示例9: OnDrawn

        protected override bool OnDrawn(Cairo.Context cr)
        {
            if (!CairoHelper.ShouldDrawWindow (cr, Window)) {
                return base.OnDrawn (cr);
            }

            if (reflect) {
                CairoExtensions.PushGroup (cr);
            }

            cr.Operator = Operator.Over;
            cr.Translate (h_padding, 0);
            cr.Rectangle (0, 0, Allocation.Width - h_padding, Math.Max (2 * bar_height,
                bar_height + bar_label_spacing + layout_height));
            cr.Clip ();

            Pattern bar = RenderBar (Allocation.Width - 2 * h_padding, bar_height);

            cr.Save ();
            cr.Source = bar;
            cr.Paint ();
            cr.Restore ();

            if (reflect) {
                cr.Save ();

                cr.Rectangle (0, bar_height, Allocation.Width - h_padding, bar_height);
                cr.Clip ();

                Matrix matrix = new Matrix ();
                matrix.InitScale (1, -1);
                matrix.Translate (0, -(2 * bar_height) + 1);
                cr.Transform (matrix);

                cr.Pattern = bar;

                LinearGradient mask = new LinearGradient (0, 0, 0, bar_height);

                mask.AddColorStop (0.25, new Color (0, 0, 0, 0));
                mask.AddColorStop (0.5, new Color (0, 0, 0, 0.125));
                mask.AddColorStop (0.75, new Color (0, 0, 0, 0.4));
                mask.AddColorStop (1.0, new Color (0, 0, 0, 0.7));

                cr.Mask (mask);
                mask.Destroy ();

                cr.Restore ();

                CairoExtensions.PopGroupToSource (cr);
                cr.Paint ();
            }

            if (show_labels) {
                cr.Translate ((reflect ? 0 : -h_padding) + (Allocation.Width - layout_width) / 2,
                     bar_height + bar_label_spacing);
                RenderLabels (cr);
            }

            bar.Destroy ();

            return true;
        }
开发者ID:knocte,项目名称:hyena,代码行数:62,代码来源:SegmentedBar.cs

示例10: ClipBackground

		void ClipBackground (Cairo.Context context, Gdk.Rectangle region)
		{
			int rounding = (region.Height - 2) / 2;
			context.RoundedRectangle (region.X, region.Y + 2, region.Width, region.Height - 4, rounding);
			context.Clip ();
		}
开发者ID:jassmith,项目名称:Xamarin.Canvas,代码行数:6,代码来源:SearchBoxCanvasElement.cs

示例11: DrawErrorAnimation

		void DrawErrorAnimation (Cairo.Context context, StatusArea.RenderArg arg)
		{
			const int surfaceWidth = 2000;
			double opacity;
			int progress;

			if (arg.ErrorAnimationProgress < .5f) {
				progress = (int) (arg.ErrorAnimationProgress * arg.Allocation.Width * 2.4);
				opacity = 1.0d;
			} else {
				progress = (int) (arg.ErrorAnimationProgress * arg.Allocation.Width * 2.4);
				opacity = 1.0d - (arg.ErrorAnimationProgress - .5d) * 2;
			}

			LayoutRoundedRectangle (context, arg.Allocation);

			context.Clip ();
			context.CachedDraw (surface: ref errorSurface,
			                    position: new Gdk.Point (arg.Allocation.X - surfaceWidth + progress, arg.Allocation.Y),
			                    size: new Gdk.Size (surfaceWidth, arg.Allocation.Height),
			                    opacity: (float)opacity,
			                    draw: (c, o) => {
				// The smaller the pixel range of our gradient the less error there will be in it.
				using (var lg = new LinearGradient (surfaceWidth - 250, 0, surfaceWidth, 0)) {
					lg.AddColorStop (0.00, Styles.WithAlpha (Styles.StatusBarErrorColor, 0.15 * o));
					lg.AddColorStop (0.10, Styles.WithAlpha (Styles.StatusBarErrorColor, 0.15 * o));
					lg.AddColorStop (0.88, Styles.WithAlpha (Styles.StatusBarErrorColor, 0.30 * o));
					lg.AddColorStop (1.00, Styles.WithAlpha (Styles.StatusBarErrorColor, 0.00 * o));

					c.Pattern = lg;
					c.Paint ();
				}
			});
			context.ResetClip ();
		}
开发者ID:wickedshimmy,项目名称:monodevelop,代码行数:35,代码来源:StatusAreaTheme.cs

示例12: ClipProgressBar

		void ClipProgressBar (Cairo.Context context, Gdk.Rectangle bounding)
		{
			LayoutRoundedRectangle (context, bounding);
			context.Clip ();
		}
开发者ID:wickedshimmy,项目名称:monodevelop,代码行数:5,代码来源:StatusAreaTheme.cs

示例13: DrawImageSized

        private void DrawImageSized(PageImage pi, Gdk.Pixbuf im, Cairo.Context g, Cairo.Rectangle r)
        {
            double height, width;      // some work variables 
            StyleInfo si = pi.SI;

            // adjust drawing rectangle based on padding 
//            System.Drawing.RectangleF r2 = new System.Drawing.RectangleF(r.Left + PixelsX(si.PaddingLeft),
//                r.Top + PixelsY(si.PaddingTop),
//                r.Width - PixelsX(si.PaddingLeft + si.PaddingRight),
//                r.Height - PixelsY(si.PaddingTop + si.PaddingBottom));
            Cairo.Rectangle r2 = new Cairo.Rectangle(r.X + PixelsX(si.PaddingLeft),
                                     r.Y + PixelsY(si.PaddingTop),
                                     r.Width - PixelsX(si.PaddingLeft + si.PaddingRight),
                                     r.Height - PixelsY(si.PaddingTop + si.PaddingBottom));

            Cairo.Rectangle ir;   // int work rectangle 
            switch (pi.Sizing)
            {
                case ImageSizingEnum.AutoSize:
//                    // Note: GDI+ will stretch an image when you only provide 
//                    //  the left/top coordinates.  This seems pretty stupid since 
//                    //  it results in the image being out of focus even though 
//                    //  you don't want the image resized. 
//                    if (g.DpiX == im.HorizontalResolution &&
//                        g.DpiY == im.VerticalResolution)
                    float imwidth = PixelsX(im.Width);
                    float imheight = PixelsX(im.Height);
                    ir = new Cairo.Rectangle(Convert.ToInt32(r2.X), Convert.ToInt32(r2.Y),
                        imwidth, imheight);
//                    else
//                        ir = new Cairo.Rectangle(Convert.ToInt32(r2.X), Convert.ToInt32(r2.Y),
//                                           Convert.ToInt32(r2.Width), Convert.ToInt32(r2.Height));
                    //g.DrawImage(im, ir);
                    im = im.ScaleSimple((int)r2.Width, (int)r2.Height, Gdk.InterpType.Hyper);
                    g.DrawPixbufRect(im, ir);
                    break;
                case ImageSizingEnum.Clip:
//                    Region saveRegion = g.Clip;
                    g.Save();
//                    Region clipRegion = new Region(g.Clip.GetRegionData());
//                    clipRegion.Intersect(r2);
//                    g.Clip = clipRegion;
                    g.Rectangle(r2);
                    g.Clip();
				
//                    if (dpiX == im.HorizontalResolution &&
//                        dpiY == im.VerticalResolution) 
                    ir = new Cairo.Rectangle(Convert.ToInt32(r2.X), Convert.ToInt32(r2.Y),
                        im.Width, im.Height);
//                    else
//                        ir = new Cairo.Rectangle(Convert.ToInt32(r2.X), Convert.ToInt32(r2.Y),
//                                           Convert.ToInt32(r2.Width), Convert.ToInt32(r2.Height));
//                    g.DrawImage(im, ir);
                    g.DrawPixbufRect(im, ir);					
//                    g.Clip = saveRegion;
                    g.Restore();
                    break;
                case ImageSizingEnum.FitProportional:
                    double ratioIm = (float)im.Height / (float)im.Width;
                    double ratioR = r2.Height / r2.Width;
                    height = r2.Height;
                    width = r2.Width;
                    if (ratioIm > ratioR)
                    { 
                        // this means the rectangle width must be corrected 
                        width = height * (1 / ratioIm);
                    }
                    else if (ratioIm < ratioR)
                    {  
                        // this means the ractangle height must be corrected 
                        height = width * ratioIm;
                    }
                    r2 = new Cairo.Rectangle(r2.X, r2.Y, width, height);
                    g.DrawPixbufRect(im, r2);
                    break;
                case ImageSizingEnum.Fit:
                default:
                    g.DrawPixbufRect(im, r2);
                    break;
            }
        }
开发者ID:myersBR,项目名称:My-FyiReporting,代码行数:81,代码来源:RenderCairo.cs

示例14: OnExposed

        protected override bool OnExposed(Cairo.Context cr, Cairo.Rectangle area)
        {
            Rectangle rectT = new Rectangle(0.0, 0.0, Allocation.Width, EdgeSize);
            Rectangle rectB = new Rectangle(0.0, Allocation.Height - EdgeSize, Allocation.Width, EdgeSize);
            Rectangle rectL = new Rectangle(0.0, 0.0, EdgeSize, Allocation.Height);
            Rectangle rectR = new Rectangle(Allocation.Width - EdgeSize, 0.0, EdgeSize, Allocation.Height);

            Rectangle areaT = Widget.Intersect(area, rectT);
            Rectangle areaB = Widget.Intersect(area, rectB);
            Rectangle areaL = Widget.Intersect(area, rectL);
            Rectangle areaR = Widget.Intersect(area, rectR);

            if(areaT.Width != 0.0 && areaT.Height != 0.0)
            {
                LinearGradient grT = new LinearGradient(0.0, 0.0, 0.0, EdgeSize);
                grT.AddColorStop(0.0, new Color(1.0, 1.0, 1.0, 1.0));
                grT.AddColorStop(1.0, new Color(1.0, 1.0, 1.0, 0.0));
                cr.Save();
                cr.Pattern = grT;
                //cr.Rectangle(areaT);
                cr.NewPath();
                cr.MoveTo(0.0, 0.0);
                cr.LineTo(Allocation.Width, 0.0);
                cr.LineTo(Allocation.Width - EdgeSize, EdgeSize);
                cr.LineTo(EdgeSize, EdgeSize);
                cr.ClosePath();
                cr.Clip();
                cr.Paint();
                cr.Restore();
            }

            if(areaB.Width != 0.0 && areaB.Height != 0.0)
            {
                LinearGradient grB = new LinearGradient(0.0, Allocation.Height, 0.0, Allocation.Height - EdgeSize);
                grB.AddColorStop(0.0, new Color(0.0, 0.0, 0.0, 1.0));
                grB.AddColorStop(1.0, new Color(0.0, 0.0, 0.0, 0.0));
                cr.Save();
                cr.Pattern = grB;
                //cr.Rectangle(areaB);
                cr.MoveTo(0.0, Allocation.Height);
                cr.LineTo(Allocation.Width, Allocation.Height);
                cr.LineTo(Allocation.Width - EdgeSize, Allocation.Height - EdgeSize);
                cr.LineTo(EdgeSize, Allocation.Height - EdgeSize);
                cr.ClosePath();
                cr.Clip();
                cr.Paint();
                cr.Restore();
            }

            if(areaL.Width != 0.0 && areaL.Height != 0.0)
            {
                LinearGradient grL = new LinearGradient(0.0, 0.0, EdgeSize, 0.0);
                grL.AddColorStop(0.0, new Color(1.0, 1.0, 1.0, 1.0));
                grL.AddColorStop(1.0, new Color(1.0, 1.0, 1.0, 0.0));
                cr.Save();
                cr.Pattern = grL;
                //cr.Rectangle(areaL);
                cr.MoveTo(0.0, 0.0);
                cr.LineTo(0.0, Allocation.Height);
                cr.LineTo(EdgeSize, Allocation.Height - EdgeSize);
                cr.LineTo(EdgeSize, EdgeSize);
                cr.ClosePath();
                cr.Clip();
                cr.Paint();
                cr.Restore();
            }

            if(areaR.Width != 0.0 && areaR.Height != 0.0)
            {
                LinearGradient grR = new LinearGradient(Allocation.Width, 0.0, Allocation.Width - EdgeSize, 0.0);
                grR.AddColorStop(0.0, new Color(0.0, 0.0, 0.0, 1.0));
                grR.AddColorStop(1.0, new Color(0.0, 0.0, 0.0, 0.0));
                cr.Save();
                cr.Pattern = grR;
                //cr.Rectangle(areaR);
                cr.MoveTo(Allocation.Width, 0.0);
                cr.LineTo(Allocation.Width, Allocation.Height);
                cr.LineTo(Allocation.Width - EdgeSize, Allocation.Height - EdgeSize);
                cr.LineTo(Allocation.Width - EdgeSize, EdgeSize);
                cr.ClosePath();
                cr.Clip();
                cr.Paint();
                cr.Restore();
            }
            return true;
        }
开发者ID:sciaopin,项目名称:bang-sharp,代码行数:86,代码来源:Button.cs

示例15: RenderNodeGroup

        private void RenderNodeGroup(NodeGroup ng, Network network, Cairo.Context gc)
        {
            gc.Save();

            SizeD size = CalculateNodeGroupSize(ng, gc);
            ng.Dimension = size;
            CreateRoundedRectPath(gc, ng.Position.X, ng.Position.Y, size.Width, size.Height, 20);
            gc.Color = new Cairo.Color(0, 0, 0, 0.5);
            gc.FillPreserve();

            if (selectedGroup == ng) {
                gc.Save();
                gc.Color = orangeOverlay;
                gc.StrokePreserve();
                gc.Restore();
            }

            var titleTextSize = CalculateNodeGroupTitleTextSize(ng, gc);
            var titleSize = new SizeD(size.Width, titleTextSize.Height + (Padding * 2.0));

            gc.Clip();
            gc.Rectangle(ng.Position.X, ng.Position.Y, titleSize.Width, titleSize.Height);
            gc.Fill();
            gc.ResetClip();

            gc.Color = lightGray;

            double hostTextX = ng.Position.X + (titleSize.Width / 2.0) - (titleTextSize.Width / 2.0);
            double hostTextY = ng.Position.Y + (titleSize.Height / 2.0) - (titleTextSize.Height / 2.0);
            gc.MoveTo(hostTextX, hostTextY /* + titleTextSize.Height */);

            Pango.Layout layout = new Pango.Layout(this.PangoContext);
            layout.FontDescription = this.PangoContext.FontDescription.Copy();
            layout.FontDescription.Size = Pango.Units.FromDouble(NodegroupNameFontSize);
            layout.SetText(ng.Name);
            Pango.CairoHelper.ShowLayout(gc, layout);

            SizeD nodesSize = CalculateNodeGroupSize(ng, gc);

            if (ng.Nodes.Count == 1) {
                double positionY = ng.Position.Y + titleSize.Height + Padding;
                double positionX = ng.Position.X + (ng.Dimension.Width / 2.0) - HalfAvatarDimension;
                RenderNode(gc, (Node)ng.Nodes[0], positionX, positionY);
            } else if (ng.Nodes.Count == 2) {
                // position them side-by-side, separated by (padding) number of pixels, centered in the
                // space.
                double positionY = ng.Position.Y + titleSize.Height + Padding;
                double position1X = ng.Position.X + (ng.Dimension.Width / 2.0) - (Padding / 2.0) - AvatarDimension;
                double position2X = position1X + Padding + AvatarDimension;
                RenderNode(gc, (Node)ng.Nodes[0], position1X, positionY);
                RenderNode(gc, (Node)ng.Nodes[1], position2X, positionY);
            } else {
                double deg = 0;
                double x = 0;
                double y = 0;

                var contentY = ng.Position.Y + titleSize.Height;
                var contentHeight = size.Height - titleSize.Height;
                var middle = new System.Drawing.Point(Convert.ToInt32(ng.Position.X + size.Width - (size.Width / 2.0)),
                                                      Convert.ToInt32(contentY + contentHeight - (contentHeight / 2.0)));

                int nodeSize = Convert.ToInt32(AvatarDimension);
                for (int i = 0; i < ng.Nodes.Count; i++) {
                    x = Math.Sin(deg) * ((size.Width / 2.0) - (nodeSize)) + middle.X - (nodeSize / 2.0);
                    y = Math.Cos(deg) * ((contentHeight / 2.0) - (nodeSize)) + middle.Y - (nodeSize / 2.0);
                    RenderNode(gc, (Node)ng.Nodes[i], x, y);
                    deg += Math.PI / (ng.Nodes.Count / 2.0);
                }
            }
            gc.Restore();
        }
开发者ID:codebutler,项目名称:meshwork,代码行数:71,代码来源:ZoomableNetworkMap.cs


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