public byte[] GetInvoicePdfDocument(Invoice invoice) { var globalSettings = new GlobalSettings { ColorMode = ColorMode.Color, Orientation = Orientation.Portrait, PaperSize = PaperKind.A4, Margins = new MarginSettings { Top = 10 }, DocumentTitle = $"Faktura - {invoice.InvoiceNumber}" }; var objectSettings = new ObjectSettings { PagesCount = true, HtmlContent = HtmlStringBuilder.HtmlInvoiceDocument(invoice), WebSettings = { DefaultEncoding = "utf-8", UserStyleSheet = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "css/site.css") }, HeaderSettings = { FontName = "Calibri", FontSize = 10, Right = "Page [page] of [toPage]", Line = true }, FooterSettings = { FontName = "Calibri", FontSize = 10, Line = true, Center = $"Faktura - {invoice.InvoiceNumber}" } }; var pdf = new HtmlToPdfDocument() { GlobalSettings = globalSettings, Objects = { objectSettings } }; var file = _converter.Convert(pdf); return(file); }
public MvcHtmlString ToHtml(HtmlHelper helper) { HtmlStringBuilder sb = new HtmlStringBuilder(); using (sb.SurroundLine("li")) { sb.Add(helper.ScriptCss("~/Help/Content/helpWidget.css")); var id = TypeContextUtilities.Compose(Prefix, "helpButton"); sb.Add(new HtmlTag("button").Id(id) .Class("btn btn-xs btn-help btn-help-widget") .Class(HelpLogic.GetEntityHelp(RootType).HasEntity ? "hasItems" : null) .Attr("type", "button") .SetInnerText("?")); var type = HelpLogic.GetEntityHelpService(this.RootType); var jsType = new { Type = TypeLogic.GetCleanName(type.Type), Info = type.Info, Operations = type.Operations.ToDictionary(a => a.Key.Key, a => a.Value), Properties = type.Properties.ToDictionary(a => a.Key.ToString(), a => a.Value), }; sb.Add(MvcHtmlString.Create("<script>$('#" + id + "').on('mouseup', function(event){ if(event.which == 3) return; " + HelpClient.WidgetModule["entityClick"](JsFunction.This, this.Prefix, jsType, helper.UrlHelper().Action((HelpController c) => c.PropertyRoutes())).ToString() + " })</script>")); } return(sb.ToHtml()); }
public ContentResult SelectedItemsContextMenu(string webQueryName, string implementationsKey, string prefix) { var lites = this.ParseLiteKeys <Entity>(); if (lites.IsEmpty()) { return(Content("")); } object queryName = Finder.ResolveQueryName(webQueryName); Implementations implementations = implementationsKey == "[All]" ? Implementations.ByAll : Implementations.By(implementationsKey.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(t => Navigator.ResolveType(t)).ToArray()); var items = ContextualItemsHelper.GetContextualItemListForLites(new SelectedItemsMenuContext { Url = RouteHelper.New(), ControllerContext = this.ControllerContext, Lites = lites, QueryName = queryName, Implementations = implementations, Prefix = prefix, }); if (items.IsNullOrEmpty()) { return(Content("")); } var sb = new HtmlStringBuilder(items.Select(mi => mi.ToHtml())); sb.Add(new MvcHtmlString(@"<script>$(function(){ $('[data-toggle=""tooltip""]').tooltip({}); });</script>")); return(Content(sb.ToHtml().ToString())); }
MvcHtmlString IWidget.ToHtml(HtmlHelper helper) { if (Isolation == null) return MvcHtmlString.Empty; HtmlStringBuilder sb = new HtmlStringBuilder(); sb.Add(helper.HiddenLite(TypeContextUtilities.Compose(Prefix, "Isolation"), Isolation)); sb.Add(new HtmlTag("span").Class("sf-quicklinks badge").SetInnerText(Isolation.ToString())); //sb.Add(new MvcHtmlString("<script>" + IsolationClient.Module["addIsolationPrefilter"](Isolation.Key()) + "</script>")); return sb.ToHtml(); }
MvcHtmlString IWidget.ToHtml(HtmlHelper helper) { if (Isolation == null) { return(MvcHtmlString.Empty); } HtmlStringBuilder sb = new HtmlStringBuilder(); sb.Add(helper.HiddenLite(TypeContextUtilities.Compose(Prefix, "Isolation"), Isolation)); sb.Add(new HtmlTag("span").Class("sf-quicklinks badge").SetInnerText(Isolation.ToString())); //sb.Add(new MvcHtmlString("<script>" + IsolationClient.Module["addIsolationPrefilter"](Isolation.Key()) + "</script>")); return(sb.ToHtml()); }
public override string ConvertFromGrapch(IGraphBasics <Point, IEdgeBasics <Point> > InitialGraph) { List <Point> points = (InitialGraph.PointCollection.ToList()); points.Sort((i1, i2) => { return(i1.Name.CompareTo(i2.Name)); }); StringBuilder HtmlStringBuilder; try { int fileLength = points.Select(i1 => i1.Name.Length).Aggregate((i1, i2) => i1 + i2) * 2; // Double length (row and columns) names of points fileLength += 126; // <!DOCTYPE HTML><html><head><meta charset =\"utf-8\"></head><body><table border = "1"><caption></caption></table></body></html> fileLength += InitialGraph.GraphName.Length; // Plus Graph name fileLength += ((InitialGraph.PointCollection.Count() + 2) * (InitialGraph.PointCollection.Count() + 1)) * 9; // Count <tr></tr>, <th></th>, <td></td> fileLength += (InitialGraph.PointCollection.Count() * InitialGraph.PointCollection.Count()); // Reserved for 0 or 1 in ref matrix HtmlStringBuilder = new StringBuilder(fileLength, fileLength); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(ex.Message); HtmlStringBuilder = new StringBuilder(Int32.MaxValue); } if (HtmlStringBuilder == null) { HtmlStringBuilder = new StringBuilder(); } HtmlStringBuilder.AppendFormat("<!DOCTYPE HTML><html><head><meta charset =\"utf-8\"></head><body><table border = \"1\"><caption>{0}</caption>", InitialGraph.GraphName); HtmlStringBuilder.AppendFormat("<tr><th></th><th>{0}</th></tr>", String.Join("</th><th>", points.Select(i1 => i1.Name))); byte[,] matrix = new byte[points.Count, points.Count]; foreach (IEdgeBasics <Point> e in InitialGraph.EdgeCollection) { matrix[points.IndexOf(e.StartPoint), points.IndexOf(e.EndPoint)] += 1; } for (int i = 0; i < matrix.GetLength(0); i++) { HtmlStringBuilder.AppendFormat("<tr><th>{0}</th>", points[i].ToString()); for (int j = 0; j < matrix.GetLength(1); j++) { HtmlStringBuilder.AppendFormat("<td>{0}</td>", matrix[i, j].ToString()); } HtmlStringBuilder.Append("</tr>"); } HtmlStringBuilder.Append("</table></body></html>"); return(HtmlStringBuilder.ToString()); }
public static MvcHtmlString QueryTokenDNBuilder(this HtmlHelper helper, TypeContext<QueryTokenEntity> ctx, QueryTokenBuilderSettings settings) { if (ctx.Value.Try(qt => qt.ParseException) != null) { HtmlStringBuilder sb = new HtmlStringBuilder(); sb.Add(new HtmlTag("div").Class("ui-state-error").SetInnerText(ctx.Value.ParseException.Message).ToHtml()); sb.Add(new HtmlTag("pre").SetInnerText(ctx.Value.TokenString).ToHtml()); sb.Add(helper.QueryTokenBuilder(null, ctx, settings)); return sb.ToHtml(); } else { return helper.QueryTokenBuilder(ctx.Value.Try(ct => ct.Token), ctx, settings); } }
public static MvcHtmlString QueryTokenDNBuilder(this HtmlHelper helper, TypeContext <QueryTokenEmbedded> ctx, QueryTokenBuilderSettings settings) { if (ctx.Value?.ParseException != null) { HtmlStringBuilder sb = new HtmlStringBuilder(); sb.Add(new HtmlTag("div").Class("ui-state-error").SetInnerText(ctx.Value.ParseException.Message).ToHtml()); sb.Add(new HtmlTag("pre").SetInnerText(ctx.Value.TokenString).ToHtml()); sb.Add(helper.QueryTokenBuilder(null, ctx, settings)); return(sb.ToHtml()); } else { return(helper.QueryTokenBuilder(ctx.Value?.Token, ctx, settings)); } }
public static MvcHtmlString Diff(string oldStr, string newStr) { StringDistance sd = new StringDistance(); var dif = sd.DiffText(oldStr, newStr); HtmlStringBuilder sb = new HtmlStringBuilder(); foreach (var line in dif) { if (line.Action == StringDistance.DiffAction.Removed) { using (sb.Surround(new HtmlTag("span").Attr("style", "background-color:#FFD1D1"))) DiffLine(sb, line.Value); } if (line.Action == StringDistance.DiffAction.Added) { using (sb.Surround(new HtmlTag("span").Attr("style", "background-color:#CEF3CE"))) DiffLine(sb, line.Value); } else if (line.Action == StringDistance.DiffAction.Equal) { if (line.Value.Count == 1) { using (sb.Surround(new HtmlTag("span"))) DiffLine(sb, line.Value); } else { using (sb.Surround(new HtmlTag("span").Attr("style", "background-color:#FFD1D1"))) DiffLine(sb, line.Value.Where(a => a.Action == StringDistance.DiffAction.Removed || a.Action == StringDistance.DiffAction.Equal)); using (sb.Surround(new HtmlTag("span").Attr("style", "background-color:#CEF3CE"))) DiffLine(sb, line.Value.Where(a => a.Action == StringDistance.DiffAction.Added || a.Action == StringDistance.DiffAction.Equal)); } } } return(sb.ToHtml()); }
string BuildHtmlText() { IHandHistoriesFilter filter = _handHistoriesViewModel.HandHistoriesFilter; string heroName = filter.SelectHero ? filter.HeroName : null; string htmlHandHistories = HtmlStringBuilder.BuildFrom( _handHistoriesViewModel.SelectedHandHistories, filter.ShowPreflopFolds, heroName); Encoding enc = Encoding.UTF8; string htmlBegin = "<html>\r\n<head>\r\n" + "<meta http-equiv=\"Content-Type\"" + " content=\"text/html; charset=" + enc.WebName + "\">\r\n" + "<title>Poker Game Report</title>\r\n</head>\r\n<body>\r\n"; const string htmlEnd = "\r\n</body>\r\n</html>\r\n"; return(htmlBegin + htmlHandHistories + htmlEnd); }
private static void DiffLine(HtmlStringBuilder sb, IEnumerable <StringDistance.DiffPair <string> > list) { foreach (var gr in list.GroupWhenChange(a => a.Action)) { string text = gr.Select(a => a.Value).ToString(""); if (gr.Key == StringDistance.DiffAction.Equal) { sb.Add(HtmlTag.Encode(text)); } else { var color = gr.Key == StringDistance.DiffAction.Added ? "#72F272" : gr.Key == StringDistance.DiffAction.Removed ? "#FF8B8B" : throw new InvalidOperationException(); sb.Add(new HtmlTag("span").Attr("style", "background:" + color).SetInnerText(text)); } } sb.AddLine(); }
public static Widget CreateWidget(WidgetContext ctx) { var ident = (Entity)ctx.Entity; var url = RouteHelper.New().Action((AlertController ac) => ac.AlertsCount()); var alertList = new[] { new { Count = CountAlerts(ident.ToLite(), "Attended"), Property = "Attended", AlertClass = "sf-alert-attended", Title = AlertMessage.Alerts_Attended.NiceToString() }, new { Count = CountAlerts(ident.ToLite(), "Alerted"), Property = "Alerted", AlertClass = "sf-alert-alerted", Title = AlertMessage.Alerts_NotAttended.NiceToString() }, new { Count = CountAlerts(ident.ToLite(), "Future"), Property = "Future", AlertClass = "sf-alert-future", Title = AlertMessage.Alerts_Future.NiceToString() }, }; var items = alertList.Select(a => new MenuItem(ctx.Prefix, "sfAlertExplore_" + a.Property) { OnClick = AlertClient.Module["exploreAlerts"](ctx.Prefix, GetFindOptions(ident, a.Property).ToJS(ctx.Prefix, "alerts"), url), CssClass = "sf-alert-view", Html = new HtmlTag("span").Class("sf-alert-count-label").Class(a.AlertClass).Class(a.Count > 0 ? "sf-alert-active" : null).InnerHtml((a.Title + ": ").EncodeHtml()).ToHtml().Concat( new HtmlTag("span").Class(a.AlertClass).Class(a.Count > 0 ? "sf-alert-active" : null).SetInnerText(a.Count.ToString())) }).Cast <IMenuItem>().ToList(); items.Add(new MenuItemSeparator()); items.Add(new MenuItem(ctx.Prefix, "sfAlertCreate") { CssClass = "sf-alert-create", OnClick = AlertClient.Module["createAlert"](JsFunction.Event, ctx.Prefix, AlertOperation.CreateAlertFromEntity.Symbol.Key, url), Text = AlertMessage.CreateAlert.NiceToString(), }); HtmlStringBuilder label = new HtmlStringBuilder(); int count = alertList.Length; for (int i = 0; i < count; i++) { var a = alertList[i]; label.Add(new HtmlTag("span") .Class("sf-widget-count") .Class(a.AlertClass) .Class(a.Count > 0 ? "sf-alert-active" : null) .SetInnerText(a.Count.ToString()) .Attr("title", a.Title) .ToHtml()); if (i < count - 1) { label.Add(new HtmlTag("span") .Class("sf-alerts-count-separator") .SetInnerText(" - ") .ToHtml()); } } return(new Widget { Title = AlertMessage.Alerts.NiceToString(), IconClass = "glyphicon glyphicon-bell", Class = "sf-alerts-toggler", Id = TypeContextUtilities.Compose(ctx.Prefix, "alertsWidget"), Active = alertList.Any(a => a.Count > 0), Html = label.ToHtml(), Items = items, }); }
public ContentResult SelectedItemsContextMenu(string webQueryName, string implementationsKey, string prefix) { var lites = this.ParseLiteKeys<Entity>(); if (lites.IsEmpty()) return Content(""); object queryName = Finder.ResolveQueryName(webQueryName); Implementations implementations = implementationsKey == "[All]" ? Implementations.ByAll : Implementations.By(implementationsKey.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(t => Navigator.ResolveType(t)).ToArray()); var items = ContextualItemsHelper.GetContextualItemListForLites(new SelectedItemsMenuContext { Url = RouteHelper.New(), ControllerContext = this.ControllerContext, Lites = lites, QueryName = queryName, Implementations = implementations, Prefix = prefix, }); if (items.IsNullOrEmpty()) return Content(""); var sb = new HtmlStringBuilder(items.Select(mi => mi.ToHtml())); sb.Add(new MvcHtmlString(@"<script>$(function(){ $('[data-toggle=""tooltip""]').tooltip({}); });</script>")); return Content(sb.ToHtml().ToString()); }
/// <summary> /// Initializes a new instance of the <see cref="NetworkPrinter"/> class. /// </summary> public HtmlNetworkPrinter() { _sb = new HtmlStringBuilder(); }
public static Widget CreateWidget(WidgetContext ctx) { var ident = (Entity)ctx.Entity; var url = RouteHelper.New().Action((AlertController ac) => ac.AlertsCount()); var alertList = new[] { new { Count = CountAlerts(ident.ToLite(), "Attended"), Property = "Attended", AlertClass = "sf-alert-attended", Title = AlertMessage.Alerts_Attended.NiceToString() }, new { Count = CountAlerts(ident.ToLite(), "Alerted"), Property = "Alerted", AlertClass = "sf-alert-alerted", Title = AlertMessage.Alerts_NotAttended.NiceToString() }, new { Count = CountAlerts(ident.ToLite(), "Future"), Property = "Future", AlertClass = "sf-alert-future", Title = AlertMessage.Alerts_Future.NiceToString() }, }; var items = alertList.Select(a => new MenuItem(ctx.Prefix, "sfAlertExplore_" + a.Property) { OnClick = AlertClient.Module["exploreAlerts"](ctx.Prefix, GetFindOptions(ident, a.Property).ToJS(ctx.Prefix, "alerts"), url), CssClass = "sf-alert-view", Html = new HtmlTag("span").Class("sf-alert-count-label").Class(a.AlertClass).Class(a.Count > 0 ? "sf-alert-active" : null).InnerHtml((a.Title + ": ").EncodeHtml()).ToHtml().Concat( new HtmlTag("span").Class(a.AlertClass).Class(a.Count > 0 ? "sf-alert-active" : null).SetInnerText(a.Count.ToString())) }).Cast<IMenuItem>().ToList(); items.Add(new MenuItemSeparator()); items.Add(new MenuItem(ctx.Prefix, "sfAlertCreate") { CssClass = "sf-alert-create", OnClick = AlertClient.Module["createAlert"](JsFunction.Event, ctx.Prefix, AlertOperation.CreateAlertFromEntity.Symbol.Key, url), Text = AlertMessage.CreateAlert.NiceToString(), }); HtmlStringBuilder label = new HtmlStringBuilder(); int count = alertList.Length; for(int i = 0; i < count; i++) { var a = alertList[i]; label.Add(new HtmlTag("span") .Class("sf-widget-count") .Class(a.AlertClass) .Class(a.Count > 0 ? "sf-alert-active" : null) .SetInnerText(a.Count.ToString()) .Attr("title", a.Title) .ToHtml()); if (i < count - 1) { label.Add(new HtmlTag("span") .Class("sf-alerts-count-separator") .SetInnerText(" - ") .ToHtml()); } } return new Widget { Title = AlertMessage.Alerts.NiceToString(), IconClass = "glyphicon glyphicon-bell", Class = "sf-alerts-toggler", Id = TypeContextUtilities.Compose(ctx.Prefix, "alertsWidget"), Active = alertList.Any(a => a.Count > 0), Html = label.ToHtml(), Items = items, }; }
internal static MvcHtmlString InternalFileLine(this HtmlHelper helper, FileLine fileLine) { if (!fileLine.Visible) { return(MvcHtmlString.Empty); } IFile value = fileLine.GetFileValue(); HtmlStringBuilder sbg = new HtmlStringBuilder(); using (sbg.SurroundLine(new HtmlTag("div").Id(fileLine.Prefix).Class("sf-field SF-control-container"))) { sbg.AddLine(new HtmlTag("link").Attrs(new { rel = "stylesheet", type = "text/css", href = RouteHelper.New().Content("~/Files/Content/Files.css") }).ToHtmlSelf()); if (value != null) { sbg.AddLine(helper.Div(fileLine.Compose(EntityBaseKeys.Entity), null, "", new Dictionary <string, object> { { "style", "display:none" } })); } fileLine.ValueHtmlProps.AddCssClass("form-control"); bool hasEntity = value != null && value.FileName.HasText(); using (sbg.SurroundLine(new HtmlTag("div", fileLine.Compose("DivOld")).Attr("style", "display:" + (hasEntity ? "block" : "none")))) { HtmlStringBuilder sb = new HtmlStringBuilder(); using (sb.SurroundLine(new HtmlTag("div", fileLine.Compose("inputGroup")).Class("input-group"))) { if (fileLine.Download != DownloadBehaviour.None) { sb.AddLine(helper.Href(fileLine.Compose(EntityBaseKeys.Link), value?.FileName, hasEntity ? FilesClient.GetDownloadUrl(value) : null, value?.FileName, "form-control file-control", fileLine.Download == DownloadBehaviour.View ? null : new Dictionary <string, object> { { "download", value?.FileName } })); } else { sb.AddLine(helper.Span(fileLine.Compose(EntityBaseKeys.ToStr), value?.FileName ?? "", "form-control file-control", null)); } if (fileLine.Type.IsEmbeddedEntity()) { sb.AddLine(helper.Hidden(fileLine.Compose(EntityBaseKeys.EntityState), value?.Let(f => Navigator.Manager.SerializeEntity((ModifiableEntity)f)))); } using (sb.SurroundLine(new HtmlTag("span", fileLine.Compose("shownButton")).Class("input-group-btn"))) { sb.AddLine(EntityButtonHelper.Remove(helper, fileLine, btn: true)); } } sbg.AddLine(helper.FormGroup(fileLine, fileLine.Download == DownloadBehaviour.None ? fileLine.Compose(EntityBaseKeys.Link) : fileLine.Compose(EntityBaseKeys.ToStr), fileLine.LabelHtml ?? fileLine.LabelText.FormatHtml(), sb.ToHtml())); } using (sbg.SurroundLine(new HtmlTag("div", fileLine.Compose("DivNew")) .Class("sf-file-line-new") .Attr("style", "display:" + (hasEntity ? "none" : "block")))) { HtmlStringBuilder sb = new HtmlStringBuilder(); sb.AddLine(helper.HiddenRuntimeInfo(fileLine)); if (!fileLine.ReadOnly) { sb.AddLine(MvcHtmlString.Create("<input type='file' id='{0}' name='{0}' class='form-control'/>".FormatWith(fileLine.Compose(FileLineKeys.File)))); sb.AddLine(MvcHtmlString.Create("<img src='{0}' id='{1}_loading' alt='loading' style='display:none'/>".FormatWith(RouteHelper.New().Content("~/Files/Images/loading.gif"), fileLine.Prefix))); } sbg.AddLine(helper.FormGroup(fileLine, fileLine.Compose(FileLineKeys.File), fileLine.LabelHtml ?? fileLine.LabelText.FormatHtml(), sb.ToHtml())); } if (!fileLine.ReadOnly) { sbg.AddLine(fileLine.ConstructorScript(FilesClient.Module, "FileLine")); } } return(sbg.ToHtml()); }