示例#1
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");
    }
        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:"));
        }
        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.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:"));
        }
示例#5
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));
        }
示例#6
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:"));
        }
示例#7
0
        public override void DrawObjectToMemorize(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            base.DrawObjectToMemorize (gr, area_width, area_height, rtl);

            if (Answer.Draw == false) {
                for (int i = 0; i < indications.Length; i++)
                {
                    gr.MoveTo (0.3, 0.2 + i * 0.08);
                    gr.ShowPangoText (indications[i].ToString ());
                    gr.Stroke ();
                }
            } else {
                    for (int i = 0; i < indications.Length; i++)
                    {
                        gr.MoveTo (0.1, 0.2 + i * 0.08);
                        gr.ShowPangoText (indications[i].ToString ());
                        gr.Stroke ();
                    }
                    DrawPossibleAnswers (gr, 0.7, 0.3, WhichAnswer (answers[ans]));
                    gr.MoveTo (0.7, 0.5);
                    gr.ShowPangoText (Answer.GetFigureName (ans));
                    gr.Stroke ();
            }
        }
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = DrawAreaX, y = 0.05;

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

            gr.MoveTo (0.05, y);
            gr.SetPangoLargeFontSize ();
            gr.ShowPangoText (Translations.GetString ("Numbers"));
            y += 0.08;

            for (int n = 0; n < numbers.Length; n++)
            {
                gr.MoveTo (x, y);
                gr.ShowPangoText (numbers[n].ToString ());
                gr.Stroke ();
                x += 0.17;
            }

            y += 0.16;

            gr.MoveTo (0.05, y);
            gr.ShowPangoText (Translations.GetString ("Possible divisors"));
        }
示例#9
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            const double aligned_pos = 0.58;

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

            gr.SetPangoLargeFontSize ();
            gr.DrawTextAlignedRight (aligned_pos, DrawAreaY + 0.2, number_a.ToString ());
            gr.DrawTextAlignedRight (aligned_pos, DrawAreaY + 0.3, number_b.ToString ());
            gr.DrawTextAlignedRight (aligned_pos, DrawAreaY + 0.4, number_c.ToString ());

            gr.MoveTo (DrawAreaX + 0.2, DrawAreaY + 0.5);
            gr.LineTo (DrawAreaX + 0.5, DrawAreaY + 0.5);
            gr.Stroke ();

            gr.DrawTextAlignedRight (aligned_pos, DrawAreaY + 0.55, total.ToString ());

            gr.MoveTo (DrawAreaX + 0.2, DrawAreaY + 0.25);
            gr.ShowPangoText ((Answer.Draw == true) ? oper1.ToString () : "?");

            gr.MoveTo (DrawAreaX + 0.2, DrawAreaY + 0.35);
            gr.ShowPangoText ((Answer.Draw == true) ?  oper2.ToString () : "?");
        }
