Beispiel #1
0
        /// <summary>
        /// Called when [user interface loaded].
        /// </summary>
        /// <param name="payload">The payload.</param>
        /// <returns></returns>
        private async Task OnUserInterfaceLoaded(object payload)
        {
            try
            {
                IsUserInterfaceEnabled = false;
                MessageHub.Publish(MessageNames.StatusAvailable, "Loading Pictures . . .");
                var pictures = await StoreProvider.RetrievePictureHeadersAsync();

                foreach (var p in pictures)
                {
                    PictureHeaders.Add(p);
                }

                MessageHub.Publish(MessageNames.StatusAvailable, "Ready");
            }
            catch (Exception ex)
            {
                // We send a status message to the hub but it should really be an Error message of its own type
                MessageHub.Publish(MessageNames.StatusAvailable, $"Error: {ex.Message}");
            }
            finally
            {
                IsUserInterfaceEnabled = true;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Called when [take picture command].
        /// </summary>
        /// <param name="payload">The payload.</param>
        /// <returns></returns>
        public async Task OnTakePictureCommand(object payload)
        {
            try
            {
                IsUserInterfaceEnabled = false;
                MessageHub.Publish(MessageNames.StatusAvailable, $"Taking picture from camera . . .");

                var pictureBytes = await Device.TakePicture();

                var pictureLocation = await Device.ReadLocation();

                var picture = new PictureViewModel
                {
                    ImageBytes = pictureBytes
                };

                picture.Header.DateTakenUtc       = DateTime.UtcNow;
                picture.Header.Location.Latitude  = pictureLocation.Latitude;
                picture.Header.Location.Longitude = pictureLocation.Longitude;
                picture.Header.Name      = $"Taken at {DateTime.UtcNow.ToShortTimeString()}";
                picture.Header.PictureId = Guid.NewGuid();

                await StoreProvider.AddOrUpdatePictureAsync(picture);

                PictureHeaders.Add(picture.Header);
                SelectedPictureHeader = picture.Header;

                MessageHub.Publish(MessageNames.StatusAvailable, "Ready");
            }
            catch (Exception ex)
            {
                // We send a status message to the hub but it should really be an Error message of its own type
                MessageHub.Publish(MessageNames.StatusAvailable, $"Error: {ex.Message}");
            }
            finally
            {
                IsUserInterfaceEnabled = true;
            }
        }