Esempio n. 1
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            base.Draw (gr, area_width, area_height, rtl);

            if (Current == null || Current.answers == null)
                return;

            gr.SetPangoLargeFontSize ();
            gr.MoveTo (0.1, DrawAreaY + 0.05);
            gr.ShowPangoText (Translations.GetString ("Choose one of the following:"));
        }
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double y = DrawAreaY + 0.1;

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

            if (Current == null || Current.answers == null)
                return;

            gr.SetPangoLargeFontSize ();
            gr.DrawTextCentered (0.5, y + 0.25,
                String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Words: {0}"), samples));
        }
Esempio n. 3
0
        static void DrawFigure(CairoContextEx gr, double x, double y, Figure figure)
        {
            switch (figure)
            {
            case Figure.Pentagon:
                gr.DrawPentagon(x, y, figure_size);
                break;

            case Figure.Circle:
                gr.Arc(x + figure_size / 2, y + (figure_size / 2), figure_size / 2, 0, 2 * Math.PI);
                break;

            case Figure.Triangle:
                gr.DrawEquilateralTriangle(x, y, figure_size);
                break;

            default:
                throw new InvalidOperationException("Invalid figure type");
            }
            gr.Stroke();
        }
Esempio n. 4
0
        private void DrawObject(CairoContextEx gr, int area_width, int area_height)
        {
            double x = DrawAreaX + 0.125, y = DrawAreaY + 0.1;

            for (int i = 0; i < showed; i++)
            {
                gr.MoveTo(x, y);
                gr.ShowPangoText(words[words_order[i]]);
                gr.Stroke();

                if ((i + 1) % 3 == 0)
                {
                    y += 0.2;
                    x  = DrawAreaX + 0.125;
                }
                else
                {
                    x += 0.25;
                }
            }
        }
Esempio n. 5
0
        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();
        }
Esempio n. 6
0
        static void DrawCircle(CairoContextEx gr, double x, double y, Color[] colors, int color_indice)
        {
            double dg;

            gr.Arc(x, y, radius, 0, 2 * Math.PI);
            gr.Stroke();

            gr.Save();
            for (int slice = 0; slice < total_slices; slice++)
            {
                dg = slice * (360 / total_slices);
                DrawSlice(gr, x, y, dg, colors [color_indice]);

                color_indice++;
                if (color_indice >= colors.Length)
                {
                    color_indice = 0;
                }
            }
            gr.Restore();
        }
Esempio n. 7
0
        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();
        }
Esempio n. 8
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double first_x, x, y;
            double figure_size = 0.07 + (0.01 * (5 - lines));
            double margin      = 0;

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

            // Figure 1
            margin = ((1.0 - (figure_size * lines * 2)) / 2);

            x = first_x = margin + (figure_size * lines / 2) + figure_size / 2;
            y = DrawAreaY + 0.2;
            for (int line = 0; line < lines + 1; line++)
            {
                for (int circles = 0; circles < line; circles++)
                {
                    gr.Arc(x, y, figure_size / 2, 0, 2 * Math.PI);
                    gr.Stroke();
                    x += figure_size;
                }
                x  = first_x = first_x - (figure_size / 2);
                y += figure_size;
            }

            // Figure 2
            first_x = margin + (figure_size * lines);
            y       = DrawAreaY + 0.2 + figure_size;
            for (int line = 0; line < lines; line++)
            {
                x = first_x = first_x + (figure_size / 2);
                for (int circles = 0; circles < lines - line; circles++)
                {
                    gr.Arc(x, y, figure_size / 2, 0, 2 * Math.PI);
                    gr.Stroke();
                    x += figure_size;
                }
                y += figure_size;
            }
        }
        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;
            }
        }
