PageRenderTime 293ms CodeModel.GetById 101ms app.highlight 103ms RepoModel.GetById 78ms app.codeStats 0ms

/IZWebFileManager/FileView.cs

http://izwebfilemanager.googlecode.com/
C# | 982 lines | 790 code | 139 blank | 53 comment | 101 complexity | b79a648b9ad9c0468360df7086868be2 MD5 | raw file
  1// Copyright (C) 2006 Igor Zelmanovich <izwebfilemanager@gmail.com>
  2//
  3// This program is free software; you can redistribute it and/or modify
  4// it under the terms of the GNU General Public License as published by
  5// the Free Software Foundation; either version 2 of the License, or
  6// (at your option) any later version.
  7//
  8// This program is distributed in the hope that it will be useful,
  9// but WITHOUT ANY WARRANTY; without even the implied warranty of
 10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 11// GNU General Public License for more details.
 12//
 13// You should have received a copy of the GNU General Public License
 14// along with this program; if not, write to the Free Software
 15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 16
 17using System;
 18using System.Collections.Generic;
 19using System.ComponentModel;
 20using System.Text;
 21using System.Web;
 22using System.Web.UI;
 23using System.Web.UI.WebControls;
 24using IZ.WebFileManager.Components;
 25using System.IO;
 26using System.Text.RegularExpressions;
 27using System.Collections;
 28using System.Drawing;
 29using System.Globalization;
 30using System.Collections.Specialized;
 31
 32namespace IZ.WebFileManager
 33{
 34	[DefaultProperty ("Text")]
 35	[ToolboxData ("<{0}:FileView runat=\"server\" width=\"400\" height=\"300\"></{0}:FileView>")]
 36	public sealed class FileView : FileManagerControlBase
 37	{
 38		#region Constructors
 39
 40		public FileView () : base () { InitializeDefaults (); }
 41		public FileView (FileManagerController controller) : base (controller) { InitializeDefaults (); }
 42
 43		#endregion
 44
 45		#region Fields
 46
 47		BorderedPanelStyle _detailsColumnHeaderStyle;
 48		Style _editTextBoxStyle;
 49		Style _itemStyle;
 50		Style _selectedItemStyle;
 51		Style _detailsSortedColumnStyle;
 52		StringBuilder _initScript = new StringBuilder ();
 53		ContextMenu _contextMenu;
 54		ContextMenu _selectedItemsContextMenu;
 55
 56		// control state fields
 57		FileViewRenderMode _view = FileViewRenderMode.Icons;
 58		SortMode _sort = SortMode.Name;
 59		SortDirection _sortDirection;
 60		bool _showInGroups;
 61		string _directory;
 62		FileManagerItemInfo _currentDirectory;
 63
 64		#endregion
 65
 66		#region Properties
 67
 68		[PersistenceMode (PersistenceMode.InnerProperty)]
 69		[Category ("Appearance")]
 70		public BorderedPanelStyle DetailsColumnHeaderStyle {
 71			get {
 72				if (_detailsColumnHeaderStyle == null) {
 73					_detailsColumnHeaderStyle = new BorderedPanelStyle ();
 74					_detailsColumnHeaderStyle.Height = Unit.Pixel (17);
 75					_detailsColumnHeaderStyle.BackColor = Color.FromArgb (0xebeadb);
 76					_detailsColumnHeaderStyle.BackImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.detailscolumnheader_RB.gif");
 77					_detailsColumnHeaderStyle.OuterBorderLeftImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.detailscolumnheader_R.gif");
 78					_detailsColumnHeaderStyle.Font.Bold = false;
 79					_detailsColumnHeaderStyle.PaddingLeft = Unit.Pixel (4);
 80					_detailsColumnHeaderStyle.PaddingRight = Unit.Pixel (4);
 81					_detailsColumnHeaderStyle.PaddingTop = Unit.Pixel (3);
 82					_detailsColumnHeaderStyle.OuterBorderStyle = OuterBorderStyle.Left;
 83					_detailsColumnHeaderStyle.OuterBorderLeftWidth = Unit.Pixel (2);
 84
 85					if (IsTrackingViewState)
 86						((IStateManager) _detailsColumnHeaderStyle).TrackViewState ();
 87				}
 88				return _detailsColumnHeaderStyle;
 89			}
 90		}
 91
 92		[PersistenceMode (PersistenceMode.InnerProperty)]
 93		[Category ("Appearance")]
 94		public Style DetailsSortedColumnStyle {
 95			get {
 96				if (_detailsSortedColumnStyle == null) {
 97					_detailsSortedColumnStyle = new Style ();
 98					_detailsSortedColumnStyle.BackColor = Color.FromArgb (0xF7F7F7);
 99
100					if (IsTrackingViewState)
101						((IStateManager) _detailsSortedColumnStyle).TrackViewState ();
102				}
103				return _detailsSortedColumnStyle;
104			}
105		}
106
107		[PersistenceMode (PersistenceMode.InnerProperty)]
108		[Category ("Appearance")]
109		public Style SelectedItemStyle {
110			get {
111				if (_selectedItemStyle == null) {
112					_selectedItemStyle = new Style ();
113					_selectedItemStyle.ForeColor = Color.White;
114					_selectedItemStyle.BackColor = Color.FromArgb (0x316AC5);
115
116					if (IsTrackingViewState)
117						((IStateManager) _selectedItemStyle).TrackViewState ();
118				}
119				return _selectedItemStyle;
120			}
121		}
122
123		[PersistenceMode (PersistenceMode.InnerProperty)]
124		[Category ("Appearance")]
125		public Style ItemStyle {
126			get {
127				if (_itemStyle == null) {
128					_itemStyle = new Style ();
129
130					if (IsTrackingViewState)
131						((IStateManager) _itemStyle).TrackViewState ();
132				}
133				return _itemStyle;
134			}
135		}
136
137		[PersistenceMode (PersistenceMode.InnerProperty)]
138		[Category ("Appearance")]
139		public Style EditTextBoxStyle {
140			get {
141				if (_editTextBoxStyle == null) {
142					_editTextBoxStyle = new Style ();
143					_editTextBoxStyle.BorderStyle = BorderStyle.Solid;
144					_editTextBoxStyle.BorderWidth = Unit.Pixel (1);
145					_editTextBoxStyle.BorderColor = Color.Black;
146					_editTextBoxStyle.Font.Names = new string [] { "Tahoma", "Verdana", "Geneva", "Arial", "Helvetica", "sans-serif" };
147					_editTextBoxStyle.Font.Size = FontUnit.Parse ("11px", null);
148
149					if (IsTrackingViewState)
150						((IStateManager) _editTextBoxStyle).TrackViewState ();
151				}
152				return _editTextBoxStyle;
153			}
154		}
155
156		[Bindable (true)]
157		[Category ("Data")]
158		[DefaultValue ("[0]/")]
159		[Localizable (false)]
160		[Themeable (false)]
161		public string Directory {
162			get { return _directory == null ? "[0]/" : _directory; }
163			internal set {
164				_directory = value;
165				_currentDirectory = null;
166			}
167		}
168
169		string [] selectedItemsStr;
170		FileManagerItemInfo [] selectedItems;
171		public override FileManagerItemInfo [] SelectedItems {
172			get {
173				if (selectedItems == null) {
174					if (selectedItemsStr == null || selectedItemsStr.Length == 0)
175						selectedItems = new FileManagerItemInfo [0];
176					else {
177						ArrayList selectedItemsArray = new ArrayList ();
178						FileManagerItemInfo dir = GetCurrentDirectory ();
179						foreach (string name in selectedItemsStr) {
180							FileManagerItemInfo itemInfo = ResolveFileManagerItemInfo (name);
181							selectedItemsArray.Add (itemInfo);
182						}
183						selectedItems = (FileManagerItemInfo []) selectedItemsArray.ToArray (typeof (FileManagerItemInfo));
184					}
185				}
186				return selectedItems;
187			}
188		}
189
190		public override FileManagerItemInfo CurrentDirectory {
191			get {
192				if (_currentDirectory == null)
193					_currentDirectory = Controller.ResolveFileManagerItemInfo (Directory);
194				return _currentDirectory;
195			}
196		}
197
198		[Bindable (true)]
199		[Category ("Appearance")]
200		[DefaultValue (false)]
201		[Localizable (false)]
202		private bool ShowInGroups {
203			get { return _showInGroups; }
204			set { _showInGroups = value; }
205		}
206
207		[Bindable (true)]
208		[Category ("Appearance")]
209		[DefaultValue (FileViewRenderMode.Icons)]
210		[Localizable (false)]
211		public FileViewRenderMode View {
212			get { return _view; }
213			set { _view = value; }
214		}
215
216		[Bindable (true)]
217		[Category ("Appearance")]
218		[DefaultValue (SortMode.Name)]
219		[Localizable (false)]
220		public SortMode Sort {
221			get { return _sort; }
222			set { _sort = value; }
223		}
224
225		[Bindable (true)]
226		[Category ("Appearance")]
227		[DefaultValue (SortDirection.Ascending)]
228		[Localizable (false)]
229		public SortDirection SortDirection {
230			get { return _sortDirection; }
231			set { _sortDirection = value; }
232		}
233
234		[Bindable (true)]
235		[Category ("Behavior")]
236		[DefaultValue (false)]
237		[Localizable (false)]
238		public bool UseLinkToOpenItem {
239			get { return (bool) (ViewState ["UseLinkToOpenItem"] ?? false); }
240			set { ViewState ["UseLinkToOpenItem"] = value; }
241		}
242
243		[Bindable (true)]
244		[Category ("Behavior")]
245		[DefaultValue ("_blank")]
246		[Localizable (false)]
247		public string LinkToOpenItemTarget {
248			get { return (string) (ViewState ["LinkToOpenItemTarget"] ?? "_blank"); }
249			set { ViewState ["LinkToOpenItemTarget"] = value; }
250		}
251
252		internal string LinkToOpenItemClass {
253			get { return "linkToOpenItem" + ClientID; }
254		}
255
256		#endregion
257
258		#region Methods
259
260		private void InitializeDefaults () {
261			LinkToOpenItemTarget = "_blank";
262		}
263
264		protected internal override string RenderContents () {
265			StringBuilder sb = new StringBuilder ();
266			HtmlTextWriter writer = new HtmlTextWriter (new StringWriter (sb, null));
267			RenderContents (writer);
268			return sb.ToString ();
269		}
270
271		protected override void RenderContents (HtmlTextWriter writer) {
272			if (DesignMode)
273				return;
274
275			DirectoryInfo directoryInfo = GetCurrentDirectory ().Directory;
276
277			FileViewRender render = FileViewRender.GetRender (this);
278			DirectoryProvider provider = new DirectoryProvider (directoryInfo, Sort, SortDirection);
279
280			render.RenderBeginList (writer);
281
282			//FileViewItem upDirectory = new FileViewUpDirectoryItem(directoryInfo.Parent, this);
283			//render.RenderItem(output, upDirectory);
284
285			//if (ShowInGroups) {
286			//    GroupInfo [] groups = provider.GetGroups ();
287			//    foreach (GroupInfo group in groups) {
288			//        render.RenderBeginGroup (writer, group);
289			//        foreach (FileSystemInfo fsi in provider.GetFileSystemInfos (group)) {
290			//            FileViewItem item = new FileViewItem (fsi, this);
291			//            render.RenderItem (writer, item);
292			//        }
293
294			//        render.RenderEndGroup (writer, group);
295			//    }
296			//}
297			//else {
298				foreach (FileSystemInfo fsi in provider.GetFileSystemInfos ()) {
299					FileViewItem item = new FileViewItem (fsi, this);
300					
301					if (!ShowHiddenFilesAndFolders && item.Hidden)
302						continue;
303
304					render.RenderItem (writer, item);
305				}
306			//}
307
308			render.RenderEndList (writer);
309			RenderInitScript (writer);
310		}
311
312		private void RenderInitScript (HtmlTextWriter output) {
313			output.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_InitScript");
314			output.AddStyleAttribute (HtmlTextWriterStyle.Display, "none");
315			output.AddStyleAttribute (HtmlTextWriterStyle.Visibility, "hidden");
316			output.AddStyleAttribute (HtmlTextWriterStyle.Position, "absolute");
317			output.RenderBeginTag (HtmlTextWriterTag.Div);
318			output.Write (_initScript.ToString ());
319			output.Write (FileManagerController.ClientScriptObjectNamePrefix + ClientID + ".Items = new Array(" + String.Join (",", (string []) itemIds.ToArray (typeof (string))) + ");\r\n");
320			output.Write (FileManagerController.ClientScriptObjectNamePrefix + ClientID + ".ClearSelectedItems();\r\n");
321			output.RenderEndTag ();
322		}
323
324		internal override FileManagerItemInfo GetCurrentDirectory () {
325			return Controller.ResolveFileManagerItemInfo (Directory);
326		}
327
328		int _itemIndex;
329		ArrayList itemIds = new ArrayList ();
330		internal void RenderItemBeginTag (HtmlTextWriter output, FileViewItem item) {
331			string id = ClientID + "_Item_" + _itemIndex;
332			item.ClientID = id;
333
334			int fileType = -2; //is Directory
335			if (item.FileSystemInfo is FileInfo) {
336				FileInfo file = (FileInfo) item.FileSystemInfo;
337				FileType ft = Controller.GetFileType (file);
338				if (ft != null)
339					fileType = Controller.FileTypes.IndexOf (ft);
340				else
341					fileType = -1;
342			}
343
344			itemIds.Add (id);
345
346			output.AddAttribute (HtmlTextWriterAttribute.Id, id);
347			output.RenderBeginTag (HtmlTextWriterTag.Div);
348
349			// trace init script 
350			_initScript.AppendLine ("var " + id + " = document.getElementById('" + id + "');");
351			_initScript.AppendLine (FileManagerController.ClientScriptObjectNamePrefix + ClientID + ".InitItem(" + id + ",'" + FileManagerController.EncodeURIComponent (item.Name) + "'," + (item.IsDirectory ? "true" : "false") + "," + (item.CanBeRenamed ? "true" : "false") + "," + "false" + "," + fileType + ");");
352
353			_itemIndex++;
354		}
355
356		[System.Diagnostics.CodeAnalysis.SuppressMessage ("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
357		internal void RenderItemEndTag (HtmlTextWriter output) {
358			output.RenderEndTag ();
359		}
360
361		public override void RenderBeginTag (HtmlTextWriter writer) {
362			if (writer == null)
363				throw new ArgumentNullException ("writer");
364
365			writer.AddStyleAttribute (HtmlTextWriterStyle.Position, "absolute");
366			writer.AddStyleAttribute (HtmlTextWriterStyle.ZIndex, "100");
367			writer.AddStyleAttribute (HtmlTextWriterStyle.Visibility, "hidden");
368			writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_ContextMenu");
369			writer.RenderBeginTag (HtmlTextWriterTag.Div);
370			_contextMenu.RenderControl (writer);
371			writer.RenderEndTag ();
372
373			writer.AddStyleAttribute (HtmlTextWriterStyle.Position, "absolute");
374			writer.AddStyleAttribute (HtmlTextWriterStyle.ZIndex, "100");
375			writer.AddStyleAttribute (HtmlTextWriterStyle.Visibility, "hidden");
376			writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_SelectedItemsContextMenu");
377			writer.RenderBeginTag (HtmlTextWriterTag.Div);
378			_selectedItemsContextMenu.RenderControl (writer);
379			writer.RenderEndTag ();
380
381			RenderFocusTextBox (writer);
382			RenderEditTextBox (writer);
383
384			base.RenderBeginTag (writer);
385		}
386
387		void RenderEditTextBox (HtmlTextWriter writer) {
388			writer.AddStyleAttribute (HtmlTextWriterStyle.Position, "absolute");
389			writer.AddStyleAttribute (HtmlTextWriterStyle.ZIndex, "100");
390			writer.AddStyleAttribute (HtmlTextWriterStyle.Visibility, "hidden");
391			writer.AddStyleAttribute (HtmlTextWriterStyle.Display, "none");
392			writer.AddAttribute (HtmlTextWriterAttribute.Id, Controller.ClientID + "_TextBox");
393			writer.RenderBeginTag (HtmlTextWriterTag.Input);
394			writer.RenderEndTag ();
395		}
396
397		private void RenderFocusTextBox (HtmlTextWriter writer) {
398			writer.AddStyleAttribute (HtmlTextWriterStyle.BorderWidth, "0px");
399			writer.AddStyleAttribute (HtmlTextWriterStyle.Width, "1px");
400			writer.AddStyleAttribute (HtmlTextWriterStyle.BackgroundColor, "transparent");
401			writer.AddStyleAttribute (HtmlTextWriterStyle.Position, "absolute");
402			writer.AddAttribute (HtmlTextWriterAttribute.Type, "text");
403			writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_Focus");
404			writer.RenderBeginTag (HtmlTextWriterTag.Input);
405			writer.RenderEndTag ();
406		}
407
408
409		internal override FileManagerItemInfo ResolveFileManagerItemInfo (string path) {
410			string fileManagerPath;
411			if (String.IsNullOrEmpty (path))
412				fileManagerPath = Directory;
413			else if (path [0] == '[' || path [0] == '/')
414				fileManagerPath = path;
415			else
416				fileManagerPath = VirtualPathUtility.AppendTrailingSlash (Directory) + path;
417
418			return Controller.ResolveFileManagerItemInfo (fileManagerPath);
419		}
420
421		protected override object SaveViewState () {
422			object [] states = new object [6];
423
424			states [0] = base.SaveViewState ();
425			if (_detailsColumnHeaderStyle != null)
426				states [1] = ((IStateManager) _detailsColumnHeaderStyle).SaveViewState ();
427			if (_detailsSortedColumnStyle != null)
428				states [2] = ((IStateManager) _detailsSortedColumnStyle).SaveViewState ();
429			if (_editTextBoxStyle != null)
430				states [3] = ((IStateManager) _editTextBoxStyle).SaveViewState ();
431			if (_itemStyle != null)
432				states [4] = ((IStateManager) _itemStyle).SaveViewState ();
433			if (_selectedItemStyle != null)
434				states [5] = ((IStateManager) _selectedItemStyle).SaveViewState ();
435
436			for (int i = 0; i < states.Length; i++) {
437				if (states [i] != null)
438					return states;
439			}
440			return null;
441		}
442
443		protected override void LoadViewState (object savedState) {
444			if (savedState == null)
445				return;
446
447			object [] states = (object []) savedState;
448
449			base.LoadViewState (states [0]);
450			if (states [1] != null)
451				((IStateManager) DetailsColumnHeaderStyle).LoadViewState (states [1]);
452			if (states [2] != null)
453				((IStateManager) DetailsSortedColumnStyle).LoadViewState (states [2]);
454			if (states [3] != null)
455				((IStateManager) EditTextBoxStyle).LoadViewState (states [3]);
456			if (states [4] != null)
457				((IStateManager) ItemStyle).LoadViewState (states [4]);
458			if (states [5] != null)
459				((IStateManager) SelectedItemStyle).LoadViewState (states [5]);
460		}
461
462		protected override void TrackViewState () {
463			base.TrackViewState ();
464
465			if (_detailsColumnHeaderStyle != null)
466				((IStateManager) _detailsColumnHeaderStyle).TrackViewState ();
467			if (_detailsSortedColumnStyle != null)
468				((IStateManager) _detailsSortedColumnStyle).TrackViewState ();
469			if (_editTextBoxStyle != null)
470				((IStateManager) _editTextBoxStyle).TrackViewState ();
471			if (_itemStyle != null)
472				((IStateManager) _itemStyle).TrackViewState ();
473			if (_selectedItemStyle != null)
474				((IStateManager) _selectedItemStyle).TrackViewState ();
475		}
476
477		protected override object SaveControlState () {
478			RegisterHiddenField ("View", View.ToString ());
479			RegisterHiddenField ("Sort", Sort.ToString ());
480			RegisterHiddenField ("SortDirection", SortDirection.ToString ());
481			RegisterHiddenField ("ShowInGroups", ShowInGroups ? "true" : "false");
482			RegisterHiddenField ("Directory", FileManagerController.EncodeURIComponent (CurrentDirectory.FileManagerPath));
483			RegisterHiddenField ("SelectedItems", "");
484
485			return new object [] { base.SaveControlState () };
486		}
487
488		protected override void LoadControlState (object savedState) {
489			base.LoadControlState (((object []) savedState) [0]);
490
491			View = (FileViewRenderMode) Enum.Parse (typeof (FileViewRenderMode), GetValueFromHiddenField ("View"));
492			Sort = (SortMode) Enum.Parse (typeof (SortMode), GetValueFromHiddenField ("Sort"));
493			SortDirection = (SortDirection) Enum.Parse (typeof (SortDirection), GetValueFromHiddenField ("SortDirection"));
494			ShowInGroups = bool.Parse (GetValueFromHiddenField ("ShowInGroups"));
495			Directory = HttpUtility.UrlDecode (GetValueFromHiddenField ("Directory"));
496
497			string [] selectedItemsEncoded = GetValueFromHiddenField ("SelectedItems").Split (new char [] { ':' }, StringSplitOptions.RemoveEmptyEntries);
498			ArrayList selectedItemsArray = new ArrayList ();
499			foreach (string pathEncoded in selectedItemsEncoded) {
500				string path = HttpUtility.UrlDecode (pathEncoded);
501				selectedItemsArray.Add (path);
502			}
503
504			selectedItemsStr = (string []) selectedItemsArray.ToArray (typeof (string));
505		}
506
507		string GetInitInstanceScript () {
508
509			StringBuilder sb = new StringBuilder ();
510			string fileView = FileManagerController.ClientScriptObjectNamePrefix + ClientID;
511			sb.AppendLine ("var " + fileView + "=new FileView('" + ClientID + "','" + Controller.ClientID + "','" + ItemStyle.RegisteredCssClass + "','" + SelectedItemStyle.RegisteredCssClass + "','" + EditTextBoxStyle.RegisteredCssClass + "');");
512			sb.AppendLine (fileView + ".Initialize();");
513
514			return sb.ToString ();
515		}
516
517		protected override void OnInit (EventArgs e) {
518			base.OnInit (e);
519			Page.RegisterRequiresControlState (this);
520		}
521
522		protected override void OnPreRender (EventArgs e) {
523			base.OnPreRender (e);
524
525			Page.Header.StyleSheet.RegisterStyle (ItemStyle, this);
526			Page.Header.StyleSheet.RegisterStyle (SelectedItemStyle, this);
527			Page.Header.StyleSheet.RegisterStyle (EditTextBoxStyle, this);
528
529			if (UseLinkToOpenItem) {
530				Style linkStyle = new Style ();
531				linkStyle.Font.Underline = false;
532				Page.Header.StyleSheet.CreateStyleRule (linkStyle, this, "a." + LinkToOpenItemClass);
533
534				Style hoverLinkStyle = new Style ();
535				hoverLinkStyle.Font.Underline = true;
536				Page.Header.StyleSheet.CreateStyleRule (hoverLinkStyle, this, "a." + LinkToOpenItemClass + ":hover");
537
538				Style itemLinkStyle = new Style ();
539				itemLinkStyle.ForeColor = ItemStyle.ForeColor;
540				if (itemLinkStyle.ForeColor == Color.Empty)
541					itemLinkStyle.ForeColor = ForeColor;
542				Page.Header.StyleSheet.CreateStyleRule (itemLinkStyle, this, "." + ItemStyle.RegisteredCssClass + " a." + LinkToOpenItemClass);
543
544				Style selectedItemLinkStyle = new Style ();
545				selectedItemLinkStyle.ForeColor = SelectedItemStyle.ForeColor;
546				if (selectedItemLinkStyle.ForeColor == Color.Empty)
547					selectedItemLinkStyle.ForeColor = ForeColor;
548				Page.Header.StyleSheet.CreateStyleRule (selectedItemLinkStyle, this, "." + SelectedItemStyle.RegisteredCssClass + " a." + LinkToOpenItemClass);
549			}
550
551			Page.ClientScript.RegisterClientScriptResource (typeof (FileView), "IZ.WebFileManager.resources.FileView.js");
552			Page.ClientScript.RegisterStartupScript (typeof (FileView), ClientID, GetInitInstanceScript (), true);
553
554			CreateContextMenu ();
555			CreateSelectedItemsContextMenu ();
556		}
557
558		internal string GetSortEventReference (SortMode sort) {
559			return Controller.GetCommandEventReference (this, FileManagerCommands.FileViewSort.ToString (), "'" + sort.ToString () + "'");
560		}
561
562		protected override void AddAttributesToRender (HtmlTextWriter writer) {
563			base.AddAttributesToRender (writer);
564
565			writer.AddAttribute (HtmlTextWriterAttribute.Onclick, FileManagerController.ClientScriptObjectNamePrefix + ClientID + ".SetFocus()");
566			Controller.AddDirectionAttribute (writer);
567			writer.AddStyleAttribute (HtmlTextWriterStyle.Position, "relative");
568			writer.AddStyleAttribute (HtmlTextWriterStyle.ZIndex, "20");
569			writer.AddStyleAttribute (HtmlTextWriterStyle.Overflow, "auto");
570		}
571
572		void CreateContextMenu () {
573			_contextMenu = new ContextMenu ();
574			_contextMenu.EnableViewState = false;
575			_contextMenu.StaticEnableDefaultPopOutImage = false;
576			_contextMenu.DynamicEnableDefaultPopOutImage = false;
577			_contextMenu.Orientation = Orientation.Horizontal;
578			_contextMenu.SkipLinkText = String.Empty;
579			_contextMenu.StaticItemTemplate = new CompiledTemplateBuilder (new BuildTemplateMethod (CreateContextMenuRootItem));
580			_contextMenu.DynamicItemTemplate = new CompiledTemplateBuilder (new BuildTemplateMethod (CreateContextMenuPopupItem));
581			SetContextMenuStyle (_contextMenu);
582			Controls.Add (_contextMenu);
583
584			// Root
585			MenuItem root = new MenuItem ();
586			root.Text = "_contextMenu";
587			root.NavigateUrl = "javascript: return;";
588			_contextMenu.Items.Add (root);
589
590			string clientClickFunction = "javascript:" + FileManagerController.ClientScriptObjectNamePrefix + Controller.ClientID + ".On{0}(" + FileManagerController.ClientScriptObjectNamePrefix + ClientID + ", '{1}');return false;";
591
592			// View
593			MenuItem itemView = new MenuItem ();
594			itemView.Text = GetResourceString ("View", "View");
595			itemView.Value = "View";
596			itemView.NavigateUrl = "javascript: return;";
597			root.ChildItems.Add (itemView);
598
599			// Icons
600			MenuItem itemViewIcons = new MenuItem ();
601			itemViewIcons.Text = GetResourceString ("Icons", "Icons");
602			itemViewIcons.Value = "Icons";
603			itemViewIcons.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.FileViewChangeView, FileViewRenderMode.Icons);
604			itemView.ChildItems.Add (itemViewIcons);
605
606			// Details
607			MenuItem itemViewDetails = new MenuItem ();
608			itemViewDetails.Text = GetResourceString ("Details", "Details");
609			itemViewDetails.Value = "Details";
610			itemViewDetails.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.FileViewChangeView, FileViewRenderMode.Details);
611			itemView.ChildItems.Add (itemViewDetails);
612
613			if (Controller.SupportThumbnails) {
614				// Thumbnails
615				MenuItem itemViewThumbnails = new MenuItem ();
616				itemViewThumbnails.Text = GetResourceString ("Thumbnails", "Thumbnails");
617				itemViewThumbnails.Value = "Thumbnails";
618				itemViewThumbnails.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.FileViewChangeView, FileViewRenderMode.Thumbnails);
619				itemView.ChildItems.Add (itemViewThumbnails);
620			}
621
622			root.ChildItems.Add (new MenuItem ("__separator__", "__separator__", null, "javascript: return;"));
623
624			// Arrange Icons By
625			MenuItem itemArrangeIconsBy = new MenuItem ();
626			itemArrangeIconsBy.Text = GetResourceString ("Arrange_Icons_By", "Arrange Icons By");
627			itemArrangeIconsBy.Value = "Arrange_Icons_By";
628			itemArrangeIconsBy.NavigateUrl = "javascript: return;";
629			root.ChildItems.Add (itemArrangeIconsBy);
630
631			// Name
632			MenuItem itemArrangeIconsByName = new MenuItem ();
633			itemArrangeIconsByName.Text = GetResourceString ("Name", "Name");
634			itemArrangeIconsByName.Value = "Name";
635			itemArrangeIconsByName.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.FileViewSort, SortMode.Name);
636			itemArrangeIconsBy.ChildItems.Add (itemArrangeIconsByName);
637
638			// Size
639			MenuItem itemArrangeIconsBySize = new MenuItem ();
640			itemArrangeIconsBySize.Text = GetResourceString ("Size", "Size");
641			itemArrangeIconsBySize.Value = "Size";
642			itemArrangeIconsBySize.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.FileViewSort, SortMode.Size);
643			itemArrangeIconsBy.ChildItems.Add (itemArrangeIconsBySize);
644
645			// Type
646			MenuItem itemArrangeIconsByType = new MenuItem ();
647			itemArrangeIconsByType.Text = GetResourceString ("Type", "Type");
648			itemArrangeIconsByType.Value = "Type";
649			itemArrangeIconsByType.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.FileViewSort, SortMode.Type);
650			itemArrangeIconsBy.ChildItems.Add (itemArrangeIconsByType);
651
652			// Modified
653			MenuItem itemArrangeIconsByModified = new MenuItem ();
654			itemArrangeIconsByModified.Text = GetResourceString ("Date_Modified", "Date Modified");
655			itemArrangeIconsByModified.Value = "Modified";
656			itemArrangeIconsByModified.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.FileViewSort, SortMode.Modified);
657			itemArrangeIconsBy.ChildItems.Add (itemArrangeIconsByModified);
658
659			// Refresh
660			MenuItem itemRefresh = new MenuItem ();
661			itemRefresh.Text = Controller.GetResourceString ("Refresh", "Refresh");
662			itemRefresh.Value = "Refresh";
663			itemRefresh.ImageUrl = Controller.GetToolbarImage (ToolbarImages.Refresh);
664			itemRefresh.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.Refresh, "");
665			root.ChildItems.Add (itemRefresh);
666
667			root.ChildItems.Add (new MenuItem ("__separator__", "__separator__", null, "javascript: return;"));
668
669			// New
670			MenuItem itemNew = new MenuItem ();
671			itemNew.Text = GetResourceString ("Create", "New");
672			itemNew.Value = "Create";
673			itemNew.NavigateUrl = "javascript: return;";
674			itemNew.Enabled = !ReadOnly;
675			root.ChildItems.Add (itemNew);
676
677			if (!ReadOnly) {
678				// New Folder
679				MenuItem itemFolder = new MenuItem ();
680				itemFolder.Text = GetResourceString ("New_Folder", "Folder");
681				itemFolder.Value = "New_Folder";
682				itemFolder.ImageUrl = Controller.GetFolderSmallImage ();
683				itemFolder.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.NewFolder, "");
684				itemNew.ChildItems.Add (itemFolder);
685
686				itemNew.ChildItems.Add (new MenuItem ("__separator__", "__separator__", null, "javascript: return;"));
687
688				for (int i = 0; i < Templates.Count; i++) {
689					NewDocumentTemplate template = Templates [i];
690					MenuItem item = new MenuItem ();
691					item.Text = template.Name;
692					item.Value = "Template" + i;
693					if (template.SmallImageUrl.Length > 0)
694						item.ImageUrl = ResolveUrl (template.SmallImageUrl);
695					else if (template.MasterFileUrl.Length > 0)
696						item.ImageUrl = Controller.GetFileSmallImage (new FileInfo (Page.MapPath (template.MasterFileUrl)));
697					else
698						item.ImageUrl = Controller.GetFileSmallImage ();
699					item.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.NewDocument, Templates.IndexOf (template));
700					itemNew.ChildItems.Add (item);
701				}
702			}
703
704			// client script
705			StringBuilder sb = new StringBuilder ();
706			sb.AppendLine ("function " + ClientID + "_ShowContextMenu(x,y) {");
707
708			sb.AppendLine ("var bulletImgSrc = '" + Page.ClientScript.GetWebResourceUrl (typeof (FileManagerController), "IZ.WebFileManager.resources.Bullet.gif") + "';");
709			sb.AppendLine ("var emptyImgSrc = '" + Page.ClientScript.GetWebResourceUrl (typeof (FileManagerController), "IZ.WebFileManager.resources.Empty.gif") + "';");
710
711			sb.AppendLine ("var nameImg = WebForm_GetElementById('" + ClientID + "CMIMGName');");
712			sb.AppendLine ("var sizeImg = WebForm_GetElementById('" + ClientID + "CMIMGSize');");
713			sb.AppendLine ("var typeImg = WebForm_GetElementById('" + ClientID + "CMIMGType');");
714			sb.AppendLine ("var modifiedImg = WebForm_GetElementById('" + ClientID + "CMIMGModified');");
715			sb.AppendLine ("var iconsImg = WebForm_GetElementById('" + ClientID + "CMIMGIcons');");
716			sb.AppendLine ("var detailsImg = WebForm_GetElementById('" + ClientID + "CMIMGDetails');");
717			if (Controller.SupportThumbnails)
718				sb.AppendLine ("var thumbnailsImg = WebForm_GetElementById('" + ClientID + "CMIMGThumbnails');");
719
720			sb.AppendLine ("nameImg.src = emptyImgSrc;");
721			sb.AppendLine ("sizeImg.src = emptyImgSrc;");
722			sb.AppendLine ("typeImg.src = emptyImgSrc;");
723			sb.AppendLine ("modifiedImg.src = emptyImgSrc;");
724			sb.AppendLine ("iconsImg.src = emptyImgSrc;");
725			sb.AppendLine ("detailsImg.src = emptyImgSrc;");
726			if (Controller.SupportThumbnails)
727				sb.AppendLine ("thumbnailsImg.src = emptyImgSrc;");
728
729			sb.AppendLine ("var sort = " + FileManagerController.ClientScriptObjectNamePrefix + ClientID + ".GetSort();");
730			sb.AppendLine ("switch(sort) {");
731			sb.AppendLine ("case '" + SortMode.Name + "':");
732			sb.AppendLine ("nameImg.src = bulletImgSrc;");
733			sb.AppendLine ("break;");
734			sb.AppendLine ("case '" + SortMode.Type + "':");
735			sb.AppendLine ("typeImg.src = bulletImgSrc;");
736			sb.AppendLine ("break;");
737			sb.AppendLine ("case '" + SortMode.Size + "':");
738			sb.AppendLine ("sizeImg.src = bulletImgSrc;");
739			sb.AppendLine ("break;");
740			sb.AppendLine ("case '" + SortMode.Modified + "':");
741			sb.AppendLine ("modifiedImg.src = bulletImgSrc;");
742			sb.AppendLine ("break;");
743			sb.AppendLine ("}");
744
745			sb.AppendLine ("var view = " + FileManagerController.ClientScriptObjectNamePrefix + ClientID + ".GetView();");
746			sb.AppendLine ("switch(view) {");
747			sb.AppendLine ("case '" + FileViewRenderMode.Icons + "':");
748			sb.AppendLine ("iconsImg.src = bulletImgSrc;");
749			sb.AppendLine ("break;");
750			sb.AppendLine ("case '" + FileViewRenderMode.Details + "':");
751			sb.AppendLine ("detailsImg.src = bulletImgSrc;");
752			sb.AppendLine ("break;");
753			if (Controller.SupportThumbnails) {
754				sb.AppendLine ("case '" + FileViewRenderMode.Thumbnails + "':");
755				sb.AppendLine ("thumbnailsImg.src = bulletImgSrc;");
756				sb.AppendLine ("break;");
757			}
758			sb.AppendLine ("}");
759
760
761			sb.AppendLine ("var node = WebForm_GetElementById('" + ClientID + "_ContextMenu')");
762			sb.AppendLine ("WebForm_SetElementX(node, x)");
763			sb.AppendLine ("WebForm_SetElementY(node, y)");
764			sb.AppendLine ("Menu_HoverStatic(WebForm_GetElementById('" + _contextMenu.ClientID + "n0'));");
765			sb.AppendLine ("}");
766			Page.ClientScript.RegisterClientScriptBlock (typeof (FileView), ClientID + "_ShowContextMenu", sb.ToString (), true);
767		}
768
769		void CreateSelectedItemsContextMenu () {
770			_selectedItemsContextMenu = new ContextMenu ();
771			_selectedItemsContextMenu.EnableViewState = false;
772			_selectedItemsContextMenu.StaticEnableDefaultPopOutImage = false;
773			_selectedItemsContextMenu.DynamicEnableDefaultPopOutImage = false;
774			_selectedItemsContextMenu.Orientation = Orientation.Horizontal;
775			_selectedItemsContextMenu.SkipLinkText = String.Empty;
776			_selectedItemsContextMenu.StaticItemTemplate = new CompiledTemplateBuilder (new BuildTemplateMethod (CreateContextMenuRootItem));
777			_selectedItemsContextMenu.DynamicItemTemplate = new CompiledTemplateBuilder (new BuildTemplateMethod (CreateContextMenuPopupItem));
778			SetContextMenuStyle (_selectedItemsContextMenu);
779			Controls.Add (_selectedItemsContextMenu);
780
781			// Root
782			MenuItem root = new MenuItem ();
783			root.Text = "_contextMenu";
784			root.NavigateUrl = "javascript: return;";
785			_selectedItemsContextMenu.Items.Add (root);
786
787			string clientClickFunction = "javascript:" + FileManagerController.ClientScriptObjectNamePrefix + Controller.ClientID + ".On{0}(" + FileManagerController.ClientScriptObjectNamePrefix + ClientID + ", '{1}');return false;";
788
789			StringBuilder sbCommands = new StringBuilder ();
790
791			for (int i = 0; i < FileTypes.Count; i++) {
792				FileType ft = FileTypes [i];
793				for (int j = 0; j < ft.Commands.Count; j++) {
794					FileManagerCommand command = ft.Commands [j];
795					MenuItem itemCommand = new MenuItem ();
796					itemCommand.Text = command.Name;
797					itemCommand.Value = i + "_" + j;
798					itemCommand.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.ExecuteCommand, "0:" + j);
799					itemCommand.ImageUrl = command.SmallImageUrl;
800					root.ChildItems.Add (itemCommand);
801
802					sbCommands.AppendLine (ClientID + "_SetCommandVisible('" + ClientID + "CMD" + i + "_" + j + "', (" + FileManagerController.ClientScriptObjectNamePrefix + ClientID + ".SelectedItems.length==1) && (" + FileManagerController.ClientScriptObjectNamePrefix + ClientID + ".SelectedItems[0].FileType==" + i + "));");
803				}
804			}
805
806			MenuItem itemOpen = new MenuItem ();
807			itemOpen.Text = GetResourceString ("Open", "Open");
808			itemOpen.Value = "Open";
809			itemOpen.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.ExecuteCommand, "0:-1");
810			root.ChildItems.Add (itemOpen);
811
812			MenuItem itemDownload = new MenuItem ();
813			itemDownload.Text = GetResourceString ("Download", "Download");
814			itemDownload.Value = "Download";
815			itemDownload.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.ExecuteCommand, "0:-2");
816			root.ChildItems.Add (itemDownload);
817			sbCommands.AppendLine (ClientID + "_SetCommandVisible('" + ClientID + "CMDDownload', (" + FileManagerController.ClientScriptObjectNamePrefix + ClientID + ".SelectedItems.length==1) && (" + FileManagerController.ClientScriptObjectNamePrefix + ClientID + ".SelectedItems[0].FileType!=-2));");
818
819			root.ChildItems.Add (new MenuItem ("__separator__", "__separator__", null, "javascript: return;"));
820
821			// Copy to
822			MenuItem itemCopyTo = new MenuItem ();
823			itemCopyTo.Text = GetResourceString ("Copy", "Copy");
824			itemCopyTo.Value = "Copy";
825			itemCopyTo.ImageUrl = Controller.GetToolbarImage (ToolbarImages.Copy);
826			itemCopyTo.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.SelectedItemsCopyTo, "");
827			itemCopyTo.Enabled = !ReadOnly;
828			root.ChildItems.Add (itemCopyTo);
829
830			// Move to
831			MenuItem itemMoveTo = new MenuItem ();
832			itemMoveTo.Text = GetResourceString ("Move", "Move");
833			itemMoveTo.Value = "Move";
834			itemMoveTo.ImageUrl = Controller.GetToolbarImage (ToolbarImages.Move);
835			itemMoveTo.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.SelectedItemsMoveTo, "");
836			itemMoveTo.Enabled = !ReadOnly && AllowDelete;
837			root.ChildItems.Add (itemMoveTo);
838
839			root.ChildItems.Add (new MenuItem ("__separator__", "__separator__", null, "javascript: return;"));
840
841			// Delete
842			MenuItem itemDelete = new MenuItem ();
843			itemDelete.Text = GetResourceString ("Delete", "Delete");
844			itemDelete.Value = "Delete";
845			itemDelete.ImageUrl = Controller.GetToolbarImage (ToolbarImages.Delete);
846			itemDelete.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.SelectedItemsDelete, "");
847			itemDelete.Enabled = !ReadOnly && AllowDelete;
848			root.ChildItems.Add (itemDelete);
849
850			// Rename
851			MenuItem itemRename = new MenuItem ();
852			itemRename.Text = GetResourceString ("Rename", "Rename");
853			itemRename.Value = "Rename";
854			itemRename.ImageUrl = Controller.GetToolbarImage (ToolbarImages.Rename);
855			itemRename.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.Rename, "");
856			itemRename.Enabled = !ReadOnly && AllowDelete;
857			root.ChildItems.Add (itemRename);
858
859			// client script
860			StringBuilder sb = new StringBuilder ();
861			sb.AppendLine ("function " + ClientID + "_ShowSelectedItemsContextMenu(x,y) {");
862			sb.Append (sbCommands.ToString ());
863			sb.AppendLine ("var node = WebForm_GetElementById('" + ClientID + "_SelectedItemsContextMenu')");
864			sb.AppendLine ("WebForm_SetElementX(node, x)");
865			sb.AppendLine ("WebForm_SetElementY(node, y)");
866			sb.AppendLine ("WebForm_GetElementById('" + _selectedItemsContextMenu.ClientID + "n0Items').style.height = \"auto\";");
867			sb.AppendLine ("WebForm_GetElementById('" + _selectedItemsContextMenu.ClientID + "n0Items').physicalHeight = null;");
868			sb.AppendLine ("Menu_HoverStatic(WebForm_GetElementById('" + _selectedItemsContextMenu.ClientID + "n0'));");
869			sb.AppendLine ("}");
870			sb.AppendLine ("function " + ClientID + "_SetCommandVisible(command, value) {");
871			sb.AppendLine ("var node = WebForm_GetElementById(command);");
872			sb.AppendLine ("var row = node.parentNode.parentNode.parentNode.parentNode.parentNode;");
873			sb.AppendLine ("if (value) {");
874			sb.AppendLine ("row.style.visibility = \"visible\";");
875			sb.AppendLine ("row.style.display = \"block\";");
876			sb.AppendLine ("row.style.position = \"static\";");
877			sb.AppendLine ("row.parentNode.parentNode.style.height = \"auto\";");
878			sb.AppendLine ("} else {");
879			sb.AppendLine ("row.style.visibility = \"hidden\";");
880			sb.AppendLine ("row.style.display = \"none\";");
881			sb.AppendLine ("row.style.position = \"absolute\";");
882			sb.AppendLine ("row.parentNode.parentNode.style.height = \"0px\";");
883			sb.AppendLine ("}");
884			sb.AppendLine ("}");
885			Page.ClientScript.RegisterClientScriptBlock (typeof (FileView), ClientID + "_ShowSelectedItemsContextMenu", sb.ToString (), true);
886		}
887
888		void SetContextMenuStyle (Menu menu) {
889			// TODO
890			menu.DynamicMenuStyle.BackColor = Color.White;
891			menu.DynamicMenuStyle.BorderStyle = BorderStyle.Solid;
892			menu.DynamicMenuStyle.BorderWidth = Unit.Pixel (1);
893			menu.DynamicMenuStyle.BorderColor = Color.FromArgb (0xACA899);
894			menu.DynamicMenuStyle.HorizontalPadding = Unit.Pixel (2);
895			menu.DynamicMenuStyle.VerticalPadding = Unit.Pixel (2);
896
897			menu.DynamicMenuItemStyle.ForeColor = Color.Black;
898			menu.DynamicMenuItemStyle.Font.Names = new string [] { "Tahoma", "Verdana", "Geneva", "Arial", "Helvetica", "sans-serif" };
899			menu.DynamicMenuItemStyle.VerticalPadding = Unit.Pixel (1);
900			menu.DynamicMenuItemStyle.Font.Size = FontUnit.Parse ("11px", null);
901
902			menu.DynamicHoverStyle.ForeColor = Color.White;
903			menu.DynamicHoverStyle.BackColor = Color.FromArgb (0x316AC5);
904		}
905
906		void CreateContextMenuPopupItem (Control control) {
907			MenuItemTemplateContainer container = (MenuItemTemplateContainer) control;
908			MenuItem menuItem = (MenuItem) container.DataItem;
909			if (menuItem.Text == "__separator__") {
910				Table t = new Table ();
911				t.CellPadding = 0;
912				t.CellSpacing = 0;
913				t.BorderWidth = 0;
914				t.BackColor = Color.FromArgb (0xACA899);
915				t.Height = 1;
916				t.Width = Unit.Percentage (100);
917				t.Style [HtmlTextWriterStyle.Cursor] = "default";
918				container.Controls.Add (t);
919				TableRow r = new TableRow ();
920				TableCell c = new TableCell ();
921				System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image ();
922				img.ImageUrl = Page.ClientScript.GetWebResourceUrl (typeof (FileManagerController), "IZ.WebFileManager.resources.Empty.gif");
923				img.Width = 1;
924				img.Height = 1;
925				c.Controls.Add (img);
926				r.Cells.Add (c);
927				t.Rows.Add (r);
928			}
929			else {
930				Table t = new Table ();
931				t.CellPadding = 0;
932				t.CellSpacing = 0;
933				t.BorderWidth = 0;
934				t.Style [HtmlTextWriterStyle.Cursor] = "default";
935				if (menuItem.Enabled)
936					t.Attributes ["onclick"] = menuItem.NavigateUrl;
937				else
938					t.Style ["color"] = "gray";
939				t.Attributes ["id"] = ClientID + "CMD" + menuItem.Value;
940				container.Controls.Add (t);
941				TableRow r = new TableRow ();
942				t.Rows.Add (r);
943				TableCell c1 = new TableCell ();
944				System.Web.UI.WebControls.Image img1 = new System.Web.UI.WebControls.Image ();
945				if (String.IsNullOrEmpty (menuItem.ImageUrl))
946					img1.ImageUrl = Page.ClientScript.GetWebResourceUrl (typeof (FileManagerController), "IZ.WebFileManager.resources.Empty.gif");
947				else
948					img1.ImageUrl = menuItem.ImageUrl;
949				img1.Attributes ["id"] = ClientID + "CMIMG" + menuItem.Value;
950				img1.Width = 16;
951				img1.Height = 16;
952				c1.Controls.Add (img1);
953				r.Cells.Add (c1);
954				TableCell c2 = new TableCell ();
955				c2.Wrap = false;
956				c2.Style [HtmlTextWriterStyle.PaddingLeft] = "2px";
957				c2.Style [HtmlTextWriterStyle.PaddingRight] = "2px";
958				c2.Text = "&nbsp;" + menuItem.Text;
959				c2.Width = Unit.Percentage (100);
960				r.Cells.Add (c2);
961				TableCell c3 = new TableCell ();
962				System.Web.UI.WebControls.Image img3 = new System.Web.UI.WebControls.Image ();
963				if (menuItem.ChildItems.Count == 0)
964					img3.ImageUrl = Page.ClientScript.GetWebResourceUrl (typeof (FileManagerController), "IZ.WebFileManager.resources.Empty.gif");
965				else
966					if (Controller.IsRightToLeft)
967						img3.ImageUrl = Page.ClientScript.GetWebResourceUrl (typeof (FileManagerController), "IZ.WebFileManager.resources.PopOutRtl.gif");
968					else
969						img3.ImageUrl = Page.ClientScript.GetWebResourceUrl (typeof (FileManagerController), "IZ.WebFileManager.resources.PopOut.gif");
970				img3.Width = 16;
971				img3.Height = 16;
972				c3.Controls.Add (img3);
973				r.Cells.Add (c3);
974			}
975		}
976
977		void CreateContextMenuRootItem (Control control) {
978		}
979
980		#endregion
981	}
982}