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;
27
using gbrainy.Core.Libraries;
29
namespace gbrainy.Core.Main.Verbal
31
public class AnalogiesPairOfWordsCompare : Analogies
33
static protected Dictionary <int, Analogy> analogies;
34
static protected ArrayListIndicesRandom analogies_indices;
35
static protected int analogies_index = 0;
37
string samples, sample;
39
public AnalogiesPairOfWordsCompare ()
41
if (analogies == null)
42
analogies = AnalogiesFactory. Get (Analogy.Type.PairOfWordsCompare);
45
public override string Name {
46
get { return Catalog.GetString ("Pair of words compare");}
49
public override ArrayListIndicesRandom Indices {
50
get { return analogies_indices; }
51
set { analogies_indices = value; }
54
public override int CurrentIndex {
55
get { return analogies_index; }
56
set { analogies_index = value; }
59
public override Dictionary <int, Analogy> List {
60
get { return analogies; }
63
public override string Question {
68
if (current.answers == null)
69
return current.question;
71
return String.Format (Catalog.GetString (
72
"Given the pair of words below, which word has the closest relationship to '{0}'?"),
77
public override void Initialize ()
81
if (current == null || current.answers == null)
86
items = current.question.Split (AnalogiesFactory.Separator);
88
if (items.Length == 2)
89
sample = items [1].Trim ();
91
sample = string.Empty;
93
samples = items [0].Trim ();
94
right_answer = current.answers [current.right];
97
public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
99
double y = DrawAreaY + 0.1;
101
base.Draw (gr, area_width, area_height, rtl);
103
if (current == null || current.answers == null)
106
gr.SetPangoLargeFontSize ();
107
gr.DrawTextCentered (0.5, y + 0.25,
108
String.Format (Catalog.GetString ("Words: {0}"), samples));