示例#1
0
        private async Task ApplySelectedImage(Stream inputImage)
        {
            if (inputImage == null)
            {
                return;
            }

            // copy as managed stream
            var imageCopy = new MemoryStream();
            await inputImage.CopyToAsync(imageCopy);

            imageCopy.Seek(0, SeekOrigin.Begin);
            MemberImageStream = imageCopy;
            OnMemberImageSelected?.Invoke();
        }
示例#2
0
        private async Task OnSaveMemberCommandExecuted()
        {
            if (IsBusy || !IsMemberImageStreamDefined)
            {
                return;
            }

            try
            {
                IsBusy = true;
                OnPropertyChanged(nameof(CanSaveMember));

                var newMember = new PersonData()
                {
                    Name        = Member.Text,
                    ImageStream = MemberImageStream,
                };

                await EyeSpyService.Value.AddTrustedPerson(newMember);

                MemberImageStream.Dispose();
                MemberImageStream = null;
                OnMemberImageSelected?.Invoke();
                MessagingCenter.Send(this, "AddMemberCompleted", Member);
                OnSaveMemberCommandCompleted?.Invoke();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
                OnPropertyChanged(nameof(CanSaveMember));
            }
        }