Esempio n. 1
0
        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.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);
            return(Task.CompletedTask);
        }
Esempio n. 2
0
        public static Task OpenAsync(OpenFileRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (request.File == null)
            {
                throw new ArgumentNullException(nameof(request.File));
            }

            return(PlatformOpenAsync(request));
        }
Esempio n. 3
0
        static Task PlatformOpenAsync(OpenFileRequest request)
        {
            if (string.IsNullOrEmpty(request.File.FullPath))
            {
                throw new ArgumentNullException(nameof(request.File.FullPath));
            }

            Permissions.EnsureDeclared <Permissions.LaunchApp>();

            var appControl = new AppControl
            {
                Operation = AppControlOperations.View,
                Mime      = FileSystem.MimeTypes.All,
                Uri       = "file://" + request.File.FullPath,
            };

            AppControl.SendLaunchRequest(appControl);

            return(Task.CompletedTask);
        }
Esempio n. 4
0
        static Task PlatformOpenAsync(OpenFileRequest request)
        {
            var contentUri = Platform.GetShareableFileUri(request.File);

            var intent = new Intent(Intent.ActionView);

            intent.SetDataAndType(contentUri, request.File.ContentType);
            intent.SetFlags(ActivityFlags.GrantReadUriPermission);

            var chooserIntent = Intent.CreateChooser(intent, request.Title ?? string.Empty);
            var flags         = ActivityFlags.ClearTop | ActivityFlags.NewTask;

#if __ANDROID_24__
            if (Platform.HasApiLevelN)
            {
                flags |= ActivityFlags.LaunchAdjacent;
            }
#endif
            chooserIntent.SetFlags(flags);

            Platform.AppContext.StartActivity(chooserIntent);

            return(Task.CompletedTask);
        }
Esempio n. 5
0
 static Task PlatformOpenAsync(OpenFileRequest request) =>
 throw ExceptionUtils.NotSupportedOrImplementedException;
Esempio n. 6
0
 static Task PlatformOpenAsync(OpenFileRequest request) =>
 throw new FeatureNotSupportedException();
Esempio n. 7
0
        static async Task PlatformOpenAsync(OpenFileRequest request)
        {
            var storageFile = request.File.File ?? await StorageFile.GetFileFromPathAsync(request.File.FullPath);

            await WinLauncher.LaunchFileAsync(storageFile).AsTask();
        }
Esempio n. 8
0
 static Task PlatformOpenAsync(OpenFileRequest request) =>
 Task.FromResult(NSWorkspace.SharedWorkspace.OpenFile(request.File.FullPath));