public override void DrawPreview(CairoContextEx gr, int width, int height, bool rtl) { gr.Scale(width, height); gr.SetSourceColor(new Cairo.Color(0, 0, 0)); gr.LineWidth = LineWidth; DrawObjectToMemorize(gr, width, height, rtl); }
protected void InitDraw(CairoContextEx gr, int width, int height, bool rtl) { gr.Scale(width, height); gr.SetSourceColor(default_color); gr.LineWidth = LineWidth; // Not all Cairo surfaces have a default font size (like PDF) gr.SetPangoNormalFontSize(); }
public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl) { if (IsPreviewMode) { DrawPreview(gr, area_width, area_height, rtl); return; } if (downview != null) { downview.Draw(gr, area_width, area_height, rtl); return; } InitDraw(gr, area_width, area_height, rtl); if (SupportsShading && shade) { if (alpha > 0) { alpha -= (1 / (double)shading_time); } gr.SetSourceColor(new Color(DefaultDrawingColor.R, DefaultDrawingColor.G, DefaultDrawingColor.B, alpha)); DrawObjectToMemorize(gr, area_width, area_height, rtl); return; } alpha = 1; gr.SetSourceColor(new Color(DefaultDrawingColor.R, DefaultDrawingColor.G, DefaultDrawingColor.B, alpha)); if (request_answer && Answer.Draw == false) { DrawPossibleAnswers(gr, area_width, area_height, rtl); } else { DrawObjectToMemorize(gr, area_width, area_height, rtl); } }
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.SetSourceColor(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.SetSource(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(); }