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");
        }
Beispiel #3
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);
        }
Beispiel #4
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)
        {
            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 () : "?");
        }
Beispiel #6
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;
            }
        }
Beispiel #7
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 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;
            }
        }
 private static void DrawFigure(CairoContextEx gr, double x, double y, Figures figure)
 {
     switch (figure) {
     case Figures.TriangleA:
         gr.DrawEquilateralTriangle (x, y, figure_size);
         break;
     case Figures.TriangleB:
         gr.MoveTo (x, y);
         gr.LineTo (x, y + figure_size);
         gr.LineTo (x + figure_size, y);
         gr.LineTo (x, y);
         gr.Stroke ();
         break;
     case Figures.TriangleC:
         gr.MoveTo (x, y);
         gr.LineTo (x, y + figure_size);
         gr.LineTo (x + figure_size, y + figure_size);
         gr.LineTo (x, y);
         gr.Stroke ();
         break;
     case Figures.Square:
         gr.Rectangle (x, y, figure_size, figure_size);
         gr.Stroke ();
         break;
     case Figures.LongRectangle:
         gr.Rectangle (x, y + figure_size / 2, figure_size, figure_size / 2);
         gr.Stroke ();
         break;
     case Figures.LongRectangleUp:
         gr.Rectangle (x, y, figure_size, figure_size / 2);
         gr.Stroke ();
         break;
     case Figures.Diamon:
         gr.DrawDiamond (x, y, figure_size);
         break;
     case Figures.TriangleD:
         gr.MoveTo (x, y);
         gr.LineTo (x, y + figure_size * 0.7);
         gr.LineTo (x + figure_size * 0.7, y + figure_size * 0.7);
         gr.LineTo (x, y);
         gr.Stroke ();
         break;
     }
 }
        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 ();
        }
Beispiel #11
0
        private void DrawSection(CairoContextEx gr, double x, double y)
        {
            double w =  width / 2, h = height / 2;
            double pos_x = x, pos_y = y;
            for (int i = 0; i < 5; i++) {
                gr.MoveTo (pos_x, pos_y + h / 5);
                gr.LineTo (pos_x + w, pos_y + h / 5);
                gr.Stroke ();
                pos_y += h / 5;
            }

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

            gr.Save ();
            gr.Color = new Cairo.Color (0.90, 0.90, 0.90);
            for (int i = 0; i < partial_zones; i++) {
                Fill (gr, x + line_width, line_width + y,
                    (w / 2) - (line_width * 2) , (h / 5) - (line_width * 2));
                Fill (gr, x + (w / 2) + line_width * 2, line_width + y,
                    (w / 2) - (line_width * 4) , (h / 5) - (line_width * 2));
                y += h / 5;
            }
            gr.Restore ();
        }
Beispiel #12
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            string train_right = "train_right.svg";
            string train_left = "train_left.svg";

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

            switch (gametype)
            {
            case GameType.Overtake:
                gr.DrawImageFromAssembly (train_right, 0, 0.1, 0.5, 0.55);
                gr.MoveTo (0.1, 0.45);
                gr.LineTo (0.9, 0.45);
                gr.Stroke ();

                gr.DrawImageFromAssembly (train_right, 0.5, 0.1, 0.5, 0.55);
                break;

            case GameType.Meet:
                gr.DrawImageFromAssembly (train_right, 0, 0.1, 0.5, 0.55);
                gr.MoveTo (0.1, 0.45);
                gr.LineTo (0.9, 0.45);
                gr.Stroke ();

                gr.DrawImageFromAssembly (train_left, 0.55, 0.3, 0.5, 0.55);
                gr.MoveTo (0.1, 0.65);
                gr.LineTo (0.9, 0.65);
                gr.Stroke ();
                break;

            case GameType.Apart:
                gr.DrawImageFromAssembly (train_right, 0.35, 0.1, 0.5, 0.55);
                gr.MoveTo (0.1, 0.45);
                gr.LineTo (0.9, 0.45);
                gr.Stroke ();

                gr.DrawImageFromAssembly (train_left, 0.15, 0.3, 0.5, 0.55);
                gr.MoveTo (0.1, 0.65);
                gr.LineTo (0.9, 0.65);
                gr.Stroke ();
                break;
            default:
                throw new Exception ("Unexpected value");
            }
        }
Beispiel #13
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 ();
        }
Beispiel #14
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 ();
 }
        void DrawGrid(CairoContextEx cr, double x, double y)
        {
            // Draw Axis
            cr.MoveTo (x, y);
            cr.LineTo (x, y + grid_height);
            cr.LineTo (x + grid_width, y + grid_height);
            cr.Stroke ();

            cr.Save ();
            cr.Color = axis_color;
            cr.LineWidth = 0.001;

            for (double line_y = y; line_y < grid_height + y; line_y += grid_height / 10) {
                cr.MoveTo (x, line_y);
                cr.LineTo (x + grid_width, line_y);
                cr.Stroke ();
            }

            cr.Restore ();

            // Draw score scale
            int pos = 100;
            for (double line_y = y; line_y < grid_height + y; line_y += grid_height / 10) {
                cr.DrawTextAlignedRight (x- 0.01, line_y, String.Format ("{0}", pos));
                pos -= 10;
            }
        }
