-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSessionOptionsDialog.cs
More file actions
75 lines (61 loc) · 2.2 KB
/
SessionOptionsDialog.cs
File metadata and controls
75 lines (61 loc) · 2.2 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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 MuTTY
{
public partial class SessionOptionsDialog : Form
{
public SessionInfo Session;
public String OKButtonText = "Ok";
public List<SessionGroup> SessionGroups;
public SessionGroup SelectedGroup;
public bool AllowGroupSelect = true;
public SessionOptionsDialog()
{
InitializeComponent();
cbSessionType.DropDownStyle = ComboBoxStyle.DropDownList;
// Add all types to session type dropdown
foreach (SessionType type in Enum.GetValues(typeof(SessionType)))
cbSessionType.Items.Add(type);
}
private void SessionOptionsDialog_Load(object sender, EventArgs e)
{
if (Session == null)
Session = new SessionInfo();
groupComboBox.Items.Clear();
foreach (SessionGroup group in SessionGroups)
groupComboBox.Items.Add(group);
groupComboBox.SelectedItem = SelectedGroup;
groupComboBox.Enabled = AllowGroupSelect;
cbSessionType.SelectedItem = Session.Type;
txtHost.Text = Session.Host;
txtUsername.Text = Session.Username;
btnConnect.Text = OKButtonText;
}
private void btnConnect_Click(object sender, EventArgs e)
{
if (txtHost.Text.Trim().Length == 0)
{
MessageBox.Show("Please enter a hostname.", "No hostname", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
return;
}
Session.Type = (SessionType)cbSessionType.SelectedItem;
Session.Host = txtHost.Text;
Session.Username = txtUsername.Text;
SelectedGroup = (SessionGroup)groupComboBox.SelectedItem;
DialogResult = DialogResult.OK;
Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}