// Copyright � 2006 by Christoph Richner. All rights are reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
// website http://www.raccoom.net, email support@raccoom.net, msn chrisdarebell@msn.com
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Raccoom.Windows.Forms;
namespace Raccoom.Xml.Editors
{
/// <summary>
/// Summary description for RssCacheManager.
/// </summary>
public class RssCacheManager : System.Windows.Forms.Form
{
#region fields
private Raccoom.Windows.Forms.DockingManagerExtender _dockingManager;
private RssFeedManager manager=null;
private OpmlDocumentFavorites favorites = null;
private TreeViewOpmlDocument treeView1;
private TreeViewOpmlDocument treeView2;
private System.Windows.Forms.ImageList _imageList;
private WebBrowser _axWebBrowserHtml;
private System.Windows.Forms.StatusBar _statusBar;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.ToolBar _toolBar;
private System.Windows.Forms.ToolBarButton toolBarButton1;
private System.Windows.Forms.ImageList _ilToolbar;
private System.Windows.Forms.ToolBarButton toolBarButton2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private string _favoritePath = System.IO.Path.Combine(Application.StartupPath, "favorites.opml");
private System.ComponentModel.IContainer components;
#endregion
#region constructors
public RssCacheManager()
{
InitializeComponent();
}
#endregion
protected override void OnLoad(EventArgs e)
{
base.OnLoad (e);
//
this._axWebBrowserHtml.Dock = DockStyle.Fill;
//
//Uri uri = new Uri("http://feedster.com/feedcache/top100.opml");
Uri uri = new Uri(_favoritePath);
favorites = new OpmlDocumentFavorites(uri);
manager = new RssFeedManager(System.Windows.Forms.Application.StartupPath, favorites);
this.treeView1.Populate(favorites);
this.treeView2.Populate(manager.History);
//
manager.Reset();
manager.Refresh();
//manager.GetFeed((OpmlOutlineFavorite) favorites.Body.Items[1].Items[0]);
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed (e);
//
favorites.Save(_favoritePath);
}
#region public interface
private void NavigateHtml(string url)
{
this._axWebBrowserHtml.Navigate(url);
}
#endregion
#region Windows Form Designer generated code
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(RssCacheManager));
this._dockingManager = new Raccoom.Windows.Forms.DockingManagerExtender(this.components);
this._axWebBrowserHtml = new WebBrowser();
this._toolBar = new System.Windows.Forms.ToolBar();
this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton2 = new System.Windows.Forms.ToolBarButton();
this._ilToolbar = new System.Windows.Forms.ImageList(this.components);
this.treeView1 = new Raccoom.Windows.Forms.TreeViewOpmlDocument(this.components);
this.treeView2 = new Raccoom.Windows.Forms.TreeViewOpmlDocument(this.components);
this._imageList = new System.Windows.Forms.ImageList(this.components);
this._statusBar = new System.Windows.Forms.StatusBar();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.SuspendLayout();
//
// _dockingManager
//
this._dockingManager.AutomaticStatePersistence = true;
this._dockingManager.ContainerControl = this;
this._dockingManager.InnerControl = this._axWebBrowserHtml;
this._dockingManager.OuterControl = this._toolBar;
this._dockingManager.PlainTabBorder = false;
this._dockingManager.VisualStyle = Crownwood.Magic.Common.VisualStyle.IDE;
//
// _axWebBrowserHtml
//
this._dockingManager.SetADockingEnable(this._axWebBrowserHtml, false);
this._dockingManager.SetCloseButton(this._axWebBrowserHtml, false);
this._dockingManager.SetCloseOnHide(this._axWebBrowserHtml, false);
this._dockingManager.SetDockingStyle(this._axWebBrowserHtml, System.Windows.Forms.DockStyle.Left);
this._dockingManager.SetFullTitle(this._axWebBrowserHtml, "_axWebBrowserHtml");
this._dockingManager.SetIcon(this._axWebBrowserHtml, null);
this._axWebBrowserHtml.Location = new System.Drawing.Point(368, 72);
this._axWebBrowserHtml.Size = new System.Drawing.Size(360, 360);
this._dockingManager.SetTabbedMode(this._axWebBrowserHtml, true);
this._axWebBrowserHtml.TabIndex = 5;
this._dockingManager.SetTitle(this._axWebBrowserHtml, "_axWebBrowserHtml");
//
// _toolBar
//
this._toolBar.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
this._toolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.toolBarButton1,
this.toolBarButton2});
this._toolBar.DropDownArrows = true;
this._toolBar.ImageList = this._ilToolbar;
this._toolBar.Location = new System.Drawing.Point(0, 0);
this._toolBar.Name = "_toolBar";
this._toolBar.ShowToolTips = true;
this._toolBar.Size = new System.Drawing.Size(872, 28);
this._toolBar.TabIndex = 7;
//
// toolBarButton1
//
this.toolBarButton1.ImageIndex = 0;
this.toolBarButton1.ToolTipText = "Exit";
//
// toolBarButton2
//
this.toolBarButton2.ImageIndex = 1;
//
// _ilToolbar
//
this._ilToolbar.ColorDepth = System.Windows.Forms.ColorDepth.Depth24Bit;
this._ilToolbar.ImageSize = new System.Drawing.Size(16, 16);
this._ilToolbar.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("_ilToolbar.ImageStream")));
this._ilToolbar.TransparentColor = System.Drawing.Color.Transparent;
//
// treeView1
//
this._dockingManager.SetADockingEnable(this.treeView1, true);
this._dockingManager.SetCloseButton(this.treeView1, true);
this._dockingManager.SetCloseOnHide(this.treeView1, false);
this.treeView1.ContentType = Raccoom.Windows.Forms.ContentType.FoldersAndContent;
this._dockingManager.SetDockingStyle(this.treeView1, System.Windows.Forms.DockStyle.Left);
this._dockingManager.SetFullTitle(this.treeView1, "Favorites");
this._dockingManager.SetIcon(this.treeView1, null);
this.treeView1.Location = new System.Drawing.Point(224, 248);
this.treeView1.Name = "treeView1";
this.treeView1.Size = new System.Drawing.Size(160, 192);
this._dockingManager.SetTabbedMode(this.treeView1, false);
this.treeView1.TabIndex = 3;
this._dockingManager.SetTitle(this.treeView1, "Favorites");
this.treeView1.ViewStyle = Raccoom.Windows.Forms.ViewStyle.Document;
this.treeView1.DoubleClick += new System.EventHandler(this.treeView1_DoubleClick);
//
// treeView2
//
this._dockingManager.SetADockingEnable(this.treeView2, true);
this._dockingManager.SetCloseButton(this.treeView2, true);
this._dockingManager.SetCloseOnHide(this.treeView2, false);
this.treeView2.ContentType = Raccoom.Windows.Forms.ContentType.FoldersAndContent;
this._dockingManager.SetDockingStyle(this.treeView2, System.Windows.Forms.DockStyle.Left);
this.treeView2.FullRowSelect = true;
this._dockingManager.SetFullTitle(this.treeView2, "History");
this.treeView2.HotTracking = true;
this._dockingManager.SetIcon(this.treeView2, null);
this.treeView2.ImageList = this._imageList;
this.treeView2.Location = new System.Drawing.Point(80, 80);
this.treeView2.Name = "treeView2";
this.treeView2.ShowLines = false;
this.treeView2.ShowPlusMinus = false;
this.treeView2.ShowRootLines = false;
this.treeView2.Size = new System.Drawing.Size(208, 144);
this._dockingManager.SetTabbedMode(this.treeView2, false);
this.treeView2.TabIndex = 4;
this._dockingManager.SetTitle(this.treeView2, "History");
this.treeView2.ViewStyle = Raccoom.Windows.Forms.ViewStyle.Flat;
//
// _imageList
//
this._imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
this._imageList.ImageSize = new System.Drawing.Size(16, 16);
this._imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("_imageList.ImageStream")));
this._imageList.TransparentColor = System.Drawing.Color.Transparent;
//
// _statusBar
//
this._statusBar.Location = new System.Drawing.Point(0, 482);
this._statusBar.Name = "_statusBar";
this._statusBar.Size = new System.Drawing.Size(872, 20);
this._statusBar.TabIndex = 6;
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem3});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem2});
this.menuItem1.Text = "&File";
//
// menuItem2
//
this.menuItem2.Index = 0;
this.menuItem2.Text = "&Exit";
//
// menuItem3
//
this.menuItem3.Index = 1;
this.menuItem3.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem4});
this.menuItem3.Text = "?";
//
// menuItem4
//
this.menuItem4.Index = 0;
this.menuItem4.Text = "&About";
//
// RssCacheManager
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(872, 502);
this.Controls.Add(this._axWebBrowserHtml);
this.Controls.Add(this.treeView2);
this.Controls.Add(this.treeView1);
this.Controls.Add(this._toolBar);
this.Controls.Add(this._statusBar);
this.Menu = this.mainMenu1;
this.Name = "RssCacheManager";
this.Text = "RssCacheManager";
this.ResumeLayout(false);
}
#endregion
private void treeView1_DoubleClick(object sender, System.EventArgs e)
{
if(this.treeView1.SelectedNode==null) return;
TreeNodeOpmlOutline node = this.treeView1.SelectedNode as TreeNodeOpmlOutline;
if(node.IsFolder) return;
Cursor.Current = Cursors.WaitCursor;
try
{
string fileNameHtml= System.IO.Path.GetFullPath("rssfeed.html");
// get embedded xslt file
using(System.IO.Stream styleSheetStream = this.GetType().Assembly.GetManifestResourceStream("Raccoom.Xml.Editors.gotdotnet.xslt"))
{
this.manager.GetFeed((OpmlOutlineFavorite) node.OpmlOutlineItem).Transform(new System.Xml.XmlTextReader(styleSheetStream), fileNameHtml);
}
//
NavigateHtml(fileNameHtml);
//
this._statusBar.Text = "Ready";
}
catch (System.Exception ex)
{
//NavigateHtml("http://feedvalidator.org/check?url="+node.OpmlOutlineItem.XmlUrl);
this._statusBar.Text = ex.Message;
}
finally
{
Cursor.Current = Cursors.Default;
}
}
}
}