public void ShowPath(History path)
        {
            var sw = new System.Diagnostics.Stopwatch();

            sw.Start();

            var linePath = new List <Point>();

            LetterGridControl.SuspendLayout();
            LetterGridControl.Visible = false;
            foreach (HistoryItem pathStop in path.GetList())
            {
                Control letterControl = letterControls[pathStop.row, pathStop.col];

                //Highlight control
                letterControl.BackColor = Color.Orange;

                //Add control location to a list of points to be painted as a line.
                Point topLeft = letterControl.Location;
                Point centre  = new Point(topLeft.X + letterControl.Width / 2, topLeft.Y + letterControl.Height / 2);
                linePath.Add(centre);
            }

            letterControls[path.GetList()[0].row, path.GetList()[0].col].BackColor = Color.Red;

            LetterGridControl.LinePath = linePath;
            LetterGridControl.Refresh(); //cause repaint
            LetterGridControl.Visible = true;

            LetterGridControl.PerformLayout();


            sw.Stop();
            Console.WriteLine($"ShowPath: {sw.ElapsedMilliseconds}");
        }
        private void NewTextBox_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            TextBox thisTextBox = (TextBox)sender;

            switch (e.KeyCode)
            {
            case Keys.Back:
            case Keys.Left:
                if (thisTextBox.Text.Length == 0)
                {
                    LetterGridControl.AdvanceCursor(thisTextBox);
                }
                break;

            case Keys.Right:
                LetterGridControl.AdvanceCursor(thisTextBox);
                break;
            }
        }
 public void ClearLinePath()
 {
     LetterGridControl.LinePath = new List <Point>();
     LetterGridControl.Refresh();
 }
 private void UpdateModel()
 {
     ReadLetters();
     LetterGridControl.OnChanged();
 }