public override void InitRemotable(DextopRemote remote, DextopConfig config) { base.InitRemotable(remote, config); Remote.RemoteHostType = "Showcase.Session"; config["aboutPageUrl"] = DextopUtil.AbsolutePath("source/About.html?cb=" + DateTime.Now.Ticks); }
/// <summary> /// Preconfigure a sound. /// </summary> /// <param name="name">The name.</param> /// <param name="url">The URL.</param> public void AddSound(String name, String url) { if (sounds == null) { sounds = new Dictionary <string, string>(); } sounds.Add(name, DextopUtil.AbsolutePath(url)); }
/// <summary> /// Register session within the module. Module can optionaly create a remotable object associated with the session. /// </summary> /// <param name="session"></param> /// <returns></returns> protected internal override Remoting.IDextopRemotable RegisterSession(DextopSession session) { var config = new DextopConfig(); config.Add("url", DextopUtil.AbsolutePath(DextopUtil.CombinePaths(base.VirtualPath, "soundmanager2/swf"))); if (sounds != null) { config.Add("sounds", sounds); } return(new DextopRemotableConfig("Dextop.modules.SoundModule", config)); }
void RenderReport(HttpContext context) { var type = context.Request.QueryString["type"]; Report report; switch (type) { case "GdpByYear": report = Reports.GdpByYearReport.Generate(); break; case "GdpByCountry": report = Reports.GdpByCountryReport.Generate(); break; case "BiggestCountries": report = Reports.GdpYearColumnReport.BiggestCountries(); break; case "FastestGrowingCountries": report = Reports.GdpYearColumnReport.FastestGrowingCountries(); break; case "BestCountries": report = Reports.GdpYearColumnReport.BestCountries(); break; default: throw new InvalidOperationException("Invalid report type."); } try { switch (context.Request.QueryString["format"]) { case "pdf": var url = context.Request.Url.ToString().Replace("format=pdf", "print=1"); PdfConvert.ConvertHtmlToPdf(new PdfDocument { Url = url }, new PdfOutput { OutputStream = context.Response.OutputStream }); context.Response.SetFileDownloadHeaders(String.Format("Report{0}.pdf", DateTime.Now.Ticks)); break; case "text": context.Response.SetFileDownloadHeaders(String.Format("Report{0}.txt", DateTime.Now.Ticks)); TextReportWriter.WriteTo(report, context.Response.Output); break; case "xlsx": context.Response.SetFileDownloadHeaders(String.Format("Report{0}.xlsx", DateTime.Now.Ticks)); XlsxReportWriter.WriteToStream(report, Themes.Default, context.Response.OutputStream); break; default: var output = new HtmlTextWriter(context.Response.Output); var htmlWriter = new HtmlReportWriter(output); htmlWriter.RegisterCss(DextopUtil.AbsolutePath("client/css/report.css")); if (context.Request.QueryString["print"] == null) { htmlWriter.RegisterCss(DextopUtil.AbsolutePath("client/css/report-preview.css")); } htmlWriter.Write(report, new DefaultHtmlReportTheme()); break; } } catch (Exception ex) { context.Response.Write(ex.ToString()); } }
public void ProcessAssemblies(DextopApplication application, IList <Assembly> assemblies, Stream output) { using (var tw = new StreamWriter(output)) { DextopJsWriter jw = new DextopJsWriter(tw); var assembly = this.GetType().Assembly; var data = AssemblyHelper.GetTypeAttributeDictionaryForAssembly <DemoAttribute>(assembly, false); jw.ExtNamespace("Showcase"); jw.Write("Showcase.Demos = ["); bool first = true; HashSet <String> levels = new HashSet <string>(); HashSet <String> categories = new HashSet <string>(); HashSet <String> topics = new HashSet <string>(); foreach (var entry in data) { var att = entry.Value; if (first) { first = false; } else { jw.Write(", "); } jw.StartBlock(); jw.AddProperty("id", att.Id); jw.DefaultProperty("title", att.Title); jw.DefaultProperty("description", att.Description); jw.AddProperty("clientLauncher", att.ClientLauncher); LevelAttribute level; if (AttributeHelper.TryGetAttribute <LevelAttribute>(entry.Key, out level, false)) { jw.AddProperty("level", level.Name); } TopicAttribute topic; if (AttributeHelper.TryGetAttribute <TopicAttribute>(entry.Key, out topic, false)) { jw.AddProperty("topic", topic.Name); } CategoryAttribute cat; if (AttributeHelper.TryGetAttribute <CategoryAttribute>(entry.Key, out cat, false)) { jw.AddProperty("category", cat.Name); } jw.AddProperty("sourceUrlBase", DextopUtil.AbsolutePath(String.Format("source/{0}", att.Id))); jw.AddProperty("cacheBuster", GetCacheBuster(att)); jw.CloseBlock(); ((ShowcaseApplication)application).RegisterDemo(att.Id, entry.Key); if (!levels.Contains(level.Name)) { levels.Add(level.Name); } if (!topics.Contains(topic.Name)) { topics.Add(topic.Name); } if (!categories.Contains(cat.Name)) { categories.Add(cat.Name); } } jw.WriteLine("];"); jw.WriteLine(); jw.Write("Showcase.Topics = "); jw.Write(DextopUtil.Encode(topics.ToArray())); jw.WriteLine(";"); jw.WriteLine(); jw.Write("Showcase.Levels = "); jw.Write(DextopUtil.Encode(levels.ToArray())); jw.WriteLine(";"); jw.WriteLine(); jw.Write("Showcase.Categories = "); jw.Write(DextopUtil.Encode(categories.ToArray())); jw.WriteLine(";"); } }
String ArticleUrl(String filePath, DateTime lastWriteTime) { var vpath = filePath.Substring(OutputPath.Length).Replace(Path.DirectorySeparatorChar, '/'); return(DextopUtil.AbsolutePath(DextopUtil.CombinePaths("guides/html", vpath)) + "?cb=" + Math.Abs(lastWriteTime.GetHashCode())); }
public override void InitRemotable(DextopRemote remote, DextopConfig config) { base.InitRemotable(remote, config); config.Add("soundUrl", DextopUtil.AbsolutePath("client/sound/notify.mp3")); }