public static string GetRtf(string sql, SqlSyntaxHighlightMap map) { if (map == null) { map = new SqlSyntaxHighlightMap(); } string rtf = Parse(sql, SqlSyntaxConstants.SqlServer); // 1: Keyword (blue) // 3: System Function (green) // 5: operator (75,75,75) // 6: Text (red) // 7: Number (cyan) // 8: Comment (magenta) // 10: Standard Text (black) string colorTable = @"{\colortbl;" + ColorToRtf(map.Keyword) + ColorToRtf(System.Drawing.Color.Black) + ColorToRtf(map.SystemFunction) + ColorToRtf(System.Drawing.Color.Black) + ColorToRtf(map.Operator) + ColorToRtf(map.Text) + ColorToRtf(map.Number) + ColorToRtf(map.Comment) + ColorToRtf(System.Drawing.Color.Black) + ColorToRtf(map.StandardText) + @"}"; return(@"{\rtf1" + colorTable + @rtf + @"}"); }
public static string GetRtf(string sql, SqlSyntaxHighlightMap map) { if (map == null) map = new SqlSyntaxHighlightMap(); string rtf = Parse(sql, SqlSyntaxConstants.SqlServer); // 1: Keyword (blue) // 3: System Function (green) // 5: operator (75,75,75) // 6: Text (red) // 7: Number (cyan) // 8: Comment (magenta) // 10: Standard Text (black) string colorTable = @"{\colortbl;" + ColorToRtf(map.Keyword) + ColorToRtf(System.Drawing.Color.Black) + ColorToRtf(map.SystemFunction) + ColorToRtf(System.Drawing.Color.Black) + ColorToRtf(map.Operator) + ColorToRtf(map.Text) + ColorToRtf(map.Number) + ColorToRtf(map.Comment) + ColorToRtf(System.Drawing.Color.Black) + ColorToRtf(map.StandardText) + @"}"; return @"{\rtf1" + colorTable + @rtf + @"}"; }
public static SqlParseResult TryGetRtf(string sql, SqlSyntaxHighlightMap map) { try { SqlParseResult result = new SqlParseResult(); result.Text = sql; result.RTF = GetRtf(sql, map); result.Success = true; return(result); } catch (Exception ex) { SqlParseResult result = new SqlParseResult(); result.Exception = ex; result.Text = sql; result.Success = false; return(result); } }
public static SqlParseResult TryGetRtf(string sql, SqlSyntaxHighlightMap map) { try { SqlParseResult result = new SqlParseResult(); result.Text = sql; result.RTF = GetRtf(sql, map); result.Success = true; return result; } catch (Exception ex) { SqlParseResult result = new SqlParseResult(); result.Exception = ex; result.Text = sql; result.Success = false; return result; } }