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


C# Cairo.Save方法代码示例

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


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

示例1: Draw

		public void Draw (Cairo.Context g, double scale, bool fillSelection)
		{
			g.Save ();
			g.Translate (0.5, 0.5);
			g.Scale (scale, scale);
			
			g.AppendPath (SelectionPath);
			
			if (fillSelection)
			{
				g.SetSourceColor (new Cairo.Color (0.7, 0.8, 0.9, 0.2));
				g.FillRule = Cairo.FillRule.EvenOdd;
				g.FillPreserve ();
			}
			
			g.LineWidth = 1 / scale;
			
			// Draw a white line first so it shows up on dark backgrounds
			g.SetSourceColor (new Cairo.Color (1, 1, 1));
			g.StrokePreserve ();
			
			// Draw a black dashed line over the white line
			g.SetDash (new double[] { 2 / scale, 4 / scale }, 0);
			g.SetSourceColor (new Cairo.Color (0, 0, 0));
			
			g.Stroke ();
			g.Restore ();
		}
开发者ID:msiyer,项目名称:Pinta,代码行数:28,代码来源:DocumentSelection.cs

示例2: RoundedRectangle

        public static void RoundedRectangle(Cairo.Context c, RectangleD rect, double radius)
        {
            if (radius > (rect.Width /2) || radius > (rect.Height / 2)) {
                radius = Math.Min ((rect.Width /2), (rect.Height / 2));
            }

            c.Save ();

            /* Bottom Left */
            c.MoveTo(rect.X, rect.Y + radius);
            c.Arc (rect.X + radius, rect.Y + radius, radius, Math.PI, -Math.PI/2);
            c.LineTo (rect.X2 - radius, rect.Y);

            /* Bottom Right */
            c.Arc (rect.X2 - radius, rect.Y + radius, radius, -Math.PI/2, 0);
            c.LineTo (rect.X2, rect.Y2 - radius);

            /* Top Right */
            c.Arc (rect.X2 - radius, rect.Y2 - radius, radius, 0, Math.PI/2);
            c.LineTo (rect.X + radius, rect.Y2);

            /* Top Left */
            c.Arc(rect.X + radius, rect.Y2 - radius, radius, Math.PI/2, Math.PI);
            c.ClosePath ();

            c.Restore ();
        }
开发者ID:erbriones,项目名称:monodevelop-classdesigner,代码行数:27,代码来源:CairoFigures.cs

示例3: 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

示例4: Paint

        public override void Paint(Cairo.Context gr, Rectangle rect, string subPart = "")
        {
            float widthRatio = 1f;
            float heightRatio = 1f;

            if (Scaled){
                widthRatio = (float)rect.Width / Dimensions.Width;
                heightRatio = (float)rect.Height / Dimensions.Height;
            }

            if (KeepProportions) {
                if (widthRatio < heightRatio)
                    heightRatio = widthRatio;
                else
                    widthRatio = heightRatio;
            }

            gr.Save ();

            gr.Translate (rect.Left,rect.Top);
            gr.Scale (widthRatio, heightRatio);
            gr.Translate ((rect.Width/widthRatio - Dimensions.Width)/2, (rect.Height/heightRatio - Dimensions.Height)/2);

            using (ImageSurface imgSurf = new ImageSurface (image, Format.Argb32,
                Dimensions.Width, Dimensions.Height, 4 * Dimensions.Width)) {
                gr.SetSourceSurface (imgSurf, 0,0);
                gr.Paint ();
            }
            gr.Restore ();
        }
开发者ID:jpbruyere,项目名称:Crow,代码行数:30,代码来源:BmpPicture.cs

示例5: Paint

        public override void Paint(Cairo.Context gr, Rectangle rect, string subPart = "")
        {
            float widthRatio = 1f;
            float heightRatio = 1f;

            if (Scaled) {
                widthRatio = (float)rect.Width / Dimensions.Width;
                heightRatio = (float)rect.Height / Dimensions.Height;
            }
            if (KeepProportions) {
                if (widthRatio < heightRatio)
                    heightRatio = widthRatio;
                else
                    widthRatio = heightRatio;
            }

            gr.Save ();

            gr.Translate (rect.Left,rect.Top);
            gr.Scale (widthRatio, heightRatio);
            gr.Translate (((float)rect.Width/widthRatio - Dimensions.Width)/2f, ((float)rect.Height/heightRatio - Dimensions.Height)/2f);

            if (string.IsNullOrEmpty (subPart))
                hSVG.RenderCairo (gr);
            else
                hSVG.RenderCairoSub (gr, "#" + subPart);

            gr.Restore ();
        }
