partial void ShowSecureEntry (NSObject sender) { var alertController = UIAlertController.Create (title, message, UIAlertControllerStyle.Alert); alertController.AddTextField (textField => { textField.Placeholder = "Password"; textField.SecureTextEntry = true; textField.InputAccessoryView = new CustomInputAccessoryView ("Enter at least 5 characters"); textField.EditingChanged += HandleTextFieldTextDidChangeNotification; }); var acceptAction = UIAlertAction.Create (acceptButtonTitle, UIAlertActionStyle.Default, _ => Console.WriteLine ("The \"Secure Text Entry\" alert's other action occured.") ); var cancelAction = UIAlertAction.Create (cancelButtonTitle, UIAlertActionStyle.Cancel, _ => Console.WriteLine ("The \"Text Entry\" alert's cancel action occured.") ); acceptAction.Enabled = false; secureTextAlertAction = acceptAction; // Add the actions. alertController.AddAction (acceptAction); alertController.AddAction (cancelAction); PresentViewController (alertController, true, null); }
private void ActionClicked(UIAlertAction action) { // find the equivalent "metro" command and call the event handler for(int i = 0; i < uac.Actions.Length; i++) { if(uac.Actions[i] == action) { if (_commands.Count > i) { _selectedCommand = Commands[i]; if (Commands[i].Invoked != null) { Commands[i].Invoked(Commands[i]); } } break; } } handle.Set(); }
public Task <string> DisplayPromptAync(string title = null, string description = null, string text = null) { var result = new TaskCompletionSource <string>(); var alert = UIAlertController.Create(title ?? string.Empty, description, UIAlertControllerStyle.Alert); UITextField input = null; alert.AddAction(UIAlertAction.Create(AppResources.Cancel, UIAlertActionStyle.Cancel, x => { result.TrySetResult(null); })); alert.AddAction(UIAlertAction.Create(AppResources.Ok, UIAlertActionStyle.Default, x => { result.TrySetResult(input.Text ?? string.Empty); })); alert.AddTextField(x => { input = x; input.Text = text ?? string.Empty; }); var vc = GetPresentedViewController(); vc?.PresentViewController(alert, true, null); return(result.Task); }
public override void Prompt(PromptConfig config) { var result = new PromptResult(); var dlg = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert); UITextField txt = null; dlg.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => { result.Ok = true; result.Text = txt.Text.Trim(); config.OnResult(result); })); dlg.AddAction(UIAlertAction.Create(config.CancelText, UIAlertActionStyle.Default, x => { result.Ok = false; result.Text = txt.Text.Trim(); config.OnResult(result); })); dlg.AddTextField(x => { x.SecureTextEntry = config.InputType == InputType.Password; x.Placeholder = config.Placeholder ?? String.Empty; x.KeyboardType = Utils.GetKeyboardType(config.InputType); txt = x; }); this.Present(dlg); }
void DeleteBarButtonItemClicked(object sender, EventArgs ea) { UIAlertController alert = UIAlertController.Create( "Delete?", $"Are you sure you want to delete {Acquaintance.FirstName} {Acquaintance.LastName}?", UIAlertControllerStyle.Alert); // cancel button alert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null)); // delete button alert.AddAction(UIAlertAction.Create("Delete", UIAlertActionStyle.Destructive, async(action) => { if (action != null) { await _DataSource.RemoveItem(Acquaintance); NavigationController.PopViewController(true); } })); UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(alert, true, null); }
private void GridColorButton_Click(object sender, EventArgs e) { // Create the view controller that will present the list of grid color options. UIAlertController gridColorAlert = UIAlertController.Create("Select a grid color", "", UIAlertControllerStyle.ActionSheet); // Needed to prevent a crash on iPad. UIPopoverPresentationController presentationPopover = gridColorAlert.PopoverPresentationController; if (presentationPopover != null) { presentationPopover.SourceView = View; presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Up; } // Add an option for each color. foreach (Colors item in new[] { Colors.Red, Colors.Green, Colors.Blue, Colors.White }) { // Record the selection and re-apply all settings. gridColorAlert.AddAction(UIAlertAction.Create(item.Name, UIAlertActionStyle.Default, action => { _selectedGridColor = item; ApplyCurrentSettings(); })); } // Add an option to hide the grid. gridColorAlert.AddAction(UIAlertAction.Create("Hide the grid", UIAlertActionStyle.Default, action => { // Record the selection and re-apply all settings. _selectedGridColor = null; ApplyCurrentSettings(); })); // Show the alert. PresentViewController(gridColorAlert, true, null); }
private void Open() { var controller = new SupportRotationAlertController(_actionHeaderTitle, _actionHeaderMessage, UIAlertControllerStyle.ActionSheet); foreach (var action in _actions) { controller.AddAction(UIAlertAction.Create(action.Title, action.CommandActionStyle.ToNative(), action.Command.Execute)); } if (!Equals(TintColor, UIColor.Clear)) { controller.View.TintColor = TintColor; } _viewLocator.GetTopViewController().PresentViewController(controller, true, null); if (!Equals(TintColor, UIColor.Clear)) { controller.View.TintColor = TintColor; } }
public Task <string> DisplayPromptAync(string title = null, string description = null, string text = null, string okButtonText = null, string cancelButtonText = null, bool numericKeyboard = false, bool autofocus = true) { var result = new TaskCompletionSource <string>(); var alert = UIAlertController.Create(title ?? string.Empty, description, UIAlertControllerStyle.Alert); UITextField input = null; okButtonText = okButtonText ?? AppResources.Ok; cancelButtonText = cancelButtonText ?? AppResources.Cancel; alert.AddAction(UIAlertAction.Create(cancelButtonText, UIAlertActionStyle.Cancel, x => { result.TrySetResult(null); })); alert.AddAction(UIAlertAction.Create(okButtonText, UIAlertActionStyle.Default, x => { result.TrySetResult(input.Text ?? string.Empty); })); alert.AddTextField(x => { input = x; input.Text = text ?? string.Empty; if (numericKeyboard) { input.KeyboardType = UIKeyboardType.NumberPad; } if (!ThemeHelpers.LightTheme) { input.KeyboardAppearance = UIKeyboardAppearance.Dark; } }); var vc = GetPresentedViewController(); vc?.PresentViewController(alert, true, null); return(result.Task); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, null ); app.RegisterUserNotificationSettings(notificationSettings); } if (options != null) { // check for a local notification if (options.ContainsKey(UIApplication.LaunchOptionsLocalNotificationKey)) { var localNotification = options[UIApplication.LaunchOptionsLocalNotificationKey] as UILocalNotification; if (localNotification != null) { UIAlertController okayAlertController = UIAlertController.Create(localNotification.AlertAction, localNotification.AlertBody, UIAlertControllerStyle.Alert); okayAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); Window.RootViewController.PresentViewController(okayAlertController, true, null); // reset our badge UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0; } } } LoadApplication(new App(new iOSInitializer())); return(base.FinishedLaunching(app, options)); }
public Task <string> Display(string title, string message, string firstButton, string secondButton, string cancel) { var taskCompletionSource = new TaskCompletionSource <string>(); var alerController = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert); alerController.AddAction(UIAlertAction.Create(firstButton, UIAlertActionStyle.Default, alert => { taskCompletionSource.SetResult(firstButton); })); alerController.AddAction(UIAlertAction.Create(secondButton, UIAlertActionStyle.Default, alert => { taskCompletionSource.SetResult(secondButton); })); alerController.AddAction(UIAlertAction.Create(cancel, UIAlertActionStyle.Cancel, alert => { taskCompletionSource.SetResult(cancel); })); UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(alerController, animated: true, completionHandler: null); return(taskCompletionSource.Task); }
public Task <bool> DisplaySettingsAlert(string title, string message, string cancel = "Cancel") { var taskCompletionSource = new TaskCompletionSource <bool>(); var alert = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert); SetAttributedText(alert, title, message); UIAlertAction cancelAction = UIAlertAction.Create(cancel, UIAlertActionStyle.Cancel, action => taskCompletionSource.SetResult(false)); alert.AddAction(cancelAction); // Provide quick access to Settings. UIAlertAction settingsAction = UIAlertAction.Create("Settings", UIAlertActionStyle.Default, action => { UIApplication.SharedApplication.OpenUrl(new NSUrl(UIApplication.OpenSettingsUrlString)); taskCompletionSource.SetResult(true); }); alert.AddAction(settingsAction); NavigationHelper.GetActiveViewController().PresentViewController(alert, true, null); return(taskCompletionSource.Task); }
void TimeLineLoaded(IAsyncResult result) { var request = result.AsyncState as HttpWebRequest; Busy = false; try { var response = request.EndGetResponse(result); var stream = response.GetResponseStream(); var root = CreateDynamicContent(XDocument.Load(new XmlTextReader(stream))); InvokeOnMainThread(delegate { var tweetVC = new DialogViewController(root, true); navigation.PushViewController(tweetVC, true); }); } catch (WebException e) { InvokeOnMainThread(delegate { var alertController = UIAlertController.Create("Error", "Code: " + e.Status, UIAlertControllerStyle.Alert); alertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, (obj) => { })); window.RootViewController.PresentViewController(alertController, true, null); }); } }
void PromptUserForStorageOption() { string title = "Choose Storage Option"; string message = "Do you want to store documents in iCloud or only on this device?"; string localOnlyActionTitle = "Local Only"; string cloudActionTitle = "iCloud"; UIAlertController storageController = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert); UIAlertAction localOption = UIAlertAction.Create(localOnlyActionTitle, UIAlertActionStyle.Default, action => { AppConfig.SharedAppConfiguration.StorageOption = StorageType.Local; }); storageController.AddAction(localOption); UIAlertAction cloudOption = UIAlertAction.Create(cloudActionTitle, UIAlertActionStyle.Default, action => { AppConfig.SharedAppConfiguration.StorageOption = StorageType.Cloud; AppConfig.SharedAppConfiguration.StoreUbiquityIdentityToken(); }); storageController.AddAction(cloudOption); PresentViewController(storageController, true, null); }
void BeginTransferProcess(UIAlertAction obj) { Console.WriteLine("LET US BEGIN."); //Update bottom sheet to show In transfer - empty table and update countdown owner.timeRemainingLabel.Text = "IN TRANSIT"; owner.timeRemainingLabel.TextColor = UIColor.Orange; owner.potentialRecipientsLabel.Text = "This organ is currently in transit."; owner.potentialRecipientsTableView.Hidden = true; //Update map to get rid of overlays and recipients customMapRenderer.removeOverlays(); customMapRenderer.ClearAllReceivers(); owner.StopTimers(); currentOrgan.inTransfer = 1; //Insert transfer into database and add new helicopter. ClinicianMapPage parent = (ClinicianMapPage)formsMap.Parent.Parent; parent.NewTransfer(currentOrgan, selectedRecipient, customPin.Position); }
// Show an alert with an "Okay" and "Cancel" button. private void ShowOkayCancelAlert() { var title = "A Short Title is Best".Localize(); var message = "A message should be a short, complete sentence.".Localize(); var cancelButtonTitle = "Cancel".Localize(); var otherButtonTitle = "OK".Localize(); var alertCotroller = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert); // Create the actions. var cancelAction = UIAlertAction.Create(cancelButtonTitle, UIAlertActionStyle.Cancel, alertAction => { Console.WriteLine("The 'Okay/Cancel' alert's cancel action occured."); }); var otherAction = UIAlertAction.Create(otherButtonTitle, UIAlertActionStyle.Default, alertAction => { Console.WriteLine("The 'Okay/Cancel' alert's other action occured."); }); // Add the actions. alertCotroller.AddAction(cancelAction); alertCotroller.AddAction(otherAction); PresentViewController(alertCotroller, true, null); }
private void ShowMissionOptions(object sender, EventArgs eventArgs) { // Create the view controller that will present the list of missions. UIAlertController missionSelectionAlert = UIAlertController.Create("Select a mission", "", UIAlertControllerStyle.ActionSheet); // Needed to prevent a crash on iPad. UIPopoverPresentationController presentationPopover = missionSelectionAlert.PopoverPresentationController; if (presentationPopover != null) { presentationPopover.SourceView = View; presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Up; } // Add an option for each mission. foreach (string item in _missionToItemId.Keys) { // Selecting the mission will call the ChangeMission method. missionSelectionAlert.AddAction(UIAlertAction.Create(item, UIAlertActionStyle.Default, async action => await ChangeMission(item))); } // Show the alert. PresentViewController(missionSelectionAlert, true, null); }
private async void RegisterButton_TouchUpInside(object sender, EventArgs e) { if (!string.IsNullOrEmpty(passwordTextField.Text)) { if (passwordTextField.Text == confirmPasswordTextField.Text) { var user = new User() { Email = emailTextField.Text, Password = passwordTextField.Text }; await AppDelegate.MobileService.GetTable <User>().InsertAsync(user); var alert = UIAlertController.Create("Success", "User inserted", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); return; } } }
/// <summary> /// This method validates that the data entry is suitable. No fields can be null or empty, and password and confirm password must be the same. /// </summary> /// <returns>Boolean value "valid". Returns false if data is wrong, true is data is valid.</returns> public Boolean Validate() { var valid = false; TrimAllFields(); if (String.IsNullOrEmpty(FirstName) || String.IsNullOrEmpty(LastName) || String.IsNullOrEmpty(Password) || String.IsNullOrEmpty(ConfirmPassword) || String.IsNullOrEmpty(Email)) { var errorAlertController = UIAlertController.Create("Error", "Please fill out all required fields.", UIAlertControllerStyle.Alert); errorAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(errorAlertController, true, null); } else if (!String.Equals(Password, ConfirmPassword)) { var errorAlertController = UIAlertController.Create("Error", "Passwords do not match, please try again.", UIAlertControllerStyle.Alert); errorAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(errorAlertController, true, null); } else { valid = true; } return(valid); }
public Task <string> DisplayAlertAsync(string title, string message, string cancel, params string[] buttons) { var result = new TaskCompletionSource <string>(); var alert = UIAlertController.Create(title ?? string.Empty, message, UIAlertControllerStyle.Alert); if (!string.IsNullOrWhiteSpace(cancel)) { alert.AddAction(UIAlertAction.Create(cancel, UIAlertActionStyle.Cancel, x => { result.TrySetResult(cancel); })); } foreach (var button in buttons) { alert.AddAction(UIAlertAction.Create(button, UIAlertActionStyle.Default, x => { result.TrySetResult(button); })); } var vc = GetPresentedViewController(); vc?.PresentViewController(alert, true, null); return(result.Task); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. string translatedNumber = ""; TranslateButton.TouchUpInside += (object sender, EventArgs e) => { translatedNumber = PhoneTranslator.ToNumber(PhoneNumberText.Text); PhoneNumberText.ResignFirstResponder(); if (translatedNumber == "") { CallButton.SetTitle("Call ", UIControlState.Normal); CallButton.Enabled = false; } else { CallButton.SetTitle("Call " + translatedNumber, UIControlState.Normal); CallButton.Enabled = true; } }; CallButton.TouchUpInside += (object sender, EventArgs e) => { // Use URL handler with tel: prefix to invoke Apple's Phone app... var url = new NSUrl("tel:" + translatedNumber); // ...otherwise show an alert dialog if (!UIApplication.SharedApplication.OpenUrl(url)) { var alert = UIAlertController.Create("Not supported", "Scheme 'tel:' is not supported on this device", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); } }; }
private void ShowBasemapList() { // Create a new Alert Controller UIAlertController basemapsActionSheet = UIAlertController.Create("Basemaps", "Choose a basemap", UIAlertControllerStyle.ActionSheet); // Add actions to apply each basemap type basemapsActionSheet.AddAction(UIAlertAction.Create("Topographic", UIAlertActionStyle.Default, (action) => _myMapView.Map.Basemap = Basemap.CreateTopographic())); basemapsActionSheet.AddAction(UIAlertAction.Create("Streets", UIAlertActionStyle.Default, (action) => _myMapView.Map.Basemap = Basemap.CreateStreets())); basemapsActionSheet.AddAction(UIAlertAction.Create("Imagery", UIAlertActionStyle.Default, (action) => _myMapView.Map.Basemap = Basemap.CreateImagery())); basemapsActionSheet.AddAction(UIAlertAction.Create("Oceans", UIAlertActionStyle.Default, (action) => _myMapView.Map.Basemap = Basemap.CreateOceans())); basemapsActionSheet.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, (action) => Console.WriteLine("Canceled"))); // Required for iPad - You must specify a source for the Action Sheet since it is displayed as a popover UIPopoverPresentationController presentationPopover = basemapsActionSheet.PopoverPresentationController; if (presentationPopover != null) { presentationPopover.SourceView = this.View; presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Up; } // Display the list of basemaps this.PresentViewController(basemapsActionSheet, true, null); }
// Handle the SearchTextEntered event from the search input UI. // SearchMapsEventArgs contains the search text that was entered. private async void SearchTextEntered(object sender, SearchMapsEventArgs e) { try { // Connect to the portal (anonymously). ArcGISPortal portal = await ArcGISPortal.CreateAsync(new Uri(ServerUrl)); // Create a query expression that will get public items of type 'web map' with the keyword(s) in the items tags. string queryExpression = $"tags:\"{e.SearchText}\" access:public type: (\"web map\" NOT \"web mapping application\")"; // Create a query parameters object with the expression and a limit of 10 results. PortalQueryParameters queryParams = new PortalQueryParameters(queryExpression, 10); // Search the portal using the query parameters and await the results. PortalQueryResultSet <PortalItem> findResult = await portal.FindItemsAsync(queryParams); // Get the items from the query results. IEnumerable <PortalItem> mapItems = findResult.Results; // Show the map results. ShowMapList(mapItems); } catch (Exception ex) { // Report search error. UIAlertController alert = UIAlertController.Create("Error", ex.Message, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); } finally { // Get rid of the search input controls. _searchMapsUi?.Hide(); _searchMapsUi = null; } }
private void ButtonAddItem_Clicked(object sender, EventArgs e) { // https://developer.xamarin.com/recipes/ios/standard_controls/alertcontroller/#ActionSheet_Alert UIAlertController actionSheetAlert = UIAlertController.Create(null, null, UIAlertControllerStyle.ActionSheet); actionSheetAlert.AddAction(UIAlertAction.Create("Add Task", UIAlertActionStyle.Default, delegate { ViewModel.AddTask(); })); actionSheetAlert.AddAction(UIAlertAction.Create("Add Event", UIAlertActionStyle.Default, delegate { ViewModel.AddEvent(); })); actionSheetAlert.AddAction(UIAlertAction.Create("Add Holiday", UIAlertActionStyle.Default, delegate { ViewModel.AddHoliday(); })); actionSheetAlert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null)); // Required for iPad - You must specify a source for the Action Sheet since it is // displayed as a popover UIPopoverPresentationController presentationPopover = actionSheetAlert.PopoverPresentationController; if (presentationPopover != null) { presentationPopover.BarButtonItem = NavItem.RightBarButtonItem; presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Up; } // Display the alert this.PresentViewController(actionSheetAlert, true, null); }
public void RunJavaScriptTextInputPanel(WKWebView webView, string prompt, string defaultText, WebKit.WKFrameInfo frame, System.Action <string> completionHandler) { var alertController = UIAlertController.Create(null, prompt, UIAlertControllerStyle.Alert); UITextField alertTextField = null; alertController.AddTextField(textField => { textField.Placeholder = defaultText; alertTextField = textField; }); alertController.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, okAction => { completionHandler(alertTextField.Text); })); alertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Default, cancelAction => { completionHandler(null); })); UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(alertController, true, null); }
private void selectTime(int index) { // Create a new Alert Controller UIAlertController actionSheetAlertTime = UIAlertController.Create("選擇時間", "是要哪個時段呢?", UIAlertControllerStyle.ActionSheet); // Add Actions actionSheetAlertTime.AddAction(UIAlertAction.Create("早上", UIAlertActionStyle.Default, (action) => PickTime((index + 2).ToString()))); actionSheetAlertTime.AddAction(UIAlertAction.Create("中午", UIAlertActionStyle.Default, (action) => PickTime((index + 4).ToString()))); actionSheetAlertTime.AddAction(UIAlertAction.Create("晚上", UIAlertActionStyle.Default, (action) => PickTime((index + 6).ToString()))); actionSheetAlertTime.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, (action) => Console.WriteLine("Cancel button pressed."))); UIPopoverPresentationController presentationPopover = actionSheetAlertTime.PopoverPresentationController; if (presentationPopover != null) { presentationPopover.SourceView = this.View; presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Up; } // Display the alert this.PresentViewController(actionSheetAlertTime, true, null); }
private async void mapView_GeoViewTapped(object sender, GeoViewInputEventArgs e) { Exception error = null; try { var result = await mapView.IdentifyLayersAsync(e.Position, 3, false); // Retrieves or builds Popup from IdentifyLayerResult var popup = GetPopup(result); // Displays callout and on (i) button click shows PopupViewer in it's own view controller if (popup != null) { var callout = new CalloutDefinition(popup.GeoElement); callout.Tag = popup; callout.ButtonImage = InfoIcon; callout.OnButtonClick = new Action <object>((s) => { var pvc = new PopupInfoViewController(popup); this.PresentModalViewController(pvc, true); }); mapView.ShowCalloutForGeoElement(popup.GeoElement, e.Position, callout); } } catch (Exception ex) { error = ex; } if (error != null) { var alert = UIAlertController.Create(error.GetType().Name, error.Message, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); this.PresentViewController(alert, true, null); } }
partial void UIButton342_TouchUpInside(UIButton sender) { if (string.IsNullOrEmpty(this.EmailText.Text)) { var alert = UIAlertController.Create("Error", "You must enter an email.", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Accept", UIAlertActionStyle.Default, null)); this.PresentViewController(alert, true, null); return; } if (string.IsNullOrEmpty(this.PasswordText.Text)) { var alert = UIAlertController.Create("Error", "You must enter a password.", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Accept", UIAlertActionStyle.Default, null)); this.PresentViewController(alert, true, null); return; } //var ok = UIAlertController.Create("Ok", "F**k yeah!", UIAlertControllerStyle.Alert); //ok.AddAction(UIAlertAction.Create("Accept", UIAlertActionStyle.Default, null)); //this.PresentViewController(ok, true, null); this.DoLogin(); }
partial void EditAsset(UIBarButtonItem sender) { // Use a UIAlertController to display editing options to the user. var alertController = UIAlertController.Create(null, null, UIAlertControllerStyle.ActionSheet); #if !__TVOS__ alertController.ModalPresentationStyle = UIModalPresentationStyle.Popover; var popoverController = alertController.PopoverPresentationController; if (popoverController != null) { popoverController.BarButtonItem = sender; popoverController.PermittedArrowDirections = UIPopoverArrowDirection.Up; } #endif // Add a Cancel action to dismiss the alert without doing anything. alertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null)); // Allow editing only if the PHAsset supports edit operations. if (Asset.CanPerformEditOperation(PHAssetEditOperation.Content)) { // Add actions for some canned filters. alertController.AddAction(UIAlertAction.Create("Sepia Tone", UIAlertActionStyle.Default, _ => { ApplyFilter(new CISepiaTone()); })); alertController.AddAction(UIAlertAction.Create("Chrome", UIAlertActionStyle.Default, _ => { ApplyFilter(new CIPhotoEffectChrome()); })); // Add actions to revert any edits that have been made to the PHAsset. alertController.AddAction(UIAlertAction.Create("Revert", UIAlertActionStyle.Default, RevertAsset)); } // Present the UIAlertController. PresentViewController(alertController, true, null); }
//handles button click depending on action void btnActionTouchUpInside(object sender, EventArgs e) { if (add) { UIAlertController actionSheetAlert = UIAlertController.Create(null, null, UIAlertControllerStyle.ActionSheet); foreach (Profiel p in _appController.DistinctProfielen) { actionSheetAlert.AddAction(UIAlertAction.Create(p.name, UIAlertActionStyle.Default, action => addToProfile(p.name))); } actionSheetAlert.AddAction(UIAlertAction.Create("Nieuw profiel", UIAlertActionStyle.Default, action => addProfileDialog())); actionSheetAlert.AddAction(UIAlertAction.Create("Annuleer", UIAlertActionStyle.Cancel, null)); // Required for iPad - You must specify a source for the Action Sheet since it is // displayed as a popover UIPopoverPresentationController presentationPopover = actionSheetAlert.PopoverPresentationController; if (presentationPopover != null) { presentationPopover.SourceView = imgAction; presentationPopover.SourceRect = new RectangleF(0, 0, 25, 25); presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Up; } PresentViewController(actionSheetAlert, true, null); } else { var okCancelAlertController = UIAlertController.Create(null, _appController.CurrentTotem.title + " verwijderen uit profiel " + _appController.CurrentProfiel.name + "?", UIAlertControllerStyle.Alert); okCancelAlertController.AddAction(UIAlertAction.Create("Ja", UIAlertActionStyle.Default, alert => deleteFromProfile())); okCancelAlertController.AddAction(UIAlertAction.Create("Nee", UIAlertActionStyle.Cancel, null)); PresentViewController(okCancelAlertController, true, null); } }
private void DownloadButton_Click(object sender, EventArgs e) { // Create the alert controller. UIAlertController mapAreaSelectionAlertController = UIAlertController.Create("Map Area Selection", "Select a map area to download and show.", UIAlertControllerStyle.ActionSheet); // Add one action per map area. foreach (PreplannedMapArea area in _preplannedMapAreas) { mapAreaSelectionAlertController.AddAction(UIAlertAction.Create(area.PortalItem.Title, UIAlertActionStyle.Default, action => { // Download and show the selected map area. OnDownloadMapAreaClicked(action.Title); })); } // Needed to prevent a crash on iPad. UIPopoverPresentationController presentationPopover = mapAreaSelectionAlertController.PopoverPresentationController; if (presentationPopover != null) { presentationPopover.SourceView = View; presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Up; } // Display the alert. PresentViewController(mapAreaSelectionAlertController, true, null); // Remove the startup prompt if it hasn't been removed already. if (_initialPrompt != null) { _initialPrompt.RemoveFromSuperview(); _initialPrompt = null; } }
public async Task NotificationLaunched(string pokemonID, DateTime expires, float lat, float lon) { if (expires < DateTime.UtcNow) { var alert = UIAlertController.Create("Pokemon expired", "Looks like that Pokemon has despawned.", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); } else { settings.PokemonEnabled = true; MKCoordinateSpan span = new MKCoordinateSpan(Utility.MilesToLatitudeDegrees(0.7), Utility.MilesToLongitudeDegrees(0.7, lat)); var coords = new CLLocationCoordinate2D(lat, lon); var reg = new MKCoordinateRegion(coords, span); map.SetRegion(reg, true); await ServiceLayer.SharedInstance.LoadData(); var poke = map.Annotations.OfType <Pokemon>().Where(p => p.id == pokemonID).FirstOrDefault(); if (poke != null) { map.SelectAnnotation(poke, true); } } }
void ShowMaps (UIAlertAction action) { #if !DEBUG Xamarin.Insights.Track ("Navigation", new Dictionary<string, string> { { "name", viewModel.Place.Name }, { "rating", viewModel.Place.ToString () } }); #endif CrossExternalMaps.Current.NavigateTo(viewModel.Place.Name, viewModel.Position.Latitude, viewModel.Position.Longitude); }
// Handle the OnMapInfoEntered event from the item input UI. // MapSavedEventArgs contains the title, description, and tags that were entered. private async void MapItemInfoEntered() { // Get the current map. Map myMap = _myMapView.Map; try { // Show the activity indicator so the user knows work is happening. _activityIndicator.StartAnimating(); // Get information entered by the user for the new portal item properties. string[] tags = _tags.Split(','); // Apply the current extent as the map's initial extent. myMap.InitialViewpoint = _myMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry); // Export the current map view for the item's thumbnail. RuntimeImage thumbnailImg = await _myMapView.ExportImageAsync(); // See if the map has already been saved (has an associated portal item). if (myMap.Item == null) { // Call a function to save the map as a new portal item. await SaveNewMapAsync(myMap, _title, _description, tags, thumbnailImg); // Report a successful save. UIAlertController alert = UIAlertController.Create("Saved map", "Saved " + _title + " to ArcGIS Online", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); } else { // This is not the initial save, call SaveAsync to save changes to the existing portal item. await myMap.SaveAsync(); // Get the file stream from the new thumbnail image. Stream imageStream = await thumbnailImg.GetEncodedBufferAsync(); // Update the item thumbnail. ((PortalItem)myMap.Item).SetThumbnail(imageStream); await myMap.SaveAsync(); // Report update was successful. UIAlertController alert = UIAlertController.Create("Updated map", "Saved changes to " + _title, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); } } catch (Exception) { // Report save error. UIAlertController alert = UIAlertController.Create("Error", "Unable to save " + _title, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null)); PresentViewController(alert, true, null); } finally { // Hide the progress bar. _activityIndicator.StopAnimating(); } }
void AddContact (UIAlertAction action) { try { #if !DEBUG Xamarin.Insights.Track ("Click", new Dictionary<string,string> { { "item", "add contact" }, { "name", viewModel.Place.Name }, }); #endif NSError error; addressBook = ABAddressBook.Create(out error); CheckAddressBookAccess(); } catch (Exception ex) { #if !DEBUG ex.Data ["call"] = "add contact"; Xamarin.Insights.Report (ex); #endif } }
void MakeACall (UIAlertAction action) { try { #if !DEBUG Xamarin.Insights.Track ("Click", new Dictionary<string,string> { { "item", "phone" }, { "name", viewModel.Place.Name }, }); #endif if (string.IsNullOrEmpty(viewModel.Place.InternationalPhoneNumber)) { var alertController = UIAlertController.Create(string.Empty, "place_have_no_phone".LocalizedString("Alert message if place have no phone number"), UIAlertControllerStyle.Alert); alertController.AddAction(UIAlertAction.Create("ok".LocalizedString("OK title for button"), UIAlertActionStyle.Destructive, null)); PresentViewController(alertController, true, null); return; } string phoneAppUrl = string.Format("telprompt://{0}", viewModel.Place.InternationalPhoneNumber.Replace(' ', '-')); var formattedString = new NSString (phoneAppUrl).CreateStringByReplacingPercentEscapes(NSStringEncoding.UTF8); using (var phoneaAppUrl = new NSUrl (formattedString)) UIApplication.SharedApplication.OpenUrl(phoneaAppUrl); } catch (Exception ex) { #if !DEBUG ex.Data ["call"] = "phone"; Xamarin.Insights.Report (ex); #endif } }
void OpenStreetView (UIAlertAction action) { var panoramaService = new PanoramaService (); var location = new CoreLocation.CLLocationCoordinate2D (viewModel.Place.Geometry.Location.Latitude, viewModel.Place.Geometry.Location.Longitude); panoramaService.RequestPanorama (location, PanoramaRequestCallback); }
/// <summary> /// Gets all messages from server, and puts on the conversation those that aren't already there. /// </summary> /// <param name="obj">Object.</param> void RefreshMessages(UIAlertAction obj) { var messagesConversation = GetMessagesConversation (); foreach (MessageServer m in messagesConversation) { if (!messages.Contains (m)) messages.Add (m); } FinishReceivingMessage (true); ScrollToBottom (true); }
private void okClicked (UIAlertAction action) { TCAlertManager.getInstance ().pop (this); if (this.Delegate != null) { this.Delegate.alertOkClicked (this); } }
void RevertAsset (UIAlertAction action) { PHPhotoLibrary.SharedPhotoLibrary.PerformChanges (() => { var request = PHAssetChangeRequest.ChangeRequest (Asset); request.RevertAssetContentToOriginal (); }, (success, error) => { if (!success) Console.WriteLine ($"can't revert asset: {error.LocalizedDescription}"); }); }
// Show a secure text entry alert with two custom buttons. private void ShowSecureTextEntryAlert() { var title = "A Short Title is Best".Localize (); var message = "A message should be a short, complete sentence.".Localize (); var cancelButtonTitle = "Cancel".Localize (); var otherButtonTitle = "OK".Localize (); var alertController = UIAlertController.Create (title, message, UIAlertControllerStyle.Alert); NSObject observer = null; // Add the text field for the secure text entry. alertController.AddTextField(textField => { // Listen for changes to the text field's text so that we can toggle the current // action's enabled property based on whether the user has entered a sufficiently // secure entry. observer = NSNotificationCenter.DefaultCenter.AddObserver(UITextField.TextFieldTextDidChangeNotification, HandleTextFieldTextDidChangeNotification); textField.SecureTextEntry = true; }); // Stop listening for text change notifications on the text field. This func will be called in the two action handlers. Action removeTextFieldObserver = () => { NSNotificationCenter.DefaultCenter.RemoveObserver(observer); }; // Create the actions. var cancelAction = UIAlertAction.Create (cancelButtonTitle, UIAlertActionStyle.Cancel, alertAction => { Console.WriteLine ("The 'Secure Text Entry' alert's cancel action occured."); removeTextFieldObserver(); }); var otherAction = UIAlertAction.Create (otherButtonTitle, UIAlertActionStyle.Default, alertAction => { Console.WriteLine ("The 'Secure Text Entry' alert's other action occured."); removeTextFieldObserver (); }); // The text field initially has no text in the text field, so we'll disable it. otherAction.Enabled = false; // Hold onto the secure text alert action to toggle the enabled/disabled state when the text changed. secureTextAlertAction = otherAction; // Add the actions. alertController.AddAction (cancelAction); alertController.AddAction (otherAction); PresentViewController (alertController, true, null); }