Ejemplo n.º 1
0
Archivo: Area.cs Proyecto: Daoting/dt
        static Point[] InitPrevious(RenderContext rc, bool inverted, Point[] pts, double[] prev)
        {
            int length = pts.Length;

            Point[] pointArray = new Point[length];
            if (inverted)
            {
                for (int j = 0; j < length; j++)
                {
                    pointArray[j] = new Point(rc.ConvertX(prev[j]), pts[j].Y);
                }
                return(pointArray);
            }
            for (int i = 0; i < length; i++)
            {
                pointArray[i] = new Point(pts[i].X, rc.ConvertY(prev[i]));
            }
            return(pointArray);
        }
Ejemplo n.º 2
0
        UIElement[] IView2DRenderer.Generate()
        {
            int nser = _dataInfo.nser;
            int npts = _dataInfo.npts;

            if ((nser == 0) || (npts == 0))
            {
                return(null);
            }

            List <UIElement> objects    = new List <UIElement>();
            Rect             dataBounds = CoordConverter.DataBounds;
            bool             isStacked  = base.IsStacked;
            StackedSum       sum        = null;
            StackedSum       sum2       = null;
            StackedSum       sum3       = null;
            int nsg = 1;

            if (isStacked)
            {
                nsg  = base.NStackGroups();
                sum  = new StackedSum(nsg);
                sum2 = new StackedSum(nsg);
                sum3 = new StackedSum(nsg);
            }

            double       num4  = GetClusterWidth() * _dataInfo.DeltaX;
            IPlotElement defel = null;

            if (base.Symbol is PlotElement)
            {
                defel = ((PlotElement)base.Symbol).Clone() as IPlotElement;
            }

            bool defval   = (defel != null) ? defel.IsClustered : false;
            bool inverted = base.Inverted;
            int  num5     = 0;

            int[] numArray  = null;
            int[] numArray2 = null;
            if (isStacked)
            {
                num5 = base.NStackGroups();
            }
            else
            {
                numArray  = NClustered(defval);
                numArray2 = new int[numArray.Length];
                num5      = numArray[0];
            }

            double d             = 0.0;
            double origin        = 0.0;
            double seriesOverlap = 0.0;
            Chart  visual        = Chart;
            string xformat       = null;
            string yformat       = null;
            bool   flag4         = false;
            bool   flag5         = false;

            if (visual != null)
            {
                origin        = BarColumnOptions.GetOrigin(visual);
                xformat       = visual.View.AxisX.AnnoFormatInternal;
                yformat       = visual.View.AxisY.AnnoFormatInternal;
                flag4         = !double.IsNaN(visual.View.AxisX.LogBase);
                flag5         = !double.IsNaN(visual.View.AxisY.LogBase);
                seriesOverlap = BarColumnOptions.GetSeriesOverlap(visual);
                if (seriesOverlap > 1.0)
                {
                    seriesOverlap = 1.0;
                }
                else if (seriesOverlap < -1.0)
                {
                    seriesOverlap = -1.0;
                }
            }

            int si    = 0;
            int num10 = 0;

            while (si < nser)
            {
                IDataSeriesInfo ds     = base.Series[si];
                DataSeries      series = (DataSeries)base.Series[si];
                series.Children.Clear();
                objects.Add(series);
                series.SetDefaultFormat(xformat, yformat);
                int stackGroup = 0;
                if (isStacked)
                {
                    stackGroup = BarColumnOptions.GetStackGroup(series);
                }
                if (series.SymbolShape == null)
                {
                    series.SymbolShape = base.StyleGen.Next();
                }
                ShapeStyle symbolShape = series.SymbolShape;
                bool?      nullable    = null;
                double[,] values = ds.GetValues();
                if (values != null)
                {
                    int           length = values.GetLength(1);
                    int           num13  = values.GetLength(0);
                    RenderContext rc     = new RenderContext(this, ds, length)
                    {
                        Bounds = CoordConverter.ViewBounds
                    };
                    Rect clipBounds = rc.ClipBounds;
                    clipBounds = new Rect(clipBounds.X - 1.0, clipBounds.Y - 1.0, clipBounds.Width + 2.0, clipBounds.Height + 2.0);
                    double naN = double.NaN;
                    if ((rc.OptimizationRadiusScope & OptimizationRadiusScope.Symbols) > ((OptimizationRadiusScope)0))
                    {
                        naN = rc.OptimizationRadius;
                    }
                    bool isClustered = defval;
                    bool flag7       = series.IsStacked;
                    int  num15       = 0;
                    int  num16       = length;
                    if (_dataInfo.incX && !inverted)
                    {
                        Rect rect2 = CoordConverter.DataBounds2D;
                        for (int j = 0; j < length; j++)
                        {
                            double num18 = (num13 >= 2) ? values[1, j] : ((double)j);
                            if (num18 >= rect2.Left)
                            {
                                num15 = Math.Max(0, j - 2);
                                break;
                            }
                        }
                        for (int k = num15; k < length; k++)
                        {
                            double num20 = (num13 >= 2) ? values[1, k] : ((double)k);
                            if (num20 > rect2.Right)
                            {
                                num16 = k;
                                break;
                            }
                        }
                        num16 = Math.Min(length, num16 + 2);
                    }
                    Point point = new Point();
                    for (int i = num15; i < num16; i++)
                    {
                        double       num22     = values[0, i];
                        double       x         = (num13 >= 2) ? values[1, i] : ((double)i);
                        double       y         = x;
                        Style        style     = null;
                        IPlotElement pe        = null;
                        bool?        nullable2 = nullable;
                        if (!nullable2.GetValueOrDefault() || !nullable2.HasValue)
                        {
                            if (base.ColorScheme == ColorScheme.Point)
                            {
                                symbolShape = base.StyleGen.GetStyle(i);
                            }
                            style = base.GetStyle(series, si, i);
                            pe    = base.CreateElement(series.Symbol, style);
                            if (pe == null)
                            {
                                pe = PlotElement.SymbolFromMarker(series.SymbolMarker);
                                if ((pe != null) && (style != null))
                                {
                                    pe.Style = style;
                                }
                            }
                            if ((pe == null) && series.ChartType.HasValue)
                            {
                                ChartSubtype subtype = ChartTypes.GetSubtype(series.ChartType.ToString());
                                if (subtype != null)
                                {
                                    pe = base.CreateElement(subtype.Symbol, style);
                                }
                            }
                            else if (pe == null)
                            {
                                if (series.IsDefaultSymbol && (defel != null))
                                {
                                    pe       = defel;
                                    pe.Style = style;
                                    defel    = ((PlotElement)base.Symbol).Clone() as IPlotElement;
                                }
                            }
                            else
                            {
                                isClustered = pe.IsClustered;
                            }
                            if (pe == null)
                            {
                                isClustered = false;
                                if ((series.PointLabelTemplate != null) || (series.PointTooltipTemplate != null))
                                {
                                    DotSymbol symbol = new DotSymbol();
                                    symbol.Fill   = TransparentBrush;
                                    symbol.Size   = new Size(5.0, 5.0);
                                    symbol.Stroke = TransparentBrush;
                                    pe            = symbol;
                                }
                                else
                                {
                                    nullable = true;
                                }
                            }
                            else
                            {
                                isClustered = pe.IsClustered;
                            }
                        }
                        bool flag8 = (flag4 && inverted) || (flag5 && !inverted);
                        if (!flag8)
                        {
                            if (nsg > 1)
                            {
                                if (flag7)
                                {
                                    x += ((-0.5 * num4) + ((0.5 * num4) / ((double)num5))) + ((stackGroup * num4) / ((double)num5));
                                }
                            }
                            else if (isClustered)
                            {
                                int clusterPlotAreaIndex = rc.ClusterPlotAreaIndex;
                                if (clusterPlotAreaIndex == 0)
                                {
                                    if (num5 > 1)
                                    {
                                        x += ((-0.5 * num4) + ((0.5 * num4) / ((double)num5))) + ((num10 * num4) / ((double)num5));
                                    }
                                }
                                else if (numArray[clusterPlotAreaIndex] > 1)
                                {
                                    x += ((-0.5 * num4) + ((0.5 * num4) / ((double)numArray[clusterPlotAreaIndex]))) + ((numArray2[clusterPlotAreaIndex] * num4) / ((double)numArray[clusterPlotAreaIndex]));
                                }
                            }
                        }
                        if (isStacked && flag7)
                        {
                            if (double.IsNaN(num22))
                            {
                                num22 = 0.0;
                            }
                            if (base.IsStacked100)
                            {
                                if (_dataInfo.Stacked[stackGroup, x] != 0.0)
                                {
                                    num22 = ((num22 * 100.0) / _dataInfo.Stacked[stackGroup, x]) + sum[stackGroup, x];
                                }
                            }
                            else
                            {
                                num22 += sum[stackGroup, x];
                            }
                        }
                        double num26 = x;
                        if (inverted)
                        {
                            double num27 = x;
                            x     = num22;
                            num22 = num27;
                        }
                        double num28 = rc.ConvertX(x);
                        double num29 = rc.ConvertY(num22);
                        if (((isStacked && flag7) && (si > 0)) && ((inverted && !double.IsNaN(num29)) || (!inverted && !double.IsNaN(num28))))
                        {
                            rc.SetPrevious(sum[stackGroup, num26]);
                        }
                        nullable2 = nullable;
                        if (!nullable2.GetValueOrDefault() || !nullable2.HasValue)
                        {
                            if (isClustered)
                            {
                                int num30 = num5;
                                if (rc.ClusterPlotAreaIndex > 0)
                                {
                                    num30 = numArray[rc.ClusterPlotAreaIndex];
                                }
                                if (num30 > 0)
                                {
                                    if (inverted)
                                    {
                                        d = Math.Abs((double)(CoordConverter.ConvertY((num4 / ((double)num30)) + num22) - CoordConverter.ConvertY(num22)));
                                    }
                                    else
                                    {
                                        d = Math.Abs((double)(CoordConverter.ConvertX((num4 / ((double)num30)) + x) - CoordConverter.ConvertX(x)));
                                    }
                                }
                            }
                            else if (inverted)
                            {
                                d = Math.Abs((double)(CoordConverter.ConvertY(num4 + num22) - CoordConverter.ConvertY(num22)));
                            }
                            else
                            {
                                d = Math.Abs((double)(CoordConverter.ConvertX(num4 + x) - CoordConverter.ConvertX(x)));
                            }
                            if (double.IsNaN(d))
                            {
                                d = inverted ? (base.SizeY * 20.0) : (base.SizeX * 20.0);
                            }
                        }
                        if (flag8)
                        {
                            double num31 = 0.0;
                            double num32 = d * num5;
                            if (nsg > 1)
                            {
                                if (flag7)
                                {
                                    num31 = ((-0.5 * num32) + ((0.5 * num32) / ((double)num5))) + ((stackGroup * num32) / ((double)num5));
                                }
                            }
                            else if ((num5 > 1) && isClustered)
                            {
                                num31 = ((-0.5 * num32) + ((0.5 * num32) / ((double)num5))) + ((num10 * num32) / ((double)num5));
                            }
                            if (num31 != 0.0)
                            {
                                if (inverted)
                                {
                                    num29 += num31;
                                }
                                else
                                {
                                    num28 += num31;
                                }
                            }
                        }
                        if (isStacked && flag7)
                        {
                            StackedSum sum4;
                            int        num63;
                            double     num64;
                            double     num33 = values[0, i];
                            if (double.IsNaN(num33))
                            {
                                num33 = 0.0;
                            }
                            double num34 = (num33 >= 0.0) ? sum2[stackGroup, num26] : sum3[stackGroup, num26];
                            double num35 = (num33 >= 0.0) ? (sum2[stackGroup, num26] + num33) : (sum3[stackGroup, num26] + num33);
                            if (base.IsStacked100)
                            {
                                num34 = (num34 * 100.0) / _dataInfo.Stacked[stackGroup, num26];
                                num35 = (num35 * 100.0) / _dataInfo.Stacked[stackGroup, num26];
                            }
                            if (inverted)
                            {
                                double num36;
                                double num37;
                                double num38;
                                if (flag4)
                                {
                                    double minX = rc.GetMinX(CoordConverter.DataBounds2D);
                                    num36 = CoordConverter.ConvertX(Math.Max(num35, minX));
                                    num37 = CoordConverter.ConvertX(Math.Max(num34, minX));
                                }
                                else
                                {
                                    num36 = CoordConverter.ConvertX(num35);
                                    num37 = CoordConverter.ConvertX(num34);
                                }
                                if (flag5)
                                {
                                    num38 = base.SizeY * 20.0;
                                }
                                else
                                {
                                    num38 = Math.Abs((double)(CoordConverter.ConvertY(num4 / ((double)nsg)) - CoordConverter.ConvertY(0.0)));
                                }
                                double width = Math.Abs((double)(num37 - num36));
                                rc.Rect = new Rect(Math.Min(num36, num37), num29 - (0.5 * num38), width, num38);
                                sum[stackGroup, num26] = x;
                            }
                            else
                            {
                                double num41;
                                double num42;
                                double num43;
                                if (flag5)
                                {
                                    double minY = rc.GetMinY(CoordConverter.DataBounds2D);
                                    num41 = CoordConverter.ConvertY(Math.Max(num35, minY));
                                    num42 = CoordConverter.ConvertY(Math.Max(num34, minY));
                                }
                                else
                                {
                                    num41 = CoordConverter.ConvertY(num35);
                                    num42 = CoordConverter.ConvertY(num34);
                                }
                                if (flag4)
                                {
                                    num43 = base.SizeX * 20.0;
                                }
                                else
                                {
                                    num43 = Math.Abs((double)(CoordConverter.ConvertX(num4 / ((double)nsg)) - CoordConverter.ConvertX(0.0)));
                                }
                                double height = Math.Abs((double)(num42 - num41));
                                rc.Rect = new Rect(num28 - (0.5 * num43), Math.Min(num41, num42), num43, height);
                                sum[stackGroup, num26] = num22;
                            }
                            if (num33 >= 0.0)
                            {
                                (sum4 = sum2)[num63 = stackGroup, num64 = num26] = sum4[num63, num64] + num33;
                            }
                            else
                            {
                                (sum4 = sum3)[num63 = stackGroup, num64 = num26] = sum4[num63, num64] + num33;
                            }
                        }
                        else
                        {
                            nullable2 = nullable;
                            if (!nullable2.GetValueOrDefault() || !nullable2.HasValue)
                            {
                                double num46 = origin;
                                if (inverted)
                                {
                                    double num47 = rc.GetMinX(CoordConverter.DataBounds2D);
                                    double maxX  = rc.GetMaxX(CoordConverter.DataBounds2D);
                                    if (num46 < num47)
                                    {
                                        num46 = num47;
                                    }
                                    else if (num46 > maxX)
                                    {
                                        num46 = maxX;
                                    }
                                    double num49 = rc.ConvertX(num46);
                                    double num50 = d;
                                    double num51 = Math.Abs((double)(num49 - num28));
                                    if (seriesOverlap != 0.0)
                                    {
                                        double num52 = rc.ConvertY(y);
                                        double num53 = d * num5;
                                        if (seriesOverlap > 0.0)
                                        {
                                            num50 = num53 / ((num5 - (num5 * seriesOverlap)) + seriesOverlap);
                                        }
                                        else
                                        {
                                            num50 *= 1.0 + seriesOverlap;
                                        }
                                        double num54 = (num53 - num50) / ((double)(num5 - 1));
                                        rc.Rect = new Rect(Math.Min(num28, num49), (num52 - (0.5 * num53)) + (((num5 - num10) - 1) * num54), num51, num50);
                                    }
                                    else
                                    {
                                        rc.Rect = new Rect(Math.Min(num28, num49), num29 - (0.5 * num50), num51, num50);
                                    }
                                }
                                else
                                {
                                    double num55 = rc.GetMinY(CoordConverter.DataBounds2D);
                                    double maxY  = rc.GetMaxY(CoordConverter.DataBounds2D);
                                    if (num46 < num55)
                                    {
                                        num46 = num55;
                                    }
                                    else if (num46 > maxY)
                                    {
                                        num46 = maxY;
                                    }
                                    double num57 = rc.ConvertY(num46);
                                    double num58 = d;
                                    double num59 = Math.Abs((double)(num57 - num29));
                                    if (seriesOverlap != 0.0)
                                    {
                                        double num60 = rc.ConvertX(y);
                                        double num61 = d * num5;
                                        if (seriesOverlap > 0.0)
                                        {
                                            num58 = num61 / ((num5 - (num5 * seriesOverlap)) + seriesOverlap);
                                        }
                                        else
                                        {
                                            num58 *= 1.0 + seriesOverlap;
                                        }
                                        double num62 = (num61 - num58) / ((double)(num5 - 1));
                                        rc.Rect = new Rect((num60 - (0.5 * num61)) + (num10 * num62), Math.Min(num29, num57), num58, num59);
                                    }
                                    else
                                    {
                                        rc.Rect = new Rect(num28 - (0.5 * num58), Math.Min(num29, num57), num58, num59);
                                    }
                                }
                            }
                        }
                        rc.SetPoint(i, num28, num29);
                        if (pe != null)
                        {
                            Point point2 = new Point(num28, num29);
                            if ((pe is ICustomClipping) || clipBounds.Contains(point2))
                            {
                                if (double.IsNaN(naN))
                                {
                                    DataPoint dp = series.CreateDataPoint(si, i);
                                    base.RenderElement(objects, pe, series, rc, symbolShape, dp);
                                }
                                else if (((i == 0) || (Math.Abs((double)(point2.X - point.X)) > naN)) || ((Math.Abs((double)(point2.Y - point.Y)) > naN) || (i == (num16 - 1))))
                                {
                                    DataPoint point4 = series.CreateDataPoint(si, i);
                                    base.RenderElement(objects, pe, series, rc, symbolShape, point4);
                                    point = point2;
                                }
                            }
                        }
                    }

                    PlotElement element3 = base.RenderConnection(series, rc, si);
                    if (element3 != null)
                    {
                        series.Children.Insert(0, element3);
                    }

                    if (isClustered)
                    {
                        if (rc.ClusterPlotAreaIndex == 0)
                        {
                            num10++;
                        }
                        else
                        {
                            numArray2[rc.ClusterPlotAreaIndex]++;
                        }
                    }
                }
                si++;
            }
            return(objects.ToArray());
        }
