private void SaveButtonClick(object sender, EventArgs e)
        {
            var newSaveCounter = new SaveCounterQuery().Get() + 1;
            var fileName = "PixImg_" + newSaveCounter + ".jpg";

            var stream = new MemoryStream();
            _writableBitmap.SaveJpeg(stream, _writableBitmap.PixelWidth, _writableBitmap.PixelHeight, 0, 100);

            var mediaLibrary = new MediaLibrary();
            mediaLibrary.SavePicture(fileName, stream.ToArray());

            new ShowSavedMessageCommand().Show();
        }
        private void OnCameraCaptureImageAvailable(object sender, ContentReadyEventArgs e)
        {
            var newSaveCounter = new SaveCounterQuery().Get() + 1;
            if (newSaveCounter > 10 && _applicationMode == ApplicationMode.Trial)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    var messageBoxResult = MessageBox.Show("The trial version of this app is limited to taking 10 images. Thanks for trying out 8cam! Press OK to buy the full version, or Cancel to continue with ads.", "Trial", MessageBoxButton.OKCancel);
                    if (messageBoxResult == MessageBoxResult.OK)
                    {
                        new MarketplaceDetailTask().Show();
                    }
                    else
                    {
                        SavePicture(newSaveCounter, e.ImageStream);
                    }
                });

                return;
            }

            SavePicture(newSaveCounter, e.ImageStream);
        }
        private void OnCameraCaptureImageAvailable(object sender, ContentReadyEventArgs e)
        {
            var newSaveCounter = new SaveCounterQuery().Get() + 1;
            if (newSaveCounter > 10 && _isTrial)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                                                              {
                                                                  var messageBoxResult = MessageBox.Show("The trial version of this app is limited to taking 10 images. Thanks for trying out 8cam! Press OK to buy the full version.", "Trial", MessageBoxButton.OKCancel);
                                                                  if (messageBoxResult == MessageBoxResult.OK)
                                                                  {
                                                                      new MarketplaceDetailTask().Show();
                                                                  }
                                                              });

                return;
            }

            var fileName = "PixImg_" + newSaveCounter + ".jpg";
            try
            {
                var saveOriginalToCameraRoll = new SaveOriginalToCameraRollQuery().Get();
                var stream = new MemoryStream();
                _wb.SaveJpeg(stream, _wb.PixelWidth, _wb.PixelHeight, 0, 100);

                Deployment.Current.Dispatcher.BeginInvoke(() =>
                                                              {
                                                                  var rotatedStream = RotateStream(stream);

                                                                   if (saveOriginalToCameraRoll)
                                                                  {
                                                                      _mediaLibrary.SavePictureToCameraRoll(fileName, e.ImageStream);
                                                                  }

                                                                  _mediaLibrary.SavePicture(fileName, rotatedStream.ToArray());

                                                                  new ShowSavedMessageCommand().Show();
                                                              });

            }
            catch (Exception exception)
            {
                // TODO: do something with exception?
            }

            new SaveCounterCommand().Set(newSaveCounter);
        }
        private void SaveButtonClick(object sender, EventArgs e)
        {
            if (_writableBitmap == null)
            {
                MessageBox.Show("Please select an image from your library.", "No image selected", MessageBoxButton.OK);
                return;
            }

            var newSaveCounter = new SaveCounterQuery().Get() + 1;
            var fileName = "PixImg_" + newSaveCounter + ".jpg";

            var stream = new MemoryStream();
            _writableBitmap.SaveJpeg(stream, _writableBitmap.PixelWidth, _writableBitmap.PixelHeight, 0, 100);

            var mediaLibrary = new MediaLibrary();
            mediaLibrary.SavePicture(fileName, stream.ToArray());

            new ShowSavedMessageCommand().Show();
        }