示例#10
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 (words[words_order[i]]);
                gr.Stroke ();

                if ((cnt + 1) % 3 == 0) {
                    y += 0.2;
                    x = DrawAreaX + 0.125;
                } else {
                    x+= 0.25;
                }
                cnt++;
            }
        }
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double first_x = DrawAreaX + 0.05;
            double first_y = DrawAreaY + 0.1;
            const double space_fromrect = 0.02, space_fromcircle = 0.01;
            int circles = 8;
            const double unit = 0.0625;

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

            gr.Rectangle (first_x, first_y, unit * 8, unit * 8);
            gr.Stroke ();

            // |-------|
            gr.MoveTo (first_x, first_y - 0.04 - space_fromrect);
            gr.LineTo (first_x, first_y - space_fromrect);
            gr.Stroke ();
            gr.MoveTo (first_x, first_y - 0.02 - space_fromrect);
            gr.LineTo (first_x + 0.5, first_y - 0.02 - space_fromrect);
            gr.Stroke ();
            gr.MoveTo (first_x + 0.5, first_y - 0.04 - space_fromrect);
            gr.LineTo (first_x + 0.5, first_y - space_fromrect);
            gr.Stroke ();

            gr.MoveTo (first_x + 0.2, first_y - 0.06 - space_fromrect);
            gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("8 units"));
            gr.Stroke ();

            //  ---
            //	 |
            //	 |
            //	 |
            //  ---
            gr.MoveTo (first_x  - space_fromrect, first_y);
            gr.LineTo (first_x  - space_fromrect - 0.04, first_y);
            gr.Stroke ();
            gr.MoveTo (first_x - space_fromrect - 0.02, first_y);
            gr.LineTo (first_x - space_fromrect - 0.02, first_y + 0.5);
            gr.Stroke ();
            gr.MoveTo (first_x - space_fromrect, first_y + 0.5);
            gr.LineTo (first_x - space_fromrect - 0.04, first_y + 0.5);
            gr.Stroke ();

            gr.MoveTo (first_x - space_fromrect - 0.07, first_y + 0.3);
            gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("8 units"), false, -1, 270 * Math.PI/180);
            gr.Stroke ();

            // Sample circle
            gr.Arc (first_x + 0.7, first_y + 0.1, unit / 2, 0, 2 * Math.PI);
            gr.Stroke ();

            // |-------|
            gr.MoveTo (first_x + 0.65, first_y + 0.05 - 0.04 - space_fromcircle);
            gr.LineTo (first_x + 0.65, first_y + 0.05 - space_fromcircle);
            gr.Stroke ();
            gr.MoveTo (first_x + 0.65, first_y + 0.05 - 0.02 - space_fromcircle);
            gr.LineTo (first_x + 0.65 + 0.1, first_y + 0.05 - 0.02 - space_fromcircle);
            gr.Stroke ();
            gr.MoveTo (first_x + 0.65 + 0.1, first_y + 0.05 - 0.04 - space_fromcircle);
            gr.LineTo (first_x + 0.65 + 0.1, first_y + 0.05 - space_fromcircle);
            gr.Stroke ();

            gr.MoveTo (first_x + 0.65, first_y - 0.04 - space_fromcircle);
            gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("1 unit"));
            gr.Stroke ();

            //  ---
            //	 |
            //	 |
            //	 |
            //  ---
            gr.MoveTo (first_x + 0.65  - space_fromcircle, first_y + 0.05);
            gr.LineTo (first_x + 0.65  - space_fromcircle - 0.04, first_y + 0.05);
            gr.Stroke ();
            gr.MoveTo (first_x + 0.65 - space_fromcircle - 0.02, first_y + 0.05);
            gr.LineTo (first_x + 0.65 - space_fromcircle - 0.02, first_y  + 0.05 + 0.1);
            gr.Stroke ();
            gr.MoveTo (first_x + 0.65 - space_fromcircle, first_y + 0.1 + 0.05);
            gr.LineTo (first_x + 0.65 - space_fromcircle - 0.04, first_y + 0.1 + 0.05);
            gr.Stroke ();

            gr.MoveTo (first_x + 0.65 - space_fromcircle - 0.08, first_y + 0.15);
            gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("1 unit"), false, -1, 270 * Math.PI/180);
            gr.Stroke ();

            if (Answer.Draw == false)
                return;

            double x;
            for (int line = 0; line < 9; line++)
            {
                for (int circle = 0; circle < circles; circle++)
                {
                    x = first_x + (unit / 2) + (circle * unit);

                    if (circles == 7)
                        x+= unit / 2;

                    gr.Arc (x, (unit / 2) + first_y + (unit * line) - (unit / 8) * line,
                            (unit / 2), 0, 2 * Math.PI);
                    gr.Stroke ();
                }

                if (circles ==8)
                    circles = 7;
                else
                    circles = 8;
            }
        }
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = DrawAreaX + 0.05, y = DrawAreaY + 0.1;
            double degrees, x1, x2, dist;

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

            for (int i = 0; i < random_indices_answers.Count; i++)
            {
                DrawFigure (gr, x, y, (Figures) random_indices_answers[i]);
                gr.MoveTo (x, y + 0.13);
                gr.ShowPangoText (Answer.GetFigureName (i));

                if (i  == (total_figures / 2) - 1) {
                    y+= 0.30;
                    x= DrawAreaX + 0.05;
                }
                else
                    x+= space_figures;
            }

            if (Answer.Draw == false)
                return;

            gr.MoveTo (DrawAreaX, y + 0.28);
            gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("The triangle is:"));
            gr.Stroke ();

            x = DrawAreaX + 0.35;
            y += 0.35;

            degrees = radian * 45;	// First triangle
            gr.MoveTo (x, y);
            x1 = x + figure_size * Math.Cos (degrees);
            gr.LineTo (x1, y + figure_size * Math.Sin (degrees));

            degrees = radian * (135);
            x2 = x + figure_size * Math.Cos (degrees);
            gr.MoveTo (x, y);
            gr.LineTo (x2, y + figure_size * Math.Sin (degrees));
            gr.LineTo (x1, y + figure_size * Math.Sin (degrees));
            dist = (x1 - x2);
            x += dist;

            degrees = radian * 45; // Second triangle
            gr.MoveTo (x, y);
            x1 = x + figure_size * Math.Cos (degrees);
            gr.LineTo (x1, y + figure_size * Math.Sin (degrees));

            degrees = radian * (135);
            x2 = x + figure_size * Math.Cos (degrees);
            gr.MoveTo (x, y);
            gr.LineTo (x2, y + figure_size * Math.Sin (degrees));
            gr.LineTo (x1, y + figure_size * Math.Sin (degrees));

            degrees = radian * (-45); // Bottom
            x =  DrawAreaX + 0.35;
            gr.MoveTo (x, y);
            gr.LineTo (x + figure_size * Math.Cos (degrees), y + figure_size * Math.Sin (degrees));

            x += dist;
            degrees = radian * (-135);
            gr.MoveTo (x, y);
            gr.LineTo (x + figure_size * Math.Cos (degrees), y + figure_size * Math.Sin (degrees));
            gr.Stroke ();
        }
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double operand_y = DrawAreaY + 0.2;
            const double operand_space = 0.1;
            const double aligned_pos = 0.58;

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

            gr.SetPangoLargeFontSize ();
            for (int i = 0; i < operands.Length - 1; i++)
            {
                gr.DrawTextAlignedRight (aligned_pos, operand_y, operands[i].ToString ());
                gr.MoveTo (DrawAreaX + 0.2, operand_y + 0.03);

                switch (operation) {
                case Operation.Addition:
                    gr.ShowPangoText ("+");
                    break;
                case Operation.Subtraction:
                    gr.ShowPangoText ("-");
                    break;
                case Operation.Multiplication:
                    gr.ShowPangoText ("*");
                    break;
                }

                operand_y += operand_space;
            }

            gr.DrawTextAlignedRight (aligned_pos, operand_y, operands[operands.Length - 1].ToString ());

            operand_y += 0.08;
            gr.MoveTo (DrawAreaX + 0.2, operand_y);
            gr.LineTo (DrawAreaX + 0.5, operand_y);
            gr.Stroke ();

            if (Answer.Draw) {
                gr.DrawTextAlignedRight (aligned_pos, operand_y + 0.03, Answer.Correct);
            }
        }
