本文整理汇总了C#中Cairo.Context类的典型用法代码示例。如果您正苦于以下问题:C# Cairo.Context类的具体用法?C# Cairo.Context怎么用?C# Cairo.Context使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Cairo.Context类属于命名空间,在下文中一共展示了Cairo.Context类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawInRegionVisitor
public DrawInRegionVisitor(Gdk.Region region, Cairo.Context context, IDrawingView view)
{
this.context = context;
this.region = region;
this.view = view;
this.figures = new List<Figure> ();
}
示例2: Import
public void Import (string fileName, Gtk.Window parent)
{
Pixbuf bg;
// Handle any EXIF orientation flags
using (var fs = new FileStream (fileName, FileMode.Open, FileAccess.Read))
bg = new Pixbuf (fs);
bg = bg.ApplyEmbeddedOrientation ();
Size imagesize = new Size (bg.Width, bg.Height);
Document doc = PintaCore.Workspace.CreateAndActivateDocument (fileName, imagesize);
doc.HasFile = true;
doc.ImageSize = imagesize;
doc.Workspace.CanvasSize = imagesize;
Layer layer = doc.AddNewLayer (Path.GetFileName (fileName));
using (Cairo.Context g = new Cairo.Context (layer.Surface)) {
CairoHelper.SetSourcePixbuf (g, bg, 0, 0);
g.Paint ();
}
bg.Dispose ();
}
示例3: Activated
private void Activated(object sender, EventArgs e)
{
Gtk.Clipboard cb = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
if (cb.WaitIsImageAvailable ()) {
PintaCore.Tools.Commit ();
Gdk.Pixbuf image = cb.WaitForImage ();
Layer l = PintaCore.Layers.AddNewLayer (string.Empty);
using (Cairo.Context g = new Cairo.Context (l.Surface))
g.DrawPixbuf (image, new Cairo.Point (0, 0));
// Make new layer the current layer
PintaCore.Layers.SetCurrentLayer (l);
PintaCore.Workspace.Invalidate ();
AddLayerHistoryItem hist = new AddLayerHistoryItem (Stock.Paste, Catalog.GetString ("Paste Into New Layer"), PintaCore.Layers.IndexOf (l));
PintaCore.History.PushNewItem (hist);
} else {
ClipboardEmptyError ();
}
}
示例4: ClearSurface
void ClearSurface ()
{
using (Cairo.Context ctx = new Cairo.Context (surface)) {
ctx.SetSourceRGB (1, 1, 1);
ctx.Paint ();
}
}
示例5: HandlePintaCoreActionsFileNewActivated
private void HandlePintaCoreActionsFileNewActivated(object sender, EventArgs e)
{
NewImageDialog dialog = new NewImageDialog ();
dialog.ParentWindow = main_window.GdkWindow;
dialog.WindowPosition = Gtk.WindowPosition.CenterOnParent;
int response = dialog.Run ();
if (response == (int)Gtk.ResponseType.Ok) {
PintaCore.Workspace.ImageSize = new Cairo.PointD (dialog.NewImageWidth, dialog.NewImageHeight);
PintaCore.Workspace.CanvasSize = new Cairo.PointD (dialog.NewImageWidth, dialog.NewImageHeight);
PintaCore.Layers.Clear ();
PintaCore.History.Clear ();
PintaCore.Layers.DestroySelectionLayer ();
PintaCore.Layers.ResetSelectionPath ();
// Start with an empty white layer
Layer background = PintaCore.Layers.AddNewLayer ("Background");
using (Cairo.Context g = new Cairo.Context (background.Surface)) {
g.SetSourceRGB (255, 255, 255);
g.Paint ();
}
PintaCore.Workspace.Filename = "Untitled1";
PintaCore.Workspace.IsDirty = false;
PintaCore.Actions.View.ZoomToWindow.Activate ();
}
dialog.Destroy ();
}
示例6: RefreshBackground
public void RefreshBackground(Field[,] fields)
{
background = new Cairo.ImageSurface (Cairo.Format.ARGB32, width * fieldSize, height * fieldSize);
using (Cairo.Context context = new Cairo.Context(background)) {
paintBackground (context, fields);
}
}
示例7: GetFileBytes
public byte[] GetFileBytes(Report report)
{
var pages = report.BuildPages();
int width = (int)report.PageWidthPoints;
int height = (int)report.PageHeightPoints;
string filename = string.Format("gen-{0}.pdf", Guid.NewGuid());
try
{
using (Cairo.PdfSurface pdf = new Cairo.PdfSurface(filename, width, height))
{
using (Cairo.Context g = new Cairo.Context(pdf))
{
var render = new fyiReporting.RdlGtkViewer.RenderCairo(g);
render.RunPages(pages);
}
}
byte[] bytes = File.ReadAllBytes(filename);
return bytes;
}
finally
{
if (File.Exists(filename))
{
File.Delete(filename);
}
}
}
示例8: OnContextInitialize
public void OnContextInitialize(RenderContextInitEventArgs args)
{
DrawingArea area = args.Widget as DrawingArea;
if (area != null)
{
_context = Gdk.CairoHelper.Create(area.GdkWindow);
}
}
示例9: FillContains
internal bool FillContains(Point point)
{
using (var context = new Cairo.Context(new Cairo.ImageSurface(Cairo.Format.Argb32, 0, 0)))
{
context.AppendPath(Path);
return context.InFill(point.X, point.Y);
}
}
示例10: RenderCairo
public RenderCairo(Cairo.Context g, float scale)
{
this.g = g;
this.layout = Pango.CairoHelper.CreateLayout(g);
dpiX *= scale;
dpiY *= scale;
}
示例11: DrawBrush
void DrawBrush (double x, double y)
{
using (Cairo.Context ctx = new Cairo.Context (surface)) {
ctx.Rectangle ((int) x - 3, (int) y - 3, 6, 6);
ctx.Fill ();
}
QueueDrawArea ((int) x - 3, (int) y - 3, 6, 6);
}
示例12: WithAlpha
public static Gdk.Pixbuf WithAlpha (this Gdk.Pixbuf image, double opacity)
{
using (var surf = new Cairo.ImageSurface (Cairo.Format.Argb32, image.Width, image.Height)) {
using (var g = new Cairo.Context (surf)) {
CairoHelper.SetSourcePixbuf (g, image, 0, 0);
g.PaintWithAlpha (opacity);
}
return new Gdk.Pixbuf (surf.Data, true, 8, surf.Width, surf.Height, surf.Stride);
}
}
示例13: Dispose
public void Dispose ()
{
if (Surface != null && Surface.Handle != IntPtr.Zero) {
((IDisposable)Surface).Dispose ();
}
Surface = null;
if (Context != null) {
Hyena.Gui.CairoExtensions.DisposeContext (Context);
Context = null;
}
}
示例14: StreamGeometryContextImpl
public StreamGeometryContextImpl(Cairo.Path path = null)
{
_surf = new Cairo.ImageSurface (Cairo.Format.Argb32, 0, 0);
_context = new Cairo.Context (_surf);
this.Path = path;
if (this.Path != null)
{
_context.AppendPath(this.Path);
}
}
示例15: Create
public override object Create(object img)
{
Gdk.Pixbuf pb = (Gdk.Pixbuf)img;
var imgs = new Cairo.ImageSurface (Cairo.Format.ARGB32, pb.Width, pb.Height);
var ic = new Cairo.Context (imgs);
Gdk.CairoHelper.SetSourcePixbuf (ic, pb, 0, 0);
ic.Paint ();
imgs.Flush ();
((IDisposable)ic).Dispose ();
var p = new Cairo.SurfacePattern (imgs);
p.Extend = Cairo.Extend.Repeat;
return p;
}