Esempio n. 10
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = DrawAreaX + 0.22, y = DrawAreaY + 0.2;
            double pos_x = x;
            double pos_y = y;

            Circle[] circles = null;

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

            circles = new Circle [] {
                new Circle(0.01, 0.06),
                new Circle(0.27, 0.06),
                new Circle(0.01, 0.21),
                new Circle(0.27, 0.21),
                new Circle(0.14, 0),
                new Circle(0.14, 0.29)
            };

            // Circle
            gr.Arc(pos_x + figure_size, pos_y + figure_size, figure_size, 0, 2 * Math.PI);
            gr.Stroke();

            const double point_size = 0.01;

            for (int i = 0; i < circles.Length; i++)
            {
                gr.Arc(x + point_size + circles[i].x, y + point_size + circles[i].y, point_size, 0, 2 * Math.PI);
                gr.Fill();
                gr.Stroke();
            }

            gr.MoveTo(x + circles[2].x + 0.01, y + circles[2].y + 0.01);
            gr.LineTo(x + circles[1].x + 0.01, y + circles[1].y + 0.01);
            gr.Stroke();

            gr.DrawTextCentered(pos_x + figure_size, pos_y + 0.08 + figure_size * 2,
                                ServiceLocator.Instance.GetService <ITranslations> ().GetString("Two people in the table sitting across each other"));
        }
Esempio n. 11
0
        private void DrawFigure(CairoContextEx gr, double x, double y, Face fig)
        {
            double space_x, space_y;
            string image;

            space_x = (rect_w - figure_size) / 2;
            space_y = (rect_h - figure_size) / 2;

            switch (fig)
            {
            case Face.FaceBoy1:
                image = "faceboy1.svg";
                break;

            case Face.FaceBoy2:
                image = "faceboy2.svg";
                break;

            case Face.FaceBoy3:
                image = "faceboy3.svg";
                break;

            case Face.FaceGirl1:
                image = "facegirl1.svg";
                break;

            case Face.FaceGirl2:
                image = "facegirl2.svg";
                break;

            case Face.FaceGirl3:
                image = "facegirl3.svg";
                break;

            default:
                throw new InvalidOperationException("Invalid value");
            }
            gr.DrawImageFromAssembly(image, x + space_x, y + space_y, figure_size, figure_size);
        }
Esempio n. 12
0
        static private void DrawSliceText(CairoContextEx gr, double x, double y, int slice, string str1, string str2, string str3)
        {
            double x0, y0, degrees;

            // Number more near to the center;
            degrees = radian * (slice * ((360 / total_slices)) + (360 / 12));
            x0      = 0.35 * radius * Math.Cos(degrees);
            y0      = 0.35 * radius * Math.Sin(degrees);
            gr.DrawTextCentered(x + x0, y + y0, str1);

            // Number opposite to the center and at the top
            degrees = radian * (slice * ((360 / total_slices)) + (360 / 24));
            x0      = 0.8 * radius * Math.Cos(degrees);
            y0      = 0.8 * radius * Math.Sin(degrees);
            gr.DrawTextCentered(x + x0, y + y0, str2);

            // Number opposite to the center and at the bottom
            degrees = radian * (slice * ((360 / total_slices)) + (360 / 8));
            x0      = 0.8 * radius * Math.Cos(degrees);
            y0      = 0.8 * radius * Math.Sin(degrees);
            gr.DrawTextCentered(x + x0, y + y0, str3);
        }
Esempio n. 13
0
        private void DrawTriangle(CairoContextEx gr, double x, double y, int index, bool question)
        {
            gr.MoveTo(x + figure_size / 2, y);
            gr.LineTo(x, y + figure_size);
            gr.LineTo(x + figure_size, y + figure_size);
            gr.LineTo(x + figure_size / 2, y);
            gr.LineTo(x + figure_size / 2, y + figure_size);
            gr.Stroke();

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

            if (question == true)
            {
                gr.ShowPangoText("?");
            }
            else
            {
                gr.ShowPangoText(numbers [(elements_group * group) + (index * 2) + 1].ToString());
            }
        }
Esempio n. 14
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            int    element;
            double x = DrawAreaX;
            double y = 0.05, pos_y;

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

            for (int i = 0; i < (Answer.Draw ? question_columns : question_columns - 1); i++)
            {
                element = question_indices [i];
                pos_y   = y;
                for (int n = 0; n < figures_column; n++)
                {
                    DrawFigure(gr, x, pos_y, figures [(n * question_columns) + element]);
                    pos_y += figure_size + space_height;
                }
                x += figure_size + space_width;
            }

            if (Answer.Draw == false)
            {
                gr.Save();
                gr.SetPangoFontSize(figure_size);
                for (int n = 0; n < figures_column; n++)
                {
                    gr.MoveTo(x, y - 0.02);
                    gr.ShowPangoText("?");
                    gr.Stroke();
                    y += figure_size + space_height;
                }
                gr.SetPangoNormalFontSize();
                gr.Restore();
            }

            gr.MoveTo(0.08, 0.45);
            gr.ShowPangoText(ServiceLocator.Instance.GetService <ITranslations> ().GetString("Choose one of the following:"));
            gr.Stroke();
        }
