protected override void OnBackKeyPress(CancelEventArgs e)
        {
            if (App.WaitIndicationService.Waiting)
            {
                App.WaitIndicationService.HideIndicator();
                ApplicationBar.IsVisible = true;
                e.Cancel = true;

                if (null != currentXmlRpcConnection)
                {
                    currentXmlRpcConnection.IsCancelled = true;
                    currentXmlRpcConnection             = null;
                }

                if (null != _mediaItemRPC)
                {
                    _mediaItemRPC.IsCancelled = true;
                    _mediaItemRPC             = null;
                }

                this.emptyImagesUploadingQueue();
            }
            else
            {
                if (_messageBoxIsShown)
                {
                    return;
                }
                _messageBoxIsShown = true;
                string           prompt = string.Format(_localizedStrings.Prompts.SureCancel, _localizedStrings.Prompts.Post);
                MessageBoxResult result = MessageBox.Show(prompt, _localizedStrings.Prompts.CancelEditing, MessageBoxButton.OKCancel);
                _messageBoxIsShown = false;
                if (result == MessageBoxResult.OK)
                {
                    if (_mediaItemRPC != null)
                    {
                        _mediaItemRPC.Completed  -= OnGetMediaItemRPCCompleted;
                        _mediaItemRPC.IsCancelled = true;
                    }

                    this.emptyImagesUploadingQueue();
                    cleanupPostMedia();
                    base.OnBackKeyPress(e);
                }
                else
                {
                    e.Cancel = true;
                }
            }
        }
        protected override void OnBackKeyPress(CancelEventArgs e)
        {
            if (App.WaitIndicationService.Waiting)
            {
                App.WaitIndicationService.HideIndicator();
                ApplicationBar.IsVisible = true;
                e.Cancel = true;

                if (null != currentXmlRpcConnection)
                {
                    currentXmlRpcConnection.IsCancelled = true;
                    currentXmlRpcConnection = null;
                }

                this.emptyImagesUploadingQueue();
            }
            else
            {
                if (_messageBoxIsShown)
                    return;
                _messageBoxIsShown = true;
                string prompt = string.Format(_localizedStrings.Prompts.SureCancel, _localizedStrings.Prompts.Page);
                MessageBoxResult result = MessageBox.Show(prompt, _localizedStrings.Prompts.CancelEditing, MessageBoxButton.OKCancel);
                _messageBoxIsShown = false;
                if (result == MessageBoxResult.OK)
                {
                    this.emptyImagesUploadingQueue();
                    cleanupPostMedia();
                    base.OnBackKeyPress(e);
                }
                else
                {
                    e.Cancel = true;
                }
            }
        }
        private void SavePost()
        {
            Post post = App.MasterViewModel.CurrentPost;
            Blog blog = App.MasterViewModel.CurrentBlog;

            if (post.HasMedia() && !post.IsLocalDraft())
            {
                StringBuilder prependBuilder = new StringBuilder();
                StringBuilder appendBuilder = new StringBuilder();
                 List<string> mediaIds = new List<string>();
                bool galleryEnabled = uploadImagesAsGalleryCheckbox.Visibility == Visibility.Visible &&
                                      uploadImagesAsGalleryCheckbox.IsChecked.GetValueOrDefault();
                post.GenerateImageMarkup(blog.PlaceImageAboveText, galleryEnabled);
            }

            //make sure the post has the latest UI data--the Save button is a ToolbarButton
            //which doesn't force focus to change
            post.Title = titleTextBox.Text;
            if (post.IsNew)
            {
                if (!post.IsLocalDraft())
                {
                    NewPostRPC rpc = new NewPostRPC(App.MasterViewModel.CurrentBlog, post);
                    rpc.PostType = ePostType.page;
                    rpc.Completed += OnNewPostRPCCompleted;
                    rpc.ExecuteAsync();
                    currentXmlRpcConnection = rpc;
                }
                else
                {
                    // Create or update a local draft
                    if (App.MasterViewModel.CurrentPageListItem != null)
                    {
                        if (App.MasterViewModel.CurrentPageListItem.DraftIndex > -1)
                            App.MasterViewModel.CurrentBlog.LocalPageDrafts[App.MasterViewModel.CurrentPageListItem.DraftIndex] = post;
                    }
                    else
                    {
                        blog.LocalPageDrafts.Add(post);
                    }
                    // Exit post editor
                    if (NavigationService.CanGoBack)
                        NavigationService.GoBack();
                    else
                        throw new ApplicationShouldEndException();
                }
            }
            else
            {
                EditPostRPC rpc = new EditPostRPC(App.MasterViewModel.CurrentBlog, post);
                if (post.PostStatus == "publish")
                    rpc.Publish = true;
                else
                    rpc.Publish = false;
                rpc.PostType = ePostType.page;
                rpc.Completed += OnEditPostRPCCompleted;

                currentXmlRpcConnection = rpc;
                rpc.ExecuteAsync();
            }
            this.Focus();
            ApplicationBar.IsVisible = false;
            App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.UploadingChanges);
        }
        private void SavePost()
        {
            Post post = App.MasterViewModel.CurrentPost;
            Blog blog = App.MasterViewModel.CurrentBlog;

            if (post.HasMedia() && !post.IsLocalDraft())
            {
                StringBuilder prependBuilder = new StringBuilder();
                StringBuilder appendBuilder  = new StringBuilder();
                List <string> mediaIds       = new List <string>();
                bool          galleryEnabled = uploadImagesAsGalleryCheckbox.Visibility == Visibility.Visible &&
                                               uploadImagesAsGalleryCheckbox.IsChecked.GetValueOrDefault();
                post.GenerateImageMarkup(blog.PlaceImageAboveText, galleryEnabled);
            }

            //make sure the post has the latest UI data--the Save button is a ToolbarButton
            //which doesn't force focus to change
            post.Title = titleTextBox.Text;
            if (post.IsNew)
            {
                if (!post.IsLocalDraft())
                {
                    NewPostRPC rpc = new NewPostRPC(App.MasterViewModel.CurrentBlog, post);
                    rpc.PostType   = ePostType.page;
                    rpc.Completed += OnNewPostRPCCompleted;
                    rpc.ExecuteAsync();
                    currentXmlRpcConnection = rpc;
                }
                else
                {
                    // Create or update a local draft
                    if (App.MasterViewModel.CurrentPageListItem != null)
                    {
                        if (App.MasterViewModel.CurrentPageListItem.DraftIndex > -1)
                        {
                            App.MasterViewModel.CurrentBlog.LocalPageDrafts[App.MasterViewModel.CurrentPageListItem.DraftIndex] = post;
                        }
                    }
                    else
                    {
                        blog.LocalPageDrafts.Add(post);
                    }
                    // Exit post editor
                    if (NavigationService.CanGoBack)
                    {
                        NavigationService.GoBack();
                    }
                    else
                    {
                        throw new ApplicationShouldEndException();
                    }
                }
            }
            else
            {
                EditPostRPC rpc = new EditPostRPC(App.MasterViewModel.CurrentBlog, post);
                if (post.PostStatus == "publish")
                {
                    rpc.Publish = true;
                }
                else
                {
                    rpc.Publish = false;
                }
                rpc.PostType   = ePostType.page;
                rpc.Completed += OnEditPostRPCCompleted;

                currentXmlRpcConnection = rpc;
                rpc.ExecuteAsync();
            }
            this.Focus();
            ApplicationBar.IsVisible = false;
            App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.UploadingChanges);
        }
        private void SavePost()
        {
            //Post post = DataContext as Post;
            //changed to CurrentPost so categories would save
            Post post = App.MasterViewModel.CurrentPost;
            Blog blog = App.MasterViewModel.CurrentBlog;

            if (post.HasMedia() && !post.IsLocalDraft())
            {
                bool galleryEnabled = uploadImagesAsGalleryCheckbox.Visibility == Visibility.Visible &&
                      uploadImagesAsGalleryCheckbox.IsChecked.GetValueOrDefault();
                post.GenerateImageMarkup(blog.PlaceImageAboveText, galleryEnabled);
            }

            //make sure the post has the latest UI data--the Save button is a ToolbarButton
            //which doesn't force focus to change
            post.Title = titleTextBox.Text;
            post.MtKeyWords = tagsTextBox.Text;

            if (post.IsNew)
            {
                if (!post.IsLocalDraft())
                {
                    // Anything but local draft status gets uploaded
                    UserSettings settings = new UserSettings();
                    if (settings.UseTaglineForNewPosts)
                    {
                        post.AddTagline(settings.Tagline);
                    }
                    NewPostRPC rpc = new NewPostRPC(App.MasterViewModel.CurrentBlog, post);
                    rpc.PostType = ePostType.post;
                    rpc.Completed += OnNewPostRPCCompleted;
                    rpc.ExecuteAsync();

                    currentXmlRpcConnection = rpc;
                    this.Focus();
                    ApplicationBar.IsVisible = false;
                    App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.UploadingChanges);

                } else {
                    // Create or update a local draft
                    if (App.MasterViewModel.CurrentPostListItem != null)
                    {
                        if (App.MasterViewModel.CurrentPostListItem.DraftIndex > -1)
                            App.MasterViewModel.CurrentBlog.LocalPostDrafts[App.MasterViewModel.CurrentPostListItem.DraftIndex] = post;
                    }
                    else
                    {
                        blog.LocalPostDrafts.Add(post);
                    }
                    // Exit post editor if the app was not lauched from the sharing feature.
                    if(NavigationService.CanGoBack)
                        NavigationService.GoBack();
                    else
                        throw new ApplicationShouldEndException();
                }
            }
            else
            {
                EditPostRPC rpc = new EditPostRPC(App.MasterViewModel.CurrentBlog, post);
                rpc.Completed += OnEditPostRPCCompleted;
                rpc.ExecuteAsync();

                currentXmlRpcConnection = rpc;
                this.Focus();
                ApplicationBar.IsVisible = false;
                App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.UploadingChanges);
            }
        }
        private void SavePost()
        {
            //Post post = DataContext as Post;
            //changed to CurrentPost so categories would save
            Post post = App.MasterViewModel.CurrentPost;
            Blog blog = App.MasterViewModel.CurrentBlog;

            if (post.HasMedia() && !post.IsLocalDraft())
            {
                bool galleryEnabled = uploadImagesAsGalleryCheckbox.Visibility == Visibility.Visible &&
                                      uploadImagesAsGalleryCheckbox.IsChecked.GetValueOrDefault();
                post.GenerateImageMarkup(blog.PlaceImageAboveText, galleryEnabled);
            }

            //make sure the post has the latest UI data--the Save button is a ToolbarButton
            //which doesn't force focus to change
            post.Title      = titleTextBox.Text;
            post.MtKeyWords = tagsTextBox.Text;

            if (post.IsNew)
            {
                if (!post.IsLocalDraft())
                {
                    // Anything but local draft status gets uploaded
                    UserSettings settings = new UserSettings();
                    if (settings.UseTaglineForNewPosts)
                    {
                        post.AddTagline(settings.Tagline);
                    }
                    NewPostRPC rpc = new NewPostRPC(App.MasterViewModel.CurrentBlog, post);
                    rpc.PostType   = ePostType.post;
                    rpc.Completed += OnNewPostRPCCompleted;
                    rpc.ExecuteAsync();

                    currentXmlRpcConnection = rpc;
                    this.Focus();
                    ApplicationBar.IsVisible = false;
                    App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.UploadingChanges);
                }
                else
                {
                    // Create or update a local draft
                    if (App.MasterViewModel.CurrentPostListItem != null)
                    {
                        if (App.MasterViewModel.CurrentPostListItem.DraftIndex > -1)
                        {
                            App.MasterViewModel.CurrentBlog.LocalPostDrafts[App.MasterViewModel.CurrentPostListItem.DraftIndex] = post;
                        }
                    }
                    else
                    {
                        blog.LocalPostDrafts.Add(post);
                    }
                    // Exit post editor if the app was not lauched from the sharing feature.
                    if (NavigationService.CanGoBack)
                    {
                        NavigationService.GoBack();
                    }
                    else
                    {
                        throw new ApplicationShouldEndException();
                    }
                }
            }
            else
            {
                EditPostRPC rpc = new EditPostRPC(App.MasterViewModel.CurrentBlog, post);
                rpc.Completed += OnEditPostRPCCompleted;
                rpc.ExecuteAsync();

                currentXmlRpcConnection = rpc;
                this.Focus();
                ApplicationBar.IsVisible = false;
                App.WaitIndicationService.ShowIndicator(_localizedStrings.Messages.UploadingChanges);
            }
        }