本文整理汇总了C#中Cairo.Paint方法的典型用法代码示例。如果您正苦于以下问题:C# Cairo.Paint方法的具体用法?C# Cairo.Paint怎么用?C# Cairo.Paint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo
的用法示例。
在下文中一共展示了Cairo.Paint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawPixbuf
public static void DrawPixbuf(Cairo.Context cr, Pixbuf pixbuf)
{
cr.SetSourceRGBA(0.0, 0.0, 0.0, 1.0);
cr.Operator = Cairo.Operator.DestIn;
Gdk.CairoHelper.SetSourcePixbuf (cr, pixbuf, 0, 0);
cr.Paint ();
cr.Operator = Cairo.Operator.Over;
cr.Paint ();
}
示例2: 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 ();
}
示例3: OnExposed
protected override bool OnExposed(Cairo.Context cr, Cairo.Rectangle area)
{
if(Pixbuf == null)
return false;
int w = Pixbuf.Width;
int h = Pixbuf.Height;
cr.Scale(Allocation.Width / w, Allocation.Height / h);
Gdk.CairoHelper.SetSourcePixbuf(cr, Pixbuf, 0.0, 0.0);
cr.Paint();
return true;
}
示例4:
void IIconBarMarker.DrawIcon (TextEditor ed, Cairo.Context cr, DocumentLine line, int lineNumber, double x, double y, double width, double height)
{
cr.Save ();
cr.Translate (
x + 0.5 + (width - cache.errorPixbuf.Width) / 2,
y + 0.5 + (height - cache.errorPixbuf.Height) / 2
);
Gdk.CairoHelper.SetSourcePixbuf (
cr,
errors.Any (e => e.IsError) ? cache.errorPixbuf : cache.warningPixbuf, 0, 0);
cr.Paint ();
cr.Restore ();
}
示例5: OnRender
protected override void OnRender (Cairo.Context context)
{
if (surfaceCache == null) {
// will improve with CGLayer surfaces
surfaceCache = new SurfaceWrapper (context, pbuf);
}
int x = (int)((Width - pbuf.Width) * XAlign);
int y = (int)((Height - pbuf.Height) * YAlign);
context.SetSourceSurface (surfaceCache.Surface, x, y);
double opacity = Opacity;
if (opacity == 1)
context.Paint ();
else
context.PaintWithAlpha (Opacity);
base.OnRender (context);
}
示例6: OnDrawn
protected override bool OnDrawn (Cairo.Context cr)
{
Gdk.Rectangle titleArea = TitleArea;
Gdk.CairoHelper.SetSourcePixbuf (cr, Icon, 0, 0);
cr.Paint ();
int layout_x = icon.Width + 1;
titleArea.Width -= icon.Width - 1;
int layoutWidth, layoutHeight;
Layout.GetPixelSize (out layoutWidth, out layoutHeight);
int layout_y = (titleArea.Height - layoutHeight) / 2;
StyleContext.RenderLayout (cr, layout_x, layout_y, Layout);
return base.OnDrawn (cr);
}
示例7: RenderCoverArt
protected override void RenderCoverArt (Cairo.Context cr, ImageSurface image)
{
if (image == null) {
return;
}
Gdk.Rectangle alloc = RenderAllocation;
int asr = ArtworkSizeRequest;
int reflect = (int)(image.Height * 0.2);
int surface_w = image.Width;
int surface_h = image.Height + reflect;
int x = alloc.X + alloc.Width - asr;
int y = alloc.Y;
Surface scene = null;
if (!surfaces.TryGetValue (image, out scene)) {
scene = CreateScene (cr, image, reflect);
surfaces.Add (image, scene);
}
cr.Rectangle (x, y, asr, alloc.Height);
cr.Color = BackgroundColor;
cr.Fill ();
x += (asr - surface_w) / 2;
y += surface_h > asr ? 0 : (asr - surface_h) / 2;
cr.SetSource (scene, x, y);
cr.Paint ();
}
示例8: DrawPixbuf
void DrawPixbuf(Cairo.Context ctx, Gdk.Pixbuf img, double x, double y, ImageDescription idesc)
{
ctx.Save ();
ctx.Translate (x, y);
ctx.Scale (idesc.Size.Width / (double)img.Width, idesc.Size.Height / (double)img.Height);
Gdk.CairoHelper.SetSourcePixbuf (ctx, img, 0, 0);
if (idesc.Alpha == 1)
ctx.Paint ();
else
ctx.PaintWithAlpha (idesc.Alpha);
ctx.Restore ();
}
示例9: OnDrawContent
protected override void OnDrawContent (Gdk.EventExpose evnt, Cairo.Context context)
{
context.LineWidth = 1;
var alloc = ChildAllocation;
var adjustedMarginSize = alloc.X - Allocation.X + headerMarginSize;
var r = results.Where (res => res.Item2.ItemCount > 0).ToArray ();
if (r.Any ()) {
context.SetSourceColor (lightSearchBackground);
context.Rectangle (Allocation.X, Allocation.Y, adjustedMarginSize, Allocation.Height);
context.Fill ();
context.SetSourceColor (darkSearchBackground);
context.Rectangle (Allocation.X + adjustedMarginSize, Allocation.Y, Allocation.Width - adjustedMarginSize, Allocation.Height);
context.Fill ();
context.MoveTo (0.5 + Allocation.X + adjustedMarginSize, 0);
context.LineTo (0.5 + Allocation.X + adjustedMarginSize, Allocation.Height);
context.SetSourceColor (separatorLine);
context.Stroke ();
} else {
context.SetSourceRGB (1, 1, 1);
context.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
context.Fill ();
}
double y = alloc.Y + yMargin;
int w, h;
if (topItem != null) {
headerLayout.SetText (GettextCatalog.GetString ("Top Result"));
headerLayout.GetPixelSize (out w, out h);
context.MoveTo (alloc.Left + headerMarginSize - w - xMargin, y);
context.SetSourceColor (headerColor);
Pango.CairoHelper.ShowLayout (context, headerLayout);
var category = topItem.Category;
var dataSrc = topItem.DataSource;
var i = topItem.Item;
double x = alloc.X + xMargin + headerMarginSize;
context.SetSourceRGB (0, 0, 0);
layout.SetMarkup (GetRowMarkup (dataSrc, i));
layout.GetPixelSize (out w, out h);
if (selectedItem != null && selectedItem.Category == category && selectedItem.Item == i) {
context.SetSourceColor (selectionBackgroundColor);
context.Rectangle (alloc.X + headerMarginSize, y, Allocation.Width - adjustedMarginSize, h);
context.Fill ();
context.SetSourceRGB (1, 1, 1);
}
var px = dataSrc.GetIcon (i);
if (px != null) {
Gdk.CairoHelper.SetSourcePixbuf (context, px, (int)x + marginIconSpacing, (int)y + (h - px.Height) / 2);
context.Paint ();
x += px.Width + iconTextSpacing + marginIconSpacing;
}
context.MoveTo (x, y);
context.SetSourceRGB (0, 0, 0);
Pango.CairoHelper.ShowLayout (context, layout);
y += h + itemSeparatorHeight;
}
foreach (var result in r) {
var category = result.Item1;
var dataSrc = result.Item2;
if (dataSrc.ItemCount == 0)
continue;
if (dataSrc.ItemCount == 1 && topItem != null && topItem.DataSource == dataSrc)
continue;
headerLayout.SetText (category.Name);
headerLayout.GetPixelSize (out w, out h);
if (y + h > Allocation.Height)
break;
context.MoveTo (alloc.X + headerMarginSize - w - xMargin, y);
context.SetSourceColor (headerColor);
Pango.CairoHelper.ShowLayout (context, headerLayout);
layout.Width = Pango.Units.FromPixels (Allocation.Width - adjustedMarginSize - 35);
for (int i = 0; i < maxItems && i < dataSrc.ItemCount; i++) {
if (topItem != null && topItem.Category == category && topItem.Item == i)
continue;
double x = alloc.X + xMargin + headerMarginSize;
context.SetSourceRGB (0, 0, 0);
layout.SetMarkup (GetRowMarkup (dataSrc, i));
layout.GetPixelSize (out w, out h);
if (y + h + itemSeparatorHeight > Allocation.Height)
break;
if (selectedItem != null && selectedItem.Category == category && selectedItem.Item == i) {
context.SetSourceColor (selectionBackgroundColor);
context.Rectangle (alloc.X + headerMarginSize, y, Allocation.Width - adjustedMarginSize, h);
context.Fill ();
context.SetSourceRGB (1, 1, 1);
}
var px = dataSrc.GetIcon (i);
//.........这里部分代码省略.........
示例10: DrawForeground
public override void DrawForeground (TextEditor editor, Cairo.Context cr, MarginDrawMetrics metrics)
{
cr.Save ();
cr.Translate (
metrics.X + 0.5 + (metrics.Width - 2 - cache.errorPixbuf.Width) / 2,
metrics.Y + 0.5 + (metrics.Height - cache.errorPixbuf.Height) / 2
);
Gdk.CairoHelper.SetSourcePixbuf (
cr,
errors.Any (e => e.IsError) ? cache.errorPixbuf : cache.warningPixbuf, 0, 0);
cr.Paint ();
cr.Restore ();
}
示例11: paintBackground
protected void paintBackground(Cairo.Context context, Field[,] fields)
{
context.SetSourceRGB (0.8, 0.8, 0.8);
context.Paint ();
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
paintSquare (context, i * fieldSize, j * fieldSize, fields [i, j].Full);
}
}
paintGrid (context);
context.Paint ();
}
示例12: DrawIndicator
protected void DrawIndicator (Cairo.Context cr, Severity severity)
{
cr.Save ();
var pixbuf = GetIndicatorIcon (severity);
cr.Translate (
1 + (Allocation.Width - pixbuf.Width) / 2,
1
);
CairoHelper.SetSourcePixbuf (
cr,
pixbuf,
0, 0
);
cr.Paint ();
cr.Restore ();
}
示例13: DrawVertCurrentCondition
/// <summary>
/// Paints the current condition.
/// </summary>
/// <param name="cr">
/// A <see cref="Cairo.Context"/> to do the painting.
/// </param>
void DrawVertCurrentCondition (Cairo.Context cr)
{
int cellSize = Allocation.Height / 6;
int iconSize = cellSize - 4;
int yPos = 0;
int topYPos = cellSize / 3;
int botYPos = 2 * topYPos;
// draw the temp
using (Gdk.Pixbuf pbuf = DockServices.Drawing.LoadIcon (DockServices.Paths.SystemDataFolder.GetChild ("temp.svg").Path, iconSize)) {
Gdk.CairoHelper.SetSourcePixbuf (cr, pbuf, (Allocation.Width - iconSize) / 2, yPos + (cellSize - iconSize) / 2);
cr.Paint ();
}
yPos += cellSize;
if (!WeatherController.Weather.ShowFeelsLike)
DrawVertConditionText (cr, yPos + topYPos, WeatherController.Weather.Temp + AbstractWeatherSource.TempUnit);
else
DrawVertConditionText (cr, yPos + topYPos, WeatherController.Weather.Temp + AbstractWeatherSource.TempUnit + " (" + WeatherController.Weather.FeelsLike + AbstractWeatherSource.TempUnit + ")");
// draw humidity
string humidity = String.Format (Catalog.GetString ("{0} humidity"), WeatherController.Weather.Humidity);
DrawVertConditionText (cr, yPos + botYPos, humidity);
yPos += cellSize;
// draw the wind
using (Gdk.Pixbuf pbuf = DockServices.Drawing.LoadIcon (DockServices.Paths.SystemDataFolder.GetChild ("wind.svg").Path, iconSize)) {
Gdk.CairoHelper.SetSourcePixbuf (cr, pbuf, (Allocation.Width - iconSize) / 2, yPos + (cellSize - iconSize) / 2);
cr.Paint ();
}
yPos += iconSize;
DrawVertConditionText (cr, yPos + topYPos, WeatherController.Weather.Wind + " " + AbstractWeatherSource.WindUnit);
DrawVertConditionText (cr, yPos + botYPos, WeatherController.Weather.WindDirection);
yPos += cellSize;
// draw sun
using (Gdk.Pixbuf pbuf = DockServices.Drawing.LoadIcon (DockServices.Paths.SystemDataFolder.GetChild ("sun.svg").Path, iconSize)) {
Gdk.CairoHelper.SetSourcePixbuf (cr, pbuf, (Allocation.Width - iconSize) / 2, yPos + (cellSize - iconSize) / 2);
cr.Paint ();
}
yPos += iconSize;
DrawVertConditionText (cr, yPos + topYPos, WeatherController.Weather.SunRise.ToShortTimeString ());
DrawVertConditionText (cr, yPos + botYPos, WeatherController.Weather.SunSet.ToShortTimeString ());
}
示例14: ShapeSurface
protected virtual void ShapeSurface (Cairo.Context cr, Cairo.Color color)
{
cr.Operator = Cairo.Operator.Source;
Cairo.Pattern pattern = new Cairo.SolidPattern (color, false);
cr.Source = pattern;
pattern.Destroy ();
cr.Paint ();
}
示例15: DrawIcon
public void DrawIcon (TextEditor editor, Cairo.Context cr, DocumentLine line, int lineNumber, double x, double y, double width, double height)
{
Gdk.CairoHelper.SetSourcePixbuf (
cr,
errors.Any (e => e.IsError) ? cache.errorPixbuf : cache.warningPixbuf,
(int)(x + (width - cache.errorPixbuf.Width) / 2),
(int)(y + (height - cache.errorPixbuf.Height) / 2));
cr.Paint ();
}