private static void ChartOnFillSceneGraph(object sender, FillSceneGraphEventArgs e)
        {
           
            var axisY = e.Grid["Y"] as IAdvanceAxis;
            var axisX = e.Grid["X"] as IAdvanceAxis;

            int targetYCoord = Convert.ToInt32(axisY.Map(0));

            int xStart = Convert.ToInt32(axisX.MapMinimum);
            int xEnd = Convert.ToInt32(axisX.MapMaximum);
            int yStart = Convert.ToInt32(axisY.MapMinimum);
            int yEnd = Convert.ToInt32(axisY.MapMaximum);

            Line targetLine = new Line(new Point(xStart, targetYCoord), new Point(xEnd, targetYCoord))
            {
                PE =
                {
                    Stroke = Color.Green,
                    StrokeWidth = 2
                },
                lineStyle =
                {
                    DrawStyle = LineDrawStyle.Solid
                     
                }
            };
            e.SceneGraph.Add(targetLine);

            var waermerLabel = new Text();
            waermerLabel.SetTextString("wärmer");
            waermerLabel.SetLabelStyle(new LabelStyle { FontColor = Color.Black, Font = new Font("Verdana", 8, FontStyle.Regular, GraphicsUnit.Point) });
            Size waermerLabelSize = Size.Ceiling(Platform.GetLabelSizePixels(waermerLabel.GetTextString(), waermerLabel.labelStyle));
            waermerLabel.bounds = new Rectangle(xStart + 5, yEnd - waermerLabelSize.Height, waermerLabelSize.Width, waermerLabelSize.Height);
            e.SceneGraph.Add(waermerLabel);

            var kaelterLabel = new Text();
            kaelterLabel.SetTextString("kälter");
            kaelterLabel.SetLabelStyle(new LabelStyle { FontColor = Color.Black, Font = new Font("Verdana", 8, FontStyle.Regular, GraphicsUnit.Point) });
            Size kaelterLabelSize = Size.Ceiling(Platform.GetLabelSizePixels(kaelterLabel.GetTextString(), kaelterLabel.labelStyle));
            kaelterLabel.bounds = new Rectangle(xStart + 5, yStart , kaelterLabelSize.Width, kaelterLabelSize.Height);
            e.SceneGraph.Add(kaelterLabel);
        }
