Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        static Task PlatformOpenAsync(OpenFileRequest request)
        {
            if (File.Exists(request.File.FullPath))
            {
                Process.Start(request.File.FullPath);
            }

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

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

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