Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

RSS Feed Aggregator and Blogging Smart Client

, 16 Aug 2005 CPOL
RSS Feed aggregator and blogging Smart Client which uses Enterprise Library, Updater Application Block, lots of XML hacks and desktop tricks. A comprehensive guide to real life hurdles of Smart Client development.
rssfeeder_src.zip
RSSFeeder
RSSBlogAPI
RSSBlogAPI.csproj.user
Web References
CommunityServer
blogservice.disco
blogservice.wsdl
Reference.map
DotText
Reference.map
simpleblogservice.disco
simpleblogservice.wsdl
RSSCommon
Helper
PropertyEditor
RSSCommon.csproj.user
RSSFeeder
Controls
docs
dropshadow.png
My Pic 7.jpg
WIndows98.jpg
Helpers
Resources
E-mail.ico
rss.ico
RSSFeeder.mdb
RSSFeeder.csproj.user
RSSStarter.exe
RSSFeederResources
PublicQueue.ico
RSSFeeder.mdb
RSSFeederResources.csproj.user
RSSFeederSetup
Messages.ico
RSSFeederSetup.vdproj
Test
RSSStarter
DummyForm.frm
DummyForm.frx
MainModule.bas
RSSStarter.exe
RSSStarter.vbp
RSSStarter.vbw
RSSTests
App.ico
RSSTests.csproj.user
Thirdparty
AxInterop.DHTMLEDLib.dll
AxInterop.SHDocVw.dll
Eyefinder.dll
GotDotNet.Exslt.dll
HttpDownloader.dll
Interop.DHTMLEDLib.dll
Interop.SHDocVw.dll
Interop.WindowsInstaller.dll
Microsoft.ApplicationBlocks.Updater.ActivationProcessors.dll
Microsoft.ApplicationBlocks.Updater.dll
Microsoft.ApplicationBlocks.Updater.Downloaders.dll
Microsoft.Practices.EnterpriseLibrary.Caching.dll
Microsoft.Practices.EnterpriseLibrary.Common.dll
Microsoft.Practices.EnterpriseLibrary.Configuration.dll
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll
Microsoft.Practices.EnterpriseLibrary.Logging.dll
Microsoft.Practices.EnterpriseLibrary.Security.Cache.CachingStore.dll
Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.dll
Microsoft.Practices.EnterpriseLibrary.Security.dll
NotifyIconBalloon.dll
SandBar.dll
SandDock.dll
SgmlReaderDll.dll
using System;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Reflection;

namespace RSSBlogAPI
{
	/// <summary>
	/// Summary description for PostEditorControl.
	/// </summary>
	public class PostEditorControl : System.Windows.Forms.UserControl
	{
		#region Designer

		private TD.SandBar.ToolBar DesignSandBar;
		private TD.SandBar.ButtonItem CutItem;
		private TD.SandBar.ButtonItem CopyItem;
		private TD.SandBar.ButtonItem PasteItem;
		private TD.SandBar.ButtonItem BoldItem;
		private TD.SandBar.ButtonItem ItalicItem;
		private TD.SandBar.ButtonItem UnderlineItem;
		private TD.SandBar.DropDownMenuItem FontDropDown;
		private TD.SandBar.MenuButtonItem FontItem0;
		private TD.SandBar.MenuButtonItem FontItem1;
		private TD.SandBar.MenuButtonItem FontItem2;
		private TD.SandBar.MenuButtonItem FontItem3;
		private TD.SandBar.MenuButtonItem FontItem4;
		private TD.SandBar.MenuButtonItem FontItem5;
		private TD.SandBar.MenuButtonItem FontItem6;
		private TD.SandBar.DropDownMenuItem SizeDropDown;
		private TD.SandBar.MenuButtonItem SizeItem1;
		private TD.SandBar.MenuButtonItem SizeItem2;
		private TD.SandBar.MenuButtonItem SizeItem3;
		private TD.SandBar.MenuButtonItem SizeItem4;
		private TD.SandBar.MenuButtonItem SizeItem5;
		private TD.SandBar.MenuButtonItem SizeItem6;
		private TD.SandBar.ButtonItem ColorItem;
		private TD.SandBar.ButtonItem RemoveFormatItem;
		private TD.SandBar.ButtonItem LeftItem;
		private TD.SandBar.ButtonItem CenterItem;
		private TD.SandBar.ButtonItem FullItem;
		private TD.SandBar.ButtonItem RightItem;
		private TD.SandBar.ButtonItem IndentItem;
		private TD.SandBar.ButtonItem OutdentItem;
		private TD.SandBar.ButtonItem UnorderListItem;
		private TD.SandBar.ButtonItem OrderListItem;
		private TD.SandBar.ButtonItem UndoItem;
		private TD.SandBar.ButtonItem RedoItem;
		private TD.SandBar.ButtonItem LinkItem;
		private TD.SandBar.ButtonItem UnlinkItem;
		private TD.SandBar.ButtonItem InsertImageItem;
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.Panel panel2;
		private System.Windows.Forms.CheckBox plainTextCheckBox;
		private System.Windows.Forms.TextBox titleTextBox;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Panel leftPanel;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Button refreshCategoryButton;
		private System.Windows.Forms.CheckedListBox categoryListBox;
		private System.Windows.Forms.Splitter splitter1;
		private System.Windows.Forms.Panel editorPanel;
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private TD.SandBar.ButtonItem sendButton;
		private TD.SandBar.ButtonItem saveButton;
		private System.Windows.Forms.Label statusLabel;
		private System.Windows.Forms.Panel errorPanel;
		private System.Windows.Forms.Button closeErrorPanelButton;
		private System.Windows.Forms.TextBox errorTextBox;