Esempio n. 15
0
        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();
        }
Esempio n. 16
0
        private void DrawSquare(CairoContextEx gr, double x, double y)
        {
            // XX
            // XX
            for (int i = 0; i < 2; i++)
            {
                if (quest1 [i] != X)
                {
                    gr.Rectangle(x + i * rect_witdh, y, rect_witdh, rect_height);
                    gr.FillGradient(x + i * rect_witdh, y, rect_witdh, rect_height, ColorForPortion(quest1 [i]));
                }
                gr.Rectangle(x + i * rect_witdh, y, rect_witdh, rect_height);
                gr.Stroke();

                if (quest1 [i + 2] != X)
                {
                    gr.Rectangle(x + i * rect_witdh, y + rect_height, rect_witdh, rect_height);
                    gr.FillGradient(x + i * rect_witdh, y + rect_height, rect_witdh, rect_height, ColorForPortion(quest1 [i + 2]));
                }
                gr.Rectangle(x + i * rect_witdh, y + rect_height, rect_witdh, rect_height);
                gr.Stroke();
            }
        }
Esempio n. 17
0
        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;
                }
            }
        }
Esempio n. 18
0
 private void DrawSquare(CairoContextEx gr, double x, double y, SquareColor [] colours, int index)
 {
     gr.Save();
     for (int column = 0; column < columns; column++)
     {
         for (int row = 0; row < rows; row++)
         {
             // if you want 2 schemes (primary or secundary colors)
             Color c = palette.Cairo(ColorPalette.Id.First + color_sheme * 3 + (int)colours[index + (columns * row) + column]);
             gr.Rectangle(x + row * rect_w, y + column * rect_h, rect_w, rect_h);
             gr.FillGradient(x + row * rect_w, y + column * rect_h, rect_w, rect_h, c);
         }
     }
     gr.Restore();
     for (int column = 0; column < columns; column++)
     {
         for (int row = 0; row < rows; row++)
         {
             gr.Rectangle(x + row * rect_w, y + column * rect_h, rect_w, rect_h);
             gr.Stroke();
         }
     }
 }
Esempio n. 19
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            StringBuilder sequence = new StringBuilder(64);

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

            gr.SetPangoLargeFontSize();

            for (int num = 0; num < max_num - 1; num++)
            {
                if (num == question)
                {
                    sequence.Append("?, ");
                }
                else
                {
                    sequence.Append(numbers[num]);
                    sequence.Append(", ");
                }
            }
            sequence.Append(numbers[max_num - 1]);
            gr.DrawTextCentered(0.5, DrawAreaY + 0.3, sequence.ToString());
        }
        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() : "?");
        }
Esempio n. 21
0
        private static void DrawAnswerFigures(CairoContextEx gr, double x, double y, int figure)
        {
            switch (figure)
            {
            case 0:
                //  XX
                // XX
                for (int i = 0; i < 2; i++)
                {
                    gr.Rectangle(x + i * rect_witdh, y, rect_witdh, rect_height);
                    gr.Rectangle(x + rect_witdh + i * rect_witdh, y - rect_height, rect_witdh, rect_height);
                }
                break;

            case 1:
                // X
                // X
                // X
                // X
                for (int i = 0; i < 4; i++)
                {
                    gr.Rectangle(x + 0.05, y - rect_height * i, rect_witdh, rect_height);
                }
                break;

            case 2:
                // XXX
                //  X
                for (int i = 0; i < 3; i++)
                {
                    gr.Rectangle(x + i * rect_witdh, y - rect_height, rect_witdh, rect_height);
                }
                gr.Rectangle(x + rect_witdh, y, rect_witdh, rect_height);
                break;
            }
            gr.Stroke();
        }
