Mercurial > servermonitor
annotate ServerMonitor/Forms/InputDialog.cs @ 6:c1dffaac66fa
- Don't show multiple password dialogs for the same key if the first one was cancelled.
- Add option to trim log files.
author | Brad Greco <brad@bgreco.net> |
---|---|
date | Fri, 01 Mar 2019 21:38:22 -0500 |
parents | b6fe203af9d5 |
children | 7127d5b5ac75 |
rev | line source |
---|---|
5
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
1 using System; |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
2 using System.Collections.Generic; |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
3 using System.ComponentModel; |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
4 using System.Data; |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
5 using System.Drawing; |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
6 using System.Linq; |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
7 using System.Text; |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
8 using System.Threading.Tasks; |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
9 using System.Windows.Forms; |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
10 |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
11 namespace ServerMonitorApp |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
12 { |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
13 public partial class InputDialog : Form |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
14 { |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
15 public string Message { get; set; } |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
16 |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
17 public Icon MessageIcon { get; set; } |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
18 |
6
c1dffaac66fa
- Don't show multiple password dialogs for the same key if the first one was cancelled.
Brad Greco <brad@bgreco.net>
parents:
5
diff
changeset
|
19 public string Input { get; private set; } = ""; |
5
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
20 |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
21 public InputDialog() |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
22 { |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
23 InitializeComponent(); |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
24 } |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
25 |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
26 private void InputDialog_Load(object sender, EventArgs e) |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
27 { |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
28 MessageIconPictureBox.Image = (MessageIcon ?? SystemIcons.Question).ToBitmap(); |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
29 MessageLabel.Text = Message; |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
30 } |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
31 |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
32 public static string ShowDialog(string message, Icon icon = null, IWin32Window owner = null) |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
33 { |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
34 using (InputDialog dialog = new InputDialog() { Message = message, MessageIcon = icon }) |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
35 { |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
36 return dialog.ShowDialog(owner) == DialogResult.OK ? dialog.Input : null; |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
37 } |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
38 } |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
39 |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
40 private void InputTextBox_TextChanged(object sender, EventArgs e) |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
41 { |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
42 Input = InputTextBox.Text; |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
43 } |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
44 } |
b6fe203af9d5
Private key passwords and validation
Brad Greco <brad@bgreco.net>
parents:
diff
changeset
|
45 } |