Public Member Functions | |
| override bool | CanOpen (string location) |
| This will implement the protocol "htmlview". | |
| override FSFile | OpenFile (FileSystem fs, string location) |
| This method implements the contents of the virtual file system. | |
| SpecialPagesAsFiles (HtmlHelpFrame dataSource) | |
This class exemplifies a method to extend wxWidgets HTML dialog with logic: Building HTML pages by the program code that will be made visible through special URLs using protocol "helpview:". This file system handler provides the pages on the management of favourite bookmarks and hyper text books.
Thus, this file system acts somehow like a web server that is tightly integrated into the application to present and maintain data. However, instead of HTML forms or java script this server will use special HTML tags placing wxWidgets controls on the page.
Refer to OpenFile() for the defined pages.
Definition at line 565 of file HelpView.cs.
| wx.Html.Help.HtmlHelpFrame.SpecialPagesAsFiles.SpecialPagesAsFiles | ( | HtmlHelpFrame | dataSource | ) |
| override bool wx.Html.Help.HtmlHelpFrame.SpecialPagesAsFiles.CanOpen | ( | string | location | ) |
This will implement the protocol "htmlview".
The different pages will be distinguished according to the name of the file. Refer to OpenFile().
Definition at line 681 of file HelpView.cs.
| override FSFile wx.Html.Help.HtmlHelpFrame.SpecialPagesAsFiles.OpenFile | ( | FileSystem | fs, | |
| string | location | |||
| ) |
This method implements the contents of the virtual file system.
Definition at line 577 of file HelpView.cs.
References wx.Html.Help.HtmlHelpFrame._BookmarkOrder.
00578 { 00579 string leftLocation = this.GetRightLocation(location); 00580 string protocol = this.GetProtocol(location); 00581 Stream result = null; 00582 using (StringWriter sw = new StringWriter()) 00583 { 00584 sw.WriteLine("<html>\n<head>"); 00585 sw.WriteLine("<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">"); 00586 if (leftLocation == "artprovider.html") 00587 { 00588 sw.WriteLine(string.Format("<title>{0}</title>", _("List Of Art Items"))); 00589 sw.WriteLine("</head>\n<body bgcolour=\"#ffffff\">"); 00590 00591 sw.WriteLine("<h1>The Bitmaps Of <code>wx.ArtProvider</code> In Different Sizes For Different Clients</h1>"); 00592 00593 int[] sizes = new int[] { 8, 16, 32, 48 }; 00594 sw.WriteLine("<table border=\"1\">"); 00595 sw.Write("<tr><th>wx.ArtID</th>"); 00596 foreach (int size in sizes) 00597 sw.Write("<th><p><code>{1}</code></p><p>{0}x{0}</p></th>", size, wx.ArtClient.wxART_OTHER.ToString()); 00598 foreach (wx.ArtClient artClient in Enum.GetValues(typeof(wx.ArtClient))) 00599 { 00600 sw.Write("<th><code>{0}</code></th>", artClient); 00601 } 00602 sw.WriteLine("</tr>"); 00603 00604 foreach (int artIndex in Enum.GetValues(typeof(wx.ArtID))) 00605 { 00606 sw.Write("<tr>"); 00607 ArtID artId = (ArtID)artIndex; 00608 sw.Write("<td><tt>{0}</tt></td>", artId); 00609 foreach (int size in sizes) 00610 sw.Write("<td><wxart artid=\"{0}\" x=\"{1}\" y=\"{2}\"></td>", artId.ToString(), size, size); 00611 foreach (int artClient in Enum.GetValues(typeof(wx.ArtClient))) 00612 sw.Write("<td><wxart artid=\"{0}\" client=\"{1}\"></td>", artId.ToString(), ((wx.ArtClient)artClient).ToString()); 00613 sw.WriteLine("</tr>"); 00614 } 00615 sw.WriteLine("</table>"); 00616 } 00617 else if (leftLocation == "bookmarks.html" 00618 || leftLocation == "bookmarksByName.html" 00619 || leftLocation == "bookmarksByUses.html" 00620 || leftLocation == "bookmarksByLastUse.html") 00621 { 00622 sw.WriteLine(string.Format("<title>{0}</title>", _("List Of Bookmarks"))); 00623 sw.WriteLine("</head>\n<body bgcolour=\"#ffffff\" background=\"zrs:helpview.zrs//wxnetbg.png\">"); 00624 00625 if (leftLocation == "bookmarksByName.html") this._dataSource._BookmarkOrder = BookmarkOrder.ByName; 00626 else if (leftLocation == "bookmarksByUses.html") this._dataSource._BookmarkOrder = BookmarkOrder.ByUses; 00627 else if (leftLocation == "bookmarksByLastUse.html") this._dataSource._BookmarkOrder = BookmarkOrder.ByFinalUseDate; 00628 00629 BookmarkComparer cmp = new BookmarkComparer(this._dataSource._BookmarkOrder); 00630 this._dataSource._BookmarkSpecs.Sort(cmp); 00631 sw.WriteLine("<table width=\"100%\" border=\"1\">"); 00632 sw.WriteLine("<tr>"); 00633 if (this._dataSource._BookmarkOrder == BookmarkOrder.ByName) 00634 sw.WriteLine(string.Format("<th bgcolor=\"#A6B3FF\" color=\"#000000\">{0}</th>", _("Title"))); 00635 else 00636 sw.WriteLine(string.Format("<th bgcolor=\"#A6B3FF\" color=\"#000000\"><a href=\"{1}:bookmarksByName.html\">{0}</a></th>", _("Title"), protocol)); 00637 sw.WriteLine(string.Format("<th bgcolor=\"#A6B3FF\" color=\"#000000\">{0}</th>", _("Descr."))); 00638 if (this._dataSource._BookmarkOrder == BookmarkOrder.ByUses) 00639 sw.WriteLine(string.Format("<th bgcolor=\"#A6B3FF\" color=\"#000000\">{0}</th>", _("Freq."))); 00640 else 00641 sw.WriteLine(string.Format("<th bgcolor=\"#A6B3FF\" color=\"#000000\"><a href=\"{1}:bookmarksByUses.html\">{0}</a></th>", _("Freq."), protocol)); 00642 if (this._dataSource._BookmarkOrder == BookmarkOrder.ByFinalUseDate) 00643 sw.WriteLine(string.Format("<th bgcolor=\"#A6B3FF\" color=\"#000000\">{0}</th>", _("Last Use"))); 00644 else 00645 sw.WriteLine(string.Format("<th bgcolor=\"#A6B3FF\" color=\"#000000\"><a href=\"{1}:bookmarksByLastUse.html\">{0}</a></th>", _("Last Use"), protocol)); 00646 sw.WriteLine("<th> </th></tr>"); 00647 00648 for (int i = this._dataSource.NumberOfStandardBookmarks; i < this._dataSource._BookmarkSpecs.Count; ++i) 00649 { 00650 BookmarkEntry entry=(BookmarkEntry)this._dataSource._BookmarkSpecs[i]; 00651 sw.WriteLine("<tr>"); 00652 sw.WriteLine(string.Format("<td><a href=\"{1}\">{0}</a></td>", entry.Name, entry.Page)); 00653 sw.WriteLine(string.Format("<td>{0}</td>", entry.Description)); 00654 sw.WriteLine(string.Format("<td>{0}</td>", entry.Uses)); 00655 sw.WriteLine(string.Format("<td>{0}</td>", entry.LastUse.ToString("u"))); 00656 sw.WriteLine(string.Format("<td><wxbutton labelart=\"{0}\" cmd=\"{1}\" eventstring=\"{2}\"></td>", (int)ArtID.wxART_NORMAL_FILE, (int)Cmd.wxID_HTML_EDITBOOKMARK, entry.Page)); 00657 sw.WriteLine("</tr>"); 00658 } 00659 00660 sw.WriteLine("</table>"); 00661 } 00662 else 00663 { 00664 sw.WriteLine(string.Format("<title>{0}</title>", _("Unknown page in virtual file system"))); 00665 sw.WriteLine("</head>\n<body bgcolour=\"#ffffff\" background=\"zrs:helpview.zrs//wxnetbg.png\">"); 00666 sw.WriteLine(string.Format(_("The URL \"{0}\" is unknown to this virtual file system."), location)); 00667 } 00668 00669 sw.WriteLine("</body></html>"); 00670 00671 result = new MemoryStream(Encoding.UTF8.GetBytes(sw.ToString())); 00672 } 00673 result.Seek(0, SeekOrigin.Begin); 00674 return new FSFile(result, leftLocation, "text/html", "", DateTime.Now); 00675 }
(c) 2003-2010 the wx.NET project