Skip to content

Commit

Permalink
Adding Prompt class for #22
Browse files Browse the repository at this point in the history
  • Loading branch information
rappen committed Nov 1, 2022
1 parent b4251bf commit b869f67
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions CustomActionTester/CAT.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
<Compile Include="EntityMetadataProxy.cs" />
<Compile Include="ICATTool.cs" />
<Compile Include="MetadataHelper.cs" />
<Compile Include="Prompt.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
34 changes: 34 additions & 0 deletions CustomActionTester/Prompt.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Windows.Forms;

namespace Rappen.XTB.XmlEditorUtils
{
public static class Prompt
{
public static string ShowDialog(string text, string caption, string startvalue = "")
{
Form prompt = new Form();
prompt.Width = 500;
prompt.Height = 150;
prompt.Text = caption;
prompt.StartPosition = FormStartPosition.CenterScreen;
prompt.FormBorderStyle = FormBorderStyle.FixedDialog;
Label textLabel = new Label() { Left = 50, Top = 20, Width = 430, Text = text };
TextBox textBox = new TextBox() { Left = 50, Top = 45, Width = 400, Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right, Text = startvalue };
Button cancellation = new Button() { Text = "Cancel", Left = 220, Width = 100, Top = 80, DialogResult = DialogResult.Cancel };
Button confirmation = new Button() { Text = "OK", Left = 350, Width = 100, Top = 80, DialogResult = DialogResult.OK };
//confirmation.Click += (sender, e) => { prompt.Close(); };
prompt.Controls.Add(textBox);
prompt.Controls.Add(cancellation);
prompt.Controls.Add(confirmation);
prompt.Controls.Add(textLabel);
prompt.CancelButton = cancellation;
prompt.AcceptButton = confirmation;
string result = null;
if (prompt.ShowDialog() == DialogResult.OK)
{
result = textBox.Text;
}
return result;
}
}
}

0 comments on commit b869f67

Please sign in to comment.