/// <summary>
        /// Adds a photo from the specified path to use as a profile photo.
        /// </summary>
        /// <param name="ms">The file stream.</param>
        /// <param name="saveLocalCopy">Set to <c>true</c> to save a local copy, <c>false</c> otherwise.</param>
        /// <param name="showAlert">Set to <c>true</c> to show an alert if photo is too large; <c>false</c> otherwise.</param>
        /// <returns></returns>
        protected internal async Task AddPhoto(MemoryStream ms, bool saveLocalCopy, bool showAlert)
        {
            byte[] bytes = ms.ToArray();
            ms.Dispose();
            if (bytes.Length > this.TagProfile.HttpFileUploadMaxSize.GetValueOrDefault())
            {
                if (showAlert)
                {
                    await this.UiDispatcher.DisplayAlert(AppResources.ErrorTitle, AppResources.PhotoIsTooLarge);
                }
                return;
            }

            RemovePhoto(saveLocalCopy);

            if (saveLocalCopy)
            {
                try
                {
                    File.WriteAllBytes(localPhotoFileName, bytes);
                }
                catch (Exception e)
                {
                    this.LogService.LogException(e);
                }
            }
            this.photo = new LegalIdentityAttachment(localPhotoFileName, Constants.MimeTypes.Jpeg, bytes);
            Image      = ImageSource.FromStream(() => new MemoryStream(bytes));
            RegisterCommand.ChangeCanExecute();
        }
        /// <inheritdoc />
        protected override async Task DoBind()
        {
            await base.DoBind();

            RegisterCommand.ChangeCanExecute();
            this.NeuronService.ConnectionStateChanged += NeuronService_ConnectionStateChanged;
        }
 private void NeuronService_ConnectionStateChanged(object sender, ConnectionStateChangedEventArgs e)
 {
     UiDispatcher.BeginInvokeOnMainThread(() =>
     {
         SetConnectionStateAndText(e.State);
         RegisterCommand.ChangeCanExecute();
     });
 }