示例#14
0
        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 ();
        }
示例#15
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();
            }
        }
        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;
            }
        }
示例#17
0
        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 ();
        }
示例#18
0
        private void DrawObject(CairoContextEx gr, int area_width, int area_height)
        {
            double x= DrawAreaX + 0.125, y = DrawAreaY + 0.1;
            for (int i = 0; i < showed; i++)
            {
                gr.MoveTo (x, y);
                gr.ShowPangoText (words[words_order[i]]);
                gr.Stroke ();

                if ((i + 1) % 3 == 0) {
                    y += 0.2;
                    x = DrawAreaX + 0.125;
                } else {
                    x+= 0.25;
                }
            }
        }
        void DrawLegend(CairoContextEx cr, double x, double y)
        {
            const double line_size = 0.05, offset_x = 0.01, second_row = 0.05, space_hor = 0.35;
            double old_width;

            old_width = cr.LineWidth;
            cr.LineWidth = 0.01;

            cr.Color = total_color;
            cr.MoveTo (x, y);
            cr.LineTo (x + line_size, y);
            cr.Stroke ();
            cr.Color = text_color;
            cr.MoveTo (x + line_size + offset_x, y - 0.01);
            cr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Total"));
            cr.Stroke ();

            cr.Color = logic_color;
            cr.MoveTo (x, y + second_row);
            cr.LineTo (x + line_size, y + second_row);
            cr.Stroke ();
            cr.Color = text_color;
            cr.MoveTo (x + line_size + offset_x, y - 0.01 + second_row);
            cr.ShowPangoText (GameTypesDescription.GetLocalized (GameTypes.LogicPuzzle));
            cr.Stroke ();

            x += space_hor;
            cr.Color = memory_color;
            cr.MoveTo (x, y);
            cr.LineTo (x + line_size, y);
            cr.Stroke ();
            cr.Color = text_color;
            cr.MoveTo (x + line_size + offset_x, y - 0.01);
            cr.ShowPangoText (GameTypesDescription.GetLocalized (GameTypes.Memory));
            cr.Stroke ();

            cr.Color = math_color;
            cr.MoveTo (x, y + second_row);
            cr.LineTo (x + line_size, y + second_row);
            cr.Stroke ();
            cr.Color = text_color;
            cr.MoveTo (x + line_size + offset_x, y - 0.01 + second_row);
            cr.ShowPangoText (GameTypesDescription.GetLocalized (GameTypes.Calculation));
            cr.Stroke ();

            x += space_hor;
            cr.Color = verbal_color;
            cr.MoveTo (x, y);
            cr.LineTo (x + line_size, y);
            cr.Stroke ();
            cr.Color = text_color;
            cr.MoveTo (x + line_size + offset_x, y - 0.01);
            cr.ShowPangoText (GameTypesDescription.GetLocalized (GameTypes.VerbalAnalogy));
            cr.Stroke ();

            cr.LineWidth = old_width;
        }
