fixed input box form never returning dialog result "ok".panels/tabs could not be renamed and new themes could not be created

This commit is contained in:
Faryan Rezagholi
2018-12-25 19:31:28 +01:00
parent 7290245729
commit cbce5729fd
8 changed files with 74 additions and 54 deletions

View File

@@ -1,6 +1,6 @@
namespace mRemoteNG.UI.Forms.Input
{
partial class InputBox
partial class FrmInputBox
{
/// <summary>
/// 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;

View File

@@ -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();
}
}
}

View File

@@ -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);
}
}
}
}

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)
{

View File

@@ -497,11 +497,11 @@
<DependentUpon>FrmSplashScreen.cs</DependentUpon>
</Compile>
<Compile Include="UI\Forms\FullscreenHandler.cs" />
<Compile Include="UI\Forms\Input\InputBox.cs">
<Compile Include="UI\Forms\Input\FrmInputBox.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\Forms\Input\InputBox.Designer.cs">
<DependentUpon>InputBox.cs</DependentUpon>
<Compile Include="UI\Forms\Input\FrmInputBox.Designer.cs">
<DependentUpon>FrmInputBox.cs</DependentUpon>
</Compile>
<Compile Include="UI\Forms\OptionsPages\AdvancedPage.Designer.cs">
<DependentUpon>AdvancedPage.cs</DependentUpon>
@@ -804,8 +804,8 @@
<EmbeddedResource Include="UI\Forms\FrmSplashScreen.resx">
<DependentUpon>FrmSplashScreen.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\Forms\Input\InputBox.resx">
<DependentUpon>InputBox.cs</DependentUpon>
<EmbeddedResource Include="UI\Forms\Input\FrmInputBox.resx">
<DependentUpon>FrmInputBox.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\Forms\OptionsPages\CredentialsPage.resx">
<DependentUpon>CredentialsPage.cs</DependentUpon>