Esempio n. 1
0
        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 + @"}");
        }
Esempio n. 2
0
        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 + @"}";
        }
Esempio n. 3
0
 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);
     }
 }
Esempio n. 4
0
 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;
     }
 }