Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static async Task OpenDocument(string filePath, bool? canShare, bool? canPrint) {
- await Mask();
- ctx.printButton.IsVisible = false;
- ctx.shareButton.IsVisible = false;
- //DEBUG
- string loaded = LoadedFilePath;
- if (LoadedFilePath == filePath) {
- await Unmask();
- return;
- }
- string typeFile = MimeTypeMap.GetMimeType(Path.GetExtension(filePath));
- if (typeFile.Equals("application/pdf")) {
- try {
- ShowPDFView(filePath, canShare, canPrint);
- } catch (Exception e) {
- Utils.Utils.Log(e.Message);
- await LogController.AddErrorLog(e.Message, e.StackTrace);
- }
- } else if (typeFile.Equals("application/vnd.ms-powerpoint") || (typeFile.Equals("application/vnd.openxmlformats-officedocument.presentationml.presentation"))) {
- try {
- string newPathName = filePath + "converted.pdf";
- System.IO.File.Move(filePath, newPathName);
- MemoryStream stream = await DocumentController.PptxToPdfViewerAsync(newPathName);
- ShowPDFView(newPathName, canShare, canPrint);
- } catch (Exception e) {
- Utils.Utils.Log(e.Message);
- await LogController.AddErrorLog(e.Message, e.StackTrace);
- }
- } else if (typeFile.Equals("video/mp4")) {
- try {
- ShowMediaView(filePath);
- } catch (Exception e) {
- Utils.Utils.Log(e.Message);
- await LogController.AddErrorLog(e.Message, e.StackTrace);
- }
- } else if (typeFile.Equals("image/jpeg") || typeFile.Equals("image/png")) {
- try {
- ShowImageView(filePath);
- } catch (Exception e) {
- Utils.Utils.Log(e.Message);
- await LogController.AddErrorLog(e.Message, e.StackTrace);
- }
- } else if (typeFile.Equals("application/zip")) {
- try {
- string extractedDir = Path.GetFileName(DocumentController.ExtractZipFile(filePath));
- string htmlFilePath = Path.Combine(DependencyService.Get<IAppHelper>().getBaseUrl(), extractedDir + "/index.html");
- ShowWebView(htmlFilePath);
- } catch (Exception e) {
- Utils.Utils.Log(e.Message);
- await LogController.AddErrorLog(e.Message, e.StackTrace);
- }
- }
- HomePage.LoadedFilePath = filePath;
- await Unmask();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement