void DrawSymbol(Graphics g, Dictionary <int, SeqData> element_seq, string name, int font_index, float font_size = 12F, HorizontalAlignment halign = HorizontalAlignment.Center, VerticalAlignment valign = VerticalAlignment.Middle, int offset_x = 0, int offset_y = 0) { ITheme theme; if (!_thems.TryGetValue(name, out theme)) { theme = new Model.Themes.ColorTheme(); } Color color = theme.GetThemeColor(ThemeMode); using (Brush brush = new SolidBrush(color)) { bool visible = true; if (_element_visible_mapping.ContainsKey(name)) { visible = _element_visible_mapping[name]; } if (visible && element_seq.Count > 0) { foreach (KeyValuePair <int, SeqData> item in element_seq) { if (item.Value != null && _PrivateFontCollection.Families.Length > font_index && item.Value.Angle != Helper.InvalidData && item.Value.Y != "9999") { using (Font f = new System.Drawing.Font(_PrivateFontCollection.Families[font_index], font_size)) { float x = (float)this.Transform(item.Key); float y = (float)PlotModel.Height - 50; PointF offset; if (!_element_offsets.TryGetValue(name, out offset)) { offset = new PointF(0, 0); } GMap.FontLabelSeries.DrawText(g, new ScreenPoint(x, y), item.Value.Y, brush, f, item.Value.Angle, halign, valign, (int)offset.X + offset_x, (int)offset.Y + offset_y); } } } } } }
public CloudAxis(PrivateFontCollection privatefont) : base() { _PrivateFontCollection = privatefont; _cloud = new Dictionary <int, SeqData>(); _wind_speeds = new Dictionary <int, SeqData>(); _tempers = new Dictionary <int, SeqData>(); _pressures = new Dictionary <int, SeqData>(); _visibles = new Dictionary <int, SeqData>(); _var3_pressures = new Dictionary <int, SeqData>(); _ww = new Dictionary <int, SeqData>(); _cl = new Dictionary <int, SeqData>(); _cm = new Dictionary <int, SeqData>(); _ch = new Dictionary <int, SeqData>(); _element_value_mapping.Add(ElementNames.Cloud, Cloud); _element_value_mapping.Add(ElementNames.Wind, WindSpeeds); _element_value_mapping.Add(ElementNames.AxisTemp, Tempers); _element_value_mapping.Add(ElementNames.AxisPressure, Pressures); _element_value_mapping.Add(ElementNames.Visible, Visibles); _element_value_mapping.Add(ElementNames.Var3Pressure, Var3Pressures); _element_value_mapping.Add(ElementNames.WW, WW); _element_value_mapping.Add(ElementNames.CL, CL); _element_value_mapping.Add(ElementNames.CM, CM); _element_value_mapping.Add(ElementNames.CH, CH); _element_visible_mapping.Add(ElementNames.Cloud, true); _element_visible_mapping.Add(ElementNames.Wind, true); _element_visible_mapping.Add(ElementNames.AxisTemp, true); _element_visible_mapping.Add(ElementNames.AxisPressure, true); _element_visible_mapping.Add(ElementNames.Visible, true); _element_visible_mapping.Add(ElementNames.Var3Pressure, true); _element_visible_mapping.Add(ElementNames.WW, true); _element_visible_mapping.Add(ElementNames.CL, true); _element_visible_mapping.Add(ElementNames.CM, true); _element_visible_mapping.Add(ElementNames.CH, true); Theme = new Model.Themes.ColorTheme(); }
public void Render(IRenderContext rc, PlotModel model) { if (Theme != null) { OxyColor color = Convertor.ConvertColorToOxyColor(Theme.GetThemeColor(ThemeMode)); TicklineColor = color; TextColor = color; TitleColor = color; } ///base.Render(rc, model, axisLayer, pass); /// //绘制线标值和线条 IList <IList <ScreenPoint> > points = new List <IList <ScreenPoint> >(); FeatureTextIntersector intersector = new FeatureTextIntersector(FeatureTextIntersector.SortStyle.Horizontal, 3); for (int i = 0; i < this.Labels.Count; i++) { string label = this.Labels[i]; OxySize text_size = rc.MeasureText(label, this.ActualFont, this.ActualFontSize, this.ActualFontWeight); double x = Transform(i); if (x < model.PlotArea.Left || x > model.PlotArea.Right) { continue; } double y = model.PlotArea.Bottom; double y2 = y + 5; IList <ScreenPoint> sps = new List <ScreenPoint>(); sps.Add(new ScreenPoint(x, y)); sps.Add(new ScreenPoint(x, model.PlotArea.Top)); points.Add(sps); intersector.Add(new FeatureText(label, new ScreenPoint(x, y2), text_size, new ScreenPoint(x, y))); // rc.DrawText(new ScreenPoint(x, y + 7), label, TextColor, this.ActualFont, this.ActualFontSize, this.ActualFontWeight, this.Angle, HorizontalAlignment.Left, VerticalAlignment.Middle); } List <FeatureText> fearures = intersector.DiscaredIntersection(); if (fearures != null) { foreach (FeatureText ft in fearures) { rc.DrawText(ft.Position, ft.Text, this.TextColor, this.ActualFont, this.ActualFontSize, this.ActualFontWeight, this.Angle, HorizontalAlignment.Center); } } foreach (IList <ScreenPoint> line in points) { rc.DrawLine(line, this.ExtraGridlineColor, 1, LineStyle.Dash.GetDashArray()); } if (model.Series.Count == 0) { return; } var field = rc.GetType().GetField("g", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); object o = field.GetValue(rc); Graphics g = (Graphics)o; foreach (string element in Font_Elements) { Dictionary <int, SeqData> datas; if (_element_value_mapping.TryGetValue(element, out datas)) { PointF offset; if (!_element_offsets.TryGetValue(element, out offset)) { offset = new PointF(0, 0); } switch (element) { case ElementNames.Wind: offset = new PointF(-15, 15); DrawSymbol(g, datas, element, 1, 30F, HorizontalAlignment.Left, VerticalAlignment.Bottom, (int)offset.X, (int)offset.Y); break; default: DrawSymbol(g, datas, element, 2); break; } } } foreach (string element in Value_Elements) { Dictionary <int, SeqData> current_points; bool visible = true; if (_element_visible_mapping.ContainsKey(element)) { visible = _element_visible_mapping[element]; } if (visible && _element_value_mapping.TryGetValue(element, out current_points)) { PointF offset; if (!_element_offsets.TryGetValue(element, out offset)) { offset = new PointF(0, 0); } double y = model.Height - 50; y += offset.Y; ITheme theme; if (!_thems.TryGetValue(element, out theme)) { theme = new Model.Themes.ColorTheme(); } OxyColor color = Helper.ConvertColorToOxyColor(theme.GetThemeColor(ThemeMode)); foreach (KeyValuePair <int, SeqData> item in current_points) { double x = Transform(item.Key); x += offset.X; string data = item.Value.Y; rc.DrawText(new ScreenPoint(x, y), data, color); } } } }