private void HandleStyle(string token, StyleInfo model) { StyleInfo si = model.Clone() as StyleInfo; // always push a StyleInfo _StyleStack.Push(si); // since they will always be popped Hashtable ht = ParseHtmlCmd(token); string style = (string)ht["style"]; if (style == null || style.Length < 1) { return; } string[] styleList = style.Split(new char[] { ';' }); foreach (string item in styleList) { string[] val = item.Split(new char[] { ':' }); if (val.Length != 2) { continue; // must be illegal syntax } string tval = val[1].Trim(); switch (val[0].ToLower().Trim()) { case "background": case "background-color": si.BackgroundColor = XmlUtil.ColorFromHtml(tval, si.Color); break; case "color": si.Color = XmlUtil.ColorFromHtml(tval, si.Color); break; case "font-family": si.FontFamily = tval; break; case "font-size": HandleStyleFontSize(si, tval); break; case "font-style": if (tval == "italic") { si.FontStyle = FontStyleEnum.Italic; } break; case "font-weight": HandleStyleFontWeight(si, tval); break; } } return; }
internal Color EvalBottom(Report rpt, Row r) { if (_Bottom == null) { return(EvalDefault(rpt, r)); } string c = _Bottom.EvaluateString(rpt, r); return(XmlUtil.ColorFromHtml(c, Color.Black, rpt)); }
internal Color EvalDefault(Report rpt, Row r) { if (_Default == null) { return(Color.Black); } string c = _Default.EvaluateString(rpt, r); return(XmlUtil.ColorFromHtml(c, Color.Black, rpt)); }
internal Color EvalTop(Report rpt, Row r) { if (_Top == null) { return(EvalDefault(rpt, r)); } string c = _Top.EvaluateString(rpt, r); return(XmlUtil.ColorFromHtml(c, System.DrawingCore.Color.Black, rpt)); }
internal Color EvalRight(Report rpt, Row r) { if (_Right == null) { return(EvalDefault(rpt, r)); } string c = _Right.EvaluateString(rpt, r); return(XmlUtil.ColorFromHtml(c, System.Drawing.Color.Black, rpt)); }
private void HandleStyleString(string style, StyleInfo si) { if (style == null || style.Length < 1) { return; } string[] styleList = style.Split(new char[] { ';' }); foreach (string item in styleList) { string[] val = item.Split(new char[] { ':' }); if (val.Length != 2) { continue; // must be illegal syntax } string tval = val[1].Trim(); switch (val[0].ToLower().Trim()) { case "background": case "background-color": si.BackgroundColor = XmlUtil.ColorFromHtml(tval, si.Color); break; case "color": si.Color = XmlUtil.ColorFromHtml(tval, si.Color); break; case "font-family": si.FontFamily = tval; break; case "font-size": HandleStyleFontSize(si, tval); break; case "font-style": if (tval == "italic") { si.FontStyle = FontStyleEnum.Italic; } break; case "font-weight": HandleStyleFontWeight(si, tval); break; } } return; }
private void HandleFont(string token, StyleInfo model) { StyleInfo si = model.Clone() as StyleInfo; // always push a StyleInfo _StyleStack.Push(si); // since they will always be popped PageTextHtmlCmdLexer hc = new PageTextHtmlCmdLexer(token.Substring(5)); Hashtable ht = hc.Lex(); string style = (string)ht["style"]; HandleStyleString(style, si); string color = (string)ht["color"]; if (color != null && color.Length > 0) { si.Color = XmlUtil.ColorFromHtml(color, si.Color); } string size = (string)ht["size"]; if (size != null && size.Length > 0) { HandleStyleFontSize(si, size); } string face = (string)ht["face"]; if (face != null && face.Length > 0) { si.FontFamily = face; } return; }
private Color ReadXmlColor(XmlReader xr) { string sc = xr.ReadString(); return(XmlUtil.ColorFromHtml(sc, Color.Empty)); }
private void DrawMap(Report rpt, Graphics g, string mapfile, double max, double min) { string file = XmlUtil.XmlFileExists(mapfile); MapData mp; if (file != null) { mp = MapData.Create(file); } else { rpt.rl.LogError(4, string.Format("Map Subtype file {0} not found.", mapfile)); mp = new MapData(); // we'll at least put up something; but it won't be right } float scale = mp.GetScale(Layout.PlotArea.Width, Layout.PlotArea.Height); for (int iRow = 1; iRow <= CategoryCount; iRow++) { for (int iCol = 1; iCol <= SeriesCount; iCol++) { string sv = GetSeriesValue(rpt, iCol); string c = this.GetDataValueString(rpt, iRow, iCol); List <MapPolygon> pl = mp.GetPolygon(sv); if (pl == null) { continue; } Brush br = new SolidBrush(XmlUtil.ColorFromHtml(c, Color.Transparent)); foreach (MapPolygon mpoly in pl) { PointF[] polygon = mpoly.Polygon; PointF[] drawpoly = new PointF[polygon.Length]; // make points relative to plotarea --- need to scale this as well for (int ip = 0; ip < drawpoly.Length; ip++) { drawpoly[ip] = new PointF(Layout.PlotArea.X + (polygon[ip].X * scale), Layout.PlotArea.Y + (polygon[ip].Y * scale)); } g.FillPolygon(br, drawpoly); if (_showToolTips) { StringBuilder sb = new StringBuilder(); sb.Append("PolyToolTip:"); sb.Append(sv.Replace('|', '/')); // we treat '|' as a separator character; don't allow in string sb.Append(' '); sb.Append(c.Replace('|', '/')); foreach (PointF pf in drawpoly) { sb.AppendFormat(NumberFormatInfo.InvariantInfo, "|{0}|{1}", pf.X, pf.Y); } g.AddMetafileComment(new System.Text.ASCIIEncoding().GetBytes(sb.ToString())); } } br.Dispose(); } } // draw the outline of the map foreach (MapObject mo in mp.MapObjects) { mo.Draw(g, scale, Layout.PlotArea.X, Layout.PlotArea.Y); } }