Esempio n. 1
0
        private void SyncChange(SyncAction action)
        {
            if (suspendCount > 0 || Other == null)
            {
                return;
            }

            using (Other.SuspendLogic())
                action(Other);
        }
        void IBlogPostEditor.OnBlogChanged(Blog newBlog)
        {
            // preserve dirty state
            using (controller.SuspendLogic())
            {
                _blogId = newBlog.Id;
                controller.OnBlogChanged(newBlog);

                // Clear out author whenever blog changes
                SetAuthor(PostIdAndNameField.Empty);

                // Comment policy hackery
                BlogCommentPolicy?commentPolicy = null;
                if (comboComments.SelectedIndex >= 0)
                {
                    commentPolicy = ((CommentComboItem)comboComments.SelectedItem).Value;
                }
                comboComments.Items.Remove(new CommentComboItem(BlogCommentPolicy.None));
                if (!newBlog.ClientOptions.CommentPolicyAsBoolean)
                {
                    comboComments.Items.Insert(1, new CommentComboItem(BlogCommentPolicy.None));
                }
                if (commentPolicy != null)
                {
                    comboComments.SelectedItem = new CommentComboItem(commentPolicy.Value);
                }
                if (comboComments.SelectedIndex == -1) // In no case should there be no selection at all
                {
                    comboComments.SelectedIndex = 0;
                }

                labelTags.Text = newBlog.ClientOptions.KeywordsAsTags
                                     ? Res.Get(StringId.PropertiesTags)
                                     : Res.Get(StringId.PropertiesKeywords);
            }
        }