private Control <TGlyph, TColor, TKey> CreateLoadMenu()
        {
            var menu  = Menu();
            var items = new List <object>(10);

            for (var i = 0; i < items.Capacity; i++)
            {
                items.Add(menu.AddItem(_glyphProvider.FromString($"Slot {i}")));
            }
            menu.OnSelect += (m, item) =>
            {
                var index = items.IndexOf(item);
                if (File.Exists($"save{index}.sav"))
                {
                    _levelControl.Level = Level.Load($"save{index}.sav");
                    Page = NewGamePage;
                }
            };
            menu.OnKeyboardInput += (control, args) =>
            {
                if (KeyboardAdapter.IsEscape(args.Input))
                {
                    Page = _previousPage;
                }
            };

            return(Panel(Boder(20, 12, "Load menu", menu)));
        }
 private Control <TGlyph, TColor, TKey> CreateGame()
 {
     _levelControl = new LevelControl <TGlyph, TColor, TKey>(_glyphProvider, _colorProvider)
     {
         Left = 1,
         Top  = 1
     };
     _levelControl.OnKeyboardInput += (s, e) =>
     {
         if (_levelControl.Level.IsCompleted)
         {
             e.Handled = true;
             var index = _levelControl.Level.Index + 1;
             if (_levelProvider.Count == index)
             {
                 Page = MainMenuPage;
             }
             else
             {
                 StartLevel(index);
             }
         }
         else if (KeyboardAdapter.IsEscape(e.Input))
         {
             e.Handled = true;
             Page      = LocalMenuPage;
         }
         else if (KeyboardAdapter.IsBackspace(e.Input))
         {
             e.Handled = true;
             _levelControl.Level.Undo();
         }
     };
     _levelControl.OnLevelCompleted += s =>
     {
         _levelCompleteMessageLabel.Text = _glyphProvider.FromString("Congratulations, you have completed the Level!");
     };
     _levelCompleteMessageLabel = new Label <TGlyph, TColor, TKey>
     {
         ColorTheme = _colorProvider.SokobanLabelColorTheme,
         Delimiter  = _glyphProvider.Delimiter,
         Height     = 1,
         Width      = 46
     };
     return(Panel(_levelControl, _levelCompleteMessageLabel));
 }