diff ServerMonitor/Forms/InputDialog.cs @ 5:b6fe203af9d5

Private key passwords and validation
author Brad Greco <brad@bgreco.net>
date Thu, 28 Feb 2019 21:19:32 -0500
parents
children c1dffaac66fa
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ServerMonitor/Forms/InputDialog.cs	Thu Feb 28 21:19:32 2019 -0500
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ServerMonitorApp
+{
+    public partial class InputDialog : Form
+    {
+        public string Message { get; set; }
+
+        public Icon MessageIcon { get; set; }
+
+        public string Input { get; private set; }
+
+        public InputDialog()
+        {
+            InitializeComponent();
+        }
+
+        private void InputDialog_Load(object sender, EventArgs e)
+        {
+            MessageIconPictureBox.Image = (MessageIcon ?? SystemIcons.Question).ToBitmap();
+            MessageLabel.Text = Message;
+        }
+
+        public static string ShowDialog(string message, Icon icon = null, IWin32Window owner = null)
+        {
+            using (InputDialog dialog = new InputDialog() { Message = message, MessageIcon = icon })
+            {
+                return dialog.ShowDialog(owner) == DialogResult.OK ? dialog.Input : null;
+            }
+        }
+
+        private void InputTextBox_TextChanged(object sender, EventArgs e)
+        {
+            Input = InputTextBox.Text;
+        }
+    }
+}