本文整理汇总了C#中gbrainy.Core.Main.CairoContextEx.Restore方法的典型用法代码示例。如果您正苦于以下问题:C# CairoContextEx.Restore方法的具体用法?C# CairoContextEx.Restore怎么用?C# CairoContextEx.Restore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gbrainy.Core.Main.CairoContextEx
的用法示例。
在下文中一共展示了CairoContextEx.Restore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
{
double x = X, y = Y;
this.rtl = rtl;
#if DESIGN_MODE
gr.Save ();
gr.Color = new Cairo.Color (0, 0, 1);
gr.Rectangle (X, Y, Width, Height);
gr.Stroke ();
gr.Restore ();
ValidateDimensions ();
#endif
//
// Coordinates are stored right to left
//
if (rtl == false) {
for (int i = 0; i < children.Count; i++)
{
gr.Save ();
gr.Translate (x, y);
children[i].Draw (gr, area_width, area_height, rtl);
gr.Restore ();
x += children[i].Width;
}
} else {
x += Width;
for (int i = 0; i < children.Count; i++)
{
x -= children[i].Width;
gr.Save ();
gr.Translate (x, y);
children[i].Draw (gr, area_width, area_height, rtl);
gr.Restore ();
}
}
}
示例2: Draw
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
{
double x = X, y = Y;
this.rtl = rtl;
#if DESIGN_MODE
gr.Save ();
gr.Color = new Cairo.Color (0, 0, 1);
gr.Rectangle (X, Y, Width, Height);
gr.Stroke ();
gr.Restore ();
double width = 0;
foreach (Widget child in children)
{
width += child.Width;
if (Height < child.Height)
throw new InvalidOperationException (String.Format ("Container height too small {0} < {1}", Height, child.Height));
}
if (Width < width)
throw new InvalidOperationException (String.Format ("Container witdh too small {0} < {1}", Width, width));
#endif
//
// Coordinates are stored right to left
//
if (rtl == false) {
for (int i = 0; i < children.Count; i++)
{
gr.Save ();
gr.Translate (x, y);
children[i].Draw (gr, area_width, area_height, rtl);
gr.Restore ();
x += children[i].Width;
}
} else {
x += Width;
for (int i = 0; i < children.Count; i++)
{
x -= children[i].Width;
gr.Save ();
gr.Translate (x, y);
children[i].Draw (gr, area_width, area_height, rtl);
gr.Restore ();
}
}
}
示例3: DrawBand
static void DrawBand(CairoContextEx gr, double x, double y)
{
gr.Save ();
gr.Rectangle (x, y, 1 - 0.06, 0.06);
gr.Color = new Cairo.Color (0, 0, 0.2, 0.2);
gr.Fill ();
gr.Restore ();
}
示例4: DrawTimeBar
public void DrawTimeBar(CairoContextEx gr, double x, double y, double percentage)
{
double width = 0.04, height = 0.6;
const double w = 0.003, h = 0.003;
gr.DrawTextCentered (x + (width / 2), y + height + 0.05, Translations.GetString ("Time left"));
gr.Stroke ();
gr.Save ();
gr.Color = new Color (0, 0, 0);
gr.MoveTo (x, y);
gr.LineTo (x, y + height);
gr.LineTo (x + width, y + height);
gr.LineTo (x + width, y);
gr.LineTo (x, y);
gr.Stroke ();
x+= w;
y+= h;
width -= w * 2;
height -= h * 2;
y += height * (100 - percentage) / 100;
height *= percentage / 100;
if (gradient == null) {
gradient = new LinearGradient (x, y, x + width, y + height);
gradient.AddColorStop (0, new Color (1, 0, 0, 1));
gradient.AddColorStop (1, new Color (0.2, 0, 0, 1));
}
gr.Source = gradient;
gr.MoveTo (x, y);
gr.LineTo (x, y + height);
gr.LineTo (x + width, y + height);
gr.LineTo (x + width, y);
gr.LineTo (x, y);
gr.FillPreserve ();
gr.Stroke ();
gr.Restore ();
}
示例5: DrawAnswer
void DrawAnswer(CairoContextEx gr, double x, double y)
{
ColorPalette palette = new ColorPalette (Translations);
gr.Save ();
// A full sized square of paper
gr.Color = palette.Cairo (ColorPalette.Id.Yellow);
gr.Rectangle (x, y, width, height);
gr.Fill ();
gr.Stroke ();
// 3/4 of the whole size square of paper in the bottom right corner
gr.Color = palette.Cairo (ColorPalette.Id.Blue);
double w = 3d/4d * width;
double h = 3d/4d * height;
gr.Rectangle (x + (width - w), y + (height - h), w, h);
gr.Fill ();
gr.Stroke ();
// 3/4 square of paper in the top left corner
gr.Color = palette.Cairo (ColorPalette.Id.Green);
gr.Rectangle (x, y, 3d/4d * width, 3d/4d * height);
gr.Fill ();
gr.Stroke ();
// 1/4 square of paper in the top left corner
gr.Color = palette.Cairo (ColorPalette.Id.Red);
gr.Rectangle (x, y, 1d/4d * width, 1d/4d * height);
gr.Fill ();
gr.Stroke ();
gr.Restore ();
}
示例6: Draw
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
{
int element;
double x = DrawAreaX;
double y = 0.05, pos_y;
base.Draw (gr, area_width, area_height, rtl);
for (int i = 0; i < (Answer.Draw ? question_columns : question_columns - 1); i++)
{
element = question_indices [i];
pos_y = y;
for (int n = 0; n < figures_column; n++)
{
DrawFigure (gr, x, pos_y, figures [(n * question_columns) + element]);
pos_y+= figure_size + space_height;
}
x+= figure_size + space_width;
}
if (Answer.Draw == false) {
gr.Save ();
gr.SetPangoFontSize (figure_size);
for (int n = 0; n < figures_column; n++) {
gr.MoveTo (x, y - 0.02);
gr.ShowPangoText ("?");
gr.Stroke ();
y+= figure_size + space_height;
}
gr.SetPangoNormalFontSize ();
gr.Restore ();
}
gr.MoveTo (0.08, 0.45);
gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
gr.Stroke ();
}
示例7: DrawGrid
void DrawGrid(CairoContextEx cr, double x, double y)
{
// Draw Axis
cr.MoveTo (x, y);
cr.LineTo (x, y + grid_height);
cr.LineTo (x + grid_width, y + grid_height);
cr.Stroke ();
cr.Save ();
cr.Color = axis_color;
cr.LineWidth = 0.001;
for (double line_y = y; line_y < grid_height + y; line_y += grid_height / 10) {
cr.MoveTo (x, line_y);
cr.LineTo (x + grid_width, line_y);
cr.Stroke ();
}
cr.Restore ();
// Draw score scale
int pos = 100;
for (double line_y = y; line_y < grid_height + y; line_y += grid_height / 10) {
cr.DrawTextAlignedRight (x- 0.01, line_y, String.Format ("{0}", pos));
pos -= 10;
}
}
示例8: DrawAxisDescription
void DrawAxisDescription(CairoContextEx cr, double x, double y, string description)
{
cr.Save ();
cr.Color = desc_color;
cr.MoveTo (x, y);
cr.ShowPangoText (description);
cr.Stroke ();
cr.Restore ();
}
示例9: DrawSection
private void DrawSection(CairoContextEx gr, double x, double y)
{
double w = width / 2, h = height / 2;
double pos_x = x, pos_y = y;
for (int i = 0; i < 5; i++) {
gr.MoveTo (pos_x, pos_y + h / 5);
gr.LineTo (pos_x + w, pos_y + h / 5);
gr.Stroke ();
pos_y += h / 5;
}
gr.MoveTo (x + w / 2, y);
gr.LineTo (x + w / 2, y + h);
gr.Stroke ();
gr.Save ();
gr.Color = new Cairo.Color (0.90, 0.90, 0.90);
for (int i = 0; i < partial_zones; i++) {
Fill (gr, x + line_width, line_width + y,
(w / 2) - (line_width * 2) , (h / 5) - (line_width * 2));
Fill (gr, x + (w / 2) + line_width * 2, line_width + y,
(w / 2) - (line_width * 4) , (h / 5) - (line_width * 2));
y += h / 5;
}
gr.Restore ();
}
示例10: 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 ();
}
示例11: OnExposeEvent
protected override bool OnExposeEvent(Gdk.EventExpose args)
{
if (!IsRealized)
return false;
int w, h, total_w, total_h;
Cairo.Context cc = Gdk.CairoHelper.Create (args.Window);
CairoContextEx cr = new CairoContextEx (cc.Handle, this);
args.Window.GetSize (out total_w, out total_h);
h = total_h - question_high;
if (UseSolutionArea)
h -= solution_high;
w = total_w;
// We want a square drawing area for the puzzles then the figures are shown as designed.
// For example, squares are squares. This also makes sure that proportions are kept when resizing
DrawingSquare = Math.Min (w, h);
if (DrawingSquare < w)
OffsetX = (w - DrawingSquare) / 2d;
else
OffsetX = 0;
if (DrawingSquare < h)
OffsetY = (h - DrawingSquare) / 2d;
else
OffsetY = 0;
OffsetY += question_high;
// Draw a background taking all the window area
cr.Save ();
cr.Scale (total_w, total_h);
cr.DrawBackground ();
if (Paused == false) {
DrawQuestionAndAnswer (cr, total_h);
} else {
cr.SetPangoFontSize (0.08);
cr.DrawTextCentered (0.5, 0.5, Catalog.GetString ("Paused"));
cr.Stroke ();
}
cr.Restore ();
if (Paused == false) {
// Draw the game area
cr.Translate (OffsetX, OffsetY);
cr.SetPangoNormalFontSize ();
cr.Color = new Color (1, 1, 1, 0.5);
Drawable.Draw (cr, DrawingSquare, DrawingSquare, Direction == Gtk.TextDirection.Rtl);
cr.Stroke ();
}
((IDisposable)cc).Dispose();
((IDisposable)cr).Dispose();
return true;
}
示例12: DrawCircle
static void DrawCircle(CairoContextEx gr, double x, double y, Color[] colors, int color_indice)
{
double dg;
gr.Arc (x, y, radius, 0, 2 * Math.PI);
gr.Stroke ();
gr.Save ();
for (int slice = 0; slice < total_slices; slice++)
{
dg = slice * (360 / total_slices);
DrawSlice (gr, x, y, dg, colors [color_indice]);
color_indice++;
if (color_indice >= colors.Length)
color_indice = 0;
}
gr.Restore ();
}
示例13: DrawAndConnectPoints
private static void DrawAndConnectPoints(CairoContextEx gr, double x, double y, Circle[] circles, bool connect)
{
const double point_size = 0.01;
for (int i = 0; i < circles.Length; i++) {
gr.Arc (x + point_size + circles[i].x, y + point_size + circles[i].y, point_size, 0, 2 * Math.PI);
gr.Fill ();
gr.Stroke ();
}
if (connect == false)
return;
gr.Save ();
gr.LineWidth = 0.003;
double offset = point_size;
for (int from = 0; from < circles.Length; from++) {
for (int to = 0; to < circles.Length; to++) {
gr.MoveTo (x + circles[from].x+ offset, y + circles[from].y + offset);
gr.LineTo (x + circles[to].x + offset, y + circles[to].y + offset);
gr.Stroke ();
}
}
gr.Restore ();
}
示例14: Draw
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
{
#if DESIGN_MODE
gr.Save ();
gr.Color = new Cairo.Color (0, 0, 1);
gr.Rectangle (X, Y, Width, Height);
gr.Stroke ();
gr.Restore ();
#endif
foreach (Widget child in children)
{
gr.Save ();
gr.Translate (child.X, child.Y);
child.Draw (gr, area_width, area_height, rtl);
gr.Restore ();
}
}
示例15: DrawSquare
private void DrawSquare(CairoContextEx gr, double x, double y, SquareColor []colours, int index)
{
gr.Save ();
for (int column = 0; column < columns; column++) {
for (int row = 0; row < rows; row++) {
// if you want 2 schemes (primary or secundary colors)
Color c = palette.Cairo(ColorPalette.Id.First+ color_sheme*3 + (int)colours[index+(columns * row) + column]);
gr.Rectangle (x + row * rect_w, y + column * rect_h, rect_w, rect_h);
gr.FillGradient (x + row * rect_w, y + column * rect_h, rect_w, rect_h, c);
}
}
gr.Restore ();
for (int column = 0; column < columns; column++) {
for (int row = 0; row < rows; row++) {
gr.Rectangle (x + row * rect_w, y + column * rect_h, rect_w, rect_h);
gr.Stroke ();
}
}
}