本文整理汇总了C#中Cairo.ShowText方法的典型用法代码示例。如果您正苦于以下问题:C# Cairo.ShowText方法的具体用法?C# Cairo.ShowText怎么用?C# Cairo.ShowText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo
的用法示例。
在下文中一共展示了Cairo.ShowText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShadowedText
public static void ShadowedText(Cairo.Context g, Cairo.Color c, string text, double x, double y)
{
g.Save();
g.MoveTo(x + SHADOW_SPACING, y + SHADOW_SPACING);
g.Color = Colors.BLACK;
g.ShowText(text);
g.MoveTo(x, y);
g.Color = c;
g.ShowText(text);
g.Restore();
}
示例2: Draw
public static void Draw(Cairo.Context ctx, object backend, double x, double y)
{
var la = (LayoutBackend) backend;
var text = la.Text;
var h = ctx.FontExtents.Ascent;
y += h;
ctx.MoveTo (x, y);
if (la.Font != null) {
ctx.SelectFont (la.Font);
ctx.SetFontSize (la.Font.Size);
}
if (la.Width == -1) {
ctx.ShowText (text);
return;
}
if (!la.Measured)
Measure (backend);
// Render word by word
int lastStart = 0;
for (int i=0; i < la.LineBreaks.Count; i++) {
if (la.Heigth != -1 && h > la.Heigth)
break;
var n = la.LineBreaks [i];
string s = text.Substring (lastStart, n - lastStart).TrimEnd('\n','\r');
ctx.ShowText (s);
var lh = la.LineHeights [i];
h += lh;
y += lh;
ctx.MoveTo (x, y);
lastStart = n;
}
}
示例3: draw
static void draw (Cairo.Context gr, int width, int height)
{
gr.Scale (width, height);
gr.LineWidth = 0.04;
gr.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Bold);
gr.SetFontSize (0.35);
gr.MoveTo ( new PointD(0.04, 0.53) );
gr.ShowText ("Hello");
gr.MoveTo ( new PointD(0.27, 0.65) );
gr.TextPath ("void");
gr.ColorRgb = new Color (0.5, 0.5, 1, 0);
gr.FillPreserve ();
gr.ColorRgb = new Color (0, 0, 0, 0);
gr.LineWidth = 0.01;
gr.Stroke ();
gr.Color = new Color (1,0.2,0.2, 0.6);
gr.Arc (0.04, 0.53, 0.02, 0, 2*M_PI);
gr.Arc (0.27, 0.65, 0.02, 0, 2*M_PI);
gr.Fill ();
}
示例4: DrawVersionNumber
void DrawVersionNumber (Cairo.Context c, ref Cairo.PointD bottomRight, string text)
{
c.SelectFontFace (SplashFontFamily, Cairo.FontSlant.Normal, Cairo.FontWeight.Normal);
c.SetFontSize (SplashFontSize);
var extents = c.TextExtents (text);
c.MoveTo (bottomRight.X - extents.Width - 1, bottomRight.Y - extents.Height);
c.Color = new Cairo.Color (1, 1, 1);
c.ShowText (text);
}
示例5: 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;
}
示例6: draw_grid
void draw_grid(Cairo.Context gr, int w, int h)
{
double y_interval, y_spacing;
double pixels = 80;
double num_ticks = h/pixels;
double interval = max_y/num_ticks;
double min_size = 1;
while (true) {
double new_size = min_size * 10;
if (new_size < interval) {
min_size = new_size;
continue;
}
break;
}
y_spacing = pixels * min_size/interval;
y_interval = min_size;
gr.Color = new Color (0.4, 0.4, 0.4, 1);
gr.LineWidth = .5;
double y_label = 0;
for (double i = h; i >= 0; i -= y_spacing) {
gr.MoveTo (0, i);
gr.LineTo (w, i);
gr.Stroke ();
gr.LineTo (5, i);
gr.ShowText (GetLabel (y_label));
y_label += y_interval;
}
}
示例7: DrawIcon
public void DrawIcon(TextEditor editor, Cairo.Context cr, DocumentLine lineSegment, int lineNumber, double x, double y, double width, double height)
{
if (BookmarkService.Instance.CheckLineForBookmark (editor.FileName, lineSegment.LineNumber)) {
Cairo.Color color1 = editor.ColorStyle.Bookmarks.Color;
Cairo.Color color2 = editor.ColorStyle.Bookmarks.SecondColor;
if (Bookmark.BookmarkType == BookmarkType.Local)
DrawRoundRectangle (cr, x + 1, y + 1, 8, width - 4, height - 4);
else
DrawCircle (cr, x + (width / 2), y + (height / 2), 6);
using (var pat = new Cairo.LinearGradient (x + width / 4, y, x + width / 2, y + height - 4)) {
pat.AddColorStop (0, color1);
pat.AddColorStop (1, color2);
cr.Pattern = pat;
cr.FillPreserve ();
}
using (var pat = new Cairo.LinearGradient (x, y + height, x + width, y)) {
pat.AddColorStop (0, color2);
//pat.AddColorStop (1, color1);
cr.Pattern = pat;
cr.Stroke ();
}
cr.Color = new Cairo.Color (0, 0, 0);
cr.SelectFontFace (DesktopService.DefaultMonospaceFont, Cairo.FontSlant.Normal, Cairo.FontWeight.Bold);
cr.SetFontSize (12);
var te = cr.TextExtents (Bookmark.Number.ToString ());
cr.MoveTo (x + 5, y + 1 + te.Height);
cr.ShowText (Bookmark.Number.ToString ());
}
}
示例8: DrawLabelFlat
/// <summary>
/// Draws the label flat.
/// </summary>
/// <param name="context">Context.</param>
/// <param name="bordertype">Bordertype.</param>
/// <param name="labelposition">Labelposition.</param>
/// <param name="pin">Pin.</param>
/// <param name="xpos">Xpos.</param>
/// <param name="ypos">Ypos.</param>
private static void DrawLabelFlat(Cairo.Context context, BorderType bordertype, LabelPosition labelposition, IPin pin, int xpos = 0, int ypos = 0)
{
string displaytext = "";
var color = GdkToCairo (pin.PlotColor);
displaytext = pin.DisplayNumberShort + " " + pin.Name;
if (displaytext.Length > 12) {
displaytext = displaytext.Substring (0, 12);
displaytext += "...";
}
if (bordertype == BorderType.Line) {
DrawRoundedRectangle (context, xpos, ypos, LabelWidth - LabelBorderWeight, FlatHeight, 5);
context.SetSourceRGBA (color.R, color.G, color.B, color.A);
context.LineWidth = LabelBorderWeight;
context.Stroke ();
}
//PinToLabelLine
int xposlabelline = 0;
int yposlabelline = 0;
switch (labelposition) {
case LabelPosition.Left:
xposlabelline = xpos + LabelWidth;
yposlabelline = ypos + (FlatHeight / 2);
break;
case LabelPosition.Right:
xposlabelline = xpos;
yposlabelline = ypos + (FlatHeight / 2);
break;
case LabelPosition.Bottom:
xpos = xpos + LabelWidth / 2;
yposlabelline = ypos;
break;
default:
break;
}
if (PinLocations.ContainsKey ((int)pin.RealNumber)) {
DrawLines (
context,
xposlabelline,
yposlabelline,
(int)(MCUImageXZero + PinLocations [(int)pin.RealNumber].x),
(int)(MCUImageYZero + PinLocations [(int)pin.RealNumber].y),
color
);
}
//Number
context.SetSourceRGB (0, 0, 0);
context.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Bold);
context.SetFontSize (LabelFontSize);
context.MoveTo (xpos + 5, ypos + LabelFontSize + LabelBorderWeight);
context.ShowText (displaytext);
}
示例9: DrawCoords
private void DrawCoords (Cairo.Context cairo)
{
cairo.Color = colors.CoordColor;
cairo.Rectangle (start_x - space - size / 5,
start_y - space - size / 5,
(size + space) * 8 +
2 * size / 5,
(size + space) * 8 + 2 * size / 5);
cairo.Stroke ();
string letters = "abcdefgh";
//cairo.Color = new Cairo.Color (0, 0, 0);
cairo.Color = colors.CoordColor;
double scale = Pango.Scale.PangoScale;
for (int i = 0; i < 8; i++)
{
layout.SetText ((letters[i]).ToString ());
Pango.Rectangle logical, ink;
layout.GetExtents (out ink, out logical);
int width =
(int) Math.Round (logical.Width /
scale);
int height =
(int) Math.Round (logical.Height /
scale);
cairo.MoveTo (start_x + size / 2 +
(size + space) * i -
(width / 4),
start_y - size / 5 -
2 * space + height - 4);
cairo.ShowText (letters[i].ToString ());
cairo.MoveTo (start_x + size / 2 +
(size + space) * i -
(width / 4),
start_y + (size + space) * 8 -
2 * space + height - 4);
cairo.ShowText (letters[i].ToString ());
}
string numbers = "12345678";
if (!side)
numbers = "87654321";
for (int i = 0; i < 8; i++)
{
layout.SetText ((numbers[i]).ToString ());
Pango.Rectangle logical, ink;
layout.GetExtents (out ink, out logical);
//int width = (int) Math.Round(logical.Width / scale);
int height =
(int) Math.Round (logical.Height /
scale);
cairo.MoveTo (start_x - size / 5,
start_y + size / 2 + (size +
space) *
i + (height / 4));
cairo.ShowText (numbers[i].ToString ());
cairo.MoveTo (start_x + (size + space) * 8,
start_y + size / 2 + (size +
space) *
i + (height / 4));
cairo.ShowText (numbers[i].ToString ());
}
}
示例10: Draw
public override void Draw(Cairo.Context cr)
{
cr.Save();
cr.SetFontSize(8);
if(ArrowKind == ArrowKind.Return)
{
double[] returnDash = new double[]{ 3.0, 3.0 };
cr.SetDash(returnDash, 0);
}
cr.MoveTo(X0, Y0);
cr.LineTo(X1, Y0);
cr.LineTo(X1, Y1);
cr.LineTo(X0b, Y1);
cr.Stroke();
cr.MoveTo(X0b + 7, Y1 - 3);
cr.LineTo(X0b, Y1);
cr.LineTo(X0b + 7, Y1 + 3);
if(ArrowKind == ArrowKind.Async)
{
cr.Stroke();
}
else
{
cr.MoveTo(X0b + 7, Y1 - 3);
cr.Fill();
}
if((Text != null) && !Text.Equals(""))
{
cr.MoveTo(XText + 5, Y0 - 5);
cr.ShowText(Text);
}
cr.Restore();
}
示例11: DrawLabel
/// <summary>
/// Draws the label.
/// </summary>
/// <param name="context">Context.</param>
/// <param name="bordertype">Bordertype.</param>
/// <param name="pin">Pin.</param>
/// <param name="xpos">Xpos.</param>
/// <param name="ypos">Ypos.</param>
private static void DrawLabel(Cairo.Context context, BorderType bordertype, IPin pin, int xpos = 0, int ypos = 0)
{
const int widht = 100;
const int height = BoldHeight;
const int fontsize = 12;
//Rect
context.Rectangle (xpos, ypos, widht, 26);
context.SetSourceRGBA (BackgroundColor.R, BackgroundColor.G, BackgroundColor.B, BackgroundColor.A);
context.Fill ();
string displaytext = pin.Name;
if (displaytext.Length > 12) {
displaytext = displaytext.Substring (0, 12);
displaytext += "...";
}
if (bordertype == BorderType.Line) {
//Border
context.SetSourceRGB (0, 0, 0);
context.LineWidth = .5;
context.Rectangle (xpos, ypos, widht, height);
context.Stroke ();
}
//ColorFlag
context.Rectangle (xpos, ypos, 5, height);
context.SetSourceRGB (pin.PlotColor.Red, pin.PlotColor.Green, pin.PlotColor.Blue);
context.Fill ();
//Number
context.SetSourceRGB (0, 0, 0);
context.SelectFontFace ("Sans", FontSlant.Normal, FontWeight.Bold);
context.SetFontSize (fontsize);
context.MoveTo (xpos + 5, ypos + fontsize);
context.ShowText (pin.DisplayNumberShort);
context.MoveTo (xpos + 5, ypos + fontsize * 2);
context.ShowText (displaytext);
}
示例12: DrawContents
protected override void DrawContents(Gdk.Drawable d, Cairo.Context g, int width, int height, bool screenChanged)
{
g.SelectFontFace(Text.MONOSPACE_FONT, FontSlant.Normal, FontWeight.Bold);
g.SetFontSize(24);
#region Slots
MateriaSlots.Render(g, MenuState.Party.Selected.Weapon, X + x_slots, Y + y_slots_weapon);
MateriaSlots.Render(g, MenuState.Party.Selected.Armor, X + x_slots, Y + y_slots_armor);
#endregion
#region Character Status
Images.RenderProfile(d, X + xpic, Y + ypic, MenuState.Party.Selected);
Graphics.Stats.RenderCharacterStatus(d, g, MenuState.Party.Selected, X + x_status, Y + y_status, false);
#endregion Status
#region Equipment
g.Color = Colors.TEXT_TEAL;
g.MoveTo(X + x_labels, Y + y_weapon);
g.ShowText("Wpn.");
g.MoveTo(X + x_labels, Y + y_armor);
g.ShowText("Arm.");
g.Color = Colors.WHITE;
Text.ShadowedText(g, "Check", X + x_labels, Y + y_check);
Text.ShadowedText(g, "Arr.", X + x_labels, Y + y_arrange);
string weapon, armor;
weapon = MenuState.Party.Selected.Weapon.Name;
armor = MenuState.Party.Selected.Armor.Name;
Text.ShadowedText(g, MenuState.Party.Selected.Weapon.Name, X + x_names, Y + y_weapon);
Text.ShadowedText(g, MenuState.Party.Selected.Armor.Name, X + x_names, Y + y_armor);
#endregion
if (IsControl)
{
Shapes.RenderCursor(g, X + cx, Y + cy);
}
}
示例13: printText
private static void printText(int x, int y, int height, int textHeight, string text, Cairo.Context g)
{
g.MoveTo(x, ((y+y+height)/2) + textHeight/2.0);
g.ShowText(text);
}
示例14: ShadowedText
public static void ShadowedText(Cairo.Context g, Cairo.Color c, string text, double x, double y)
{
g.Save();
g.MoveTo(x + Graphics.SHADOW_SPACING, y + Graphics.SHADOW_SPACING);
g.Color = new Cairo.Color(0, 0, 0);
g.ShowText(text);
g.MoveTo(x, y);
g.Color = c;
g.ShowText(text);
g.Restore();
}
示例15: DrawContents
//.........这里部分代码省略.........
Text.ShadowedText(g, "Exp:", X + x8, Y + ya);
Text.ShadowedText(g, "Next lvl:", X + x8, Y + yb);
Text.ShadowedText(g, "Limit lvl:", X + x8, Y + yc);
te = g.TextExtents(exp);
Text.ShadowedText(g, exp, X + x11 - te.Width, Y + ya);
te = g.TextExtents(next);
Text.ShadowedText(g, next, X + x11 - te.Width, Y + yb);
te = g.TextExtents(llvl);
Text.ShadowedText(g, llvl, X + x11 - te.Width, Y + yc);
#endregion Top
#region Left
string str, vit, dex, mag, spi, lck;
string atk, atkp, def, defp, mat, mdf, mdfp;
str = Party.Selected.Strength.ToString();
vit = Party.Selected.Vitality.ToString();
dex = Party.Selected.Dexterity.ToString();
mag = Party.Selected.Magic.ToString();
spi = Party.Selected.Spirit.ToString();
lck = Party.Selected.Luck.ToString();
atk = Ally.Attack(Party.Selected).ToString();
atkp = Ally.AttackPercent(Party.Selected).ToString();
def = Ally.Defense(Party.Selected).ToString();
defp = Ally.DefensePercent(Party.Selected).ToString();
mat = Ally.MagicAttack(Party.Selected).ToString();
mdf = Ally.MagicDefense(Party.Selected).ToString();
mdfp = Ally.MagicDefensePercent(Party.Selected).ToString();
Cairo.Color greenish = Colors.TEXT_TEAL;
Text.ShadowedText(g, greenish, "Strength", X + x0, Y + yq + (line * 0));
Text.ShadowedText(g, greenish, "Vitality", X + x0, Y + yq + (line * 1));
Text.ShadowedText(g, greenish, "Dexterity", X + x0, Y + yq + (line * 2));
Text.ShadowedText(g, greenish, "Magic", X + x0, Y + yq + (line * 3));
Text.ShadowedText(g, greenish, "Spirit", X + x0, Y + yq + (line * 4));
Text.ShadowedText(g, greenish, "Luck", X + x0, Y + yq + (line * 5));
Text.ShadowedText(g, greenish, "Attack", X + x0, Y + yr + (line * 0));
Text.ShadowedText(g, greenish, "Attack %", X + x0, Y + yr + (line * 1));
Text.ShadowedText(g, greenish, "Defense", X + x0, Y + yr + (line * 2));
Text.ShadowedText(g, greenish, "Defense %", X + x0, Y + yr + (line * 3));
Text.ShadowedText(g, greenish, "Magic", X + x0, Y + yr + (line * 4));
Text.ShadowedText(g, greenish, "Magic def", X + x0, Y + yr + (line * 5));
Text.ShadowedText(g, greenish, "Magic def %", X + x0, Y + yr + (line * 6));
te = g.TextExtents(str);
Text.ShadowedText(g, str, X + x1 - te.Width, Y + yq + (line * 0));
te = g.TextExtents(vit);
Text.ShadowedText(g, vit, X + x1 - te.Width, Y + yq + (line * 1));
te = g.TextExtents(dex);
Text.ShadowedText(g, dex, X + x1 - te.Width, Y + yq + (line * 2));
te = g.TextExtents(mag);
Text.ShadowedText(g, mag, X + x1 - te.Width, Y + yq + (line * 3));
te = g.TextExtents(spi);
Text.ShadowedText(g, spi, X + x1 - te.Width, Y + yq + (line * 4));
te = g.TextExtents(lck);
Text.ShadowedText(g, lck, X + x1 - te.Width, Y + yq + (line * 5));
te = g.TextExtents(atk);
Text.ShadowedText(g, atk, X + x1 - te.Width, Y + yr + (line * 0));
te = g.TextExtents(atkp);
Text.ShadowedText(g, atkp, X + x1 - te.Width, Y + yr + (line * 1));
te = g.TextExtents(def);
Text.ShadowedText(g, def, X + x1 - te.Width, Y + yr + (line * 2));
te = g.TextExtents(defp);
Text.ShadowedText(g, defp, X + x1 - te.Width, Y + yr + (line * 3));
te = g.TextExtents(mat);
Text.ShadowedText(g, mat, X + x1 - te.Width, Y + yr + (line * 4));
te = g.TextExtents(mdf);
Text.ShadowedText(g, mdf, X + x1 - te.Width, Y + yr + (line * 5));
te = g.TextExtents(mdfp);
Text.ShadowedText(g, mdfp, X + x1 - te.Width, Y + yr + (line * 6));
#endregion Left
#region Right
MateriaSlots.Render(g, Party.Selected.Weapon, X + x9, Y + yi);
MateriaSlots.Render(g, Party.Selected.Armor, X + x9, Y + yk);
g.Color = Colors.TEXT_TEAL;
g.MoveTo(X + x7, Y + yh);
g.ShowText("Wpn.");
g.MoveTo(X + x7, Y + yj);
g.ShowText("Arm.");
g.MoveTo(X + x7, Y + yl);
g.ShowText("Acc.");
g.Color = Colors.WHITE;
Text.ShadowedText(g, Party.Selected.Weapon.Name, X + x8, Y + yh);
Text.ShadowedText(g, Party.Selected.Armor.Name, X + x8, Y + yj);
Text.ShadowedText(g, Party.Selected.Accessory.Name, X + x8, Y + yl);
#endregion Right
}