Example #1
0
        static string GetColumnTd(ResourceColumn column)
        {
            switch (column)
            {
            case ResourceColumn.Created:
            case ResourceColumn.Modified:
                return("<td nowrap=\"true\">&nbsp;&nbsp;");

            case ResourceColumn.Size:
                return("<td align=\"right\" nowrap=\"true\">&nbsp;&nbsp;");

            case ResourceColumn.Name:
                return("<td>&nbsp;&nbsp;");

            default:
                return("<td>&nbsp;&nbsp;");
            }
        }
Example #2
0
		static string GetColumnTd(ResourceColumn column)
		{
			switch(column)
			{
				case ResourceColumn.Created:
				case ResourceColumn.Modified:
					return "<td nowrap=\"true\">&nbsp;&nbsp;";
				case ResourceColumn.Size:
					return "<td align=\"right\" nowrap=\"true\">&nbsp;&nbsp;";
				case ResourceColumn.Name:
					return "<td>&nbsp;&nbsp;";
				default:
					return "<td>&nbsp;&nbsp;";
			}
		}
Example #3
0
			public void WriteHtml(StreamWriter writer, ResourceColumn[] columns)
			{
				try
				{
					if(path != null)
					{
						if((File.GetAttributes(path) & FileAttributes.Hidden) != 0)
							return;
					}
				}
				catch(IOException)
				{
				}

				writer.WriteLine("<tr>");

				foreach(ResourceColumn column in columns)
				{
					writer.Write(GetColumnTd(column));
					switch(column)
					{
						case ResourceColumn.Created:
							if(path != null)
								if(Created != DateTime.MinValue)
									writer.Write(Created.ToString());
							break;
						case ResourceColumn.Modified:
							if(path != null)
								if(Modified != DateTime.MinValue)
									writer.Write(Modified.ToString());
							break;
						case ResourceColumn.Size:
							if(!isDir)
								if(path != null)
									if(Size != -1)
										writer.Write(ReadableDataLength.Calculate(Size));
							break;
						case ResourceColumn.Name:
							writer.WriteLine("<a href=\"" + UrlEncoding.Encode(resource.Name) +
								(isDir ? "/\">[" : "\">") + resource.Name + (isDir ? "]" : "") +"</a>");
							break;
					}
					writer.WriteLine("</td>");
				}

				writer.WriteLine("</tr>");
			}
Example #4
0
			public ResourceComparer(bool reverse, ResourceColumn column)
			{
				this.reverse = reverse;
				this.column = column;
			}
Example #5
0
 public ResourceComparer(bool reverse, ResourceColumn column)
 {
     this.reverse = reverse;
     this.column  = column;
 }
Example #6
0
        internal override void PrintBody(StreamWriter writer,
                                         HttpRequest request,
                                         IDirectory directory,
                                         ICollection dirs,
                                         ICollection files
                                         )
        {
            bool reverse = request.Query["desc"] != null;

            ResourceColumn sort = ResourceColumn.None;

            try
            {
                string sortString = request.Query["sort"];
                if (sortString != null && sortString != string.Empty)
                {
                    sort = (ResourceColumn)Enum.Parse(typeof(ResourceColumn), sortString);
                }
            }
            catch (ArgumentException)
            {
            }

            writer.WriteLine("<h2>Index of " + MakeLinkPath(directory, request) + "</h2>");

            writer.WriteLine("<table cellspacing=\"0\">");

            writer.WriteLine("<tr>");
            foreach (ResourceColumn column in columns)
            {
                writer.Write(GetColumnTd(column) + "<b><a href=\"" + "." + "?sort=" + column.ToString());
                if (sort == column && !reverse)
                {
                    writer.Write("&desc");
                }
                writer.Write("\"/>");
                writer.WriteLine(column.ToString() + "</a></b></td>");
            }
            writer.WriteLine("</tr>");

            ArrayList entries = new ArrayList(dirs.Count + files.Count);

            foreach (IDirectory dir in dirs)
            {
                entries.Add(new ResourceEntry(dir));
            }
            foreach (IFile file in files)
            {
                entries.Add(new ResourceEntry(file));
            }

            if (sort != ResourceColumn.None)
            {
                entries.Sort(new ResourceComparer(reverse, sort));
            }

            foreach (ResourceEntry entry in entries)
            {
                entry.WriteHtml(writer, columns);
            }

            writer.WriteLine("</table>");
        }