本文整理汇总了C#中gbrainy.Core.Main.CairoContextEx.DrawStringWithWrapping方法的典型用法代码示例。如果您正苦于以下问题:C# CairoContextEx.DrawStringWithWrapping方法的具体用法?C# CairoContextEx.DrawStringWithWrapping怎么用?C# CairoContextEx.DrawStringWithWrapping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gbrainy.Core.Main.CairoContextEx
的用法示例。
在下文中一共展示了CairoContextEx.DrawStringWithWrapping方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawObjectToMemorize
public override void DrawObjectToMemorize(CairoContextEx gr, int area_width, int area_height, bool rtl)
{
string text = string.Empty;
base.DrawObjectToMemorize (gr, area_width, area_height, rtl);
for (int i = 0; i < facts.Length; i++)
{
text += facts[i].fact;
text += "\n\n";
}
gr.DrawStringWithWrapping (0.3, DrawAreaY + 0.2, text, 0.95 - 0.3);
}
示例2: GenerateAnswers
static void GenerateAnswers(CairoContextEx cr, Game [] games, int columns, int rows)
{
int x, y, page;
string str;
int column, row;
const int space_lines = 80;
x = y = page = 0;
column = row = 0;
// Draw solution title
cr.SetPangoFontSize (20);
cr.DrawStringWithWrapping (x + margin, y + margin,
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Solutions"), width - margin);
y += space_lines;
cr.Stroke ();
cr.SetPangoFontSize (12);
cr.UseMarkup = true;
for (int i = 0; i < games.Length; i++)
{
str = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Game #{0}. {1}"), i + 1, games[i].AnswerText);
// Draw Solution
cr.DrawStringWithWrapping (x + margin, y + margin, str, width - margin);
cr.Stroke ();
y += space_lines;
// Next lateral page (right)
if (y + space_lines >= page_height * (row + 1) && x + page_width < page_width * columns) {
column++;
x = column * page_width;
y = row * page_height;
page++;
} else {
// No more space (right), new row
if (y + space_lines >= page_height * (row + 1) && x + page_width >= page_width * columns) {
row++;
column = 0;
x = column * page_width;
y = row * page_height;
page++;
}
}
if (page >= rows * columns) {
cr.ShowPage ();
page = x = y = 0;
column = row = 0;
}
}
if (y > 0)
cr.ShowPage ();
}
示例3: GenerateQuestions
static void GenerateQuestions(CairoContextEx cr, Game [] games, int columns, int rows)
{
int x, y, page;
Game puzzle;
string str;
x = y = page = 0;
for (int i = 0; i < games.Length; i++)
{
puzzle = games [i];
puzzle.Begin ();
page++;
cr.Save ();
cr.Translate (x, y);
cr.Rectangle (0, 0, width, height + question_height);
cr.Clip ();
// Translators: {0} is the game number and {1} the game question or answer
// The number is used as reference when looking for the game solution in the PDF
str = String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Game #{0}. {1}"), i + 1, puzzle.Question);
// Draw question
cr.SetPangoFontSize (12);
cr.UseMarkup = true;
cr.DrawStringWithWrapping (margin, 10, str, width - margin);
cr.Stroke ();
cr.UseMarkup = false;
// Draw from question_height up height since from 0 to question_height is the question
// Translate adds always to previous matrix's transformation
cr.Translate (0, question_height);
puzzle.DrawPreview (cr, width, height, false);
if (i == 0) {
cr.Save ();
cr.SetPangoFontSize (0.02);
cr.MoveTo (0.05, 0.95);
cr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Created by gbrainy {0}"), Defines.VERSION));
cr.Stroke ();
cr.Restore ();
}
x += width + margin;
if (x > width + margin) {
x = 0;
y += height + margin + question_height;
}
cr.Restore ();
cr.Stroke ();
if (page >= columns * rows) {
cr.ShowPage ();
page = x = y = 0;
}
}
if (y > 0)
cr.ShowPage ();
}
示例4: Draw
public void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
{
double y = 0.04, x = 0.05;
const double space_small = 0.02;
List <PlayerPersonalRecord> records;
string s, tip, played;
double width, height;
gr.Scale (area_width, area_height);
gr.Color = new Cairo.Color (0, 0, 0, 1);
gr.MoveTo (x, y);
gr.ShowPangoText (Translations.GetString ("Score"), false, -1, 0);
DrawBand (gr, 0.03, y - 0.01);
y += 0.08;
gr.MoveTo (x, y);
s = session.History.GetResult (Translations);
// Translator: This will be part of the sentence "Games won: 10 (6 played)"
played = String.Format (Translations.GetPluralString ("{0} played", "{0} played", session.History.GamesPlayed),
session.History.GamesPlayed);
if (s == string.Empty) {
gr.ShowPangoText (String.Format (Translations.GetPluralString ("Games won: {0} ({1})",
"Games won: {0} ({1})", session.History.GamesWon), session.History.GamesWon, played));
}
else {
gr.ShowPangoText (String.Format (Translations.GetPluralString ("{0}. Games won: {1} ({2})",
"{0}. Games won: {1} ({2})", session.History.GamesWon), s, session.History.GamesWon, played));
}
y += 0.06;
gr.MoveTo (x, y);
gr.ShowPangoText (String.Format (Translations.GetString ("Time played {0} (average per game {1})"), session.GameTime, session.TimePerGame));
y += 0.09;
DrawColumnBarGraphic (gr, x, y);
y += 0.36;
gr.MoveTo (x, y);
gr.SetPangoFontSize (smaller_font);
// Translators: translated string should not be longer that the English original (space restriction on the UI)
gr.ShowPangoText (Translations.GetString ("For details on how gbrainy's scoring works refer to the help."));
y += 0.07;
gr.SetPangoNormalFontSize ();
records = session.PlayerHistory.GetLastGameRecords ();
gr.MoveTo (x, y);
if (records.Count == 0) {
bool caching = cached_sessionid != session.ID;
gr.ShowPangoText (Translations.GetString ("Tips for your next games"), false, -1, 0);
DrawBand (gr, 0.03, y - 0.01);
y += 0.08;
if (caching)
tips.Clear ();
for (int i = 0; i < tips_shown; i++)
{
if (caching)
tips.Add (game_tips.Tip);
tip = "- " + tips [i];
gr.MeasureString (tip, 1.0 - x, true, out width, out height);
if (y + height > 0.98)
break;
gr.DrawStringWithWrapping (x, y, tip , 1.0 - x);
y += height + space_small;
}
if (caching)
cached_sessionid = session.ID;
}
else {
gr.ShowPangoText (Translations.GetString ("Congratulations! New personal record"), false, -1, 0);
DrawBand (gr, 0.03, y - 0.01);
y += 0.08;
for (int i = 0; i < records.Count; i++)
{
switch (records[i].GameType) {
case GameTypes.LogicPuzzle:
s = String.Format (Translations.
GetString ("By scoring {0} in logic puzzle games you have established a new personal record. Your previous record was {1}."),
records[i].NewScore,
records[i].PreviousScore);
break;
case GameTypes.Calculation:
s = String.Format (Translations.
GetString ("By scoring {0} in calculation games you have established a new personal record. Your previous record was {1}."),
records[i].NewScore,
//.........这里部分代码省略.........
示例5: DrawSolution
void DrawSolution(CairoContextEx cr, int height, double max_width)
{
if (UseSolutionArea == false || String.IsNullOrEmpty (Solution) == true)
return;
double width_str, height_str, x_text, icon_x, icon_w, icon_h, box_height_scaled;
cr.Save ();
cr.LineWidth = 0.001;
icon_w = icon_size * (cr.Matrix.Xx > cr.Matrix.Yy ? cr.Matrix.Yy / cr.Matrix.Xx : 1);
icon_h = icon_size * (cr.Matrix.Yy > cr.Matrix.Xx ? cr.Matrix.Xx / cr.Matrix.Yy : 1);
cr.MeasureString (Solution, max_width - icon_w, true, out width_str, out height_str);
// In case that the string to show is longer than the space reserved (long translations for example)
// allow the box to grow taking part of the lower part of the graphic
box_height_scaled = Math.Max (height_str, (double) solution_high / (double) height);
// Draw black box
cr.Color = new Color (0.1, 0.1, 0.1);
cr.Rectangle (text_margin,
1 - box_height_scaled - text_margin,
max_width,
box_height_scaled);
cr.Fill ();
cr.Stroke ();
// Draw text and icon
cr.Color = new Color (1, 1, 1);
if (Direction == Gtk.TextDirection.Rtl)
{
x_text = 0;
icon_x = max_width - icon_w;
}
else
{
x_text = icon_w + text_margin;
icon_x = 0;
}
cr.DrawStringWithWrapping (x_text,
(1 - box_height_scaled - text_margin) + ((box_height_scaled - height_str) / 2),
Solution, max_width - icon_w);
cr.Stroke ();
DrawSolutionIcon (cr, icon_x,
(1 - box_height_scaled - text_margin) + ((box_height_scaled - icon_h) / 2),
icon_w, icon_h);
cr.Restore ();
}
示例6: DrawQuestion
void DrawQuestion(CairoContextEx cr, int height, double max_width)
{
if (String.IsNullOrEmpty (Question) == true)
return;
cr.DrawStringWithWrapping (text_margin, text_margin, Question, max_width);
cr.Stroke ();
double w, h, question_high_scaled;
cr.MeasureString (Question, max_width, true, out w, out h);
// We use a minimum hight, but if the text is longer (L10 versions) move the line as needed
question_high_scaled = Math.Max (question_high / (double) height, h);
cr.LineWidth = 0.002;
cr.MoveTo (0.01, question_high_scaled + 0.01);
cr.LineTo (0.99, question_high_scaled + 0.01);
cr.Stroke ();
}
示例7: Draw
public void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
{
double y = 0.03;
gr.Scale (area_width, area_height);
gr.LineWidth = 0.005;
gr.Color = new Cairo.Color (0, 0, 0, 1);
gr.MoveTo (0.05, y);
// Translators: {0} is the version number of the program
gr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Welcome to gbrainy {0}"), Defines.VERSION), true, -1, 0);
gr.Stroke ();
gr.DrawStringWithWrapping (0.05, y + 0.07,
ServiceLocator.Instance.GetService <ITranslations> ().GetString ("gbrainy is a brain teaser game and trainer to have fun and to keep your brain trained. It includes:"),
1 - 0.05);
y = 0.22 + space * 3;
gr.DrawStringWithWrapping (0.05, y + 0.17, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Use the Settings to adjust the difficulty level of the game."),
1 - 0.05);
gr.Stroke ();
foreach (Toolkit.Container container in containers)
container.Draw (gr, area_width, area_height, rtl);
}