-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectDialog.cs
More file actions
57 lines (49 loc) · 1.77 KB
/
ConnectDialog.cs
File metadata and controls
57 lines (49 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Linq;
using System.Windows.Forms;
using System.Collections.Generic;
namespace RedisAdmin
{
public partial class ConnectDialog : Form
{
private Main Main { get; set; }
private List<RedisCredentials> Credentials { get; set; }
public ConnectDialog( Main Main, List<RedisCredentials> Credentials )
{
this.Main = Main;
this.Credentials = Credentials;
InitializeComponent();
if( this.Credentials == null ) return;
this.nickname.Items.Clear();
this.host.Text = string.Empty;
this.port.Text = string.Empty;
foreach( var c in this.Credentials )
{
this.nickname.Items.Add( c.Name );
}
}
private void button1_Click( object sender, EventArgs e )
{
this.button1.Text = @"Please wait...";
this.button1.Enabled = false;
this.Main.Authorize( new RedisCredentials
{
Name = this.nickname.Text,
Host = this.host.Text,
Port = int.Parse( this.port.Text ),
Password = this.password.Text
} );
this.DialogResult = System.Windows.Forms.DialogResult.OK;
this.Close();
}
private void nickname_SelectedIndexChanged( object sender, EventArgs e )
{
if( this.Credentials == null ) return;
var c = this.Credentials.FirstOrDefault( m => m.Name.Equals( this.nickname.Text, StringComparison.OrdinalIgnoreCase ) );
if( c == null ) return;
this.host.Text = c.Host;
this.port.Text = c.Port.ToString();
this.password.Text = c.Password;
}
}
}