void DrawAnswer(CairoContextEx gr, double x, double y) { ColorPalette palette = new ColorPalette (Translations); gr.Save (); // A full sized square of paper gr.Color = palette.Cairo (ColorPalette.Id.Yellow); gr.Rectangle (x, y, width, height); gr.Fill (); gr.Stroke (); // 3/4 of the whole size square of paper in the bottom right corner gr.Color = palette.Cairo (ColorPalette.Id.Blue); double w = 3d/4d * width; double h = 3d/4d * height; gr.Rectangle (x + (width - w), y + (height - h), w, h); gr.Fill (); gr.Stroke (); // 3/4 square of paper in the top left corner gr.Color = palette.Cairo (ColorPalette.Id.Green); gr.Rectangle (x, y, 3d/4d * width, 3d/4d * height); gr.Fill (); gr.Stroke (); // 1/4 square of paper in the top left corner gr.Color = palette.Cairo (ColorPalette.Id.Red); gr.Rectangle (x, y, 1d/4d * width, 1d/4d * height); gr.Fill (); gr.Stroke (); gr.Restore (); }
protected override void Initialize() { ArrayListIndicesRandom random_indices = new ArrayListIndicesRandom (total_slices); Color clr; cp = new ColorPalette (); Answer.CheckAttributes |= GameAnswerCheckAttributes.MultiOption | GameAnswerCheckAttributes.IgnoreSpaces; cercle_colors = new Color [total_slices]; badcercle_colors = new Color [total_slices]; for (int i = 0; i < total_slices; i++) { cercle_colors [i] = cp.Cairo (i); badcercle_colors [i] = cp.Cairo (i); } // Correct answer random_indices.Initialize (); clr = badcercle_colors [random_indices[0]]; badcercle_colors [random_indices[0]] = badcercle_colors [random_indices[1]]; badcercle_colors [random_indices[1]] = clr; // Create random color order for the session start_indices = new int [circles]; for (int i = 0; i < circles; i++) start_indices[i] = (random_indices[i]); ans_pos = random.Next (circles); Answer.SetMultiOptionAnswer (ans_pos, Answer.GetFigureName (ans_pos)); const double text_offset = 0.04; const double witdh_used = 0.9; // Total width used for drawing all the figures const double margin = 0.1 / circles / 2; const double box_size = witdh_used / circles; double y; HorizontalContainer container; DrawableArea drawable_area; Color [] colors; y = DrawAreaY + 0.1 + (radius / 2); container = new HorizontalContainer (0.05, y, witdh_used, box_size); AddWidget (container); circle_parameters = new CircleParameters [circles]; for (int i = 0; i < circles; i++) { if (ans_pos == i) colors = badcercle_colors; else colors = cercle_colors; circle_parameters [i] = new CircleParameters (colors); drawable_area = new DrawableArea (box_size, box_size); drawable_area.SelectedArea = new Rectangle ((box_size - box_size) / 2, 0, box_size, box_size); drawable_area.Data = i; drawable_area.DataEx = Answer.GetMultiOption (i); drawable_area.DrawEventHandler += delegate (object sender, DrawEventArgs e) { int idx = (int) e.Data; CircleParameters circle = circle_parameters [idx]; double x1, y1; x1 = y1 = radius + margin; DrawCircle (e.Context, x1, y1, circle.Colors, start_indices [idx]); e.Context.DrawTextCentered (e.Width / 2, box_size + text_offset, Answer.GetFigureName (idx)); e.Context.Stroke (); }; container.AddChild (drawable_area); } }