示例#1
0
        public override void Render(OxyPlot.IRenderContext rc, OxyPlot.PlotModel model, AxisLayer axisLayer, int pass)
        {
            base.Render(rc, model, axisLayer, pass);
            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;



            LineSeries series = model.Series.First(s => { if (s is LineSeries)
                                                          {
                                                              return(true);
                                                          }
                                                          else
                                                          {
                                                              return(false);
                                                          } }) as LineSeries;

            for (int i = 0; i < series.Points.Count; i++)
            {
                ScreenPoint sp  = series.Transform(series.Points[i]);
                int         key = (int)series.Points[i].X;
                if (IsCloudVisble && Cloud.Count > 0 && (Cloud[key]) != "9999")
                {
                    if (Cloud[key] != null)
                    {
                        using (Font f = new System.Drawing.Font(_PrivateFontCollection.Families[1], 12F))
                        {
                            float x = (float)sp.X;
                            float y = (float)model.Height - 50;
                            DrawText(g, new ScreenPoint(x, y), Cloud[key],
                                     OxyColor.FromRgb(CloudColor.R, CloudColor.G, CloudColor.B), f, 0F,
                                     HorizontalAlignment.Center, VerticalAlignment.Middle);
                        }
                    }
                }

                if (IsWindVisible && WindSpeeds.Count > 0 && (WindSpeeds[key]) != "9999" /* && (WindSpeeds[key]) != "0"*/)
                {
                    if (WindDirs[key] != null)
                    {
                        using (Font f = new System.Drawing.Font(_PrivateFontCollection.Families[0], 30F))
                        {
                            float x = (float)sp.X;
                            float y = (float)model.Height - 50;
                            DrawText(g, new ScreenPoint(x, y), WindSpeeds[key],
                                     OxyColor.FromRgb(WindColor.R, WindColor.G, WindColor.B), f, float.Parse(WindDirs[key]),
                                     HorizontalAlignment.Left, VerticalAlignment.Bottom, -15, 15);
                        }
                    }
                }
            }
        }