示例#20
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double org_x = DrawAreaX + 0.1;
            double x = org_x, y = 0.08;
            double x45, y45, x135, y135, offset;

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

            // First pattern
            gr.Rectangle (x, y, figure_size, figure_size);
            gr.MoveTo (x, y);
            gr.LineTo (x + figure_size, y + figure_size);
            gr.MoveTo (x + figure_size, y);
            gr.LineTo (x, y + figure_size);
            gr.MoveTo (x + figure_size / 2, y);
            gr.LineTo (x + figure_size / 2, y + figure_size);
            gr.MoveTo (x, y + figure_size / 2);
            gr.LineTo (x + figure_size, y + figure_size / 2);
            gr.Stroke ();

            x += figure_size + space_x;
            gr.Rectangle (x, y, figure_size, figure_size);
            gr.MoveTo (x + figure_size / 2, y);
            gr.LineTo (x + figure_size / 2, y + figure_size);
            gr.MoveTo (x, y + figure_size / 2);
            gr.LineTo (x + figure_size, y + figure_size / 2);
            gr.Stroke ();

            x += figure_size + space_x;
            DrawCross (gr, x, y, figure_size);

            y += space_y;
            x = org_x;
            // Second pattern
            gr.Rectangle (x, y, figure_size, figure_size);
            gr.MoveTo (x, y);
            gr.LineTo (x + figure_size, y + figure_size);
            gr.MoveTo (x + figure_size, y);
            gr.LineTo (x, y + figure_size);
            gr.Stroke ();

            x += figure_size + space_x;
            DrawRotatedCross (gr, x, y, figure_size);

            // Rotated rectangle
            x += figure_size + space_x;
            x45 = figure_size * Math.Cos (45 * Math.PI / 180);
            y45 = figure_size * Math.Sin (45 * Math.PI / 180);
            x135 = figure_size * Math.Cos (135 * Math.PI / 180);
            y135 = figure_size * Math.Sin (135 * Math.PI / 180);
            offset = - 0.03;
            // Down-right
            gr.MoveTo (x + figure_size / 2, y + offset);
            gr.LineTo (x + figure_size / 2 + x45, y + offset + y45);
            // Up right
            gr.LineTo ((x + figure_size / 2 + x45) + x135, (y + offset +  y45) + y135);
            gr.Stroke ();
            // Down left
            gr.MoveTo (x + figure_size / 2, y + offset);
            gr.LineTo (x + figure_size / 2 + x135, y + offset + y135);
            // Up left
            gr.LineTo (x + figure_size / 2 + x135 + x45, y + offset + y135 + y45);
            gr.Stroke ();

            y += space_y;
            x = org_x;

            // Third pattern
            gr.MoveTo (x, y);
            gr.LineTo (x + figure_size, y);
            gr.LineTo (x, y + figure_size);
            gr.LineTo (x + figure_size, y  + figure_size);
            gr.Stroke ();

            x += figure_size + space_x;
            gr.MoveTo (x + figure_size, y);
            gr.LineTo (x, y);
            gr.LineTo (x + figure_size, y + figure_size);
            gr.LineTo (x, y  + figure_size);
            gr.Stroke ();

            x += figure_size + space_x;
            gr.MoveTo (x + 0.03, y - 0.02);
            gr.SetPangoFontSize (figure_size);
            gr.ShowPangoText ("?");
            gr.SetPangoNormalFontSize ();
            gr.Stroke ();

            gr.MoveTo (0.05, y - 0.01 + space_y);
            gr.ShowPangoText (Translations.GetString ("Choose one of the following:"));
            gr.Stroke ();
        }
