mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 14:07:46 +08:00
Merge branch 'v1.78.2-dev' into copilot/fix-empty-option-panel
This commit is contained in:
@@ -257,8 +257,8 @@ namespace mRemoteNG.UI.Forms.OptionsPages
|
||||
// tableLayoutPanel2
|
||||
//
|
||||
tableLayoutPanel2.ColumnCount = 2;
|
||||
tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 45F));
|
||||
tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 55F));
|
||||
tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.AutoSize));
|
||||
tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
tableLayoutPanel2.Controls.Add(numRdpReconnectionCount, 1, 0);
|
||||
tableLayoutPanel2.Controls.Add(numAutoSave, 1, 2);
|
||||
tableLayoutPanel2.Controls.Add(lblRdpReconnectionCount, 0, 0);
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace mRemoteNG.UI.Forms
|
||||
private string _pageName;
|
||||
private readonly DisplayProperties _display = new();
|
||||
private readonly List<string> _optionPageObjectNames;
|
||||
private bool _isInitialized = false;
|
||||
|
||||
public FrmOptions() : this(Language.StartupExit)
|
||||
{
|
||||
@@ -57,6 +58,13 @@ namespace mRemoteNG.UI.Forms
|
||||
|
||||
private void FrmOptions_Load(object sender, EventArgs e)
|
||||
{
|
||||
// Only initialize once to prevent multiple event subscriptions and page reloading
|
||||
if (_isInitialized)
|
||||
{
|
||||
this.Visible = true;
|
||||
return;
|
||||
}
|
||||
|
||||
this.Visible = true;
|
||||
FontOverrider.FontOverride(this);
|
||||
SetActivatedPage();
|
||||
@@ -293,6 +301,9 @@ namespace mRemoteNG.UI.Forms
|
||||
|
||||
private void FrmOptions_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
// Ensure Application.Idle handler is removed if still attached
|
||||
Application.Idle -= Application_Idle;
|
||||
|
||||
e.Cancel = true;
|
||||
this.Visible = false;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace mRemoteNG.UI.Window
|
||||
public partial class OptionsWindow : BaseWindow
|
||||
{
|
||||
private FrmOptions _optionsForm;
|
||||
private bool _isInitialized = false;
|
||||
|
||||
#region Public Methods
|
||||
|
||||
@@ -34,8 +35,14 @@ namespace mRemoteNG.UI.Window
|
||||
|
||||
private void Options_Load(object sender, EventArgs e)
|
||||
{
|
||||
// Only subscribe to ThemeChanged once to prevent multiple subscriptions
|
||||
if (!_isInitialized)
|
||||
{
|
||||
ThemeManager.getInstance().ThemeChanged += ApplyTheme;
|
||||
_isInitialized = true;
|
||||
}
|
||||
|
||||
ApplyTheme();
|
||||
ThemeManager.getInstance().ThemeChanged += ApplyTheme;
|
||||
ApplyLanguage();
|
||||
LoadOptionsForm();
|
||||
}
|
||||
|
||||
@@ -33,5 +33,32 @@ namespace mRemoteNGTests.UI.Forms
|
||||
ListViewTester listViewTester = new("lstOptionPages", _optionsForm);
|
||||
Assert.That(listViewTester.Items.Count, Is.EqualTo(12));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FormCanBeHiddenAndShownMultipleTimes()
|
||||
{
|
||||
// First show (already done in Setup)
|
||||
Assert.That(_optionsForm.Visible, Is.True);
|
||||
|
||||
// Hide the form
|
||||
_optionsForm.Hide();
|
||||
Assert.That(_optionsForm.Visible, Is.False);
|
||||
|
||||
// Show it again
|
||||
_optionsForm.Show();
|
||||
Assert.That(_optionsForm.Visible, Is.True);
|
||||
|
||||
// Verify pages are still loaded correctly
|
||||
ListViewTester listViewTester = new("lstOptionPages", _optionsForm);
|
||||
Assert.That(listViewTester.Items.Count, Is.EqualTo(12));
|
||||
|
||||
// Hide and show one more time
|
||||
_optionsForm.Hide();
|
||||
_optionsForm.Show();
|
||||
Assert.That(_optionsForm.Visible, Is.True);
|
||||
|
||||
// Verify pages are still there
|
||||
Assert.That(listViewTester.Items.Count, Is.EqualTo(12));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user