/dotnet/LoginForm.cs
C# | 71 lines | 55 code | 16 blank | 0 comment | 1 complexity | daaaf656ed889bc5a264ee7486e9ad95 MD5 | raw file
1using System; 2using System.Collections.Generic; 3using System.ComponentModel; 4using System.Data; 5using System.Drawing; 6using System.Linq; 7using System.Text; 8using System.Windows.Forms; 9 10using ActivityInfo.Api; 11 12namespace ActivityInfo 13{ 14 public partial class LoginForm : Form 15 { 16 17 private ActivityInfoService service; 18 19 public LoginForm() 20 { 21 InitializeComponent(); 22 23 serverCombo.Text = (string)Application.UserAppDataRegistry.GetValue("Server"); 24 emailTextBox.Text = (string) Application.UserAppDataRegistry.GetValue("Email"); 25 passwordTextBox.Text = (string) Application.UserAppDataRegistry.GetValue("Password"); 26 } 27 28 29 private void okButton_Click(object sender, EventArgs e) 30 { 31 try 32 { 33 String serverUrl = serverCombo.Text; 34 if (!serverUrl.EndsWith("/")) 35 { 36 serverUrl += "/"; 37 } 38 service = new ActivityInfoService(serverUrl, emailTextBox.Text, passwordTextBox.Text); 39 40 Application.UserAppDataRegistry.SetValue("Server", serverUrl); 41 Application.UserAppDataRegistry.SetValue("Email", emailTextBox.Text); 42 Application.UserAppDataRegistry.SetValue("Password", passwordTextBox.Text); 43 44 this.Hide(); 45 } 46 catch (AuthenticationException) 47 { 48 MessageBox.Show(this, "Invalid Login"); 49 } 50 51 } 52 53 private void LoginForm_Load(object sender, EventArgs e) 54 { 55 56 } 57 58 private void cancelButton_Click(object sender, EventArgs e) 59 { 60 service = null; 61 this.Hide(); 62 } 63 64 public ActivityInfoService Service { get { return service; } } 65 66 private void label3_Click(object sender, EventArgs e) 67 { 68 69 } 70 } 71}