Esempio n. 22
0
        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.08;
            int          total = (full == true) ? (elements * 2) : elements;

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

            gr.DrawImageFromAssembly("balance.svg", x + 0.02, y - 0.08, 0.9, 0.25);
        }
		public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
		{
			int rows = 7, columns = 9;
			double rect_w = DrawAreaWidth / columns;
			double rect_h = DrawAreaHeight / rows;
			int first_column;
			string text;

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

			for (int row = 0; row < rows; row++)
			{
				for (int column = 0; column < columns; column++)
				{
					gr.Rectangle (DrawAreaX + column * rect_w, DrawAreaY + row * rect_h, rect_w, rect_h);
					gr.Stroke ();

					if (row >= lines.Length)
						continue;

					first_column = (columns - lines[row].TotalNumbers) / 2;

					if (column < first_column || column - first_column >= lines [row].TotalNumbers)
						continue;

					if (row + 1 == lines.Length && lines [row].IsMiddle (column - first_column))
						text = "?";
					else
						text = lines [row].GetNumber (column - first_column).ToString ();

					gr.DrawTextCentered (DrawAreaX + (column * rect_w) + rect_w / 2,
							DrawAreaY + (row * rect_h) + rect_h / 2,
							text.ToString());
				}
			}
		}
Esempio n. 24
0
            protected override bool OnDrawn(Cairo.Context cc)
            {
                if (!IsRealized)
                {
                    return(false);
                }

                int    w, h, nw, nh;
                double x = 0, y = 0;

                CairoContextEx cr = new CairoContextEx(cc.Handle);

                cr.PangoFontDescription = PangoContext.FontDescription;
                w = Window.Width;
                h = Window.Height;

                nh = nw = Math.Min(w, h);

                if (nw < w)
                {
                    x = (w - nw) / 2d;
                }

                if (nh < h)
                {
                    y = (h - nh) / 2d;
                }

                cr.Translate(x, y);
                cr.Scale(nw, nh);

                view.Draw(cr, nw, nh, Direction == Gtk.TextDirection.Rtl);

                ((IDisposable)cr).Dispose();
                return(true);
            }
            protected override bool OnExposeEvent(Gdk.EventExpose args)
            {
                if (!IsRealized)
                {
                    return(false);
                }

                int    w, h, nw, nh;
                double x = 0, y = 0;

                Cairo.Context  cc = Gdk.CairoHelper.Create(args.Window);
                CairoContextEx cr = new CairoContextEx(cc.Handle, this);

                args.Window.GetSize(out w, out h);

                nh = nw = Math.Min(w, h);

                if (nw < w)
                {
                    x = (w - nw) / 2d;
                }

                if (nh < h)
                {
                    y = (h - nh) / 2d;
                }

                cr.Translate(x, y);
                cr.Scale(nw, nh);

                view.Draw(cr, nw, nh, Direction == Gtk.TextDirection.Rtl);

                ((IDisposable)cc).Dispose();
                ((IDisposable)cr).Dispose();
                return(base.OnExposeEvent(args));
            }
Esempio n. 26
0
		private void DrawAllFigures (CairoContextEx gr, double x, double y)
		{
			int col = 1, fig;
			double org_x = x;

			DrawGrid (gr, x, y);
			gr.Color = new Color (DefaultDrawingColor.R, DefaultDrawingColor.G, DefaultDrawingColor.B, alpha);
			for (int figure = 0; figure < figures.Count; figure++, col++)
			{
				fig = figures[figure];
				if (fig >= figures_active) 
					fig -= figures_active;

				DrawFigure (gr, x, y, (Face) fig);

				if (col >= columns) {
					col = 0;
					y += rect_h;
					x = org_x;
				} else {
					x += rect_w;
				}
			}
		}
Esempio n. 27
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"));
        }
Esempio n. 28
0
        public override void DrawPossibleAnswers(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double x = DrawAreaX, y = DrawAreaY + 0.1;
            int    pos = 0;

            gr.Color = new Color(DefaultDrawingColor.R, DefaultDrawingColor.G, DefaultDrawingColor.B, 1);

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

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

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

                if ((pos + 1) % 3 == 0)
                {
                    y += 0.2;
                    x  = DrawAreaX;
                }
                else
                {
                    x += 0.30;
                }
                pos++;
            }
        }
Esempio n. 29
0
        static private void DrawAnswerFigures(CairoContextEx gr, double x, double y, int figure)
        {
            gr.Rectangle(x, y, sub_figure, sub_figure);

            switch (figure)
            {
            case 0:
                gr.MoveTo(x, y + sub_figure);
                gr.LineTo(x + sub_figure / 2, y + sub_figure / 2);
                gr.LineTo(x + sub_figure, y + sub_figure);
                break;

            case 1:
                gr.MoveTo(x, y + sub_figure);
                gr.LineTo(x + sub_figure, y);
                break;

            case 2:
                gr.MoveTo(x, y);
                gr.LineTo(x + sub_figure, y + sub_figure);
                break;
            }
            gr.Stroke();
        }
