PageRenderTime 506ms CodeModel.GetById 267ms app.highlight 16ms RepoModel.GetById 219ms app.codeStats 0ms

/IZWebFileManager/Components/FileViewDetailsRender.cs

http://izwebfilemanager.googlecode.com/
C# | 216 lines | 157 code | 36 blank | 23 comment | 11 complexity | 0f27969d93fd1463fb1ac919302145ad 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.WebControls;
 21using System.Web.UI;
 22using System.Web;
 23using System.IO;
 24using System.Globalization;
 25
 26namespace IZ.WebFileManager.Components
 27{
 28	class FileViewDetailsRender : FileViewRender
 29	{
 30
 31		internal FileViewDetailsRender (FileView fileView) : base (fileView) { }
 32
 33		internal override void RenderBeginList (System.Web.UI.HtmlTextWriter output) {
 34			BorderedPanel panel = new BorderedPanel ();
 35			panel.Page = fileView.Page;
 36			if (fileView.DetailsColumnHeaderStyle.HorizontalAlign == HorizontalAlign.NotSet)
 37				fileView.DetailsColumnHeaderStyle.HorizontalAlign = fileView.Controller.CurrentUICulture.TextInfo.IsRightToLeft ? HorizontalAlign.Right : HorizontalAlign.Left;
 38			panel.ControlStyle.CopyFrom (fileView.DetailsColumnHeaderStyle);
 39
 40			output.AddAttribute (HtmlTextWriterAttribute.Cellpadding, "0");
 41			output.AddAttribute (HtmlTextWriterAttribute.Cellspacing, "0");
 42			output.AddAttribute (HtmlTextWriterAttribute.Border, "0");
 43			output.AddStyleAttribute (HtmlTextWriterStyle.Width, "100%");
 44			output.RenderBeginTag (HtmlTextWriterTag.Table);
 45			output.RenderBeginTag (HtmlTextWriterTag.Thead);
 46			output.RenderBeginTag (HtmlTextWriterTag.Tr);
 47			output.RenderBeginTag (HtmlTextWriterTag.Th);
 48
 49			output.AddAttribute (HtmlTextWriterAttribute.Onclick, fileView.GetSortEventReference (SortMode.Name));
 50			output.AddStyleAttribute (HtmlTextWriterStyle.Cursor, "default");
 51			output.AddStyleAttribute (HtmlTextWriterStyle.WhiteSpace, "nowrap");
 52			output.AddStyleAttribute (HtmlTextWriterStyle.Width, "100%");
 53			output.AddAttribute (HtmlTextWriterAttribute.Id, fileView.ClientID + "_Thead_Name");
 54
 55			panel.RenderBeginTag (output);
 56			output.Write (HttpUtility.HtmlEncode (controller.GetResourceString ("Name", "Name")));
 57			panel.RenderEndTag (output);
 58
 59			output.RenderEndTag ();
 60			output.RenderBeginTag (HtmlTextWriterTag.Th);
 61
 62			output.AddAttribute (HtmlTextWriterAttribute.Onclick, fileView.GetSortEventReference (SortMode.Size));
 63			output.AddStyleAttribute (HtmlTextWriterStyle.Cursor, "default");
 64			output.AddStyleAttribute (HtmlTextWriterStyle.WhiteSpace, "nowrap");
 65			output.AddStyleAttribute (HtmlTextWriterStyle.Width, "100%");
 66			output.AddAttribute (HtmlTextWriterAttribute.Id, fileView.ClientID + "_Thead_Size");
 67
 68			panel.RenderBeginTag (output);
 69			output.Write (HttpUtility.HtmlEncode (controller.GetResourceString ("Size", "Size")));
 70			panel.RenderEndTag (output);
 71
 72			output.RenderEndTag ();
 73			output.RenderBeginTag (HtmlTextWriterTag.Th);
 74
 75			output.AddAttribute (HtmlTextWriterAttribute.Onclick, fileView.GetSortEventReference (SortMode.Type));
 76			output.AddStyleAttribute (HtmlTextWriterStyle.Cursor, "default");
 77			output.AddStyleAttribute (HtmlTextWriterStyle.WhiteSpace, "nowrap");
 78			output.AddStyleAttribute (HtmlTextWriterStyle.Width, "100%");
 79			output.AddAttribute (HtmlTextWriterAttribute.Id, fileView.ClientID + "_Thead_Type");
 80
 81			panel.RenderBeginTag (output);
 82			output.Write (HttpUtility.HtmlEncode (controller.GetResourceString ("Type", "Type")));
 83			panel.RenderEndTag (output);
 84
 85			output.RenderEndTag ();
 86			output.RenderBeginTag (HtmlTextWriterTag.Th);
 87
 88			output.AddAttribute (HtmlTextWriterAttribute.Onclick, fileView.GetSortEventReference (SortMode.Modified));
 89			output.AddStyleAttribute (HtmlTextWriterStyle.Cursor, "default");
 90			output.AddStyleAttribute (HtmlTextWriterStyle.WhiteSpace, "nowrap");
 91			output.AddStyleAttribute (HtmlTextWriterStyle.Width, "100%");
 92			output.AddAttribute (HtmlTextWriterAttribute.Id, fileView.ClientID + "_Thead_Modified");
 93
 94			panel.RenderBeginTag (output);
 95			output.Write (HttpUtility.HtmlEncode (controller.GetResourceString ("Date_Modified", "Date Modified")));
 96			panel.RenderEndTag (output);
 97
 98			output.RenderEndTag ();
 99			output.RenderEndTag ();
100			output.RenderEndTag ();
101
102			output.AddStyleAttribute (HtmlTextWriterStyle.Overflow, "auto");
103			output.RenderBeginTag (HtmlTextWriterTag.Tbody);
104
105		}
106		internal override void RenderEndList (System.Web.UI.HtmlTextWriter output) {
107			output.RenderEndTag ();
108			output.RenderEndTag ();
109		}
110
111		internal override void RenderItem (HtmlTextWriter output, FileViewItem item) {
112			output.RenderBeginTag (HtmlTextWriterTag.Tr);
113
114			// Name Collumn
115			if (fileView.Sort == SortMode.Name)
116				fileView.DetailsSortedColumnStyle.AddAttributesToRender (output);
117			output.AddStyleAttribute (HtmlTextWriterStyle.PaddingLeft, "6px");
118			output.AddStyleAttribute (HtmlTextWriterStyle.PaddingRight, "6px");
119			output.AddStyleAttribute (HtmlTextWriterStyle.PaddingBottom, "1px");
120			output.AddStyleAttribute (HtmlTextWriterStyle.Cursor, "default");
121			output.AddStyleAttribute (HtmlTextWriterStyle.WhiteSpace, "nowrap");
122			output.RenderBeginTag (HtmlTextWriterTag.Td);
123
124			fileView.RenderItemBeginTag (output, item);
125
126			output.AddAttribute (HtmlTextWriterAttribute.Border, "0");
127			output.AddAttribute (HtmlTextWriterAttribute.Cellpadding, "0");
128			output.AddAttribute (HtmlTextWriterAttribute.Cellspacing, "0");
129			output.RenderBeginTag (HtmlTextWriterTag.Table);
130			output.RenderBeginTag (HtmlTextWriterTag.Tr);
131			output.RenderBeginTag (HtmlTextWriterTag.Td);
132
133			output.AddStyleAttribute (HtmlTextWriterStyle.Width, FileManagerController.SmallImageWidth.ToString (CultureInfo.InstalledUICulture));
134			output.AddStyleAttribute (HtmlTextWriterStyle.Height, FileManagerController.SmallImageHeight.ToString (CultureInfo.InstalledUICulture));
135			output.AddStyleAttribute (HtmlTextWriterStyle.BackgroundImage, item.SmallImage);
136			if (item.Hidden)
137				fileView.Controller.HiddenItemStyle.AddAttributesToRender (output);
138			output.RenderBeginTag (HtmlTextWriterTag.Div);
139			output.RenderEndTag ();
140
141			output.RenderEndTag ();
142			output.AddStyleAttribute (HtmlTextWriterStyle.Width, "100%");
143			output.RenderBeginTag (HtmlTextWriterTag.Td);
144
145			output.AddAttribute (HtmlTextWriterAttribute.Id, item.ClientID + "_Name");
146			output.AddStyleAttribute (HtmlTextWriterStyle.WhiteSpace, "nowrap");
147			output.RenderBeginTag (HtmlTextWriterTag.Div);
148			output.Write ("&nbsp;");
149			RenderItemName (output, item);
150			output.RenderEndTag ();
151
152			output.RenderEndTag ();
153			output.RenderEndTag ();
154			output.RenderEndTag ();
155
156			fileView.RenderItemEndTag (output);
157
158			output.RenderEndTag ();
159
160			// Size Collumn
161			if (fileView.Sort == SortMode.Size)
162				fileView.DetailsSortedColumnStyle.AddAttributesToRender (output);
163			output.AddStyleAttribute (HtmlTextWriterStyle.PaddingLeft, "6px");
164			output.AddStyleAttribute (HtmlTextWriterStyle.PaddingRight, "6px");
165			output.AddStyleAttribute (HtmlTextWriterStyle.PaddingBottom, "1px");
166			output.AddStyleAttribute (HtmlTextWriterStyle.Direction, "ltr");
167			output.AddStyleAttribute (HtmlTextWriterStyle.TextAlign, "right");
168			output.AddStyleAttribute (HtmlTextWriterStyle.Cursor, "default");
169			output.AddStyleAttribute (HtmlTextWriterStyle.WhiteSpace, "nowrap");
170			output.RenderBeginTag (HtmlTextWriterTag.Td);
171			output.Write (item.Size);
172			output.RenderEndTag ();
173
174			// Type Collumn
175			if (fileView.Sort == SortMode.Type)
176				fileView.DetailsSortedColumnStyle.AddAttributesToRender (output);
177			output.AddStyleAttribute (HtmlTextWriterStyle.PaddingLeft, "6px");
178			output.AddStyleAttribute (HtmlTextWriterStyle.PaddingRight, "6px");
179			output.AddStyleAttribute (HtmlTextWriterStyle.PaddingBottom, "1px");
180			output.AddStyleAttribute (HtmlTextWriterStyle.Cursor, "default");
181			output.AddStyleAttribute (HtmlTextWriterStyle.WhiteSpace, "nowrap");
182			output.RenderBeginTag (HtmlTextWriterTag.Td);
183			output.Write (HttpUtility.HtmlEncode (item.Type));
184			output.RenderEndTag ();
185
186			// Modified Collumn
187			if (fileView.Sort == SortMode.Modified)
188				fileView.DetailsSortedColumnStyle.AddAttributesToRender (output);
189			output.AddStyleAttribute (HtmlTextWriterStyle.PaddingLeft, "6px");
190			output.AddStyleAttribute (HtmlTextWriterStyle.PaddingRight, "6px");
191			output.AddStyleAttribute (HtmlTextWriterStyle.PaddingBottom, "1px");
192			output.AddStyleAttribute (HtmlTextWriterStyle.Cursor, "default");
193			output.AddStyleAttribute (HtmlTextWriterStyle.WhiteSpace, "nowrap");
194			output.RenderBeginTag (HtmlTextWriterTag.Td);
195			output.Write (HttpUtility.HtmlEncode (item.Modified));
196			output.RenderEndTag ();
197
198
199			output.RenderEndTag ();
200		}
201
202		internal override void RenderBeginGroup (HtmlTextWriter output, GroupInfo group) {
203			output.RenderBeginTag (HtmlTextWriterTag.Tr);
204			output.AddAttribute (HtmlTextWriterAttribute.Colspan, "4");
205			output.RenderBeginTag (HtmlTextWriterTag.Td);
206			base.RenderBeginGroup (output, group);
207			output.RenderEndTag ();
208			output.RenderEndTag ();
209		}
210
211		//internal override void RenderEndGroup(HtmlTextWriter output, GroupInfo group)
212		//{
213		//    base.RenderEndGroup(output, group);
214		//}
215	}
216}