Exemplo n.º 1
0
        private static async void OnOpenSampleFile(string path)
        {
#if WINDOWS_UWP || __TVOS__ || __IOS__ || __ANDROID__ || __TIZEN__
            var title = "Open " + Path.GetExtension(path).ToUpperInvariant();
            await Launcher.OpenAsync(new OpenFileRequest(title, new ReadOnlyFile(path)));
#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 __DESKTOP__
            Process.Start(path);
#elif __WASM__
            var data       = File.ReadAllBytes(path);
            var gch        = GCHandle.Alloc(data, GCHandleType.Pinned);
            var pinnedData = gch.AddrOfPinnedObject();
            try
            {
                WebAssemblyRuntime.InvokeJS($"fileSaveAs('{Path.GetFileName(path)}', {pinnedData}, {data.Length})");
            }
            finally
            {
                gch.Free();
            }
#endif
        }
Exemplo n.º 2
0
        private static async void OnOpenSampleFile(string path)
        {
#if WINDOWS_UWP || __TVOS__ || __IOS__ || __ANDROID__ || __TIZEN__
            var title = "Open " + Path.GetExtension(path).ToUpperInvariant();
            await Launcher.OpenAsync(new OpenFileRequest(title, new ReadOnlyFile(path)));
#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 __DESKTOP__
            Process.Start(path);
#endif
        }
Exemplo n.º 3
0
        static void PlatformOpen(string number)
        {
            ValidateOpen(number);

            Launcher.OpenAsync("tel:" + number);
        }
 static async void PlatformShowSettingsUI()
 => await Launcher.OpenAsync(UIApplication.OpenSettingsUrlString);