Ejemplo n.º 3
0
        protected override bool Render(RenderContext rc)
        {
            bool   inverted = ((Renderer2D)rc.Renderer).Inverted;
            double left     = 0.0;
            double top      = 0.0;

            // uno不支持Path.Data为非PathGeometry!
            // wasm中在给Path.Data赋值前内容必须完整,后添加的Figures无效!众里寻他千百度,因为赋值没按顺序,操!
            PathGeometry geometry = new PathGeometry();

            if (inverted)
            {
                double num3 = rc.ConvertX(rc["HighValues"]);
                double num4 = rc.ConvertX(rc["LowValues"]);
                if (num3 < num4)
                {
                    double num5 = num4;
                    num4 = num3;
                    num3 = num5;
                }
                double     width = num3 - num4;
                PathFigure pf    = new PathFigure();
                pf.Segments.Add(new LineSegment {
                    Point = new Point()
                });
                pf.Segments.Add(new LineSegment {
                    Point = new Point(width, 0)
                });
                pf.Segments.Add(new LineSegment {
                    Point = new Point(width, Size.Width)
                });
                pf.Segments.Add(new LineSegment {
                    Point = new Point(0, Size.Width)
                });
                pf.Segments.Add(new LineSegment {
                    Point = new Point()
                });
                geometry.Figures.Add(pf);

                left = num4;
                top  = rc.Current.Y - (0.5 * Size.Height);
            }
            else
            {
                double num7 = rc.ConvertY(rc["HighValues"]);
                double num8 = rc.ConvertY(rc["LowValues"]);
                if (num7 < num8)
                {
                    double num9 = num8;
                    num8 = num7;
                    num7 = num9;
                }
                double     height = num7 - num8;
                PathFigure pf     = new PathFigure();
                pf.Segments.Add(new LineSegment {
                    Point = new Point()
                });
                pf.Segments.Add(new LineSegment {
                    Point = new Point(Size.Width, 0)
                });
                pf.Segments.Add(new LineSegment {
                    Point = new Point(Size.Width, height)
                });
                pf.Segments.Add(new LineSegment {
                    Point = new Point(0, height)
                });
                pf.Segments.Add(new LineSegment {
                    Point = new Point()
                });
                geometry.Figures.Add(pf);

                left = rc.Current.X - (0.5 * Size.Width);
                top  = num8;
            }
            Data = geometry;

            if (double.IsNaN(left) || double.IsNaN(top))
            {
                return(false);
            }

            Canvas.SetLeft(this, left);
            Canvas.SetTop(this, top);
            _labelRect = rc.Bounds2D;
            RectangleGeometry geo = new RectangleGeometry();

            geo.Rect = new Rect(_labelRect.X - left, _labelRect.Y - top, _labelRect.Width, _labelRect.Height);
            Clip     = geo;
            return(true);
        }
