protected override Control CreateMainControl() { // create post editor main control as appropriate if (_initialEditingContext != null) { _postEditorMainControl = new PostEditorMainControl(this, _initialEditingContext); } else { throw new ArgumentException("PostEditorForm was not properly initialized with either a blog post or blog this item"); } InitializeCommands(); // connect our provider command manager to the BlogPostEditingManager _providerButtonManager.Initialize(this, _postEditorMainControl.BlogPostEditingManager); // update status bar then subscribe to weblog changed events for future updates //UpdateStatusBarBlogInfo(); //_postEditorMainControl.BlogPostEditingManager.BlogChanged +=new EventHandler(BlogPostEditingManager_BlogChanged); //_postEditorMainControl.BlogPostEditingManager.BlogSettingsChanged +=new WeblogSettingsChangedHandler(BlogPostEditingManager_BlogSettingsChanged); // return the post editor main control return(_postEditorMainControl); }
public override void Save() { string destinationRecentPosts = Path.Combine(_postEditorPreferences.WeblogPostsFolder + "\\Recent Posts"); string destinationDrafts = Path.Combine(_postEditorPreferences.WeblogPostsFolder + "\\Drafts"); Directory.CreateDirectory(destinationRecentPosts); Directory.CreateDirectory(destinationDrafts); _postEditorPreferences.SaveWebLogPostFolder(); if (string.Compare(_originalFolder, _postEditorPreferences.WeblogPostsFolder, true, CultureInfo.CurrentUICulture) != 0) { string message = "You have updated the default location for your blog posts, would you like to move any existing posts?"; string caption = "Move existing posts"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; result = MessageBox.Show(message, caption, buttons); if (result == DialogResult.Yes) { MovePosts(Path.Combine(_originalFolder + @"\\Recent Posts\\"), destinationRecentPosts); MovePosts(Path.Combine(_originalFolder + @"\\Drafts\\"), destinationDrafts); PostEditorForm frm = Application.OpenForms?[0] as PostEditorForm; if (frm != null) { PostEditorMainControl ctrl = frm.Controls?[0] as PostEditorMainControl; if (ctrl != null) { ctrl.FirePostListChangedEvent(); } } } } if (_postEditorPreferences.IsModified()) { _postEditorPreferences.Save(); } if (_wordCountPreferences.IsModified()) { _wordCountPreferences.Save(); } _originalFolder = _postEditorPreferences.WeblogPostsFolder; }