diff --git a/mRemoteV1/App/Runtime.cs b/mRemoteV1/App/Runtime.cs index 81c0526cf..93b5f1cd5 100644 --- a/mRemoteV1/App/Runtime.cs +++ b/mRemoteV1/App/Runtime.cs @@ -1,4 +1,3 @@ -using Microsoft.VisualBasic; using mRemoteNG.App.Info; using mRemoteNG.Config.Connections; using mRemoteNG.Connection; @@ -20,6 +19,7 @@ using System.Threading; using System.Windows.Forms; using System.Xml; using mRemoteNG.UI.Forms; +using mRemoteNG.UI.Forms.Input; using mRemoteNG.UI.TaskDialog; using WeifenLuo.WinFormsUI.Docking; using TabPage = Crownwood.Magic.Controls.TabPage; @@ -285,9 +285,10 @@ namespace mRemoteNG.App try { ConnectionWindow conW = default(ConnectionWindow); - conW = (ConnectionWindow)((Control)sender).Tag; + conW = (ConnectionWindow)((ToolStripMenuItem)sender).Tag; - string nTitle = Interaction.InputBox(Prompt: Language.strNewTitle + ":", DefaultResponse: Convert.ToString(((Control)((Control)sender).Tag).Text.Replace("&&", "&"))); + string nTitle = ""; + input.InputBox(Language.strNewTitle, Language.strNewTitle + ":", ref nTitle); if (!string.IsNullOrEmpty(nTitle)) { diff --git a/mRemoteV1/UI/Forms/Input/input.cs b/mRemoteV1/UI/Forms/Input/input.cs new file mode 100644 index 000000000..0cb65ebdd --- /dev/null +++ b/mRemoteV1/UI/Forms/Input/input.cs @@ -0,0 +1,59 @@ +/* + * http://www.csharp-examples.net/inputbox/ + * + */ +using System; +using System.Windows.Forms; +using System.Drawing; + +namespace mRemoteNG.UI.Forms.Input +{ + internal class input + { + public static DialogResult InputBox(string title, string promptText, ref string value) + { + var form = new Form(); + var label = new Label(); + var textBox = new TextBox(); + var buttonOk = new Button(); + var buttonCancel = new Button(); + + label.Text = promptText; + label.AutoSize = true; + label.SetBounds(9, 20, 372, 13); + + textBox.Text = value; + textBox.BorderStyle = BorderStyle.Fixed3D; + textBox.Anchor = textBox.Anchor | AnchorStyles.Right; + textBox.SetBounds(12, 36, 372, 20); + + buttonOk.Text = "OK"; + buttonOk.DialogResult = DialogResult.OK; + buttonOk.FlatStyle = FlatStyle.Flat; + buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonOk.SetBounds(228, 72, 75, 23); + + buttonCancel.Text = "Cancel"; + buttonCancel.DialogResult = DialogResult.Cancel; + buttonCancel.FlatStyle = FlatStyle.Flat; + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonCancel.SetBounds(309, 72, 75, 23); + + form.Text = title; + form.ClientSize = new Size(396, 107); + form.Controls.AddRange(new Control[] {label, textBox, buttonOk, buttonCancel}); + form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height); + form.FormBorderStyle = FormBorderStyle.FixedDialog; + form.StartPosition = FormStartPosition.CenterScreen; + form.MinimizeBox = false; + form.MaximizeBox = false; + form.AcceptButton = buttonOk; + form.CancelButton = buttonCancel; + + var dialogResult = form.ShowDialog(); + value = textBox.Text; + return dialogResult; + } + } +} + diff --git a/mRemoteV1/UI/Forms/frmChoosePanel.cs b/mRemoteV1/UI/Forms/frmChoosePanel.cs index f622711d0..de1426298 100644 --- a/mRemoteV1/UI/Forms/frmChoosePanel.cs +++ b/mRemoteV1/UI/Forms/frmChoosePanel.cs @@ -1,6 +1,6 @@ -using Microsoft.VisualBasic; +using System.Windows.Forms; using mRemoteNG.App; -using mRemoteNG.My; +using mRemoteNG.UI.Forms.Input; namespace mRemoteNG { @@ -22,7 +22,7 @@ namespace mRemoteNG } } - public void frmChoosePanel_Load(System.Object sender, System.EventArgs e) + public void frmChoosePanel_Load(object sender, System.EventArgs e) { ApplyLanguage(); @@ -60,11 +60,11 @@ namespace mRemoteNG } } - public void btnNew_Click(System.Object sender, System.EventArgs e) + public void btnNew_Click(object sender, System.EventArgs e) { - string pnlName = Interaction.InputBox(Language.strPanelName + ":", Language.strNewPanel, Language.strNewPanel); + string pnlName = Language.strNewPanel; - if (!string.IsNullOrEmpty(pnlName)) + if (input.InputBox(Language.strNewPanel, Language.strPanelName + ":", ref pnlName) == DialogResult.OK && !string.IsNullOrEmpty(pnlName)) { Runtime.AddPanel(pnlName); AddAvailablePanels(); @@ -73,14 +73,14 @@ namespace mRemoteNG } } - public void btnOK_Click(System.Object sender, System.EventArgs e) + public void btnOK_Click(object sender, System.EventArgs e) { - this.DialogResult = System.Windows.Forms.DialogResult.OK; + DialogResult = DialogResult.OK; } - public void btnCancel_Click(System.Object sender, System.EventArgs e) + public void btnCancel_Click(object sender, System.EventArgs e) { - this.DialogResult = System.Windows.Forms.DialogResult.Cancel; + DialogResult = DialogResult.Cancel; } } } diff --git a/mRemoteV1/mRemoteV1.csproj b/mRemoteV1/mRemoteV1.csproj index ad6b81306..9f72b935e 100644 --- a/mRemoteV1/mRemoteV1.csproj +++ b/mRemoteV1/mRemoteV1.csproj @@ -248,6 +248,7 @@ frmOptions.cs + AdvancedPage.cs