diff --git a/mRemoteV1/UI/Forms/Input/InputBox.Designer.cs b/mRemoteV1/UI/Forms/Input/FrmInputBox.Designer.cs similarity index 85% rename from mRemoteV1/UI/Forms/Input/InputBox.Designer.cs rename to mRemoteV1/UI/Forms/Input/FrmInputBox.Designer.cs index e5704adb4..6e5b7532a 100644 --- a/mRemoteV1/UI/Forms/Input/InputBox.Designer.cs +++ b/mRemoteV1/UI/Forms/Input/FrmInputBox.Designer.cs @@ -1,6 +1,6 @@ namespace mRemoteNG.UI.Forms.Input { - partial class InputBox + partial class FrmInputBox { /// /// Required designer variable. @@ -50,9 +50,9 @@ this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 3; - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 24F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 24F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 24F)); this.tableLayoutPanel1.Size = new System.Drawing.Size(284, 81); this.tableLayoutPanel1.TabIndex = 0; // @@ -66,6 +66,7 @@ this.buttonOk.TabIndex = 0; this.buttonOk.Text = "Ok"; this.buttonOk.UseVisualStyleBackColor = true; + this.buttonOk.Click += new System.EventHandler(this.buttonOk_Click); // // buttonCancel // @@ -78,42 +79,41 @@ this.buttonCancel.TabIndex = 1; this.buttonCancel.Text = "Cancel"; this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); // // textBox // this.tableLayoutPanel1.SetColumnSpan(this.textBox, 3); this.textBox.Dock = System.Windows.Forms.DockStyle.Fill; - this.textBox.Location = new System.Drawing.Point(10, 26); - this.textBox.Margin = new System.Windows.Forms.Padding(10, 3, 10, 3); + this.textBox.Location = new System.Drawing.Point(3, 27); this.textBox.Name = "textBox"; - this.textBox.Size = new System.Drawing.Size(264, 20); + this.textBox.Size = new System.Drawing.Size(278, 20); this.textBox.TabIndex = 2; // // label // this.label.AutoSize = true; this.tableLayoutPanel1.SetColumnSpan(this.label, 3); - this.label.Dock = System.Windows.Forms.DockStyle.Left; - this.label.Location = new System.Drawing.Point(10, 10); - this.label.Margin = new System.Windows.Forms.Padding(10, 10, 3, 0); + this.label.Dock = System.Windows.Forms.DockStyle.Fill; + this.label.Location = new System.Drawing.Point(3, 0); this.label.Name = "label"; - this.label.Size = new System.Drawing.Size(33, 13); + this.label.Size = new System.Drawing.Size(278, 24); this.label.TabIndex = 3; this.label.Text = "Label"; + this.label.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // - // InputBox + // FrmInputBox // - this.AcceptButton = this.buttonOk; this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.CancelButton = this.buttonCancel; this.ClientSize = new System.Drawing.Size(284, 81); this.ControlBox = false; this.Controls.Add(this.tableLayoutPanel1); this.DoubleBuffered = true; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.MinimizeBox = false; - this.Name = "InputBox"; + this.Name = "FrmInputBox"; this.ShowIcon = false; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; diff --git a/mRemoteV1/UI/Forms/Input/InputBox.cs b/mRemoteV1/UI/Forms/Input/FrmInputBox.cs similarity index 63% rename from mRemoteV1/UI/Forms/Input/InputBox.cs rename to mRemoteV1/UI/Forms/Input/FrmInputBox.cs index 9cffd3488..a0f1c6c63 100644 --- a/mRemoteV1/UI/Forms/Input/InputBox.cs +++ b/mRemoteV1/UI/Forms/Input/FrmInputBox.cs @@ -3,13 +3,18 @@ using mRemoteNG.Themes; namespace mRemoteNG.UI.Forms.Input { - public partial class InputBox : Form + public partial class FrmInputBox : Form { private readonly DisplayProperties _display = new DisplayProperties(); + internal string returnValue; - public InputBox() + public FrmInputBox(string title, string promptText, ref string value) { InitializeComponent(); + + Text = title; + label.Text = promptText; + textBox.Text = value; ApplyLanguage(); ApplyTheme(); } @@ -27,14 +32,17 @@ namespace mRemoteNG.UI.Forms.Input ForeColor = activeTheme.ExtendedPalette.getColor("Dialog_Foreground"); } - public DialogResult ShowAsDialog(string title, string promptText, ref string value) + private void buttonOk_Click(object sender, System.EventArgs e) { - Text = title; - label.Text = promptText; - textBox.Text = value; - var dialogResult = ShowDialog(); - value = textBox.Text; - return dialogResult; + DialogResult = DialogResult.OK; + returnValue = textBox.Text; + Close(); + } + + private void buttonCancel_Click(object sender, System.EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); } } } diff --git a/mRemoteV1/UI/Forms/Input/InputBox.resx b/mRemoteV1/UI/Forms/Input/FrmInputBox.resx similarity index 100% rename from mRemoteV1/UI/Forms/Input/InputBox.resx rename to mRemoteV1/UI/Forms/Input/FrmInputBox.resx diff --git a/mRemoteV1/UI/Forms/OptionsPages/ThemePage.cs b/mRemoteV1/UI/Forms/OptionsPages/ThemePage.cs index 23e9d6e57..86f157550 100644 --- a/mRemoteV1/UI/Forms/OptionsPages/ThemePage.cs +++ b/mRemoteV1/UI/Forms/OptionsPages/ThemePage.cs @@ -173,17 +173,22 @@ namespace mRemoteNG.UI.Forms.OptionsPages private void btnThemeNew_Click(object sender, EventArgs e) { var name = _themeManager.ActiveTheme.Name; - var res = new InputBox().ShowAsDialog(Language.strOptionsThemeNewThemeCaption, Language.strOptionsThemeNewThemeText, ref name); - if (res != DialogResult.OK) return; - if (_themeManager.isThemeNameOk(name)) + using (FrmInputBox frmInputBox = new FrmInputBox(Language.strOptionsThemeNewThemeCaption, Language.strOptionsThemeNewThemeText, ref name)) { - var addedTheme = _themeManager.addTheme(_themeManager.ActiveTheme, name); - _themeManager.ActiveTheme = addedTheme; - LoadSettings(); - } - else - { - TaskDialog.CTaskDialog.ShowTaskDialogBox(this, Language.strErrors, Language.strOptionsThemeNewThemeError, "", "", "", "", "", "", TaskDialog.ETaskDialogButtons.Ok, TaskDialog.ESysIcons.Error, TaskDialog.ESysIcons.Information, 0); + DialogResult dr = frmInputBox.ShowDialog(); + if (dr == DialogResult.OK) + { + if (_themeManager.isThemeNameOk(frmInputBox.returnValue)) + { + var addedTheme = _themeManager.addTheme(_themeManager.ActiveTheme, frmInputBox.returnValue); + _themeManager.ActiveTheme = addedTheme; + LoadSettings(); + } + else + { + TaskDialog.CTaskDialog.ShowTaskDialogBox(this, Language.strErrors, Language.strOptionsThemeNewThemeError, "", "", "", "", "", "", TaskDialog.ETaskDialogButtons.Ok, TaskDialog.ESysIcons.Error, TaskDialog.ESysIcons.Information, 0); + } + } } } diff --git a/mRemoteV1/UI/Forms/frmChoosePanel.cs b/mRemoteV1/UI/Forms/frmChoosePanel.cs index 51a22044b..aa98b5138 100644 --- a/mRemoteV1/UI/Forms/frmChoosePanel.cs +++ b/mRemoteV1/UI/Forms/frmChoosePanel.cs @@ -69,12 +69,17 @@ namespace mRemoteNG.UI.Forms private void btnNew_Click(object sender, System.EventArgs e) { var pnlName = Language.strNewPanel; - - if (new InputBox().ShowAsDialog(Language.strNewPanel, Language.strPanelName + ":", ref pnlName) != DialogResult.OK || string.IsNullOrEmpty(pnlName)) return; - _panelAdder.AddPanel(pnlName); - AddAvailablePanels(); - cbPanels.SelectedItem = pnlName; - cbPanels.Focus(); + using (FrmInputBox frmInputBox = new FrmInputBox(Language.strNewPanel, Language.strPanelName + ":", ref pnlName)) + { + DialogResult dr = frmInputBox.ShowDialog(); + if (dr == DialogResult.OK && !string.IsNullOrEmpty(frmInputBox.returnValue)) + { + _panelAdder.AddPanel(frmInputBox.returnValue); + AddAvailablePanels(); + cbPanels.SelectedItem = frmInputBox.returnValue; + cbPanels.Focus(); + } + } } private void btnOK_Click(object sender, System.EventArgs e) diff --git a/mRemoteV1/UI/Panels/PanelAdder.cs b/mRemoteV1/UI/Panels/PanelAdder.cs index 30096bd31..f835275dc 100644 --- a/mRemoteV1/UI/Panels/PanelAdder.cs +++ b/mRemoteV1/UI/Panels/PanelAdder.cs @@ -96,13 +96,12 @@ namespace mRemoteNG.UI.Panels try { var conW = (ConnectionWindow)((ToolStripMenuItem)sender).Tag; - var nTitle = ""; - new InputBox().ShowAsDialog(Language.strNewTitle, Language.strNewTitle + ":", ref nTitle); - - if (!string.IsNullOrEmpty(nTitle)) + using (FrmInputBox frmInputBox = new FrmInputBox(Language.strNewTitle, Language.strNewTitle + ":", ref nTitle)) { - conW.SetFormText(nTitle.Replace("&", "&&")); + DialogResult dr = frmInputBox.ShowDialog(); + if (dr == DialogResult.OK && string.IsNullOrEmpty(frmInputBox.returnValue)) + conW.SetFormText(frmInputBox.returnValue); } } catch (Exception ex) diff --git a/mRemoteV1/UI/Window/ConnectionWindow.cs b/mRemoteV1/UI/Window/ConnectionWindow.cs index 89f0abc02..0cf51244f 100644 --- a/mRemoteV1/UI/Window/ConnectionWindow.cs +++ b/mRemoteV1/UI/Window/ConnectionWindow.cs @@ -785,10 +785,13 @@ namespace mRemoteNG.UI.Window { try { - var newTitle = TabController.SelectedTab.Title; - if (new InputBox().ShowAsDialog(Language.strNewTitle, Language.strNewTitle + ":", ref newTitle) == DialogResult.OK && - !string.IsNullOrEmpty(newTitle)) - TabController.SelectedTab.Title = newTitle.Replace("&", "&&"); + var title = TabController.SelectedTab.Title; + using (FrmInputBox frmInputBox = new FrmInputBox(Language.strNewTitle, Language.strNewTitle + ":", ref title)) + { + DialogResult dr = frmInputBox.ShowDialog(); + if (dr == DialogResult.OK && !string.IsNullOrEmpty(frmInputBox.returnValue)) + TabController.SelectedTab.Title = frmInputBox.returnValue;// newTitle.Replace("&", "&&"); + } } catch (Exception ex) { diff --git a/mRemoteV1/mRemoteV1.csproj b/mRemoteV1/mRemoteV1.csproj index 6fa446498..d29b865ac 100644 --- a/mRemoteV1/mRemoteV1.csproj +++ b/mRemoteV1/mRemoteV1.csproj @@ -497,11 +497,11 @@ FrmSplashScreen.cs - + Form - - InputBox.cs + + FrmInputBox.cs AdvancedPage.cs @@ -804,8 +804,8 @@ FrmSplashScreen.cs - - InputBox.cs + + FrmInputBox.cs CredentialsPage.cs