Ejemplo n.º 4
0
        protected override bool Render(RenderContext rc)
        {
            Point[] points = rc.Points;
            if (points == null)
            {
                return(false);
            }

            BaseRenderer renderer = rc.Renderer as BaseRenderer;
            bool         inverted = (renderer != null) && renderer.Inverted;
            bool         flag2    = (renderer != null) && renderer.IsStacked;

            double[] previousValues = rc.PreviousValues;
            double   d   = inverted ? rc.ConvertX(0.0) : rc.ConvertY(0.0);
            double   naN = double.NaN;

            if ((rc.OptimizationRadiusScope & OptimizationRadiusScope.Lines) > ((OptimizationRadiusScope)0))
            {
                naN = rc.OptimizationRadius;
            }
            if (double.IsNaN(d))
            {
                d = inverted ? (rc.XReversed ? (rc.Bounds2D.X + rc.Bounds2D.Width) : rc.Bounds2D.X) : (rc.YReversed ? rc.Bounds2D.Y : (rc.Bounds2D.Y + rc.Bounds2D.Height));
            }
            Rect cr = rc.IsCustomClipping ? new Rect(rc.Bounds2D.X - 2.0, rc.Bounds2D.Y - 2.0, rc.Bounds2D.Width + 4.0, rc.Bounds2D.Height + 4.0) : Extensions.EmptyRect;

            // uno不支持Path.Data为非PathGeometry!
            // wasm中在给Path.Data赋值前内容必须完整,后添加的Figures无效!众里寻他千百度,因为赋值没按顺序,操!
            PathGeometry geometry = new PathGeometry();

            if (flag2 && (previousValues != null))
            {
                points         = Lines.CreateSteps(points, inverted);
                previousValues = Lines.CreateSteps(previousValues);
                int     length = points.Length;
                Point[] pts    = new Point[2 * length];
                for (int i = 0; i < length; i++)
                {
                    pts[i] = points[i];
                    if (inverted)
                    {
                        pts[length + i] = new Point(rc.ConvertX(previousValues[(length - i) - 1]), points[(length - i) - 1].Y);
                    }
                    else
                    {
                        pts[length + i] = new Point(points[(length - i) - 1].X, rc.ConvertY(previousValues[(length - i) - 1]));
                    }
                }
                if (pts != null)
                {
                    PathFigure figure = base.RenderSegment(pts);
                    geometry.Figures.Add(figure);
                }
            }
            else
            {
                points = Lines.CreateSteps(points, inverted);
                List <Point[]> list = base.SplitPointsWithHoles(points);
                if (list != null)
                {
                    for (int j = 0; j < list.Count; j++)
                    {
                        PathFigure figure2 = null;
                        figure2 = base.RenderNonStacked(list[j], d, inverted, naN, cr);
                        if (figure2 != null)
                        {
                            geometry.Figures.Add(figure2);
                        }
                    }
                }
            }
            Data = geometry;

            RectangleGeometry geometry3 = new RectangleGeometry();

            _labelRect     = rc.Bounds2D;
            geometry3.Rect = _labelRect;
            Clip           = geometry3;
            return(true);
        }
