From 00825b1a59bdc41e7536ce825cd9e3b7363d2e83 Mon Sep 17 00:00:00 2001 From: Tomas Hansson Date: Fri, 11 Sep 2026 10:35:27 +0100 Subject: [PATCH] Center dialogs and message boxes on their parent window Dialogs and message boxes were shown without an explicit owner, so FormStartPosition.CenterParent had no parent to center against and placement fell back to inconsistent, sometimes off-monitor behavior (especially for non-modal Form.Show(), which never infers an owner). Passing the parent form explicitly to ShowDialog/Show/MessageBox.Show throughout MainForm, RDPConnect, AssetLibrarySearch, AddNSG, Parameters, and ChooseProject makes every dialog center on and stay stacked above its parent, on the parent's monitor. --- 2LCS/AssetLibrary/AssetLibrarySearch.cs | 4 +- 2LCS/Forms/AddNSG.cs | 6 +- 2LCS/Forms/ChooseProject.cs | 4 +- 2LCS/Forms/MainForm.cs | 104 ++++++++++++------------ 2LCS/Forms/Parameters.cs | 2 +- 2LCS/Forms/RDPConnect.cs | 16 ++-- 6 files changed, 68 insertions(+), 68 deletions(-) diff --git a/2LCS/AssetLibrary/AssetLibrarySearch.cs b/2LCS/AssetLibrary/AssetLibrarySearch.cs index e098931..3fdd3f8 100644 --- a/2LCS/AssetLibrary/AssetLibrarySearch.cs +++ b/2LCS/AssetLibrary/AssetLibrarySearch.cs @@ -76,7 +76,7 @@ private void search_Click(object sender, EventArgs e) Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*" }; - if (saveFile.ShowDialog() == DialogResult.OK) + if (saveFile.ShowDialog(this) == DialogResult.OK) { try { @@ -86,7 +86,7 @@ private void search_Click(object sender, EventArgs e) } catch (Exception ex) { - MessageBox.Show(ex.Message); + MessageBox.Show(this, ex.Message); } } } diff --git a/2LCS/Forms/AddNSG.cs b/2LCS/Forms/AddNSG.cs index 459fa16..8ddc995 100644 --- a/2LCS/Forms/AddNSG.cs +++ b/2LCS/Forms/AddNSG.cs @@ -60,7 +60,7 @@ private void PopulateWithOwnIP() } catch { - MessageBox.Show("Failed to get your IP address. Please enter it manually."); + MessageBox.Show(this, "Failed to get your IP address. Please enter it manually."); } } } @@ -69,12 +69,12 @@ private bool ValidateRule() { if (string.IsNullOrEmpty(textBox1.Text)) { - MessageBox.Show("Rule name is empty."); + MessageBox.Show(this, "Rule name is empty."); return false; } if (string.IsNullOrEmpty(textBox2.Text)) { - MessageBox.Show("IP address field is empty."); + MessageBox.Show(this, "IP address field is empty."); return false; } Rule = new Dictionary(StringComparer.OrdinalIgnoreCase) diff --git a/2LCS/Forms/ChooseProject.cs b/2LCS/Forms/ChooseProject.cs index c1cf8f7..d09c3c9 100644 --- a/2LCS/Forms/ChooseProject.cs +++ b/2LCS/Forms/ChooseProject.cs @@ -65,7 +65,7 @@ private void OkButton_Click(object sender, EventArgs e) LcsProject = (LcsProject)projectsDataGridView.SelectedRows[0].DataBoundItem; if (LcsProject.RequestPending == true) { - MessageBox.Show($"Invitation to the project {LcsProject.Name} has not been completed yet for your user account.\n\nVisit LCS and accept invitation first!", "Warning! Action needed."); + MessageBox.Show(this, $"Invitation to the project {LcsProject.Name} has not been completed yet for your user account.\n\nVisit LCS and accept invitation first!", "Warning! Action needed."); return; } UpdateProjectLinks(); @@ -84,7 +84,7 @@ private void ProjectsDataGridView_CellMouseDoubleClick(object sender, DataGridVi LcsProject = (LcsProject)projectsDataGridView.SelectedRows[0].DataBoundItem; if (LcsProject.RequestPending == true) { - MessageBox.Show($"Invitation to the project {LcsProject.Name} has not been completed yet for your user account.\n\nVisit LCS and accept invitation first!", "Warning! Action needed."); + MessageBox.Show(this, $"Invitation to the project {LcsProject.Name} has not been completed yet for your user account.\n\nVisit LCS and accept invitation first!", "Warning! Action needed."); return; } UpdateProjectLinks(); diff --git a/2LCS/Forms/MainForm.cs b/2LCS/Forms/MainForm.cs index 6b786ec..78e508e 100644 --- a/2LCS/Forms/MainForm.cs +++ b/2LCS/Forms/MainForm.cs @@ -83,7 +83,7 @@ public MainForm() private DataGridView SelectedDataGridView => tabControl.SelectedTab == tabControl.TabPages["cheTabPage"] ? cheDataGridView : saasDataGridView; - public static RDPConnectionDetails ChooseRdpLogonUser(List rdpList) + public static RDPConnectionDetails ChooseRdpLogonUser(List rdpList, IWin32Window owner) { if (Properties.Settings.Default.alwaysLogAsAdmin) { @@ -104,7 +104,7 @@ public static RDPConnectionDetails ChooseRdpLogonUser(List form.Text = "Choose user"; form.ClientSize = new Size(280, 60); form.FormBorderStyle = FormBorderStyle.FixedDialog; - form.StartPosition = FormStartPosition.CenterScreen; + form.StartPosition = FormStartPosition.CenterParent; form.AcceptButton = button_OK; form.CancelButton = button_Cancel; form.MinimizeBox = false; @@ -127,7 +127,7 @@ public static RDPConnectionDetails ChooseRdpLogonUser(List } form.Controls.Add(panel); - DialogResult dialogResult = form.ShowDialog(); + DialogResult dialogResult = form.ShowDialog(owner); if (dialogResult == DialogResult.Cancel) return null; @@ -212,7 +212,7 @@ private async void ChangeProjectMenuItem_Click(object sender, EventArgs e) { HttpClientHelper = _httpClientHelper }; - form.ShowDialog(); + form.ShowDialog(this); if (!form.Cancelled && (form.LcsProject != null)) { Projects = form.Projects; @@ -259,7 +259,7 @@ private void CheDataGridView_CellMouseDoubleClick(object sender, DataGridViewCel RDPConnectionDetails rdpEntry; if (rdpList.Count > 1) { - rdpEntry = ChooseRdpLogonUser(rdpList); + rdpEntry = ChooseRdpLogonUser(rdpList, this); } else { @@ -351,7 +351,7 @@ private void CheExportRDCManConnectionsMenuItem_Click(object sender, EventArgs e DefaultExt = "rdg", AddExtension = true }; - if (savefile.ShowDialog() == DialogResult.OK) + if (savefile.ShowDialog(this) == DialogResult.OK) { using StreamWriter sw = new StreamWriter(savefile.FileName); sw.Write(sb); @@ -401,7 +401,7 @@ private void CheExportRDMConnectionsToolStripMenuItem_Click(object sender, Event DefaultExt = "rdm", AddExtension = true }; - if (savefile.ShowDialog() == DialogResult.OK) + if (savefile.ShowDialog(this) == DialogResult.OK) { using StreamWriter sw = new StreamWriter(savefile.FileName); sw.Write(sb); @@ -421,7 +421,7 @@ private void CheShowPasswordsMenuItem_Click(object sender, EventArgs e) CredentialsDict = _httpClientHelper.GetCredentials(instance.EnvironmentId, vm.ItemName), Text = $"Instance: {instance.InstanceId}, VM: {vm.MachineName}" }; - form.Show(); + form.Show(this); } } } @@ -437,21 +437,21 @@ private void CheShowPasswordsPowershellMenuItem_Click(object sender, EventArgs e CredentialsDict = _httpClientHelper.GetCredentials(instance.EnvironmentId, vm.ItemName), Text = $"Instance: {instance.InstanceId}, VM: {vm.MachineName}" }; - form.Show(); + form.Show(this); } } private void CookieToolStripMenuItem_Click(object sender, EventArgs e) { using var form = new CookieEdit(); - form.ShowDialog(); + form.ShowDialog(this); if (form.Cancelled || string.IsNullOrEmpty(form.Cookie)) return; if (form.Cookie == Properties.Settings.Default.cookie) return; Properties.Settings.Default.cookie = form.Cookie; Properties.Settings.Default.projects = ""; Properties.Settings.Default.instances = ""; Properties.Settings.Default.Save(); - MessageBox.Show("Application will now restart", "Message", MessageBoxButtons.OK); + MessageBox.Show(this, "Application will now restart", "Message", MessageBoxButtons.OK); Application.Restart(); } @@ -561,7 +561,7 @@ private void CustomLinkClicked(object sender, EventArgs e) private void CustomLinksToolStripMenuItem_Click(object sender, EventArgs e) { using var form = new CustomLinks(); - form.ShowDialog(); + form.ShowDialog(this); if (form.Cancelled) return; RemoveCustomLinksMenuItems(); CreateCustomLinksMenuItems(); @@ -594,7 +594,7 @@ private void DeallocateMenuItem_Click(object sender, EventArgs e) foreach (DataGridViewRow row in SelectedDataGridView.SelectedRows) { var instance = (CloudHostedInstance)row.DataBoundItem; - if (MessageBox.Show($"Deallocation is the step before deletion. Do you really want to deallocate {instance.DisplayName} instance?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes) + if (MessageBox.Show(this, $"Deallocation is the step before deletion. Do you really want to deallocate {instance.DisplayName} instance?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes) { tasks.Add(Task.Run(() => new HttpClientHelper(_cookies) { LcsUrl = _lcsUrl, LcsUpdateUrl = _lcsUpdateUrl, LcsDiagUrl = _lcsDiagUrl, LcsProjectId = _selectedProject.Id.ToString() }.StartStopDeployment(instance, "deallocate"))); } @@ -610,7 +610,7 @@ private void DeleteMenuItem_Click(object sender, EventArgs e) foreach (DataGridViewRow row in SelectedDataGridView.SelectedRows) { var instance = (CloudHostedInstance)row.DataBoundItem; - if (MessageBox.Show($"Deletion cannot be cancelled or rolled back. Do you really want to delete {instance.DisplayName} instance?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes) + if (MessageBox.Show(this, $"Deletion cannot be cancelled or rolled back. Do you really want to delete {instance.DisplayName} instance?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes) { tasks.Add(Task.Run(() => new HttpClientHelper(_cookies) { LcsUrl = _lcsUrl, LcsUpdateUrl = _lcsUpdateUrl, LcsDiagUrl = _lcsDiagUrl, LcsProjectId = _selectedProject.Id.ToString() }.DeleteEnvironment(instance))); } @@ -634,7 +634,7 @@ private void DeployPackageToolStripMenuItem_Click(object sender, EventArgs e) { Packages = packages }; - form.ShowDialog(); + form.ShowDialog(this); if (!form.Cancelled && (form.DeployablePackage != null)) { package = form.DeployablePackage; @@ -661,7 +661,7 @@ private void DeployPackageToolStripMenuItem_Click(object sender, EventArgs e) LogEntries = log.ToString(), Text = $"Deployment log for package: {package.Name}" }; - form.Show(); + form.Show(this); } Cursor = Cursors.Default; } @@ -677,7 +677,7 @@ private void DetailedBuildInfoToolStripMenuItem_Click(object sender, EventArgs e var buildInfo = _httpClientHelper.GetEnvironmentBuildInfoDetails(instance, environmentId.ToString()); if (buildInfo == null || buildInfo.BuildInfoTreeView.Count == 0) { - MessageBox.Show($"Request to get build info details. Please try again later."); + MessageBox.Show(this, $"Request to get build info details. Please try again later."); continue; } using var form = new BuildInfoDetailsForm @@ -685,7 +685,7 @@ private void DetailedBuildInfoToolStripMenuItem_Click(object sender, EventArgs e BuildInfo = buildInfo, Text = $"Instance: {instance.InstanceId}, Build version: {buildInfo.BuildVersion}, Platform build: {buildInfo.InstalledPlatformBuild}" }; - form.ShowDialog(); + form.ShowDialog(this); } Cursor = Cursors.Default; } @@ -776,7 +776,7 @@ private async void ExportEnvironmentUpdates(LCSEnvironments _LCSEnvironments) Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*" }; - if (savefile.ShowDialog() == DialogResult.OK) + if (savefile.ShowDialog(this) == DialogResult.OK) { try { @@ -786,7 +786,7 @@ private async void ExportEnvironmentUpdates(LCSEnvironments _LCSEnvironments) } catch (Exception ex) { - MessageBox.Show(ex.Message); + MessageBox.Show(this, ex.Message); } } _selectedProject = previousProject; @@ -888,7 +888,7 @@ private async void ExportListOfInstancesForAllProjects(LCSEnvironments _LCSEnvir Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*" }; - if (savefile.ShowDialog() == DialogResult.OK) + if (savefile.ShowDialog(this) == DialogResult.OK) { try { @@ -898,7 +898,7 @@ private async void ExportListOfInstancesForAllProjects(LCSEnvironments _LCSEnvir } catch (Exception ex) { - MessageBox.Show(ex.Message); + MessageBox.Show(this, ex.Message); } } _selectedProject = previousProject; @@ -1291,7 +1291,7 @@ private void ExportProjectDataToolStripMenuItem_Click(object sender, EventArgs e DefaultExt = "docx", AddExtension = true }; - if (savefile.ShowDialog() == DialogResult.OK) + if (savefile.ShowDialog(this) == DialogResult.OK) { try { @@ -1299,7 +1299,7 @@ private void ExportProjectDataToolStripMenuItem_Click(object sender, EventArgs e } catch (Exception ex) { - MessageBox.Show(ex.Message); + MessageBox.Show(this, ex.Message); } } } @@ -1368,7 +1368,7 @@ private async Task ExportListOfUsers(LCSProjectAllCurrent _LCSProjectAllCurrent) Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*" }; - if (savefile.ShowDialog() == DialogResult.OK) + if (savefile.ShowDialog(this) == DialogResult.OK) { try { @@ -1378,7 +1378,7 @@ private async Task ExportListOfUsers(LCSProjectAllCurrent _LCSProjectAllCurrent) } catch (Exception ex) { - MessageBox.Show(ex.Message); + MessageBox.Show(this, ex.Message); } } _selectedProject = previousProject; @@ -1440,12 +1440,12 @@ private void HotfixesToolStripMenuItem_Click(object sender, EventArgs e) var kbs = _httpClientHelper.GetAvailableHotfixes(diagId, (int)hotfixesType); if (kbs == null) { - MessageBox.Show($"Request to get available updates failed. Please try again later."); + MessageBox.Show(this, $"Request to get available updates failed. Please try again later."); continue; } if (kbs.Count == 0) { - MessageBox.Show($"There are no {label} available for {((CloudHostedInstance)row.DataBoundItem).DisplayName} instance."); + MessageBox.Show(this, $"There are no {label} available for {((CloudHostedInstance)row.DataBoundItem).DisplayName} instance."); continue; } using var form = new AvailableKBs @@ -1453,7 +1453,7 @@ private void HotfixesToolStripMenuItem_Click(object sender, EventArgs e) Hotfixes = kbs, Text = $"{kbs.Count} {label} available for {((CloudHostedInstance)row.DataBoundItem).DisplayName} instance." }; - form.ShowDialog(); + form.ShowDialog(this); } Cursor = Cursors.Default; } @@ -1499,7 +1499,7 @@ public void LoginToLCSMenuItem_Click(object sender, EventArgs e) { WebBrowserHelper.FixBrowserVersion(); using var form = new Login(); - form.ShowDialog(); + form.ShowDialog(this); if (form.Cancelled) return; _cookies = GetUriCookieContainer(); if (_cookies == null) return; @@ -1542,7 +1542,7 @@ private void LogonToApplicationToolStripMenuItem_Click(object sender, EventArgs private void LogoutToolStripMenuItem_Click(object sender, EventArgs e) { - if (MessageBox.Show( + if (MessageBox.Show(this, $"When you log off, all locally saved information about your projects and instances will be deleted. You will need to refresh data from LCS.{Environment.NewLine}{Environment.NewLine}Application will restart.{Environment.NewLine}{Environment.NewLine}Do you want to proceed?", "Confirmation", MessageBoxButtons.YesNo) != DialogResult.Yes) return; Properties.Settings.Default.projects = ""; @@ -1696,12 +1696,12 @@ private void OpenRDPConnectionToolStripMenuItem_Click(object sender, EventArgs e if (rdpList.Count == 0) { Cursor = Cursors.Default; - MessageBox.Show($"Cannot retrieve RDP connection details. This instance is not accessible through RDP or you do not have access to see those details. Check if you have Environment Manager role."); + MessageBox.Show(this, $"Cannot retrieve RDP connection details. This instance is not accessible through RDP or you do not have access to see those details. Check if you have Environment Manager role."); return; } else if (rdpList.Count > 1) { - rdpEntry = ChooseRdpLogonUser(rdpList); + rdpEntry = ChooseRdpLogonUser(rdpList, this); } else { @@ -1734,7 +1734,7 @@ private void OpenWorkItemsToolStripMenuItem_Click(object sender, EventArgs e) private void ParametersToolStripMenuItem_Click(object sender, EventArgs e) { using var form = new Parameters(); - form.ShowDialog(); + form.ShowDialog(this); } private string ParseCustomLink(string template, CloudHostedInstance instance) @@ -1862,7 +1862,7 @@ private void RemoveCustomLinksMenuItems() private void SaasAddNsgRule_Click(object sender, EventArgs e) { using var form = new AddNsg(); - form.ShowDialog(); + form.ShowDialog(this); if (form.Cancelled || (form.Rule == null)) return; Cursor = Cursors.WaitCursor; var tasks = new List(); @@ -1899,7 +1899,7 @@ private void SaasDeleteNsgRule_Click(object sender, EventArgs e) NetworkSecurityGroup = networkSecurityGroup, Text = $"Choose firewall rule to delete" }; - form.ShowDialog(); + form.ShowDialog(this); if (!form.Cancelled && (form.NSGRule != null)) { nsgRule = form.NSGRule; @@ -1929,7 +1929,7 @@ private void SaasDeleteNsgRule_Click(object sender, EventArgs e) LogEntries = log.ToString(), Text = $"Log for deletion of firewall rule: {nsgRule.Name}" }; - form.Show(); + form.Show(this); } Cursor = Cursors.Default; } @@ -2012,7 +2012,7 @@ private void SaasExportRDCManConnectionsToolStripMenuItem_Click(object sender, E DefaultExt = "rdg", AddExtension = true }; - if (savefile.ShowDialog() == DialogResult.OK) + if (savefile.ShowDialog(this) == DialogResult.OK) { using StreamWriter sw = new StreamWriter(savefile.FileName); sw.Write(sb); @@ -2062,7 +2062,7 @@ private void SaasExportRDMConnectionsToolStripMenuItem_Click(object sender, Even DefaultExt = "rdm", AddExtension = true }; - if (savefile.ShowDialog() == DialogResult.OK) + if (savefile.ShowDialog(this) == DialogResult.OK) { using StreamWriter sw = new StreamWriter(savefile.FileName); sw.Write(sb); @@ -2082,7 +2082,7 @@ private void SaasOpenRdpConnectionToolStripMenuItem_Click(object sender, EventAr Text = $"Choose machine to connect to. Instance: {instance.DisplayName}", RDPConnections = rdpList }; - form.ShowDialog(); + form.ShowDialog(this); if (!form.Cancelled && (form.RDPConnection != null)) { var rdpEntry = form.RDPConnection; @@ -2124,7 +2124,7 @@ private void SaasShowPasswordsMenuItem_Click(object sender, EventArgs e) Text = $"Instance: {instance.InstanceId}", CredentialsDict = credentials }; - form.Show(); + form.Show(this); } } @@ -2149,7 +2149,7 @@ private void SaasShowPasswordsPowershellMenuItem_Click(object sender, EventArgs Text = $"Instance: {instance.InstanceId}", CredentialsDict = credentials }; - form.Show(); + form.Show(this); } } @@ -2212,7 +2212,7 @@ private void ShowRDPDetailsToolStripMenuItem_Click(object sender, EventArgs e) Text = $"RDP connection details for {instance.DisplayName}", LogEntries = details.ToString() }; - form.Show(); + form.Show(this); } Cursor = Cursors.Default; } @@ -2323,7 +2323,7 @@ private async void SaasUpcomingUpdatesToolStripMenuItem_Click(object sender, Eve if (calendar == null || calendar.Count == 0) { Cursor = Cursors.Default; - MessageBox.Show($"Request to get upcoming service updates calendar failed. You are using learning project or you do not have access to that information."); + MessageBox.Show(this, $"Request to get upcoming service updates calendar failed. You are using learning project or you do not have access to that information."); return; } using var form = new UpcomingUpdates @@ -2331,7 +2331,7 @@ private async void SaasUpcomingUpdatesToolStripMenuItem_Click(object sender, Eve Calendar = calendar, Text = $"Upcoming service updates for {_selectedProject.Name} project." }; - form.ShowDialog(); + form.ShowDialog(this); Cursor = Cursors.Default; } @@ -2399,7 +2399,7 @@ private async void ExportUpdateScheduleForAllProjectsToolStripMenuItem_Click(obj Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*" }; - if (savefile.ShowDialog() == DialogResult.OK) + if (savefile.ShowDialog(this) == DialogResult.OK) { try { @@ -2409,7 +2409,7 @@ private async void ExportUpdateScheduleForAllProjectsToolStripMenuItem_Click(obj } catch (Exception ex) { - MessageBox.Show(ex.Message); + MessageBox.Show(this, ex.Message); } } _selectedProject = previousProject; @@ -2435,7 +2435,7 @@ private async void SaasRestartService_Click(object sender, EventArgs e) { AvailableServices = _httpClientHelper.GetServicesToRestart() }; - form.ShowDialog(); + form.ShowDialog(this); if (form.Cancelled || (form.ServicesToRestart == null)) return; Cursor = Cursors.WaitCursor; @@ -2489,7 +2489,7 @@ private async void SaasRestartService_Click(object sender, EventArgs e) LogEntries = log.ToString(), Text = $"Restarting service(s) log" }; - logForm.ShowDialog(); + logForm.ShowDialog(this); } } @@ -2507,7 +2507,7 @@ private async void EnvironmentChangesToolStripMenuItem_Click(object sender, Even ActionDetails = actions, Text = $"Environment changes for {instance.DisplayName} instance." }; - form.ShowDialog(); + form.ShowDialog(this); } } Cursor = Cursors.Default; @@ -2552,13 +2552,13 @@ private async void allProjectUsersExportMenuItem_Click(object sender, EventArgs private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { About2LCS about2LCS = new About2LCS(); - about2LCS.ShowDialog(); + about2LCS.ShowDialog(this); } private void exportListOfNuGetPackagesToolStripMenuItem_Click(object sender, EventArgs e) { using var form = new AssetLibrarySearch(_httpClientHelper); - form.ShowDialog(); + form.ShowDialog(this); } } diff --git a/2LCS/Forms/Parameters.cs b/2LCS/Forms/Parameters.cs index 74f8567..4bcfb5f 100644 --- a/2LCS/Forms/Parameters.cs +++ b/2LCS/Forms/Parameters.cs @@ -97,7 +97,7 @@ private void ClearCacheButton_Click(object sender, EventArgs e) if (result != null) { - MessageBox.Show(string.Format("Error while trying to clear cache, caching disabled.\n {0}", result), "Error"); + MessageBox.Show(this, string.Format("Error while trying to clear cache, caching disabled.\n {0}", result), "Error"); } } diff --git a/2LCS/Forms/RDPConnect.cs b/2LCS/Forms/RDPConnect.cs index 24e070d..0be8e68 100644 --- a/2LCS/Forms/RDPConnect.cs +++ b/2LCS/Forms/RDPConnect.cs @@ -67,7 +67,7 @@ private void RDPConnect_Shown(object sender, EventArgs e) using (var form = new Login()) { - form.ShowDialog(); + form.ShowDialog(this); } worker.RunWorkerAsync(); @@ -80,7 +80,7 @@ private void RDPConnect_Shown(object sender, EventArgs e) private bool CheckFailed(string message, string caption) { - MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(this, message, caption, MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } @@ -136,7 +136,7 @@ private void OnWorkerDoWork(object sender, DoWorkEventArgs e) { if (rdpList.Count > 1) { - rdpEntry = MainForm.ChooseRdpLogonUser(rdpList); + rdpEntry = MainForm.ChooseRdpLogonUser(rdpList, this); } else { @@ -163,28 +163,28 @@ private void OnWorkerDoWork(object sender, DoWorkEventArgs e) } else { - MessageBox.Show($"Operation cancelled", "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(this, $"Operation cancelled", "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { - MessageBox.Show($"Cannot retrieve RDP connection details. This instance is not accessible through RDP or you do not have access to see those details. Check if you have Environment Manager role.", "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(this, $"Cannot retrieve RDP connection details. This instance is not accessible through RDP or you do not have access to see those details. Check if you have Environment Manager role.", "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { - MessageBox.Show($"Cannot retrieve RDP connection details. This instance is not accessible through RDP or you do not have access to see those details. Check if you have Environment Manager role.", "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(this, $"Cannot retrieve RDP connection details. This instance is not accessible through RDP or you do not have access to see those details. Check if you have Environment Manager role.", "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { - MessageBox.Show($"Cannot find cloud-hosted instance with ID {rdpData.Environment} on project {project.Name}", "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(this, $"Cannot find cloud-hosted instance with ID {rdpData.Environment} on project {project.Name}", "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { - MessageBox.Show("Unsupported operation", "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(this, "Unsupported operation", "Operation failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }