private void SelectCurrentControl() { if (_selectedControl != null) _selectedControl.Unselect(); try { _selectedControl = _gameControls[current_page][current_row * max_controls_width + current_column]; _selectedControl.Select(); } catch { try { _selectedControl = _gameControls[current_page][0]; _selectedControl.Select(); } catch { } } }
private void ComputeControls() { ClearPage(); _gameControls.Clear(); // Compute controls per page SleekControl testControl = new SleekControl(); max_controls_width = gameControlsPanel.ClientSize.Width / testControl.Size.Width; if (max_controls_width <= 0) max_controls_width = 1; max_controls_height = gameControlsPanel.ClientSize.Height / testControl.Size.Height; if (max_controls_height <= 0) max_controls_height = 1; List<ApplicationEntry> gameList = _dictionary.ApplicationList; int cp_page = 0; int cp_x = 0; int cp_y = 0; foreach (ApplicationEntry game in gameList) { SleekControl b = new SleekControl(); b.LoadEntry(game); b.Unselect(); b.Click += b_Click; b.DoubleClick += b_DoubleClick; if (cp_page >= _gameControls.Count) _gameControls.Add(new List<SleekControl>()); _gameControls[cp_page].Add(b); cp_x++; if (cp_x >= max_controls_width) { cp_y++; cp_x = 0; } if (cp_y >= max_controls_height) { cp_page++; cp_y = 0; cp_x = 0; } } }