Пример #1
0
        /// <summary>
        /// Updates the series when the start or end angle changes.
        /// </summary>
        /// <param name="d">The Dependency Object</param>
        /// <param name="e">The Event Arguments</param>
        private static void OnAngleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CircularSeriesBase3D series = d as CircularSeriesBase3D;

            if (series != null)
            {
                series.UpdateArea();
            }
        }
Пример #2
0
        /// <summary>
        /// Adds the pie adornments.
        /// </summary>
        /// <param name="x">The X Value</param>
        /// <param name="y">The Y Value</param>
        /// <param name="startAngle">The Start Angle</param>
        /// <param name="endAngle">The End Angle</param>
        /// <param name="index">The Index</param>
        /// <param name="radius">The Radius</param>
        /// <param name="startDepth">The Start Depth</param>
        private void AddPieAdornments(double x, double y, double startAngle, double endAngle, int index, double radius, double startDepth)
        {
            startAngle = CircularSeriesBase3D.DegreeToRadianConverter(startAngle);
            endAngle   = DegreeToRadianConverter(endAngle);
            var angle = (startAngle + endAngle) / 2;

            Adornments.Add(PieSeries3D.CreateAdornment(this, x, y, angle, radius, startDepth));
            Adornments[(int)x].Item = this.ActualData[index];
        }
Пример #3
0
        /// <summary>
        /// Gets the actual center of the series.
        /// </summary>
        /// <param name="centerPoint">The Center Point</param>
        /// <param name="radius">The Radius</param>
        /// <returns>Returns the actual center point.</returns>
        internal Point GetActualCenter(Point centerPoint, double radius)
        {
            if (this.Area != null && Area.Series.IndexOf(this) > 0)
            {
                return(centerPoint);
            }

            Point  actualCenter = centerPoint;
            double startAngle   = this.StartAngle;
            double endAngle     = this.EndAngle;

            double[]   regions = new double[] { -630, -540, -450, -360, -270, -180, -90, 0, 90, 180, 270, 360, 450, 540, 630 };
            List <int> region  = new List <int>();

            if (startAngle < endAngle)
            {
                for (int i = 0; i < regions.Count(); i++)
                {
                    if (regions[i] > startAngle && regions[i] < endAngle)
                    {
                        region.Add((int)((regions[i] % 360) < 0 ? (regions[i] % 360) + 360 : (regions[i] % 360)));
                    }
                }
            }
            else
            {
                for (int i = 0; i < regions.Count(); i++)
                {
                    if (regions[i] < startAngle && regions[i] > endAngle)
                    {
                        region.Add((int)((regions[i] % 360) < 0 ? (regions[i] % 360) + 360 : (regions[i] % 360)));
                    }
                }
            }

            var   startRadian = 2 * Math.PI * (startAngle) / 360;
            var   endRadian   = 2 * Math.PI * (endAngle) / 360;
            Point startPoint  = new Point(centerPoint.X + radius * Math.Cos(startRadian), centerPoint.Y + radius * Math.Sin(startRadian));
            Point endPoint    = new Point(centerPoint.X + radius * Math.Cos(endRadian), centerPoint.Y + radius * Math.Sin(endRadian));

            switch (region.Count)
            {
            case 0:
                var longX    = Math.Abs(centerPoint.X - startPoint.X) > Math.Abs(centerPoint.X - endPoint.X) ? startPoint.X : endPoint.X;
                var longY    = Math.Abs(centerPoint.Y - startPoint.Y) > Math.Abs(centerPoint.Y - endPoint.Y) ? startPoint.Y : endPoint.Y;
                var midPoint = new Point(Math.Abs((centerPoint.X + longX)) / 2, Math.Abs((centerPoint.Y + longY)) / 2);
                actualCenter.X = centerPoint.X + (centerPoint.X - midPoint.X);
                actualCenter.Y = centerPoint.Y + (centerPoint.Y - midPoint.Y);
                break;

            case 1:
                Point point1 = new Point(), point2 = new Point();
                var   maxRadian = 2 * Math.PI * region[0] / 360;
                var   maxPoint  = new Point(centerPoint.X + radius * Math.Cos(maxRadian), centerPoint.Y + radius * Math.Sin(maxRadian));
                switch (region.ElementAt(0))
                {
                case 270:
                    point1 = new Point(startPoint.X, maxPoint.Y);
                    point2 = new Point(endPoint.X, centerPoint.Y);
                    break;

                case 0:
                case 360:
                    point1 = new Point(centerPoint.X, endPoint.Y);
                    point2 = new Point(maxPoint.X, startPoint.Y);
                    break;

                case 90:
                    point1 = new Point(endPoint.X, centerPoint.Y);
                    point2 = new Point(startPoint.X, maxPoint.Y);
                    break;

                case 180:
                    point1 = new Point(maxPoint.X, startPoint.Y);
                    point2 = new Point(centerPoint.X, endPoint.Y);
                    break;
                }

                midPoint       = new Point((point1.X + point2.X) / 2, (point1.Y + point2.Y) / 2);
                actualCenter.X = centerPoint.X + ((centerPoint.X - midPoint.X) >= radius ? 0 : (centerPoint.X - midPoint.X));
                actualCenter.Y = centerPoint.Y + ((centerPoint.Y - midPoint.Y) >= radius ? 0 : (centerPoint.Y - midPoint.Y));
                break;

            case 2:
                var minRadian = 2 * Math.PI * region[0] / 360;
                maxRadian = 2 * Math.PI * (region[1]) / 360;
                maxPoint  = new Point(centerPoint.X + radius * Math.Cos(maxRadian), centerPoint.Y + radius * Math.Sin(maxRadian));
                Point minPoint = new Point(centerPoint.X + radius * Math.Cos(minRadian), centerPoint.Y + radius * Math.Sin(minRadian));
                if (region[0] == 0 && region[1] == 90 || region[0] == 180 && region[1] == 270)
                {
                    point1 = new Point(minPoint.X, maxPoint.Y);
                }
                else
                {
                    point1 = new Point(maxPoint.X, minPoint.Y);
                }

                if (region[0] == 0 || region[0] == 180)
                {
                    point2 = new Point(CircularSeriesBase3D.GetMinMaxValue(startPoint, endPoint, region[0]), CircularSeriesBase3D.GetMinMaxValue(startPoint, endPoint, region[1]));
                }
                else
                {
                    point2 = new Point(CircularSeriesBase3D.GetMinMaxValue(startPoint, endPoint, region[1]), CircularSeriesBase3D.GetMinMaxValue(startPoint, endPoint, region[0]));
                }

                midPoint       = new Point(Math.Abs(point1.X - point2.X) / 2 >= radius ? 0 : (point1.X + point2.X) / 2, y: Math.Abs(point1.Y - point2.Y) / 2 >= radius ? 0 : (point1.Y + point2.Y) / 2);
                actualCenter.X = centerPoint.X + (midPoint.X == 0 ? 0 : (centerPoint.X - midPoint.X) >= radius ? 0 : (centerPoint.X - midPoint.X));
                actualCenter.Y = centerPoint.Y + (midPoint.Y == 0 ? 0 : (centerPoint.Y - midPoint.Y) >= radius ? 0 : (centerPoint.Y - midPoint.Y));
                break;
            }

            return(actualCenter);
        }