/// <summary> /// Dispose /// </summary> public void Dispose() { foreach (var textFormat in TextFormats.Values) { textFormat.Dispose(); } TextFormats.Clear(); Brush?.Dispose(); TextFormat?.Dispose(); TextFormat = null; Brush?.Dispose(); Brush = null; Target?.Dispose(); Target = null; NativeDeviceContext.Target = null; NativeDeviceContext?.Dispose(); NativeDeviceContext = null; NativeDevice?.Dispose(); NativeDevice = null; NativeFactory?.Dispose(); NativeFactory = null; NativeFactoryWrite?.Dispose(); NativeFactoryWrite = null; }
//Extention method that formats a textviews font public static void Format(this TextView TextView, TextFormats Format) { if (Format == TextFormats.Heading) { TextView.TextSize = MEDFONT; TextView.SetTextColor(RtGraphicsColours.White); } else if (Format == TextFormats.Heading1) { TextView.TextSize = MEDFONT; TextView.SetTextColor(RtGraphicsColours.Orange); } else if (Format == TextFormats.Heading2) { TextView.TextSize = BIGFONT; TextView.SetTextColor(RtGraphicsColours.Orange); } else if (Format == TextFormats.Paragraph) { TextView.TextSize = SMALLFONT; TextView.SetTextColor(RtGraphicsColours.Grey); } else if (Format == TextFormats.Paragraph1) { TextView.TextSize = TINYFONT; TextView.SetTextColor(RtGraphicsColours.GreyLight); } else if (Format == TextFormats.Paragraph2) { TextView.TextSize = SMALLFONT; TextView.SetTextColor(RtGraphicsColours.Orange); } }
protected object ApplyTextFormat(string propertyName, object value) { if (value != null && TextFormats.ContainsKey(propertyName)) { return(string.Format(TextFormats[propertyName], value)); } return(value); }
public TableExporter <T> TextFormatFor(IEnumerable <string> propertyNames, string format) { foreach (var propName in propertyNames) { TextFormats.AddOrUpdate(propName, format); } return(this); }
public TextFormat GetTextFormat(Font font) { if (!TextFormats.TryGetValue(font, out var format)) { format = new TextFormat(NativeFactoryWrite, font.FontFamily, font.Size); TextFormats.Add(font, format); } return(format); }
public TableExporter <T> TextFormatFor <TProperty>(Expression <Func <T, TProperty> > property, string format) { foreach (var propName in PropertyNames.For(property)) { TextFormats.AddOrUpdate(propName, format); } return(this); }
private List <DataTable> GetTables(TextFormats format) { IHTMLElementCollection tableCollection = this.doc3.getElementsByTagName("table"); List <DataTable> list = new List <DataTable>(); if (tableCollection != null) { foreach (var tableObject in tableCollection) { HTMLTable table = tableObject as HTMLTable; if (table != null) { DataTable dt = new DataTable(); foreach (HTMLTableRow htmlRow in table.rows) { DataRow row = dt.NewRow(); for (int i = 0; i < htmlRow.cells.length; i++) { if (dt.Columns.Count < i + 1) { dt.Columns.Add(); } HTMLTableCell cell = htmlRow.cells.item(i, i) as HTMLTableCell; if (format == TextFormats.Text) { row[i] = cell.innerText; } if (format == TextFormats.HTML) { row[i] = cell.innerHTML; } } dt.Rows.Add(row); } list.Add(dt); } } } return(list); }
protected object GetPropertyValue(PropertyInfo property, object item) { #if NET4 var value = property.GetValue(item, null); #endif #if NET45 || NET46 var value = property.GetValue(item); #endif if (value != null && TextFormats.ContainsKey(property.Name)) { return(string.Format(TextFormats[property.Name], value)); } return(value); }
public static extern unsafe int DrawText( SafeDCHandle hDC, [Friendly(FriendlyFlags.Array | FriendlyFlags.Bidirectional)] char* lpString, int nCount, [Friendly(FriendlyFlags.Bidirectional)] RECT* lpRect, TextFormats uFormat);
public static string Format(string input, TextFormats textFormat) { Logger.GetInstance().Debug("Format() >>"); var formattedText = ""; try { switch (textFormat) { case TextFormats.BlockCode: { input = input.Replace("\r", ""); var lines = input.Split('\n'); if (lines[0].StartsWith("```") && lines[lines.Length - 1].EndsWith("```")) { for (var i = 1; i < lines.Length - 1; i++) { if (i != lines.Length - 2) { formattedText += lines[i] + "\r\n"; } else { formattedText += lines[i]; } } } else { formattedText += "```\r\n"; for (var i = 0; i < lines.Length; i++) { formattedText += lines[i] + "\r\n"; } formattedText += "```"; } break; } case TextFormats.BlockQuote: { input = input.Replace("\r", ""); var lines = input.Split('\n'); for (var i = 0; i < lines.Length; i++) { if (lines[i].StartsWith(">")) { if (i != lines.Length - 1) { formattedText += lines[i].Substring(1, lines[i].Length - 1).Trim() + "\r\n"; } else { formattedText += lines[i].Substring(1, lines[i].Length - 1).Trim(); } } else { if (i != lines.Length - 1) { formattedText += "> " + lines[i].Trim() + "\r\n"; } else { formattedText += "> " + lines[i].Trim(); } } } break; } case TextFormats.Bold: { if (input.StartsWith("**") && input.EndsWith("**")) { formattedText = input.Substring(2, input.Length - 4); } else { formattedText = "**" + input + "**"; } break; } case TextFormats.Heading1: { if (input.StartsWith("# ")) { formattedText = input.Substring(1, input.Length - 1).Trim(); } else { formattedText = "# " + input; } break; } case TextFormats.Heading2: { if (input.StartsWith("## ")) { formattedText = input.Substring(2, input.Length - 2).Trim(); } else { formattedText = "## " + input; } break; } case TextFormats.Heading3: { if (input.StartsWith("### ")) { formattedText = input.Substring(3, input.Length - 3).Trim(); } else { formattedText = "### " + input; } break; } case TextFormats.Heading4: { if (input.StartsWith("#### ")) { formattedText = input.Substring(4, input.Length - 4).Trim(); } else { formattedText = "#### " + input; } break; } case TextFormats.Heading5: { if (input.StartsWith("##### ")) { formattedText = input.Substring(5, input.Length - 5).Trim(); } else { formattedText = "##### " + input; } break; } case TextFormats.Heading6: { if (input.StartsWith("###### ")) { formattedText = input.Substring(6, input.Length - 6).Trim(); } else { formattedText = "###### " + input; } break; } case TextFormats.InlineCode: { if (input.StartsWith("`") && input.EndsWith("`")) { formattedText = input.Substring(1, input.Length - 2).Trim(); } else { formattedText = "`" + input + "`"; } break; } case TextFormats.Italic: { if (input.StartsWith("*") && input.EndsWith("*")) { formattedText = input.Substring(1, input.Length - 2).Trim(); } else { formattedText = "*" + input + "*"; } break; } case TextFormats.OrderedList: { input = input.Replace("\r", ""); var lines = input.Split('\n'); for (var i = 0; i < lines.Length; i++) { var line = lines[i]; if (!string.IsNullOrEmpty(line)) { // If the line starts with a number, followed by a dot and a space if (Regex.IsMatch(line, @"^\d+\. ")) { if (i != lines.Length - 1) { formattedText += line.Substring(2, line.Length - 2).Trim() + "\r\n"; } else { formattedText += line.Substring(2, line.Length - 2).Trim(); } } else { if (i != lines.Length - 1) { formattedText += (i + 1) + ". " + line.Trim() + "\r\n"; } else { formattedText += (i + 1) + ". " + line.Trim(); } } } } break; } case TextFormats.UnorderedList: { input = input.Replace("\r", ""); var lines = input.Split('\n'); for (var i = 0; i < lines.Length; i++) { var line = lines[i]; if (!string.IsNullOrEmpty(line)) { if (line.StartsWith("* ") || line.StartsWith("- ")) { if (i != lines.Length - 1) { formattedText += line.Substring(2, line.Length - 2).Trim() + "\r\n"; } else { formattedText += line.Substring(2, line.Length - 2).Trim(); } } else { if (i != lines.Length - 1) { formattedText += "* " + line.Trim() + "\r\n"; } else { formattedText += "* " + line.Trim(); } } } } break; } case TextFormats.StrikeThrough: { if (input.StartsWith("~~") && input.EndsWith("~~")) { formattedText = input.Substring(2, input.Length - 4); } else { formattedText = "~~" + input + "~~"; } break; } default: { break; } } } catch (Exception e) { throw e; } Logger.GetInstance().Debug("<< Format()"); return(formattedText); }