Esempio n. 30
0
 public override void DrawObjectToMemorize(CairoContextEx gr, int area_width, int area_height, bool rtl)
 {
     base.DrawObjectToMemorize(gr, area_width, area_height, rtl);
     DrawObject(gr);
 }
Esempio n. 31
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.02);
            gr.ShowPangoText("a");
            gr.Stroke();

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

            gr.MoveTo(x + w + 0.02, y - 0.02);
            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.04);
            gr.ShowPangoText("g");
            gr.Stroke();

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

            gr.MoveTo(x + w + 0.02, y + h + 0.04);
            gr.ShowPangoText("i");
            gr.Stroke();
        }
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            double y = DrawAreaY;

            if (Current == null || Current.answers == null || Current.answers.Length <= 1)
                return;

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

            gr.SetPangoLargeFontSize ();

            gr.MoveTo (0.1, y + 0.12);
            gr.ShowPangoText (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Choose one of the following:"));
            gr.Stroke ();

            gr.DrawTextCentered (0.5, y,
                String.Format (ServiceLocator.Instance.GetService <ITranslations> ().GetString ("Words: {0}"), samples));
        }
Esempio n. 33
0
        public override void Draw(CairoContextEx gr, int area_width, int area_height, bool rtl)
        {
            base.Draw (gr, area_width, area_height, rtl);

            DrawObjects (gr, game.DrawingObjects, null); // Draw objects shared by all variants

            if (game.Variants.Count > 0)
                DrawObjects (gr, game.Variants[current.Variant].DrawingObjects, null); // Draw variant specific objects
        }
Esempio n. 34
0
        void DrawObjects(CairoContextEx gr, DrawingObject [] drawing_objects, int? option)
        {
            if (drawing_objects == null)
                return;

            foreach (DrawingObject draw_object in drawing_objects)
            {
                if (draw_object is OptionDrawingObject)
                    continue;

                if (draw_object is TextDrawingObject)
                {
                    string text;
                    TextDrawingObject draw_string = draw_object as TextDrawingObject;

                    text = CatalogGetString (draw_string.Text);
                    text = ReplaceVariables (text);

                    switch (draw_string.Size) {
                    case TextDrawingObject.Sizes.Small:
                        gr.SetPangoFontSize (0.018);
                        break;
                    case TextDrawingObject.Sizes.Medium:
                        gr.SetPangoNormalFontSize (); // 0.022
                        break;
                    case TextDrawingObject.Sizes.Large:
                        gr.SetPangoLargeFontSize (); // 0.0325
                        break;
                    case TextDrawingObject.Sizes.XLarge:
                        gr.SetPangoFontSize (0.06);
                        break;
                    case TextDrawingObject.Sizes.XXLarge:
                        gr.SetPangoFontSize (0.08);
                        break;
                    default:
                        throw new InvalidOperationException ("Invalid value");
                    }

                    if (draw_string.Centered) {
                        gr.DrawTextCentered (draw_string.X, draw_string.Y, text);
                    } else {
                        gr.MoveTo (draw_string.X, draw_string.Y);
                        if (option == null)
                            gr.ShowPangoText (text);
                        else
                            gr.ShowPangoText (GetOptionPrefix (text, (int) option));

                        gr.Stroke ();
                    }
                }
                else if (draw_object is ImageDrawingObject)
                {
                    ImageDrawingObject image = draw_object as ImageDrawingObject;

                    if (String.IsNullOrEmpty (image.Filename) == false)
                    {
                        string dir;
                        IConfiguration config;

                        config = ServiceLocator.Instance.GetService <IConfiguration> ();
                        dir = config.Get <string> (ConfigurationKeys.GamesGraphics);

                        gr.DrawImageFromFile (Path.Combine (dir, image.Filename),
                            image.X, image.Y, image.Width, image.Height);
                    }
                }
            }
        }
 private static void Fill(CairoContextEx gr, double x, double y, double w, double h)
 {
     gr.Rectangle(x, y, w, h);
     gr.FillGradient(x, y, w, h);
 }