PageRenderTime 120ms CodeModel.GetById 20ms app.highlight 68ms RepoModel.GetById 11ms app.codeStats 1ms

/IZWebFileManager/FileManager.cs

http://izwebfilemanager.googlecode.com/
C# | 992 lines | 843 code | 112 blank | 37 comment | 121 complexity | 992528bba0ec3f88c89198c2bc5f8d79 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.Text;
 20using System.Web.UI;
 21using System.Web.UI.WebControls;
 22using System.Drawing;
 23using System.ComponentModel;
 24using IZ.WebFileManager.Components;
 25using System.Web;
 26using System.Collections.Specialized;
 27using System.Drawing.Design;
 28
 29namespace IZ.WebFileManager
 30{
 31	[ToolboxData ("<{0}:FileManager runat=\"server\" width=\"400\" height=\"300\"></{0}:FileManager>")]
 32	public sealed class FileManager : FileManagerControlBase, IPostBackEventHandler
 33	{
 34		#region Fields
 35
 36		FileView _fileView;
 37		FolderTree _folderTree;
 38		Menu _toolBar;
 39		BorderedPanelStyle _addressBarStyle;
 40		BorderedPanelStyle _addressTextBoxStyle;
 41		BorderedPanelStyle _toolbarStyle;
 42		BorderedPanelStyle _toolbarButtonStyle;
 43		BorderedPanelStyle _toolbarButtonHoverStyle;
 44		BorderedPanelStyle _toolbarButtonPressedStyle;
 45		ToolbarOptions _toolbarOptions;
 46		CustomToolbarButtonCollection _cusomToolbarButtonCollection;
 47
 48		BorderedPanelStyle _defaultToolbarStyle;
 49		BorderedPanelStyle _defaultToolbarButtonStyle;
 50		BorderedPanelStyle _defaultToolbarButtonHoverStyle;
 51		BorderedPanelStyle _defaultToolbarButtonPressedStyle;
 52
 53		#endregion
 54
 55		#region Events
 56
 57		[Category ("Action")]
 58		public event CommandEventHandler ToolbarCommand;
 59
 60		#endregion
 61
 62		#region Properties
 63
 64		[Themeable (false)]
 65		[Localizable (false)]
 66		[DefaultValue (true)]
 67		[Category ("Appearance")]
 68		public bool ShowToolBar {
 69			get { return ViewState ["ShowToolBar"] == null ? true : (bool) ViewState ["ShowToolBar"]; }
 70			set { ViewState ["ShowToolBar"] = value; }
 71		}
 72
 73		[Themeable (false)]
 74		[Localizable (false)]
 75		[DefaultValue (true)]
 76		[Category ("Appearance")]
 77		public bool ShowAddressBar {
 78			get { return ViewState ["ShowAddressBar"] == null ? true : (bool) ViewState ["ShowAddressBar"]; }
 79			set { ViewState ["ShowAddressBar"] = value; }
 80		}
 81
 82		[Themeable (false)]
 83		[Localizable (false)]
 84		[DefaultValue (true)]
 85		[Category ("Appearance")]
 86		public bool ShowUploadBar {
 87			get { return ViewState ["ShowUploadBar"] == null ? true : (bool) ViewState ["ShowUploadBar"]; }
 88			set { ViewState ["ShowUploadBar"] = value; }
 89		}
 90
 91		[Category ("Appearance")]
 92		[PersistenceMode (PersistenceMode.InnerProperty)]
 93		[Localizable (false)]
 94		[Themeable (true)]
 95		public ToolbarOptions ToolbarOptions {
 96			get {
 97				if (_toolbarOptions == null) {
 98					_toolbarOptions = new ToolbarOptions (ViewState);
 99				}
100				return _toolbarOptions;
101			}
102		}
103
104		[MergableProperty (false)]
105		[PersistenceMode (PersistenceMode.InnerProperty)]
106		[Category ("Behavior")]
107		[Localizable (false)]
108		[Themeable (false)]
109		public CustomToolbarButtonCollection CustomToolbarButtons {
110			get {
111				if (_cusomToolbarButtonCollection == null) {
112					_cusomToolbarButtonCollection = new CustomToolbarButtonCollection ();
113					if (IsTrackingViewState)
114						((IStateManager) _cusomToolbarButtonCollection).TrackViewState ();
115				}
116				return _cusomToolbarButtonCollection;
117			}
118		}
119
120		FileView FileView {
121			get {
122				EnsureChildControls ();
123				return _fileView;
124			}
125		}
126
127		FolderTree FolderTree {
128			get {
129				EnsureChildControls ();
130				return _folderTree;
131			}
132		}
133
134		public override FileManagerItemInfo [] SelectedItems {
135			get {
136				return FileView.SelectedItems;
137			}
138		}
139
140		[Editor ("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof (UITypeEditor))]
141		[DefaultValue ("")]
142		[UrlProperty]
143		[Bindable (true)]
144		[Category ("Appearance")]
145		public string SplitterImageUrl {
146			get { return ViewState ["SplitterImageUrl"] == null ? String.Empty : (string) ViewState ["SplitterImageUrl"]; }
147			set { ViewState ["SplitterImageUrl"] = value; }
148		}
149
150		// TODO
151		[PersistenceMode (PersistenceMode.InnerProperty)]
152		[Category ("Appearance")]
153		internal BorderedPanelStyle AddressBarStyle {
154			get {
155				if (_addressBarStyle == null) {
156					_addressBarStyle = new BorderedPanelStyle ();
157					_addressBarStyle.PaddingLeft = Unit.Pixel (3);
158					_addressBarStyle.PaddingTop = Unit.Pixel (2);
159					_addressBarStyle.PaddingBottom = Unit.Pixel (2);
160					_addressBarStyle.PaddingRight = Unit.Pixel (2);
161					if (IsTrackingViewState)
162						((IStateManager) _addressBarStyle).TrackViewState ();
163				}
164				return _addressBarStyle;
165			}
166		}
167
168		// TODO
169		[PersistenceMode (PersistenceMode.InnerProperty)]
170		[Category ("Appearance")]
171		internal BorderedPanelStyle AddressTextBoxStyle {
172			get {
173				if (_addressTextBoxStyle == null) {
174					_addressTextBoxStyle = new BorderedPanelStyle ();
175					_addressTextBoxStyle.Font.Names = new string [] { "Tahoma", "Verdana", "Geneva", "Arial", "Helvetica", "sans-serif" };
176					_addressTextBoxStyle.Font.Size = FontUnit.Parse ("11px", null);
177					_addressTextBoxStyle.Width = Unit.Percentage (98);
178					_addressTextBoxStyle.BorderStyle = BorderStyle.Solid;
179					_addressTextBoxStyle.BorderWidth = Unit.Pixel (1);
180					_addressTextBoxStyle.BorderColor = Color.FromArgb (0xACA899);
181					_addressTextBoxStyle.PaddingLeft = Unit.Pixel (2);
182					_addressTextBoxStyle.PaddingTop = Unit.Pixel (2);
183					_addressTextBoxStyle.PaddingBottom = Unit.Pixel (2);
184					if (IsTrackingViewState)
185						((IStateManager) _addressTextBoxStyle).TrackViewState ();
186				}
187				return _addressTextBoxStyle;
188			}
189		}
190
191		[PersistenceMode (PersistenceMode.InnerProperty)]
192		[Category ("Appearance")]
193		public BorderedPanelStyle ToolbarStyle {
194			get {
195				if (_toolbarStyle == null) {
196					_toolbarStyle = new BorderedPanelStyle ();
197					if (IsTrackingViewState)
198						((IStateManager) _toolbarStyle).TrackViewState ();
199				}
200				return _toolbarStyle;
201			}
202		}
203
204		bool ToolbarStyleCreated {
205			get { return _toolbarStyle != null; }
206		}
207
208		BorderedPanelStyle DefaultToolbarStyle {
209			get {
210				if (_defaultToolbarStyle == null) {
211					_defaultToolbarStyle = new BorderedPanelStyle ();
212					_defaultToolbarStyle.ForeColor = Color.Black;
213					_defaultToolbarStyle.Font.Names = new string [] { "Tahoma", "Verdana", "Geneva", "Arial", "Helvetica", "sans-serif" };
214					_defaultToolbarStyle.Font.Size = FontUnit.Parse ("11px", null);
215					_defaultToolbarStyle.Height = Unit.Pixel (24);
216					_defaultToolbarStyle.BackImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.toolbarbg.gif");
217					_defaultToolbarStyle.BackColor = Color.FromArgb (0xEBEADB);
218					_defaultToolbarStyle.PaddingLeft = Unit.Pixel (3);
219					_defaultToolbarStyle.PaddingRight = Unit.Pixel (3);
220					_defaultToolbarStyle.PaddingTop = Unit.Pixel (2);
221				}
222				return _defaultToolbarStyle;
223			}
224		}
225
226		[PersistenceMode (PersistenceMode.InnerProperty)]
227		[Category ("Appearance")]
228		public BorderedPanelStyle ToolbarButtonStyle {
229			get {
230				if (_toolbarButtonStyle == null) {
231					_toolbarButtonStyle = new BorderedPanelStyle ();
232					if (IsTrackingViewState)
233						((IStateManager) _toolbarButtonStyle).TrackViewState ();
234				}
235				return _toolbarButtonStyle;
236			}
237		}
238
239		bool ToolbarButtonStyleCreated {
240			get { return _toolbarButtonStyle != null; }
241		}
242
243		BorderedPanelStyle DefaultToolbarButtonStyle {
244			get {
245				if (_defaultToolbarButtonStyle == null) {
246					_defaultToolbarButtonStyle = new BorderedPanelStyle ();
247					_defaultToolbarButtonStyle.OuterBorderStyle = OuterBorderStyle.AllSides;
248					_defaultToolbarButtonStyle.OuterBorderTopWidth = Unit.Pixel (3);
249					_defaultToolbarButtonStyle.OuterBorderLeftWidth = Unit.Pixel (3);
250					_defaultToolbarButtonStyle.OuterBorderRightWidth = Unit.Pixel (3);
251					_defaultToolbarButtonStyle.OuterBorderBottomWidth = Unit.Pixel (3);
252					_defaultToolbarButtonStyle.ForeColor = Color.Black;
253				}
254				return _defaultToolbarButtonStyle;
255			}
256		}
257
258		[PersistenceMode (PersistenceMode.InnerProperty)]
259		[Category ("Appearance")]
260		public BorderedPanelStyle ToolbarButtonHoverStyle {
261			get {
262				if (_toolbarButtonHoverStyle == null) {
263					_toolbarButtonHoverStyle = new BorderedPanelStyle ();
264					if (IsTrackingViewState)
265						((IStateManager) _toolbarButtonHoverStyle).TrackViewState ();
266				}
267				return _toolbarButtonHoverStyle;
268			}
269		}
270
271		bool ToolbarButtonHoverStyleCreated {
272			get { return _toolbarButtonHoverStyle != null; }
273		}
274
275		BorderedPanelStyle DefaultToolbarButtonHoverStyle {
276			get {
277				if (_defaultToolbarButtonHoverStyle == null) {
278					_defaultToolbarButtonHoverStyle = new BorderedPanelStyle ();
279					_defaultToolbarButtonHoverStyle.ForeColor = Color.Black;
280					_defaultToolbarButtonHoverStyle.BackColor = Color.FromArgb (0xf5f5ef);
281					_defaultToolbarButtonHoverStyle.OuterBorderLeftBottomCornerImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.toolbarbtnhover_LB.gif");
282					_defaultToolbarButtonHoverStyle.OuterBorderRightBottomCornerImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.toolbarbtnhover_RB.gif");
283					_defaultToolbarButtonHoverStyle.OuterBorderLeftTopCornerImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.toolbarbtnhover_LT.gif");
284					_defaultToolbarButtonHoverStyle.OuterBorderRightTopCornerImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.toolbarbtnhover_RT.gif");
285					_defaultToolbarButtonHoverStyle.OuterBorderTopImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.toolbarbtnhover_T.gif");
286					_defaultToolbarButtonHoverStyle.OuterBorderBottomImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.toolbarbtnhover_B.gif");
287					_defaultToolbarButtonHoverStyle.OuterBorderLeftImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.toolbarbtnhover_L.gif");
288					_defaultToolbarButtonHoverStyle.OuterBorderRightImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.toolbarbtnhover_R.gif");
289				}
290				return _defaultToolbarButtonHoverStyle;
291			}
292		}
293
294		[PersistenceMode (PersistenceMode.InnerProperty)]
295		[Category ("Appearance")]
296		public BorderedPanelStyle ToolbarButtonPressedStyle {
297			get {
298				if (_toolbarButtonPressedStyle == null) {
299					_toolbarButtonPressedStyle = new BorderedPanelStyle ();
300					if (IsTrackingViewState)
301						((IStateManager) _toolbarButtonPressedStyle).TrackViewState ();
302				}
303				return _toolbarButtonPressedStyle;
304			}
305		}
306
307		bool ToolbarButtonPressedStyleCreated {
308			get { return _toolbarButtonPressedStyle != null; }
309		}
310
311		BorderedPanelStyle DefaultToolbarButtonPressedStyle {
312			get {
313				if (_defaultToolbarButtonPressedStyle == null) {
314					_defaultToolbarButtonPressedStyle = new BorderedPanelStyle ();
315					_defaultToolbarButtonPressedStyle.ForeColor = Color.Black;
316					_defaultToolbarButtonPressedStyle.BackColor = Color.FromArgb (0xe3e3db);
317					_defaultToolbarButtonPressedStyle.OuterBorderLeftBottomCornerImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.toolbarbtndown_LB.gif");
318					_defaultToolbarButtonPressedStyle.OuterBorderRightBottomCornerImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.toolbarbtndown_RB.gif");
319					_defaultToolbarButtonPressedStyle.OuterBorderLeftTopCornerImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.toolbarbtndown_LT.gif");
320					_defaultToolbarButtonPressedStyle.OuterBorderRightTopCornerImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.toolbarbtndown_RT.gif");
321					_defaultToolbarButtonPressedStyle.OuterBorderTopImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.toolbarbtndown_T.gif");
322					_defaultToolbarButtonPressedStyle.OuterBorderBottomImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.toolbarbtndown_B.gif");
323					_defaultToolbarButtonPressedStyle.OuterBorderLeftImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.toolbarbtndown_L.gif");
324					_defaultToolbarButtonPressedStyle.OuterBorderRightImageUrl = Page.ClientScript.GetWebResourceUrl (GetType (), "IZ.WebFileManager.resources.toolbarbtndown_R.gif");
325				}
326				return _defaultToolbarButtonPressedStyle;
327			}
328		}
329
330		[Bindable (true)]
331		[Category ("Behavior")]
332		[DefaultValue (false)]
333		[Localizable (false)]
334		public bool UseLinkToOpenItem {
335			get { return FileView.UseLinkToOpenItem; }
336			set { FileView.UseLinkToOpenItem = value; }
337		}
338
339		[Bindable (true)]
340		[Category ("Behavior")]
341		[DefaultValue ("_blank")]
342		[Localizable (false)]
343		public string LinkToOpenItemTarget {
344			get { return FileView.LinkToOpenItemTarget; }
345			set { FileView.LinkToOpenItemTarget = value; }
346		}
347
348		[Bindable (true)]
349		[Category ("Appearance")]
350		[DefaultValue (FileViewRenderMode.Icons)]
351		[Localizable (false)]
352		public FileViewRenderMode FileViewMode {
353			get { return FileView.View; }
354			set { FileView.View = value; }
355		}
356
357		[PersistenceMode (PersistenceMode.InnerProperty)]
358		[Category ("Appearance")]
359		public Style FileViewStyle {
360			get { return FileView.ControlStyle; }
361		}
362
363		[PersistenceMode (PersistenceMode.InnerProperty)]
364		[Category ("Appearance")]
365		public Style FolderTreeStyle {
366			get { return FolderTree.ControlStyle; }
367		}
368
369		[Bindable (true)]
370		[Category ("Data")]
371		[DefaultValue ("[0]/")]
372		[Localizable (false)]
373		[Themeable (false)]
374		public string Directory {
375			get { return FileView.Directory; }
376			set { FileView.Directory = value; }
377		}
378
379		public override FileManagerItemInfo CurrentDirectory {
380			get {
381				return FileView.CurrentDirectory;
382			}
383		}
384
385		#endregion
386
387		protected override void OnPreRender (EventArgs e) {
388			base.OnPreRender (e);
389			if (ShowToolBar)
390				CreateToolbar ();
391			RegisterSplitterClientScript ();
392			RegisterLayoutSetupScript ();
393
394			Page.Form.Enctype = "multipart/form-data";
395
396			Page.ClientScript.RegisterExpandoAttribute (_fileView.ClientID, "rootControl", ClientID);
397		}
398
399		private void RegisterLayoutSetupScript () {
400			StringBuilder sb = new StringBuilder ();
401			if (!ShowAddressBar)
402				sb.AppendLine ("var addressBarHeight = 0;");
403			else
404				sb.AppendLine ("var addressBarHeight = WebForm_GetElementPosition(WebForm_GetElementById('" + ClientID + "_AddressBar')).height;");
405			if (!ShowToolBar)
406				sb.AppendLine ("var toolBarHeight = 0;");
407			else
408				sb.AppendLine ("var toolBarHeight = WebForm_GetElementPosition(WebForm_GetElementById('" + ClientID + "_ToolBar')).height;");
409			if (ReadOnly || !AllowUpload || !ShowUploadBar)
410				sb.AppendLine ("var uploadBarHeight = 0;");
411			else
412				sb.AppendLine ("var uploadBarHeight = WebForm_GetElementPosition(WebForm_GetElementById('" + ClientID + "_UploadBar')).height;");
413			sb.AppendLine ("var fileManagerHeight = WebForm_GetElementPosition(WebForm_GetElementById('" + ClientID + "')).height;");
414			sb.AppendLine ("var requestedHeight = fileManagerHeight - addressBarHeight - toolBarHeight - uploadBarHeight;");
415			sb.AppendLine ("WebForm_SetElementHeight(WebForm_GetElementById('" + _fileView.ClientID + "'), requestedHeight);");
416			sb.AppendLine ("WebForm_SetElementHeight(WebForm_GetElementById('" + _folderTree.ClientID + "'), requestedHeight);");
417			Page.ClientScript.RegisterStartupScript (typeof (FileManager), ClientID + "LayoutSetup", sb.ToString (), true);
418
419		}
420
421		private void RegisterSplitterClientScript () {
422			StringBuilder sb = new StringBuilder ();
423			sb.AppendLine ("var __fileView;");
424			sb.AppendLine ("var __fileViewWidth;");
425			sb.AppendLine ("var __folderTree;");
426			sb.AppendLine ("var __folderTreeWidth;");
427			sb.AppendLine ("var __clientX;");
428			sb.AppendLine ("var __document_onmousemove;");
429			sb.AppendLine ("var __document_onmouseup;");
430			sb.AppendLine ("function " + ClientID + "SplitterDragStart(e) {");
431			sb.AppendLine ("if(e == null) var e = event;");
432			sb.AppendLine ("__fileView = WebForm_GetElementById('" + _fileView.ClientID + "');");
433			sb.AppendLine ("__fileViewWidth = WebForm_GetElementPosition(__fileView).width;");
434			sb.AppendLine ("__folderTree = WebForm_GetElementById('" + _folderTree.ClientID + "');");
435			sb.AppendLine ("__folderTreeWidth = WebForm_GetElementPosition(__folderTree).width;");
436			sb.AppendLine ("__clientX = e.clientX;");
437			sb.AppendLine ("__document_onmousemove = document.onmousemove;");
438			sb.AppendLine ("__document_onmouseup = document.onmouseup;");
439			sb.AppendLine ("document.onmousemove = " + ClientID + "SplitterDrag;");
440			sb.AppendLine ("document.onmouseup = " + ClientID + "SplitterDragEnd;");
441			sb.AppendLine ("return false;");
442			sb.AppendLine ("}");
443			sb.AppendLine ("function " + ClientID + "SplitterDragEnd(e) {");
444			sb.AppendLine ("document.onmousemove = __document_onmousemove;");
445			sb.AppendLine ("document.onmouseup = __document_onmouseup;");
446			sb.AppendLine ("return false;");
447			sb.AppendLine ("}");
448			sb.AppendLine ("function " + ClientID + "SplitterDrag(e) {");
449			sb.AppendLine ("if(e == null) var e = event;");
450			if (Controller.IsRightToLeft)
451				sb.AppendLine ("var __delta = __clientX - e.clientX;");
452			else
453				sb.AppendLine ("var __delta = e.clientX - __clientX;");
454			sb.AppendLine ("WebForm_SetElementWidth(__fileView, __fileViewWidth - __delta);");
455			sb.AppendLine ("WebForm_SetElementWidth(__folderTree, __folderTreeWidth + __delta);");
456			sb.AppendLine ("return false;");
457			sb.AppendLine ("}");
458			Page.ClientScript.RegisterClientScriptBlock (typeof (FileManager), ClientID + "SplitterDrag", sb.ToString (), true);
459		}
460
461		protected override void CreateChildControls () {
462			base.CreateChildControls ();
463			CreateFileView ();
464			CreateFolderTree ();
465		}
466
467		private void CreateFolderTree () {
468			_folderTree = new FolderTree (Controller, _fileView);
469			_folderTree.ID = "FolderTree";
470			Controls.Add (_folderTree);
471		}
472
473		private void CreateFileView () {
474			_fileView = new FileView (Controller);
475			_fileView.ID = "FileView";
476			Controls.Add (_fileView);
477		}
478
479        class IE8Fix : Style
480        {
481            protected override void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver)
482            {
483                //.IE8fix
484                //{
485                //     z-index: 100;
486                //}
487                base.FillStyleAttributes(attributes, urlResolver);
488                attributes.Add(HtmlTextWriterStyle.ZIndex, "100");
489            }
490        }
491
492		private void CreateToolbar () {
493			_toolBar = new Menu ();
494			_toolBar.EnableViewState = false;
495			_toolBar.StaticEnableDefaultPopOutImage = false;
496			_toolBar.DynamicEnableDefaultPopOutImage = false;
497			_toolBar.Orientation = Orientation.Horizontal;
498			_toolBar.SkipLinkText = String.Empty;
499			_toolBar.StaticItemTemplate = new CompiledTemplateBuilder (new BuildTemplateMethod (CreateToolbarButton));
500			_toolBar.DynamicItemTemplate = new CompiledTemplateBuilder (new BuildTemplateMethod (CreateToolbarPopupItem));
501
502			// TODO
503			_toolBar.DynamicMenuStyle.BackColor = Color.White;
504			_toolBar.DynamicMenuStyle.BorderStyle = BorderStyle.Solid;
505			_toolBar.DynamicMenuStyle.BorderWidth = Unit.Pixel (1);
506			_toolBar.DynamicMenuStyle.BorderColor = Color.FromArgb (0xACA899);
507			_toolBar.DynamicMenuStyle.HorizontalPadding = Unit.Pixel (2);
508			_toolBar.DynamicMenuStyle.VerticalPadding = Unit.Pixel (2);
509
510            // fix IE8 bug
511            var ie8fix = new IE8Fix();
512            if (Page.Header != null)
513                Page.Header.StyleSheet.RegisterStyle(ie8fix, this);
514            _toolBar.DynamicMenuStyle.CssClass = ie8fix.RegisteredCssClass;
515            
516
517			_toolBar.DynamicMenuItemStyle.ForeColor = Color.Black;
518			_toolBar.DynamicMenuItemStyle.Font.Names = new string [] { "Tahoma", "Verdana", "Geneva", "Arial", "Helvetica", "sans-serif" };
519			_toolBar.DynamicMenuItemStyle.VerticalPadding = Unit.Pixel (1);
520			_toolBar.DynamicMenuItemStyle.Font.Size = FontUnit.Parse ("11px", null);
521
522			_toolBar.DynamicHoverStyle.ForeColor = Color.White;
523			_toolBar.DynamicHoverStyle.BackColor = Color.FromArgb (0x316AC5);
524
525			Controls.Add (_toolBar);
526
527			string clientClickFunction = "javascript:" + FileManagerController.ClientScriptObjectNamePrefix + Controller.ClientID + ".On{0}(" + FileManagerController.ClientScriptObjectNamePrefix + _fileView.ClientID + ", '{1}');return false;";
528
529			// Copy to
530			if (ToolbarOptions.ShowCopyButton) {
531				MenuItem itemCopyTo = new MenuItem ();
532				itemCopyTo.Text = Controller.GetResourceString ("Copy", "Copy");
533				itemCopyTo.ImageUrl = Controller.GetToolbarImage (ToolbarImages.Copy);
534				itemCopyTo.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.SelectedItemsCopyTo, "");
535				itemCopyTo.Enabled = !ReadOnly;
536				_toolBar.Items.Add (itemCopyTo);
537			}
538
539			// Move to
540			if (ToolbarOptions.ShowMoveButton) {
541				MenuItem itemMoveTo = new MenuItem ();
542				itemMoveTo.Text = Controller.GetResourceString ("Move", "Move");
543				itemMoveTo.ImageUrl = Controller.GetToolbarImage (ToolbarImages.Move);
544				itemMoveTo.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.SelectedItemsMoveTo, "");
545				itemMoveTo.Enabled = !ReadOnly && AllowDelete;
546				_toolBar.Items.Add (itemMoveTo);
547			}
548
549			// Delete
550			if (ToolbarOptions.ShowDeleteButton) {
551				MenuItem itemDelete = new MenuItem ();
552				itemDelete.Text = Controller.GetResourceString ("Delete", "Delete");
553				itemDelete.ImageUrl = Controller.GetToolbarImage (ToolbarImages.Delete);
554				itemDelete.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.SelectedItemsDelete, "");
555				itemDelete.Enabled = !ReadOnly && AllowDelete;
556				_toolBar.Items.Add (itemDelete);
557			}
558
559			// Rename
560			if (ToolbarOptions.ShowRenameButton) {
561				MenuItem itemRename = new MenuItem ();
562				itemRename.Text = Controller.GetResourceString ("Rename", "Rename");
563				itemRename.ImageUrl = Controller.GetToolbarImage (ToolbarImages.Rename);
564				itemRename.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.Rename, "");
565				itemRename.Enabled = !ReadOnly && AllowDelete;
566				_toolBar.Items.Add (itemRename);
567			}
568
569			// NewFolder
570			if (ToolbarOptions.ShowNewFolderButton) {
571				MenuItem itemNewFolder = new MenuItem ();
572				itemNewFolder.Text = Controller.GetResourceString ("Create_New_Folder", "New Folder");
573				itemNewFolder.ImageUrl = Controller.GetToolbarImage (ToolbarImages.NewFolder);
574				itemNewFolder.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.NewFolder, "");
575				itemNewFolder.Enabled = !ReadOnly;
576				_toolBar.Items.Add (itemNewFolder);
577			}
578
579			// FolderUp
580			if (ToolbarOptions.ShowFolderUpButton) {
581				MenuItem itemFolderUp = new MenuItem ();
582				itemFolderUp.Text = Controller.GetResourceString ("Up", "Up");
583				itemFolderUp.ImageUrl = Controller.GetToolbarImage (ToolbarImages.FolderUp);
584				itemFolderUp.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.FileViewNavigate, "..");
585				_toolBar.Items.Add (itemFolderUp);
586			}
587
588			// View
589			if (ToolbarOptions.ShowViewButton) {
590				MenuItem itemView = new MenuItem ();
591				itemView.Text = Controller.GetResourceString ("View", "View");
592				itemView.ImageUrl = Controller.GetToolbarImage (ToolbarImages.View);
593				itemView.NavigateUrl = "javascript: return;";
594				_toolBar.Items.Add (itemView);
595
596				// Icons
597				MenuItem itemViewIcons = new MenuItem ();
598				itemViewIcons.Text = Controller.GetResourceString ("Icons", "Icons");
599				itemViewIcons.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.FileViewChangeView, FileViewRenderMode.Icons);
600				itemView.ChildItems.Add (itemViewIcons);
601
602				// Details
603				MenuItem itemViewDetails = new MenuItem ();
604				itemViewDetails.Text = Controller.GetResourceString ("Details", "Details");
605				itemViewDetails.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.FileViewChangeView, FileViewRenderMode.Details);
606				itemView.ChildItems.Add (itemViewDetails);
607
608				if (Controller.SupportThumbnails) {
609					// Thumbnails
610					MenuItem itemViewThumbnails = new MenuItem ();
611					itemViewThumbnails.Text = Controller.GetResourceString ("Thumbnails", "Thumbnails");
612					itemViewThumbnails.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.FileViewChangeView, FileViewRenderMode.Thumbnails);
613					itemView.ChildItems.Add (itemViewThumbnails);
614				}
615			}
616
617			// Refresh
618			if (ToolbarOptions.ShowRefreshButton) {
619				MenuItem itemRefresh = new MenuItem ();
620				itemRefresh.Text = Controller.GetResourceString ("Refresh", "Refresh");
621				itemRefresh.Value = "Refresh";
622				itemRefresh.ImageUrl = Controller.GetToolbarImage (ToolbarImages.Refresh);
623				itemRefresh.NavigateUrl = String.Format (clientClickFunction, FileManagerCommands.Refresh, "");
624				_toolBar.Items.Add (itemRefresh);
625			}
626
627			// Custom Buttons
628			if (_cusomToolbarButtonCollection != null) {
629				for (int i = 0; i < _cusomToolbarButtonCollection.Count; i++) {
630					CustomToolbarButton button = _cusomToolbarButtonCollection [i];
631					string postBackStatement = null;
632					if (button.PerformPostBack) {
633						postBackStatement = Page.ClientScript.GetPostBackEventReference (this, "Toolbar:" + i);
634					}
635					MenuItem item = new MenuItem ()
636					{
637						Text = button.Text,
638						ImageUrl = button.ImageUrl,
639						NavigateUrl = "javascript:" + button.OnClientClick + ";" + postBackStatement + ";return false;"
640					};
641					_toolBar.Items.Add (item);
642				}
643			}
644		}
645
646		void CreateToolbarPopupItem (Control control) {
647			MenuItemTemplateContainer container = (MenuItemTemplateContainer) control;
648			MenuItem menuItem = (MenuItem) container.DataItem;
649			Table t = new Table ();
650			t.CellPadding = 0;
651			t.CellSpacing = 0;
652			t.BorderWidth = 0;
653			t.Style [HtmlTextWriterStyle.Cursor] = "default";
654			t.Attributes ["onclick"] = menuItem.NavigateUrl;
655			container.Controls.Add (t);
656			TableRow r = new TableRow ();
657			t.Rows.Add (r);
658			TableCell c1 = new TableCell ();
659			System.Web.UI.WebControls.Image img1 = new System.Web.UI.WebControls.Image ();
660			img1.ImageUrl = Page.ClientScript.GetWebResourceUrl (typeof (FileManagerController), "IZ.WebFileManager.resources.Empty.gif");
661			img1.Width = 16;
662			img1.Height = 16;
663			c1.Controls.Add (img1);
664			r.Cells.Add (c1);
665			TableCell c2 = new TableCell ();
666			c2.Style [HtmlTextWriterStyle.PaddingLeft] = "2px";
667			c2.Style [HtmlTextWriterStyle.PaddingRight] = "2px";
668			c2.Text = "&nbsp;" + menuItem.Text;
669			c2.Width = Unit.Percentage (100);
670			r.Cells.Add (c2);
671			TableCell c3 = new TableCell ();
672			System.Web.UI.WebControls.Image img3 = new System.Web.UI.WebControls.Image ();
673			img3.ImageUrl = Page.ClientScript.GetWebResourceUrl (typeof (FileManagerController), "IZ.WebFileManager.resources.Empty.gif");
674			img3.Width = 16;
675			img3.Height = 16;
676			c3.Controls.Add (img3);
677			r.Cells.Add (c3);
678		}
679
680		void CreateToolbarButton (Control control) {
681			MenuItemTemplateContainer container = (MenuItemTemplateContainer) control;
682			MenuItem menuItem = (MenuItem) container.DataItem;
683			BorderedPanel panel = new BorderedPanel ();
684			panel.ControlStyle.CopyFrom (DefaultToolbarButtonStyle);
685			if (ToolbarButtonStyleCreated)
686				panel.ControlStyle.CopyFrom (ToolbarButtonStyle);
687			panel.Style [HtmlTextWriterStyle.Cursor] = "default";
688			if (menuItem.Enabled) {
689				panel.HoverSyle.CopyFrom (DefaultToolbarButtonHoverStyle);
690				if (ToolbarButtonHoverStyleCreated)
691					panel.HoverSyle.CopyFrom (ToolbarButtonHoverStyle);
692				panel.PressedSyle.CopyFrom (DefaultToolbarButtonPressedStyle);
693				if (ToolbarButtonPressedStyleCreated)
694					panel.PressedSyle.CopyFrom (ToolbarButtonPressedStyle);
695				panel.Attributes ["onclick"] = menuItem.NavigateUrl;
696			}
697			else
698				panel.Style ["color"] = "gray";
699			container.Controls.Add (panel);
700			Table t = new Table ();
701			t.CellPadding = 0;
702			t.CellSpacing = 0;
703			t.BorderWidth = 0;
704			panel.Controls.Add (t);
705			TableRow r = new TableRow ();
706			t.Rows.Add (r);
707			TableCell c1 = new TableCell ();
708			r.Cells.Add (c1);
709			System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image ();
710			img.ImageUrl = ((MenuItem) container.DataItem).ImageUrl;
711			c1.Controls.Add (img);
712			TableCell c2 = new TableCell ();
713			c2.Style [HtmlTextWriterStyle.PaddingLeft] = "2px";
714			c2.Style [HtmlTextWriterStyle.PaddingRight] = "2px";
715			c2.Text = "&nbsp;" + menuItem.Text;
716			r.Cells.Add (c2);
717		}
718
719		protected override Style CreateControlStyle () {
720			Style style = base.CreateControlStyle ();
721			style.BackColor = Color.FromArgb (0xEDEBE0);
722			return style;
723		}
724
725		protected override void AddAttributesToRender (HtmlTextWriter writer) {
726			base.AddAttributesToRender (writer);
727			writer.AddStyleAttribute (HtmlTextWriterStyle.Cursor, "default");
728		}
729
730		protected override void Render (HtmlTextWriter writer) {
731			if (DesignMode) {
732				writer.Write (String.Format (System.Globalization.CultureInfo.InvariantCulture,
733				"<div><table width=\"{0}\" height=\"{1}\" bgcolor=\"#f5f5f5\" bordercolor=\"#c7c7c7\" cellpadding=\"0\" cellspacing=\"0\" border=\"1\"><tr><td valign=\"middle\" align=\"center\">IZWebFileManager - <b>{2}</b></td></tr></table></div>",
734					Width,
735					Height,
736					ID));
737				return;
738			}
739
740			AddAttributesToRender (writer);
741			RenderBeginOuterTable (writer);
742			if (ShowAddressBar)
743				RenderAddressBar (writer);
744			if (ShowToolBar)
745				RenderToolBar (writer);
746
747			writer.AddAttribute (HtmlTextWriterAttribute.Cellpadding, "0");
748			writer.AddAttribute (HtmlTextWriterAttribute.Cellspacing, "0");
749			writer.RenderBeginTag (HtmlTextWriterTag.Table);
750			writer.RenderBeginTag (HtmlTextWriterTag.Tr);
751			writer.RenderBeginTag (HtmlTextWriterTag.Td);
752
753			RenderFolderTree (writer);
754
755			writer.RenderEndTag ();
756
757			// splitter
758			writer.AddStyleAttribute (HtmlTextWriterStyle.Cursor, "col-resize");
759			writer.AddAttribute ("onmousedown", ClientID + "SplitterDragStart(event)");
760			writer.AddAttribute ("onselectstart", "return false");
761			writer.RenderBeginTag (HtmlTextWriterTag.Td);
762			if (SplitterImageUrl.Length > 0) {
763				writer.AddAttribute (HtmlTextWriterAttribute.Src, ResolveClientUrl (SplitterImageUrl));
764			}
765			else {
766				writer.AddAttribute (HtmlTextWriterAttribute.Width, "3px");
767				writer.AddAttribute (HtmlTextWriterAttribute.Height, "3px");
768				writer.AddAttribute (HtmlTextWriterAttribute.Src, Page.ClientScript.GetWebResourceUrl (typeof (FileManagerController), "IZ.WebFileManager.resources.Empty.gif"));
769			}
770			writer.AddAttribute (HtmlTextWriterAttribute.Alt, "");
771			writer.RenderBeginTag (HtmlTextWriterTag.Img);
772			writer.RenderEndTag ();
773			writer.RenderEndTag ();
774
775			writer.RenderBeginTag (HtmlTextWriterTag.Td);
776
777			RenderFileView (writer);
778
779			writer.RenderEndTag ();
780			writer.RenderEndTag ();
781			writer.RenderEndTag ();
782
783			if (!ReadOnly && AllowUpload && ShowUploadBar)
784				RenderFileUploadBar (writer);
785			RenderEndOuterTable (writer);
786		}
787
788		private void RenderToolBar (HtmlTextWriter writer) {
789			BorderedPanel p = new BorderedPanel ();
790			p.Page = Page;
791			p.ControlStyle.CopyFrom (DefaultToolbarStyle);
792			if (ToolbarStyleCreated)
793				p.ControlStyle.CopyFrom (ToolbarStyle);
794
795			writer.AddStyleAttribute (HtmlTextWriterStyle.Position, "relative");
796			writer.AddStyleAttribute (HtmlTextWriterStyle.ZIndex, "100");
797			writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_ToolBar");
798			writer.RenderBeginTag (HtmlTextWriterTag.Div);
799			p.RenderBeginTag (writer);
800			_toolBar.RenderControl (writer);
801			p.RenderEndTag (writer);
802			writer.RenderEndTag ();
803		}
804
805		private void RenderFolderTree (HtmlTextWriter writer) {
806			_folderTree.Width = new Unit (Width.Value * 0.25, Width.Type);
807			_folderTree.Height = 100;
808			_folderTree.RenderControl (writer);
809		}
810
811		private void RenderFileView (HtmlTextWriter writer) {
812			_fileView.Width = new Unit (Width.Value * 0.75, Width.Type);
813			_fileView.Height = 100;
814			_fileView.RenderControl (writer);
815		}
816
817		private void RenderAddressBar (HtmlTextWriter writer) {
818			AddressBarStyle.AddAttributesToRender (writer);
819			writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_AddressBar");
820			writer.RenderBeginTag (HtmlTextWriterTag.Div);
821
822			writer.AddAttribute (HtmlTextWriterAttribute.Cellspacing, "0");
823			writer.AddAttribute (HtmlTextWriterAttribute.Cellpadding, "0");
824			writer.AddAttribute (HtmlTextWriterAttribute.Border, "0");
825			writer.AddStyleAttribute (HtmlTextWriterStyle.Width, "100%");
826			writer.RenderBeginTag (HtmlTextWriterTag.Table);
827			writer.RenderBeginTag (HtmlTextWriterTag.Tr);
828
829
830			writer.RenderBeginTag (HtmlTextWriterTag.Td);
831
832			writer.AddAttribute (HtmlTextWriterAttribute.Id, _fileView.ClientID + "_Address");
833			writer.AddAttribute (HtmlTextWriterAttribute.Value, CurrentDirectory.FileManagerPath, true);
834			AddressTextBoxStyle.AddAttributesToRender (writer);
835			//writer.AddAttribute(HtmlTextWriterAttribute.ReadOnly, "readonly");
836			writer.RenderBeginTag (HtmlTextWriterTag.Input);
837			writer.RenderEndTag ();
838
839
840			writer.RenderEndTag ();
841			writer.AddStyleAttribute (HtmlTextWriterStyle.Width, "16px");
842			writer.RenderBeginTag (HtmlTextWriterTag.Td);
843			writer.AddAttribute (HtmlTextWriterAttribute.Alt, "");
844			writer.AddAttribute (HtmlTextWriterAttribute.Src, Controller.GetToolbarImage (ToolbarImages.Process));
845			writer.AddAttribute (HtmlTextWriterAttribute.Id, _fileView.ClientID + "_ProgressImg");
846			writer.AddStyleAttribute (HtmlTextWriterStyle.Visibility, "hidden");
847			writer.RenderBeginTag (HtmlTextWriterTag.Img);
848			writer.RenderEndTag ();
849			writer.RenderEndTag ();
850			writer.RenderEndTag ();
851			writer.RenderEndTag ();
852
853			writer.RenderEndTag ();
854		}
855		private void RenderFileUploadBar (HtmlTextWriter writer) {
856			AddressBarStyle.AddAttributesToRender (writer);
857			writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_UploadBar");
858			writer.RenderBeginTag (HtmlTextWriterTag.Div);
859			writer.RenderBeginTag (HtmlTextWriterTag.Table);
860			writer.RenderBeginTag (HtmlTextWriterTag.Tr);
861			writer.AddStyleAttribute (HtmlTextWriterStyle.WhiteSpace, "nowrap");
862			writer.RenderBeginTag (HtmlTextWriterTag.Td);
863			writer.Write (HttpUtility.HtmlEncode (Controller.GetResourceString ("Upload_File", "Upload File")));
864			writer.RenderEndTag ();
865			writer.AddStyleAttribute (HtmlTextWriterStyle.Width, "100%");
866			writer.RenderBeginTag (HtmlTextWriterTag.Td);
867			writer.AddAttribute (HtmlTextWriterAttribute.Id, ClientID + "_Upload");
868			writer.AddAttribute (HtmlTextWriterAttribute.Name, ClientID + "_Upload");
869			writer.AddAttribute (HtmlTextWriterAttribute.Type, "file");
870			writer.AddStyleAttribute (HtmlTextWriterStyle.Width, "100%");
871			writer.RenderBeginTag (HtmlTextWriterTag.Input);
872			writer.RenderEndTag ();
873			writer.RenderEndTag ();
874			writer.RenderBeginTag (HtmlTextWriterTag.Td);
875			writer.AddAttribute (HtmlTextWriterAttribute.Type, "button");
876			writer.AddAttribute (HtmlTextWriterAttribute.Onclick, Page.ClientScript.GetPostBackEventReference (this, "Upload"));
877			writer.AddAttribute (HtmlTextWriterAttribute.Value, Controller.GetResourceString ("Submit", "Submit"));
878			writer.RenderBeginTag (HtmlTextWriterTag.Input);
879			writer.RenderEndTag ();
880			writer.RenderEndTag ();
881			writer.RenderEndTag ();
882			writer.RenderEndTag ();
883			writer.RenderEndTag ();
884		}
885
886		[System.Diagnostics.CodeAnalysis.SuppressMessage ("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
887		private void RenderBeginOuterTable (HtmlTextWriter writer) {
888			Controller.AddDirectionAttribute (writer);
889			writer.AddAttribute (HtmlTextWriterAttribute.Cellpadding, "0");
890			writer.AddAttribute (HtmlTextWriterAttribute.Cellspacing, "0");
891			writer.RenderBeginTag (HtmlTextWriterTag.Table);
892            writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top");
893            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
894			writer.RenderBeginTag (HtmlTextWriterTag.Td);
895		}
896
897		[System.Diagnostics.CodeAnalysis.SuppressMessage ("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
898		private void RenderEndOuterTable (HtmlTextWriter writer) {
899			writer.RenderEndTag ();
900			writer.RenderEndTag ();
901			writer.RenderEndTag ();
902		}
903
904		protected override object SaveViewState () {
905			object [] states = new object [6];
906
907			states [0] = base.SaveViewState ();
908			if (_toolbarStyle != null)
909				states [1] = ((IStateManager) _toolbarStyle).SaveViewState ();
910			if (_toolbarButtonStyle != null)
911				states [2] = ((IStateManager) _toolbarButtonStyle).SaveViewState ();
912			if (_toolbarButtonHoverStyle != null)
913				states [3] = ((IStateManager) _toolbarButtonHoverStyle).SaveViewState ();
914			if (_toolbarButtonPressedStyle != null)
915				states [4] = ((IStateManager) _toolbarButtonPressedStyle).SaveViewState ();
916			if (_cusomToolbarButtonCollection != null)
917				states [5] = ((IStateManager) _cusomToolbarButtonCollection).SaveViewState ();
918
919			for (int i = 0; i < states.Length; i++) {
920				if (states [i] != null)
921					return states;
922			}
923			return null;
924		}
925
926		protected override void LoadViewState (object savedState) {
927			if (savedState == null)
928				return;
929
930			object [] states = (object []) savedState;
931
932			base.LoadViewState (states [0]);
933			if (states [1] != null)
934				((IStateManager) ToolbarStyle).LoadViewState (states [1]);
935			if (states [2] != null)
936				((IStateManager) ToolbarButtonStyle).LoadViewState (states [2]);
937			if (states [3] != null)
938				((IStateManager) ToolbarButtonHoverStyle).LoadViewState (states [3]);
939			if (states [4] != null)
940				((IStateManager) ToolbarButtonPressedStyle).LoadViewState (states [4]);
941			if (states [5] != null)
942				((IStateManager) CustomToolbarButtons).LoadViewState (states [5]);
943		}
944
945		protected override void TrackViewState () {
946			base.TrackViewState ();
947
948			if (_toolbarStyle != null)
949				((IStateManager) _toolbarStyle).TrackViewState ();
950			if (_toolbarButtonStyle != null)
951				((IStateManager) _toolbarButtonStyle).TrackViewState ();
952			if (_toolbarButtonHoverStyle != null)
953				((IStateManager) _toolbarButtonHoverStyle).TrackViewState ();
954			if (_toolbarButtonPressedStyle != null)
955				((IStateManager) _toolbarButtonPressedStyle).TrackViewState ();
956			if (_cusomToolbarButtonCollection != null)
957				((IStateManager) _cusomToolbarButtonCollection).TrackViewState ();
958		}
959
960		void RaisePostBackEvent (string eventArgument) {
961			if (eventArgument == "Upload") {
962				HttpPostedFile uploadedFile = Page.Request.Files [ClientID + "_Upload"];
963				if (uploadedFile != null && uploadedFile.ContentLength > 0) {
964					FileManagerItemInfo dir = GetCurrentDirectory ();
965					Controller.ProcessFileUpload (dir, uploadedFile);
966				}
967			}
968			else if (eventArgument.StartsWith ("Toolbar:", StringComparison.Ordinal)) {
969				int i = int.Parse (eventArgument.Substring (8));
970				CustomToolbarButton button = CustomToolbarButtons [i];
971				OnToolbarCommand (new CommandEventArgs (button.CommandName, button.CommandArgument));
972			}
973		}
974
975		void OnToolbarCommand (CommandEventArgs e) {
976			if (ToolbarCommand != null)
977				ToolbarCommand (this, e);
978		}
979
980		internal override FileManagerItemInfo GetCurrentDirectory () {
981			return Controller.ResolveFileManagerItemInfo (_fileView.Directory);
982		}
983
984		#region IPostBackEventHandler Members
985
986		void IPostBackEventHandler.RaisePostBackEvent (string eventArgument) {
987			RaisePostBackEvent (eventArgument);
988		}
989
990		#endregion
991	}
992}