// 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;
namespace Raccoom.Xml.Editors
{
/// <summary>
/// Summary description for RssUIManagerTest.
/// </summary>
public class RssUIManagerTest : System.Windows.Forms.Form, Raccoom.Windows.Forms.IEnvironmentWindow
{
#region fields
private EnvProgressBar _envProgressBar;
private InternetExplorerRss _ie;
private Raccoom.Windows.Forms.TreeViewOpmlDocument treeView2;
private Raccoom.Windows.Forms.TreeViewOpmlDocument treeView1;
private Raccoom.Windows.Forms.DockingManagerExtender _dockingManager;
private Raccoom.Windows.Forms.RssFeedDataAdaptor _rssFeedDataAdaptor;
private EnvStatusBar _statusBar;
private System.Windows.Forms.MainMenu _mainMenu;
private System.Windows.Forms.ToolBar _toolBar;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.ToolBarButton toolBarButton1;
private System.Windows.Forms.ToolBarButton toolBarButton2;
private System.Windows.Forms.ToolBarButton toolBarButton3;
private System.ComponentModel.IContainer components;
private Actions.Action _actPrevious;
private Actions.Action _actNext;
private System.Windows.Forms.ImageList imageList1;
private Actions.Action _refresh;
private Actions.Action _actOrganize;
private Actions.Action _actAddFavorite;
private System.Windows.Forms.ToolBarButton toolBarButton4;
private System.Windows.Forms.ToolBarButton toolBarButton5;
private System.Windows.Forms.MenuItem menuItem9;
private System.Windows.Forms.ToolBarButton toolBarButton6;
private Actions.Action _actExit;
private Actions.Action _actAbout;
private System.Windows.Forms.ToolBarButton toolBarButton7;
private System.Windows.Forms.ToolBarButton toolBarButton9;
private System.Windows.Forms.MenuItem menuItem11;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem7;
private System.Windows.Forms.MenuItem menuItem8;
private Actions.ActionList _actionList;
#endregion
#region constructors
public RssUIManagerTest()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
this._ie.Dock = DockStyle.Fill;
this._rssFeedDataAdaptor.EnvironmentWindow = this;
this.treeView1.AllowDrop = true;
}
#endregion
#region public interface
#endregion
#region events
private void _actOrganize_Execute(object sender, System.EventArgs e)
{
this._rssFeedDataAdaptor.ShowOrganizeFavoriteDialog();
}
private void _actAddFavorite_Execute(object sender, System.EventArgs e)
{
this._rssFeedDataAdaptor.ShowNewFavoriteDialog();
}
private void _actExit_Execute(object sender, System.EventArgs e)
{
this.Close();
}
private void _actAbout_Execute(object sender, System.EventArgs e)
{
new Raccoom.Windows.Forms.FormAbout().ShowDialog();
}
private void _refresh_Execute(object sender, System.EventArgs e)
{
this._rssFeedDataAdaptor.Manager.Reset();
this._rssFeedDataAdaptor.Manager.Refresh();
}
#endregion
#region IEnvironmentWindow Members
public Raccoom.Windows.Forms.IProgressBarWindow Progress
{
get
{
return _envProgressBar;
}
}
public Raccoom.Windows.Forms.IStatusTextWindow Status
{
get
{
return this._statusBar;
}
}
#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(RssUIManagerTest));
this._envProgressBar = new Raccoom.Xml.Editors.EnvProgressBar();
this._actionList = new Actions.ActionList(this.components);
this._actPrevious = new Actions.Action(this.components);
this._actNext = new Actions.Action(this.components);
this._refresh = new Actions.Action(this.components);
this._actOrganize = new Actions.Action(this.components);
this._actAddFavorite = new Actions.Action(this.components);
this._actExit = new Actions.Action(this.components);
this._actAbout = new Actions.Action(this.components);
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton2 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton3 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton4 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton5 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton7 = new System.Windows.Forms.ToolBarButton();
this.menuItem9 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.menuItem8 = new System.Windows.Forms.MenuItem();
this._ie = new Raccoom.Xml.Editors.InternetExplorerRss();
this._dockingManager = new Raccoom.Windows.Forms.DockingManagerExtender(this.components);
this._toolBar = new System.Windows.Forms.ToolBar();
this.toolBarButton6 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton9 = new System.Windows.Forms.ToolBarButton();
this.treeView1 = new Raccoom.Windows.Forms.TreeViewOpmlDocument(this.components);
this.treeView2 = new Raccoom.Windows.Forms.TreeViewOpmlDocument(this.components);
this._rssFeedDataAdaptor = new Raccoom.Windows.Forms.RssFeedDataAdaptor(this.components);
this._statusBar = new Raccoom.Xml.Editors.EnvStatusBar();
this._mainMenu = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem11 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
((System.ComponentModel.ISupportInitialize)(this._rssFeedDataAdaptor)).BeginInit();
this.SuspendLayout();
//
// _envProgressBar
//
this._dockingManager.SetADockingEnable(this._envProgressBar, false);
this._envProgressBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this._dockingManager.SetCloseButton(this._envProgressBar, false);
this._dockingManager.SetCloseOnHide(this._envProgressBar, false);
this._dockingManager.SetDockingStyle(this._envProgressBar, System.Windows.Forms.DockStyle.Left);
this._dockingManager.SetFullTitle(this._envProgressBar, "_envProgressBar");
this._dockingManager.SetIcon(this._envProgressBar, null);
this._envProgressBar.Location = new System.Drawing.Point(320, 384);
this._envProgressBar.Name = "_envProgressBar";
this._envProgressBar.Size = new System.Drawing.Size(168, 8);
this._dockingManager.SetTabbedMode(this._envProgressBar, true);
this._envProgressBar.TabIndex = 4;
this._dockingManager.SetTitle(this._envProgressBar, "_envProgressBar");
this._envProgressBar.Value = 0;
this._envProgressBar.Visible = false;
//
// _actionList
//
this._actionList.Actions.AddRange(new Actions.Action[] {
this._actPrevious,
this._actNext,
this._refresh,
this._actOrganize,
this._actAddFavorite,
this._actExit,
this._actAbout});
this._actionList.Count = 7;
this._actionList.ImageList = this.imageList1;
this._actionList.ShowTextOnToolBar = false;
this._actionList.Tag = null;
//
// _actPrevious
//
this._actPrevious.Checked = false;
this._actPrevious.Enabled = true;
this._actPrevious.Hint = null;
this._actPrevious.ImageIndex = 0;
this._actPrevious.Shortcut = System.Windows.Forms.Shortcut.None;
this._actPrevious.Tag = null;
this._actPrevious.Text = "Back";
this._actPrevious.Visible = true;
//
// _actNext
//
this._actNext.Checked = false;
this._actNext.Enabled = true;
this._actNext.Hint = null;
this._actNext.ImageIndex = 1;
this._actNext.Shortcut = System.Windows.Forms.Shortcut.None;
this._actNext.Tag = null;
this._actNext.Text = "Forward";
this._actNext.Visible = true;
//
// _refresh
//
this._refresh.Checked = false;
this._refresh.Enabled = true;
this._refresh.Hint = null;
this._refresh.ImageIndex = 3;
this._refresh.Shortcut = System.Windows.Forms.Shortcut.F5;
this._refresh.Tag = null;
this._refresh.Text = "Refresh";
this._refresh.Visible = true;
this._refresh.Execute += new System.EventHandler(this._refresh_Execute);
//
// _actOrganize
//
this._actOrganize.Checked = false;
this._actOrganize.Enabled = true;
this._actOrganize.Hint = null;
this._actOrganize.ImageIndex = 2;
this._actOrganize.Shortcut = System.Windows.Forms.Shortcut.None;
this._actOrganize.Tag = null;
this._actOrganize.Text = "Organize Favorites...";
this._actOrganize.Visible = true;
this._actOrganize.Execute += new System.EventHandler(this._actOrganize_Execute);
//
// _actAddFavorite
//
this._actAddFavorite.Checked = false;
this._actAddFavorite.Enabled = true;
this._actAddFavorite.Hint = null;
this._actAddFavorite.ImageIndex = 7;
this._actAddFavorite.Shortcut = System.Windows.Forms.Shortcut.None;
this._actAddFavorite.Tag = null;
this._actAddFavorite.Text = "Add Favorites...";
this._actAddFavorite.Visible = true;
this._actAddFavorite.Execute += new System.EventHandler(this._actAddFavorite_Execute);
//
// _actExit
//
this._actExit.Checked = false;
this._actExit.Enabled = true;
this._actExit.Hint = null;
this._actExit.ImageIndex = 4;
this._actExit.Shortcut = System.Windows.Forms.Shortcut.None;
this._actExit.Tag = null;
this._actExit.Text = "Exit";
this._actExit.Visible = true;
this._actExit.Execute += new System.EventHandler(this._actExit_Execute);
//
// _actAbout
//
this._actAbout.Checked = false;
this._actAbout.Enabled = true;
this._actAbout.Hint = null;
this._actAbout.ImageIndex = 5;
this._actAbout.Shortcut = System.Windows.Forms.Shortcut.None;
this._actAbout.Tag = null;
this._actAbout.Text = "About";
this._actAbout.Visible = true;
this._actAbout.Execute += new System.EventHandler(this._actAbout_Execute);
//
// imageList1
//
this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth24Bit;
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// toolBarButton1
//
this._actionList.SetAction(this.toolBarButton1, this._actPrevious);
this.toolBarButton1.ImageIndex = 0;
//
// toolBarButton2
//
this._actionList.SetAction(this.toolBarButton2, this._actNext);
this.toolBarButton2.ImageIndex = 1;
//
// toolBarButton3
//
this._actionList.SetAction(this.toolBarButton3, this._refresh);
this.toolBarButton3.ImageIndex = 3;
this.toolBarButton3.ToolTipText = " (F5)";
//
// toolBarButton4
//
this._actionList.SetAction(this.toolBarButton4, this._actOrganize);
this.toolBarButton4.ImageIndex = 2;
//
// toolBarButton5
//
this._actionList.SetAction(this.toolBarButton5, this._actAddFavorite);
this.toolBarButton5.ImageIndex = 7;
//
// toolBarButton7
//
this._actionList.SetAction(this.toolBarButton7, this._actAbout);
this.toolBarButton7.ImageIndex = 5;
//
// menuItem9
//
this._actionList.SetAction(this.menuItem9, this._actExit);
this.menuItem9.Index = 0;
this.menuItem9.Text = "Exit";
//
// menuItem5
//
this._actionList.SetAction(this.menuItem5, this._actOrganize);
this.menuItem5.Index = 1;
this.menuItem5.Text = "Organize Favorites...";
//
// menuItem6
//
this._actionList.SetAction(this.menuItem6, this._actAddFavorite);
this.menuItem6.Index = 0;
this.menuItem6.Text = "Add Favorites...";
//
// menuItem7
//
this._actionList.SetAction(this.menuItem7, this._actPrevious);
this.menuItem7.Index = 0;
this.menuItem7.Text = "Back";
//
// menuItem8
//
this._actionList.SetAction(this.menuItem8, this._actNext);
this.menuItem8.Index = 1;
this.menuItem8.Text = "Forward";
//
// _ie
//
this._dockingManager.SetADockingEnable(this._ie, false);
this._dockingManager.SetCloseButton(this._ie, false);
this._dockingManager.SetCloseOnHide(this._ie, false);
this._dockingManager.SetDockingStyle(this._ie, System.Windows.Forms.DockStyle.Left);
this._dockingManager.SetFullTitle(this._ie, "_ie");
this._dockingManager.SetIcon(this._ie, null);
this._ie.Location = new System.Drawing.Point(296, 144);
this._ie.Name = "_ie";
this._dockingManager.SetTabbedMode(this._ie, true);
this._ie.TabIndex = 4;
this._dockingManager.SetTitle(this._ie, "_ie");
//
// _dockingManager
//
this._dockingManager.AutomaticStatePersistence = true;
this._dockingManager.ContainerControl = this;
this._dockingManager.InnerControl = this._ie;
this._dockingManager.OuterControl = this._toolBar;
this._dockingManager.PlainTabBorder = false;
this._dockingManager.VisualStyle = Crownwood.Magic.Common.VisualStyle.IDE;
//
// _toolBar
//
this._toolBar.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
this._toolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.toolBarButton1,
this.toolBarButton2,
this.toolBarButton6,
this.toolBarButton3,
this.toolBarButton4,
this.toolBarButton5,
this.toolBarButton9,
this.toolBarButton7});
this._toolBar.DropDownArrows = true;
this._toolBar.ImageList = this.imageList1;
this._toolBar.Location = new System.Drawing.Point(0, 0);
this._toolBar.Name = "_toolBar";
this._toolBar.ShowToolTips = true;
this._toolBar.Size = new System.Drawing.Size(520, 28);
this._toolBar.TabIndex = 9;
//
// toolBarButton6
//
this.toolBarButton6.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// toolBarButton9
//
this.toolBarButton9.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// 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.treeView1.Cursor = System.Windows.Forms.Cursors.Default;
this._dockingManager.SetDockingStyle(this.treeView1, System.Windows.Forms.DockStyle.Left);
this.treeView1.FullRowSelect = true;
this._dockingManager.SetFullTitle(this.treeView1, "treeView1");
this.treeView1.HotTracking = true;
this._dockingManager.SetIcon(this.treeView1, null);
this.treeView1.Location = new System.Drawing.Point(16, 176);
this.treeView1.Name = "treeView1";
this.treeView1.ShowLines = false;
this.treeView1.ShowPlusMinus = false;
this.treeView1.ShowRootLines = false;
this.treeView1.Size = new System.Drawing.Size(160, 192);
this._dockingManager.SetTabbedMode(this.treeView1, false);
this.treeView1.TabIndex = 6;
this._dockingManager.SetTitle(this.treeView1, "treeView1");
this.treeView1.ViewStyle = Raccoom.Windows.Forms.ViewStyle.Flat;
//
// 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, "treeView2");
this.treeView2.HotTracking = true;
this._dockingManager.SetIcon(this.treeView2, null);
this.treeView2.Location = new System.Drawing.Point(8, 32);
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 = 7;
this._dockingManager.SetTitle(this.treeView2, "treeView2");
this.treeView2.ViewStyle = Raccoom.Windows.Forms.ViewStyle.Flat;
//
// _rssFeedDataAdaptor
//
this._rssFeedDataAdaptor.Browser = this._ie;
this._rssFeedDataAdaptor.EnvironmentWindow = null;
this._rssFeedDataAdaptor.Favorites = this.treeView1;
this._rssFeedDataAdaptor.History = this.treeView2;
//
// _statusBar
//
this._statusBar.Location = new System.Drawing.Point(0, 376);
this._statusBar.Name = "_statusBar";
this._statusBar.Size = new System.Drawing.Size(520, 22);
this._statusBar.TabIndex = 8;
//
// _mainMenu
//
this._mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem4,
this.menuItem11,
this.menuItem2});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem9});
this.menuItem1.Text = "&File";
//
// menuItem4
//
this.menuItem4.Index = 1;
this.menuItem4.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem7,
this.menuItem8});
this.menuItem4.Text = "&View";
//
// menuItem11
//
this.menuItem11.Index = 2;
this.menuItem11.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem6,
this.menuItem5});
this.menuItem11.Text = "&Favorites";
//
// menuItem2
//
this.menuItem2.Index = 3;
this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem3});
this.menuItem2.Text = "?";
//
// menuItem3
//
this.menuItem3.Index = 0;
this.menuItem3.Text = "&About";
//
// RssUIManagerTest
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(800, 640);
this.Controls.Add(this._envProgressBar);
this.Controls.Add(this._ie);
this.Controls.Add(this.treeView2);
this.Controls.Add(this.treeView1);
this.Controls.Add(this._toolBar);
this.Controls.Add(this._statusBar);
this.Menu = this._mainMenu;
this.Name = "RssUIManagerTest";
this.Text = "RssUIManagerTest";
((System.ComponentModel.ISupportInitialize)(this._rssFeedDataAdaptor)).EndInit();
this.ResumeLayout(false);
}
#endregion
}
public class InternetExplorerRss : UserControl, Raccoom.Windows.Forms.IRssFeedDataAdaptorRssView
{
private WebBrowser _axWebBrowserHtml;
public InternetExplorerRss()
{
this._axWebBrowserHtml = new WebBrowser();
this.Controls.Add(this._axWebBrowserHtml);
_axWebBrowserHtml.Dock = DockStyle.Fill;
_axWebBrowserHtml.Visible = true;
}
public void Populate(OpmlOutlineFavorite favorite, IRssChannel channel)
{
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"))
{
channel.Transform(new System.Xml.XmlTextReader(styleSheetStream), fileNameHtml);
}
//
NavigateHtml(fileNameHtml);
}
catch (System.Exception ex)
{
NavigateHtml("http://feedvalidator.org/check?url="+favorite.XmlUrl);
throw ex;
}
}
private void NavigateHtml(string url)
{
this._axWebBrowserHtml.Navigate(url);
}
}
public class EnvStatusBar : StatusBar, Raccoom.Windows.Forms.IStatusTextWindow
{
#region IStatusTextWindow Members
public void SetStatusText(string text)
{
this.Text = text;
}
#endregion
}
public class EnvProgressBar : UserControl, Raccoom.Windows.Forms.IProgressBarWindow
{
private ProgressBar _progressBar;
public EnvProgressBar()
{
_progressBar = new ProgressBar();
_progressBar.Dock = DockStyle.Fill;
this.Controls.Add(_progressBar);
}
#region IProgressBarWindow Members
public void Init(int min, int max)
{
_progressBar.Minimum = min;
_progressBar.Maximum = max;
this.Visible = true;
}
public int Value
{
get
{
return _progressBar.Value;
}
set
{
_progressBar.Value = value;
//
if(value==_progressBar.Maximum)
{
System.Windows.Forms.Timer timer = new Timer();
timer.Interval = 500;
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
}
}
}
public void Abort()
{
this.Visible = false;
}
#endregion
private void timer_Tick(object sender, EventArgs e)
{
Timer timer = (Timer) sender;
timer.Stop();
timer.Dispose();
//
this.Visible = false;
}
}
}