Наследование: gbrainy.Core.Libraries.CairoContext
Пример #1
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            base.Draw (gr, area_width, area_height, rtl);

            if (String.IsNullOrEmpty (svg_image) == false)
                gr.DrawImageFromAssembly (svg_image, 0.25, 0.25, 0.5, 0.5);
        }
Пример #2
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            base.Draw (gr, area_width, area_height, rtl);

            if (gametype == GameType.Present) {
                gr.DrawImageFromAssembly ("present.svg", 0.2, 0.4, 0.6, 0.2);
            } else {
                if (gametype == GameType.Fence)
                {
                    double x105, y105, y;
                    const double x = 0.35;
                    const double figure_size = 0.4;

                    x105 = figure_size * Math.Cos (105 * Math.PI / 180);
                    y105 = figure_size * Math.Sin (105 * Math.PI / 180);

                    y = (1 - y105) / 2;
                    gr.MoveTo (x, y);
                    gr.LineTo (x + x105, y + y105);
                    gr.LineTo (x + x105 + figure_size, y + y105);
                    gr.Stroke ();
                    gr.MoveTo (x + figure_size, y);
                    gr.LineTo (x + figure_size + x105, y + y105);
                    gr.Stroke ();
                    gr.MoveTo (x, y);
                    gr.LineTo (x + figure_size, y);
                    gr.Stroke ();
                }
            }
        }
Пример #3
0
    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");
    }
Пример #4
0
    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");
    }
Пример #5
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            base.Draw (gr, area_width, area_height, rtl);

            DrawLine (gr, 0.1, 0.2, 0.4, 0.38);
            DrawLine (gr, 0.1, 0.3, 0.4, 0.3);
            DrawLine (gr, 0.1, 0.4, 0.4, 0.25);

            if (type == 1)  {
                DrawLine (gr, 0.6, 0.3, -0.2, 0.35);
                DrawLine (gr, 0.5, 0.25, -0.2, 0.35);
            }

            DrawLine (gr, 0.1, 0.25, 0.6, 0.1);
            DrawLine (gr, 0.25, 0.2, 0, 0.4);

            if (type == 2 || type == 1)  {
                DrawLine (gr, 0.85, 0.25, -0.2, 0.4);
                DrawLine (gr, 0.88, 0.25, -0.2, 0.4);
            }

            DrawLine (gr, 0.91, 0.25, -0.2, 0.4);
            DrawLine (gr, 0.8, 0.2, 0, 0.4);
            DrawLine (gr, 0.82, 0.2, 0, 0.4);
            DrawLine (gr, 0.6, 0.50, 0.25, 0);
            DrawLine (gr, 0.6, 0.53, 0.25, 0);
        }
Пример #6
0
        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);
        }
Пример #7
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = DrawAreaX + 0.2, y = DrawAreaY + 0.2, width = 0.4, height = 0.4;

            base.Draw (gr, area_width, area_height, rtl);

            gr.Rectangle (x, y, width, height);
            gr.Stroke ();

            gr.MoveTo (x, y + 0.1);
            gr.LineTo (x + width, y + 0.1);  // First horizontal
            gr.Stroke ();

            gr.MoveTo (x, y + 0.3);
            gr.LineTo (x + width - 0.1, y + 0.3); // Second horizontal
            gr.Stroke ();

            gr.MoveTo (x + 0.1, y);
            gr.LineTo (x + 0.1, y + height);  // First vertical
            gr.Stroke ();

            gr.MoveTo (x + 0.3, y);
            gr.LineTo (x + 0.3, y + height - 0.1);  // Second vertical
            gr.Stroke ();
        }
        public override void DrawPossibleAnswers(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x= DrawAreaX, y = DrawAreaY + 0.1;
            int pos = 0;
            gr.Color = new Color (DefaultDrawingColor.R, DefaultDrawingColor.G, DefaultDrawingColor.B, 1);

            if (Answer.Draw ==  true) {
                DrawAllFigures (gr, start_x_ans, start_y, area_width, area_height);
                return;
            }

            gr.SetPangoNormalFontSize ();
            for (int i = 0; i < figures.Length; i++)
            {
                if (i == question_pos)
                    continue;

                gr.MoveTo (x, y);
                gr.ShowPangoText (FigureType.ToString (figures[i]));

                if ((pos + 1) % 3 == 0) {
                    y += 0.2;
                    x = DrawAreaX;
                } else {
                    x+= 0.30;
                }
                pos++;
            }
        }
