private void generateHtml_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(f_titleLbl.Text)) { Messanger.Warning("First, you need to create subject"); return; } if (subject.Semesters.Count == 0) { Messanger.Warning("Semesters list is empty"); return; } FolderBrowserDialog folder = new FolderBrowserDialog(); if (folder.ShowDialog() == DialogResult.Cancel) { return; } pageConfiguration config = new pageConfiguration(); config.ShowDialog(); HtmlGenerator html = new HtmlGenerator(folder.SelectedPath, subject, config.config); Messanger.Information("File generated successfully!"); }
public static string AddTextArea(StringBuilder sb, string key, string id, object value, int rows, int columns) { var idValue = key + "_" + id; HtmlGenerator.AddTextArea(sb, idValue, value, rows, columns); return(idValue); }
public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { EnsureForIsValid(); ThrowIfLookupableIsInvalid(); var selectTag = (SelectTag)HtmlGenerator.TagFor(For, nameof(HtmlConvention.Selects)); if (Lookup != null) { var items = Lookup.Model as IEnumerable <ILookupable>; items.Each(item => selectTag.Option(item.Display, item.Value)); } var currentValue = For.Model; selectTag.SelectByValue(currentValue); if (output.Attributes.ContainsName("empty-option")) { var emptyOption = output.Attributes["empty-option"].Value.ToString(); selectTag.EmptyOption(emptyOption); } selectTag.MergeAttributes(output.Attributes); output.TagName = null; output.PreElement.SetHtmlContent(selectTag.ToHtmlString()); return(Task.CompletedTask); }
public static string AddTextBox(StringBuilder sb, string key, string id, object value, int maxLength, int columns, string width) { var idValue = key + "_" + id; HtmlGenerator.AddTextBox(sb, idValue, value, maxLength, columns, width); return(idValue); }
private async Task EmailCXMLContents(M3Order parsedOrder, string cxml) { string orderLinesHtml = HtmlGenerator.ToHtmlTable(parsedOrder.OrderLines); string subject = $"cXML Order Received - PO {parsedOrder.CustomerPONumber}"; string finalEmail = $"{orderLinesHtml} <hr/> <textarea style='width:100%;'>{cxml}</textarea>"; await Email.SendEmail(EmailClient, Logger, subject, "*****@*****.**", new List <string>() { Settings.OrderEmailRecipient }, finalEmail); }
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) { var th = GetHtmlTag(nameof(HtmlConfiguration.TableHeader)); var childContent = await output.GetChildContentAsync(); if (For == null) { SetOutput(th, output); await Task.CompletedTask; return; } if (childContent.IsEmptyOrWhiteSpace) { var span = HtmlGenerator.TagFor(For, nameof(HtmlConfiguration.DisplayLabels)); // .Id(GetId()); th.Children.Add(span); } else { th.AppendHtml(childContent.GetContent()); // th.Id(GetId()); childContent.Clear(); } SetOutput(th, output); }
public string FormatHtmlForGoogle(bool includeSolution = false, bool isFragment = false) { HtmlGenerator generator = new HtmlGenerator(); var builder = new StringBuilder(); if (!isFragment) { generator.AppendHtmlHeader(builder); } builder.AppendLine("<p><h2>Instructions</h2>"); builder.AppendLine(INSTRUCTIONS); //List words builder.AppendLine("<p><h2>List of clues</h2>"); builder.AppendLine("<table>"); DisplayListOfClues(includeSolution, builder); builder.AppendLine("</table>"); //Show puzzle. builder.AppendLine("<p><h2>List of words</h2>"); builder.AppendLine("<table>"); DisplayListOfWords(includeSolution, builder); builder.AppendLine("</table>"); if (!isFragment) { generator.AppendHtmlFooter(builder); } return(builder.ToString()); }
public void GenerateHTML_StyleClasInFormatOnlyOneText_Ok() { IGenerator htmlGenerator = new HtmlGenerator(); Style colorRed = Utils.CreateStyleForTest("color red", Style.StyleType.COLOR, "red"); Style colorBlue = Utils.CreateStyleForTest("color blue", Style.StyleType.COLOR, "blue"); Style alignRight = Utils.CreateStyleForTest("align right", Style.StyleType.ALIGN, "right"); Style bold = Utils.CreateStyleForTest("bold", Style.StyleType.BOLD, "bold"); Style italic = Utils.CreateStyleForTest("italic", Style.StyleType.ITALIC, "italic"); StyleClass styleClassInheritedParagraph = CreateStyleClassForTest("Normal0", alignRight); StyleClass styleClassParagraph = CreateStyleClassForTest("Normal", colorBlue); StyleClass styleClassDocument = CreateStyleClassForTest("Normal2", bold); styleClassParagraph.SetInheritedStyleClass(styleClassInheritedParagraph); styleClassInheritedParagraph.AddStyle(italic); Format format = CreateFormatForTest(styleClassParagraph); format.AddStyleClass(styleClassDocument); Document document = Utils.CreateDocumentForTest(); Paragraph paragraph = Utils.CreateParagraphForTest(); Text text = Utils.CreateTextForTest(); paragraph.PutTextAtLast(text); document.DocumentParagraphs.Add(paragraph); document.OwnStyleClass = "Normal"; paragraph.OwnStyleClass = "Normal2"; string htmlGenerated = htmlGenerator.Generate(document, format); int x = 2; }
private static void CreateHtmlPage(IEnumerable<Item> items) { var htmlGenerator = new HtmlGenerator(); string html = htmlGenerator.GenerateHtml(items); FileUtils.CreateFile(HtmlFilePath, html); Console.WriteLine("Html page saved to <{0}>", HtmlFilePath); }
private string GetOuterHtml() { HtmlGenerator generator = new HtmlGenerator(this); generator.GenerateHtml(); return(generator.NodeHtml); }
private void SaveToHtml(string html_filename) { string pic_filename = Path.Combine(Path.GetDirectoryName(html_filename), Path.GetFileNameWithoutExtension(html_filename) + ".jpg"); if (!Globals.Tournaments.ContainsKey(FCompetition.Info.TournamentId)) { DatabaseManager.CurrentDb.ReadTournamentList(Globals.Tournaments); } TournamentInfo tInfo = Globals.Tournaments[FCompetition.Info.TournamentId].Info; string tDate = tInfo.DateBegin.ToString("dd.MM.yyyy") + " - " + tInfo.DateEnd.ToString("dd.MM.yyyy"); string tPlace = tInfo.Place; string tName = tInfo.Name; string cName = FCompetition.Info.Name; string cDate = FCompetition.Info.Date.ToString("dd.MM.yyyy"); string title = String.Format("{0}. {1}. {2} - {3}", tDate, tPlace, tName, cName); HtmlGenerator html = new HtmlGenerator(); html.Title = title; StringBuilder body = new StringBuilder(); body.AppendLine(html.TagString("h1", tDate + " - " + tPlace)); body.AppendLine(html.TagString("h1", tName)); body.AppendLine(html.TagString("h2", cName)); // Список участников body.AppendLine(html.TagString("h3", Localizator.Dictionary.GetString("PLAYER_IN_COMPETITION", ":"))); body.AppendLine(html.TagString("p", lvCompetitionPlayers.ToHtmlTableString())); // Сетка турнира if (FCompetition.Info.Status != CompetitionInfo.CompetitionState.RegistrationAndSeeding) { Bitmap bmp = pnlCompetition.GetPicture(new SolidBrush(Color.White)); PictureSaver.SavePicture(bmp, pic_filename, ImageFormat.Png); string fn = Path.GetFileName(pic_filename); string img = String.Format("<img src='{0}' alt=''/>", fn); body.AppendLine(html.TagString("h3", Localizator.Dictionary.GetString("COMPETITION_MATCHES", " :"))); body.AppendLine(html.TagString("p", img)); } // Результаты if (FCompetition.Info.Status == CompetitionInfo.CompetitionState.Finished) { body.AppendLine(html.TagString("h3", Localizator.Dictionary.GetString("COMPETITION_RESULTS", " :"))); body.AppendLine(html.TagString("p", lvPlayerPlace.ToHtmlTableString())); } // Изменение рейтинга #if FEDITION if (FCompetition.Info.Status == CompetitionInfo.CompetitionState.Finished && FCompetition.Info.ChangesRating) { body.AppendLine(html.TagString("h3", Localizator.Dictionary.GetString("RATING_CHANGES", " :"))); body.AppendLine(html.TagString("p", lvRatingAfter.ToHtmlTableString())); } #endif html.Body = body.ToString(); html.SaveTo(html_filename); }
public static string AddLookupTextBox(StringBuilder sb, string key, string id, long?value, string textValue, string tableName, string projectName, string mode, ExtenderAjaxControl extenderAjaxControl, int minimumPrefixLength, string width, BrowseFilterParameters browseFilterParameters) { var idValue = key + "_" + id; HtmlGenerator.AddLookupTextBox(sb, idValue, value, textValue, tableName, projectName, mode, browseFilterParameters, extenderAjaxControl, minimumPrefixLength, string.IsNullOrEmpty(width) ? "180px" : width); return(idValue); }
public string Visit(NamedElement value) { IEnumerable <string> textList = value.Attributes.Where(o => o.Attribute == "text").Select(o => o.Accept(valueVisitor)); IEnumerable <string> attrList = value.Attributes.Where(o => o.Attribute != "text").Select(o => o.Accept(valueVisitor)); // Get values that could only be attributes in html IEnumerable <string> objList = ResolveChildElementsOptions(value.Children).Select(o => o.Accept(this)); return(HtmlGenerator.CreateHtmlTag(value.Identifier, textList, attrList, objList)); }
public FormForTest() { var services = new ServiceCollection() .AddMiruHtml(new HtmlConvention()) .ReplaceTransient <IAntiforgeryAccessor, StubAntiforgeryAccessor>(); _sp = services.BuildServiceProvider(); _htmlGenerator = new HtmlGenerator(_sp); }
public string Visit(ImageElement value) { NamedElement?source = null; var sourceList = value.Children .Where(o => o is NamedElement nEl && nEl.Identifier.Equals("source", StringComparison.OrdinalIgnoreCase)) .Cast <NamedElement>(); foreach (var item in sourceList) { if (item.ConditionalOptions != null) { // condition is true if not null var conditionElement = optionVisitor.Visit(item.ConditionalOptions); if (conditionElement != null) { source = item; } } else { source = item; } } if (source != null) { var src = source.Attributes .Where(o => o is DataValue data && data.Attribute.Equals("src", StringComparison.OrdinalIgnoreCase)) .Cast <DataValue>().First(); value.Attributes.Add(src); } IEnumerable <string> textList = value.Attributes.Where(o => o.Attribute == "text").Select(o => o.Accept(valueVisitor)); IEnumerable <string> attrList = value.Attributes.Where(o => o.Attribute != "text" && o.GetType() != typeof(ListValue)).Select(o => o.Accept(valueVisitor)); NamedElement?description = value.Children .Where(o => o is NamedElement nEl && nEl.Identifier.Equals("description", StringComparison.OrdinalIgnoreCase)) .Cast <NamedElement>().FirstOrDefault(); var imgElement = HtmlGenerator.CreateHtmlTag("img", textList, attrList, Enumerable.Empty <string>()); if (description == null) { return(imgElement); } List <string> objList = new() { imgElement, description.Accept(this), }; return(HtmlGenerator.CreateHtmlTag("figure", textList, Enumerable.Empty <string>(), objList)); }
public void Setup () { root = RootTree.LoadTree (BaseDir, includeExternal: false); generator = new HtmlGenerator (defaultCache: null); }
/// <summary> /// Execute the generate command /// </summary> private void GenerateCommandExecute() { if (this.FilteredModel == null || this.FilteredModel.Count == 0 || string.IsNullOrWhiteSpace(this.OutputPath)) return; var docGen = new HtmlGenerator(); docGen.GenerateDocumentation(this.FilteredModel[0], this.OutputPath, this.ModelName, this.ModelVersion, this.ModelDescription, this.topLevelFilters, this.bottomLevelFilters, this.propertyFilters); }
void GenerateCache (Options opts, string basePath, string format, string outDir) { var hs = RootTree.GetHelpSource (format, basePath); if (hs == null) { Error ("Unable to find a HelpSource for provider '{0}' and file '{1}.tree'.", format, basePath); } var tree = hs.Tree; RootTree docRoot = null; if (!opts.UseSystemSources) docRoot = RootTree.LoadTree (null, null, opts.Sources); else { docRoot = RootTree.LoadTree (); foreach (var source in opts.Sources) docRoot.AddSourceFile (source); } hs.RootTree = docRoot; var generator = new HtmlGenerator (new NullCache ()); foreach (Node node in tree.RootNode.TraverseDepthFirst<Node, Node> (t => t, t => t.Nodes)) { var url = node.PublicUrl; Message (TraceLevel.Info, "\tProcessing URL: {0}", url); if (string.IsNullOrEmpty (url)) continue; var file = XmlDocUtils.GetCachedFileName (outDir, url); using (var o = File.AppendText (file)) { Node _; string contents = docRoot.RenderUrl (url, generator, out _); o.Write (contents); } } }