public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double rect_w = DrawAreaWidth / rows; double rect_h = DrawAreaHeight / columns; base.Draw (gr, area_width, area_height, rtl); for (int column = 0; column < columns; column++) { for (int row = 0; row < rows; row++) { gr.Color = DefaultDrawingColor; gr.Rectangle (DrawAreaX + row * rect_w, DrawAreaY + column * rect_h, rect_w, rect_h); gr.Stroke (); gr.DrawTextCentered (DrawAreaX + (rect_w / 2) + column * rect_w, (rect_h / 2) + DrawAreaY + row * rect_h, (numbers[column + (row * 4)]).ToString() ); if (numbers[column + (row * 4)] % divisor == 0 && good_pos != column + (row * 4)) { gr.Arc (DrawAreaX + (rect_w / 2) + column * rect_w, (rect_h / 2) + DrawAreaY + row * rect_h, 0.05, 0, 2 * Math.PI); gr.FillGradient (DrawAreaX + (rect_w / 2) + column * rect_w, (rect_h / 2) + DrawAreaY + row * rect_h, 0.05, 0.05); } gr.Stroke (); } } }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { base.Draw (gr, area_width, area_height, rtl); gr.SetPangoLargeFontSize (); gr.DrawTextCentered (0.5, DrawAreaY + 0.3, formula); }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { base.Draw (gr, area_width, area_height, rtl); gr.Color = new Color (0.4, 0.4, 0.4); gr.DrawTextCentered (0.5, DrawAreaY, "This is an extension sample"); }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { base.Draw (gr, area_width, area_height, rtl); gr.DrawImageFromAssembly ("people_table.svg", 0.2, 0.2, 0.6, 0.6); gr.DrawTextCentered (0.5, 0.85, Translations.GetString ("Two people in the table sitting across each other")); }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { base.Draw (gr, area_width, area_height, rtl); gr.DrawClock (DrawAreaX + 0.4, DrawAreaY + 0.4, figure_size, 0, 0 /* No hands */); gr.DrawTextCentered (0.5, DrawAreaY + 0.3 + figure_size, Translations.GetString ("Sample clock")); }
public void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { gr.Scale (area_width, area_height); gr.LineWidth = 0.01; gr.Color = new Cairo.Color (0, 0, 0, 1); gr.SetPangoLargeFontSize (); gr.DrawTextCentered (0.5, 0.1, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Get ready to memorize the next objects...")); gr.Stroke (); gr.SetPangoFontSize (0.35); gr.DrawTextCentered (0.5, 0.5, countdown_time.ToString ()); gr.Stroke (); gr.Arc (0.5, 0.5, 0.25, 0, 2 * Math.PI); gr.Stroke (); gr.Arc (0.5, 0.5, 0.28, 0, 2 * Math.PI); gr.Stroke (); }
public override void DrawObjectToMemorize(CairoContextEx gr, int area_width, int area_height, bool rtl) { StringBuilder sequence = new StringBuilder (64); base.DrawObjectToMemorize (gr, area_width, area_height, rtl); gr.SetPangoLargeFontSize (); for (int num = 0; num < Challenge.Numbers.Length - 1; num++) { sequence.Append (Challenge.Numbers [num]); sequence.Append (", "); } sequence.Append (Challenge.Numbers [Challenge.Numbers.Length - 1]); gr.DrawTextCentered (0.5, DrawAreaY + 0.3, sequence.ToString ()); }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double rect_w = DrawAreaWidth / rows; double rect_h = DrawAreaHeight / columns; base.Draw (gr, area_width, area_height, rtl); for (int column = 0; column < columns; column++) { for (int row = 0; row < rows; row++) { gr.Rectangle (DrawAreaX + row * rect_w, DrawAreaY + column * rect_h, rect_w, rect_h); if (row != 3 || column != 3) { gr.DrawTextCentered (DrawAreaX + column * rect_w + rect_w / 2, DrawAreaY + row * rect_h + rect_h / 2, (numbers[column + (row * 4)]).ToString()); } } } gr.DrawTextCentered (DrawAreaX + 3 * rect_w + rect_w / 2, DrawAreaY + 3 * rect_h + rect_h / 2, "?"); gr.Stroke (); }
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; }
private static void DrawSliceText(CairoContextEx gr, double x, double y, int slice, string str1, string str2, string str3) { double x0, y0, degrees; // Number more near to the center; degrees = radian * (slice * ((360 / total_slices)) + (360 / 12)); x0 = 0.35 * radius * Math.Cos (degrees); y0 = 0.35 * radius * Math.Sin (degrees); gr.DrawTextCentered (x + x0, y + y0, str1); // Number opposite to the center and at the top degrees = radian * (slice * ((360 / total_slices)) + (360 / 24)); x0 = 0.8 * radius * Math.Cos (degrees); y0 = 0.8 * radius * Math.Sin (degrees); gr.DrawTextCentered (x + x0, y + y0, str2); // Number opposite to the center and at the bottom degrees = radian * (slice * ((360 / total_slices)) + (360 / 8)); x0 = 0.8 * radius * Math.Cos (degrees); y0 = 0.8 * radius * Math.Sin (degrees); gr.DrawTextCentered (x + x0, y + y0, str3); }
static void DrawBar(CairoContextEx gr, double x, double y, double w, double h, double percentage) { double per = percentage / 100; gr.Rectangle (x, y - h * per, w, h * per); gr.FillGradient (x, y - h * per, w, h * per, new Cairo.Color (0, 0, 1)); gr.DrawTextCentered (x + w / 2, (y - 0.03) - h * per, String.Format ("{0}", percentage)); gr.Save (); gr.Color = new Cairo.Color (0, 0, 0); gr.MoveTo (x, y); gr.LineTo (x, y - h * per); gr.LineTo (x + w, y - h * per); gr.LineTo (x + w, y); gr.LineTo (x, y); gr.Stroke (); gr.Restore (); }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { StringBuilder sequence = new StringBuilder (64); base.Draw (gr, area_width, area_height, rtl); gr.SetPangoLargeFontSize (); for (int num = 0; num < max_num - 1; num++) { if (num == question) { sequence.Append ("?, "); } else { sequence.Append (numbers[num]); sequence.Append (", "); } } sequence.Append (numbers[max_num - 1]); gr.DrawTextCentered (0.5, DrawAreaY + 0.3, sequence.ToString ()); }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double x = DrawAreaX + 0.22, y = DrawAreaY + 0.2; double pos_x = x; double pos_y = y; Circle[] circles = null; base.Draw (gr, area_width, area_height, rtl); circles = new Circle [] { new Circle (0.01, 0.06), new Circle (0.27, 0.06), new Circle (0.01, 0.21), new Circle (0.27, 0.21), new Circle (0.14, 0), new Circle (0.14, 0.29) }; // Circle gr.Arc (pos_x + figure_size, pos_y + figure_size, figure_size, 0, 2 * Math.PI); gr.Stroke (); 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 (); } gr.MoveTo (x + circles[2].x + 0.01, y + circles[2].y + 0.01); gr.LineTo (x + circles[1].x + 0.01, y + circles[1].y + 0.01); gr.Stroke (); gr.DrawTextCentered (pos_x + figure_size, pos_y + 0.08 + figure_size * 2, ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Two people in the table sitting across each other")); }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double x = DrawAreaX + 0.05, y = DrawAreaY; double pos_x = x; double pos_y = y; Circle[] circles = null; base.Draw (gr, area_width, area_height, rtl); // First circle gr.Arc (pos_x + figure_size, y + figure_size, figure_size, 0, 2 * Math.PI); gr.Stroke (); DrawAndConnectPoints (gr, pos_x, pos_y, new Circle [] { new Circle (0.14, 0), new Circle (0.14, 0.29), }, true); gr.DrawTextCentered (pos_x + figure_size, pos_y + figure_size * 2 + 0.07, HasNRegionString (2)); gr.Stroke (); // Second circle pos_x += 0.4; gr.Arc (pos_x + figure_size, pos_y + figure_size, figure_size, 0, 2 * Math.PI); gr.Stroke (); DrawAndConnectPoints (gr, pos_x, pos_y, new Circle [] { new Circle (0.01, 0.06), new Circle (0.27, 0.06), new Circle (0.14, 0.29), }, true); gr.DrawTextCentered (pos_x + figure_size, pos_y + figure_size * 2 + 0.07, HasNRegionString (4)); gr.Stroke (); // Third circle pos_x = x; pos_y += 0.45; gr.Arc (pos_x + figure_size, pos_y + figure_size, figure_size, 0, 2 * Math.PI); gr.Stroke (); DrawAndConnectPoints (gr, pos_x, pos_y, new Circle [] { new Circle (0.01, 0.06), new Circle (0.27, 0.06), new Circle (0.01, 0.21), new Circle (0.27, 0.21), }, true); gr.DrawTextCentered (pos_x + figure_size, pos_y + figure_size * 2 + 0.07, HasNRegionString (8)); gr.Stroke (); switch (dots) { case 5: circles = new Circle [] { new Circle (0.01, 0.06), new Circle (0.27, 0.06), new Circle (0.01, 0.21), new Circle (0.27, 0.21), new Circle (0.14, 0), }; break; case 6: circles = new Circle [] { new Circle (0.01, 0.06), new Circle (0.27, 0.06), new Circle (0.01, 0.21), new Circle (0.27, 0.21), new Circle (0.14, 0), new Circle (0.14, 0.29) }; break; } // Forth circle pos_x += 0.4; gr.Arc (pos_x + figure_size, pos_y + figure_size, figure_size, 0, 2 * Math.PI); gr.Stroke (); DrawAndConnectPoints (gr, pos_x, pos_y, circles, Answer.Draw); }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double x = DrawAreaX + 0.1; base.Draw (gr, area_width, area_height, rtl); gr.SetPangoLargeFontSize (); gr.MoveTo (x, DrawAreaY + 0.22); gr.ShowPangoText (String.Format ("number1 + number2 = {0}", op1)); gr.MoveTo (x, DrawAreaY + 0.44); gr.ShowPangoText (String.Format ("number1 * number2 = {0}", op2)); gr.Color = new Color (0.9, 0.9, 0.9); gr.DrawTextCentered (0.5, DrawAreaY, "This is an extension sample"); }
public override void DrawPossibleAnswers(CairoContextEx gr, int area_width, int area_height, bool rtl) { double x= DrawAreaX + 0.125, y = DrawAreaY + 0.1; int cnt = 0; for (int i = 0; i < showed; i++) { if (i == answer) continue; gr.MoveTo (x, y); gr.ShowPangoText (animals[animals_order[i]]); gr.Stroke (); if ((cnt + 1) % 3 == 0) { y += 0.2; x = DrawAreaX + 0.125; } else { x+= 0.25; } cnt++; } gr.Color = new Color (0.9, 0.9, 0.9); gr.DrawTextCentered (0.5, DrawAreaY, "This is an extension sample"); }
public void Draw(CairoContextEx gr, ref double x, ref double y, Indication next_prev) { const double line_length = 0.045; const double points = 0.045; if (type == Indication.Type.Start) { gr.Rectangle (x, y, points, points); gr.DrawTextCentered (x + points /2 , y + points /2, ((int)obj).ToString ()); gr.Stroke (); switch ((TurnDirection) next_prev.obj) { case TurnDirection.Right: x += points; y += points / 2; break; case TurnDirection.Left: y += points / 2; break; case TurnDirection.Down: y += points; x += points / 2; break; case TurnDirection.Up: x += points / 2; break; } } else if (type == Indication.Type.Turn) { gr.MoveTo (x, y); switch ((TurnDirection) obj) { case TurnDirection.Right: x += line_length; break; case TurnDirection.Left: x -= line_length; break; case TurnDirection.Up: y -= line_length; break; case TurnDirection.Down: y += line_length; break; } gr.LineTo (x, y); gr.Stroke (); } else if (type == Indication.Type.End) { switch ((TurnDirection) next_prev.obj) { case TurnDirection.Right: y -= points / 2; break; case TurnDirection.Left: x -= points; y -= points / 2; break; case TurnDirection.Down: x -= points / 2; break; case TurnDirection.Up: x -= points / 2; y -= points; break; } gr.Rectangle (x, y, points, points); gr.Stroke (); gr.DrawTextCentered (x + points /2 , y + points /2, ((int)obj).ToString ()); } }
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 (); }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { int rows = 7, columns = 9; double rect_w = DrawAreaWidth / columns; double rect_h = DrawAreaHeight / rows; int first_column; string text; base.Draw (gr, area_width, area_height, rtl); gr.SetPangoLargeFontSize (); for (int row = 0; row < rows; row++) { for (int column = 0; column < columns; column++) { gr.Rectangle (DrawAreaX + column * rect_w, DrawAreaY + row * rect_h, rect_w, rect_h); gr.Stroke (); if (row >= lines.Length) continue; first_column = (columns - lines[row].TotalNumbers) / 2; if (column < first_column || column - first_column >= lines [row].TotalNumbers) continue; if (row + 1 == lines.Length && lines [row].IsMiddle (column - first_column)) text = "?"; else text = lines [row].GetNumber (column - first_column).ToString (); gr.DrawTextCentered (DrawAreaX + (column * rect_w) + rect_w / 2, DrawAreaY + (row * rect_h) + rect_h / 2, text.ToString()); } } }
void DrawColumnBarGraphic(CairoContextEx gr, double x, double y) { const double area_w = 0.85, area_h = 0.28; const double bar_w = 0.05, bar_h = area_h - 0.02; const double space_x = 0.08; gr.LineWidth = 0.005; // Draw X reference values gr.SetPangoFontSize (smaller_font); gr.DrawTextAlignedRight (x + 0.05, y, "100"); gr.DrawTextAlignedRight (x + 0.05, y + area_h - 0.02, "0"); x += 0.06; // Axis gr.MoveTo (x, y); gr.LineTo (x, y + area_h); gr.LineTo (x + area_w, y + area_h); gr.Stroke (); x = x + space_x; DrawBar (gr, x, y + area_h, bar_w, bar_h, session.History.TotalScore); gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, Translations.GetString ("Total")); x = x + space_x * 2; if (session.History.LogicPlayed > 0) DrawBar (gr, x, y + area_h, bar_w, bar_h, session.History.LogicScore); gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, Translations.GetString ("Logic")); x = x + space_x * 2; if (session.History.MathPlayed > 0) DrawBar (gr, x, y + area_h, bar_w, bar_h, session.History.MathScore); gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, Translations.GetString ("Calculation")); x = x + space_x * 2; if (session.History.MemoryPlayed > 0) DrawBar (gr, x, y + area_h, bar_w, bar_h, session.History.MemoryScore); gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, Translations.GetString ("Memory")); x = x + space_x * 2; if (session.History.VerbalPlayed > 0) DrawBar (gr, x, y + area_h, bar_w, bar_h, session.History.VerbalScore); gr.DrawTextCentered (x + bar_w / 2, y + area_h + 0.03, Translations.GetString ("Verbal")); }
private void DrawSquare(CairoContextEx gr, double x, double y, int[] nums, int index) { 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 (); gr.DrawTextCentered (x + (rect_w / 2) + column * rect_w, y + (rect_h / 2) + row * rect_h, (nums[index + column + (row * columns)]).ToString ()); gr.Stroke (); } } }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { double x = DrawAreaX + 0.2, y = DrawAreaY; double x0, y0, degrees; int pos; base.Draw (gr, area_width, area_height, rtl); gr.Arc (x + arc_centerx, y + arc_centery, radius, 0, 2 * Math.PI); gr.Stroke (); for (int slice = 0; slice < total_slices; slice++) { degrees = radian * slice * (360 / total_slices); gr.MoveTo (x + arc_centerx, y + arc_centery); gr.LineTo (x + arc_centerx + (radius * Math.Cos (degrees)), y + arc_centery + (radius * Math.Sin (degrees))); if (slice > total_slices - 1) continue; if (slice == 0) { degrees = radian * (slice * ((360 / total_slices)) + (360 / 12)); x0 = 0.5 * radius * Math.Cos (degrees); y0 = 0.5 * radius * Math.Sin (degrees); gr.DrawTextCentered (x + arc_centerx + x0, y + arc_centery + y0, "?"); continue; } if (slice < half_slices) { pos = random_indices [slice]; DrawSliceText (gr, x + arc_centerx, y + arc_centery, slice, (sum_offset + slices [pos * items_per_slice]).ToString (), (sum_offset + slices [1 + (pos * items_per_slice)]).ToString (), (sum_offset + slices [2 + (pos * items_per_slice)]).ToString ()); } else { pos = random_indices [slice - half_slices]; DrawSliceText (gr, x + arc_centerx, y + arc_centery, slice, slices_opposite [pos * items_per_slice].ToString (), slices_opposite [2 + (pos * items_per_slice)].ToString (), slices_opposite [1 + (pos * items_per_slice)].ToString ()); } } gr.MoveTo (0.1, 0.55); gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:")); gr.Stroke (); }
static void DrawClock(CairoContextEx gr, double x, double y, int hand_short, int hand_large, bool draw_large) { const double radius = figure_size / 2; double x0, y0; int num, degrees; gr.Arc (x, y, radius, 0, 2 * Math.PI); gr.Stroke (); for (degrees = 0; degrees < 360; degrees+= 30) { x0 = radius * Math.Cos (degrees * radian); y0 = radius * Math.Sin (degrees * radian); // Small lines gr.MoveTo (x + 0.9 * x0, y + 0.9 * y0); gr.LineTo (x + x0, y + y0); gr.Stroke (); // Numbers num = (degrees / 30) + 3; if (num > 12) num = num - 12; gr.DrawTextCentered (x + x0 * 0.75, y + y0 * 0.75, num.ToString ()); gr.Stroke (); } if (draw_large) { // Hand Large degrees = (hand_large - 3) * 30; x0 = radius * Math.Cos (degrees * radian); y0 = radius * Math.Sin (degrees * radian); gr.MoveTo (x, y); gr.LineTo (x + x0 * 0.55, y + y0 * 0.55); gr.Stroke (); } // Hand Short degrees = (hand_short - 3) * 30; x0 = radius * Math.Cos (degrees * radian); y0 = radius * Math.Sin (degrees * radian); gr.MoveTo (x, y); gr.LineTo (x + x0 * 0.4, y + y0 * 0.4); gr.Stroke (); }