From: <br...@us...> - 2009-02-03 22:50:37
|
Revision: 483 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=483&view=rev Author: brus07 Date: 2009-02-03 22:50:29 +0000 (Tue, 03 Feb 2009) Log Message: ----------- Added HtmlBuilder for Build html page to LibraryExtention. Modified Paths: -------------- ACMServer/trunk/ACMServer/Library/LibraryExtention/LibraryExtention.csproj Added Paths: ----------- ACMServer/trunk/ACMServer/Library/LibraryExtention/HtmlBuilder.cs Added: ACMServer/trunk/ACMServer/Library/LibraryExtention/HtmlBuilder.cs =================================================================== --- ACMServer/trunk/ACMServer/Library/LibraryExtention/HtmlBuilder.cs (rev 0) +++ ACMServer/trunk/ACMServer/Library/LibraryExtention/HtmlBuilder.cs 2009-02-03 22:50:29 UTC (rev 483) @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace AcmContester.Library.LibraryExtention +{ + public class HtmlBuilder + { + private string title; + private string body; + private string bgcolor; + + public string Title + { + get + { + return title; + } + set + { + title = value; + } + } + + public string BackgroundColor + { + get + { + return bgcolor; + } + set + { + bgcolor = value; + } + } + + public string Result + { + get + { + string res = "<html>\n<head>\n\t<title>" + title + "</title>\n</head>"; + res = res + "<body bgcolor=\"" + bgcolor + ">\n" + body + "</body>\n</html>"; + return res; + } + } + + public void AddTable(string[,] data,string[] header,string caption) + { + body += "<table>\n"; + if (caption!="") + body+="<caption>" + caption + "</caption>\n"; + if (header.Length>0) + { + body+="<tr>"; + for (int i = 0; i < header.Length; i++) + body += "<th>" + header[i] + "</th>"; + body+="\n"; + } + for (int i=0;i<data.GetLength(0);i++) + { + body += "<tr>"; + for (int j = 0; j < data.GetLength(1); j++) + body += "<td>" + data[i,j] + "</td>"; + body += "</tr>\n"; + } + body += "</table>"; + } + + public void AddReference(string URL, string text) + { + body += "<a href=\"" + URL + "\">" + text + "</a> "; + } + + public void AddReference(string URL, string text, string align) + { + body += "<a align=\""+align+"\" href=\"" + URL + "\">" + text + "</a> "; + } + + public void AddParagraph(string data, string align, string color) + { + body += "<p align=\"" + align + "\" color=\"" + color + "\" >" + data + "</p>\n"; + } + + public void AddParagraph(string data, string align) + { + body += "<p align=\"" + align + "\" >" + data + "</p>\n"; + } + + public void AddParagraph(string data) + { + body += "<p>" + data + "</p>\n"; + } + + public void AddHorizLine() + { + body+="\n<hr>\n"; + } + + public void AddList(string[] data, bool ordered) + { + if (ordered) + body += "<ol>\n"; + else + body += "<ul>\n"; + for (int i = 0; i < data.Length; i++) + body += "<li>" + data[i] + "\n"; + if (ordered) + body += "</ol>\n"; + else + body += "</ul>\n"; + } + + public void AddText(string data) + { + body += data; + } + + public void AddCode(string data) + { + body += "<code>" + data + "</code>\n"; + } + + public void AddHeader(string data, int size, string align) //size from 1 to 6 + { + body += "<h" + size.ToString() + " align=\"" + align + "\">" + data + "</h" + size.ToString() + ">\n"; + } + } +} Modified: ACMServer/trunk/ACMServer/Library/LibraryExtention/LibraryExtention.csproj =================================================================== --- ACMServer/trunk/ACMServer/Library/LibraryExtention/LibraryExtention.csproj 2009-02-03 11:33:16 UTC (rev 482) +++ ACMServer/trunk/ACMServer/Library/LibraryExtention/LibraryExtention.csproj 2009-02-03 22:50:29 UTC (rev 483) @@ -34,6 +34,7 @@ </ItemGroup> <ItemGroup> <Compile Include="Configuration.cs" /> + <Compile Include="HtmlBuilder.cs" /> <Compile Include="IniFile.cs" /> <Compile Include="Log.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> @@ -51,4 +52,4 @@ <Target Name="AfterBuild"> </Target> --> -</Project> +</Project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |