2
* Copyright (C) 2009 Jordi Mas i Hernàndez <jmas@softcatala.org>
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; either version 2 of the
7
* License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* General Public License for more details.
14
* You should have received a copy of the GNU General Public
15
* License along with this program; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
22
using System.Collections.Generic;
28
public class AnalogiesPairOfWordsOptions : Analogies
30
static protected Dictionary <int, Analogy> analogies;
31
static protected ArrayListIndicesRandom analogies_indices;
32
static protected int analogies_index = 0;
34
public AnalogiesPairOfWordsOptions ()
36
if (analogies == null)
37
analogies = AnalogiesFactory. Get (Analogy.Type.PairOfWordsOptions);
40
public override string Name {
41
get { return Catalog.GetString ("Pair of words");}
44
public override ArrayListIndicesRandom Indices {
45
get { return analogies_indices; }
46
set { analogies_indices = value; }
49
public override int CurrentIndex {
50
get { return analogies_index; }
51
set { analogies_index = value; }
54
public override Dictionary <int, Analogy> List {
55
get { return analogies; }
58
public override string Question {
60
string str = string.Empty;
65
if (current.answers == null)
66
return current.question;
68
for (int n = 0; n < current.answers.Length; n++)
70
str+= GetPossibleAnswer (n);
72
if (n +1 < current.answers.Length) {
73
// Translators: this the separator used when concatenating possible options for answering verbal analogies
74
// For example: "Possible correct answers are: a, b, c, d."
75
str += Catalog.GetString (", ");
79
return String.Format (Catalog.GetString (
80
"Given the pair of words '{0}', which of the possible answers has the closest in relationship to the given pair? Answer {1}."),
86
public override void Initialize ()
90
if (current == null || current.answers == null)
93
right_answer = GetPossibleAnswer (current.right);
96
public override void Draw (CairoContextEx gr, int area_width, int area_height)
98
double x = DrawAreaX, y = DrawAreaY + 0.1;
100
base.Draw (gr, area_width, area_height);
102
if (current == null || current.answers == null || current.answers.Length <= 1)
105
gr.SetPangoLargeFontSize ();
107
gr.ShowPangoText (Catalog.GetString ("Possible answers are:"));
110
for (int n = 0; n < current.answers.Length; n++)
113
gr.ShowPangoText (String.Format ("{0}) {1}", GetPossibleAnswer (n), current.answers[n].ToString ()));