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 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");
        }
示例#3
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:"));
        }
示例#5
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)
        {
            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:"));
        }
示例#7
0
        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, ServiceLocator.Instance.GetService <ITranslations> ().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)
        {
            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:"));
        }
示例#9
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:"));
        }
示例#10
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));
        }
        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 () : "?");
        }
示例#12
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 ();
            }
        }
示例#13
0
        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"));
        }
        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);
            }
        }
示例#15
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++;
            }
        }
示例#16
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            const double size = 0.05;
            const double radian = Math.PI / 180;
            const int degrees = -45;
            const double radius = 0.035;
            const double size_y = 0.025;

            double x = DrawAreaX + 0.1;
            double y = DrawAreaY + 0.3;
            double x0, y0, offset_y;
            double offset_x = 0;

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

            x = 1 - (2 * DrawAreaX) - (columns * size * 1.5);
            x = DrawAreaX + x /2;

            // Front face
            for (int pos_y = 0; pos_y < rows; pos_y++)
            {
                //  |
                //  |
                //
                gr.MoveTo (x, y + (pos_y * size));
                gr.LineTo (x, y + ((pos_y + 1) * size));
                gr.Stroke ();

                for (int pos_x = 0; pos_x < columns; pos_x++)
                {
                    //  ---|
                    //     |
                    //
                    gr.MoveTo (x + (size * pos_x) , y + (pos_y * size));
                    gr.LineTo (x + (size * (pos_x + 1)), y + (pos_y * size));
                    gr.LineTo (x + (size * (pos_x + 1)), y + (pos_y + 1) * size);
                    gr.Stroke ();
                }
            }

            gr.MoveTo (x , y + (rows * size));
            gr.LineTo (x + (columns * size) , y + (rows * size));
            gr.Stroke ();

            // Back face
            for (int pos_y = 0; pos_y < rows; pos_y++)
            {
                offset_x = (0.025 * pos_y);

                //  |
                //  |
                //
                gr.MoveTo (x + offset_x, y - (pos_y * size_y));
                gr.LineTo (x + offset_x + 0.025, y - ((pos_y + 1)  * size_y));
                gr.Stroke ();

                for (int pos_x = 0; pos_x < columns; pos_x++)
                {
                    gr.MoveTo (x + offset_x + (size * pos_x) , y - (pos_y * size_y));
                    gr.LineTo (x + offset_x + (size * (pos_x + 1)), y - (pos_y * size_y));
                    gr.LineTo (x + offset_x +  0.025 + (size * (pos_x + 1)), y - (pos_y + 1) * size_y);
                    gr.Stroke ();
                }
            }

            offset_x = (0.025 * columns);
            gr.MoveTo (x + offset_x, y - (rows * size_y));
            gr.LineTo (x + offset_x + (size * columns) , y - (rows * size_y));
            gr.Stroke ();

            // Lateral face
            for (int pos_y = 0; pos_y < rows; pos_y++)
            {
                for (int pos_x = 0; pos_x < columns; pos_x++)
                {
                    offset_x = (size * columns) + (0.025 * pos_x);
                    offset_y = size_y * pos_x;

                    gr.MoveTo (x + offset_x, y - offset_y + (pos_y * size));
                    gr.LineTo (x + offset_x, y - offset_y + (pos_y + 1) * size);
                    x0 = radius * Math.Cos (degrees * radian);
                    y0 = radius * Math.Sin (degrees * radian);

                    gr.LineTo (x + offset_x + x0, y - offset_y + y0 +  (pos_y + 1) * size);
                    gr.Stroke ();
                }
            }

            offset_x = (size * columns) + (0.025 * columns);
            offset_y = size_y * rows;
            gr.MoveTo (x + offset_x, y - offset_y);
            gr.LineTo (x + offset_x, y - offset_y + (rows * size));
            gr.Stroke ();
        }
示例#17
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 ();
        }
示例#18
0
        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"));
        }
        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;
            }
        }
        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 ();
        }
示例#21
0
 private static void DrawLine(CairoContextEx gr, double x, double y, double w, double h)
 {
     gr.MoveTo (x, y);
     gr.LineTo (x + w, y + h);
     gr.Stroke ();
 }
示例#22
0
        void DrawQuestion(CairoContextEx gr, double x, double y)
        {
            gr.Rectangle (x, y, width, height);
            gr.Stroke ();

            gr.MoveTo (x, y + 0.1);
            gr.LineTo (x + width, y + 0.1);  // Container square
            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 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 ();
        }
示例#24
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 ();
        }
示例#25
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 ();
                }
            }
        }
示例#26
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;
            }
        }
        private static void DrawSlice(CairoContextEx gr, double x, double y)
        {
            double degrees, x1, y1;

            degrees = 0;
            gr.MoveTo (x, y);
            x1 = x + radius * Math.Cos (degrees);
            y1 = y + radius * Math.Sin (degrees);
            gr.LineTo (x1, y1);
            gr.Stroke ();

            degrees = radian * 60;
            gr.MoveTo (x, y);
            x1 = x + radius * Math.Cos (degrees);
            y1 = y + radius * Math.Sin (degrees);
            gr.LineTo (x1, y1);
            gr.Stroke ();

            gr.Arc (x, y, radius, 0, radian * 60);
            gr.Stroke ();
        }
示例#28
0
文件: Memory.cs 项目: GNOME/gbrainy
        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 ();
        }
        static void DrawFigure(CairoContextEx gr, double x, double y, Figures figure)
        {
            switch (figure) {
            case Figures.FigureA:
                double x105, y105;

                x105 = figure_size * Math.Cos (105 * Math.PI / 180);
                y105 = figure_size * Math.Sin (105 * Math.PI / 180);
                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);
                break;

            case Figures.FigureB:
                gr.Rectangle (x, y, figure_size * 0.8, figure_size * 1.2);
                break;

            case Figures.FigureC:
                gr.MoveTo (x, y);
                gr.LineTo (x + figure_size * 1.3, y);
                gr.LineTo (x + figure_size * 1.3, y + figure_size);
                gr.LineTo (x , y + figure_size);
                gr.LineTo (x, y);
                break;

            case Figures.FigureD:
                gr.MoveTo (x + 0.03, y);
                gr.LineTo (x + figure_size - 0.03, y);
                gr.LineTo (x + figure_size, y + figure_size);
                gr.LineTo (x , y + figure_size);
                gr.LineTo (x + 0.03, y);
                break;

            case Figures.FigureE:
                gr.MoveTo (x + 0.03, y);
                gr.LineTo (x + figure_size - 0.04, y);
                gr.LineTo (x + figure_size - 0.04, y + figure_size * 1.2);
                gr.LineTo (x , y + figure_size  * 1.2);
                gr.LineTo (x + 0.03, y);
                break;

            case Figures.FigureF:
                gr.MoveTo (x, y);
                gr.LineTo (x, y + figure_size);
                gr.LineTo (x + figure_size, y + figure_size);
                gr.LineTo (x + figure_size - 0.02, y);
                gr.LineTo (x, y);
                break;
            }

            gr.Stroke ();
        }
示例#30
0
        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)
        {
            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;
            }
        }
示例#32
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();
            }
        }