开发者ID:jpbruyere,项目名称:Crow,代码行数:29,代码来源:SvgPicture.cs

示例6: DrawRoundedRectangle

        public static void DrawRoundedRectangle(Cairo.Context gr, double x, double y,
		                                        double width, double height, double radius,
		                                        Cairo.Color color, Cairo.Color borderColor)
        {
            gr.Save();

            if((radius > height / 2) || (radius > width / 2))
                radius = Math.Min(height / 2, width / 2);

            gr.MoveTo(x, y + radius);
            gr.Arc(x + radius, y + radius, radius, Math.PI, -Math.PI / 2);
            gr.LineTo(x + width - radius, y);
            gr.Arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0);
            gr.LineTo(x + width, y + height - radius);
            gr.Arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2);
            gr.LineTo(x + radius, y + height);
            gr.Arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI);
            gr.ClosePath();
            gr.Restore();

            gr.LineJoin = LineJoin.Round;
            gr.Color = borderColor;
            gr.StrokePreserve();
            gr.Color = color;
            gr.Fill();
        }
开发者ID:dineshkummarc,项目名称:longomatch,代码行数:26,代码来源:Cairo.cs

示例7: Render

 public void Render(Cairo.Context c, MonoReports.Model.Controls.Control control)
 {
     Section section = control as Section;
     Rectangle borderRect;
     c.Save ();
     borderRect = new Rectangle (section.Location.X * unitMulitipier , section.Location.Y * unitMulitipier , section.Width * unitMulitipier, section.Height * unitMulitipier);
     c.FillRectangle (borderRect, section.BackgroundColor.ToCairoColor());
     c.Restore ();
 }
开发者ID:elsupergomez,项目名称:monoreports,代码行数:9,代码来源:SectionRenderer.cs

示例8: DrawCurvedRectangle

 /// <summary>
 /// The draw curved rectangle.
 /// </summary>
 protected void DrawCurvedRectangle(Cairo.Context gr, double x, double y, double width, double height)
 {
     gr.Save();
     gr.MoveTo(x, y + height / 2);
     gr.CurveTo(x, y, x, y, x + width / 2, y);
     gr.CurveTo(x + width, y, x + width, y, x + width, y + height / 2);
     gr.CurveTo(x + width, y + height, x + width, y + height, x + width / 2, y + height);
     gr.CurveTo(x, y + height, x, y + height, x, y + height / 2);
     gr.Restore();
 }
开发者ID:willy40,项目名称:testmono,代码行数:13,代码来源:CBaseControl.cs

示例9: RenderLine

 public static void RenderLine(Cairo.Context g, Cairo.Color c, double lw, double x0, double y0, double x1, double y1)
 {
     g.Save();
     g.Color = c;
     g.LineWidth = 3;
     g.MoveTo(x0, y0);
     g.LineTo(x1, y1);
     g.Stroke();
     g.Restore();
 }
开发者ID:skinitimski,项目名称:Reverence,代码行数:10,代码来源:Shapes.cs

示例10: DrawCurvedRectangle

 static void DrawCurvedRectangle(Cairo.Context gr, int x, int y, int width, int height)
 {
     gr.Save ();
     gr.MoveTo (x, y + height / 2);
     gr.CurveTo (x, y, x, y, x + width / 2, y);
     gr.CurveTo (x + width, y, x + width, y, x + width, y + height / 2);
     gr.CurveTo (x + width, y + height, x + width, y + height, x + width / 2, y + height);
     gr.CurveTo (x, y + height, x, y + height, x, y + height / 2);
     gr.Restore ();
 }
开发者ID:mooxh,项目名称:The-Birds,代码行数:10,代码来源:Main.cs

