using System; using System.Collections.Generic; using System.Web.UI; using System.Web.UI.WebControls; namespace ExWeb { public partial class Mod_Par : System.Web.UI.Page { public static string[] Modules = new string[] { "calendar", "content", "directory", "download", "image", "inline", "links", "maps", "password", "picasa", "search", "sendmail", "template", "upload" }; protected void Page_Load(object sender, EventArgs e) { string ModuleToShow = Mod.GetQs_String("mod", "", this.Page); string Show = Mod.GetQs_String("show", "", this.Page); string[][] Help_Attributes = GetAttributes(ModuleToShow); string Help_Description = GetHelp(ModuleToShow); SortedList<string, string> list = Mod.GetQs(this.Page); string QS = ""; string Path = ""; for (int i = 0; i < list.Count; i++) { string Key = list.Keys[i].ToLower(); string Value = list[list.Keys[i]]; switch (Key) { case "fil": if (Path == "") Path = Value; else Path = Value + Path; break; case "pat": if (!Value.EndsWith("/")) Value += "/"; if (Path == "") Path = Value; else Path = Value + Path; break; default: QS += "<b>" + Key + "</b>:" + Value + " "; break; case "id": case "ix": break; } } switch (Show.ToLower()) { case "doc": Label_Title.Text += "Modul: " + ModuleToShow + "<br/>Dokumentation"; break; case "exe": Label_Title.Text += "Modul: " + ModuleToShow + "<br/>Ausführung" + "<br/>" + Path; break; case "all": Label_Title.Text += "Liste aller Module"; Label_Title.Text += "<br/>Für detaillierte Beschreibung und Beispielanwendungen im Menü links auf das jeweilige Untermenü 'Module... klicken"; break; default: Label_Title.Text += Path + "<br/>" + QS; break; } switch (Show.ToLower()) { case "doc": // Label_Title.Text = "Documentation "; List<Control> Help = ShowHelp(this.Page, "Mod_" + ModuleToShow + ".ascx", ModuleToShow.ToLower(), Help_Description, Help_Attributes); for (int i = 0; i < Help.Count; i++) { PlaceHolder_Mod.Controls.Add(Help[i]); } break; case "exe": // Label_Title.Text = "Test "; string Iframe_Code = Mod_Inline.GetIframe("TestFrame", Mod.GetQs_String("pat", "", this.Page) + Mod.GetQs_String("fil", "", this.Page), -1, -1, "auto"); PlaceHolder_Mod.Controls.Add(new LiteralControl(Iframe_Code)); break; case "all": string s = "<table>"; for (int i = 0; i < Mod_Par.Modules.Length; i++) s += "<tr><td valign='top'><p style='font-weight:bold;'>" + Mod_Par.Modules[i] + "</p></td><td valign='top'>" + MakeHtml(GetHelp(Modules[i])) + "</td></tr>"; s += "</table>"; PlaceHolder_Mod.Controls.Add(new LiteralControl(s)); break; default: // Label_Title.Text = "Module: " + ModuleToShow; Control c; switch (ModuleToShow.ToLower()) { case "calendar": c = LoadControl("~/Mod/Mod_Calendar.ascx"); PlaceHolder_Mod.Controls.Add(c); break; case "content": c = LoadControl("~/Mod/Mod_Content.ascx"); PlaceHolder_Mod.Controls.Add(c); break; case "directory": c = LoadControl("~/Mod/Mod_Directory.ascx"); PlaceHolder_Mod.Controls.Add(c); break; case "download": c = LoadControl("~/Mod/Mod_Download.ascx"); PlaceHolder_Mod.Controls.Add(c); break; case "image": c = LoadControl("~/Mod/Mod_Image.ascx"); PlaceHolder_Mod.Controls.Add(c); break; case "inline": c = LoadControl("~/Mod/Mod_Inline.ascx"); PlaceHolder_Mod.Controls.Add(c); break; case "links": c = LoadControl("~/Mod/Mod_Links.ascx"); PlaceHolder_Mod.Controls.Add(c); break; case "maps": c = LoadControl("~/Mod/Mod_Maps.ascx"); PlaceHolder_Mod.Controls.Add(c); break; case "password": c = LoadControl("~/Mod/Mod_Password.ascx"); PlaceHolder_Mod.Controls.Add(c); break; case "picasa": c = LoadControl("~/Mod/Mod_Picasa.ascx"); PlaceHolder_Mod.Controls.Add(c); break; case "search": c = LoadControl("~/Mod/Mod_Search.ascx"); PlaceHolder_Mod.Controls.Add(c); break; case "sendmail": c = LoadControl("~/Mod/Mod_Sendmail.ascx"); PlaceHolder_Mod.Controls.Add(c); break; case "template": c = LoadControl("~/Mod/Mod_Template.ascx"); PlaceHolder_Mod.Controls.Add(c); break; case "upload": c = LoadControl("~/Mod/Mod_Upload.ascx"); PlaceHolder_Mod.Controls.Add(c); break; default: case "doc": case "exe": c = null; return; } break; } } public string[] HelpHeader = new string[] { "Attribut", "Werte", "Default", "Optional", "Beschreibung", "Beispiel" }; public bool[] HelpTt = new bool[] { true, true, true, false, false, true }; public System.Web.UI.WebControls.HorizontalAlign[] HelpHorizontalAlign = new System.Web.UI.WebControls.HorizontalAlign[] { System.Web.UI.WebControls.HorizontalAlign.Left, System.Web.UI.WebControls.HorizontalAlign.Center, System.Web.UI.WebControls.HorizontalAlign.Center, System.Web.UI.WebControls.HorizontalAlign.Center, System.Web.UI.WebControls.HorizontalAlign.Left, System.Web.UI.WebControls.HorizontalAlign.Left }; public string MakeHtml(string txt) { txt = txt.Replace("<pre>", "##pre##"); txt = txt.Replace("</pre>", "##/pre##"); txt = txt.Replace("<tt>", "##tt##"); txt = txt.Replace("</tt>", "##/tt##"); txt = Mod.Untag(txt); txt = txt.Replace("##pre##", "<pre>"); txt = txt.Replace("##/pre##", "</pre>"); txt = txt.Replace("##tt##", "<tt>"); txt = txt.Replace("##/tt##", "</tt>"); return "<p>" + txt.Replace("\r\n\r\n", "</p><p>").Replace("\r\n", "<br/>") + "</p>"; } public List<Control> ShowHelp(Page p, string ModuleFile, string ModuleCode, string Help_Description, string[][] Help_Attributes) { List<Control> ctrls = new List<Control>(); Label l = new Label(); l.Text = "<h3>Funktion</h3>" + MakeHtml(Help_Description) + "<h3>Anwendung</h3>" + "<p>In einer Seite .aspx wird unmittelbar nach der Kopfzeile <tt><@Page...</tt> eingefügt: "; ctrls.Add(l); Mod_Inline mi = (Mod_Inline)p.LoadControl(Mod.RelPathToMod + "Mod_Inline.ascx"); mi.Mode = "high"; mi.Text = "<%@ Register " + "\r\nTagPrefix=\"mod\"" + "\r\nTagName=\"" + ModuleCode + "\"" + "\r\nSrc=\"" + ModuleFile + "\"" + "\r\n%>\r\n"; mi.Extension = "xml"; ctrls.Add(mi); l = new Label(); l.Text = "und an der Stelle, an der das Modul benötigt wird:"; ctrls.Add(l); mi = (Mod_Inline)p.LoadControl(Mod.RelPathToMod + "Mod_Inline.ascx"); mi.Mode = "high"; mi.Text = " \r\n<mod:" + ModuleCode + " " + "\r\nrunat=\"server\" " + "\r\nID=" + ModuleCode + "1" + "\r\nAttribut1=\"wert1\"" + "\r\nAttribut2=\"wert2\"" + "\r\n...>" + "\r\n</mod:" + ModuleCode + ">"; mi.Extension = "xml"; ctrls.Add(mi); l = new Label(); l.Text = "wobei die Attribute der nachfolgenden Tabelle verwendet werden" + "<h3>Attribute</h3>" ; ctrls.Add(l); Table table = new Table(); table.Rows.Add(GetHelpRow(HelpHeader, true, false)); for (int i = 0; i < Help_Attributes.Length; i++) { table.Rows.Add(GetHelpRow(Help_Attributes[i], false, false)); } ctrls.Add(table); return ctrls; } private TableRow GetHelpRow(string[] HelpRow, bool Header, bool Common) { TableRow tr = (Header ? new TableHeaderRow() : new TableRow()); TableCell tc; for (int i = 0; i < HelpRow.Length; i++) { tc = (Header ? new TableHeaderCell() : new TableCell()); tc.Text = HelpRow[i]; tc.HorizontalAlign = HelpHorizontalAlign[i]; if (Common) tc.BackColor = System.Drawing.Color.LightGray; if (!Header) if (HelpTt[i]) tc.Text = "<tt>" + tc.Text + "</tt>"; tr.Cells.Add(tc); } return tr; } private string[][] GetAttributes(string Module) { string[][] Help_Attributes = null; switch (Module.ToLower()) { default: break; case "common": Help_Attributes = Mod.Help_Attributes; break; case "calendar": Help_Attributes = Mod_Calendar.Help_Attributes; break; case "content": Help_Attributes = Mod_Content.Help_Attributes; break; case "directory": Help_Attributes = Mod_Directory.Help_Attributes; break; case "download": Help_Attributes = Mod_Download.Help_Attributes; break; case "image": Help_Attributes = Mod_Image.Help_Attributes; break; case "inline": Help_Attributes = Mod_Inline.Help_Attributes; break; case "links": Help_Attributes = Mod_Links.Help_Attributes; break; case "maps": Help_Attributes = Mod_Maps.Help_Attributes; break; case "password": Help_Attributes = Mod_Password.Help_Attributes; break; case "picasa": Help_Attributes = Mod_Picasa.Help_Attributes; break; case "search": Help_Attributes = Mod_Search.Help_Attributes; break; case "sendmail": Help_Attributes = Mod_Sendmail.Help_Attributes; break; case "template": Help_Attributes = Mod_Template.Help_Attributes; break; case "upload": Help_Attributes = Mod_Upload.Help_Attributes; break; } return Help_Attributes; } private string GetHelp(string Module) { string Help_Description = ""; switch (Module.ToLower()) { default: break; case "common": Help_Description = Mod.Help_Description; break; case "calendar": Help_Description = Mod_Calendar.Help_Description; break; case "content": Help_Description = Mod_Content.Help_Description; break; case "directory": Help_Description = Mod_Directory.Help_Description; break; case "download": Help_Description = Mod_Download.Help_Description; break; case "image": Help_Description = Mod_Image.Help_Description; break; case "inline": Help_Description = Mod_Inline.Help_Description; break; case "links": Help_Description = Mod_Links.Help_Description; break; case "maps": Help_Description = Mod_Maps.Help_Description; break; case "password": Help_Description = Mod_Password.Help_Description; break; case "picasa": Help_Description = Mod_Picasa.Help_Description; break; case "search": Help_Description = Mod_Search.Help_Description; break; case "sendmail": Help_Description = Mod_Sendmail.Help_Description; break; case "template": Help_Description = Mod_Template.Help_Description; break; case "upload": Help_Description = Mod_Upload.Help_Description; break; } return Help_Description; } } }