public override void Start(IPracticeWindow owner) { base.Start(owner); GameArea.Resize += OnGameAreaResize; // State rounds = new List <IList <Attempt> >(); StartRound(); // UI var form = GameArea.FindForm(); var formFont = form != null ? form.Font : SystemFonts.DefaultFont; var fontFamily = formFont.FontFamily; font = new Font(fontFamily, 24); smallFont = new Font(fontFamily, 16); extraSmallFont = new Font(fontFamily, 12); scoreFont = new Font(fontFamily, 16); phrase = new Label { AutoSize = true, BackColor = Color.Transparent, Font = font }; answer = new Label { AutoSize = true, BackColor = Color.Transparent, Font = font }; scoreLabel = new Label { AutoSize = true, BackColor = Color.Transparent, Font = scoreFont, Dock = DockStyle.Bottom, TextAlign = ContentAlignment.BottomRight }; history = new Label { AutoSize = true, BackColor = Color.Transparent, Font = extraSmallFont, Dock = DockStyle.Top, TextAlign = ContentAlignment.MiddleLeft }; translation = new TextBox { Font = font }; affirmation = new TextBox { Font = font }; overrideButton = new Button { Font = formFont, Text = Resources.LearnMode.OverrideButton }; editButton = new Button { Font = formFont, Text = Resources.LearnMode.EditButton }; viewButton = new Button { Font = formFont, Text = Resources.LearnMode.ViewInListButton }; deleteButton = new Button { Font = formFont, Text = Resources.LearnMode.DeleteButton }; roundOverview = new RoundOverview { Dock = DockStyle.Fill }; gameOverview = new GameOverview(this) { Dock = DockStyle.Fill }; GameArea.Controls.Add(phrase); GameArea.Controls.Add(scoreLabel); GameArea.Controls.Add(answer); GameArea.Controls.Add(history); GameArea.Controls.Add(translation); GameArea.Controls.Add(affirmation); GameArea.Controls.Add(overrideButton); GameArea.Controls.Add(editButton); GameArea.Controls.Add(viewButton); GameArea.Controls.Add(deleteButton); GameArea.Controls.Add(roundOverview); GameArea.Controls.Add(gameOverview); translation.TextChanged += delegate { Layout(); }; translation.KeyUp += TranslationKeyUp; affirmation.TextChanged += AffirmationTextChanged; overrideButton.Click += delegate { Override(items[index], lastGuess); }; editButton.Click += EditButtonClick; viewButton.Click += ViewButtonClick; deleteButton.Click += DeleteButtonClick; roundOverview.KeyUp += RoundOverviewKeyUp; // Stop the beep sound being produced when Enter is pressed. // (Handling KeyUp is not sufficient to stop this.) translation.KeyPress += (s, e) => { if (e.KeyChar == '\r') { e.Handled = true; } }; MergeMenu(new OptionsMenu(this)); Update(); Layout(); }
public override void Start(IPracticeWindow owner) { base.Start(owner); GameArea.Resize += OnGameAreaResize; // State rounds = new List<IList<Attempt>>(); StartRound(); // UI var form = GameArea.FindForm(); var formFont = form != null ? form.Font : SystemFonts.DefaultFont; var fontFamily = formFont.FontFamily; font = new Font(fontFamily, 24); smallFont = new Font(fontFamily, 16); extraSmallFont = new Font(fontFamily, 12); scoreFont = new Font(fontFamily, 16); phrase = new Label { AutoSize = true, BackColor = Color.Transparent, Font = font }; answer = new Label { AutoSize = true, BackColor = Color.Transparent, Font = font }; scoreLabel = new Label { AutoSize = true, BackColor = Color.Transparent, Font = scoreFont, Dock = DockStyle.Bottom, TextAlign = ContentAlignment.BottomRight }; history = new Label { AutoSize = true, BackColor = Color.Transparent, Font = extraSmallFont, Dock = DockStyle.Top, TextAlign = ContentAlignment.MiddleLeft }; translation = new TextBox { Font = font }; affirmation = new TextBox { Font = font }; overrideButton = new Button { Font = formFont, Text = Resources.LearnMode.OverrideButton }; editButton = new Button { Font = formFont, Text = Resources.LearnMode.EditButton }; viewButton = new Button { Font = formFont, Text = Resources.LearnMode.ViewInListButton }; deleteButton = new Button { Font = formFont, Text = Resources.LearnMode.DeleteButton }; roundOverview = new RoundOverview { Dock = DockStyle.Fill }; gameOverview = new GameOverview(this) { Dock = DockStyle.Fill }; GameArea.Controls.Add(phrase); GameArea.Controls.Add(scoreLabel); GameArea.Controls.Add(answer); GameArea.Controls.Add(history); GameArea.Controls.Add(translation); GameArea.Controls.Add(affirmation); GameArea.Controls.Add(overrideButton); GameArea.Controls.Add(editButton); GameArea.Controls.Add(viewButton); GameArea.Controls.Add(deleteButton); GameArea.Controls.Add(roundOverview); GameArea.Controls.Add(gameOverview); translation.TextChanged += delegate { Layout(); }; translation.KeyUp += TranslationKeyUp; affirmation.TextChanged += AffirmationTextChanged; overrideButton.Click += delegate { Override(items[index], lastGuess); }; editButton.Click += EditButtonClick; viewButton.Click += ViewButtonClick; deleteButton.Click += DeleteButtonClick; roundOverview.KeyUp += RoundOverviewKeyUp; // Stop the beep sound being produced when Enter is pressed. // (Handling KeyUp is not sufficient to stop this.) translation.KeyPress += (s, e) => { if (e.KeyChar == '\r') e.Handled = true; }; MergeMenu(new OptionsMenu(this)); Update(); Layout(); }