		private HtmlEditor _Editor;

		public PostEditorControl()
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			// TODO: Add any initialization after the InitializeComponent call
			this.CreateEditor();
		}

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Component Designer generated code
		/// <summary> 
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(PostEditorControl));
			this.DesignSandBar = new TD.SandBar.ToolBar();
			this.sendButton = new TD.SandBar.ButtonItem();
			this.saveButton = new TD.SandBar.ButtonItem();
			this.CutItem = new TD.SandBar.ButtonItem();
			this.CopyItem = new TD.SandBar.ButtonItem();
			this.PasteItem = new TD.SandBar.ButtonItem();
			this.BoldItem = new TD.SandBar.ButtonItem();
			this.ItalicItem = new TD.SandBar.ButtonItem();
			this.UnderlineItem = new TD.SandBar.ButtonItem();
			this.FontDropDown = new TD.SandBar.DropDownMenuItem();
			this.FontItem0 = new TD.SandBar.MenuButtonItem();
			this.FontItem1 = new TD.SandBar.MenuButtonItem();
			this.FontItem2 = new TD.SandBar.MenuButtonItem();
			this.FontItem3 = new TD.SandBar.MenuButtonItem();
			this.FontItem4 = new TD.SandBar.MenuButtonItem();
			this.FontItem5 = new TD.SandBar.MenuButtonItem();
			this.FontItem6 = new TD.SandBar.MenuButtonItem();
			this.SizeDropDown = new TD.SandBar.DropDownMenuItem();
			this.SizeItem1 = new TD.SandBar.MenuButtonItem();
			this.SizeItem2 = new TD.SandBar.MenuButtonItem();
			this.SizeItem3 = new TD.SandBar.MenuButtonItem();
			this.SizeItem4 = new TD.SandBar.MenuButtonItem();
			this.SizeItem5 = new TD.SandBar.MenuButtonItem();
			this.SizeItem6 = new TD.SandBar.MenuButtonItem();
			this.ColorItem = new TD.SandBar.ButtonItem();
			this.RemoveFormatItem = new TD.SandBar.ButtonItem();
			this.LeftItem = new TD.SandBar.ButtonItem();
			this.CenterItem = new TD.SandBar.ButtonItem();
			this.FullItem = new TD.SandBar.ButtonItem();
			this.RightItem = new TD.SandBar.ButtonItem();
			this.IndentItem = new TD.SandBar.ButtonItem();
			this.OutdentItem = new TD.SandBar.ButtonItem();
			this.UnorderListItem = new TD.SandBar.ButtonItem();
			this.OrderListItem = new TD.SandBar.ButtonItem();
			this.UndoItem = new TD.SandBar.ButtonItem();
			this.RedoItem = new TD.SandBar.ButtonItem();
			this.LinkItem = new TD.SandBar.ButtonItem();
			this.UnlinkItem = new TD.SandBar.ButtonItem();
			this.InsertImageItem = new TD.SandBar.ButtonItem();
			this.panel1 = new System.Windows.Forms.Panel();
			this.editorPanel = new System.Windows.Forms.Panel();
			this.splitter1 = new System.Windows.Forms.Splitter();
			this.leftPanel = new System.Windows.Forms.Panel();
			this.label2 = new System.Windows.Forms.Label();
			this.refreshCategoryButton = new System.Windows.Forms.Button();
			this.categoryListBox = new System.Windows.Forms.CheckedListBox();
			this.panel2 = new System.Windows.Forms.Panel();
			this.statusLabel = new System.Windows.Forms.Label();
			this.plainTextCheckBox = new System.Windows.Forms.CheckBox();
			this.titleTextBox = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.errorPanel = new System.Windows.Forms.Panel();
			this.errorTextBox = new System.Windows.Forms.TextBox();
			this.closeErrorPanelButton = new System.Windows.Forms.Button();
			this.panel1.SuspendLayout();
			this.leftPanel.SuspendLayout();
			this.panel2.SuspendLayout();
			this.errorPanel.SuspendLayout();
			this.SuspendLayout();
			// 
			// DesignSandBar
			// 
			this.DesignSandBar.Buttons.AddRange(new TD.SandBar.ToolbarItemBase[] {
																					 this.sendButton,
																					 this.saveButton,
																					 this.CutItem,
																					 this.CopyItem,
																					 this.PasteItem,
																					 this.BoldItem,
																					 this.ItalicItem,
																					 this.UnderlineItem,
																					 this.FontDropDown,
																					 this.SizeDropDown,
																					 this.ColorItem,
																					 this.RemoveFormatItem,
																					 this.LeftItem,
																					 this.CenterItem,
																					 this.FullItem,
																					 this.RightItem,
																					 this.IndentItem,
																					 this.OutdentItem,
																					 this.UnorderListItem,
																					 this.OrderListItem,
																					 this.UndoItem,
																					 this.RedoItem,
																					 this.LinkItem,
																					 this.UnlinkItem,
																					 this.InsertImageItem});
			this.DesignSandBar.Closable = false;
			this.DesignSandBar.DockLine = 1;
			this.DesignSandBar.Guid = new System.Guid("1fd972d3-e337-4d0f-ab9e-b228d26929dd");
			this.DesignSandBar.Location = new System.Drawing.Point(0, 0);
			this.DesignSandBar.Name = "DesignSandBar";
			this.DesignSandBar.Size = new System.Drawing.Size(624, 26);
			this.DesignSandBar.TabIndex = 2;
			this.DesignSandBar.Text = "";
			this.DesignSandBar.ButtonClick += new TD.SandBar.ToolBar.ButtonClickEventHandler(this.DesignSandBar_ButtonClick);
			// 
			// sendButton
			// 
			this.sendButton.Icon = ((System.Drawing.Icon)(resources.GetObject("sendButton.Icon")));
			this.sendButton.Tag = "$Send";
			this.sendButton.Text = "Send";
			// 
			// saveButton
			// 
			this.saveButton.Icon = ((System.Drawing.Icon)(resources.GetObject("saveButton.Icon")));
			this.saveButton.Tag = "$Save";
			this.saveButton.Text = "Save";
			// 
			// CutItem
			// 
			this.CutItem.BeginGroup = true;
			this.CutItem.Image = ((System.Drawing.Image)(resources.GetObject("CutItem.Image")));
			this.CutItem.ImageIndex = 8;
			this.CutItem.Tag = "Cut";
			// 
			// CopyItem
			// 
			this.CopyItem.Image = ((System.Drawing.Image)(resources.GetObject("CopyItem.Image")));
			this.CopyItem.ImageIndex = 6;
			this.CopyItem.Tag = "Copy";
			// 
			// PasteItem
			// 
			this.PasteItem.Image = ((System.Drawing.Image)(resources.GetObject("PasteItem.Image")));
			this.PasteItem.ImageIndex = 4;
			this.PasteItem.Tag = "Paste";
			// 
			// BoldItem
			// 
			this.BoldItem.BeginGroup = true;
			this.BoldItem.Image = ((System.Drawing.Image)(resources.GetObject("BoldItem.Image")));
			this.BoldItem.ImageIndex = 11;
			this.BoldItem.Tag = "Bold";
			// 
			// ItalicItem
			// 
			this.ItalicItem.Image = ((System.Drawing.Image)(resources.GetObject("ItalicItem.Image")));
			this.ItalicItem.ImageIndex = 13;
			this.ItalicItem.Tag = "Italic";
			// 
			// UnderlineItem
			// 
			this.UnderlineItem.Image = ((System.Drawing.Image)(resources.GetObject("UnderlineItem.Image")));
			this.UnderlineItem.ImageIndex = 12;
			this.UnderlineItem.Tag = "Underline";
			// 
			// FontDropDown
			// 
			this.FontDropDown.Image = ((System.Drawing.Image)(resources.GetObject("FontDropDown.Image")));
			this.FontDropDown.ImageIndex = 7;
			this.FontDropDown.MenuItems.AddRange(new TD.SandBar.MenuButtonItem[] {
																					 this.FontItem0,
																					 this.FontItem1,
																					 this.FontItem2,
																					 this.FontItem3,
																					 this.FontItem4,
																					 this.FontItem5,
																					 this.FontItem6});
			this.FontDropDown.Tag = "";
			this.FontDropDown.Text = "";
			// 
			// FontItem0
			// 
			this.FontItem0.Text = "Arial";
			this.FontItem0.Activate += new System.EventHandler(this.SetFont);
			// 
			// FontItem1
			// 
			this.FontItem1.Text = "Courier New";
			this.FontItem1.Activate += new System.EventHandler(this.SetFont);
			// 
			// FontItem2
			// 
			this.FontItem2.Text = "Garamond";
			this.FontItem2.Activate += new System.EventHandler(this.SetFont);
			// 
			// FontItem3
			// 
			this.FontItem3.Text = "Georgia";
			this.FontItem3.Activate += new System.EventHandler(this.SetFont);
			// 
			// FontItem4
			// 
			this.FontItem4.Text = "Tahoma";
			this.FontItem4.Activate += new System.EventHandler(this.SetFont);
			// 
			// FontItem5
			// 
			this.FontItem5.Text = "Times New Roman";
			this.FontItem5.Activate += new System.EventHandler(this.SetFont);
			// 
			// FontItem6
			// 
			this.FontItem6.Text = "Verdana";
			this.FontItem6.Activate += new System.EventHandler(this.SetFont);
			// 
			// SizeDropDown
			// 
			this.SizeDropDown.Image = ((System.Drawing.Image)(resources.GetObject("SizeDropDown.Image")));
			this.SizeDropDown.ImageIndex = 18;
			this.SizeDropDown.MenuItems.AddRange(new TD.SandBar.MenuButtonItem[] {
																					 this.SizeItem1,
																					 this.SizeItem2,
																					 this.SizeItem3,
																					 this.SizeItem4,
																					 this.SizeItem5,
																					 this.SizeItem6});
			this.SizeDropDown.Tag = "";
			this.SizeDropDown.Text = "";
			// 
			// SizeItem1
			// 
			this.SizeItem1.Text = "1";
			this.SizeItem1.Activate += new System.EventHandler(this.SetSize);
			// 
			// SizeItem2
			// 
			this.SizeItem2.Text = "2";
			this.SizeItem2.Activate += new System.EventHandler(this.SetSize);
			// 
			// SizeItem3
			// 
			this.SizeItem3.Text = "3";
			this.SizeItem3.Activate += new System.EventHandler(this.SetSize);
			// 
			// SizeItem4
			// 
			this.SizeItem4.Text = "4";
			this.SizeItem4.Activate += new System.EventHandler(this.SetSize);
			// 
			// SizeItem5
			// 
			this.SizeItem5.Text = "5";
			this.SizeItem5.Activate += new System.EventHandler(this.SetSize);
			// 
			// SizeItem6
			// 
			this.SizeItem6.Text = "6";
			this.SizeItem6.Activate += new System.EventHandler(this.SetSize);
			// 
			// ColorItem
			// 
			this.ColorItem.Image = ((System.Drawing.Image)(resources.GetObject("ColorItem.Image")));
			this.ColorItem.ImageIndex = 10;
			this.ColorItem.Tag = "SetColor";
			// 
			// RemoveFormatItem
			// 
			this.RemoveFormatItem.Image = ((System.Drawing.Image)(resources.GetObject("RemoveFormatItem.Image")));
			this.RemoveFormatItem.Tag = "RemoveFormat";
			// 
			// LeftItem
			// 
			this.LeftItem.BeginGroup = true;
			this.LeftItem.Image = ((System.Drawing.Image)(resources.GetObject("LeftItem.Image")));
			this.LeftItem.ImageIndex = 5;
			this.LeftItem.Tag = "JustifyLeft";
			// 
			// CenterItem
			// 
			this.CenterItem.Image = ((System.Drawing.Image)(resources.GetObject("CenterItem.Image")));
			this.CenterItem.Tag = "JustifyCenter";
			// 
			// FullItem
			// 
			this.FullItem.Image = ((System.Drawing.Image)(resources.GetObject("FullItem.Image")));
			this.FullItem.Tag = "JustifyFull";
			// 
			// RightItem
			// 
			this.RightItem.Image = ((System.Drawing.Image)(resources.GetObject("RightItem.Image")));
			this.RightItem.ImageIndex = 6;
			this.RightItem.Tag = "JustifyRight";
			// 
			// IndentItem
			// 
			this.IndentItem.Image = ((System.Drawing.Image)(resources.GetObject("IndentItem.Image")));
			this.IndentItem.Tag = "Indent";
			// 
			// OutdentItem
			// 
			this.OutdentItem.Image = ((System.Drawing.Image)(resources.GetObject("OutdentItem.Image")));
			this.OutdentItem.Tag = "Outdent";
			// 
			// UnorderListItem
			// 
			this.UnorderListItem.Image = ((System.Drawing.Image)(resources.GetObject("UnorderListItem.Image")));
			this.UnorderListItem.Tag = "UnorderList";
			// 
			// OrderListItem
			// 
			this.OrderListItem.Image = ((System.Drawing.Image)(resources.GetObject("OrderListItem.Image")));
			this.OrderListItem.Tag = "OrderList";
			// 
			// UndoItem
			// 
			this.UndoItem.BeginGroup = true;
			this.UndoItem.Image = ((System.Drawing.Image)(resources.GetObject("UndoItem.Image")));
			this.UndoItem.ImageIndex = 8;
			this.UndoItem.Tag = "Undo";
			// 
			// RedoItem
			// 
			this.RedoItem.Image = ((System.Drawing.Image)(resources.GetObject("RedoItem.Image")));
			this.RedoItem.ImageIndex = 9;
			this.RedoItem.Tag = "Redo";
			// 
			// LinkItem
			// 
			this.LinkItem.Image = ((System.Drawing.Image)(resources.GetObject("LinkItem.Image")));
			this.LinkItem.ImageIndex = 14;
			this.LinkItem.Tag = "InsertHyperlink";
			// 
			// UnlinkItem
			// 
			this.UnlinkItem.Image = ((System.Drawing.Image)(resources.GetObject("UnlinkItem.Image")));
			this.UnlinkItem.Tag = "RemoveLink";
			// 
			// InsertImageItem
			// 
			this.InsertImageItem.Image = ((System.Drawing.Image)(resources.GetObject("InsertImageItem.Image")));
			this.InsertImageItem.Tag = "InsertImage";
			// 
			// panel1
			// 
			this.panel1.Controls.Add(this.editorPanel);
			this.panel1.Controls.Add(this.splitter1);
			this.panel1.Controls.Add(this.leftPanel);
			this.panel1.Controls.Add(this.panel2);
			this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.panel1.Location = new System.Drawing.Point(0, 26);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(624, 406);
			this.panel1.TabIndex = 4;
			// 
			// editorPanel
			// 
			this.editorPanel.BackColor = System.Drawing.Color.White;
			this.editorPanel.Dock = System.Windows.Forms.DockStyle.Fill;
			this.editorPanel.Location = new System.Drawing.Point(0, 56);
			this.editorPanel.Name = "editorPanel";
			this.editorPanel.Size = new System.Drawing.Size(517, 350);
			this.editorPanel.TabIndex = 7;
			// 
			// splitter1
			// 
			this.splitter1.Dock = System.Windows.Forms.DockStyle.Right;
			this.splitter1.Location = new System.Drawing.Point(517, 56);
			this.splitter1.Name = "splitter1";
			this.splitter1.Size = new System.Drawing.Size(3, 350);
			this.splitter1.TabIndex = 6;
			this.splitter1.TabStop = false;
			// 
			// leftPanel
			// 
			this.leftPanel.BackColor = System.Drawing.Color.White;
			this.leftPanel.Controls.Add(this.label2);
			this.leftPanel.Controls.Add(this.refreshCategoryButton);
			this.leftPanel.Controls.Add(this.categoryListBox);
			this.leftPanel.Dock = System.Windows.Forms.DockStyle.Right;
			this.leftPanel.Location = new System.Drawing.Point(520, 56);
			this.leftPanel.Name = "leftPanel";
			this.leftPanel.Size = new System.Drawing.Size(104, 350);
			this.leftPanel.TabIndex = 5;
			// 
			// label2
			// 
			this.label2.Dock = System.Windows.Forms.DockStyle.Top;
			this.label2.Location = new System.Drawing.Point(0, 0);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(104, 32);
			this.label2.TabIndex = 3;
			this.label2.Text = "&Categories:";
			// 
			// refreshCategoryButton
			// 
			this.refreshCategoryButton.BackColor = System.Drawing.SystemColors.Control;
			this.refreshCategoryButton.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.refreshCategoryButton.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.refreshCategoryButton.Location = new System.Drawing.Point(0, 326);
			this.refreshCategoryButton.Name = "refreshCategoryButton";
			this.refreshCategoryButton.Size = new System.Drawing.Size(104, 24);
			this.refreshCategoryButton.TabIndex = 1;
			this.refreshCategoryButton.Text = "Refresh";
			this.refreshCategoryButton.Click += new System.EventHandler(this.refreshCategoryButton_Click);
			// 
			// categoryListBox
			// 
			this.categoryListBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
			this.categoryListBox.CheckOnClick = true;
			this.categoryListBox.Dock = System.Windows.Forms.DockStyle.Fill;
			this.categoryListBox.Location = new System.Drawing.Point(0, 0);
			this.categoryListBox.Name = "categoryListBox";
			this.categoryListBox.Size = new System.Drawing.Size(104, 345);
			this.categoryListBox.TabIndex = 0;
			this.categoryListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.categoryListBox_ItemCheck);
			// 
			// panel2
			// 
			this.panel2.BackColor = System.Drawing.SystemColors.Control;
			this.panel2.Controls.Add(this.statusLabel);
			this.panel2.Controls.Add(this.plainTextCheckBox);
			this.panel2.Controls.Add(this.titleTextBox);
			this.panel2.Controls.Add(this.label1);
			this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
			this.panel2.Location = new System.Drawing.Point(0, 0);
			this.panel2.Name = "panel2";
			this.panel2.Size = new System.Drawing.Size(624, 56);
			this.panel2.TabIndex = 1;
			// 
			// statusLabel
			// 
			this.statusLabel.AutoSize = true;
			this.statusLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.statusLabel.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
			this.statusLabel.Location = new System.Drawing.Point(8, 32);
			this.statusLabel.Name = "statusLabel";
			this.statusLabel.Size = new System.Drawing.Size(30, 16);
			this.statusLabel.TabIndex = 5;
			this.statusLabel.Text = "Draft";
			this.statusLabel.TextAlign = System.Drawing.ContentAlignment.TopCenter;
			// 
			// plainTextCheckBox
			// 
			this.plainTextCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.plainTextCheckBox.Location = new System.Drawing.Point(144, 32);
			this.plainTextCheckBox.Name = "plainTextCheckBox";
			this.plainTextCheckBox.Size = new System.Drawing.Size(472, 16);
			this.plainTextCheckBox.TabIndex = 4;
			this.plainTextCheckBox.Text = "Post as plain text, smaller, better, and supported by all but no fomatting, color" +
				" or style";
			// 
			// titleTextBox
			// 
			this.titleTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.titleTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.titleTextBox.Location = new System.Drawing.Point(48, 8);
			this.titleTextBox.MaxLength = 255;
			this.titleTextBox.Name = "titleTextBox";
			this.titleTextBox.Size = new System.Drawing.Size(568, 20);
			this.titleTextBox.TabIndex = 3;
			this.titleTextBox.Text = "";
			// 
			// label1
			// 
			this.label1.AutoSize = true;
			this.label1.Location = new System.Drawing.Point(8, 8);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(29, 16);
			this.label1.TabIndex = 2;
			this.label1.Text = "&Title:";
			this.label1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
			// 
			// errorPanel
			// 
			this.errorPanel.BackColor = System.Drawing.SystemColors.Info;
			this.errorPanel.Controls.Add(this.errorTextBox);
			this.errorPanel.Controls.Add(this.closeErrorPanelButton);
			this.errorPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.errorPanel.Location = new System.Drawing.Point(0, 368);
			this.errorPanel.Name = "errorPanel";
			this.errorPanel.Size = new System.Drawing.Size(624, 64);
			this.errorPanel.TabIndex = 5;
			this.errorPanel.Visible = false;
			// 
			// errorTextBox
			// 
			this.errorTextBox.BackColor = System.Drawing.SystemColors.Info;
			this.errorTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
			this.errorTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.errorTextBox.ForeColor = System.Drawing.Color.DarkRed;
			this.errorTextBox.Location = new System.Drawing.Point(8, 8);
			this.errorTextBox.Multiline = true;
			this.errorTextBox.Name = "errorTextBox";
			this.errorTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			this.errorTextBox.Size = new System.Drawing.Size(584, 48);
			this.errorTextBox.TabIndex = 2;
			this.errorTextBox.Text = "(No error in post)";
			// 
			// closeErrorPanelButton
			// 
			this.closeErrorPanelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
			this.closeErrorPanelButton.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.closeErrorPanelButton.Location = new System.Drawing.Point(600, 8);
			this.closeErrorPanelButton.Name = "closeErrorPanelButton";
			this.closeErrorPanelButton.Size = new System.Drawing.Size(16, 16);
			this.closeErrorPanelButton.TabIndex = 1;
			this.closeErrorPanelButton.Text = "x";
			this.closeErrorPanelButton.Click += new System.EventHandler(this.closeErrorPanelButton_Click);
			// 
			// PostEditorControl
			// 
			this.Controls.Add(this.errorPanel);
			this.Controls.Add(this.panel1);
			this.Controls.Add(this.DesignSandBar);
			this.Name = "PostEditorControl";
			this.Size = new System.Drawing.Size(624, 432);
			this.panel1.ResumeLayout(false);
			this.leftPanel.ResumeLayout(false);
			this.panel2.ResumeLayout(false);
			this.errorPanel.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		#endregion

		#region My Code

		public event EventHandler OnSave;

		private Post _Post = new Post();

		public Post CurrentPost
		{
			get
			{
				this.PreparePost();
				return this._Post;
			}
			set
			{
				this._Post = value;
				this.ShowPost();
			}
		}

		private void CreateEditor()
		{
			_Editor = new HtmlEditor();
			_Editor.Dock = DockStyle.Fill;
			_Editor.HandleCreated += new EventHandler(_Editor_HandleCreated);
			editorPanel.Controls.Add( _Editor );
		}

		private void ShowPost()
		{
			if( null == this._Post ) return;

			if( this._Editor.IsHandleCreated )
			{
				//this._Editor.NewDocument();
				if( null != this._Post )
					this._Editor.DocumentHTML = this._Post.Text;
			}

			this.titleTextBox.Text = this._Post.Title;

			// preselect categories
			this.categoryListBox.ClearSelected();

			if( null != this._Post.Categories )
			{
				for( int i = 0; i < this.categoryListBox.Items.Count; i ++)
				{
					Category categoryItem = this.categoryListBox.Items[i] as Category;
					foreach( Category category in this._Post.Categories )
					{
						if( categoryItem.Id == category.Id )
							this.categoryListBox.SetItemChecked( i, true );
					}
				}
			}

			this.UpdateStatus();

			this.titleTextBox.Focus();
			this.titleTextBox.SelectAll();

			if( null != this._Post.ErrorInPost && this._Post.ErrorInPost.Length > 0 )
			{
				this.errorPanel.Visible = true;
				this.errorTextBox.Text = this._Post.ErrorInPost;
			}
			else
			{
				this.errorPanel.Visible = false;
			}
		}

		private void ShowCategories()
		{
			categoryListBox.Items.Clear();
			foreach( Category cat in this._WebLog.Categories )
				categoryListBox.Items.Add( cat );
		}

		private WebLog _WebLog;

		public void SetWebLog( WebLog log )
		{
			this._WebLog = log;
			this.ShowCategories();

			if( EngineEnum.B2Evolution == log.Engine )
			{
				FontDropDown.Enabled = false;
				SizeDropDown.Enabled = false;
				ColorItem.Enabled = false;
			}
		}

		private void PreparePost()
		{
			if( null == this._Post ) return;
			// Get the selected categories
			Category [] selectedCategories = new Category[ categoryListBox.CheckedItems.Count ];
			categoryListBox.CheckedItems.CopyTo( selectedCategories, 0 );

			_Post.Categories = selectedCategories;
			_Post.Date = DateTime.Now;
			
			if( null != _Editor && _Editor.IsHandleCreated && null != _Editor.GetOcx() )
			{
				if( plainTextCheckBox.Checked )
				{
					if( null != _Editor.DOM && null != _Editor.DOM.body )
						_Post.Text = _Editor.DOM.body.innerText;
					else
						_Post.Text = _Editor.SelectedText;
				}
				else
				{
					try
					{
						_Post.Text = _Editor.DocumentHTML;
					}
					catch
					{
						// The editor control is so unpredictable
					}
				}
			}

			_Post.Title = titleTextBox.Text;
			
		}