Beispiel #16
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 ();
        }
        static void DrawSlice(CairoContextEx gr, double x, double y, double dg, Color color)
        {
            double x1, y1, smallest_x, smallest_y, degrees;

            smallest_x = x;
            smallest_y = y;
            degrees = radian * (60 + dg);
            gr.MoveTo (x, y);
            x1 = x + radius * Math.Cos (degrees);
            y1 = y + radius * Math.Sin (degrees);
            gr.LineTo (x1, y1);
            if (x1 < smallest_x) smallest_x = x1;
            if (y1 < smallest_y) smallest_y = y1;

            degrees = dg * radian;
            gr.MoveTo (x, y);
            x1 = x + radius * Math.Cos (degrees);
            y1 = y + radius * Math.Sin (degrees);
            gr.LineTo (x1, y1);
            if (x1 < smallest_x) smallest_x = x1;
            if (y1 < smallest_y) smallest_y = y1;

            gr.Arc (x, y, radius, dg * radian, radian * (60 + dg));
            gr.FillGradient (smallest_x, smallest_y, radius, radius, color);
            gr.Stroke ();
        }
        void DrawQuestion(CairoContextEx cr, int height, double max_width)
        {
            if (String.IsNullOrEmpty (Question) == true)
                return;

            cr.DrawStringWithWrapping (text_margin, text_margin, Question, max_width);
            cr.Stroke ();

            double w, h, question_high_scaled;
            cr.MeasureString (Question, max_width, true, out w, out h);

            // We use a minimum hight, but if the text is longer (L10 versions) move the line as needed
            question_high_scaled = Math.Max (question_high / (double) height, h);
            cr.LineWidth = 0.002;
            cr.MoveTo (0.01, question_high_scaled + 0.01);
            cr.LineTo (0.99, question_high_scaled + 0.01);
            cr.Stroke ();
        }
        public void DrawBalance(CairoContextEx gr, double x, double y, int index, bool full)
        {
            const double width = 0.5;
            double fig_x = x + 0.1, fig_y = y - 0.11;
            int total = (full == true) ? (elements * 2) : elements;

            gr.Rectangle (x + 0.05, y - 0.12, 0.38, 0.08);
            gr.Stroke ();

            gr.Rectangle (x + 0.5, y - 0.12, 0.38, 0.08);
            gr.Stroke ();

            for (int i = 0; i < total; i++) {
                switch (balances[i + index]) {
                case 1:
                    gr.DrawEquilateralTriangle (fig_x, fig_y, 0.05);
                    break;
                case 2:
                    gr.Arc (fig_x + (0.05 / 2), fig_y + (0.05 / 2) + 0.003, (0.05 / 2), 0, 2 * Math.PI);
                    gr.Stroke ();
                    break;
                case 3:
                    gr.Rectangle (fig_x, fig_y + 0.005, 0.045, 0.045);
                    gr.Stroke ();
                    break;
                }

                if (i == elements - 1)
                    fig_x = x + 0.54;
                else
                    fig_x += 0.07;
            }

            x += 0.2;
            y += 0.01;
            gr.MoveTo (x, y);
            gr.LineTo (x + width, y);
            gr.LineTo (x + width, y - 0.05);
            gr.Stroke ();

            gr.MoveTo (x , y);
            gr.LineTo (x , y - 0.05);
            gr.Stroke ();

            gr.DrawEquilateralTriangle (x + (width / 2) - 0.04, y, 0.08);
            gr.Stroke ();
        }