示例11: Render

        public virtual void Render(Cairo.Context cr, Layout layout, double x, double y, double w, double h)
        {
            cr.Save();
            cr.Translate (x,y);

            // make the background white
            cr.Color  = new Cairo.Color(1, 1, 1);
            cr.Rectangle(0,0,w,h);
            cr.Fill();

            // calc some values
            int lw;
            string prefix = "INV-"+InventoryAbbreviation+"-";
            string idString = Id.ToString("0000000000");

            // basic text stuff
            layout.FontDescription = FontDescription.FromString(CalcFont(Layout,layout,h));
            layout.Width = (int)(w*Scale.PangoScale);
            layout.Alignment = Alignment.Center;

            // draw the description
            int descH = 0;
            if(Layout.UseDescription){
                Layout descLayout = layout.Copy();
                descLayout.SetText (Description);
                descLayout.GetPixelSize(out lw, out descH);
                layout.Ellipsize = EllipsizeMode.Middle;
                layout.Justify = true;
                cr.Color = new Cairo.Color(0, 0, 0);
                Pango.CairoHelper.ShowLayout (cr, descLayout);
            }

            // draw the barcode	text
            int codeH = 0;
            if(Layout.UseBarcodeText){
                Layout codeLayout = layout.Copy();
                codeLayout.SetText (prefix+idString);
                codeLayout.GetPixelSize(out lw, out codeH);
                cr.MoveTo(0,h-(double)codeH);
                cr.Color = new Cairo.Color(0, 0, 0);
                Pango.CairoHelper.ShowLayout (cr, codeLayout);
            }

            // draw the barcode
            if(Layout.UseBarcode){
                double barcodeH = h-((double)codeH+(double)descH+Layout.SpacingSize*2);
                if(barcodeH>0){
                    IBarcode bc = new Code128();
                    bc.WriteString(prefix+idString);
                    bc.WriteEnd();
                    RenderBarcode(bc,cr,0,descH+Layout.SpacingSize,w,barcodeH);
                }
            }
            cr.Restore();
        }
开发者ID:konne88,项目名称:MyInventory,代码行数:55,代码来源:LabelRenderer.cs

示例12: RenderCircle

 public static void RenderCircle(Cairo.Context g, Cairo.Color c, double r, double x, double y)
 {
     g.Save();
     g.Color = c;
     g.MoveTo(x, y);
     g.Arc(x, y, r, 0, 6.28);
     g.LineWidth = 3;
     g.ClosePath();
     g.Fill();
     g.Restore();
 }
开发者ID:skinitimski,项目名称:Reverence,代码行数:11,代码来源:Shapes.cs

示例13: Draw

 public override void Draw(Cairo.Context cr)
 {
     cr.Save();
     cr.Color = new Color(1.0, 1.0, 1.0);
     cr.Rectangle(X0, Y0, X1 - X0, Y1 - Y0);
     cr.Fill();
     cr.Color = new Color(0.0, 0.0, 0.0);
     cr.Rectangle(X0, Y0, X1 - X0, Y1 - Y0);
     cr.Stroke();
     cr.Restore();
 }
开发者ID:jonasoster,项目名称:smul,代码行数:11,代码来源:Canvas.cs

示例14: Render

 public void Render(Cairo.Context c, MonoReports.Model.Controls.Control control)
 {
     SubReport subreport = control as SubReport;
     Rectangle borderRect;
     c.Save ();
     borderRect = new Rectangle (subreport.Location.X, subreport.Location.Y, subreport.Width, subreport.Height);
     c.ClipRectangle (borderRect);
     borderRect = new Rectangle (subreport.Location.X, subreport.Location.Y, subreport.Width, subreport.Height);
     c.FillRectangle (borderRect, subreport.BackgroundColor.ToCairoColor ());
     c.Restore ();
 }
开发者ID:elsupergomez,项目名称:monoreports,代码行数:11,代码来源:SubreportRenderer.cs

示例15: OnDrawn

 protected override bool OnDrawn(Cairo.Context cr)
 {
     cr.Save ();
     Gdk.RGBA color = Hyena.Gui.GtkUtilities.ColorBlend (
         StyleContext.GetBackgroundColor (StateFlags.Normal),
         StyleContext.GetColor (StateFlags.Normal));
     cr.SetSourceRGBA (color.Red, color.Green, color.Blue, color.Alpha);
     DrawCairo (cr);
     cr.Restore ();
     return false;
 }
开发者ID:knocte,项目名称:banshee,代码行数:11,代码来源:LinearProgress.cs


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