/// <summary> /// Finds the row which is equivalent to the current loaded /// theme out of the theme selector loads and selects the row /// upon the user's entry to the menu. /// </summary> private void SelectLoadedTheme() { // Find the row with current theme and select it. foreach (DataGridViewRow row in box_ThemeList.Rows) { // Get the theme title and version. string themeName = (string)row.Cells[0].Value; string themeVersion = (string)row.Cells[4].Value; // Get the theme configuration. ThemeConfigParser.ThemeConfig themeConfiguration = FindThemeConfiguration(themeName, themeVersion); // Obtain theme directory. string themeDirectory = Path.GetFileName(Path.GetDirectoryName(themeConfiguration.ThemeLocation)); // Check if the theme configuration folder matches current theme folder. if (themeDirectory == Global.LoaderConfiguration.CurrentTheme) { // Set theme config, select row and exit loop. row.Selected = true; Global.CurrentThemeConfig = themeConfiguration; Global.LoaderConfiguration.CurrentTheme = themeDirectory; break; } } }
/// <summary> /// Load the relevant game details when the selection is changed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LoadCurrentTheme(object sender, EventArgs e) { try { // Cast the sender to the datagridview var senderGrid = (DataGridView)sender; // Obtain current row index. (Note: CurrentRow is invalid) int rowIndex = senderGrid.SelectedCells[0].RowIndex; // Get the theme title and version. string themeName = (string)senderGrid.Rows[rowIndex].Cells[0].Value; string themeVersion = (string)senderGrid.Rows[rowIndex].Cells[4].Value; // Cells[0] = Theme Name // Cells[1] = Theme Description // Cells[2] = Author // Cells[3] = Separator // Cells[4] = Version // Get the theme configuration. ThemeConfigParser.ThemeConfig themeConfiguration = FindThemeConfiguration(themeName, themeVersion); Global.CurrentThemeConfig = themeConfiguration; // Set the button text for website, source. borderless_WebBox.Text = themeConfiguration.ThemeSite.Length == 0 ? "N/A" : "Webpage"; borderless_SourceBox.Text = themeConfiguration.ThemeGithub.Length == 0 ? "N/A" : "Github"; // Obtain theme directory. string themeDirectory = Path.GetFileName(Path.GetDirectoryName(themeConfiguration.ThemeLocation)); // Load theme. Global.Theme.ThemeDirectory = themeDirectory; Global.LoaderConfiguration.CurrentTheme = themeDirectory; } catch { } }