Click here to Skip to main content
15,886,742 members
Articles / Programming Languages / Visual Basic

RSS Feed Aggregator and Blogging Smart Client

Rate me:
Please Sign up or sign in to vote.
4.91/5 (85 votes)
16 Aug 2005CPOL52 min read 1.1M   2.4K   397  
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.
// 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.IO;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace RSSBlogAPI
{
	/// <summary>
	/// Summary description for AddNewWebLog.
	/// </summary>
	public class WebLogEditor : System.Windows.Forms.Form
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

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

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

		/// <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(WebLogEditor));
			this.panel1 = new System.Windows.Forms.Panel();
			this.cancelButton = new System.Windows.Forms.Button();
			this.okButton = new System.Windows.Forms.Button();
			this.panel2 = new System.Windows.Forms.Panel();
			this.propGrid = new System.Windows.Forms.PropertyGrid();
			this.splitter1 = new System.Windows.Forms.Splitter();
			this.panel3 = new System.Windows.Forms.Panel();
			this.browser = new AxSHDocVw.AxWebBrowser();
			this.panel1.SuspendLayout();
			this.panel2.SuspendLayout();
			this.panel3.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.browser)).BeginInit();
			this.SuspendLayout();
			// 
			// panel1
			// 
			this.panel1.Controls.Add(this.cancelButton);
			this.panel1.Controls.Add(this.okButton);
			this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.panel1.Location = new System.Drawing.Point(0, 358);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(664, 32);
			this.panel1.TabIndex = 1;
			// 
			// cancelButton
			// 
			this.cancelButton.Anchor = System.Windows.Forms.AnchorStyles.None;
			this.cancelButton.Location = new System.Drawing.Point(340, 8);
			this.cancelButton.Name = "cancelButton";
			this.cancelButton.TabIndex = 2;
			this.cancelButton.Text = "Cancel";
			this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
			// 
			// okButton
			// 
			this.okButton.Anchor = System.Windows.Forms.AnchorStyles.None;
			this.okButton.Location = new System.Drawing.Point(252, 8);
			this.okButton.Name = "okButton";
			this.okButton.TabIndex = 1;
			this.okButton.Text = "OK";
			this.okButton.Click += new System.EventHandler(this.okButton_Click);
			// 
			// panel2
			// 
			this.panel2.Controls.Add(this.panel3);
			this.panel2.Controls.Add(this.splitter1);
			this.panel2.Controls.Add(this.propGrid);
			this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
			this.panel2.Location = new System.Drawing.Point(0, 0);
			this.panel2.Name = "panel2";
			this.panel2.Size = new System.Drawing.Size(664, 358);
			this.panel2.TabIndex = 2;
			// 
			// propGrid
			// 
			this.propGrid.CommandsVisibleIfAvailable = true;
			this.propGrid.Dock = System.Windows.Forms.DockStyle.Left;
			this.propGrid.LargeButtons = false;
			this.propGrid.LineColor = System.Drawing.SystemColors.ScrollBar;
			this.propGrid.Location = new System.Drawing.Point(0, 0);
			this.propGrid.Name = "propGrid";
			this.propGrid.Size = new System.Drawing.Size(336, 358);
			this.propGrid.TabIndex = 0;
			this.propGrid.Text = "propertyGrid1";
			this.propGrid.ViewBackColor = System.Drawing.SystemColors.Window;
			this.propGrid.ViewForeColor = System.Drawing.SystemColors.WindowText;
			// 
			// splitter1
			// 
			this.splitter1.Location = new System.Drawing.Point(336, 0);
			this.splitter1.Name = "splitter1";
			this.splitter1.Size = new System.Drawing.Size(3, 358);
			this.splitter1.TabIndex = 1;
			this.splitter1.TabStop = false;
			// 
			// panel3
			// 
			this.panel3.BackColor = System.Drawing.Color.White;
			this.panel3.Controls.Add(this.browser);
			this.panel3.Dock = System.Windows.Forms.DockStyle.Fill;
			this.panel3.Location = new System.Drawing.Point(339, 0);
			this.panel3.Name = "panel3";
			this.panel3.Size = new System.Drawing.Size(325, 358);
			this.panel3.TabIndex = 2;
			// 
			// browser
			// 
			this.browser.ContainingControl = this;
			this.browser.Dock = System.Windows.Forms.DockStyle.Fill;
			this.browser.Enabled = true;
			this.browser.Location = new System.Drawing.Point(0, 0);
			this.browser.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("browser.OcxState")));
			this.browser.Size = new System.Drawing.Size(325, 358);
			this.browser.TabIndex = 0;
			// 
			// WebLogEditor
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
			this.ClientSize = new System.Drawing.Size(664, 390);
			this.Controls.Add(this.panel2);
			this.Controls.Add(this.panel1);
			this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "WebLogEditor";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "Web Log";
			this.Load += new System.EventHandler(this.WebLogEditor_Load);
			this.panel1.ResumeLayout(false);
			this.panel2.ResumeLayout(false);
			this.panel3.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.browser)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.Button okButton;
		private System.Windows.Forms.Button cancelButton;
		private System.Windows.Forms.Panel panel2;
		private System.Windows.Forms.PropertyGrid propGrid;
		private System.Windows.Forms.Splitter splitter1;
		private System.Windows.Forms.Panel panel3;
		private AxSHDocVw.AxWebBrowser browser;

		public WebLog NewWebLog = new WebLog();

		public void EditWebLog( WebLog log )
		{
			this.NewWebLog.PropertyChanged -= new PropertyChangedEventHandler(NewWebLog_PropertyChanged);

			this.NewWebLog = log;
			this.propGrid.SelectedObject = this.NewWebLog;

			this.NewWebLog.PropertyChanged += new PropertyChangedEventHandler(NewWebLog_PropertyChanged);
		}

		private void AddNewWeblog()
		{
			try
			{
				base.Cursor = Cursors.WaitCursor;
				Application.DoEvents();

				// Test if the weblog site setting is correct
				WebLogProvider.Instance.Test( this.NewWebLog );

				// Retreive categories from the blog site
				this.NewWebLog.Categories = WebLogProvider.Instance.GetCategories( this.NewWebLog );

				this.DialogResult = DialogResult.OK;
				this.Close();
			}
			catch( Exception x )
			{
				MessageBox.Show(this, "Error: " + x.Message + Environment.NewLine +
					"Please check the ServiceURL if it is correct. ", 
					"WebLog Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation );
			}
			finally
			{
				base.Cursor = Cursors.Default;				
			}
		}

		private void cancelButton_Click(object sender, System.EventArgs e)
		{
			this.DialogResult = DialogResult.Cancel;
			this.Close();
		}

		private void NewWebLog_PropertyChanged(object sender, PropertyChangedEventArgs e)
		{
			try
			{
				this.propGrid.SelectedObject = this.NewWebLog;
			}
			catch {}
			//this.propGrid.Refresh();
		}

		
		private void okButton_Click(object sender, System.EventArgs e)
		{
			this.AddNewWeblog();
		}

		private void WebLogEditor_Load(object sender, System.EventArgs e)
		{
			this.propGrid.SelectedObject = this.NewWebLog;
			this.NewWebLog.PropertyChanged += new PropertyChangedEventHandler(NewWebLog_PropertyChanged);

			try
			{
				object url = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, "docs\\WebLogInstruction.html" );
				object nil = System.Reflection.Missing.Value;
				this.browser.Navigate2( ref url, ref nil, ref nil, ref nil, ref nil );
			}
			catch
			{
				
			}
		}

	}
}

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)


Written By
Architect BT, UK (ex British Telecom)
United Kingdom United Kingdom

Comments and Discussions