Beispiel #20
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, Translations.GetString ("Time left"));
            gr.Stroke ();

            gr.Save ();
            gr.Color = new Color (0, 0, 0);
            gr.MoveTo (x, y);
            gr.LineTo (x, y + height);
            gr.LineTo (x + width, y + height);
            gr.LineTo (x + width, y);
            gr.LineTo (x, y);
            gr.Stroke ();

            x+= w;
            y+= h;
            width -= w * 2;
            height -= h * 2;
            y += height * (100 - percentage) / 100;
            height *= percentage / 100;

            if (gradient == null) {
                gradient = new LinearGradient (x, y, x + width, y + height);
                gradient.AddColorStop (0, new Color (1, 0, 0, 1));
                gradient.AddColorStop (1, new Color (0.2, 0, 0, 1));
            }

            gr.Source = gradient;
            gr.MoveTo (x, y);
            gr.LineTo (x, y + height);
            gr.LineTo (x + width, y + height);
            gr.LineTo (x + width, y);
            gr.LineTo (x, y);
            gr.FillPreserve ();
            gr.Stroke ();
            gr.Restore ();
        }
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            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 ();
        }
        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;
        }
        public void DrawFigure(CairoContextEx gr, double x, double y, bool [] puzzle, int index)
        {
            double pos_x = x, pos_y = y;
            double square_size = figure_size / lines;
            double center_square = square_size / 2;
            double radius_square = (square_size - (LineWidth *2)) / 2.5;

            gr.Rectangle (pos_x, pos_y, figure_size, figure_size);
            gr.Stroke ();

            for (int line = 0; line < lines - 1; line++) // Horizontal
            {
                pos_y += square_size;
                gr.MoveTo (pos_x, pos_y);
                gr.LineTo (pos_x + figure_size, pos_y);
                gr.Stroke ();
            }

            pos_y = y;
            for (int column = 0; column < columns - 1; column++) // Vertical
            {
                pos_x += square_size;
                gr.MoveTo (pos_x, pos_y);
                gr.LineTo (pos_x, pos_y + figure_size);
                gr.Stroke ();
            }

            pos_y = y + center_square;
            pos_x = x + center_square;

            for (int line = 0; line < lines; line++) // Circles
            {
                for (int column = 0; column < columns; column++)
                {
                    if (puzzle[index + (columns * line) + column] == false)
                        continue;

                    gr.Arc (pos_x + (square_size * column), pos_y, radius_square, 0, 2 * Math.PI);
                    gr.Fill ();
                    gr.Stroke ();
                }
                pos_y += square_size;
            }
        }
Beispiel #24
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"));
        }
        void DrawLines(CairoContextEx cr, double x, double y)
        {
            double px, py;
            double ratio;
            int pos;

            if (history.Games.Count == 0)
                return;

            ratio = grid_width / (history.Games.Count - 1);

            if (ShowLogic) {
                cr.Color = logic_color;
                cr.MoveTo (x, grid_height - (grid_height * history.Games[0].LogicScore / 100));

                pos = 1;
                for (int i = 1; i < history.Games.Count; i++)
                {
                    if (history.Games[i].LogicScore < 0)
                        continue;

                    px = x + (ratio * pos);
                    py = y + grid_height - (grid_height * history.Games[i].LogicScore / 100);
                    cr.LineTo (px, py);
                    pos++;
                }
                cr.Stroke ();
            }

            if (ShowCalculation) {
                cr.Color = math_color;
                cr.MoveTo (x, grid_height - (grid_height * history.Games[0].MathScore / 100));

                pos = 1;
                for (int i = 1; i < history.Games.Count; i++)
                {
                    if (history.Games[i].MathScore < 0)
                        continue;

                    px = x + (ratio * pos);
                    py = y + grid_height - (grid_height * history.Games[i].MathScore / 100);
                    cr.LineTo (px, py);
                    pos++;
                }
                cr.Stroke ();
            }

            if (ShowMemory) {
                cr.Color = memory_color;
                cr.MoveTo (x, grid_height - (grid_height * history.Games[0].MemoryScore / 100));

                pos = 1;
                for (int i = 1; i < history.Games.Count; i++)
                {
                    if (history.Games[i].MemoryScore < 0)
                        continue;

                    px = x + (ratio * pos);
                    py = y + grid_height - (grid_height * history.Games[i].MemoryScore / 100);
                    cr.LineTo (px, py);
                    pos++;
                }
                cr.Stroke ();
            }

            if (ShowVerbal) {
                cr.Color = verbal_color;
                cr.MoveTo (x, grid_height - (grid_height * history.Games[0].VerbalScore / 100));

                pos = 1;
                for (int i = 1; i < history.Games.Count; i++)
                {
                    if (history.Games[i].VerbalScore < 0)
                        continue;

                    px = x + (ratio * i);
                    py = y + grid_height - (grid_height * history.Games[i].VerbalScore / 100);
                    cr.LineTo (px, py);
                    pos++;
                }
                cr.Stroke ();
            }

            if (ShowTotal) {
                cr.Color = total_color;
                cr.MoveTo (x, grid_height - (grid_height * history.Games[0].TotalScore / 100));

                pos = 1;
                for (int i = 1; i < history.Games.Count; i++)
                {
                    if (history.Games[pos].TotalScore < 0)
                        continue;

                    px = x + (ratio * pos);
                    py = y + grid_height - (grid_height * history.Games[i].TotalScore / 100);
                    cr.LineTo (px, py);
                    pos++;
                }
                cr.Stroke ();
            }
        }
Beispiel #26
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 ();
                }
            }
        }
Beispiel #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 ();
        }
        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 ();
        }
        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 ());
        }
        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 ();
        }
        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);
            }
        }