public void SendEmail(string email, string title) { if (MFMailComposeViewController.CanSendMail) { try { if (validator.isEmail (email)) { mailController.SetToRecipients (new string[]{ email }); } if(!string.IsNullOrEmpty(title)){ mailController.SetSubject (title); } //_mailController.SetMessageBody ("this is a test", false); mailController.Finished += ( object s, MFComposeResultEventArgs args) => { Console.WriteLine (args.Result.ToString ()); RootController.NavigationBarHidden = false; RootController.ToolbarHidden = false; args.Controller.DismissViewController (true, null); }; RootController.PresentViewController(mailController, true, null); } catch (Exception exp) { Console.WriteLine (exp.Message); } } }
public static UIActionSheet GetActionSheet(PictureMomentViewController controller, UINavigationController nav, Boolean video) { controller.VideoMode = video; controller.NavigationBar.TintColor = nav.NavigationBar.TintColor; var sheet = new UIActionSheet("Choose Source"); sheet.AddButton("Camera"); sheet.AddButton("Library"); sheet.AddButton("Cancel"); sheet.DestructiveButtonIndex = 2; sheet.Clicked += (send, evt) => { if (evt.ButtonIndex == 0) { controller.SourceType = UIImagePickerControllerSourceType.Camera; controller.MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.Camera); if (video) { controller.CameraCaptureMode = UIImagePickerControllerCameraCaptureMode.Video; } else { controller.CameraCaptureMode = UIImagePickerControllerCameraCaptureMode.Photo; } nav.PresentViewController(controller, true, null); } else if (evt.ButtonIndex == 1) { controller.MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.SavedPhotosAlbum); controller.SourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum; nav.PresentViewController(controller, true, null); } }; return(sheet); }
public void ActionsViewControllerDidRequestRemoval(ActionsViewController controller) { var activityItem = new UIActivityItemProvider(item.Url); var activityViewController = new UIActivityViewController(new[] { activityItem.Item }, null); navigationController?.PresentViewController(activityViewController, true, null); }
public async Task ExportPDF(string Exporter, BuilderContext context) { var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var tmp = Path.Combine(documents, "..", "tmp"); using (fs = System.IO.File.OpenWrite(Path.Combine(tmp, context.Player.Name + ".pdf"))) { PDF p = await Load(await PCLSourceManager.Data.GetFileAsync(Exporter).ConfigureAwait(false)).ConfigureAwait(false); await p.Export(context, this).ConfigureAwait(false); } var fileinfo = new FileInfo(Path.Combine(tmp, context.Player.Name + ".pdf")); Device.BeginInvokeOnMainThread(() => { var previewController = new QLPreviewController { DataSource = new PreviewControllerDataSource(fileinfo.FullName, fileinfo.Name) }; UINavigationController controller = FindNavigationController(); if (controller != null) { controller.PresentViewController((UIViewController)previewController, true, (Action)null); } }); }
public void ShowDocumentFile(string name, Stream file, string mimeType) { var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var tmp = Path.Combine(documents, "..", "tmp"); using (FileStream fs = File.OpenWrite(Path.Combine(tmp, name))) { file.CopyTo(fs); } var fileinfo = new FileInfo(Path.Combine(tmp, name)); Device.BeginInvokeOnMainThread(() => { var previewController = new QLPreviewController { DataSource = new PreviewControllerDataSource(fileinfo.FullName, fileinfo.Name) }; UINavigationController controller = FindNavigationController(); if (controller != null) { controller.PresentViewController((UIViewController)previewController, true, (Action)null); } }); }
public void showPhoto(string AttachmentName, byte[] AttachmentBytes) { var FileName = AttachmentName; string dirPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var filename = Path.Combine(dirPath, FileName); FileInfo fi = new FileInfo(filename); if (!NSFileManager.DefaultManager.FileExists(filename)) { Stream stream = new MemoryStream(AttachmentBytes); NSData imgData = NSData.FromStream(stream); NSError err; imgData.Save(filename, false, out err); } Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { QLPreviewController previewController = new QLPreviewController(); previewController.DataSource = new PDFPreviewControllerDataSource(fi.FullName, fi.Name); UINavigationController controller = FindNavigationController(); if (controller != null) { controller.PresentViewController(previewController, true, null); } }); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { Window = new UIWindow(UIScreen.MainScreen.Bounds); ViewController = new ViewController(); var navigationController = new UINavigationController(ViewController) { NavigationBarHidden = true }; GKLocalPlayer.LocalPlayer.AuthenticateHandler = (viewController, error) => { if (error != null) { Console.WriteLine("Error while trying to authenticate local player: " + error.Description); return; } if (GKLocalPlayer.LocalPlayer.Authenticated || (viewController == null)) { return; } navigationController.PresentViewController(viewController, true, null); }; Window.RootViewController = navigationController; Window.MakeKeyAndVisible(); return(true); }
public static void Present(UIViewController controller) { UIApplication.SharedApplication.Windows [0].InvokeOnMainThread(delegate { UINavigationController navcontroller = (UINavigationController)UIApplication.SharedApplication.Windows[0].RootViewController; navcontroller.PresentViewController(controller, true, null); }); }
public void ProccessOrder() { var processing = new ProcessingViewController(WebService.Shared.CurrentUser); processing.OrderPlaced += (object sender, EventArgs e) => { OrderCompleted(); }; navigation.PresentViewController(new UINavigationController(processing), true, null); }
/// <summary> /// Composes the SM. /// </summary> /// <param name="controller">Controller.</param> /// <param name="recipients">Recipients.</param> /// <param name="message">Message.</param> public static void ComposeSMS(UINavigationController controller, string[] recipients, string message) { MFMessageComposeViewController smsController = new MFMessageComposeViewController(); smsController.Recipients = recipients; smsController.Body = message; smsController.Finished += (sender, e) => { smsController.DismissViewController(true, null); }; controller.PresentViewController(smsController, true, null); }
private void ShowPdfFromLocalPath(string path) { FileInfo fi = new FileInfo(path); QLPreviewController previewController = new QLPreviewController { DataSource = new ItemPreviewControllerDataSource(fi.FullName, fi.Name) }; UINavigationController controller = FindNavigationController(); controller?.PresentViewController(previewController, true, null); }
public void PushToModel(UIViewController vc) { if (_splitViewController != null) { _splitViewController.PresentViewController(vc, true, null); } else { _masterNavigationController.PresentViewController(vc, true, null); } }
private void PresentView(UINavigationController navigationController, UIViewController view) { if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { view.ModalPresentationStyle = UIModalPresentationStyle.FormSheet; view.ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve; navigationController.PresentViewController(view, true, null); } else { navigationController.PushViewController(view, true); } }
public void ShowDocumentFile(string filepath) { var fileinfo = new FileInfo(filepath); var previewController = new QLPreviewController(); previewController.DataSource = new PreviewControllerDataSource(fileinfo.FullName, fileinfo.Name); UINavigationController controller = FindNavigationController(); if (controller != null) { controller.PresentViewController((UIViewController)previewController, true, (Action)null); } }
public void Read(string filePath) { FileInfo fi = new FileInfo(filePath); QLPreviewController previewController = new QLPreviewController(); previewController.DataSource = new PDFPreviewControllerDataSource(fi.FullName, fi.Name); UINavigationController controller = FindNavigationController(); if (controller != null) { controller.PresentViewController(previewController, true, null); } }
public void OpenFile(string filePath) { Device.BeginInvokeOnMainThread(() => { FileInfo fi = new FileInfo(filePath); QLPreviewController previewController = new QLPreviewController(); previewController.DataSource = new FilePreviewControllerDataSource(fi.FullName, fi.Name); UINavigationController controller = FindNavigationController(); if (controller != null) { controller.PresentViewController(previewController, true, null); } }); }
private void ShowView(UIViewController vc) { if (MasterNavigationController == null) { MasterNavigationController = new UINavigationController(); var appDelegate = UIApplication.SharedApplication.Delegate as AppDelegate; appDelegate.Window.RootViewController = MasterNavigationController; appDelegate.NavigationController = MasterNavigationController; } if (_showAsPresentView) { MasterNavigationController.PresentViewController(vc, true, null); } else { MasterNavigationController.PushViewController(vc, true); } }
public void ShowDocument(string fileName) { string dirPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); dirPath = Path.Combine(dirPath, "Reports"); var filename = Path.Combine(dirPath, fileName); FileInfo fi = new FileInfo(filename); Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { QLPreviewController previewController = new QLPreviewController(); previewController.DataSource = new PDFPreviewControllerDataSource(fi.FullName, fi.Name); UINavigationController controller = FindNavigationController(); if (controller != null) { controller.PresentViewController(previewController, true, null); } }); }
public void WriteReadData(string filename, byte[] data) { var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var filePath = Path.Combine(documentsPath, filename); File.WriteAllBytes(filePath, data); //Then open the PDF FileInfo fi = new FileInfo(filePath); QLPreviewController previewController = new QLPreviewController(); previewController.DataSource = new PDFPreviewControllerDataSource(fi.FullName, fi.Name); UINavigationController controller = FindNavigationController(); if (controller != null) { controller.PresentViewController(previewController, true, null); } }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { _window = new UIWindow(UIScreen.MainScreen.Bounds); var welcomeView = new WelcomeView(UIScreen.MainScreen.ApplicationFrame); _window.AddSubview(welcomeView); welcomeView.Done += () => { var rootController = new UINavigationController(); _window.RootViewController = rootController; var gettingStarted = new GettingStartedViewController(); gettingStarted.Done += () => _locationService.GetCurrentLocation(coordinate => { var me = new Ninja { GroupName = gettingStarted.GroupName, Latitude = coordinate.Latitude, Longitude = coordinate.Longitude, NickName = gettingStarted.Nickname }; NinjaClient = new ServiceClient(gettingStarted) { AuthenticationProvider = gettingStarted.AuthenticationProvider }; NinjaClient.LocateNinjas(me, ninjasLocated => InvokeOnMainThread(() => { rootController.DismissViewController(true, null); var mapView = new MapViewController(coordinate, ninjasLocated); mapView.Title = me.GroupName; rootController.PushViewController(mapView, true); })); }); rootController.PresentViewController(gettingStarted, true, null); }; _window.MakeKeyAndVisible(); return true; }
public void MakeApplePayment(ApplePayViewModel payment, JudoSuccessCallback success, JudoFailureCallback failure, UINavigationController controller, ApplePaymentType type) { try { PKPaymentRequest request = new PKPaymentRequest(); request.CurrencyCode = payment.CurrencyCode; request.CountryCode = payment.CountryCode; request.MerchantCapabilities = (PKMerchantCapability)payment.MerchantCapabilities; request.SupportedNetworks = payment.SupportedNetworks; request.PaymentSummaryItems = payment.Basket; request.MerchantIdentifier = payment.MerchantIdentifier;// @"merchant.com.judo.Xamarin"; // do it with configuration/overwrite var pkDelegate = new JudoPKPaymentAuthorizationViewControllerDelegate(this, request, payment.ConsumerRef.ToString(), type, success, failure); PKPaymentAuthorizationViewController pkController = new PKPaymentAuthorizationViewController(request) { Delegate = pkDelegate }; controller.PresentViewController(pkController, true, null); } catch (Exception e) { Console.WriteLine(e.InnerException.ToString()); var judoError = new JudoError() { Exception = e }; failure(judoError); } }
public string SavePdfFile(byte[] imageByte) { var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments); var filePath = Path.Combine(documentsPath, "download.pdf"); File.WriteAllBytes(filePath, imageByte); FileInfo fi = new FileInfo(filePath); QLPreviewController previewController = new QLPreviewController(); previewController.DataSource = new PDFPreviewControllerDataSource(fi.FullName, fi.Name); UINavigationController controller = FindNavigationController(); if (controller != null) { controller.PresentViewController(previewController, true, null); } return(filePath); }
public override bool FinishedLaunching (UIApplication app, NSDictionary options) { Window = new UIWindow (UIScreen.MainScreen.Bounds); ViewController = new ViewController (); var navigationController = new UINavigationController (ViewController) { NavigationBarHidden = true }; GKLocalPlayer.LocalPlayer.AuthenticateHandler = (viewController, error) => { if (error != null) { Console.WriteLine ("Error while trying to authenticate local player: " + error.Description); return; } if (GKLocalPlayer.LocalPlayer.Authenticated || (viewController == null)) return; navigationController.PresentViewController (viewController, true, null); }; Window.RootViewController = navigationController; Window.MakeKeyAndVisible (); return true; }
void UploadFromCamera() { m_imagePicker = new UIImagePickerController(); m_imagePicker.SourceType = UIImagePickerControllerSourceType.Camera; m_imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes( UIImagePickerControllerSourceType.Camera); m_imagePicker.FinishedPickingMedia += ImagePicker_FinishedPickingMedia;; m_imagePicker.Canceled += (sender, evt) => { m_imagePicker.DismissModalViewController(true); }; var window = UIApplication.SharedApplication.KeyWindow; UINavigationController navigationController = window.RootViewController as UINavigationController; //UINavigationController navigationController = new UINavigationController(new iOSApp()); //window.RootViewController = navigationController; //window.MakeKeyAndVisible(); navigationController.PresentViewController(m_imagePicker, true, null); //AppDelegate.GetCurrentController().ShowViewController(m_imagePicker, null); }
private void ShowView(UIViewController viewController) { if (viewController is IRootView) { if (viewController is MainViewController) { var xVC = viewController as IXiOSView; var index = xVC.ParameterData == null ? 0 : (int)xVC.ParameterData; var viewC = viewController as MainViewController; viewC.SetVisibleView(index); } Debug.WriteLine($"ViewController is a Root Controller"); SetRootViewController(viewController); } else { var presentViewProperty = viewController?.GetType()?.GetProperty("ShowAsPresentView"); bool showAsModal = (bool)presentViewProperty?.GetValue(viewController); if (MasterNavigationController == null) { Debug.WriteLine($"MasterNavigationController is null"); SetRootViewController(new MainViewController()); } if (showAsModal) { MasterNavigationController.PresentViewController(viewController, true, null); } else { MasterNavigationController.PushViewController(viewController, true); } Debug.WriteLine($"{viewController} was Pushed/Presented"); } }
/// <summary> /// This method swipe and delete row /// </summary> /// <param name="tableView"></param> /// <param name="editingStyle"></param> /// <param name="indexPath"></param> //public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath) //{ // // base.CommitEditingStyle(tableView, editingStyle, indexPath); // switch (editingStyle) // { // case UITableViewCellEditingStyle.Delete: // // remove the item from the underlying data source // mEmployees.RemoveAt(indexPath.Row); // // delete the row from the table // tableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade); // var listOfCustomersAsJson = JsonConvert.SerializeObject(this.mEmployees); // File.WriteAllText(mFilename, listOfCustomersAsJson); // break; // } //} public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("bg-BG"); EmployeeCell cell = (EmployeeCell)tableView.DequeueReusableCell("Custom_Cell", indexPath); Customer currentEmployee = mEmployees[indexPath.Row]; cell.UpdateCell(currentEmployee); // setTag to button to identify in which row button is pressed cell.DeleteBtn.Tag = indexPath.Row; cell.EditBtn.Tag = indexPath.Row; //assign action cell.DeleteBtn.TouchUpInside += (sender, e) => { //Create Alert var confirmCustomerDelete = UIAlertController.Create("Потвърждавате ли изтриването ?", $"Изтрий клиент " + $"{currentEmployee.FullName.ToString()}", UIAlertControllerStyle.Alert); //Add Actions to alert confirmCustomerDelete.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, alert => { var row = ((UIButton)sender).Tag; var currentCustomer = mEmployees[indexPath.Row]; mEmployees.RemoveAt((int)row); var listOfCustomersAsJson = JsonConvert.SerializeObject(this.mEmployees); File.WriteAllText(mFilename, listOfCustomersAsJson); tableView.ReloadData(); if (mEmployees.Count == 0) { InvokeOnMainThread(() => { mViewController.MFullUpdateText.Text = "Моля добавете абонати"; } ); } })); confirmCustomerDelete.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, alert => this.Dispose())); //Present Alert navController.PresentViewController(confirmCustomerDelete, true, null); }; cell.EditBtn.TouchUpInside += (sender, e) => { var row = ((UIButton)sender).Tag; var currentCustomer = mEmployees[indexPath.Row]; var detailViewController1 = mStoryBoard.InstantiateViewController("DetailView"); //var detailViewController = mStoryBoard.InstantiateViewController("TestModalvViewMiniController"); //var detailViewController = new ModalViewController(Handle); //var detailViewController = new ModalViewController(indexPath.Row, mEmployees.Count, // currentCustomer.NotifyNewInvoice, currentCustomer.NotifyInvoiceOverdue, currentCustomer.NotifyReading); var detailViewController = new ModalViewController(); detailViewController = (ModalViewController)detailViewController1; detailViewController.MCurrentPosition = indexPath.Row; detailViewController.MCustomresCount = mEmployees.Count; detailViewController.MIsNewCharge = currentCustomer.NotifyNewInvoice; detailViewController.MIsLateCharge = currentCustomer.NotifyInvoiceOverdue; detailViewController.MIsReport = currentCustomer.NotifyReading; detailViewController.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext; mViewController.PresentViewController(detailViewController, true, null); //mViewController, navController // navController.PushViewController(detailViewController, true); detailViewController.OnEditCustomerComplete += (object sender1, OnEditCustomerEventArgs e1) => { currentCustomer.NotifyNewInvoice = e1.IsThereANewCharge; currentCustomer.NotifyInvoiceOverdue = e1.IsThereALateBill; currentCustomer.NotifyReading = e1.IsThereAReport; Customer updateCustomer = mEmployees[indexPath.Row]; updateCustomer.NotifyNewInvoice = e1.IsThereANewCharge; updateCustomer.NotifyInvoiceOverdue = e1.IsThereALateBill; updateCustomer.NotifyReading = e1.IsThereAReport; mEmployees.RemoveAt(indexPath.Row); //new count -1 mEmployees.Insert(e1.CurrentPossition, updateCustomer); // put in the same posstion var listOfCustomersAsJson = JsonConvert.SerializeObject(this.mEmployees); File.WriteAllText(mFilename, listOfCustomersAsJson); tableView.ReloadData(); }; }; return(cell); }
private void PresentView (UINavigationController navigationController, UIViewController view) { if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad) { view.ModalPresentationStyle = UIModalPresentationStyle.FormSheet; view.ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve; navigationController.PresentViewController (view, true, null); } else { navigationController.PushViewController (view, true); } }
public void Show(UINavigationController navController, QRCodeReaderCallback _callback) { readerView.HideLayer(); callback = _callback; navController.PresentViewController(this, true, null); }