mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
credential manager and cred editor windows now start in the middle of their parent window
This commit is contained in:
20
mRemoteV1/UI/FormExtensions.cs
Normal file
20
mRemoteV1/UI/FormExtensions.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
||||
namespace mRemoteNG.UI
|
||||
{
|
||||
public static class FormExtensions
|
||||
{
|
||||
public static void CenterOnTarget(this Form formToMove, Form formToCenterOn)
|
||||
{
|
||||
var targetFormCenterX = formToCenterOn.Location.X + formToCenterOn.Width/2;
|
||||
var targetFormCenterY = formToCenterOn.Location.Y + formToCenterOn.Height/2;
|
||||
|
||||
var thisFormCenterX = formToMove.Location.X + formToMove.Width/2;
|
||||
var thisFormCenterY = formToMove.Location.Y + formToMove.Height/2;
|
||||
|
||||
formToMove.Location = new Point(targetFormCenterX - thisFormCenterX, targetFormCenterY - thisFormCenterY);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,6 +163,7 @@
|
||||
this.Controls.Add(this.textBoxTitle);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Name = "CredentialEditorForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||
this.Text = "Credential Editor";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@@ -112,6 +112,7 @@
|
||||
this.Controls.Add(this.objectListView1);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Name = "CredentialManagerForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||
this.Text = "Credential Manager";
|
||||
((System.ComponentModel.ISupportInitialize)(this.objectListView1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace mRemoteNG.UI.Forms
|
||||
if (clickedCredential == null) return;
|
||||
var credentialEditorForm = new CredentialEditorForm(clickedCredential);
|
||||
credentialEditorForm.ChangesAccepted += (o, args) => RaiseCredentialsChangedEvent(o);
|
||||
credentialEditorForm.CenterOnTarget(this);
|
||||
credentialEditorForm.Show(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -1263,6 +1263,7 @@ namespace mRemoteNG.UI.Forms
|
||||
{
|
||||
var credentialManager = new CredentialManagerForm(_credentialRecords);
|
||||
credentialManager.CredentialsChanged += (o, args) => SaveCredentialList();
|
||||
credentialManager.CenterOnTarget(this);
|
||||
credentialManager.Show();
|
||||
}
|
||||
|
||||
|
||||
@@ -274,6 +274,7 @@
|
||||
<Compile Include="UI\Controls\ToolStripSplitButton.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UI\FormExtensions.cs" />
|
||||
<Compile Include="UI\Forms\CredentialEditorForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
||||
Reference in New Issue
Block a user