本文整理汇总了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 ();
}
示例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 ();
}
示例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 ();
}
示例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 ();
}
示例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 ();
}
示例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();
}
示例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 ();
}
示例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();
}
示例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();
}
示例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 ();
}
示例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();
}
示例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();
}
示例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();
}
示例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 ();
}
示例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;
}