Пример #9
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            #if DESIGN_MODE
            gr.Save ();
            gr.Color = new Cairo.Color (1, 0, 0);
            gr.Rectangle (0, 0, Width, Height);
            gr.Stroke ();
            gr.Restore ();
            #endif

            if (hoover == true)
              			{
                double lw = gr.LineWidth;
                double [] dashes = {0.01,  /* ink */
                           0.01,  /* skip */ };

                gr.Save ();

                gr.Color = new Cairo.Color (0.5, 0.5, 0.5, 1);
                gr.SetDash (dashes, 0);

                if (SelectedArea.Width == 0 && SelectedArea.Height == 0)
                    gr.Rectangle (-lw, -lw, Width + lw * 2, Height + lw * 2);
                else
                    gr.Rectangle (SelectedArea.X -lw, SelectedArea.Y -lw, SelectedArea.Width + lw * 2, SelectedArea.Height + lw * 2);

                gr.Stroke ();
                gr.Restore ();
            }

            if (DrawEventHandler == null)
                return;

            DrawEventHandler (this, new DrawEventArgs (gr, Width, Height, rtl, Data));
        }
Пример #10
0
        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 ();
                }
            }
        }
Пример #11
0
 public DrawEventArgs(CairoContextEx gr, double width, double height, bool rtl, object data)
 {
     Context = gr;
     Width = width;
     Height = height;
     Rtl = rtl;
     Data = data;
 }
Пример #12
0
        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.MoveTo (0.1, DrawAreaY);
            gr.ShowPangoText (Translations.GetString ("Choose one of the following:"));
        }
Пример #13
0
        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"));
        }
Пример #14
0
        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.SetPangoLargeFontSize ();

            gr.MoveTo (0.1, 0.15);
            gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
        }
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = DrawAreaX + 0.05, y = DrawAreaY + 0.1;

            base.Draw (gr, area_width, area_height, rtl);

            DrawRectangleWithText (gr, x, y, 0);
            DrawRectangleWithText (gr, x + figure_size + 0.2, y, 4);
            DrawRectangleWithText (gr, x + figure_size + 0.05, y + 0.2 + figure_size, 8);
        }
Пример #17
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = DrawAreaX + 0.2, y = DrawAreaY + 0.2;

            base.Draw (gr, area_width, area_height, rtl);

            if (Answer.Draw)
                DrawAnswer (gr, x, y);

            DrawQuestion (gr, x, y);
        }
Пример #18
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            base.Draw (gr, area_width, area_height, rtl);

            if (problems[problem].single)
                gr.DrawImageFromAssembly ("dice.svg", 0.3, 0.3, 0.4, 0.4);
            else {
                gr.DrawImageFromAssembly ("dice.svg", 0.1, 0.3, 0.4, 0.4);
                gr.DrawImageFromAssembly ("dice.svg", 0.5, 0.3, 0.4, 0.4);
            }
        }
Пример #19
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = DrawAreaX + 0.1, y = DrawAreaY + 0.05;

            base.Draw (gr, area_width, area_height, rtl);

            for (int i = 0; i < circles.Length; i++)
            {
                gr.Arc (x + circles[i].x + 0.1, y + circles[i].y + 0.1, circles[i].rad, 0, 2 * Math.PI);
                gr.Stroke ();
            }
        }
Пример #20
0
        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);
        }
Пример #21
0
        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 ();
                }
            }
        }
Пример #22
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = DrawAreaX + 0.15;

            base.Draw (gr, area_width, area_height, rtl);

            for (int i = 0; i < 2; i++)
                DrawFigureSequence (gr, x, DrawAreaY + sub_figure * i , i, true);

            DrawFigureSequence (gr, x, DrawAreaY + sub_figure * 2 , 2, false);

            gr.MoveTo (0.1, 0.62);
            gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
        }
Пример #23
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = DrawAreaX, y = DrawAreaY + 0.1;

            base.Draw (gr, area_width, area_height, rtl);

            for (int i = 0; i < 4; i++) {
                DrawQuestionFigures (gr, x, y, random_indices_questions [i]);
                x += space_figures;
            }

            gr.MoveTo (0.1, 0.4 - 0.02);
            gr.ShowPangoText (Translations.GetString ("Choose one of the following:"));
        }
Пример #24
0
        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 (Translations.GetString ("x + y = {0}"), number_a + number_b));

            gr.MoveTo (x, DrawAreaY + 0.44);
            gr.ShowPangoText (String.Format (Translations.GetString ("have a ratio of {0}:{1}"), ratio_a, ratio_b));
        }
Пример #25
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = DrawAreaX + 0.1, y = DrawAreaY + 0.2;
            const double witdh = 0.6, height = 0.5;

            base.Draw (gr, area_width, area_height, rtl);

            gr.MoveTo (x, y);
            gr.LineTo (x + witdh, y);
            gr.LineTo (x + witdh / 2, y + height / 2);
            gr.LineTo (x, y);
            gr.LineTo (x + 0.45, y + height /4);
            gr.Stroke ();

            if (type == 0) {
                gr.MoveTo (x + witdh / 2, y);
                gr.LineTo (x + witdh / 2, y + height / 2);
                gr.Stroke ();
            }

            gr.MoveTo (x + 0.152, y + 0.125);
            gr.LineTo (x + witdh, y);
            gr.Stroke ();

            if (Answer.Draw == false)
                return;

            // References
            gr.MoveTo (x - 0.02, y);
            gr.ShowPangoText ("a");

            gr.MoveTo (x + witdh /2  - 0.02, y);
            gr.ShowPangoText ("b");

            gr.MoveTo (x + witdh, y);
            gr.ShowPangoText ("c");

            gr.MoveTo (x + witdh /2  - 0.03, y + 0.07 - 0.02);
            gr.ShowPangoText ("d");

            gr.MoveTo (x + 0.11, y + 0.16);
            gr.ShowPangoText ("e");

            gr.MoveTo (x + 0.47, y + 0.16);
            gr.ShowPangoText ("f");

            gr.MoveTo (x + (witdh /2) - 0.01, y + 0.26);
            gr.ShowPangoText ("g");
        }