Ejemplo n.º 5
0
Archivo: Area.cs Proyecto: Daoting/dt
        protected override bool Render(RenderContext rc)
        {
            Point[] points = rc.Points;
            if ((points == null) || (points.Length < 2))
            {
                return(false);
            }
            BaseRenderer renderer = rc.Renderer as BaseRenderer;

            if (renderer == null)
            {
                return(false);
            }
            bool   inverted = renderer.Inverted;
            double naN      = double.NaN;

            if ((rc.OptimizationRadiusScope & OptimizationRadiusScope.Lines) > ((OptimizationRadiusScope)0))
            {
                naN = rc.OptimizationRadius;
            }
            double[] previousValues = rc.PreviousValues;
            Point[]  pts            = null;

            // uno不支持Path.Data为非PathGeometry!
            // wasm中在给Path.Data赋值前内容必须完整,后添加的Figures无效!众里寻他千百度,因为赋值没按顺序,操!
            PathGeometry geometry = new PathGeometry();

            if (renderer.IsStacked && previousValues != null)
            {
                int length = points.Length;
                if ((previousValues != null) && (previousValues.Length == length))
                {
                    if (base.Smoothed && (length > 3))
                    {
                        Point[] pointArray3 = InitPrevious(rc, inverted, points, previousValues);
                        points      = new SplineNew(points).Calculate();
                        pointArray3 = new SplineNew(pointArray3).Calculate();
                        length      = points.Length;
                        pts         = new Point[2 * length];
                        for (int i = 0; i < length; i++)
                        {
                            pts[i]          = points[i];
                            pts[length + i] = pointArray3[(length - i) - 1];
                        }
                    }
                    else
                    {
                        pts = new Point[2 * length];
                        for (int j = 0; j < length; j++)
                        {
                            pts[j] = points[j];
                            if (inverted)
                            {
                                pts[length + j] = new Point(rc.ConvertX(previousValues[(length - j) - 1]), points[(length - j) - 1].Y);
                            }
                            else
                            {
                                pts[length + j] = new Point(points[(length - j) - 1].X, rc.ConvertY(previousValues[(length - j) - 1]));
                            }
                        }
                    }
                }
                if (pts != null)
                {
                    PathFigure figure = RenderSegment(pts);
                    geometry.Figures.Add(figure);
                }
            }
            else
            {
                double num5 = inverted ? rc.ConvertX(0.0) : rc.ConvertY(0.0);
                if (double.IsNaN(num5))
                {
                    num5 = inverted ? (rc.XReversed ? (rc.Bounds.X + rc.Bounds.Width) : rc.Bounds.X) : (rc.YReversed ? rc.Bounds.Y : (rc.Bounds.Y + rc.Bounds.Height));
                }
                List <Point[]> list = base.SplitPointsWithHoles(points);
                Rect           cr   = rc.IsCustomClipping ? new Rect(rc.Bounds2D.X - 2.0, rc.Bounds2D.Y - 2.0, rc.Bounds2D.Width + 4.0, rc.Bounds2D.Height + 4.0) : Extensions.EmptyRect;
                if (list != null)
                {
                    for (int k = 0; k < list.Count; k++)
                    {
                        Point[]    pointArray4 = list[k];
                        PathFigure figure;
                        if (renderer is RadarRenderer)
                        {
                            figure = RenderSegment(pointArray4);
                        }
                        else
                        {
                            figure = RenderNonStacked(pointArray4, num5, inverted, naN, cr);
                        }
                        if (figure != null)
                        {
                            geometry.Figures.Add(figure);
                        }
                    }
                }
            }
            Data = geometry;

            RectangleGeometry geometry2 = new RectangleGeometry();

            geometry2.Rect = new Rect(rc.Bounds.X, rc.Bounds.Y, rc.Bounds.Width, rc.Bounds.Height);
            base.Clip      = geometry2;
            return(true);
        }
