public Teacher(MapControl control, InputBox inputBox, HelpControl helpControl) { //http://www.thedailybeast.com/articles/2014/07/12/repetition-doesn-t-work-better-ways-to-train-your-memory.html this.control = control; this.inputBox = inputBox; this.helpControl = helpControl; inputBox.OnInput += OnInput; inputBox.OnNext += OnNext; inputBox.OnPlayAgain += OnPlayAgain; random = new Random(); history = new Dictionary <DateTime, Statistic[]>(); soundHandle = new ManualResetEvent(true); }
public void LoadData(MapData mapData, InputBox input, HelpControl help) { StopHighlighting(); this.mapData = mapData; if (mapData != null && !Resizing) { string curDir = Environment.CurrentDirectory; string imageFile = Path.Combine(curDir, "images", mapData.File); if (!File.Exists(imageFile)) { MessageBox.Show("Missing map image file.", "Missing Files", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { context = new Image <Bgra, byte>(imageFile); data = context.Clone(); } catch (Exception ex) { MessageBox.Show(string.Format("Error = {0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } graphics = new IGraphics[mapData.Countries]; for (int i = 0; i < mapData.Countries; i++) { IGraphics type; if (mapData.CountryTypes[i] == typeof(EllipseGraphics)) { type = (IGraphics)Activator.CreateInstance(mapData.CountryTypes[i], new object[] { this, mapData.CountryPoints[i] }); } else if (mapData.CountryTypes[i] == typeof(FillGraphics)) { type = (IGraphics)Activator.CreateInstance(mapData.CountryTypes[i], new object[] { this, mapData.CountryPoints[i] }); } else { type = null; } graphics[i] = type; if (!graphics[i].Init()) { MessageBox.Show(string.Format("Invalid graphics for (name={0}:index={1})", mapData.CountryNames[i], i), "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } helpControl = help; if (teacher == null) { teacher = new Teacher(this, input, help); } help.LoadData(mapData); teacher.Load(mapData); teacher.LoadUserData(); Invalidate(); } }