public void addNewItem(object sender, EventArgs e) { UIAlertView alert = new UIAlertView( NSBundle.MainBundle.LocalizedString("Create an Asset Type", "Create Asset Type"), NSBundle.MainBundle.LocalizedString("Please enter a new asset type", "Please Enter"), null, NSBundle.MainBundle.LocalizedString("Cancel", "Cancel"), new string[]{NSBundle.MainBundle.LocalizedString("Done", "Done")}); alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; UITextField alerttextField = alert.GetTextField(0); alerttextField.KeyboardType = UIKeyboardType.Default; alerttextField.Placeholder = NSBundle.MainBundle.LocalizedString("Enter a new asset type", "Enter New"); alert.Show(); // Use for silver challenge alert.Clicked += (object avSender, UIButtonEventArgs ave) => { if (ave.ButtonIndex == 1) { Console.WriteLine("Entered: {0}", alert.GetTextField(0).Text); BNRItemStore.addAssetType(alert.GetTextField(0).Text); TableView.ReloadData(); NSIndexPath ip = NSIndexPath.FromRowSection(BNRItemStore.allAssetTypes.Count-1, 0); this.RowSelected(TableView, ip); } else { this.NavigationController.PopViewController(true); } }; }
public void Display (string body, string title, GoalsAvailable goalAvailable, string cancelButtonTitle, string acceptButtonTitle = "", Action<GoalsAvailable, int> action = null) { UIAlertView alert = new UIAlertView(); alert.Title = title; alert.AddButton(acceptButtonTitle); alert.AddButton(cancelButtonTitle); alert.Message = body; alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; alert.GetTextField(0).KeyboardType=UIKeyboardType.NumberPad; const int maxCharacters =7; alert.GetTextField(0).ShouldChangeCharacters = (textField, range, replacement) => { var newContent = new NSString(textField.Text).Replace(range, new NSString(replacement)).ToString(); int number; return newContent.Length <= maxCharacters && (replacement.Length == 0 || int.TryParse(replacement, out number)); }; alert.Clicked += (object s, UIButtonEventArgs ev) => { if(action != null) { if(ev.ButtonIndex ==0) { string input = alert.GetTextField(0).Text; int goalValue; int.TryParse(input, out goalValue); action.Invoke(goalAvailable, goalValue); } } }; alert.Show(); }
private static Task<string> PlatformShow(string title, string description, string defaultText, bool usePasswordMode) { tcs = new TaskCompletionSource<string>(); UIApplication.SharedApplication.InvokeOnMainThread(delegate { alert = new UIAlertView(); alert.Title = title; alert.Message = description; alert.AlertViewStyle = usePasswordMode ? UIAlertViewStyle.SecureTextInput : UIAlertViewStyle.PlainTextInput; alert.AddButton("Cancel"); alert.AddButton("Ok"); UITextField alertTextField = alert.GetTextField(0); alertTextField.KeyboardType = UIKeyboardType.ASCIICapable; alertTextField.AutocorrectionType = UITextAutocorrectionType.No; alertTextField.AutocapitalizationType = UITextAutocapitalizationType.Sentences; alertTextField.Text = defaultText; alert.Dismissed += (sender, e) => { if (!tcs.Task.IsCompleted) tcs.SetResult(e.ButtonIndex == 0 ? null : alert.GetTextField(0).Text); }; // UIAlertView's textfield does not show keyboard in iOS8 // http://stackoverflow.com/questions/25563108/uialertviews-textfield-does-not-show-keyboard-in-ios8 if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) alert.Presented += (sender, args) => alertTextField.SelectAll(alert); alert.Show(); }); return tcs.Task; }
public override void LoadView() { base.LoadView(); _MapView = new MapView() { MyLocationEnabled = true, }; _Markers.ForEach(mmi => mmi.Map = _MapView); _MapView.Settings.RotateGestures = false; _MapView.Tapped += (object tapSender, GMSCoordEventArgs coordEventArgs) => { UIAlertView nameInputAlertView = new UIAlertView("Add New Marker", "", null, "Cancel", new[] { "Add" }) { AlertViewStyle = UIAlertViewStyle.PlainTextInput, }; UITextField nameTextField = nameInputAlertView.GetTextField(0); nameTextField.Placeholder = "Marker name"; nameTextField.BecomeFirstResponder(); nameInputAlertView.Dismissed += (sender, e) => { if (e.ButtonIndex != nameInputAlertView.CancelButtonIndex) { MarkerInfo newMarkerInfo = new MarkerInfo() { Latitude = coordEventArgs.Coordinate.Latitude, Longitude = coordEventArgs.Coordinate.Longitude, Name = nameTextField.Text, }; NewMarkerCreated(this, new MarkerAddedEventArgs(newMarkerInfo)); } }; nameInputAlertView.Show(); }; View = _MapView; }
async Task<bool> SignIn() { var tcs = new TaskCompletionSource<bool> (); var alert = new UIAlertView ("Please sign in", "", null, "Cancel", "Ok"); alert.AlertViewStyle = UIAlertViewStyle.SecureTextInput; var tb = alert.GetTextField(0); tb.ShouldReturn = (t)=>{ alert.DismissWithClickedButtonIndex(1,true); signIn(tcs,tb.Text); return true; }; alert.Clicked += async (object sender, UIButtonEventArgs e) => { if(e.ButtonIndex == 0) { tcs.TrySetResult(false); alert.Dispose(); return; } var id = tb.Text; signIn(tcs,id); }; alert.Show (); return await tcs.Task; }
public override void Login(LoginConfig config) { UITextField txtUser = null; UITextField txtPass = null; if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var dlg = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert); dlg.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, true)))); dlg.AddAction(UIAlertAction.Create(config.CancelText, UIAlertActionStyle.Default, x => config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, false)))); dlg.AddTextField(x => { txtUser = x; x.Placeholder = config.LoginPlaceholder; x.Text = config.LoginValue ?? String.Empty; }); dlg.AddTextField(x => { txtPass = x; x.Placeholder = config.PasswordPlaceholder; x.SecureTextEntry = true; }); this.Present(dlg); } else { var dlg = new UIAlertView { AlertViewStyle = UIAlertViewStyle.LoginAndPasswordInput, Title = config.Title, Message = config.Message }; txtUser = dlg.GetTextField(0); txtPass = dlg.GetTextField(1); txtUser.Placeholder = config.LoginPlaceholder; txtUser.Text = config.LoginValue ?? String.Empty; txtPass.Placeholder = config.PasswordPlaceholder; dlg.AddButton(config.OkText); dlg.AddButton(config.CancelText); dlg.CancelButtonIndex = 1; dlg.Clicked += (s, e) => { var ok = ((int)dlg.CancelButtonIndex != (int)e.ButtonIndex); config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, ok)); }; this.Present(dlg); } }
public override void Login(LoginConfig config) { this.Dispatch(() => { var dlg = new UIAlertView { AlertViewStyle = UIAlertViewStyle.LoginAndPasswordInput }; var txtUser = dlg.GetTextField(0); var txtPass = dlg.GetTextField(1); txtUser.Placeholder = config.LoginPlaceholder; txtUser.Text = config.LoginValue ?? String.Empty; txtPass.Placeholder = config.PasswordPlaceholder; txtPass.SecureTextEntry = true; dlg.Clicked += (s, e) => { var ok = (dlg.CancelButtonIndex != e.ButtonIndex); config.OnResult(new LoginResult(txtUser.Text, txtPass.Text, ok)); }; dlg.Show(); }); }
public override void Dismissed(UIAlertView alertView, int buttonIndex) { if (buttonIndex == alertView.CancelButtonIndex) cancelAction(); else if (alertView.AlertViewStyle == UIAlertViewStyle.SecureTextInput) okActionOfString(alertView.GetTextField(0).Text); else okAction(); }
public void Display (string body, string title, BarriersAvailable barrierAvailable, string cancelButtonTitle, string acceptButtonTitle = "", Action<BarriersAvailable, string> action = null) { UIAlertView alert = new UIAlertView(); alert.Title = title; alert.AddButton(acceptButtonTitle); alert.AddButton(cancelButtonTitle); alert.Message = body; alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; var textField = alert.GetTextField (0); CGRect frameRect = textField.Frame; CGSize size = new CGSize (150, 60); frameRect.Size = size; textField.Frame = frameRect; alert.Clicked += (object s, UIButtonEventArgs ev) => { if(action != null) { if(ev.ButtonIndex ==0) { string input = alert.GetTextField(0).Text; action.Invoke(barrierAvailable, input); } } }; alert.Show(); // UIAlertController alert = UIAlertController.Create (title, body, UIAlertControllerStyle.Alert); // // alert.AddAction (UIAlertAction.Create (acceptButtonTitle, UIAlertActionStyle.Default, action2 => { // //SendComment(alert.TextFields[0].Text); // string input = alert.TextFields[0].Text; // action.Invoke(barrierAvailable, input); // })); // // alert.AddAction (UIAlertAction.Create (cancelButtonTitle, UIAlertActionStyle.Cancel, null)); // alert.AddTextField ((field) => { // field.Placeholder = title; // }); // // alert. }
public Task<string> PromptTextBox(string title, string message, string defaultValue, string okTitle) { var tcs = new TaskCompletionSource<string>(); var alert = new UIAlertView(); alert.Title = title; alert.Message = message; alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; var cancelButton = alert.AddButton("Cancel"); var okButton = alert.AddButton(okTitle); alert.CancelButtonIndex = cancelButton; alert.GetTextField(0).Text = defaultValue; alert.Clicked += (s, e) => { if (e.ButtonIndex == okButton) tcs.SetResult(alert.GetTextField(0).Text); else tcs.SetCanceled(); }; alert.Show(); return tcs.Task; }
public void AskForString(string message, string title, System.Action<string> returnString) { Helpers.EnsureInvokedOnMainThread (() => { var alertView = new UIAlertView (title ?? string.Empty, message, null, "OK", "Cancel"); alertView.AlertViewStyle = UIAlertViewStyle.PlainTextInput; alertView.Clicked += (sender, e) => { var text = alertView.GetTextField(0).Text.Trim(); if(e.ButtonIndex == 0 && !string.IsNullOrWhiteSpace(text)) returnString (text); }; alertView.Show (); }); }
private void Save() { /* _messageDb.SaveMessage(textViewMessage.Text); */ var alert = new UIAlertView("Enter Password", "Password", null, "OK", null) { AlertViewStyle = UIAlertViewStyle.SecureTextInput }; alert.Clicked += (s, a) => { _messageDb.Password = alert.GetTextField(0).Text; _messageDb.SaveMessage(textViewMessage.Text); }; alert.Show(); }
public void EnterTextMessage(string title, string message, Action<string> completed) { var alert = new UIAlertView(title, message, null, "Enter", "Cancel") { AlertViewStyle = UIAlertViewStyle.PlainTextInput }; alert.Dismissed += (sender2, args) => { if (args.ButtonIndex != 0) return; completed(alert.GetTextField(0).Text.Trim()); }; alert.Show(); }
public void Input(string message, Action<bool, string> answer, string placeholder = null, string title = null, string okButton = "OK", string cancelButton = "Cancel") { UIApplication.SharedApplication.InvokeOnMainThread(() => { var input = new UIAlertView(title ?? string.Empty, message, null, cancelButton, okButton); input.AlertViewStyle = UIAlertViewStyle.PlainTextInput; var textField = input.GetTextField(0); textField.Placeholder = placeholder; if (answer != null) { input.Clicked += (sender, args) => answer(input.CancelButtonIndex != args.ButtonIndex, textField.Text); } input.Show(); }); }
void HandleCreateSheetClicked (object sender, UIButtonEventArgs e) { var actionSheet = (UIActionSheet)sender; if (e.ButtonIndex != actionSheet.CancelButtonIndex) { creatingFolder = e.ButtonIndex > 0; string title = creatingFolder ? "Create folder" : "Create a file"; var alert = new UIAlertView (title, "", null, "Cancel", new string[] {"Create"}); alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; alert.Clicked += (s, a) => { if (a.ButtonIndex != alert.CancelButtonIndex) { string input = alert.GetTextField (0).Text; CreateAt (input); } DispatchQueue.DefaultGlobalQueue.DispatchAsync (() => LoadFiles ()); }; alert.Show (); } }
public override void Prompt(string message, Action<PromptResult> promptResult, string title, string okText, string cancelText, string placeholder, int lines) { this.Dispatch(() => { var result = new PromptResult(); var dlg = new UIAlertView(title ?? String.Empty, message, null, cancelText, okText) { AlertViewStyle = UIAlertViewStyle.PlainTextInput }; var txt = dlg.GetTextField(0); txt.Placeholder = placeholder; //UITextView = editable dlg.Clicked += (s, e) => { result.Ok = (dlg.CancelButtonIndex != e.ButtonIndex); result.Text = txt.Text; promptResult(result); }; dlg.Show(); }); }
partial void Add (NSObject sender) { if (this.prompt != null) this.prompt.Dispose (); this.prompt = new UIAlertView ("Add Item", String.Empty, null, "Cancel", "Add"); this.prompt.AlertViewStyle = UIAlertViewStyle.PlainTextInput; this.prompt.Clicked += (s, e) => { if (e.ButtonIndex == 1) { UITextField text = prompt.GetTextField (0); todoTable.InsertAsync (new TodoItem { Text = text.Text }) .ContinueWith (t => this.itemController.RefreshAsync(), scheduler); } }; this.prompt.Show(); }
void Input(string message, Action<bool, string> answer, string placeholder = null, string title = null, string okButton = "OK", string cancelButton = "Cancel", bool password = false) { DismissAll(); UIApplication.SharedApplication.InvokeOnMainThread(() => { alertView = new UIAlertView(title ?? string.Empty, message, null, cancelButton, okButton); alertView.AlertViewStyle = password ? UIAlertViewStyle.SecureTextInput : UIAlertViewStyle.PlainTextInput; var textField = alertView.GetTextField(0); textField.Placeholder = placeholder; if (answer != null) { alertView.Clicked += (sender, args) => { answer(alertView.CancelButtonIndex != args.ButtonIndex, textField.Text); }; } alertView.Show(); }); }
// Process to save the file on Dropbox void WriteFile (object sender, EventArgs e) { // Notify that the user has ended typing textView.EndEditing (true); // Ask for a name to the file var alertView = new UIAlertView ("Save to Dropbox", "Enter a name for the file", null, "Cancel", new [] { "Save" }); alertView.AlertViewStyle = UIAlertViewStyle.PlainTextInput; alertView.Clicked += (avSender, avE) => { // Once we have the name, we need to save the file locally first and then upload it to Dropbox if (avE.ButtonIndex == 1) { filename = alertView.GetTextField (0).Text + ".txt"; var fullPath = Path.GetTempPath () + filename; // Write the file locally File.WriteAllText (fullPath, textView.Text); // Now upload it to Dropbox restClient.UploadFile (filename, DropboxCredentials.FolderPath, null, fullPath); } }; alertView.Show (); }
private void Load() { /* textViewMessage.Text = _messageDb.LoadMessage(); */ var alert = new UIAlertView("Enter Password", "Password", null, "OK", null) { AlertViewStyle = UIAlertViewStyle.SecureTextInput }; alert.Clicked += (s, a) => { _messageDb.Password = alert.GetTextField(0).Text; try { textViewMessage.Text = _messageDb.LoadMessage(); } catch (Exception e) { textViewMessage.Text = e.Message; } }; alert.Show(); }
public override void Prompt(PromptConfig config) { this.Dispatch(() => { var result = new PromptResult(); var dlg = new UIAlertView(config.Title ?? String.Empty, config.Message, null, config.CancelText, config.OkText) { AlertViewStyle = config.InputType == InputType.Password ? UIAlertViewStyle.SecureTextInput : UIAlertViewStyle.PlainTextInput }; var txt = dlg.GetTextField(0); txt.SecureTextEntry = config.InputType == InputType.Password; txt.Placeholder = config.Placeholder; txt.KeyboardType = Utils.GetKeyboardType(config.InputType); dlg.Clicked += (s, e) => { result.Ok = (dlg.CancelButtonIndex != e.ButtonIndex); result.Text = txt.Text; config.OnResult(result); }; dlg.Show(); }); }
// Process to save the file on Dropbox void WriteFile(object sender, EventArgs e) { // Notify that the user has ended typing textView.EndEditing(true); // Ask for a name to the file var alertView = new UIAlertView("Save to Dropbox", "Enter a name for the file", null, "Cancel", new [] { "Save" }); alertView.AlertViewStyle = UIAlertViewStyle.PlainTextInput; alertView.Clicked += (avSender, avE) => { // Once we have the name, we need to save the file locally first and then upload it to Dropbox if (avE.ButtonIndex == 1) { filename = alertView.GetTextField(0).Text + ".txt"; var fullPath = Path.GetTempPath() + filename; // Write the file locally File.WriteAllText(fullPath, textView.Text); // Now upload it to Dropbox restClient.UploadFile(filename, DropboxCredentials.FolderPath, null, fullPath); } }; alertView.Show(); }
public override void Prompt(PromptConfig config) { this.Dispatch(() => { var result = new PromptResult(); var dlg = new UIAlertView(config.Title ?? String.Empty, config.Message, null, config.CancelText, config.OkText) { AlertViewStyle = config.InputType == InputType.Password ? UIAlertViewStyle.SecureTextInput : UIAlertViewStyle.PlainTextInput }; var txt = dlg.GetTextField(0); txt.SecureTextEntry = config.InputType == InputType.Password; txt.Placeholder = config.Placeholder; txt.KeyboardType = Utils.GetKeyboardType(config.InputType); dlg.Clicked += (s, e) => { result.Ok = (dlg.CancelButtonIndex != e.ButtonIndex); result.Text = txt.Text; config.OnResult(result); }; dlg.Show(); }); }
private void Stuff() { var alert = new UIAlertView(); alert.Title = "Enterprise URL"; alert.Message = "Please enter the webpage address for the GitHub Enterprise installation"; alert.CancelButtonIndex = alert.AddButton("Cancel"); var okButton = alert.AddButton("Ok"); alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; alert.Clicked += (sender, e) => { if (e.ButtonIndex == okButton) { var txt = alert.GetTextField(0); ViewModel.WebDomain = txt.Text; LoadRequest(); } if (e.ButtonIndex == alert.CancelButtonIndex) { ViewModel.GoBackCommand.Execute(null); } }; alert.Show(); }
partial void Add(NSObject sender) { if (this.prompt != null) { this.prompt.Dispose(); } this.prompt = new UIAlertView("Add Item", String.Empty, null, "Cancel", "Add"); this.prompt.AlertViewStyle = UIAlertViewStyle.PlainTextInput; this.prompt.Clicked += (s, e) => { if (e.ButtonIndex == 1) { UITextField text = prompt.GetTextField(0); todoTable.InsertAsync(new TodoItem { Text = text.Text }) .ContinueWith(t => this.itemController.RefreshAsync(), scheduler); } }; this.prompt.Show(); }
private void CreateAlertDialog(TableSource tableSource) { UIAlertView alert = new UIAlertView(); alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; alert.Title = "Neuen Task anlegen"; alert.AddButton("Abbrechen"); alert.AddButton("OK"); alert.Show(); alert.Clicked += (sender, args) => { if (args.ButtonIndex == 1) { var newTask = new Task(); newTask.Name = alert.GetTextField(0).Text; newTask.IsDone = false; newTask.CreateDate = DateTime.Now; tableSource.taskList.Add(newTask); tableView.ReloadData(); dbHelper.addTask(newTask); } }; }
/// <summary> /// Handle the two factor authentication nonsense by showing an alert view with a textbox for the code /// </summary> private static void HandleTwoFactorAuth(string apiUrl, string user, string pass, UIViewController ctrl) { var alert = new UIAlertView(); alert.Title = "Two-Factor Authentication"; alert.CancelButtonIndex = alert.AddButton("Cancel"); var okIndex = alert.AddButton("Ok"); alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; alert.Dismissed += async(object sender, UIButtonEventArgs e) => { if (e.ButtonIndex == okIndex) { try { await Authenticate(apiUrl, user, pass, alert.GetTextField(0).Text, ctrl); } catch (Exception ex) { MonoTouch.Utilities.ShowAlert("Error".t(), ex.Message); } } }; alert.Show(); }
public void ShowPopup(EntryPopup popup) { var alert = new UIAlertView { Title = popup.Title, Message = popup.Text, AlertViewStyle = UIAlertViewStyle.PlainTextInput }; foreach (var b in popup.Buttons) { alert.AddButton(b); } alert.Clicked += (s, args) => { popup.OnPopupClosed(new EntryPopupClosedArgs { Button = popup.Buttons.ElementAt(Convert.ToInt32(args.ButtonIndex)), Text = alert.GetTextField(0).Text }); }; alert.Show(); }
public void ShowPrompt(string title, string message, string affirmButton, string denyButton, Action <string> onAffirm, Action onDeny = null, string text = "", string placeholder = "", Func <string, bool> affirmEnableFunc = null, bool isPassword = false) { CancelAlert(); Utilities.Dispatch(() => { _Alert = new UIAlertView(title ?? string.Empty, message, null, denyButton, new string[] { affirmButton }) { AlertViewStyle = isPassword ? UIAlertViewStyle.SecureTextInput : UIAlertViewStyle.PlainTextInput }; var textField = _Alert.GetTextField(0); textField.Text = text; textField.SecureTextEntry = isPassword; textField.Placeholder = placeholder; _Alert.ShouldEnableFirstOtherButton = al => affirmEnableFunc?.Invoke(textField?.Text) ?? true; _Alert.Clicked += (s, e) => { if (_Alert.CancelButtonIndex == e.ButtonIndex) { onDeny?.Invoke(); } else { onAffirm?.Invoke(textField?.Text); } }; _Alert.Show(); }); }
public override void ViewDidLoad() { base.ViewDidLoad (); buttonAdd = new UIBarButtonItem (UIBarButtonSystemItem.Add); buttonAdd.Clicked += (sender, e) => { var arAdd = new UIAlertView("Load Url", "Enter a Wikitude World URL to Load:", null, "Cancel", "Load"); arAdd.AlertViewStyle = UIAlertViewStyle.PlainTextInput; arAdd.Clicked += (sender2, e2) => { var tf = arAdd.GetTextField(0); var url = tf.Text; var isOk = true; try { var uri = new Uri(url); } catch { isOk = false; } if (isOk) { AddUrl(url); Reload(); arController = new ARViewController (url, true); NavigationController.PushViewController (arController, true); } }; arAdd.Show(); }; NavigationItem.RightBarButtonItem = buttonAdd; Reload (); }
public override void ViewDidLoad() { base.ViewDidLoad(); buttonAdd = new UIBarButtonItem(UIBarButtonSystemItem.Add); buttonAdd.Clicked += (sender, e) => { var arAdd = new UIAlertView("Load Url", "Enter a Wikitude World URL to Load:", null, "Cancel", "Load"); arAdd.AlertViewStyle = UIAlertViewStyle.PlainTextInput; arAdd.Clicked += (sender2, e2) => { var tf = arAdd.GetTextField(0); var url = tf.Text; var isOk = true; try { var uri = new Uri(url); } catch { isOk = false; } if (isOk) { AddUrl(url); Reload(); arController = new ARViewController(url, true); NavigationController.PushViewController(arController, true); } }; arAdd.Show(); }; NavigationItem.RightBarButtonItem = buttonAdd; Reload(); }
public void AuthKey() { UIAlertView alert = new UIAlertView (); alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; alert.Title = "Auth Key"; alert.Message = "Enter Auth Key"; alert.AddButton ("Set"); alert.AddButton ("Cancel"); alert.Clicked += delegate(object sender, UIButtonEventArgs e) { if(e.ButtonIndex == 0) { if(alert.GetTextField(0) != null){ string input = alert.GetTextField(0).Text; pubnub.AuthenticationKey = input; Display("Auth Key Set"); } } }; alert.Show(); }
public void Publish() { UIAlertView alert = new UIAlertView (); alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; alert.Title = "Publish"; alert.Message = "Enter message to publish"; alert.AddButton ("Publish"); alert.AddButton ("Cancel"); alert.Clicked += delegate(object sender, UIButtonEventArgs e) { if(e.ButtonIndex == 0) { if(alert.GetTextField(0) != null){ string input = alert.GetTextField(0).Text; Display("Running Publish"); string[] channels = Channel.Split(','); foreach (string channel in channels) { pubnub.Publish<string> (channel.Trim(), input, DisplayReturnMessage, DisplayErrorMessage); } } } }; alert.Show(); }
void ShowAlertType1(CommonDialogStates cds) { UIAlertView alert = new UIAlertView(); alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; bool isHeartbeatInterval = false; string messageBoxTitle = "Set"; if (cds == CommonDialogStates.Auth) { alert.Title = "Auth Key"; alert.Message = "Enter Auth Key"; } else if ((cds == CommonDialogStates.AuditSubscribe) || (cds == CommonDialogStates.AuditPresence) || (cds == CommonDialogStates.RevokePresence) || (cds == CommonDialogStates.RevokeSubscribe)) { alert.Title = "Auth Key"; alert.Message = "Enter Auth Key (Optional)"; messageBoxTitle = cds.ToString(); } else if (cds == CommonDialogStates.PresenceHeartbeat) { alert.GetTextField(0).KeyboardType = UIKeyboardType.NumberPad; alert.Title = "Presence Heartbeat"; alert.Message = "Enter Presence Heartbeat"; } else if (cds == CommonDialogStates.PresenceHeartbeatInterval) { isHeartbeatInterval = true; alert.GetTextField(0).KeyboardType = UIKeyboardType.NumberPad; alert.Title = "Presence Heartbeat Interval"; alert.Message = "Enter Presence Heartbeat Interval"; } else if (cds == CommonDialogStates.ChangeUuid) { alert.Title = "Change UUID"; alert.Message = "Enter UUID"; } else if (cds == CommonDialogStates.WhereNow) { alert.Title = "Where Now"; alert.Message = "Enter UUID (optional)"; messageBoxTitle = "Where Now"; } alert.AddButton(messageBoxTitle); alert.AddButton("Cancel"); alert.Clicked += delegate(object sender, UIButtonEventArgs e) { if (e.ButtonIndex == 0) { if (alert.GetTextField(0) != null) { string input = alert.GetTextField(0).Text; Channel = newChannels.Text; if (cds == CommonDialogStates.Auth) { InvokeInBackground(() => { pubnub.AuthenticationKey = input; }); Display("Auth Key Set"); } else if (cds == CommonDialogStates.AuditSubscribe) { Display("Running Subscribe Audit"); InvokeInBackground(() => { pubnub.AuditAccess <string> (Channel, input, DisplayReturnMessage, DisplayErrorMessage); }); } else if (cds == CommonDialogStates.AuditPresence) { Display("Running Presence Audit"); InvokeInBackground(() => { pubnub.AuditPresenceAccess <string> (Channel, input, DisplayReturnMessage, DisplayErrorMessage); }); } else if (cds == CommonDialogStates.RevokePresence) { Display("Running Presence Revoke"); InvokeInBackground(() => { pubnub.GrantPresenceAccess <string> (Channel, input, false, false, DisplayReturnMessage, DisplayErrorMessage); }); } else if (cds == CommonDialogStates.RevokeSubscribe) { Display("Running Subscribe Revoke"); InvokeInBackground(() => { pubnub.GrantAccess <string> (Channel, input, false, false, DisplayReturnMessage, DisplayErrorMessage); }); } else if ((cds == CommonDialogStates.PresenceHeartbeat) || (cds == CommonDialogStates.PresenceHeartbeatInterval)) { int iVal; Int32.TryParse(input, out iVal); if (iVal != 0) { if (isHeartbeatInterval) { InvokeInBackground(() => { pubnub.PresenceHeartbeatInterval = iVal; }); Display(string.Format("Presence Heartbeat Interval set to {0}", pubnub.PresenceHeartbeatInterval)); } else { InvokeInBackground(() => { pubnub.PresenceHeartbeat = iVal; }); Display(string.Format("Presence Heartbeat set to {0}", pubnub.PresenceHeartbeat)); } } else { Display(string.Format("Value not numeric")); } } else if (cds == CommonDialogStates.ChangeUuid) { InvokeInBackground(() => { pubnub.ChangeUUID(input); }); Display(string.Format("UUID set to {0}", pubnub.SessionUUID)); } else if (cds == CommonDialogStates.WhereNow) { Display("Running where now"); InvokeInBackground(() => { pubnub.WhereNow <string> (input, DisplayReturnMessage, DisplayErrorMessage); }); } } } }; alert.Show(); }
private async Task<string> ShowAlert(string mh) { var alert = new UIAlertView(); alert.Title="Nhắc Lịch Cho Môn "+mh; alert.Message = "Nội dung"; alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; alert.AddButton ("OK"); alert.AddButton ("Cancel"); var tcs = new TaskCompletionSource<int>(); alert.Clicked += (s, e) => { tcs.SetResult (int.Parse (e.ButtonIndex.ToString ())); }; alert.Show(); await tcs.Task; string text = alert.GetTextField(0).Text; return text; }
void KeyboardDidHide(NSNotification obj) { if (clickedButtonIndex != -1 && clickedButtonIndex != uiAlertView.CancelButtonIndex && uiAlertView.GetTextField(0).Text != "" && (!(int.TryParse(uiAlertView.GetTextField(0).Text, out pageNum) && pageNum > 0 && pageNum <= pdfviewer.PageCount))) { alert.Show(); } NSNotificationCenter.DefaultCenter.RemoveObserver(notificationToken); }
public override void Dismissed(UIAlertView alertView, int buttonIndex) { if (buttonIndex == 1 && !ApplicationSettings.Instance.UserTimetablelist.Usernames.Contains(alertView.GetTextField(0).Text) && !String.IsNullOrEmpty(alertView.GetTextField(0).Text)) { ApplicationSettings.Instance.UserTimetablelist.Usernames.Add(alertView.GetTextField(0).Text); _usernameSection.Add(new StringElement(alertView.GetTextField(0).Text)); } }
void ChangeNameHandler(object sender, EventArgs e) { var alert = new UIAlertView (); alert.Canceled += (object s, EventArgs e2) => {}; // we crash if we don't assign Cancel delegate! alert.Title = "Please enter name."; alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; alert.Clicked += (object s, UIButtonEventArgs e2) => { if (alert.GetTextField(0).Text != _name) { _name = alert.GetTextField(0).Text; SetNameDate(); } }; alert.AddButton("Ok"); alert.Show (); }
public override void ViewDidLoad() { base.ViewDidLoad(); activityView = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge); activityView.Frame = View.Frame; activityView.BackgroundColor = UIColor.FromRGBA(0, 0, 0, 0.6f); activityView.Center = View.Center; activityView.HidesWhenStopped = true; View.AddSubview(activityView); tlc = TimeLoggingController.GetInstance(); if (timeLogEntry == null) { throw new ArgumentException("timeLogEntry is null."); } if (isAddingMode) { barBtnItem = new UIBarButtonItem(UIBarButtonSystemItem.Save, async(s, e) => { activityView.StartAnimating(); try { await PDashAPI.Controller.AddATimeLog(timeLogEntry.Comment, timeLogEntry.StartDate, timeLogEntry.Task.Id, timeLogEntry.LoggedTime, timeLogEntry.InterruptTime, false); activityView.StopAnimating(); NavigationController.PopViewController(true); } catch (Exception ex) { activityView.StopAnimating(); ViewControllerHelper.ShowAlert(this, "Add Time Log", ex.Message + " Please try again later."); } }); } else { barBtnItem = new UIBarButtonItem(UIBarButtonSystemItem.Trash, (s, e) => { UIAlertController actionSheetAlert = UIAlertController.Create(null, "This time log will be deleted", UIAlertControllerStyle.ActionSheet); actionSheetAlert.AddAction(UIAlertAction.Create("Delete", UIAlertActionStyle.Destructive, async(action) => { if (isActiveTimeLog()) { ViewControllerHelper.ShowAlert(this, "Oops", "You are currently logging time to this time log. Please stop the timmer first."); } else { activityView.StartAnimating(); try { await PDashAPI.Controller.DeleteTimeLog(timeLogEntry.Id.ToString()); activityView.StopAnimating(); NavigationController.PopViewController(true); } catch (Exception ex) { activityView.StopAnimating(); ViewControllerHelper.ShowAlert(this, "Delete Time Log", ex.Message + " Please try again later."); } } })); actionSheetAlert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, (action) => Console.WriteLine("Cancel button pressed."))); UIPopoverPresentationController presentationPopover = actionSheetAlert.PopoverPresentationController; if (presentationPopover != null) { presentationPopover.SourceView = this.View; presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Up; } // Display the alertg this.PresentViewController(actionSheetAlert, true, null); }); } NavigationItem.RightBarButtonItem = barBtnItem; ProjectNameLabel.Text = timeLogEntry.Task.Project.Name; TaskNameLabel.Text = timeLogEntry.Task.FullName; StartTimeText.Text = Util.GetInstance().GetLocalTime(timeLogEntry.StartDate).ToString("g"); // set up start time customized UIpicker StartTimePicker = new UIDatePicker(new CoreGraphics.CGRect(10f, this.View.Frame.Height - 250, this.View.Frame.Width - 20, 200f)); StartTimePicker.BackgroundColor = UIColor.FromRGB(220, 220, 220); StartTimePicker.UserInteractionEnabled = true; StartTimePicker.Mode = UIDatePickerMode.DateAndTime; StartTimePicker.MaximumDate = ViewControllerHelper.DateTimeUtcToNSDate(DateTime.UtcNow); startTimeSelectedDate = Util.GetInstance().GetServerTime(timeLogEntry.StartDate); StartTimePicker.ValueChanged += (Object sender, EventArgs e) => { startTimeSelectedDate = ViewControllerHelper.NSDateToDateTimeUtc((sender as UIDatePicker).Date); }; StartTimePicker.BackgroundColor = UIColor.White; StartTimePicker.SetDate(ViewControllerHelper.DateTimeUtcToNSDate(Util.GetInstance().GetServerTime(timeLogEntry.StartDate)), true); //Setup the toolbar toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Default; toolbar.BackgroundColor = UIColor.FromRGB(220, 220, 220); toolbar.Translucent = true; toolbar.SizeToFit(); // Create a 'done' button for the toolbar and add it to the toolbar saveButton = new UIBarButtonItem("Save", UIBarButtonItemStyle.Bordered, null); saveButton.Clicked += async(s, e) => { this.StartTimeText.Text = Util.GetInstance().GetLocalTime(startTimeSelectedDate).ToString(); timeLogEntry.StartDate = startTimeSelectedDate; this.StartTimeText.ResignFirstResponder(); if (!isAddingMode) { try { await PDashAPI.Controller.UpdateTimeLog(timeLogEntry.Id.ToString(), null, timeLogEntry.StartDate, timeLogEntry.Task.Id, null, null, false); } catch (Exception ex) { ViewControllerHelper.ShowAlert(this, "Change Start Time", ex.Message + " Please try again later."); } } }; var spacer = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace) { Width = 50 }; cancelButton = new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Bordered, (s, e) => { this.StartTimeText.ResignFirstResponder(); }); toolbar.SetItems(new UIBarButtonItem[] { cancelButton, spacer, saveButton }, true); this.StartTimeText.InputView = StartTimePicker; this.StartTimeText.InputAccessoryView = toolbar; DeltaText.Text = TimeSpan.FromMinutes(timeLogEntry.LoggedTime).ToString(@"hh\:mm"); IntText.Text = TimeSpan.FromMinutes(timeLogEntry.InterruptTime).ToString(@"hh\:mm"); CommentText.SetTitle(timeLogEntry.Comment ?? "No Comment", UIControlState.Normal); CommentText.TouchUpInside += (sender, e) => { UIAlertView alert = new UIAlertView(); alert.Title = "Comment"; alert.AddButton("Cancel"); alert.AddButton("Save"); alert.Message = "Please enter new Comment"; alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; UITextField textField = alert.GetTextField(0); textField.Placeholder = timeLogEntry.Comment ?? "No Comment"; alert.Clicked += CommentButtonClicked; alert.Show(); }; /////Delta Picker DeltaPicker = new UIPickerView(new CoreGraphics.CGRect(10f, this.View.Frame.Height - 250, this.View.Frame.Width - 20, 200f)); DeltaPicker.BackgroundColor = UIColor.FromRGB(220, 220, 220); DeltaPicker.UserInteractionEnabled = true; DeltaPicker.ShowSelectionIndicator = true; string[] hours = new string[24]; string[] minutes = new string[60]; for (int i = 0; i < hours.Length; i++) { hours[i] = i.ToString(); } for (int i = 0; i < minutes.Length; i++) { minutes[i] = i.ToString("00"); } StatusPickerViewModel deltaModel = new StatusPickerViewModel(hours, minutes); int h = (int)timeLogEntry.LoggedTime / 60; int m = (int)timeLogEntry.LoggedTime % 60; this.deltaSelectedHour = h.ToString(); this.deltaSelectedMinute = m.ToString("00"); deltaModel.NumberSelected += (Object sender, EventArgs e) => { this.deltaSelectedHour = deltaModel.selectedHour; this.deltaSelectedMinute = deltaModel.selectedMinute; }; DeltaPicker.Model = deltaModel; DeltaPicker.BackgroundColor = UIColor.White; DeltaPicker.Select(h, 0, true); DeltaPicker.Select(m, 1, true); //Setup the toolbar toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Default; toolbar.BackgroundColor = UIColor.FromRGB(220, 220, 220); toolbar.Translucent = true; toolbar.SizeToFit(); // Create a 'done' button for the toolbar and add it to the toolbar saveButton = new UIBarButtonItem("Save", UIBarButtonItemStyle.Bordered, null); saveButton.Clicked += async(s, e) => { this.DeltaText.Text = this.deltaSelectedHour + ":" + this.deltaSelectedMinute; double oldLoggedTime = timeLogEntry.LoggedTime; timeLogEntry.LoggedTime = int.Parse(this.deltaSelectedHour) * 60 + int.Parse(this.deltaSelectedMinute); this.DeltaText.ResignFirstResponder(); if (!isAddingMode) { if (isActiveTimeLog()) { tlc.SetLoggedTime((int)timeLogEntry.LoggedTime); } else { try { await PDashAPI.Controller.UpdateTimeLog(timeLogEntry.Id.ToString(), null, null, timeLogEntry.Task.Id, timeLogEntry.LoggedTime - oldLoggedTime, null, false); } catch (Exception ex) { ViewControllerHelper.ShowAlert(this, "Change Logged Time", ex.Message + " Please try again later."); } } } }; cancelButton = new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Bordered, (s, e) => { this.DeltaText.ResignFirstResponder(); }); toolbar.SetItems(new UIBarButtonItem[] { cancelButton, spacer, saveButton }, true); this.DeltaText.InputView = DeltaPicker; this.DeltaText.InputAccessoryView = toolbar; ////// Int Picker IntPicker = new UIPickerView(new CoreGraphics.CGRect(10f, this.View.Frame.Height - 200, this.View.Frame.Width - 20, 200f)); IntPicker.BackgroundColor = UIColor.FromRGB(220, 220, 220); IntPicker.UserInteractionEnabled = true; IntPicker.ShowSelectionIndicator = true; IntPicker.BackgroundColor = UIColor.White; IntPicker.Select(0, 0, true); StatusPickerViewModel intModel = new StatusPickerViewModel(hours, minutes); intModel.NumberSelected += (Object sender, EventArgs e) => { this.intSelectedHour = intModel.selectedHour; this.intSelectedMinute = intModel.selectedMinute; }; IntPicker.Model = intModel; IntPicker.Select((int)timeLogEntry.InterruptTime / 60, 0, true); IntPicker.Select((int)timeLogEntry.InterruptTime % 60, 1, true); //Setup the toolbar toolbar = new UIToolbar(); toolbar.BarStyle = UIBarStyle.Default; toolbar.BackgroundColor = UIColor.FromRGB(220, 220, 220); toolbar.Translucent = true; toolbar.SizeToFit(); saveButton = new UIBarButtonItem("Save", UIBarButtonItemStyle.Bordered, null); saveButton.Clicked += async(s, e) => { this.IntText.Text = this.intSelectedHour + ":" + this.intSelectedMinute; timeLogEntry.InterruptTime = int.Parse(this.intSelectedHour) * 60 + int.Parse(this.intSelectedMinute); this.IntText.ResignFirstResponder(); if (!isAddingMode) { if (isActiveTimeLog()) { tlc.SetInterruptTime((int)timeLogEntry.InterruptTime); } else { try { await PDashAPI.Controller.UpdateTimeLog(timeLogEntry.Id.ToString(), null, null, timeLogEntry.Task.Id, null, timeLogEntry.InterruptTime, false); } catch (Exception ex) { ViewControllerHelper.ShowAlert(this, "Change Interrupt Time", ex.Message + " Please try again later."); } } } }; cancelButton = new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Bordered, (s, e) => { this.IntText.ResignFirstResponder(); }); toolbar.SetItems(new UIBarButtonItem[] { cancelButton, spacer, saveButton }, true); this.IntText.InputView = IntPicker; this.IntText.InputAccessoryView = toolbar; }
private async void AlertGetName() { int buttonClicked = -1; //Create Our Alert var alert = new UIAlertView("Filename", "Please Input The Filename", null, "Cancel", "Submit"); //Set The Alert Style alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; //Create Our Async Task var tcs = new TaskCompletionSource <int>(); //Check What Button Was Pressed alert.Clicked += (sender, buttonArgs) => { buttonClicked = (int)buttonArgs.ButtonIndex; tcs.TrySetResult((int)buttonArgs.ButtonIndex); }; alert.Show(); //Wait For Us To Get A Button Press await tcs.Task; //After Press Get Our Text From TextBox string text = alert.GetTextField(0).Text; if (buttonClicked == 0) //Cancel Button Clicked { //Do Nothing } else if (buttonClicked == 1) //Submit Button Clicked { DataSet dataSet = new DataSet() { dataSetName = text, dataSetAvgP0 = lastAvgP0.ToString("0.0000"), dataSetTotP0 = lastTotalP0.ToString("0.0000"), dataSetAvgData = lastAvgData.ToString("0.0000"), dataSetTotData = lastTotalData.ToString("0.0000"), dataSetA = lastA.ToString("0.0000000") }; try //This Has A Possibility To Crash The Program { //Try Saving Our Data Set To JSON dataService.SaveDataSet(dataSet); //Has to be called after dataService because Id needs to be assigned by JSON SaveImageToFile(dataSet.dataSetName + "P0" + dataSet.Id, P0Image); SaveImageToFile(dataSet.dataSetName + "Data" + dataSet.Id, dataImage); } catch (Exception e) { Console.WriteLine("Exception Caught : Cant Write Data To File (Please Fix This)"); Console.WriteLine(e); } } else { Console.WriteLine("Alert : View Was Closed Unnaturally, What Happened?"); } dataService.RefreshCache(); }
public override void RunVoicePromptAsync(string prompt, Action<string> callback) { new Thread(() => { string input = null; ManualResetEvent dialogDismissWait = new ManualResetEvent(false); Device.BeginInvokeOnMainThread(() => { ManualResetEvent dialogShowWait = new ManualResetEvent(false); UIAlertView dialog = new UIAlertView("Sensus is requesting input...", prompt, null, "Cancel", "OK"); dialog.AlertViewStyle = UIAlertViewStyle.PlainTextInput; dialog.Dismissed += (o, e) => { dialogDismissWait.Set(); }; dialog.Presented += (o, e) => { dialogShowWait.Set(); }; dialog.Clicked += (o, e) => { if (e.ButtonIndex == 1) input = dialog.GetTextField(0).Text; }; dialog.Show(); #region voice recognizer new Thread(() => { // wait for the dialog to be shown so it doesn't hide our speech recognizer activity dialogShowWait.WaitOne(); // there's a slight race condition between the dialog showing and speech recognition showing. pause here to prevent the dialog from hiding the speech recognizer. Thread.Sleep(1000); // TODO: Add speech recognition }).Start(); #endregion }); dialogDismissWait.WaitOne(); callback(input); }).Start(); }
partial void officeFollowupTouchDown(NSObject sender) { ac = new UIActionSheet("Is office follow-up required for this?", null, "Cancel", null, "Yes", "No"); // WillDismiss ac.Dismissed += delegate(object _sender, UIButtonEventArgs e) { const int i = 2; // ac.CancelButtonIndex; switch (e.ButtonIndex) { case i: { /* officeFollowupTextField.Text = "?";*/ break; } case i - 2: { officeFollowupTextField.Text = "Yes"; pr.OfficeFollowUpRequired = Choices.Yes; Dictionary <int, string> Reasons = MyConstants.GetFollowUpReasonsFromDB(); UIActionSheet act = new UIActionSheet("Please specify a reason"); foreach (int j in Reasons.Keys) { act.AddButton(Reasons[j]); } act.WillDismiss += delegate(object __sender, UIButtonEventArgs ee) { if (ee.ButtonIndex != -1) { // IMPLEMENTED :: saves the followup reason to database string pickedReason = ((UIActionSheet)__sender).ButtonTitle(ee.ButtonIndex); // Reasons[ee.ButtonIndex+1]; int reasonID = Reasons.FindKeyByValue(pickedReason); long jobID = _navWorkflow._tabs._jobRunTable.CurrentJob.JobBookingNumber; if (act.ButtonTitle(ee.ButtonIndex).ToUpper().Contains("OTHER") || act.ButtonTitle(ee.ButtonIndex).ToUpper().Contains("TECHNICAL ISSUES")) { // display an additional dialog to get a description of what happened var getDescription = new UIAlertView("Comment", "Type in a few words about why this needs to be followed up", null, "Cancel", "OK"); getDescription.AlertViewStyle = UIAlertViewStyle.PlainTextInput; getDescription.Dismissed += delegate(object desc_sender, UIButtonEventArgs btn) { if (btn.ButtonIndex != getDescription.CancelButtonIndex) { string desc = getDescription.GetTextField(0).Text; _navWorkflow._tabs._jobService.SaveFollowupToDatabase(jobID, reasonID, desc); } else { pr.OfficeFollowUpRequired = Choices.No; } }; getDescription.Show(); } else { _navWorkflow._tabs._jobService.SaveFollowupToDatabase(jobID, reasonID, ""); } officeFollowupTextField.Text = pickedReason; } else { officeFollowupTextField.Text = "No"; pr.OfficeFollowUpRequired = Choices.No; } }; act.ShowInView(this.View); break; } case i - 1: { officeFollowupTextField.Text = "No"; pr.OfficeFollowUpRequired = Choices.No; break; } } }; ac.ShowInView(this.View); }
public override void Clicked(UIAlertView alertview, nint buttonIndex) { if (alertview.Tag == currentViewContorller.ALERT_VIEW_OPERATION_TIME) { if (buttonIndex == 1) { UITextField textfield = alertview.GetTextField(0); if (textfield != null) { string str = alertview.GetTextField(0).Text; if (str == "") { str = "0"; } currentViewContorller.setOperationTime(str); currentViewContorller.mReader.OperationTime = int.Parse(str); currentViewContorller.systemSetting.setOperationTime(int.Parse(str)); } } } else if (alertview.Tag == currentViewContorller.ALERT_VIEW_PASSWORD) { if (buttonIndex == 1) { currentViewContorller.setPassword(alertview.GetTextField(0).Text); } } else if (alertview.Tag == currentViewContorller.ALERT_VIEW_SET_ACCESS_PW) { if (buttonIndex == 1) { UITextField textfield = alertview.GetTextField(0); if (textfield != null) { string str = alertview.GetTextField(0).Text; if (str == "") { str = "0"; } currentViewContorller.mReader.AccessPassword = currentViewContorller.passwordTextField.Text; currentViewContorller.mReader.WriteMemory(MemoryBank.Reserved, 2, str); } } } else if (alertview.Tag == currentViewContorller.ALERT_VIEW_SET_KILL_PW) { if (buttonIndex == 1) { UITextField textfield = alertview.GetTextField(0); if (textfield != null) { string str = alertview.GetTextField(0).Text; if (str == "") { str = "0"; } currentViewContorller.mReader.AccessPassword = currentViewContorller.passwordTextField.Text; currentViewContorller.mReader.WriteMemory(MemoryBank.Reserved, 0, str); } } } else if (alertview.Tag == currentViewContorller.ALERT_VIEW_KILL_PW) { if (buttonIndex == 1) { UITextField textfield = alertview.GetTextField(0); if (textfield != null) { string str = alertview.GetTextField(0).Text; if (str == "") { str = "0"; } if (str.Length != 8) { if (currentViewContorller.currentAlertView != null) { currentViewContorller.currentAlertView.DismissWithClickedButtonIndex(0, true); } currentViewContorller.currentAlertView = new UIAlertView("Error", "Password length is not valid ", new MyAlertViewDelegate(currentViewContorller), "Cancel", null); currentViewContorller.currentAlertView.Tag = currentViewContorller.ALERT_VIEW_OUTHERVIEW; currentViewContorller.currentAlertView.Show(); } else { currentViewContorller.mReader.Kill(str); } } } } else if (alertview.Tag == currentViewContorller.ALERT_VIEW_LOCK) { currentViewContorller.stopAction(); } }
public void HandleActionAsync(FeedActionModel model, string actionType = null, string AreaGUID = null) { if (model == null) { /* * UIAlertView alert = new UIAlertView() * { * Title = "Action error", * Message = "Action data empty" * }; * alert.AddButton("OK"); * alert.Show(); */ return; } UIStoryboard storyboard = UIStoryboard.FromName("Main", null); var rootViewController = UIApplication.SharedApplication.KeyWindow.RootViewController as UINavigationController; if ((model.ActionScreen == "CHALLENGE" || actionType == "REFERRAL_ACCEPTED" || actionType == "ITB_COMPLETE" || actionType == "CTAC") && model.ActionScreen != "DIALOG") { OpenChallengeDetailsScreenWithURL(model.ActionParamDict["ChallengeDetailURL"]); return; } if (model.ActionScreen == "REWARD") { SL.Manager.GetRewardByUrl(model.ActionParamDict["RewardDetailURL"], GetRewardByUrlComplete); return; } if (model.ActionScreen == "REWARDLIST") { NavigateByAction("Main", "MainNav1", ENavigationTabs.REWARDS); } if (model.ActionScreen == "CHALLENGELIST")/////////////////// { NavigateByAction("Main", "MainNav1", ENavigationTabs.CHALLENGES); } if (model.ActionScreen == "FEED") { string feedUrl = string.Empty; model.ActionParamDict.TryGetValue("FeedURL", out feedUrl); LoadFeedByUrl(feedUrl); //NavigateByAction("Main", "MainNav1", ENavigationTabs.FEED); } if (model.ActionScreen == "WEB") { string url = string.Empty; bool gotUrl = model.ActionParamDict.TryGetValue("WebRequestURL", out url); if (gotUrl == false) { url = model.WebRequestURL; } if (url == string.Empty) { //alert no url to open //return; } UIApplication.SharedApplication.OpenUrl(new NSUrl(url)); } if (model.ActionScreen == "SETTINGS") { NavigateByAction("Main", "MainNav1", ENavigationTabs.MORE); } if (model.ActionScreen == "SHARE") { if (!model.ActionParamDict.ContainsKey("ChallengeDetailURL")) { return; } OpenChallengeDetailsScreenWithURL(model.ActionParamDict["ChallengeDetailURL"]); } if (model.ActionScreen == "SwitchArea") { SwitchAreaIfNeeded(AreaGUID); } if (model.ActionScreen == "INVITE") { SL.Manager.RefreshShareTemplate(model.ActionParamDict["ShareTemplateURL"], SendInviteMessage); } if (model.ActionScreen == "DIALOG")/////////////////// { var dialogStyle = model.ActionParamDict["DialogStyle"]; _dialogSubmisionUrl = model.ActionParamDict["SubmissionURL"]; var message = model.ActionParamDict["Caption"]; if (dialogStyle != string.Empty) { if (dialogStyle == "NONE") { } if (dialogStyle == "ENTRY") { var alert = new UIAlertView("", message, this as IUIAlertViewDelegate, "Cancel", null); alert.AddButton("Ok"); alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; var textField = alert.GetTextField(0); alert.Show(); } } } if (model.ActionScreen == "IWEB" && actionType == "CTAIW") { string url = string.Empty; bool gotUrl = model.ActionParamDict.TryGetValue("WebRequestURL", out url); url = model.ActionParamDict["WebRequestURL"]; if (gotUrl == false) { //url = model.WebRequestURL; } if (url == string.Empty) { //alert no url to open //return; } GenericWebViewController webViewController = new GenericWebViewController(); webViewController.Url = url; UIViewController parentController = Platform.TopViewController; parentController.PresentViewController(webViewController, false, null); return; } if (model.ActionScreen == "IWEB") { string url = string.Empty; bool gotUrl = model.ActionParamDict.TryGetValue("WebRequestURL", out url); if (gotUrl == false) { url = model.WebRequestURL; } if (url == string.Empty) { //alert no url to open //return; } UIApplication.SharedApplication.OpenUrl(new NSUrl(url)); } if (model.ActionScreen == "SCORE") { NavigateByAction("Main", "MainNav1", ENavigationTabs.POINTS); } if (model.ActionScreen == "FRIENDLIST") { NavigateByAction("Main", "MainNav1", ENavigationTabs.POINTS); } }
public ListViewPage() { Items = new ObservableCollection <ListViewItem>(); var header = new Label { Text = "ListView" }; var button = new Button { Text = "+" }; var listView = new ListView { ItemsSource = Items, ItemTemplate = new DataTemplate(() => { var grid = new Grid() { Padding = new Thickness(5, 10) }; grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Star }); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Star }); var iLabel = new Label { VerticalOptions = LayoutOptions.FillAndExpand }; iLabel.SetBinding(Label.TextProperty, "Index"); var label = new Label { VerticalOptions = LayoutOptions.FillAndExpand }; label.SetBinding(Label.TextProperty, "Name"); grid.Children.Add(iLabel, 0, 0); grid.Children.Add(label, 1, 0); return(new ViewCell { View = grid }); }), SeparatorVisibility = SeparatorVisibility.None }; listView.ItemSelected += (sender, e) => { var elem = e.SelectedItem as ListViewItem; if (elem != null) { var msg = $"willst du {elem.Name} löschen"; var alert = new UIAlertView(); alert.Title = "Löschen?"; alert.AddButton("OK"); alert.AddButton("Absagen"); alert.Message = msg; alert.AlertViewStyle = UIAlertViewStyle.Default; alert.Clicked += (sender1, e1) => { if (e1.ButtonIndex == 0) { Items.Remove(elem); foreach (var item in Items) { item.Index = Items.IndexOf(item) + 1; } } }; alert.Show(); } listView.SelectedItem = null; }; button.Clicked += (sender, e) => { var alert = new UIAlertView(); alert.Title = "Nahme?"; alert.AddButton("OK"); alert.AddButton("Absagen"); alert.Message = "Geben sie eine nahme"; alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; alert.Clicked += (sender1, e1) => { if (e1.ButtonIndex == 0) { var input = alert.GetTextField(0).Text; Items.Add(new ListViewItem() { Index = Items.Count + 1, Name = input }); } }; alert.Show(); }; var headerStack = new StackLayout { Children = { header, button }, Orientation = StackOrientation.Horizontal }; Content = new StackLayout { Children = { headerStack, listView } }; }
private void PromptForWikiPage() { var alert = new UIAlertView { Title = "Goto Wiki Page", Message = "What is the title of the Wiki page you'd like to goto?", AlertViewStyle = UIAlertViewStyle.PlainTextInput }; alert.CancelButtonIndex = alert.AddButton("Cancel"); alert.DismissWithClickedButtonIndex(alert.CancelButtonIndex, true); var gotoButton = alert.AddButton("Go"); alert.Dismissed += (sender, e) => { if (e.ButtonIndex == gotoButton) { GoToPage(alert.GetTextField(0).Text); //ViewModel.GoToPageCommand.Execute(alert.GetTextField(0).Text); } }; alert.Show(); }
private UIButton GenerateBookmarkButton(PSPDFPageView pageView, Page page, Bookmark bookmark) { UIButton button = UIButton.FromType(UIButtonType.Custom); // Image if (bookmark == null) { button.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/bookmark_add.png"), UIControlState.Normal); button.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/bookmark_add.png"), UIControlState.Highlighted); } else { button.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/bookmark_solid.png"), UIControlState.Normal); button.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/bookmark_solid.png"), UIControlState.Highlighted); } button.Frame = new CGRect(30, 0, button.CurrentBackgroundImage.Size.Width, button.CurrentBackgroundImage.Size.Height); // Action button.TouchUpInside += (object sender, EventArgs e) => { UIAlertView alertView = new UIAlertView("Bookmark", "Please enter bookmark title and press Save.", null, StringRef.cancel, "Save"); alertView.AlertViewStyle = UIAlertViewStyle.PlainTextInput; alertView.GetTextField(0).ReturnKeyType = UIReturnKeyType.Done; alertView.GetTextField(0).Placeholder = "Bookmark Title"; // Show bookmark title if already exist bookmark = BooksOnDeviceAccessor.GetBookmark(book.ID, page.ID); if (bookmark != null) { alertView.GetTextField(0).Text = bookmark.Title; } alertView.Dismissed += delegate(object sender1, UIButtonEventArgs e1) { if (e1.ButtonIndex == 1) { String text = alertView.GetTextField(0).Text; BookmarkUpdater.SaveBookmark(book, page.ID, text); if (String.IsNullOrEmpty(text)) { RemoveBookmarkFromBookmarkParser(this.Page); button.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/bookmark_add.png"), UIControlState.Normal); button.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/bookmark_add.png"), UIControlState.Highlighted); } else { AddBookmarkToBookmarkParser(this.Page); button.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/bookmark_solid.png"), UIControlState.Normal); button.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/bookmark_solid.png"), UIControlState.Highlighted); } } }; alertView.WillDismiss += delegate { alertView.GetTextField(0).ResignFirstResponder(); }; alertView.Show(); }; return(button); }
public AdminPage() { var header = new Label { Text = "Admin" }; var subHeader = new Label { Text = "Menu" }; var listView = new ListView() { ItemsSource = MenuPage.masterPageItems, ItemTemplate = new DataTemplate(() => { var grid = new Grid() { Padding = new Thickness(5, 10) }; grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(30) }); grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Star }); var label = new Label { VerticalOptions = LayoutOptions.FillAndExpand }; label.SetBinding(Label.TextProperty, "Title", BindingMode.TwoWay); grid.Children.Add(label, 1, 0); return(new ViewCell { View = grid }); }), SeparatorVisibility = SeparatorVisibility.None }; listView.ItemSelected += (sender, e) => { var item = e.SelectedItem as MasterPageItem; if (item != null) { var alert = new UIAlertView(); alert.Title = "Nahme?"; alert.AddButton("OK"); alert.AddButton("Absagen"); alert.Message = "Geben sie eine nahme"; alert.AlertViewStyle = UIAlertViewStyle.PlainTextInput; alert.Clicked += (sender1, e1) => { if (e1.ButtonIndex == 0) { var input = alert.GetTextField(0).Text; item.Title = input; listView.ItemsSource = null; listView.ItemsSource = MenuPage.masterPageItems; } }; alert.Show(); } }; Button btn = new Button { Text = "Ok" }; btn.Clicked += (sender, e) => { Application.Current.MainPage = new NavigationPage(new Page1()); }; Content = new StackLayout { Children = { header, subHeader, listView, btn } }; }
public override bool ShouldEnableFirstOtherButton(UIAlertView alertView) { return(alertView.GetTextField(0).Text.Length > 0); }
public ListViewController(UITableViewStyle style) : base(style) { numberOfSongsToGet = 20; UIBarButtonItem bbi = new UIBarButtonItem(); bbi.Title = "Info"; bbi.Style = UIBarButtonItemStyle.Bordered; this.NavigationItem.SetRightBarButtonItem(bbi, true); bbi.Clicked += (object sender, EventArgs e) => { // Create the channel view controller channelViewController = new ChannelViewController(UITableViewStyle.Grouped); if (this.SplitViewController != null) { this.transferBarButtonItem(channelViewController); UINavigationController nvc = new UINavigationController(channelViewController); // Create an array with our nav controller and this new VC's nav controller UINavigationController[] vcs = new UINavigationController[] { this.NavigationController, nvc }; // Grab a pointer to the split view controller // and reset its view controllers array this.SplitViewController.ViewControllers = vcs; // Make detail view controller the delegate of the split view controller // - ignore the warning for now this.SplitViewController.WeakDelegate = channelViewController; if (webViewController.popover != null) { webViewController.popover.Dismiss(true); } // If a row has been selected, deselect it so that a row // is not selected when viewing the info NSIndexPath selectedRow = this.TableView.IndexPathForSelectedRow; if (selectedRow != null) { this.TableView.DeselectRow(selectedRow, true); } } else { this.NavigationController.PushViewController(channelViewController, true); } // Give the VC the channel object through the interface method channelViewController.listViewControllerHandleObject(this, BNRFeedStore.channel); }; rssType = ListViewControllerRSSType.BNRFeed; rssTypeControl = new UISegmentedControl(new string[] { "Onobytes", "Apple" }); rssTypeControl.SelectedSegment = 0; if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0) || UIDevice.CurrentDevice.CheckSystemVersion(7, 1)) { rssTypeControl.TintAdjustmentMode = UIViewTintAdjustmentMode.Normal; } rssTypeControl.ValueChanged += (object sender, EventArgs e) => { rssType = (ListViewControllerRSSType)(int)rssTypeControl.SelectedSegment; if (rssType == ListViewControllerRSSType.Apple) { BNRFeedStore.items.Clear(); // Alert to select number of songs UIAlertView aiView = new UIAlertView("Get Top Songs", "Enter how many songs to get", null, "OK", null); aiView.AlertViewStyle = UIAlertViewStyle.PlainTextInput; aiView.GetTextField(0).Text = numberOfSongsToGet.ToString(); aiView.GetTextField(0).KeyboardType = UIKeyboardType.NumberPad; aiView.WeakDelegate = this; aiView.Show(); // Comment out if above is commented in // this.TableView.ReloadData(); // fetchEntries(); } else { BNRFeedStore.items.Clear(); this.TableView.ReloadData(); fetchEntries(); } }; this.NavigationItem.TitleView = rssTypeControl; this.TableView.BackgroundColor = UIColor.Black; fetchEntries(); }
//public override void ViewDidLoad() //{ // base.ViewDidLoad(); // var CattegoryList = new List<String> // { // "None", "Home", "Work", "Learning", "Fun" // }; // var cattegoryViewModel = new CattegoryViewModel(CattegoryList); // CattegoryPicker.Model = cattegoryViewModel; // cattegoryViewModel.CattegoryChange += (sender, e) => // { // Cattegory = cattegoryViewModel.SelectedCattegory; // }; //} ctrl e c public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); DatePicker.Locale = NSLocale.CurrentLocale; DatePicker.TimeZone = NSTimeZone.LocalTimeZone; TaskShortLable.Layer.BorderColor = UIColor.LightGray.CGColor; TaskShortLable.Layer.CornerRadius = 5.0f; TaskShortLable.Layer.BorderWidth = 0.25f; var CattegoryList = new List <String> { "None", "Meeting", "Activit", "Learning", "Home", "Other" }; var cattegoryViewModel = new CattegoryViewModel(CattegoryList); CattegoryPicker.Model = cattegoryViewModel; cattegoryViewModel.CattegoryChange += (sender, e) => { Cattegory = cattegoryViewModel.SelectedCattegory; Console.WriteLine(Cattegory); if (Cattegory == "Other") { var AlertInput = new UIAlertView(); AlertInput.Title = "Own cattegory"; AlertInput.AddButton("OK"); AlertInput.Message = "Please enter your cattegory"; AlertInput.AlertViewStyle = UIAlertViewStyle.PlainTextInput; AlertInput.Clicked += (object s, UIButtonEventArgs ev) => { if (ev.ButtonIndex == 0) { Cattegory = AlertInput.GetTextField(0).Text; } }; AlertInput.Show(); } }; if (EditingEnable) { TaskName.Text = currentTask.Name; TaskShortLable.Text = currentTask.ShortLabel; NotificationSwitch.On = currentTask.Notification; CalendarSwitch.On = currentTask.CalenderEvent; Duration.Text = currentTask.Duration.ToString(); if (CattegoryList.Contains(currentTask.Cattegory)) { CattegoryPicker.Select(CattegoryList.IndexOf(currentTask.Cattegory), 0, true); } else { CattegoryPicker.Select(CattegoryList.Count - 1, 0, true); Cattegory = currentTask.Cattegory; } DatePicker.Date = currentTask.DateAndTime; } }