public override void ViewDidLoad() { base.ViewDidLoad(); doSegue = false; // Prevents segue from occurring if validation has failed // Set handlers for TextFields ipTextField.ShouldReturn += TextFieldShouldReturn; usernameTextField.ShouldReturn += TextFieldShouldReturn; passwordTextField.ShouldReturn += TextFieldShouldReturn; /* * StatusButton Handler * */ statusButton.TouchUpInside += (object sender, EventArgs e) => { endpoint = setDevice(ipTextField.Text, usernameTextField.Text, passwordTextField.Text); if (endpoint != null) { PerformSegue("statusSegue", this); } }; /* * ProfileButton event handler * */ profileButton.TouchUpInside += (object sender, EventArgs e) => { endpoint = setDevice(ipTextField.Text, usernameTextField.Text, passwordTextField.Text); if (endpoint != null) { PerformSegue("profileSegue", this); } }; /* * APIButton event handler * */ apiButton.TouchUpInside += (object sender, EventArgs e) => { endpoint = setDevice(ipTextField.Text, usernameTextField.Text, passwordTextField.Text); if (endpoint != null) { doSegue = true; if (selectedDeviceSegment.SelectedSegment == 0) { PerformSegue("apiSegue", this); } else { var okAlertController = UIAlertController.Create("Info:", "Feature only available for HDX devices", UIAlertControllerStyle.Alert); okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(okAlertController, true, null); doSegue = false; } } }; }
public RPDevice setDevice(string ip, string un, string pw) { RPDevice device = null; if (isValidIP(ipTextField.Text) && isValidUsername(usernameTextField.Text)) { if (selectedDeviceSegment.SelectedSegment == 0) { device = new HDXDevice(ip, un, pw); } else if (selectedDeviceSegment.SelectedSegment == 1) { device = new GroupSeriesDevice(ip, un, pw); } } return(device); }
public List <string> getProfileList(RPDevice device) { var list = new List <string>(); try { device.getSession(); list = device.getProfile(); } catch (Exception e) { var okAlertController = UIAlertController.Create("Error", e.Message, UIAlertControllerStyle.Alert); okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(okAlertController, true, null); } return(list); }