Esempio n. 1
0
        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}");
        }
Esempio n. 2
0
 public void ClearLinePath()
 {
     LetterGridControl.LinePath = new List <Point>();
     LetterGridControl.Refresh();
 }