示例#1
0
        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);
        }
示例#2
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.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);
        }
示例#3
0
        static Task PlatformOpenAsync(OpenFileRequest request)
        {
            if (File.Exists(request.File.FullPath))
            {
                Process.Start(request.File.FullPath);
            }

            return(Task.CompletedTask);
        }
示例#4
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));
        }
示例#5
0
        static Task PlatformOpenAsync(OpenFileRequest request)
        {
            var fileUrl = NSUrl.FromFilename(request.File.FullPath);

            var documentController = UIDocumentInteractionController.FromUrl(fileUrl);

            documentController.Uti = request.File.ContentType;

            var vc = Platform.GetCurrentViewController();

            documentController.PresentOpenInMenu(vc.View.Frame, vc.View, true);
            return(Task.CompletedTask);
        }
示例#6
0
        static Task PlatformOpenAsync(OpenFileRequest request)
        {
            var contentUri = Platform.GetShareableFileUri(request.File.FullPath);

            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);

            chooserIntent.SetFlags(ActivityFlags.ClearTop);
            chooserIntent.SetFlags(ActivityFlags.NewTask);
            Platform.AppContext.StartActivity(chooserIntent);

            return(Task.CompletedTask);
        }
示例#7
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      = "*/*",
                Uri       = "file://" + request.File.FullPath,
            };

            AppControl.SendLaunchRequest(appControl);

            return(Task.CompletedTask);
        }
示例#8
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,
            };

            if (!string.IsNullOrEmpty(request.File.FullPath))
            {
                appControl.ExtraData.Add("http://tizen.org/appcontrol/data/path", request.File.FullPath);
            }

            AppControl.SendLaunchRequest(appControl);

            return(Task.CompletedTask);
        }
        static Task PlatformOpenAsync(OpenFileRequest request)
        {
            var contentUri = Platform.GetShareableFileUri(request.File.FullPath);

            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);
        }
 static Task PlatformOpenAsync(OpenFileRequest request) =>
 Task.FromResult(NSWorkspace.SharedWorkspace.OpenFile(request.File.FullPath));
示例#11
0
 static Task PlatformOpenAsync(OpenFileRequest request) =>
 throw new FeatureNotSupportedException();
示例#12
0
 static Task PlatformOpenAsync(OpenFileRequest request) =>
 throw ExceptionUtils.NotSupportedOrImplementedException;
示例#13
0
 public static Task OpenAsync(OpenFileRequest request)
 {
     return(PlatformOpenAsync(request));
 }
        public static Task OpenAsync(OpenFileRequest request)
        {
            ExperimentalFeatures.VerifyEnabled(ExperimentalFeatures.ShareFileRequest);

            return PlatformOpenAsync(request);
        }
 static Task PlatformOpenAsync(OpenFileRequest request) =>
 throw new NotImplementedInReferenceAssemblyException();
示例#16
0
        static async Task PlatformOpenAsync(OpenFileRequest request)
        {
            var storageFile = request.File.File ?? await StorageFile.GetFileFromPathAsync(request.File.FullPath);

            await WinLauncher.LaunchFileAsync(storageFile).AsTask();
        }