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

RSS Feed Aggregator and Blogging Smart Client

, 16 Aug 2005
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
// Copyright � 2005 by Omar Al Zabir. All rights are reserved.
// 
// If you like this code then feel free to go ahead and use it.
// The only thing I ask is that you don't remove or alter my copyright notice.
//
// Your use of this software is entirely at your own risk. I make no claims or
// warrantees about the reliability or fitness of this code for any particular purpose.
// If you make changes or additions to this code please mark your code as being yours.
// 
// website http://www.oazabir.com, email OmarAlZabir@gmail.com, msn oazabir@hotmail.com
using System;
using System.Diagnostics;
using System.Threading;
using System.Reflection;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace RSSBlogAPI
{
	/// <summary>
	/// Summary description for PostForm.
	/// </summary>
	public class PostForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Panel topPanel;
		private System.Windows.Forms.Panel leftPanel;
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.CheckedListBox categoryListBox;
		private System.Windows.Forms.Panel panel2;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox titleTextBox;
		private System.Windows.Forms.Panel editorPanel;
		private System.ComponentModel.IContainer components;
		//private TD.SandDock.SandDockManager sandManager;
		private TD.SandBar.ToolBar DesignSandBar;
		private TD.SandBar.DropDownMenuItem SaveItem;
		private TD.SandBar.MenuButtonItem postButton;
		private TD.SandBar.MenuButtonItem closeButton;
		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.Button refreshCategoryButton;
		private System.Windows.Forms.Label postStatusLabel;
		private System.Windows.Forms.CheckBox plainTextCheckBox;
		private TD.SandBar.MenuButtonItem sendNowMenuItem;

		private HtmlEditor _Editor;

		public PostForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//

			_Editor = new HtmlEditor();
			_Editor.Dock = DockStyle.Fill;
			editorPanel.Controls.Add( _Editor );
		}

		/// <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 Windows Form 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(PostForm));
			this.topPanel = new System.Windows.Forms.Panel();
			this.DesignSandBar = new TD.SandBar.ToolBar();
			this.SaveItem = new TD.SandBar.DropDownMenuItem();
			this.postButton = new TD.SandBar.MenuButtonItem();
			this.closeButton = new TD.SandBar.MenuButtonItem();
			this.sendNowMenuItem = new TD.SandBar.MenuButtonItem();
			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.leftPanel = new System.Windows.Forms.Panel();
			this.refreshCategoryButton = new System.Windows.Forms.Button();
			this.categoryListBox = new System.Windows.Forms.CheckedListBox();
			this.panel1 = new System.Windows.Forms.Panel();
			this.editorPanel = new System.Windows.Forms.Panel();
			this.postStatusLabel = new System.Windows.Forms.Label();
			this.panel2 = new System.Windows.Forms.Panel();
			this.plainTextCheckBox = new System.Windows.Forms.CheckBox();
			this.titleTextBox = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.topPanel.SuspendLayout();
			this.leftPanel.SuspendLayout();
			this.panel1.SuspendLayout();
			this.editorPanel.SuspendLayout();
			this.panel2.SuspendLayout();
			this.SuspendLayout();
			// 
			// topPanel
			// 
			this.topPanel.Controls.Add(this.DesignSandBar);
			this.topPanel.Dock = System.Windows.Forms.DockStyle.Top;
			this.topPanel.Location = new System.Drawing.Point(0, 0);
			this.topPanel.Name = "topPanel";
			this.topPanel.Size = new System.Drawing.Size(632, 24);
			this.topPanel.TabIndex = 0;
			// 
			// DesignSandBar
			// 
			this.DesignSandBar.Buttons.AddRange(new TD.SandBar.ToolbarItemBase[] {
																					 this.SaveItem,
																					 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(632, 26);
			this.DesignSandBar.TabIndex = 1;
			this.DesignSandBar.Text = "";
			this.DesignSandBar.ButtonClick += new TD.SandBar.ToolBar.ButtonClickEventHandler(this.DesignSandBar_ButtonClick);
			// 
			// SaveItem
			// 
			this.SaveItem.Image = ((System.Drawing.Image)(resources.GetObject("SaveItem.Image")));
			this.SaveItem.MenuItems.AddRange(new TD.SandBar.MenuButtonItem[] {
																				 this.postButton,
																				 this.sendNowMenuItem,
																				 this.closeButton});
			this.SaveItem.Tag = "$PostBlog";
			this.SaveItem.Text = "";
			// 
			// postButton
			// 
			this.postButton.Image = ((System.Drawing.Image)(resources.GetObject("postButton.Image")));
			this.postButton.Tag = "$Post";
			this.postButton.Text = "Post (Queue)";
			this.postButton.Select += new System.EventHandler(this.postButton_Select);
			// 
			// closeButton
			// 
			this.closeButton.Image = ((System.Drawing.Image)(resources.GetObject("closeButton.Image")));
			this.closeButton.Tag = "$Close";
			this.closeButton.Text = "Close";
			this.closeButton.Select += new System.EventHandler(this.closeButton_Select);
			// 
			// sendNowMenuItem
			// 
			this.sendNowMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("sendNowMenuItem.Image")));
			this.sendNowMenuItem.Tag = "$SendNow";
			this.sendNowMenuItem.Text = "Send Now";
			// 
			// 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.Select += new System.EventHandler(this.SetFont);
			// 
			// FontItem1
			// 
			this.FontItem1.Text = "Courier New";
			this.FontItem1.Select += new System.EventHandler(this.SetFont);
			// 
			// FontItem2
			// 
			this.FontItem2.Text = "Garamond";
			this.FontItem2.Select += new System.EventHandler(this.SetFont);
			// 
			// FontItem3
			// 
			this.FontItem3.Text = "Georgia";
			this.FontItem3.Select += new System.EventHandler(this.SetFont);
			// 
			// FontItem4
			// 
			this.FontItem4.Text = "Tahoma";
			this.FontItem4.Select += new System.EventHandler(this.SetFont);
			// 
			// FontItem5
			// 
			this.FontItem5.Text = "Times New Roman";
			this.FontItem5.Select += new System.EventHandler(this.SetFont);
			// 
			// FontItem6
			// 
			this.FontItem6.Text = "Verdana";
			this.FontItem6.Select += 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.Select += new System.EventHandler(this.SetSize);
			// 
			// SizeItem2
			// 
			this.SizeItem2.Text = "2";
			this.SizeItem2.Select += new System.EventHandler(this.SetSize);
			// 
			// SizeItem3
			// 
			this.SizeItem3.Text = "3";
			this.SizeItem3.Select += new System.EventHandler(this.SetSize);
			// 
			// SizeItem4
			// 
			this.SizeItem4.Text = "4";
			this.SizeItem4.Select += new System.EventHandler(this.SetSize);
			// 
			// SizeItem5
			// 
			this.SizeItem5.Text = "5";
			this.SizeItem5.Select += new System.EventHandler(this.SetSize);
			// 
			// SizeItem6
			// 
			this.SizeItem6.Text = "6";
			this.SizeItem6.Select += 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";
			// 
			// leftPanel
			// 
			this.leftPanel.Controls.Add(this.refreshCategoryButton);
			this.leftPanel.Controls.Add(this.categoryListBox);
			this.leftPanel.Dock = System.Windows.Forms.DockStyle.Left;
			this.leftPanel.Location = new System.Drawing.Point(0, 24);
			this.leftPanel.Name = "leftPanel";
			this.leftPanel.Size = new System.Drawing.Size(136, 358);
			this.leftPanel.TabIndex = 1;
			// 
			// refreshCategoryButton
			// 
			this.refreshCategoryButton.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.refreshCategoryButton.Location = new System.Drawing.Point(0, 334);
			this.refreshCategoryButton.Name = "refreshCategoryButton";
			this.refreshCategoryButton.Size = new System.Drawing.Size(136, 24);
			this.refreshCategoryButton.TabIndex = 1;
			this.refreshCategoryButton.Text = "Refresh";
			this.refreshCategoryButton.Click += new System.EventHandler(this.refreshCategoryButton_Click);
			// 
			// categoryListBox
			// 
			this.categoryListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
				| System.Windows.Forms.AnchorStyles.Left) 
				| System.Windows.Forms.AnchorStyles.Right)));
			this.categoryListBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.categoryListBox.CheckOnClick = true;
			this.categoryListBox.Location = new System.Drawing.Point(0, 0);
			this.categoryListBox.Name = "categoryListBox";
			this.categoryListBox.Size = new System.Drawing.Size(136, 322);
			this.categoryListBox.TabIndex = 0;
			// 
			// panel1
			// 
			this.panel1.Controls.Add(this.editorPanel);
			this.panel1.Controls.Add(this.panel2);
			this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.panel1.Location = new System.Drawing.Point(136, 24);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(496, 358);
			this.panel1.TabIndex = 3;
			// 
			// editorPanel
			// 
			this.editorPanel.Controls.Add(this.postStatusLabel);
			this.editorPanel.Dock = System.Windows.Forms.DockStyle.Fill;
			this.editorPanel.Location = new System.Drawing.Point(0, 40);
			this.editorPanel.Name = "editorPanel";
			this.editorPanel.Size = new System.Drawing.Size(496, 318);
			this.editorPanel.TabIndex = 4;
			// 
			// postStatusLabel
			// 
			this.postStatusLabel.BackColor = System.Drawing.Color.LightYellow;
			this.postStatusLabel.Font = new System.Drawing.Font("Tahoma", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.postStatusLabel.ForeColor = System.Drawing.Color.DimGray;
			this.postStatusLabel.Location = new System.Drawing.Point(136, 272);
			this.postStatusLabel.Name = "postStatusLabel";
			this.postStatusLabel.Size = new System.Drawing.Size(176, 56);
			this.postStatusLabel.TabIndex = 0;
			this.postStatusLabel.Text = "Posting...";
			this.postStatusLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			this.postStatusLabel.Visible = false;
			// 
			// panel2
			// 
			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(496, 40);
			this.panel2.TabIndex = 1;
			// 
			// plainTextCheckBox
			// 
			this.plainTextCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.plainTextCheckBox.Location = new System.Drawing.Point(48, 24);
			this.plainTextCheckBox.Name = "plainTextCheckBox";
			this.plainTextCheckBox.Size = new System.Drawing.Size(432, 16);
			this.plainTextCheckBox.TabIndex = 4;
			this.plainTextCheckBox.Text = "Post as plain text, smaller, better, supported by all but no fomatting, color or " +
				"style";
			// 
			// titleTextBox
			// 
			this.titleTextBox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.titleTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
			this.titleTextBox.Location = new System.Drawing.Point(48, 0);
			this.titleTextBox.MaxLength = 255;
			this.titleTextBox.Name = "titleTextBox";
			this.titleTextBox.Size = new System.Drawing.Size(448, 21);
			this.titleTextBox.TabIndex = 3;
			this.titleTextBox.Text = "";
			// 
			// label1
			// 
			this.label1.Dock = System.Windows.Forms.DockStyle.Left;
			this.label1.Location = new System.Drawing.Point(0, 0);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(48, 40);
			this.label1.TabIndex = 2;
			this.label1.Text = "&Title:";
			this.label1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
			// 
			// PostForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
			this.ClientSize = new System.Drawing.Size(632, 382);
			this.Controls.Add(this.panel1);
			this.Controls.Add(this.leftPanel);
			this.Controls.Add(this.topPanel);
			this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.Name = "PostForm";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "New Blog";
			this.topPanel.ResumeLayout(false);
			this.leftPanel.ResumeLayout(false);
			this.panel1.ResumeLayout(false);
			this.editorPanel.ResumeLayout(false);
			this.panel2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		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 Post PreparePost()
		{
			// Get the selected categories
			Category [] selectedCategories = new Category[ categoryListBox.CheckedItems.Count ];
			categoryListBox.CheckedItems.CopyTo( selectedCategories, 0 );

			Post post = new Post();
			post.Categories = selectedCategories;
			post.Date = DateTime.Now;
			
			if( plainTextCheckBox.Checked )
			{
				if( null != _Editor.DOM && null != _Editor.DOM.body )
					post.Text = _Editor.DOM.body.innerText;
				else
					post.Text = _Editor.SelectedText;
			}
			else
			{
				post.Text = _Editor.DocumentHTML;
			}

			post.Title = titleTextBox.Text;
			
			return post;
		}

		/// <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 ); 
						}
					}
			}
		}

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

		private void postButton_Select(object sender, System.EventArgs e)
		{
			this.PostBlog();
		}

		private void closeButton_Select(object sender, System.EventArgs e)
		{
			this.Close();
		}

		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 ) );
		}

	}
}

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


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