public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { if (indexPath.Section == 0) { var previewController = UIDocumentInteractionController.FromUrl( NSUrl.FromFilename(source.Documents[indexPath.Row])); previewController.Delegate = new MyInteractionDelegate(this); previewController.PresentPreview(true); // You can present other options for the file instead of a preview // //previewController.PresentOptionsMenu(TableView.Frame, TableView, true); //previewController.PresentOpenInMenu(TableView.Frame, TableView, true); } else { var previewController = new QLPreviewController(); previewController.DataSource = new QuickLookSource(source.Documents); previewController.CurrentPreviewItemIndex = indexPath.Row; NavigationController.PushViewController(previewController, true); // You can present modally instead // // PresentViewController(previewController, true, null); } }
public override void DidEndPreview(UIDocumentInteractionController controller) { if (null != doneWithPreview) { doneWithPreview(null, null); } }
Task <bool> PlatformOpenAsync(OpenFileRequest request) { #pragma warning disable CA1416 // https://github.com/xamarin/xamarin-macios/issues/14619 documentController = new UIDocumentInteractionController() { Name = request.File.FileName, Url = NSUrl.FromFilename(request.File.FullPath), Uti = request.File.ContentType }; var view = Platform.GetCurrentUIViewController().View; CGRect rect; if (request.PresentationSourceBounds != Rect.Zero) { rect = request.PresentationSourceBounds.AsCGRect(); } else { rect = DeviceInfo.Idiom == DeviceIdiom.Tablet ? new CGRect(new CGPoint(view.Bounds.Width / 2, view.Bounds.Height), CGRect.Empty.Size) : view.Bounds; } documentController.PresentOpenInMenu(rect, view, true); #pragma warning restore CA1416 return(Task.FromResult(true)); }
public void open(string filepath) { var previewController = UIDocumentInteractionController.FromUrl(NSUrl.FromFilename(filepath)); previewController.Delegate = new FileInteractionDelegate(GetVisibleViewController()); previewController.PresentPreview(true); }
private void ShowExtraMenu(object o, EventArgs arg) { var sheet = CreateActionSheet(Title); var vm = ViewModel; var openButton = !string.IsNullOrEmpty(ViewModel.FilePath) ? sheet.AddButton("Open In") : -1; var shareButton = !string.IsNullOrEmpty(ViewModel.HtmlUrl) ? sheet.AddButton("Share") : -1; var showButton = ViewModel.GoToHtmlUrlCommand.CanExecute(null) ? sheet.AddButton("Show in GitHub") : -1; var cancelButton = sheet.AddButton("Cancel"); sheet.CancelButtonIndex = cancelButton; sheet.Dismissed += (s, e) => BeginInvokeOnMainThread(() => { try { if (e.ButtonIndex == openButton) { var ctrl = new UIDocumentInteractionController(); ctrl.Url = NSUrl.FromFilename(ViewModel.FilePath); ctrl.PresentOpenInMenu(NavigationItem.RightBarButtonItem, true); } else if (e.ButtonIndex == shareButton) { AlertDialogService.ShareUrl(ViewModel?.HtmlUrl, o as UIBarButtonItem); } else if (e.ButtonIndex == showButton) { vm.GoToHtmlUrlCommand.Execute(null); } } catch { } }); sheet.ShowFrom(NavigationItem.RightBarButtonItem, true); }
public override UIViewController ViewControllerForPreview(UIDocumentInteractionController controller) { UIViewController value; owner.TryGetTarget(out value); return(value); }
private void ShowExtraMenu() { var sheet = MonoTouch.Utilities.GetSheet(); var openButton = sheet.AddButton("Open In"); var shareButton = ViewModel.HtmlUrl != null ? sheet.AddButton("Share") : -1; var showButton = ViewModel.HtmlUrl != null ? sheet.AddButton("Show in Bitbucket") : -1; var cancelButton = sheet.AddButton("Cancel"); sheet.CancelButtonIndex = cancelButton; sheet.DismissWithClickedButtonIndex(cancelButton, true); sheet.Dismissed += (s, e) => { BeginInvokeOnMainThread(() => { if (e.ButtonIndex == openButton) { var ctrl = new UIDocumentInteractionController(); ctrl.Url = NSUrl.FromFilename(ViewModel.FilePath); ctrl.PresentOpenInMenu(NavigationItem.RightBarButtonItem, true); } else if (e.ButtonIndex == shareButton) { Mvx.Resolve<IShareService>().ShareUrl(ViewModel.HtmlUrl); } else if (e.ButtonIndex == showButton) { ViewModel.GoToHtmlUrlCommand.Execute(null); } }); }; sheet.ShowInView(this.View); }
private void ShowExtraMenu() { var sheet = MonoTouch.Utilities.GetSheet(Title); var openButton = sheet.AddButton("Open In".t()); var shareButton = ViewModel.HtmlUrl != null ? sheet.AddButton("Share".t()) : -1; var showButton = ViewModel.HtmlUrl != null ? sheet.AddButton("Show in Bitbucket".t()) : -1; var cancelButton = sheet.AddButton("Cancel".t()); sheet.CancelButtonIndex = cancelButton; sheet.DismissWithClickedButtonIndex(cancelButton, true); sheet.Clicked += (s, e) => { if (e.ButtonIndex == openButton) { var ctrl = new UIDocumentInteractionController(); ctrl.Url = NSUrl.FromFilename(ViewModel.FilePath); ctrl.PresentOpenInMenu(NavigationItem.RightBarButtonItem, true); } else if (e.ButtonIndex == shareButton) { var item = UIActivity.FromObject (ViewModel.HtmlUrl); var activityItems = new NSObject[] { item }; UIActivity[] applicationActivities = null; var activityController = new UIActivityViewController (activityItems, applicationActivities); PresentViewController (activityController, true, null); } else if (e.ButtonIndex == showButton) { ViewModel.GoToHtmlUrlCommand.Execute(null); } }; sheet.ShowInView(this.View); }
static Task PlatformOpenAsync(OpenFileRequest request) { var fileUrl = NSUrl.FromFilename(request.File.FullPath); documentController = UIDocumentInteractionController.FromUrl(fileUrl); documentController.Delegate = new DocumentControllerDelegate { DismissHandler = () => { documentController?.Dispose(); documentController = null; } }; documentController.Uti = request.File.ContentType; var vc = Platform.GetCurrentViewController(); CoreGraphics.CGRect?rect = null; if (DeviceInfo.Idiom == DeviceIdiom.Tablet) { rect = new CoreGraphics.CGRect(new CoreGraphics.CGPoint(vc.View.Bounds.Width / 2, vc.View.Bounds.Height), CoreGraphics.CGRect.Empty.Size); } else { rect = vc.View.Bounds; } documentController.PresentOpenInMenu(rect.Value, vc.View, true); return(Task.CompletedTask); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { // set up resource paths string fontName = "content-font.ttf"; SkiaSharp.Demos.CustomFontPath = NSBundle.MainBundle.PathForResource(Path.GetFileNameWithoutExtension(fontName), Path.GetExtension(fontName)); var dir = Path.Combine(Path.GetTempPath(), "SkiaSharp.Demos", Path.GetRandomFileName()); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } SkiaSharp.Demos.WorkingDirectory = dir; SkiaSharp.Demos.OpenFileDelegate = path => { var vc = Xamarin.Forms.Platform.iOS.Platform.GetRenderer(Xamarin.Forms.Application.Current.MainPage) as UIViewController; var resourceToOpen = NSUrl.FromFilename(Path.Combine(dir, path)); var controller = UIDocumentInteractionController.FromUrl(resourceToOpen); if (!controller.PresentOpenInMenu(vc.View.Bounds, vc.View, true)) { new UIAlertView("SkiaSharp", "Unable to open file.", null, "OK").Show(); } }; global::Xamarin.Forms.Forms.Init(); LoadApplication(new App()); return(base.FinishedLaunching(app, options)); }
/// <summary> /// Exports the configuration. Create a zip file which can be shared /// </summary> /// <param name="sender">Sender.</param> async partial void ExportConfiguration(NSObject sender) { UIActivityIndicatorView activityIndicator = new UIActivityIndicatorView(ExportConfigBtn.Frame); activityIndicator.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray; activityIndicator.StartAnimating(); this.View.AddSubview(activityIndicator); ExportConfigBtn.Hidden = true; string zip = await ConfigsEngine.CreateFileForExport(_loadedConfiguration); activityIndicator.StopAnimating(); activityIndicator.RemoveFromSuperview(); ExportConfigBtn.Hidden = false; if (zip == string.Empty) { UIAlertView alertError = new UIAlertView("Error".Localize(), "Error Creating Zip File".Localize(), null, "Ok".Localize()); alertError.Show(); return; } var viewer = UIDocumentInteractionController.FromUrl(NSUrl.FromFilename(zip)); viewer.PresentOpenInMenu(ExportConfigBtn.Frame, this.View, true); }
public override UIView ViewForPreview (UIDocumentInteractionController controller) { UIViewController vc = ViewControllerForPreview (controller); if (vc == null) return null; return vc.View; }
private void ShowExtraMenu(object o, EventArgs arg) { var sheet = CreateActionSheet(Title); var vm = ViewModel; var openButton = !string.IsNullOrEmpty(ViewModel.FilePath) ? sheet.AddButton("Open In") : -1; var shareButton = !string.IsNullOrEmpty(ViewModel.HtmlUrl) ? sheet.AddButton("Share") : -1; var showButton = ViewModel.GoToHtmlUrlCommand.CanExecute(null) ? sheet.AddButton("Show in GitHub") : -1; var cancelButton = sheet.AddButton("Cancel"); sheet.CancelButtonIndex = cancelButton; sheet.Dismissed += (s, e) => BeginInvokeOnMainThread(() => { try { if (e.ButtonIndex == openButton) { var ctrl = new UIDocumentInteractionController(); ctrl.Url = NSUrl.FromFilename(ViewModel.FilePath); ctrl.PresentOpenInMenu(NavigationItem.RightBarButtonItem, true); } else if (e.ButtonIndex == shareButton) { AlertDialogService.ShareUrl(ViewModel?.HtmlUrl, o as UIBarButtonItem); } else if (e.ButtonIndex == showButton) { vm.GoToHtmlUrlCommand.Execute(null); } } catch { } }); sheet.ShowFrom(NavigationItem.RightBarButtonItem, true); }
private static UPMInboxFile ModelInboxFileFromInboxFile(UPInboxFile inboxFile) { UPMInboxFile upmInboxFile = new UPMInboxFile(StringIdentifier.IdentifierWithStringId(inboxFile.Path)) { Path = inboxFile.Path, URL = inboxFile.URL }; #if PORTING upmInboxFile.Name = inboxFile.Path.LastPathComponent(); Exception attributesErr; NSDictionary fileAttributes = NSFileManager.DefaultManager().AttributesOfItemAtPathError(inboxFile.Path, attributesErr); if (attributesErr) { DDLogError("UPInBoxPageModelController error no fileAttributes: %@", fileAttributes); } NSNumber fileSizeNumber = fileAttributes.ObjectForKey(NSFileSize); upmInboxFile.Size = fileSizeNumber.LongLongValue(); upmInboxFile.FormattedSize = NSByteCountFormatter.StringFromByteCountCountStyle(upmInboxFile.Size, NSByteCountFormatterCountStyleFile); upmInboxFile.Date = fileAttributes.ObjectForKey(NSFileCreationDate); // Cant use TimeZone here. Called before Login and server independent. upmInboxFile.FormattedDate = UPInBoxPageModelController.UpDateFormatter().StringFromDate(upmInboxFile.Date); UIDocumentInteractionController interactionController = UIDocumentInteractionController.InteractionControllerWithURL(inboxFile.URL); ArrayList icons = interactionController.Icons; //upmInboxFile.Icon = icons.LastObject(); // Adding largest Icon available #endif upmInboxFile.MimeTye = UPInboxFileManager.MimeTypeForPath(upmInboxFile.Path); upmInboxFile.Color = UPInBoxPageModelController.ColorForMimeType(upmInboxFile.MimeTye); return(upmInboxFile); }
public override void DidEndSendingToApplication(UIDocumentInteractionController controller, string application) { //ChallengeModel challenge = InstagramViewController.Challenge; //challenge.Status = "Pending"; //SL.Manager.UpdateChallenge(challenge, challenge.ID); InstagramViewController.SendToInstagramComplete(); }
public static void PreviewFile(this UIViewController controller, NSUrl url) { if (!(controller is IUIDocumentInteractionControllerDelegate @delegate)) { throw new InvalidOperationException($"{controller.GetType().Name} must implement 'UIDocumentInteractionControllerDelegate' protocol."); } var preview = UIDocumentInteractionController.FromUrl(url); preview.Delegate = @delegate; if (preview.PresentPreview(true)) { return; } var alert = UIAlertController.Create(Localize("Global.NoPreview.Short"), Localize("Global.NoPreview.Long"), UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create(Localize("Global.BackAction"), UIAlertActionStyle.Cancel, null)); var ok = UIAlertAction.Create(Localize("Global.NoPreview.OpenIn"), UIAlertActionStyle.Default, action => { var share = new UIActivityViewController(new[] { url }, null); controller.PresentViewController(share, true, null); }); alert.AddAction(ok); alert.SetPreferredAction(ok); controller.PresentViewController(alert, true, null); }
public override System.Drawing.RectangleF RectangleForPreview (UIDocumentInteractionController controller) { UIView view = ViewForPreview (controller); if (view == null) return RectangleF.Empty; return view.Frame; }
/// <summary> /// Print preview of the report. /// </summary> /// <param name="sender">Sender.</param> partial void btnPrintPreview_TouchUpInside(UIButton sender) { //Object inspectionObject=new Object(); if (reportPhotoSegment.SelectedSegment == 0) { if (File.Exists(reportPath)) { var viewer = UIDocumentInteractionController.FromUrl(NSUrl.FromFilename(reportPath)); UIDocumentInteractionControllerDelegateDerived del = new UIDocumentInteractionControllerDelegateDerived(this); del.doneWithPreview += (informer, eventArgs) => { btnFinalizeSave.Hidden = false; btnEdit.Hidden = false; }; viewer.Delegate = del; viewer.PresentPreview(true); } } else { if (File.Exists(PhotoLogReportPath)) { var viewer = UIDocumentInteractionController.FromUrl(NSUrl.FromFilename(PhotoLogReportPath)); UIDocumentInteractionControllerDelegateDerived del = new UIDocumentInteractionControllerDelegateDerived(this); del.doneWithPreview += (informer, eventArgs) => { btnFinalizeSave.Hidden = false; btnEdit.Hidden = false; }; viewer.Delegate = del; viewer.PresentPreview(true); } } }
static Task PlatformOpenAsync(OpenFileRequest request) { documentController = new UIDocumentInteractionController() { Name = request.File.FileName, Url = NSUrl.FromFilename(request.File.FullPath), Uti = request.File.ContentType }; var view = Platform.GetCurrentUIViewController().View; CGRect rect; if (request.PresentationSourceBounds != Rectangle.Empty) { rect = request.PresentationSourceBounds.ToPlatformRectangle(); } else { rect = DeviceInfo.Idiom == DeviceIdiom.Tablet ? new CGRect(new CGPoint(view.Bounds.Width / 2, view.Bounds.Height), CGRect.Empty.Size) : view.Bounds; } documentController.PresentOpenInMenu(rect, view, true); return(Task.CompletedTask); }
private void OpenFile() { string filePath = PdfPath(); var viewer = UIDocumentInteractionController.FromUrl(NSUrl.FromFilename(filePath)); viewer.PresentOpenInMenu(new RectangleF(0, -260, 320, 320), this.owner.View, true); }
public void OpenIn(object sender, string file) { var ctrl = new UIDocumentInteractionController(); ctrl.Url = NSUrl.FromFilename(file); ctrl.PresentOpenInMenu(sender as UIBarButtonItem, true); }
private void ShareDeck(Deck deck) { UIViewController topCtrl = UIApplication.SharedApplication.KeyWindow.RootViewController; //save deck in temp location with name var tempdir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var file = Path.Combine(tempdir, deck.Name + ".dfd"); var deckJson = JsonConvert.SerializeObject(deck, Formatting.Indented); File.WriteAllText(file, deckJson); var navCtrl = topCtrl.ChildViewControllers.OfType <NavigationRenderer>().FirstOrDefault(); if (navCtrl != null) { viewCtrl = navCtrl.TopViewController; var allButtons = viewCtrl.NavigationItem.RightBarButtonItems; var button = allButtons[0]; uidic = UIDocumentInteractionController.FromUrl(new NSUrl(file, true)); uidic.Name = "Share Deck"; uidic.Uti = "com.benreierson.deck"; result = uidic.PresentOptionsMenu(button, true); } }
private void CreateShareInstagram(string mediaPath) { NSUrl imageURL = new NSUrl(mediaPath, false); NSUrl instagramURL = NSUrl.FromString(@"instagram://app"); //check for App is install or not if (UIApplication.SharedApplication.CanOpenUrl(instagramURL)) { documentController = UIDocumentInteractionController.FromUrl(imageURL); documentController.Uti = "com.instagram.exclusivegram"; UIView presentingView = GetVisibleViewController().View; documentController.PresentOpenInMenu(new CGRect(x: 1, y: 1, width: 1, height: 1), presentingView, true); ShareInsTaskCompletion.SetResult(true); } else { bool isSimulator = Runtime.Arch == Arch.SIMULATOR; NSUrl itunesLink; if (isSimulator) { itunesLink = new NSUrl("https://itunes.apple.com/us/app/instagram/id389801252?mt=8"); } else { itunesLink = new NSUrl("itms://itunes.apple.com/us/app/instagram/id389801252?mt=8"); } UIApplication.SharedApplication.OpenUrl(itunesLink, new NSDictionary() { }, null); } }
/// <summary> /// Open Instagram with the specified image and caption. /// </summary> /// <returns><c>true</c> if Instagram is installed, <c>false</c> otherwise.</returns> /// <param name="image">Image.</param> /// <param name="caption">Caption.</param> public static bool Instagram(UIImage image, string caption = null) { if (!UIApplication.SharedApplication().CanOpenURL(new NSURL("instagram://app"))) { return(false); } // write image to tmp folder NSData data = image.JPEGRepresentation(1f); string filePath = Application.temporaryCachePath + "/" + UUID.Generate() + ".igo"; data.WriteToFile(filePath, true); _documentIC = UIDocumentInteractionController.InteractionController(new NSURL(filePath, false)); _documentIC.UTI = "com.instagram.exclusivegram"; if (caption != null) { var annotation = new Dictionary <object, object>(); annotation["InstagramCaption"] = caption; _documentIC.annotation = annotation; } var rootView = UIApplication.deviceRootViewController.view; _documentIC.PresentOpenInMenu(new Rect(0, 0, 1, 1), rootView, true); return(true); }
private void ShowExtraMenu() { var sheet = CreateActionSheet(Title); var openButton = !string.IsNullOrEmpty(ViewModel.FilePath) ? sheet.AddButton("Open In".t()) : -1; var shareButton = !string.IsNullOrEmpty(ViewModel.HtmlUrl) ? sheet.AddButton("Share".t()) : -1; var showButton = ViewModel.GoToHtmlUrlCommand.CanExecute(null) ? sheet.AddButton("Show in GitHub".t()) : -1; var cancelButton = sheet.AddButton("Cancel".t()); sheet.CancelButtonIndex = cancelButton; sheet.DismissWithClickedButtonIndex(cancelButton, true); sheet.Clicked += (s, e) => { try { if (e.ButtonIndex == openButton) { var ctrl = new UIDocumentInteractionController(); ctrl.Url = NSUrl.FromFilename(ViewModel.FilePath); ctrl.PresentOpenInMenu(NavigationItem.RightBarButtonItem, true); } else if (e.ButtonIndex == shareButton) { ViewModel.ShareCommand.Execute(null); } else if (e.ButtonIndex == showButton) { ViewModel.GoToHtmlUrlCommand.Execute(null); } } catch (Exception ex) { } }; sheet.ShowInView(this.View); }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { NSUrl url = new NSUrl(TableItems[indexPath.Row].longdesc, true); UIDocumentInteractionController udoc = UIDocumentInteractionController.FromUrl(url); udoc.PresentOpenInMenu(CGRect.Empty, owner.View, true); tableView.DeselectRow(indexPath, true); }
void IPDFHelper.OpenPDF(string pdfFilepath) { var viewer = UIDocumentInteractionController.FromUrl(NSUrl.FromFilename(pdfFilepath)); var rootVC = UIApplication.SharedApplication.KeyWindow.RootViewController; var rootView = rootVC.View; var temp = viewer.PresentOpenInMenu(new CoreGraphics.CGRect(0, -200, 100, 100), rootView, true); System.Diagnostics.Debug.WriteLine(temp); }
public override System.Drawing.RectangleF RectangleForPreview(UIDocumentInteractionController controller) { UIView view = ViewForPreview(controller); if (view == null) { return(RectangleF.Empty); } return(view.Frame); }
public void OpenFile(string filePath) { var PreviewController = UIDocumentInteractionController.FromUrl(NSUrl.FromFilename(filePath)); PreviewController.Delegate = new UIDocumentInteractionControllerDelegateClass(UIApplication.SharedApplication.KeyWindow.RootViewController); Device.BeginInvokeOnMainThread(() => { PreviewController.PresentPreview(true); }); }
public override UIView ViewForPreview(UIDocumentInteractionController controller) { UIViewController vc = ViewControllerForPreview(controller); if (vc == null) { return(null); } return(vc.View); }
public void OpenFile(NSUrl fileUrl) { var docControl = UIDocumentInteractionController.FromUrl(fileUrl); var window = UIApplication.SharedApplication.KeyWindow; var subViews = window.Subviews; var lastView = subViews.Last(); var frame = lastView.Frame; docControl.PresentOpenInMenu(frame, lastView, true); }
public bool OpenFile(byte[] fileData, string id, string fileName) { var filePath = Path.Combine(GetTempPath(), fileName); File.WriteAllBytes(filePath, fileData); var url = NSUrl.FromFilename(filePath); var viewer = UIDocumentInteractionController.FromUrl(url); var controller = GetVisibleViewController(); return(viewer.PresentOpenInMenu(controller.View.Frame, controller.View, true)); }
public override void ViewDidUnload() { base.ViewDidUnload(); this.SaveButton = null; this.LoadButton = null; this.RotateLeft = null; this.RotateRight = null; this.ImageView = null; this.dic = null; }
private static async void OnOpenSampleFile(string path) { #if WINDOWS_UWP var file = await StorageFile.GetFileFromPathAsync(path); await Launcher.LaunchFileAsync(file); #elif __MACOS__ if (!NSWorkspace.SharedWorkspace.OpenFile(path)) { var alert = new NSAlert(); alert.AddButton("OK"); alert.MessageText = "SkiaSharp"; alert.InformativeText = "Unable to open file."; alert.RunSheetModal(NSApplication.SharedApplication.MainWindow); } #elif __TVOS__ #elif __IOS__ // the external / shared location var external = Path.Combine(Path.GetTempPath(), "SkiaSharpSample"); if (!Directory.Exists(external)) { Directory.CreateDirectory(external); } // copy file to external var newPath = Path.Combine(external, Path.GetFileName(path)); File.Copy(path, newPath); // open the file var vc = Xamarin.Forms.Platform.iOS.Platform.GetRenderer(Xamarin.Forms.Application.Current.MainPage) as UIViewController; var resourceToOpen = NSUrl.FromFilename(newPath); var controller = UIDocumentInteractionController.FromUrl(resourceToOpen); if (!controller.PresentOpenInMenu(vc.View.Bounds, vc.View, true)) { new UIAlertView("SkiaSharp", "Unable to open file.", (IUIAlertViewDelegate)null, "OK").Show(); } #elif __ANDROID__ // the external / shared location var external = Path.Combine(Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "SkiaSharpSample"); if (!Directory.Exists(external)) { Directory.CreateDirectory(external); } // copy file to external var newPath = Path.Combine(external, Path.GetFileName(path)); File.Copy(path, newPath); // open the file var uri = Android.Net.Uri.FromFile(new Java.IO.File(newPath)); var intent = new Intent(Intent.ActionView, uri); intent.AddFlags(ActivityFlags.NewTask); Application.Context.StartActivity(intent); #elif __DESKTOP__ Process.Start(path); #endif }
private void PresentOpenIn(UIBarButtonItem barButtonItem) { if (ContentSavePath == null) { return; } var ctrl = new UIDocumentInteractionController(); ctrl.Url = NSUrl.FromFilename(ContentSavePath); ctrl.PresentOpenInMenu(barButtonItem, true); }
public void OpenActionSheet(string path) { var window = UIApplication.SharedApplication.KeyWindow; var subviews = window.Subviews; var view = subviews.Last(); NSUrl videoUrl = NSUrl.CreateFileUrl(path, null); UIDocumentInteractionController openInWindow = UIDocumentInteractionController.FromUrl(videoUrl); openInWindow.PresentOptionsMenu(CGRect.Empty, view, true); //openInWindow.PresentOpenInMenu(CGRect.Empty, view, true); }
public FilePresenter () { this.documentInteractionController = new UIDocumentInteractionController (); this.documentInteractionController.Delegate = this; }
/// <summary> /// Open Instagram with the specified image and caption. /// </summary> /// <returns><c>true</c> if Instagram is installed, <c>false</c> otherwise.</returns> /// <param name="image">Image.</param> /// <param name="caption">Caption.</param> public static bool Instagram(UIImage image, string caption = null) { if (!UIApplication.SharedApplication().CanOpenURL(new NSURL("instagram://app"))) return false; // write image to tmp folder NSData data = image.JPEGRepresentation(1f); string filePath = Application.temporaryCachePath + "/" + UUID.Generate() + ".igo"; data.WriteToFile(filePath, true); _documentIC = UIDocumentInteractionController.InteractionController(new NSURL(filePath, false)); _documentIC.UTI = "com.instagram.exclusivegram"; if (caption != null) { var annotation = new Dictionary<object, object>(); annotation["InstagramCaption"] = caption; _documentIC.annotation = annotation; } var rootView = UIApplication.deviceRootViewController.view; _documentIC.PresentOpenInMenu(new Rect(0, 0, 1, 1), rootView, true); return true; }
private static UIViewController ViewControllerForPreview(UIDocumentInteractionController c) { return UIApplication.SharedApplication.KeyWindow.RootViewController; }
private void OpenFile(string filePath, DataItem item) { var sbounds = UIScreen.MainScreen.Bounds; string ext = UrlHelper.GetExtension(filePath); if (ext.ToUpper () == ".MOV" || ext.ToUpper () == ".M4V") { var movieController = new AdvancedUIViewController (); moviePlayer = new MPMoviePlayerController (NSUrl.FromFilename (filePath)); moviePlayer.View.Frame = new RectangleF ( sbounds.X, sbounds.Y - 20, sbounds.Width, sbounds.Height - 30 ); moviePlayer.ControlStyle = MPMovieControlStyle.Fullscreen; moviePlayer.View.AutoresizingMask = (UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight); moviePlayer.ShouldAutoplay = true; moviePlayer.PrepareToPlay (); moviePlayer.Play (); var btnClose = UIButton.FromType (UIButtonType.RoundedRect); btnClose.Frame = new RectangleF (3, 7, 60, 30); btnClose.SetTitle ("Close", UIControlState.Normal); btnClose.SetTitleColor (UIColor.Black, UIControlState.Normal); btnClose.TouchDown += delegate { movieController.DismissModalViewControllerAnimated (true); }; var btnShare = UIButton.FromType (UIButtonType.RoundedRect); btnShare.Frame = new RectangleF ( (sbounds.Width / 2) - 50, sbounds.Height - 50, 100, 30 ); btnShare.SetTitle ("Share", UIControlState.Normal); btnShare.SetTitleColor (UIColor.Black, UIControlState.Normal); btnShare.TouchDown += delegate { ResharedItem = item; ResharedItemType = FileType.Video; ShowSecretsView(); }; movieController.View.AddSubview (moviePlayer.View); movieController.View.AddSubview (btnClose); movieController.View.AddSubview (btnShare); navigation.PresentModalViewController (movieController, true); } else if (ext.ToUpper () == ".JPEG" || ext.ToUpper () == ".JPG" || ext.ToUpper () == ".PNG") { ALAssetsLibrary library = new ALAssetsLibrary (); library.AssetForUrl (new NSUrl (filePath), (asset) => { if (asset != null) { var imageController = new AdvancedUIViewController (); var image = UIImage.FromImage (asset.DefaultRepresentation.GetFullScreenImage ()); var imageView = new UIImageView (image); imageView.Frame = sbounds; imageView.UserInteractionEnabled = true; imageView.ClipsToBounds = true; imageView.ContentMode = UIViewContentMode.ScaleAspectFit; var btnClose = UIButton.FromType (UIButtonType.RoundedRect); btnClose.Frame = new RectangleF ( (sbounds.Width / 2) - 50, 20, 100, 30 ); btnClose.SetTitle ("Close", UIControlState.Normal); btnClose.SetTitleColor (UIColor.Black, UIControlState.Normal); btnClose.TouchDown += delegate { imageController.DismissModalViewControllerAnimated (true); }; var btnShare = UIButton.FromType (UIButtonType.RoundedRect); btnShare.Frame = new RectangleF ( (sbounds.Width / 2) - 50, sbounds.Height - 60, 100, 30 ); btnShare.SetTitle ("Share", UIControlState.Normal); btnShare.SetTitleColor (UIColor.Black, UIControlState.Normal); btnShare.TouchDown += delegate { ResharedItem = item; ResharedItemType = FileType.Photo; ShowSecretsView(); }; var scrollView = new UIScrollView (sbounds); scrollView.ClipsToBounds = true; scrollView.ContentSize = sbounds.Size; scrollView.BackgroundColor = UIColor.Gray; scrollView.MinimumZoomScale = 1.0f; scrollView.MaximumZoomScale = 3.0f; scrollView.MultipleTouchEnabled = true; scrollView.AutoresizingMask = (UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight); scrollView.ViewForZoomingInScrollView = delegate(UIScrollView sv) { return imageView; }; scrollView.AddSubview (imageView); imageController.View.AddSubview (scrollView); imageController.View.AddSubview (btnClose); imageController.View.AddSubview (btnShare); navigation.PresentModalViewController (imageController, true); } else { Console.Out.WriteLine ("Asset is null."); } }, (error) => { if (error != null) { Console.Out.WriteLine ("Error: " + error.LocalizedDescription); } } ); } else { var btnShare = UIButton.FromType (UIButtonType.RoundedRect); btnShare.Frame = new RectangleF ( (sbounds.Width / 2) - 50, sbounds.Height - 50, 100, 30 ); btnShare.SetTitle ("Share", UIControlState.Normal); btnShare.SetTitleColor (UIColor.Black, UIControlState.Normal); btnShare.Tag = SHARE_BUTTON_TAG; btnShare.TouchDown += delegate { ResharedItem = item; ResharedItemType = FileType.Other; ShowSecretsView(); }; navigation.Add(btnShare); interactionControllerDelegate = new UIDocumentInteractionControllerDelegateClass(navigation); interactionController = UIDocumentInteractionController.FromUrl(NSUrl.FromFilename(filePath)); interactionController.Delegate = interactionControllerDelegate; InvokeOnMainThread(delegate { interactionController.PresentPreview(true); }); } }
public override UIViewController ViewControllerForPreview(UIDocumentInteractionController controller) { return this.controller; }
public override UIViewController ViewControllerForPreview (UIDocumentInteractionController controller) { UIViewController value; owner.TryGetTarget(out value); return value; }
public override void WillBeginPreview (UIDocumentInteractionController controller) { ReadyToPresent (controller, EventArgs.Empty); }
public override void DidEndPreview (UIDocumentInteractionController controller) { Done (controller, EventArgs.Empty); }
protected override void Dispose (bool disposing) { base.Dispose (disposing); documentInteractionController.Dispose (); documentInteractionController = null; }
public override RectangleF RectangleForPreview(UIDocumentInteractionController controller) { return viewC.View.Frame; }
public override UIView ViewForPreview(UIDocumentInteractionController controller) { return viewC.View; }
public TableSource (DocumentViewModel documentViewModel) { this.documentViewModel = documentViewModel; documentController = new UIDocumentInteractionController(); }