//
//		/// <summary>
//		/// force send the post now
//		/// </summary>
//		public void SendNow()
//		{
//			Post post = this.PreparePost();
//
//			base.Cursor = Cursors.AppStarting;
//			this.postStatusLabel.Visible = true;
//			base.Refresh();
//
//			ThreadPool.QueueUserWorkItem( new WaitCallback( this.PostWaitCallback ), post );
//		}

//		public void PostBlog()
//		{
//			Post post = this.PreparePost();
//			this._WebLog.EnqueuePost( post );
//
//			this._Editor.NewDocument();
//		}
//
//		private void PostWaitCallback( object state )
//		{
//			Post post = state as Post;
//			try
//			{
//				string postID = WebLogProvider.Instance.PostBlog( this._WebLog, post );
//
//				base.Invoke( new WaitCallback( this.PostCompleteEvent ), new object[] { postID } );
//			}
//			catch( Exception x )
//			{
//				base.Invoke( new WaitCallback( this.PostCompleteEvent ), new object[] { x } );
//			}
//		}
//
//		private void PostCompleteEvent( object state )
//		{
//			if( state is string )
//			{
//				this.postStatusLabel.Text = "Posted.";
//				base.Refresh();
//
//				string postID = state as string;
//				if( DialogResult.Yes ==  MessageBox.Show( this, "Blog successfully posted. Post ID: " + postID + Environment.NewLine +
//					"Would you like to post another?", "Post Blog", 
//					MessageBoxButtons.YesNo, MessageBoxIcon.Information ) )
//				{
//					this._Editor.NewDocument();
//				}
//
//				//this.Close();
//			}
//			else if( state is Exception )
//			{
//				Exception x = state as Exception;
//				MessageBox.Show( this, "Error occured while posting to blog." + Environment.NewLine +
//					x.Message, "Post Blog Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation );
//			}
//
//			base.Cursor = Cursors.Default;
//			this.postStatusLabel.Visible = false;
//
//		}

		private void RefreshCategories()
		{
			Category [] newCategories = WebLogProvider.Instance.GetCategories( this._WebLog );
			this._WebLog.Categories = newCategories;

			this.ShowCategories();
		}

		private void DesignSandBar_ButtonClick(object sender, TD.SandBar.ToolBarItemEventArgs e)
		{
			// Get the tag which contains the function name to be invoked
			string name = e.Item.Tag as string;

			if( null == name || 0 == name.Length ) return;

			// if self call, call the function on self
			if( name.StartsWith("$") )
			{
				MethodInfo method = this.GetType().GetMethod( name.TrimStart('$') );
				method.Invoke( this, null );
			}
			else
			{
				// The function is on the editor component
				MethodInfo [] methods = this._Editor.GetType().GetMethods( );
				// Call the method which has no parameter
				foreach( MethodInfo method in methods )
					if( method.Name == name && 0 == method.GetParameters().Length ) 
					{
						try
						{
							method.Invoke( this._Editor, null );
						}
						catch( Exception x )
						{
							Debug.WriteLine( x ); 
						}
					}
			}
		}

		public void Send()
		{
			this._Post.IsSend = true;
			this._Post.IsSent = false;
			this._Post.ErrorInPost = string.Empty;
			this.errorPanel.Visible = false;
			if( null != OnSave ) OnSave( this, EventArgs.Empty );
			this.UpdateStatus();
		}

		public void Save()
		{
			this._Post.IsSend = false;
			this._Post.IsSent = false;
			
			if( null != OnSave ) OnSave( this, EventArgs.Empty );
			this.UpdateStatus();
		}

		private void UpdateStatus()
		{
			if( null != this._Post.ErrorInPost && this._Post.ErrorInPost.Length > 0 )
			{
				this.statusLabel.Text = "Error while posting";
			}
			if( this._Post.IsSend )
			{
				this.statusLabel.Text = "Queued for send.";
			}
			else if( this._Post.IsSent )
			{
				this.statusLabel.Text = "Sent";
			} 
			else
			{
				this.statusLabel.Text = "Draft";
			}
		}

		private void refreshCategoryButton_Click(object sender, System.EventArgs e)
		{
			this.RefreshCategories();
		}

		private void SetFont(object sender, System.EventArgs e)
		{
			TD.SandBar.MenuButtonItem item = (TD.SandBar.MenuButtonItem)sender;
			this._Editor.SetFont( item.Text );
		}

		private void SetSize(object sender, System.EventArgs e)
		{
			TD.SandBar.MenuButtonItem item = (TD.SandBar.MenuButtonItem)sender;
			this._Editor.SetSize( int.Parse( item.Text ) );
		}

		
		private void categoryListBox_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
		{
			//this.PreparePost();
		}

		private void closeErrorPanelButton_Click(object sender, System.EventArgs e)
		{
			this.errorPanel.Visible = false;
		}

		private void _Editor_HandleCreated(object sender, EventArgs e)
		{			
			//this._Editor.NewDocument();
			if( null != this._Post )
				this._Editor.DocumentHTML = this._Post.Text;
		}


		#endregion
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Omar Al Zabir
Architect BT, UK (ex British Telecom)
United Kingdom United Kingdom

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150414.1 | Last Updated 16 Aug 2005
Article Copyright 2005 by Omar Al Zabir
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid