本文整理汇总了C#中Cairo.Rectangle类的典型用法代码示例。如果您正苦于以下问题:C# Cairo.Rectangle类的具体用法?C# Cairo.Rectangle怎么用?C# Cairo.Rectangle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cairo.Rectangle类属于命名空间,在下文中一共展示了Cairo.Rectangle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnExposeEvent
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
{
using (var ctx = Gdk.CairoHelper.Create (evnt.Window)) {
ctx.LineWidth = 1;
var rect = new Gdk.Rectangle (Allocation.X, Allocation.Y, Allocation.Width, Allocation.Height);
var shadowColor = CairoExtensions.ParseColor (Styles.WelcomeScreen.Pad.ShadowColor);
int inset = 2;
var ss = Styles.WelcomeScreen.Pad.ShadowSize;
var r = new Cairo.Rectangle (rect.X + ss + 0.5, rect.Y + ss + 0.5, rect.Width - ss * 2 - 1, rect.Height - ss * 2 - 1);
var sr = new Cairo.Rectangle (r.X + inset, r.Y + inset + Styles.WelcomeScreen.Pad.ShadowVerticalOffset, r.Width - inset * 2, r.Height - inset * 2);
int size = Styles.WelcomeScreen.Pad.ShadowSize;
double alpha = 0.2;
double alphaDec = 0.2 / (double)size;
for (int n=0; n<size; n++) {
sr = new Cairo.Rectangle (sr.X - 1, sr.Y - 1, sr.Width + 2, sr.Height + 2);
CairoExtensions.RoundedRectangle (ctx, sr.X, sr.Y, sr.Width, sr.Height, 4);
shadowColor.A = alpha;
ctx.SetSourceColor (shadowColor);
ctx.Stroke ();
alpha -= alphaDec;
}
CairoExtensions.RoundedRectangle (ctx, r.X, r.Y, r.Width, r.Height, 4);
ctx.SetSourceColor (CairoExtensions.ParseColor (Styles.WelcomeScreen.Pad.BackgroundColor));
ctx.FillPreserve ();
ctx.SetSourceColor (CairoExtensions.ParseColor (Styles.WelcomeScreen.Pad.BorderColor));
ctx.Stroke ();
}
PropagateExpose (Child, evnt);
return true;
}
示例2: Popup
public virtual void Popup ()
{
if (editor.GdkWindow == null){
editor.Realized += HandleRealized;
return;
}
bounds = CalculateInitialBounds ();
//GTK uses integer position coords, so round fractions down, we'll add them back later as draw offsets
int x = (int) System.Math.Floor (bounds.X);
int y = (int) System.Math.Floor (bounds.Y);
//capture any lost fractions to pass as an offset to Draw
userspaceArea = new Cairo.Rectangle (bounds.X - x, bounds.Y - y, bounds.Width, bounds.Height);
//lose half-pixels on the expansion, it's not a big deal
xExpandedOffset = (int) (System.Math.Floor (ExpandWidth / 2d));
yExpandedOffset = (int) (System.Math.Floor (ExpandHeight / 2d));
//round the width/height up to make sure we have room for restored fractions
int width = System.Math.Max (1, (int) (System.Math.Ceiling (bounds.Width) + ExpandWidth));
int height = System.Math.Max (1, (int) (System.Math.Ceiling (bounds.Height) + ExpandHeight));
this.SetSizeRequest (width, height);
editor.TextArea.AddTopLevelWidget (this, x - xExpandedOffset, y - yExpandedOffset);
stage.AddOrReset (this, Duration);
stage.Play ();
Show ();
}
示例3: Draw
internal protected override void Draw (Cairo.Context cr, Cairo.Rectangle area, LineSegment lineSegment, int line, double x, double y, double lineHeight)
{
foldSegmentSize = marginWidth * 4 / 6;
foldSegmentSize -= (foldSegmentSize) % 2;
Cairo.Rectangle drawArea = new Cairo.Rectangle (x, y, marginWidth, lineHeight);
var state = editor.Document.GetLineState (lineSegment);
bool isFoldStart = false;
bool isContaining = false;
bool isFoldEnd = false;
bool isStartSelected = false;
bool isContainingSelected = false;
bool isEndSelected = false;
if (line <= editor.Document.LineCount) {
startFoldings.Clear ();
containingFoldings.Clear ();
endFoldings.Clear ();
foreach (FoldSegment segment in editor.Document.GetFoldingContaining (lineSegment)) {
if (segment.StartLine.Offset == lineSegment.Offset) {
startFoldings.Add (segment);
} else if (segment.EndLine.Offset == lineSegment.Offset) {
endFoldings.Add (segment);
} else {
containingFoldings.Add (segment);
}
}
isFoldStart = startFoldings.Count > 0;
isContaining = containingFoldings.Count > 0;
isFoldEnd = endFoldings.Count > 0;
isStartSelected = this.lineHover != null && IsMouseHover (startFoldings);
isContainingSelected = this.lineHover != null && IsMouseHover (containingFoldings);
isEndSelected = this.lineHover != null && IsMouseHover (endFoldings);
}
var bgGC = foldBgGC;
if (editor.TextViewMargin.BackgroundRenderer != null) {
if (isContainingSelected || isStartSelected || isEndSelected) {
bgGC = foldBgGC;
} else {
bgGC = foldLineHighlightedGCBg;
}
}
cr.Rectangle (drawArea);
cr.Color = bgGC;
cr.Fill ();
if (state == TextDocument.LineState.Changed) {
cr.Color = lineStateChangedGC;
cr.Rectangle (x + 1, y, marginWidth / 3, lineHeight);
cr.Fill ();
} else if (state == TextDocument.LineState.Dirty) {
cr.Color = lineStateDirtyGC;
cr.Rectangle (x + 1, y, marginWidth / 3, lineHeight);
cr.Fill ();
}
if (line < editor.Document.LineCount) {
double foldSegmentYPos = y + System.Math.Floor (editor.LineHeight - foldSegmentSize) / 2;
double xPos = x + System.Math.Floor (marginWidth / 2) + 0.5;
if (isFoldStart) {
bool isVisible = true;
bool moreLinedOpenFold = false;
foreach (FoldSegment foldSegment in startFoldings) {
if (foldSegment.IsFolded) {
isVisible = false;
} else {
moreLinedOpenFold = foldSegment.EndLine.Offset > foldSegment.StartLine.Offset;
}
}
bool isFoldEndFromUpperFold = false;
foreach (FoldSegment foldSegment in endFoldings) {
if (foldSegment.EndLine.Offset > foldSegment.StartLine.Offset && !foldSegment.IsFolded)
isFoldEndFromUpperFold = true;
}
DrawFoldSegment (cr, x, y, isVisible, isStartSelected);
if (isContaining || isFoldEndFromUpperFold)
cr.DrawLine (isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Y, xPos, foldSegmentYPos - 2);
if (isContaining || moreLinedOpenFold)
cr.DrawLine (isEndSelected || (isStartSelected && isVisible) || isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, foldSegmentYPos + foldSegmentSize + 2, xPos, drawArea.Y + drawArea.Height);
} else {
if (isFoldEnd) {
double yMid = drawArea.Y + drawArea.Height / 2;
cr.DrawLine (isEndSelected ? foldLineHighlightedGC : foldLineGC, xPos, yMid, x + marginWidth - 2, yMid);
cr.DrawLine (isContainingSelected || isEndSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Y, xPos, yMid);
if (isContaining)
cr.DrawLine (isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, yMid + 1, xPos, drawArea.Y + drawArea.Height);
} else if (isContaining) {
cr.DrawLine (isContainingSelected ? foldLineHighlightedGC : foldLineGC, xPos, drawArea.Y, xPos, drawArea.Y + drawArea.Height);
}
//.........这里部分代码省略.........
示例4: Draw
internal protected override void Draw (Cairo.Context cr, Cairo.Rectangle area, DocumentLine lineSegment, int line, double x, double y, double lineHeight)
{
foldSegmentSize = marginWidth * 4 / 6;
foldSegmentSize -= (foldSegmentSize) % 2;
Cairo.Rectangle drawArea = new Cairo.Rectangle (x, y, marginWidth, lineHeight);
var state = editor.Document.GetLineState (lineSegment);
bool isSelected = false;
int nextDepth = 0;
if (line <= editor.Document.LineCount) {
containingFoldings.Clear ();
startFoldings.Clear ();
foreach (FoldSegment segment in editor.Document.GetFoldingContaining (lineSegment)) {
if (segment.StartLine == lineSegment)
startFoldings.Add (segment);
containingFoldings.Add (segment);
}
nextDepth = containingFoldings.Count;
if (lineSegment.NextLine != null)
nextDepth = editor.Document.GetFoldingContaining (lineSegment.NextLine).Count ();
isSelected = containingFoldings.Contains (hoverSegment);
}
var bgGC = foldLineHighlightedGC;
if (editor.TextViewMargin.BackgroundRenderer != null) {
if (isSelected) {
bgGC = foldLineHighlightedGCBg;
} else {
bgGC = foldBgGC;
}
} else {
HslColor col = foldLineHighlightedGCBg;
if (col.L < 0.5) {
col.L = System.Math.Min (1.0, col.L + containingFoldings.Count / 15.0);
} else {
col.L = System.Math.Max (0.0, col.L - containingFoldings.Count / 15.0);
}
bgGC = col;
}
cr.Rectangle (drawArea);
cr.Color = bgGC;
cr.Fill ();
if (editor.TextViewMargin.BackgroundRenderer == null) {
int delta = nextDepth - containingFoldings.Count ();
if (delta != 0) {
HslColor col = foldLineHighlightedGCBg;
if (col.L < 0.5) {
col.L = System.Math.Min (1.0, col.L + (nextDepth - delta * 1.5) / 15.0);
} else {
col.L = System.Math.Max (0.0, col.L - (nextDepth - delta * 1.5) / 15.0);
}
cr.Color = col;
cr.MoveTo (x, y + lineHeight - 0.5);
cr.LineTo (x + marginWidth, y + lineHeight - 0.5);
cr.Stroke ();
}
}
if (state == TextDocument.LineState.Changed) {
cr.Color = lineStateChangedGC;
cr.Rectangle (x + 1, y, marginWidth / 3, lineHeight);
cr.Fill ();
} else if (state == TextDocument.LineState.Dirty) {
cr.Color = lineStateDirtyGC;
cr.Rectangle (x + 1, y, marginWidth / 3, lineHeight);
cr.Fill ();
}
if (line < editor.Document.LineCount) {
bool isVisible = true;
foreach (FoldSegment foldSegment in startFoldings) {
if (foldSegment.IsFolded) {
isVisible = false;
}
}
if (!isVisible) {
DrawClosedFolding (cr, bgGC, x, y);
} else {
if (hoverSegment != null && editor.TextViewMargin.BackgroundRenderer != null) {
if (hoverSegment.StartLine == lineSegment) {
DrawUpFolding (cr, bgGC, x, y);
} else if (hoverSegment.EndLine == lineSegment) {
DrawDownFolding (cr, bgGC, x, y);
}
}
}
}
}
示例5: DrawBackground
public override void DrawBackground (MonoTextEditor editor, Cairo.Context cr, LineMetrics metrics, int startOffset, int endOffset)
{
try {
double fromX, toX;
GetLineDrawingPosition (metrics, startOffset, out fromX, out toX);
fromX = Math.Max (fromX, editor.TextViewMargin.XOffset);
toX = Math.Max (toX, editor.TextViewMargin.XOffset);
if (fromX < toX) {
var bracketMatch = new Cairo.Rectangle (fromX + 0.5, metrics.LineYRenderStartPosition + 0.5, toX - fromX - 1, editor.LineHeight - 2);
if (editor.TextViewMargin.BackgroundRenderer == null) {
cr.SetSourceColor (editor.ColorStyle.BraceMatchingRectangle.Color);
cr.Rectangle (bracketMatch);
cr.FillPreserve ();
cr.SetSourceColor (editor.ColorStyle.BraceMatchingRectangle.SecondColor);
cr.Stroke ();
}
}
} catch (Exception e) {
LoggingService.LogError ($"Error while drawing bracket matcher ({this}) startOffset={startOffset} lineCharLength={metrics.Layout.LineChars.Length}", e);
}
}
示例6: DrawAlphaBetaMarker
void DrawAlphaBetaMarker (Cairo.Context c, ref Cairo.PointD bottomRight, string text)
{
c.SelectFontFace (SplashFontFamily, Cairo.FontSlant.Normal, Cairo.FontWeight.Bold);
c.SetFontSize (SplashFontSize);
// Create a rectangle larger than the text so we can have a nice border
var extents = c.TextExtents (text);
var x = bottomRight.X - extents.Width * 1.3;
var y = bottomRight.Y - extents.Height * 1.5;
var rectangle = new Cairo.Rectangle (x, y, bottomRight.X - x, bottomRight.Y - y);
// Draw the background color the text will be overlaid on
DrawRoundedRectangle (c, rectangle);
// Calculate the offset the text will need to be at to be centralised
// in the border
x = x + extents.XBearing + (rectangle.Width - extents.Width) / 2;
y = y - extents.YBearing + (rectangle.Height - extents.Height) / 2;
c.MoveTo (x, y);
// Draw the text
c.Color = new Cairo.Color (1, 1, 1);
c.ShowText (text);
bottomRight.Y -= rectangle.Height - 2;
}
示例7: DecorateMatchingBracket
void DecorateMatchingBracket (Cairo.Context ctx, LayoutWrapper layout, int offset, int length, double xPos, double y, int selectionStart, int selectionEnd)
{
uint curIndex = 0, byteIndex = 0;
if (offset <= highlightBracketOffset && highlightBracketOffset <= offset + length) {
int index = highlightBracketOffset - offset;
Pango.Rectangle rect = layout.Layout.IndexToPos ((int)TranslateToUTF8Index (layout.LineChars, (uint)index, ref curIndex, ref byteIndex));
var bracketMatch = new Cairo.Rectangle (xPos + rect.X / Pango.Scale.PangoScale + 0.5, y + 0.5, (rect.Width / Pango.Scale.PangoScale) - 1, (rect.Height / Pango.Scale.PangoScale) - 1);
if (BackgroundRenderer == null) {
ctx.Color = this.ColorStyle.BraceMatchingRectangle.Color;
ctx.Rectangle (bracketMatch);
ctx.FillPreserve ();
ctx.Color = this.ColorStyle.BraceMatchingRectangle.SecondColor;
ctx.Stroke ();
}
}
}
示例8: ProcessPage
private void ProcessPage(Cairo.Context g, IEnumerable p)
{
foreach (PageItem pi in p)
{
if (pi is PageTextHtml)
{ // PageTextHtml is actually a composite object (just like a page)
ProcessHtml(pi as PageTextHtml, g);
continue;
}
if (pi is PageLine)
{
PageLine pl = pi as PageLine;
DrawLine(
pl.SI.BColorLeft.ToCairoColor(), pl.SI.BStyleLeft, pl.SI.BWidthLeft,
g, PixelsX(pl.X), PixelsY(pl.Y), PixelsX(pl.X2), PixelsY(pl.Y2)
);
continue;
}
// RectangleF rect = new RectangleF(PixelsX(pi.X), PixelsY(pi.Y), PixelsX(pi.W), PixelsY(pi.H));
Cairo.Rectangle rect = new Cairo.Rectangle(PixelsX(pi.X), PixelsY(pi.Y), PixelsX(pi.W), PixelsY(pi.H));
if (pi.SI.BackgroundImage != null)
{
// put out any background image
PageImage i = pi.SI.BackgroundImage;
DrawImage(i, g, rect);
continue;
}
if (pi is PageText)
{
PageText pt = pi as PageText;
DrawString(pt, g, rect);
}
if (pi is PageImage)
{
PageImage i = pi as PageImage;
DrawImage(i, g, rect);
}
if (pi is PageRectangle)
{
//DrawBackground(g, rect, pi.SI);
}
// else if (pi is PageEllipse)
// {
// PageEllipse pe = pi as PageEllipse;
// DrawEllipse(pe, g, rect);
// }
// else if (pi is PagePie)
// {
// PagePie pp = pi as PagePie;
// DrawPie(pp, g, rect);
// }
// else if (pi is PagePolygon)
// {
// PagePolygon ppo = pi as PagePolygon;
// FillPolygon(ppo, g, rect);
// }
// else if (pi is PageCurve)
// {
// PageCurve pc = pi as PageCurve;
// DrawCurve(pc.SI.BColorLeft, pc.SI.BStyleLeft, pc.SI.BWidthLeft,
// g, pc.Points, pc.Offset, pc.Tension);
// }
//
DrawBorder(pi, g, rect);
}
}
示例9: OnExposeEvent
protected override bool OnExposeEvent (Gdk.EventExpose evnt)
{
base.OnExposeEvent (evnt);
if (size == Gdk.Size.Empty)
return true;
var preview_size = Gdk.Size.Empty;
var widget_size = GdkWindow.GetBounds ();
// Figure out the dimensions of the preview to draw
if (size.Width <= max_size && size.Height <= max_size)
preview_size = size;
else if (size.Width > size.Height)
preview_size = new Gdk.Size (max_size, (int)(max_size / ((float)size.Width / (float)size.Height)));
else
preview_size = new Gdk.Size ((int)(max_size / ((float)size.Height / (float)size.Width)), max_size);
using (var g = Gdk.CairoHelper.Create (GdkWindow)) {
var r = new Cairo.Rectangle ((widget_size.Width - preview_size.Width) / 2, (widget_size.Height - preview_size.Height) / 2, preview_size.Width, preview_size.Height);
if (color.A == 0) {
// Fill with transparent checkerboard pattern
using (var grid = GdkExtensions.CreateTransparentColorSwatch (false))
using (var surf = grid.ToSurface ())
using (var pattern = surf.ToTiledPattern ())
g.FillRectangle (r, pattern);
} else {
// Fill with selected color
g.FillRectangle (r, color);
}
// Draw our canvas drop shadow
g.DrawRectangle (new Cairo.Rectangle (r.X - 1, r.Y - 1, r.Width + 2, r.Height + 2), new Cairo.Color (.5, .5, .5), 1);
g.DrawRectangle (new Cairo.Rectangle (r.X - 2, r.Y - 2, r.Width + 4, r.Height + 4), new Cairo.Color (.8, .8, .8), 1);
g.DrawRectangle (new Cairo.Rectangle (r.X - 3, r.Y - 3, r.Width + 6, r.Height + 6), new Cairo.Color (.9, .9, .9), 1);
}
return true;
}
示例10: 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;
}
}
示例11: DrawString
private void DrawString(PageText pt, Cairo.Context g, Cairo.Rectangle r)
{
StyleInfo si = pt.SI;
string s = pt.Text;
g.Save();
layout = Pango.CairoHelper.CreateLayout(g);
// Font drawFont = null;
// StringFormat drawFormat = null;
// Brush drawBrush = null;
// STYLE
// System.Drawing.FontStyle fs = 0;
// if (si.FontStyle == FontStyleEnum.Italic)
// fs |= System.Drawing.FontStyle.Italic;
//Pango fonts are scaled to 72dpi, Windows fonts uses 96dpi
float fontsize = (si.FontSize * 72 / 96);
var font = Pango.FontDescription.FromString(string.Format("{0} {1}", si.GetFontFamily().Name,
fontsize * PixelsX(1)));
if (si.FontStyle == FontStyleEnum.Italic)
font.Style = Pango.Style.Italic;
//
// switch (si.TextDecoration)
// {
// case TextDecorationEnum.Underline:
// fs |= System.Drawing.FontStyle.Underline;
// break;
// case TextDecorationEnum.LineThrough:
// fs |= System.Drawing.FontStyle.Strikeout;
// break;
// case TextDecorationEnum.Overline:
// case TextDecorationEnum.None:
// break;
// }
// WEIGHT
// switch (si.FontWeight)
// {
// case FontWeightEnum.Bold:
// case FontWeightEnum.Bolder:
// case FontWeightEnum.W500:
// case FontWeightEnum.W600:
// case FontWeightEnum.W700:
// case FontWeightEnum.W800:
// case FontWeightEnum.W900:
// fs |= System.Drawing.FontStyle.Bold;
// break;
// default:
// break;
// }
// try
// {
// drawFont = new Font(si.GetFontFamily(), si.FontSize, fs); // si.FontSize already in points
// }
// catch (ArgumentException)
// {
// drawFont = new Font("Arial", si.FontSize, fs); // if this fails we'll let the error pass thru
// }
//font.AbsoluteSize = (int)(PixelsX (si.FontSize));
switch (si.FontWeight)
{
case FontWeightEnum.Bold:
case FontWeightEnum.Bolder:
case FontWeightEnum.W500:
case FontWeightEnum.W600:
case FontWeightEnum.W700:
case FontWeightEnum.W800:
case FontWeightEnum.W900:
font.Weight = Pango.Weight.Bold;
break;
}
Pango.FontDescription oldfont = layout.FontDescription;
layout.FontDescription = font;
// ALIGNMENT
// drawFormat = new StringFormat();
// switch (si.TextAlign)
// {
// case TextAlignEnum.Right:
// drawFormat.Alignment = StringAlignment.Far;
// break;
// case TextAlignEnum.Center:
// drawFormat.Alignment = StringAlignment.Center;
// break;
// case TextAlignEnum.Left:
// default:
// drawFormat.Alignment = StringAlignment.Near;
// break;
// }
switch (si.TextAlign)
{
case TextAlignEnum.Right:
layout.Alignment = Pango.Alignment.Right;
break;
//.........这里部分代码省略.........
示例12: GetNextRect
public Cairo.Rectangle GetNextRect()
{
Cairo.Rectangle rectangle;
rect = rfx_message_get_rect(msg, irects++);
rectangle = new Cairo.Rectangle((double) rect->x, (double) rect->y,
(double) rect->width, (double) rect->height);
return rectangle;
}
示例13: OnSizeAllocated
protected override void OnSizeAllocated(Gdk.Rectangle allocation)
{
base.OnSizeAllocated (allocation);
// Insert layout code here.
this.graphRect = new Cairo.Rectangle(20, 4,
allocation.Width - 24, allocation.Height - 24);
this.scaleRectX = new Cairo.Rectangle(20, allocation.Height - 20,
allocation.Width - 24, 16);
this.scaleRectY = new Cairo.Rectangle(4, 4,
16, allocation.Height - 24);
}
示例14: Draw
// public double Width
// {
// get { return this.width; }
// set { this.width = value; }
// }
//
// public double Height
// {
// get { return this.height; }
// set { this.height = value; }
// }
//
// public double X
// {
// get { return this.x; }
// set { this.x = value; }
// }
//
// public double Y
// {
// get { return this.y; }
// set { this.y = value; }
// }
//
// public double LineWidth
// {
// get { return this.lineWidth; }
// set { this.lineWidth = value; }
// }
//
// public double[] FillColor
// {
// get { return this.fillColor; }
// set { this.fillColor = value; }
// }
//
// public double FillOpacity
// {
// get { return this.fillOpacity; }
// set { this.fillOpacity = value; }
// }
//
// public double[] StrokeColor
// {
// get { return this.strokeColor; }
// set { this.strokeColor = value; }
// }
//
// public double StrokeOpacity
// {
// get { return this.strokeOpacity; }
// set { this.strokeOpacity = value; }
// }
public void Draw(Gtk.PrintContext context)
{
Cairo.Context con = context.CairoContext;
Cairo.Rectangle cairoRectangle =
new Cairo.Rectangle(new Cairo.Point((int)this.x,
(int)this.y),
this.width,
this.height);
con.Rectangle(cairoRectangle);
con.Color = new Cairo.Color(this.fillColor[0],
this.fillColor[1],
this.fillColor[2],
this.fillOpacity);
con.FillPreserve();
con.LineWidth = this.lineWidth;
con.Color = new Cairo.Color(this.strokeColor[0],
this.strokeColor[1],
this.strokeColor[2],
this.strokeOpacity);
con.Stroke();
}
示例15: DrawFoldSegment
void DrawFoldSegment (Cairo.Context ctx, double x, double y, bool isOpen, bool isSelected)
{
var drawArea = new Cairo.Rectangle (System.Math.Floor (x + (Width - foldSegmentSize) / 2) + 0.5,
System.Math.Floor (y + (editor.LineHeight - foldSegmentSize) / 2) + 0.5, foldSegmentSize, foldSegmentSize);
ctx.Rectangle (drawArea);
ctx.SetSourceColor (isOpen ? foldBgGC : foldToggleMarkerBackground);
ctx.FillPreserve ();
ctx.SetSourceColor (isSelected ? foldLineHighlightedGC : foldLineGC);
ctx.Stroke ();
ctx.DrawLine (isSelected ? foldLineHighlightedGC : foldToggleMarkerGC,
drawArea.X + drawArea.Width * 2 / 10,
drawArea.Y + drawArea.Height / 2,
drawArea.X + drawArea.Width - drawArea.Width * 2 / 10,
drawArea.Y + drawArea.Height / 2);
if (!isOpen)
ctx.DrawLine (isSelected ? foldLineHighlightedGC : foldToggleMarkerGC,
drawArea.X + drawArea.Width / 2,
drawArea.Y + drawArea.Height * 2 / 10,
drawArea.X + drawArea.Width / 2,
drawArea.Y + drawArea.Height - drawArea.Height * 2 / 10);
}