public static int ShowBasicButton(this Form frm, string labelText, string button1text, string button2text, string button3text) { BasicButtonPopup basicButtonPrompt = GetBasicButton(frm, labelText, button1text, button2text, button3text); basicButtonPrompt.ShowDialog(); return(basicButtonPrompt.ResultButton); }
public static BasicButtonPopup GetBasicButton(this Form frm, string labelText, string button1text, string button2text, string button3text) { BasicButtonPopup basicButtonPrompt = new BasicButtonPopup(); basicButtonPrompt.Owner = frm; basicButtonPrompt.Text = frm.Text; // We later adjust this in the button itself to correct error, but good to have this here as a backup basicButtonPrompt.StartPosition = FormStartPosition.Manual; basicButtonPrompt.Location = new Point((frm.Location.X + frm.Width / 2) - (basicButtonPrompt.Width / 2), (frm.Location.Y + frm.Height / 2) - (basicButtonPrompt.Height / 2)); basicButtonPrompt.DisplayText = labelText; basicButtonPrompt.button1.Text = button1text; if (string.IsNullOrEmpty(button1text)) { basicButtonPrompt.button1.Hide(); } basicButtonPrompt.button2.Text = button2text; if (string.IsNullOrEmpty(button2text)) { basicButtonPrompt.button2.Hide(); } basicButtonPrompt.button3.Text = button3text; if (string.IsNullOrEmpty(button3text)) { basicButtonPrompt.button3.Hide(); } return(basicButtonPrompt); }
private void Form1_Load(object sender, EventArgs e) { dataGridView1.ClearSelection(); if (!string.IsNullOrEmpty(Program.CommandLineOptions.NextLaunchPath)) { ModManager.LaunchCommand = Program.CommandLineOptions.NextLaunchPath; Program.CommandLineOptions.NextLaunchPath = null; ModManager.SyncConfigToDisk(); } // Fetch the latest version from github Task.Run(() => { latestOnlineVersion = GitHubAPI.GetLatestVersionFromGitHub(GitHubRepo); }).ContinueWith(res => { if (latestOnlineVersion != null && latestOnlineVersion.IsAMLVersionLower()) { BasicButtonPopup resultButton = this.GetBasicButton("A new version of AstroModLoader (v" + latestOnlineVersion + ") is available!", "OK", "Open in browser", null); resultButton.PageToVisit = GitHubAPI.GetLatestVersionURL(GitHubRepo); resultButton.ShowDialog(); } }, TaskScheduler.FromCurrentSynchronizationContext()); // Initial resize of the menu to fit the table if necessary AMLUtils.InvokeUI(ForceTableToFit); AMLUtils.InvokeUI(ForceResize); AMLUtils.InvokeUI(ForceResize); UpdateVersionLabel(); RefreshModInfoLabel(); }