Пример #26
0
        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);
                }
            }

            gr.Stroke ();
        }
Пример #27
0
        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 ());
        }
Пример #28
0
        // TODO: We need a parameter here because not all the views are games
        // we need to extend the concept of view to include Widgets
        public bool CreateImage(IDrawable drawable, string file)
        {
            Cairo.ImageSurface cairo_image      = null;
            gbrainy.Core.Main.CairoContextEx cr = null;

            try
            {
                file        = Path.GetFullPath(file);
                cairo_image = new Cairo.ImageSurface(Cairo.Format.ARGB32, IMAGE_WIDTH, IMAGE_HEIGHT);
                cr          = new gbrainy.Core.Main.CairoContextEx(cairo_image, "sans 12", 96);

                // Draw Image
                drawable.Draw(cr, IMAGE_WIDTH, IMAGE_WIDTH, false);
                cairo_image.WriteToPng(file);

                if (File.Exists(file) == false)
                {
                    Logger.Error("Game.CreateImage. Error writting {0}", file);
                }
                else
                {
                    Logger.Debug("Game.CreateImage. Wrote image {0}", file);
                }
            }

            catch (Exception e)
            {
                Logger.Error("Game.CreateImage. Error writting {0} {1}", file, e);
                return(false);
            }

            finally
            {
                if (cr != null)
                {
                    ((IDisposable)cr).Dispose();
                }

                if (cairo_image != null)
                {
                    ((IDisposable)cairo_image).Dispose();
                }
            }

            return(true);
        }
Пример #29
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = 0.25, y = 0.25;

            base.Draw (gr, area_width, area_height, rtl);

            gr.Rectangle (x, y, width, height);
            gr.Stroke ();

            gr.MoveTo (x, y + height / 2);
            gr.LineTo (x + width, y + height / 2);
            gr.Stroke ();

            gr.MoveTo (x + width / 2, y);
            gr.LineTo (x + width / 2, y + height);
            gr.Stroke ();

            if (cover_zone1)
                CoverZone (gr, x, y);

            if (cover_zone2)
                CoverZone (gr, x + width / 2, y);

            if (cover_zone3)
                CoverZone (gr, x, y + height / 2);

            if (cover_zone4)
                CoverZone (gr, x + width / 2, y + height / 2);

            switch (partial_zone) {
                case 1:
                    break;
                case 2:
                    x += width / 2;
                    break;
                case 3:
                    y += height / 2;
                    break;
                case 4:
                    y += height / 2;
                    x += width / 2;
                    break;
            }

            DrawSection (gr, x, y);
        }
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = DrawAreaX, y = DrawAreaY, space_x = 0.15;

            base.Draw (gr, area_width, area_height, rtl);

            for (int i = 0; i < random_indices.Count; i++) {
                DrawFigure (gr, x, y, (Figures) random_indices[i]);
                gr.MoveTo (x, y - 0.02 + figure_size * 1.6);
                gr.ShowPangoText (Answer.GetFigureName (i));

                if (i == 2) {
                    x = DrawAreaX;
                    y += figure_size * 3;
                } else
                    x += figure_size + space_x;
            }
        }
Пример #31
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = 0.05, y = DrawAreaY + 0.1;

            base.Draw (gr, area_width, area_height, rtl);

            DrawBalance (gr, x, y, group * elements * 6, true);
            y += 0.3;

            DrawBalance (gr, x, y, (group * elements * 6) + 1 * elements * 2, true);
            y += 0.3;

            DrawBalance (gr, x, y, (group * elements * 6) + 2 * elements * 2, false);

            gr.SetPangoFontSize (0.05);
            gr.MoveTo (0.74, 0.68);
            gr.ShowPangoText ("?");
            gr.Stroke ();
        }
Пример #32
0
        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);
            }
        }
Пример #33
0
        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, Translations.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(Translations.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();
            }
        }
Пример #34
0
 public virtual void Draw(CairoContextEx gr, int width, int height, bool rtl)
 {
     controler.CurrentView.Draw(gr, width, height, rtl);
 }
Пример #35
0
 public virtual void DrawPreview(CairoContextEx gr, int width, int height, bool rtl)
 {
     Draw(gr, width, height, rtl);
 }
Пример #36
0
        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(Translations.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(Translations.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();
            }
        }