|
8 | 8 | using postgres_database_restore_tool.ValueObject; |
9 | 9 | using postgres_database_restore_tool.Constants; |
10 | 10 | using postgres_database_restore_tool.Properties; |
| 11 | +using System.Drawing; |
11 | 12 |
|
12 | 13 | namespace postgres_database_restore_tool |
13 | 14 | { |
14 | 15 | public partial class PgAdmin : Form |
15 | 16 | { |
16 | 17 | private bool isRestoring = false; |
| 18 | + private bool isPasswordVisible = false; |
17 | 19 |
|
18 | 20 | public PgAdmin() |
19 | 21 | { |
@@ -49,6 +51,7 @@ private void AddEventHandlers() |
49 | 51 | private void OnFormLoad(object sender, EventArgs e) |
50 | 52 | { |
51 | 53 | ApplyTheme(); |
| 54 | + RenderPasswordToggleState(); |
52 | 55 |
|
53 | 56 | LoadPostgresUserData(); |
54 | 57 |
|
@@ -87,6 +90,7 @@ private void ApplyTheme() |
87 | 90 | FileOpenElem.ApplyRegularFont(); |
88 | 91 | rememberPassword.ApplyRegularFont(); |
89 | 92 | statusStrip1.ApplyRegularFont(); |
| 93 | + passwordToggleButton.ApplyRegularFont(); |
90 | 94 | } |
91 | 95 |
|
92 | 96 | private void LoadPostgresUserData() |
@@ -196,5 +200,28 @@ private void RememberPassword_CheckedChanged(object sender, EventArgs e) |
196 | 200 | Settings.Default.Save(); |
197 | 201 | } |
198 | 202 | } |
| 203 | + |
| 204 | + private void passwordToggleButton_Click(object sender, EventArgs e) |
| 205 | + { |
| 206 | + isPasswordVisible = !isPasswordVisible; |
| 207 | + |
| 208 | + RenderPasswordToggleState(); |
| 209 | + } |
| 210 | + |
| 211 | + private void RenderPasswordToggleState() |
| 212 | + { |
| 213 | + PasswordElm.PasswordChar = isPasswordVisible ? '\0' : '*'; |
| 214 | + |
| 215 | + if (isPasswordVisible) |
| 216 | + { |
| 217 | + passwordToggleButton.BackColor = Color.CornflowerBlue; |
| 218 | + passwordToggleButton.ForeColor = Color.White; |
| 219 | + } |
| 220 | + else |
| 221 | + { |
| 222 | + passwordToggleButton.BackColor = Color.White; |
| 223 | + passwordToggleButton.ForeColor = Color.Black; |
| 224 | + } |
| 225 | + } |
199 | 226 | } |
200 | 227 | } |
0 commit comments