示例#21
0
        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.MoveTo (pos_x, pos_y + figure_size * 2 + 0.05);
            gr.ShowPangoText (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.MoveTo (pos_x, pos_y + figure_size * 2 + 0.05);
            gr.ShowPangoText (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.MoveTo (pos_x, pos_y + figure_size * 2 + 0.05);
            gr.ShowPangoText (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);
        }
示例#22
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");
        }
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = DrawAreaX + 0.25;

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

            gr.SetPangoLargeFontSize ();
            gr.MoveTo (x, DrawAreaY + 0.22);

            switch (type) {
            case SubGameTypes.Addition:
                gr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("x + y = {0}"), op1));
                break;
            case SubGameTypes.Subtraction:
                gr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("x - y = {0}"), op1));
                break;
            default:
                throw new InvalidOperationException ();
            }

            gr.MoveTo (x, DrawAreaY + 0.44);
            gr.ShowPangoText (String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("x * y = {0}"), op2));
        }
示例#24
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = 0.05 + space_figures / 2, y = DrawAreaY;

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

            DrawFigure (gr, x, y, puzzle, 0);
            DrawFigure (gr, x + figure_size + space_figures, y, puzzle, columns * lines);
            DrawFigure (gr, x + (figure_size + space_figures) * 2, y, puzzle, columns * lines * 2);

            y += figure_size + 0.10;
            gr.MoveTo (x, y - 0.02);
            gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
        }
示例#25
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            const double fraction_size = 0.17;
            double x =  0.5  - (fractions_num * fraction_size / 2), y = DrawAreaY + 0.3;
            const double offset_x = 0.12;

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

            gr.SetPangoLargeFontSize ();

            for (int i = 0; i < fractions_num; i++)
            {
                // Numerator
                gr.DrawTextAlignedRight (x + offset_x, y, fractions[i].Numerator.ToString ());

                // Sign
                gr.MoveTo (x, y + 0.04);
                switch (fractions[i].Operation) {
                case Operation.Addition:
                    gr.ShowPangoText ("+");
                    break;
                case Operation.Subtraction:
                    gr.ShowPangoText ("-");
                    break;
                }
                gr.Stroke ();

                // Line
                gr.MoveTo (x + 0.05, y + 0.08);
                gr.LineTo (x + offset_x + 0.02,  y + 0.08);
                gr.Stroke ();

                // Denominator
                gr.DrawTextAlignedRight (x + offset_x, y + 0.1, fractions[i].Denominator.ToString ());

                x += fraction_size;
            }
        }
