public IEnumerator ApplyAvatarTextureToImage(User user, RawImage image) { Debug.Log("Retrieving avatar for " + user.GetUserId()); if (ApplicationFileManager.IsAvatarDownloaded(user)) { Debug.Log("Avatar already downloaded. Applying saved texture"); image.texture = ApplicationFileManager.GetDownloadedAvatar(user); } else { Debug.Log("Download started"); WWW currentDownload = new WWW(user.GetUserAvatarLocation()); while (!currentDownload.isDone && currentDownload.error == null) { yield return(null); } Debug.Log("Download finished"); if (!string.IsNullOrEmpty(currentDownload.error)) // If the web request returned an error, return the error... { image.texture = BLANK_DOWNLOAD_TEXTURE; throw new Exception(currentDownload.error); } else // otherwise, return the text content of the web request { Texture2D downloadedTexture = currentDownload.texture; ApplicationFileManager.SaveAvatar(downloadedTexture, user); image.texture = downloadedTexture; yield return("Success!"); } } }
public static IEnumerator DownloadGlyphFromFirebase(Glyph glyph) { string path = glyph.GetPathToContent(); bool commandFinished = false; Debug.Log("Downloading content for " + glyph.GetGlyphId()); // Create local filesystem URL string local_url = ApplicationFileManager.GetLocalDownloadPath(glyph); // Firebase.Storage.StorageReference glyph_fb_reference = storage_ref.Child (path); // Download to the local filesystem FileInfo local_file = new FileInfo(local_url); local_file.Directory.Create(); Debug.Log("Path: " + path); // glyph_fb_reference.GetFileAsync(local_url).ContinueWith(task => { // if (!task.IsFaulted && !task.IsCanceled) { // Debug.Log("File downloaded."); // commandFinished = true; // } else { // Debug.LogError("error downloading file: " + task.Exception); // } // }); while (!commandFinished) { yield return(null); } yield return("Done"); }
private void setImageToDrawing() { if (ApplicationFileManager.DoesAddGlyphFileExist()) { setImageTexture(ApplicationFileManager.LoadAddGlyphFileTexture()); } }
private IEnumerator setGlyphImage(Glyph glyph) { if (!ApplicationFileManager.IsGlyphDownloaded(glyph)) { ServerCall call = new ServerCall(ServerInteract.DownloadGlyphFromFirebase(glyph)); yield return(StartCoroutine(call.call())); } Texture2D texture = ApplicationFileManager.LoadTextureFromPNGFile(ApplicationFileManager.GetLocalDownloadPath(glyph)); glyphImage.texture = texture; imageSet = true; imageTransform.sizeDelta = new Vector2(texture.width, texture.height); if (placeHolderHeight != 0.0f) { float imageScale = (placeHolderHeight - IMAGE_PADDING * 2.0f) / texture.height; imageTransform.localScale = new Vector3(imageScale, imageScale, imageScale); imageResized = true; } yield return("Done"); }
private IEnumerator saveDrawing() { yield return(new WaitForEndOfFrame()); ApplicationFileManager.SavePaintTextureToAddGlyphFile(canvasTexture.GetScreenshot()); SceneManager.LoadScene(ADD_GLYPH_SCENE); }
public static void switchToAddGlyphScene() { //if (ApplicationFileManager.addGlyphFileExists()) { // SceneManager.LoadScene ("Scenes/AddGlyph"); //} else { ApplicationFileManager.DeleteAddGlyphFile(); SceneManager.LoadScene("Scenes/TakePicture"); //} }
public AutoApplicationBundler(ApplicationSettings settings) : base(settings) { _razorEngine = new RazorEngine(); _razorEngine.AddProjectDirectory(Settings.ProjectName, Settings.ProjectDirectory); _fileManager = new ApplicationFileManager() { TempStylesFilePath = Path.GetTempFileName() }; _projAnalyzer = new ProjectAnalyzer(); _asmAnalyzer = new AssemblyAnalyzer(); }
private void renderPNGGlyph(Glyph glyph) { string localPath = ApplicationFileManager.GetLocalDownloadPath(glyph); Debug.Log("Render: Loading " + localPath); Texture2D tex = ApplicationFileManager.LoadTextureFromPNGFile(localPath); if (tex == null) { Debug.LogError("Render: Couldn't find downloaded file"); } else { Debug.Log("Render: File loaded, setting image"); setGlyphContentDisplayImage(tex); } }
public async Task <BaseApiResponse> UpdateClientPhotoAsync(int fileId) { if (!IsAuthenticated) { return(new BaseApiResponse(false, ValidationMessages.YouAreNotAuthorized)); } var userRepo = GetRepository <Client>(); var userToEditEntity = await userRepo.Query().FirstOrDefaultAsync(x => x.Id == UserId); if (userToEditEntity == null) { return(new BaseApiResponse(false, ValidationMessages.UserNotFound)); } var fileManager = new ApplicationFileManager(AmbientContext.RepositoryFactory); var file = await fileManager.LocalStorageService.GetFilesQueryable().FirstOrDefaultAsync(x => x.Id == fileId); if (file == null) { return(new BaseApiResponse(false, DbFileValidationMessages.FileIsNotFoundById)); } if (!file.IsImage()) { return(new BaseApiResponse(false, DbFileValidationMessages.FileIsNotImage)); } userToEditEntity.AvatarFileId = fileId; userRepo.UpdateHandled(userToEditEntity); return(await TryExecuteCodeAndReturnSuccessfulResultAsync(async() => { await SaveChangesAsync(); await _refreshUserDataFunc(await GetUserByIdAsync(userToEditEntity.Id), userToEditEntity); return new BaseApiResponse(true, ClientResource.ClientAvatarUpdated); })); }
private void loadSnapshot() { Texture2D snapshot = ApplicationFileManager.LoadTextureFromPNGFile(ApplicationFileManager.TAKE_PICTURE_FILE_PATH); if (snapshot != null) { canvasTexture.addSnapshot(snapshot); File.Delete(ApplicationFileManager.TAKE_PICTURE_FILE_PATH); } else { snapshot = ApplicationFileManager.LoadTextureFromPNGFile(ApplicationFileManager.ADD_GLYPH_FILE_PATH); if (snapshot == null) { return; } canvasTexture.addSnapshot(snapshot); } }
private IEnumerator doRenderForGlyph(Glyph glyph) { Debug.Log("Render: Loading " + ApplicationFileManager.GetLocalDownloadPath(glyph)); if (!ApplicationFileManager.IsGlyphDownloaded(glyph)) { Debug.Log("Render: Downloading"); ServerCall download = new ServerCall(ServerInteract.DownloadGlyphFromFirebase(glyph)); yield return(StartCoroutine(download.call())); if (download.ReturnException != null) { statusPanel.showErrorStatus(download.ReturnException.Message); throw download.ReturnException; } //yield return StartCoroutine (ServerInteract.downloadObjectFromAWS (glyph.getPathToContent (), LoadUserData.getLoggedInUser ().getAWSAuthToken ())); Debug.Log("Render: Downloading finished"); } else { Debug.Log("Render: Glyph already downloaded"); } string extension = ApplicationFileManager.GetFileExtension(glyph.GetPathToContent()); if (extension.Equals(ApplicationFileManager.PNG_EXTENSION)) { Debug.Log("Render: Loading PNG File"); renderPNGGlyph(glyph); Debug.Log("Render: Finished"); } else { Debug.LogError("Render: Unknown Render Type " + extension); } yield return("Done"); }
private IEnumerator doRenderForGlyph(Glyph glyph) { Debug.Log("Render: Loading " + ApplicationFileManager.GetLocalDownloadPath(glyph)); if (!ApplicationFileManager.IsGlyphDownloaded(glyph)) { Debug.Log("Render: Downloading"); ServerCall download = new ServerCall(ServerInteract.DownloadGlyphFromFirebase(glyph)); yield return(StartCoroutine(download.call())); //yield return StartCoroutine (ServerInteract.downloadObjectFromAWS (glyph.getPathToContent (), LoadUserData.getLoggedInUser ().getAWSAuthToken ())); Debug.Log("Render: Downloading finished"); } else { Debug.Log("Render: Glyph already downloaded"); } string extension = ApplicationFileManager.GetFileExtension(glyph.GetPathToContent()); if (extension.Equals(ApplicationFileManager.PNG_EXTENSION)) { Debug.Log("Render: Loading PNG File"); renderPNGGlyph(glyph); } else { Debug.Log("Render: Unknown Render Type " + extension); } ServerCall markGlyphFound = new ServerCall(ServerInteract.INSTANCE.MarkGlyphAsFound(glyph)); StartCoroutine(markGlyphFound.call()); Debug.Log("Render: Finished"); yield return("Done"); }
private void saveSnapshot() { ApplicationFileManager.SaveTextureToFile(ApplicationFileManager.TAKE_PICTURE_FILE_PATH, currentSnapshot); SceneManager.LoadScene(PAINT_SCENE); }
private IEnumerator uploadGlyph() { if (HardwareController.Instance.getLastLocation().Equals(GPSLocation.UNDEFINED)) { statusPanel.showErrorStatus(CANNOT_ACCESS_LOCATION_ERROR); yield return(null); } else if (LoggedInUser.GetLoggedInUser() == null) { statusPanel.showErrorStatus(NO_LOGGED_IN_USER_ERROR); yield return(null); } else { statusPanel.showLoadingStatus("Creating Glyph"); double latitude = HardwareController.Instance.getLastLocation().latitude; double longitude = HardwareController.Instance.getLastLocation().longitude; double altitude = HardwareController.Instance.getLastLocation().altitude; ServerCall uploadGlyphCall; if (!publicToggle.isOn) { uploadGlyphCall = new ServerCall(ServerInteract.INSTANCE.AddPrivateGlyph(latitude, longitude, altitude)); } else { uploadGlyphCall = new ServerCall(ServerInteract.INSTANCE.AddPublicGlyph(latitude, longitude, altitude, dateTimePicker.getSelectedDateTime())); } yield return(StartCoroutine(uploadGlyphCall.call())); if (uploadGlyphCall.ReturnException != null) { statusPanel.showErrorStatus(uploadGlyphCall.ReturnException.Message); } else { OwnedGlyphEvent ownedGlyph = (OwnedGlyphEvent)uploadGlyphCall.ObjectResponse; LoggedInUser.GetLoggedInUser().ownedGlyphs.Add(ownedGlyph); statusPanel.showLoadingStatus("Uploading Picture"); ServerCall uploadToFirebaseCall = new ServerCall(ServerInteract.INSTANCE.UploadAddGlyphFileToFirebase(ownedGlyph.GetGlyph())); yield return(StartCoroutine(uploadToFirebaseCall.call())); if (uploadToFirebaseCall.ReturnException != null) { statusPanel.showErrorStatus(uploadToFirebaseCall.ReturnException.Message); } else { statusPanel.showStatus("Glyph Created!"); ApplicationFileManager.DeleteAddGlyphFile(); yield return(new WaitForSeconds(3)); SceneManager.LoadScene("Scenes/GroundViewScene"); } } } yield return("Done"); }