Ejemplo n.º 6
0
Archivo: HLOC.cs Proyecto: Daoting/dt
        protected void RenderCandle(RenderContext rc)
        {
            bool inverted = false;

            if (rc.Renderer is BaseRenderer)
            {
                inverted = ((BaseRenderer)rc.Renderer).Inverted;
            }
            double d    = rc["HighValues"];
            double num2 = rc["LowValues"];
            double num3 = rc["OpenValues"];
            double num4 = rc["CloseValues"];

            if (double.IsNaN(num3) || double.IsNaN(num4))
            {
                return;
            }

            bool flag2 = num3 > num4;
            Rect rect;

            if (inverted)
            {
                num4 = rc.ConvertX(num4);
                num3 = rc.ConvertX(num3);
                double height = Size.Height;
                double y      = rc.Current.Y - (0.5 * height);
                double x      = num4;
                double width  = num3 - num4;
                if (width < 0.0)
                {
                    x     = num3;
                    width = -width;
                }
                rect = new Rect(x, y, width, height);
            }
            else
            {
                double num9  = Size.Width;
                double num10 = rc.Current.X - (0.5 * num9);
                num4 = rc.ConvertY(num4);
                num3 = rc.ConvertY(num3);
                double num11 = num4;
                double num12 = num3 - num4;
                if (num12 < 0.0)
                {
                    num11 = num3;
                    num12 = -num12;
                }
                rect = new Rect(num10, num11, num9, num12);
            }

            // uno不支持Path.Data为非PathGeometry!
            // wasm中在给Path.Data赋值前内容必须完整,后添加的Figures无效!众里寻他千百度,因为赋值没按顺序,操!
            PathGeometry geometry = new PathGeometry();
            PathFigure   figure   = CreateRectFigure(rect, true);

            if (!flag2)
            {
                base.Fill = new SolidColorBrush(Colors.Transparent);
            }
            geometry.Figures.Add(figure);
            if (!double.IsNaN(d))
            {
                PathFigure  figure2 = new PathFigure();
                LineSegment segment = new LineSegment();
                if (inverted)
                {
                    d = rc.ConvertX(d);
                    double num13 = num3;
                    if (Math.Abs((double)(d - num4)) < Math.Abs((double)(d - num3)))
                    {
                        num13 = num4;
                    }
                    figure2.StartPoint = new Point(d, rc.Current.Y);
                    segment.Point      = new Point(num13, rc.Current.Y);
                }
                else
                {
                    d = rc.ConvertY(d);
                    double num14 = num3;
                    if (Math.Abs((double)(d - num4)) < Math.Abs((double)(d - num3)))
                    {
                        num14 = num4;
                    }
                    figure2.StartPoint = new Point(rc.Current.X, d);
                    segment.Point      = new Point(rc.Current.X, num14);
                }
                figure2.Segments.Add(segment);
                geometry.Figures.Add(figure2);
            }
            if (!double.IsNaN(num2))
            {
                PathFigure  figure3  = new PathFigure();
                LineSegment segment2 = new LineSegment();
                if (inverted)
                {
                    num2 = rc.ConvertX(num2);
                    double num15 = num3;
                    if (Math.Abs((double)(num2 - num4)) < Math.Abs((double)(num2 - num3)))
                    {
                        num15 = num4;
                    }
                    figure3.StartPoint = new Point(num2, rc.Current.Y);
                    segment2.Point     = new Point(num15, rc.Current.Y);
                }
                else
                {
                    num2 = rc.ConvertY(num2);
                    double num16 = num3;
                    if (Math.Abs((double)(num2 - num4)) < Math.Abs((double)(num2 - num3)))
                    {
                        num16 = num4;
                    }
                    figure3.StartPoint = new Point(rc.Current.X, num2);
                    segment2.Point     = new Point(rc.Current.X, num16);
                }
                figure3.Segments.Add(segment2);
                geometry.Figures.Add(figure3);
            }
            Data = geometry;
        }