Beispiel #2
0
        private static void TemperaturChartFillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e)
        {
            double target = 15;
            IAdvanceAxis axisY = e.Grid["Y"] as IAdvanceAxis;
            IAdvanceAxis axisX = e.Grid["X"] as IAdvanceAxis;

            int targetYCoord = Convert.ToInt32(axisY.Map(target));
            int xStart = Convert.ToInt32(axisX.MapMinimum);
            int xEnd = Convert.ToInt32(axisX.MapMaximum);

            Line targetLine = new Line(new Point(xStart, targetYCoord), new Point(xEnd, targetYCoord));

            targetLine.PE.Stroke = Color.Green;
            targetLine.PE.StrokeWidth = 1;


            //e.SceneGraph.Add(targetLine)

            Text targetLabel = new Text();
            targetLabel.SetTextString("Heizgrenztemperatur");
            Size targetLabelSize = Size.Ceiling(Platform.GetLabelSizePixels(targetLabel.GetTextString(), targetLabel.labelStyle));
            targetLabel.bounds = new Rectangle(xStart + 10, targetYCoord - targetLabelSize.Height, targetLabelSize.Width, targetLabelSize.Height);
            e.SceneGraph.Add(targetLabel);
        }
        private static void ChartOnFillSceneGraph(object sender, FillSceneGraphEventArgs e)
        {

            //List<Primitive> boxes = e.SceneGraph.Cast<Primitive>().Where(p => p is Box && p.Row > -1).ToList();

            //foreach (var box in boxes)
            //{
            //    Point loc = ((Box)box).rect.Location;

            //    //loc.Offset(((Box)box).rect.Width, ((Box)box).rect.Height);
            //    loc.Offset(0, -20);

            //    //Rectangle rect = new Rectangle(loc, new Size(((Box)box).rect.Width, 25));

            //    Text t = new Text(loc, box.Value.ToString());
            //    t.SetLabelStyle(new LabelStyle { FontColor = Color.Black });
            //    // new LabelStyle(this.Font, Color.Black, false, false, false, StringAlignment.Center, StringAlignment.Center, TextOrientation.Horizontal)); 
            //    //e.SceneGraph.Add(t);
            //}

            var chart = sender as UltraChartEx;

            if (chart == null)
            {
                return;
            }
            var data = chart.ExtraData as MeteoGtzYear;


            var relativeData = data.ToRelativeData();
            var relativeDataForChart = data.ToRelativeDataForChart();
           
            //Aktuelles Jahr
            var aktuellJahr = relativeDataForChart.Period1;
            var lgtz = relativeDataForChart.Lgtz; 

            var axisY = e.Grid["Y"] as IAdvanceAxis;
            var axisX = e.Grid["X"] as IAdvanceAxis;

            int targetYCoord = Convert.ToInt32(axisY.Map(lgtz));

            int aktuellJahrY = Convert.ToInt32(axisY.Map(aktuellJahr));

            int nullY = Convert.ToInt32(axisY.Map(0));

            var margin = MarginX * 3.5;
            if (!isPdf)
            {
                margin = MarginX * 6.2;
            }

            int xStart = Convert.ToInt32(axisX.MapMinimum - margin);
            int xEnd = Convert.ToInt32(axisX.MapMaximum + margin + (isPdf ? 32 :15));

            Line nullLine = new Line(new Point(xStart, nullY), new Point(xEnd, nullY))
            {
                PE =
                {
                    Stroke = Color.Black,
                    StrokeWidth = 1
                },
                lineStyle =
                {
                    DrawStyle = LineDrawStyle.Solid

                }
            };

            e.SceneGraph.Add(nullLine);

            var annLabel = new Text();
            annLabel.SetTextString(GetAnnotationText(relativeData.Lgtz, "das Langzeitmittel" + Environment.NewLine + "ist"));
            annLabel.SetLabelStyle(new LabelStyle { FontColor = Constants.YearsChartColors[3], Font = new Font("Verdana", isPdf ? 6f : 8.5f, FontStyle.Italic, GraphicsUnit.Point) });
            Size annLabelSize = Size.Ceiling(Platform.GetLabelSizePixels(annLabel.GetTextString(), annLabel.labelStyle));
            annLabel.bounds = new Rectangle(xEnd - annLabelSize.Width, targetYCoord - annLabelSize.Height / 2, annLabelSize.Width, annLabelSize.Height);
            e.SceneGraph.Add(annLabel);

            Line targetLine = new Line(new Point(xStart, targetYCoord), new Point(xEnd - annLabelSize.Width - 2, targetYCoord))
            {
                PE =
                {
                    Stroke = Constants.YearsChartColors[3],
                    StrokeWidth = 2
                },
                lineStyle =
                {
                    DrawStyle = LineDrawStyle.Dash
                     
                }
            };
            
            e.SceneGraph.Add(targetLine);

            var targetLabel = new Text();
            targetLabel.SetTextString("Langzeitmittel");
            targetLabel.SetLabelStyle(new LabelStyle { FontColor = Constants.YearsChartColors[3] });
            Size targetLabelSize = Size.Ceiling(Platform.GetLabelSizePixels(targetLabel.GetTextString(), targetLabel.labelStyle));
            targetLabel.bounds = new Rectangle(xStart - (targetLabelSize.Width - (isPdf ? 10 : 0)), targetYCoord - targetLabelSize.Height / 2, targetLabelSize.Width, targetLabelSize.Height);

            e.SceneGraph.Add(targetLabel);

            int yEnd = Convert.ToInt32(axisY.MapMaximum);

            var waermerLabel = new Text();
            waermerLabel.SetTextString("Temperatur");
            waermerLabel.SetLabelStyle(new LabelStyle { FontColor = Color.Black, Font = new Font("Verdana", 9, FontStyle.Regular, GraphicsUnit.Point) });
            Size waermerLabelSize = Size.Ceiling(Platform.GetLabelSizePixels(waermerLabel.GetTextString(), waermerLabel.labelStyle));
            waermerLabel.bounds = new Rectangle(xStart - (waermerLabelSize.Width / 2), yEnd - waermerLabelSize.Height, waermerLabelSize.Width, waermerLabelSize.Height);
            e.SceneGraph.Add(waermerLabel);

            if (Math.Abs(targetYCoord - aktuellJahrY) < 5)
            {
                return;
            }

            var targetLine2 = new Line(new Point(xStart, aktuellJahrY), new Point(xEnd - annLabelSize.Width - 2, aktuellJahrY))
            {
                PE =
                {
                    Stroke = Color.Black,
                    StrokeWidth = 2
                },
                lineStyle =
                {
                    DrawStyle = LineDrawStyle.Dot
                }

            };

            e.SceneGraph.Add(targetLine2);

            var targetLabel2 = new Text();
            targetLabel2.SetLabelStyle(new LabelStyle { FontColor = Color.Black});
            targetLabel2.SetTextString("100%");
            Size targetLabelSize2 = Size.Ceiling(Platform.GetLabelSizePixels(targetLabel2.GetTextString(), targetLabel2.labelStyle));
            targetLabel2.bounds = new Rectangle(xStart - targetLabelSize2.Width , aktuellJahrY - targetLabelSize2.Height/2, targetLabelSize2.Width, targetLabelSize2.Height);

            e.SceneGraph.Add(targetLabel2);
            
        }