1 /* -*- Mode: C#; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is Manticore.
18 * The Initial Developer of the Original Code is
19 * Silverstone Interactive.
20 * Portions created by the Initial Developer are Copyright (C) 2001
21 * the Initial Developer. All Rights Reserved.
24 * Ben Goodger <ben@netscape.com> (Original Author)
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 namespace Silverstone
.Manticore
.Bookmarks
44 using System
.Collections
;
45 using System
.ComponentModel
;
46 using System
.Windows
.Forms
;
48 using Silverstone
.Manticore
.Toolkit
;
49 using Silverstone
.Manticore
.Core
;
52 /// Summary description for FileBookmark.
54 public class FileBookmark
: System
.Windows
.Forms
.Form
59 private BookmarksTreeView mFolderTree
;
60 private Button mOKButton
;
61 private Button mCancelButton
;
62 private Button mUseDefaultButton
;
63 private Button mNewFolderButton
;
64 private TextBox mLocationField
;
65 private TextBox mNameField
;
67 /// Required designer variable.
69 private System
.ComponentModel
.Container components
= null;
71 public FileBookmark(String aURL
, String aTitle
)
74 // Required for Windows Form Designer support
76 InitializeComponent();
78 mNameField
.Text
= aTitle
;
79 mLocationField
.Text
= aURL
;
82 // Button XP Theme support.
84 mOKButton
.FlatStyle
= FlatStyle
.System
;
85 mCancelButton
.FlatStyle
= FlatStyle
.System
;
86 mUseDefaultButton
.FlatStyle
= FlatStyle
.System
;
87 mNewFolderButton
.FlatStyle
= FlatStyle
.System
;
92 mFolderTree
= new BookmarksTreeView("BookmarksRoot");
93 mFolderTree
.Anchor
= (((System
.Windows
.Forms
.AnchorStyles
.Top
| System
.Windows
.Forms
.AnchorStyles
.Bottom
)
94 | System
.Windows
.Forms
.AnchorStyles
.Left
)
95 | System
.Windows
.Forms
.AnchorStyles
.Right
);
96 mFolderTree
.ImageIndex
= -1;
97 mFolderTree
.Location
= new System
.Drawing
.Point(64, 88);
98 mFolderTree
.Name
= "folderTree";
99 mFolderTree
.SelectedImageIndex
= -1;
100 mFolderTree
.Size
= new System
.Drawing
.Size(208, 144);
101 mFolderTree
.TabIndex
= 5;
103 // Only show folders in this |TreeView|
104 mFolderTree
.AddCriteria(new String
[] {"container", "true"}
);
106 Controls
.Add(mFolderTree
);
109 Bitmap bmp
= new Bitmap(@"resources\bookmark.png");
110 bmp
.MakeTransparent(ColorTranslator
.FromOle(0x00FF00));
111 // this.Icon = new Icon(
115 /// Clean up any resources being used.
117 protected override void Dispose(bool aDisposing
)
119 if (aDisposing
&& components
!= null)
120 components
.Dispose();
121 base.Dispose(aDisposing
);
124 #region Windows Form Designer generated code
126 /// Required method for Designer support - do not modify
127 /// the contents of this method with the code editor.
129 private void InitializeComponent()
131 this.mLocationField
= new System
.Windows
.Forms
.TextBox();
132 this.mCancelButton
= new System
.Windows
.Forms
.Button();
133 this.mNameField
= new System
.Windows
.Forms
.TextBox();
134 this.mNewFolderButton
= new System
.Windows
.Forms
.Button();
135 this.mUseDefaultButton
= new System
.Windows
.Forms
.Button();
136 this.mOKButton
= new System
.Windows
.Forms
.Button();
137 this.label1
= new System
.Windows
.Forms
.Label();
138 this.label2
= new System
.Windows
.Forms
.Label();
139 this.label3
= new System
.Windows
.Forms
.Label();
140 this.SuspendLayout();
144 this.mLocationField
.Anchor
= ((System
.Windows
.Forms
.AnchorStyles
.Top
| System
.Windows
.Forms
.AnchorStyles
.Left
)
145 | System
.Windows
.Forms
.AnchorStyles
.Right
);
146 this.mLocationField
.Location
= new System
.Drawing
.Point(64, 48);
147 this.mLocationField
.Name
= "mLocationField";
148 this.mLocationField
.Size
= new System
.Drawing
.Size(296, 20);
149 this.mLocationField
.TabIndex
= 3;
150 this.mLocationField
.Text
= "";
154 this.mCancelButton
.Anchor
= (System
.Windows
.Forms
.AnchorStyles
.Bottom
| System
.Windows
.Forms
.AnchorStyles
.Right
);
155 this.mCancelButton
.DialogResult
= System
.Windows
.Forms
.DialogResult
.Cancel
;
156 this.mCancelButton
.Location
= new System
.Drawing
.Point(288, 248);
157 this.mCancelButton
.Name
= "mCancelButton";
158 this.mCancelButton
.TabIndex
= 9;
159 this.mCancelButton
.Text
= "Cancel";
163 this.mNameField
.Anchor
= ((System
.Windows
.Forms
.AnchorStyles
.Top
| System
.Windows
.Forms
.AnchorStyles
.Left
)
164 | System
.Windows
.Forms
.AnchorStyles
.Right
);
165 this.mNameField
.Location
= new System
.Drawing
.Point(64, 16);
166 this.mNameField
.Name
= "mNameField";
167 this.mNameField
.Size
= new System
.Drawing
.Size(296, 20);
168 this.mNameField
.TabIndex
= 1;
169 this.mNameField
.Text
= "";
173 this.mNewFolderButton
.Anchor
= (System
.Windows
.Forms
.AnchorStyles
.Top
| System
.Windows
.Forms
.AnchorStyles
.Right
);
174 this.mNewFolderButton
.Location
= new System
.Drawing
.Point(280, 88);
175 this.mNewFolderButton
.Name
= "mNewFolderButton";
176 this.mNewFolderButton
.Size
= new System
.Drawing
.Size(80, 23);
177 this.mNewFolderButton
.TabIndex
= 6;
178 this.mNewFolderButton
.Text
= "Ne&w Folder...";
179 this.mNewFolderButton
.Click
+= new System
.EventHandler(this.mNewFolderButton_Click
);
183 this.mUseDefaultButton
.Anchor
= (System
.Windows
.Forms
.AnchorStyles
.Top
| System
.Windows
.Forms
.AnchorStyles
.Right
);
184 this.mUseDefaultButton
.Location
= new System
.Drawing
.Point(280, 120);
185 this.mUseDefaultButton
.Name
= "mUseDefaultButton";
186 this.mUseDefaultButton
.Size
= new System
.Drawing
.Size(80, 23);
187 this.mUseDefaultButton
.TabIndex
= 7;
188 this.mUseDefaultButton
.Text
= "Use &Default";
192 this.mOKButton
.Anchor
= (System
.Windows
.Forms
.AnchorStyles
.Bottom
| System
.Windows
.Forms
.AnchorStyles
.Right
);
193 this.mOKButton
.Location
= new System
.Drawing
.Point(208, 248);
194 this.mOKButton
.Name
= "mOKButton";
195 this.mOKButton
.TabIndex
= 8;
196 this.mOKButton
.Text
= "OK";
197 this.mOKButton
.Click
+= new System
.EventHandler(this.mOKButton_Click
);
201 this.label1
.AutoSize
= true;
202 this.label1
.Location
= new System
.Drawing
.Point(8, 16);
203 this.label1
.Name
= "label1";
204 this.label1
.Size
= new System
.Drawing
.Size(38, 13);
205 this.label1
.TabIndex
= 0;
206 this.label1
.Text
= "&Name:";
210 this.label2
.AutoSize
= true;
211 this.label2
.Location
= new System
.Drawing
.Point(8, 48);
212 this.label2
.Name
= "label2";
213 this.label2
.Size
= new System
.Drawing
.Size(50, 13);
214 this.label2
.TabIndex
= 2;
215 this.label2
.Text
= "&Location:";
219 this.label3
.AutoSize
= true;
220 this.label3
.Location
= new System
.Drawing
.Point(8, 88);
221 this.label3
.Name
= "label3";
222 this.label3
.Size
= new System
.Drawing
.Size(53, 13);
223 this.label3
.TabIndex
= 4;
224 this.label3
.Text
= "Create in:";
228 this.AcceptButton
= this.mOKButton
;
229 this.AutoScaleBaseSize
= new System
.Drawing
.Size(5, 13);
230 this.CancelButton
= this.mCancelButton
;
231 this.ClientSize
= new System
.Drawing
.Size(376, 277);
232 this.ControlBox
= false;
233 this.Controls
.AddRange(new System
.Windows
.Forms
.Control
[] {
236 this.mUseDefaultButton
,
237 this.mNewFolderButton
,
243 this.MinimumSize
= new System
.Drawing
.Size(384, 300);
244 this.Name
= "FileBookmark";
245 this.ShowInTaskbar
= false;
246 this.SizeGripStyle
= System
.Windows
.Forms
.SizeGripStyle
.Show
;
247 this.Text
= "File Bookmark";
248 this.ResumeLayout(false);
253 private void mNewFolderButton_Click(object sender
, System
.EventArgs e
)
255 mFolderTree
.NewFolder();
258 private void mOKButton_Click(object sender
, System
.EventArgs e
)
260 String destinationFolder
= "Bookmarks"; // XXX Parameterize this
261 ManticoreTreeNode node
= mFolderTree
.SelectedNode
as ManticoreTreeNode
;
263 destinationFolder
= node
.Data
as String
;
264 Bookmarks bmks
= ServiceManager
.Bookmarks
;
265 String bookmarkID
= bmks
.CreateBookmark(mNameField
.Text
, destinationFolder
, -1);
266 bmks
.SetBookmarkAttribute(bookmarkID
, "url", mLocationField
.Text
);