示例#26
0
        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,
                            records[i].PreviousScore);
                        break;
                    case GameTypes.Memory:
                        s = String.Format (Translations.
                            GetString ("By scoring {0} in memory games you have established a new personal record. Your previous record was {1}."),
                            records[i].NewScore,
                            records[i].PreviousScore);
                        break;
                    case GameTypes.VerbalAnalogy:
                        s = String.Format (Translations.
                            GetString ("By scoring {0} in verbal analogies you have established a new personal record. Your previous record was {1}."),
                            records[i].NewScore,
                            records[i].PreviousScore);
                        break;
                    default:
                        break;
                    }

                    tip = "- " + s;

                    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;
                }
            }

            gr.Stroke ();
        }
示例#27
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = DrawAreaX + 0.1, y = DrawAreaY + 0.1, w = 0.6, h = 0.6;

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

            gr.Rectangle (x, y, w, h);
            gr.Stroke ();

            // Lines
            gr.MoveTo (x + w /2, y);
            gr.LineTo (x + w /2, y + h);
            gr.Stroke ();
            gr.MoveTo (x, y + h /2);
            gr.LineTo (x + w, y + h / 2);
            gr.Stroke ();

            // Diagonals
            gr.MoveTo (x, y);
            gr.LineTo (x + w, y + h);
            gr.Stroke ();

            if (type == 1) {
                gr.MoveTo (x + w, y);
                gr.LineTo (x, y + h);
                gr.Stroke ();
            }

            if (Answer.Draw == false)
                return;

            // References
            gr.MoveTo (x - 0.04, y - 0.05);
            gr.ShowPangoText ("a");
            gr.Stroke ();

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

            gr.MoveTo (x + w + 0.02, y - 0.05);
            gr.ShowPangoText ("c");
            gr.Stroke ();

            gr.MoveTo (x - 0.04, y + h /2 - 0.02);
            gr.ShowPangoText ("d");
            gr.Stroke ();

            gr.MoveTo (x + w / 2 - 0.04, y  + h /2 - 0.04);
            gr.ShowPangoText ("e");
            gr.Stroke ();

            gr.MoveTo (x + w + 0.02, y  + h /2 - 0.02);
            gr.ShowPangoText ("f");
            gr.Stroke ();

            gr.MoveTo (x - 0.04, y + h + 0.02);
            gr.ShowPangoText ("g");
            gr.Stroke ();

            gr.MoveTo (x + w / 2 - 0.02, y + h + 0.02);
            gr.ShowPangoText ("h");
            gr.Stroke ();

            gr.MoveTo (x + w + 0.02, y + h + 0.02);
            gr.ShowPangoText ("i");
            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 ();
        }
示例#29
0
        private void DrawTriangle(CairoContextEx gr, double x, double y, int index, bool question)
        {
            gr.MoveTo (x + figure_size / 2, y);
            gr.LineTo (x, y + figure_size);
            gr.LineTo (x + figure_size, y + figure_size);
            gr.LineTo (x + figure_size / 2, y);
            gr.LineTo (x + figure_size / 2, y + figure_size);
            gr.Stroke ();

            gr.MoveTo (x + 0.04, y + 0.15);
            gr.ShowPangoText (numbers [(elements_group * group) + index * 2].ToString ());
            gr.MoveTo (x + 0.12, y + 0.15);

            if (question == true)
                gr.ShowPangoText ("?");
            else
                gr.ShowPangoText (numbers [(elements_group * group) + (index * 2) + 1].ToString ());
        }
 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 ();
 }
示例#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 ();
        }