public override void Start(IPracticeWindow owner) { base.Start(owner); swap = false; nav = new Navigator(owner); navMenu = new NavigatorMenu(nav, true); MergeMenu(navMenu.Menu); phraseLabel = new Label(); translationLabel = new Label(); translationLabel.ForeColor = System.Drawing.SystemColors.GrayText; bigFont = new System.Drawing.Font(GameArea.FindForm().Font.FontFamily, 24); smallFont = new System.Drawing.Font(GameArea.FindForm().Font.FontFamily, 16); foreach (var l in new[] { phraseLabel, translationLabel }) { l.AutoSize = true; l.Font = bigFont; l.BackColor = Color.Transparent; GameArea.Controls.Add(l); } GameArea.Resize += new EventHandler(GameArea_Resize); GameArea.PreviewKeyDown += new PreviewKeyDownEventHandler(GameArea_PreviewKeyDown); foreach (Control c in new Control[] { phraseLabel, translationLabel, GameArea }) { c.MouseUp += new MouseEventHandler(GameArea_MouseUp); } navMenu.Back += delegate { GoBack(); }; navMenu.Forward += delegate { GoForward(); }; navMenu.End += delegate { GoToEnd(); }; navMenu.Edit += delegate { var newItem = Dialogs.EditPracticeItem.Show(nav.CurrentItem); if (newItem != null) { nav.UpdateCurrentItem(newItem); } Update(); Layout(); }; navMenu.Swap += delegate { SwapItems(); }; translationLabel.Visible = false; 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(); }