Back to index

lightning-sunbird  0.9+nobinonly
BookmarksWindow.cs
Go to the documentation of this file.
00001 /* -*- Mode: C#; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is Manticore.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Silverstone Interactive.
00020  * Portions created by the Initial Developer are Copyright (C) 2001
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Ben Goodger <ben@netscape.com> (Original Author)
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 namespace Silverstone.Manticore.Bookmarks
00041 {
00042   using System;
00043   using System.Drawing;
00044   using System.Collections;
00045   using System.ComponentModel;
00046   using System.Windows.Forms;
00047 
00048   using Silverstone.Manticore.App;
00049   using Silverstone.Manticore.Core;
00050   using Silverstone.Manticore.Toolkit;
00051   using Silverstone.Manticore.Bookmarks;
00052   using Silverstone.Manticore.Browser;
00053 
00057        public class BookmarksWindow : ManticoreWindow
00058        {
00059     private StatusBar mStatusBar;
00060     private StatusBarPanel mStatusBarPanel;
00061     private BookmarksTreeView mBookmarksTree;
00062 
00063     private BaseTreeBuilder mBuilder = null;
00064 
00065               public BookmarksWindow()
00066               {
00067       mType = "BookmarksWindow";
00068       
00069       Init();
00070     }
00071 
00072     protected void Init()
00073     {
00074       // Set up UI
00075       InitializeComponent();
00076 
00077       base.Init();
00078     }
00079     
00080     #region Windows Form Designer generated code
00081 
00082 
00083 
00084 
00085               private void InitializeComponent()
00086               {
00087       mStatusBar = new StatusBar();
00088       mStatusBarPanel = new StatusBarPanel();
00089       ((ISupportInitialize)mStatusBarPanel).BeginInit();
00090       SuspendLayout();
00091 
00092       mStatusBar.Name = "statusBar";
00093       mStatusBar.Panels.Add(mStatusBarPanel);
00094       mStatusBar.TabIndex = 0;
00095       mStatusBar.Text = "";
00096       mStatusBarPanel.Text = "";
00097       Controls.Add(mStatusBar);
00098 
00099       mBookmarksTree = new BookmarksTreeView("BookmarksRoot");
00100       mBookmarksTree.Dock = DockStyle.Fill;
00101       mBookmarksTree.ImageIndex = -1;
00102       mBookmarksTree.Name = "bookmarksTree";
00103       mBookmarksTree.SelectedImageIndex = -1;
00104       mBookmarksTree.Size = new System.Drawing.Size(584, 409);
00105       mBookmarksTree.TabIndex = 1;
00106 
00107       mBookmarksTree.AfterSelect += new TreeViewEventHandler(OnTreeAfterSelect);
00108       mBookmarksTree.DoubleClick += new EventHandler(OnTreeDoubleClick);
00109 
00110       Controls.Add(mBookmarksTree);
00111       mBookmarksTree.Build();
00112 
00113       
00114       AutoScaleBaseSize = new System.Drawing.Size(5, 13);
00115       ClientSize = new System.Drawing.Size(584, 429);
00116       Name = "BookmarksWindow";
00117       Text = Environment.UserName + "'s Bookmarks";
00118       ((ISupportInitialize)(mStatusBarPanel)).EndInit();
00119       ResumeLayout(false);
00120     }
00121               #endregion
00122 
00123     protected void OnTreeAfterSelect(Object sender, TreeViewEventArgs e)
00124     {
00125       ManticoreTreeNode node = e.Node as ManticoreTreeNode;
00126       Bookmarks bmks = ServiceManager.Bookmarks;
00127       String bookmarkURL = bmks.GetBookmarkAttribute(node.Data as String, "url");
00128       mStatusBar.Text = bookmarkURL;
00129     }
00130 
00131     protected void OnTreeDoubleClick(Object sender, EventArgs e)
00132     {
00133       ManticoreTreeNode node = mBookmarksTree.SelectedNode as ManticoreTreeNode;
00134       Bookmarks bmks = ServiceManager.Bookmarks;
00135       String bookmarkURL = bmks.GetBookmarkAttribute(node.Data as String, "url");
00136       if (bookmarkURL != "") 
00137       {
00138         WindowMediator wm = ServiceManager.WindowMediator;
00139         BrowserWindow window = wm.GetMostRecentWindow("BrowserWindow") as BrowserWindow;
00140         if (window != null)
00141           window.LoadURL(bookmarkURL);
00142       }
00143     }
00144 
00145        }
00146 }