Ejemplo n.º 7
0
Archivo: HLOC.cs Proyecto: Daoting/dt
        void RenderDefault(RenderContext rc)
        {
            Fill = new SolidColorBrush(Colors.Transparent);
            double high     = rc["HighValues"];
            double low      = rc["LowValues"];
            double open     = rc["OpenValues"];
            double close    = rc["CloseValues"];
            double width    = Size.Width;
            double x        = rc.Current.X - (0.5 * width);
            double num7     = x + width;
            bool   inverted = false;

            if (rc.Renderer is BaseRenderer)
            {
                inverted = ((BaseRenderer)rc.Renderer).Inverted;
            }

            // uno不支持Path.Data为非PathGeometry!
            // wasm中在给Path.Data赋值前内容必须完整,后添加的Figures无效!众里寻他千百度,因为赋值没按顺序,操!
            PathGeometry geometry = new PathGeometry();
            PathFigure   figure;
            LineSegment  segment;

            if (!double.IsNaN(low) && !double.IsNaN(high))
            {
                figure          = new PathFigure();
                figure.IsFilled = true;
                segment         = new LineSegment();
                if (inverted)
                {
                    low  = rc.ConvertX(low);
                    high = rc.ConvertX(high);
                    figure.StartPoint = new Point(low, rc.Current.Y);
                    segment.Point     = new Point(high, rc.Current.Y);
                }
                else
                {
                    low  = rc.ConvertY(low);
                    high = rc.ConvertY(high);
                    figure.StartPoint = new Point(rc.Current.X, low);
                    segment.Point     = new Point(rc.Current.X, high);
                }
                figure.Segments.Add(segment);
                geometry.Figures.Add(figure);
            }

            if (!double.IsNaN(open))
            {
                figure          = new PathFigure();
                figure.IsFilled = true;
                segment         = new LineSegment();
                if (inverted)
                {
                    open = rc.ConvertX(open);
                    figure.StartPoint = new Point(open, rc.Current.Y + (0.5 * Size.Height));
                    segment.Point     = new Point(open, rc.Current.Y);
                }
                else
                {
                    open = rc.ConvertY(open);
                    figure.StartPoint = new Point(x, open);
                    segment.Point     = new Point(rc.Current.X, open);
                }
                figure.Segments.Add(segment);
                geometry.Figures.Add(figure);
            }

            if (!double.IsNaN(close))
            {
                figure          = new PathFigure();
                figure.IsFilled = true;
                segment         = new LineSegment();
                if (inverted)
                {
                    close             = rc.ConvertX(close);
                    figure.StartPoint = new Point(close, rc.Current.Y - (0.5 * Size.Height));
                    segment.Point     = new Point(close, rc.Current.Y);
                }
                else
                {
                    close             = rc.ConvertY(close);
                    figure.StartPoint = new Point(num7, close);
                    segment.Point     = new Point(rc.Current.X, close);
                }
                figure.Segments.Add(segment);
                geometry.Figures.Add(figure);
            }
            Data = geometry;
        }