private async void ChangeUserProfile(PlatformDocument document) { // Ensure that user downloads .png or .jpg file as profile icon. if (document.Name.EndsWith(".png") || document.Name.EndsWith(".jpg") || document.Name.EndsWith(".jpeg")) { try { ViewModelChanged = true; await Task.Run(() => { var imageContent = _fileService.ReadAllBytes(document.Path); var resizedImage = _mediaService.ResizeImage(imageContent, ConstantsHelper.ResizedImageWidth, ConstantsHelper.ResizedImageHeight); ImageContent = resizedImage; }).ConfigureAwait(false); Device.BeginInvokeOnMainThread(UpdateProfilePhoto); } catch (Exception ex) { await UserDialogs.Instance.AlertAsync(ex.Message); } } }
private async Task PickPhotoCommandExecute(PlatformDocument document) { if (document.Name.EndsWith(".png") || document.Name.EndsWith(".jpg")) { var photoModel = new PhotoModel { NoteId = Id }; var mediaService = DependencyService.Get <IMediaService>(); var fileSystem = DependencyService.Get <IFileSystem>(); var imageContent = fileSystem.ReadAllBytes(document.Path); var resizedImage = mediaService.ResizeImage(imageContent, ConstantsHelper.ResizedImageWidth, ConstantsHelper.ResizedImageHeight); string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal); string imagePath = Path.Combine(path, document.Name); File.WriteAllBytes(imagePath, resizedImage); photoModel.ResizedPath = imagePath; photoModel.Thumbnail = imagePath; await _transformHelper.ResizeAsync(imagePath, photoModel); Photos.Add(photoModel.ToPhotoViewModel()); PhotosCollectionChanged?.Invoke(this, EventArgs.Empty); } IsLoading = false; }
private async Task PickPhotoCommandExecute(PlatformDocument document) { IsLoading = true; var ci = CrossMultilingual.Current.CurrentCultureInfo; if (document.Name.EndsWith(".png") || document.Name.EndsWith(".jpg")) { var mediaService = DependencyService.Get <IMediaService>(); var fileSystem = DependencyService.Get <IFileSystem>(); var imageContent = fileSystem.ReadAllBytes(document.Path); var resizedImage = mediaService.ResizeImage(imageContent, ConstantsHelper.ResizedImageWidth, ConstantsHelper.ResizedImageHeight); var photoModel = new PhotoModel { Name = document.Name, Image = Convert.ToBase64String(resizedImage) }; Photos.Add(photoModel.ToPhotoViewModel()); PhotosCollectionChanged?.Invoke(this, EventArgs.Empty); IsLoading = false; } else { IsLoading = false; var imagePickErrorMesssageLocalized = Resmgr.Value.GetString(ConstantsHelper.ImagePickErrorMesssage, ci); var okLocalized = Resmgr.Value.GetString(ConstantsHelper.Ok, ci); _alertService.ShowOkAlert(imagePickErrorMesssageLocalized, okLocalized); } }
private void ChangeUserProfileCommandExecute(PlatformDocument document) { // Ensure that user downloads .png or .jpg file as profile icon. if (document.Name.EndsWith(".png") || document.Name.EndsWith(".jpg")) { var imageContent = FileService.ReadAllBytes(document.Path); var resizedImage = MediaService.ResizeImage(imageContent, ConstantsHelper.ResizedImageWidth, ConstantsHelper.ResizedImageHeight); ImageContent = resizedImage; } }
static async Task RunAsync(string[] args) { if (args.Length < 2) { WSUtilities.PrintVersionMesssage("VerifyAttachments", "1.0"); Console.WriteLine("VerifyAttachments.exe [settings file] [IC]"); Console.WriteLine("Gets the number of channels in IC::ATCH and looks for more channels in /risks/root items"); return; } try { WSSettings settings = WSSettings.Load(args[0]); WSAPIClient client = WSAPIClient.ForToken(settings); _ = await client.DoOIDC(settings); client = WSAPIClient.ForJSON(settings); string url = String.Format("/api/documents/{0}", args[1] + "::ATCH"); PlatformDocument doc = await client.DoGet <PlatformDocument>(url); Console.WriteLine("{0} has {1} channel(s)", doc._id, doc.channels.Count); url = string.Format("/api/risks/root/{0}", args[1]); List <RisksRootResult> risksRootResult = await client.DoGet <List <RisksRootResult> >(url); Console.WriteLine("{0} results from {1}", risksRootResult.Count, url); foreach (var r in risksRootResult) { string prefix = ""; if (r.channels.Count > doc.channels.Count) { prefix = "ERROR: "; } Console.WriteLine("{0}{1} has {2} channel(s)", prefix, r.id, r.channels.Count); } } catch (Exception ex) { Console.WriteLine("ERROR: " + ex.Message); } }