Example #1
0
        public void start_path()
        {
            current_path = new Path();
            current_path.Data = new GeometryGroup();

            current_path.Stroke = Brushes.Black;
            current_path.StrokeThickness = 1;
            current_path.SnapsToDevicePixels = true;
            current_path.SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased);
        }
Example #2
0
        /// <summary>
        /// 界面中 增加管道
        /// </summary>
        /// <param name="pipe"></param>
        /// <param name="Start"></param>
        /// <param name="End"></param>
        public void AddPipe(Pipe pipe, Point Start, Point End)
        {
            Path path = new Path();
            path.Stroke = pipe.GetColorBrush();

            path.Data = DrawPipe(Start, End);

            path.StrokeThickness = App.StrokeThinkness * 2/3;
            path.SetValue(Canvas.ZIndexProperty, -1);
            path.ToolTip = pipe;
            context.Children.Add(path);
            listpath.Add(path);
        }
Example #3
0
        public void AddWastePipes(List<WastePipe> listpipe, List<VectorLine> list)
        {
            int index = 0;
            foreach (WastePipe pipe in listpipe)
            {
                Path path = new Path();
                path.Stroke = pipe.GetColorBrush();

                //添加带方向的管道

                path.Data = DrawPipe(list[index].StartPoint, list[index].EndPoint);
                index++;

                path.StrokeThickness = App.StrokeThinkness;
                path.SetValue(Canvas.ZIndexProperty, -1);
                path.ToolTip = pipe;
                path.SetValue(Canvas.ZIndexProperty, -1);
                context.Children.Add(path);

                listpath.Add(path);
            }
        }
Example #4
0
        /// <summary>
        /// Create and position ChartGrid for circular chart
        /// </summary>
        internal void CreateAndPositionChartGrid4CircularAxesY()
        {
            Double interval = (Double)Interval; // Interval  for the chart grid
            Decimal index = 0;                  // starting point for the loop that generates grids
            Decimal minVal = (Decimal)Minimum;  // smallest value from where the grid must be drawn
            Decimal maxVal = (Decimal)Maximum;  // largest value from where the grid must be drawn

            // gap between two intervals
            Decimal gap = (Decimal)interval;    

            Int32 countRectangles = 0;          // counts the number of color bands for animating them alternately in opposite direction
            Double position = 0;                // value of the line position for the running loop cycle

            InterlacedPaths = new List<Path>();
            InterlacedLines = new List<Line>();

            List<Point> previousPoints = new List<Point>();
            List<Point> currPoints = new List<Point>();

            CircularPlotDetails plotDetails = ParentAxis.CircularPlotDetails;

            if (minVal != maxVal)
            {
                Decimal xValue;

                for (xValue = minVal; xValue <= maxVal; )
                {
                    position = Graphics.ValueToPixelPosition(Height, 0, Minimum, Maximum, (Double)xValue);

                    Double radius = Height - position;

                    List<Point> points;

                    if (plotDetails.CircularChartType == RenderAs.Radar)
                        points = GetGridPoints4Radar(radius, plotDetails.Center, plotDetails.ListOfPoints4CircularAxis.Count);
                    else
                        points = GetGridPoints4Polar(radius, plotDetails.Center, plotDetails.AnglesInRadian);

                    currPoints = points;

                    Int32 i;
                    for (i = 0; i < points.Count - 1; i++)
                    {
                        Line line = new Line();
                        InterlacedLines.Add(line);
                        line.Stroke = LineColor;
                        line.StrokeThickness = (Double)LineThickness;
                        line.StrokeDashArray = ExtendedGraphics.GetDashArray(LineStyle);

                        line.X1 = points[i].X;
                        line.X2 = points[i + 1].X;
                        line.Y1 = points[i].Y;
                        line.Y2 = points[i + 1].Y;

                        Visual.Children.Add(line);
                    }

                    // Create last line
                    Line lastLine = new Line();
                    InterlacedLines.Add(lastLine);
                    lastLine.Stroke = LineColor;
                    lastLine.StrokeThickness = (Double)LineThickness;
                    lastLine.StrokeDashArray = ExtendedGraphics.GetDashArray(LineStyle);

                    lastLine.X1 = points[i].X;
                    lastLine.X2 = points[0].X;
                    lastLine.Y1 = points[i].Y;
                    lastLine.Y2 = points[0].Y;

                    Visual.Children.Add(lastLine);

                    if (index % 2 == 1)
                    {
                        Path path = new Path();
                        path.StrokeThickness = 0;

                        List<Point> listOfPreAndCurrPoints = new List<Point>();

                        for (Int32 newPointIndex = 0; newPointIndex < currPoints.Count; newPointIndex++)
                        {
                            listOfPreAndCurrPoints.Add(currPoints[newPointIndex]);
                        }

                        listOfPreAndCurrPoints.Add(currPoints[0]);

                        for (Int32 prePointIndex = 0; prePointIndex < previousPoints.Count; prePointIndex++)
                        {
                            listOfPreAndCurrPoints.Add(previousPoints[prePointIndex]);
                        }

                        listOfPreAndCurrPoints.Add(previousPoints[0]);
                        listOfPreAndCurrPoints.Add(currPoints[0]);

                        path.Data = ParentAxis.GetPathGeometry(listOfPreAndCurrPoints);

                        countRectangles++;
                        path.Fill = InterlacedColor;
                        path.SetValue(Canvas.ZIndexProperty, 10);
                        Visual.Children.Add(path);
                        InterlacedPaths.Add(path);
                    }

                    previousPoints = currPoints;

                    index += (ParentAxis.SkipOffset + 1);

                    xValue = minVal + index * gap;
                }
            }
        }
Example #5
0
        /// <summary>
        /// Create a slice of a funnel
        /// </summary>
        /// <param name="isLightingGradientLayer">Whether CreateFunnelSlice() function should create a layer for lighting</param>
        /// <param name="topRadius">Top Radius of the funnel</param>
        /// <param name="is3D">Whether the chart is a 3D Chart</param>
        /// <param name="funnelSlice">FunnelSlice canvas reference</param>
        /// <param name="yScaleTop">Top YScale for 3D view</param>
        /// <param name="yScaleBottom">Bottom YScale for 3D view</param>
        /// <param name="sideFillColor">Side surface fill color</param>
        /// <param name="topFillColor">Top surface fill color</param>
        /// <param name="topSurfaceStroke">Top surface stroke color</param>
        /// <param name="animationEnabled">Whether animation is enabled</param>
        /// <returns>Return funnel slice canvas</returns>
        private static Canvas CreateFunnelSlice(Boolean isLightingGradientLayer, Double topRadius, Boolean is3D, TriangularChartSliceParms funnelSlice, Double yScaleTop, Double yScaleBottom, Brush sideFillColor, Brush topFillColor, Brush topSurfaceStroke, Boolean animationEnabled)
        {
            Double SOLID_FUNNEL_EDGE_THICKNESS = 3;

            if (funnelSlice.Index == 0 && is3D && isLightingGradientLayer && (funnelSlice.FillType == FillType.Solid))
            {   
                funnelSlice.Height += SOLID_FUNNEL_EDGE_THICKNESS;
            }

            Canvas sliceCanvas = new Canvas() { Tag = new ElementData() { Element = funnelSlice.DataPoint } };
            Canvas visual = new Canvas() { Width = topRadius * 2, Height = funnelSlice.Height, Tag = new ElementData() { Element = funnelSlice.DataPoint } };  // Canvas holds a slice of a funnel chart
            Faces faces = null;


            // GeometryGroup for for a funnel slice path
            GeometryGroup geometryGroup = new GeometryGroup();

            // PathGeometry for for a funnel slice path
            PathGeometry pathGeometry = new PathGeometry();

            // pathFigure for for a funnel slice path
            PathFigure pathFigure = new PathFigure() { StartPoint = new Point(topRadius - funnelSlice.TopRadius, 0) };  // PathFigure of a funnel slice


            // Path for for a funnel slice
            Path path4Slice = new Path() { Fill = sideFillColor };

            path4Slice.Tag = new ElementData() { Element = funnelSlice.DataPoint };

            // Add PathGeometry to GeometryGroup
            geometryGroup.Children.Add(pathGeometry);

            // Set path data
            path4Slice.Data = geometryGroup;

            // Set properties for path
            path4Slice.StrokeThickness = 0;
            path4Slice.Stroke = new SolidColorBrush(Colors.Black);

            // Add path elements to its parent canvas
            pathGeometry.Figures.Add(pathFigure);
            visual.Children.Add(path4Slice);
            
            if (is3D)
            {
                
                #region 3D

                geometryGroup.FillRule = FillRule.Nonzero;

                // Create top arc left
                ArcSegment arcSegment = new ArcSegment();
                arcSegment.Point = new Point(topRadius, yScaleTop / 2);
                arcSegment.Size = new Size(funnelSlice.TopRadius, yScaleTop / 2);
                pathFigure.Segments.Add(arcSegment);

                // Create top arc right
                arcSegment = new ArcSegment();
                arcSegment.Point = new Point(topRadius + funnelSlice.TopRadius, 0);
                arcSegment.Size = new Size(funnelSlice.TopRadius, yScaleTop / 2);
                pathFigure.Segments.Add(arcSegment);

                // Create right Plain
                LineSegment lineSegment = new LineSegment() { Point = new Point(topRadius + funnelSlice.BottomRadius, funnelSlice.Height) };
                pathFigure.Segments.Add(lineSegment);

                lineSegment = new LineSegment() { Point = new Point(topRadius - funnelSlice.BottomRadius, funnelSlice.Height) };
                pathFigure.Segments.Add(lineSegment);

                // Create left Plain
                lineSegment = new LineSegment() { Point = new Point(topRadius - funnelSlice.TopRadius, 0) };
                pathFigure.Segments.Add(lineSegment);

                EllipseGeometry ellipseGeometry = new EllipseGeometry();
                ellipseGeometry.Center = new Point(topRadius, funnelSlice.Height);
                ellipseGeometry.RadiusX = funnelSlice.BottomRadius;
                ellipseGeometry.RadiusY = yScaleBottom / 2;

                geometryGroup.Children.Add(ellipseGeometry);

                // Create ellips for the funnel top
                Ellipse funnelTopEllipse = new Ellipse() { Height = yScaleTop, Width = funnelSlice.TopRadius * 2, Fill = topFillColor, Tag = new ElementData() { Element = funnelSlice.DataPoint } };

                funnelTopEllipse.SetValue(Canvas.TopProperty, -yScaleTop / 2);
                funnelTopEllipse.SetValue(Canvas.LeftProperty, topRadius - funnelSlice.TopRadius);

                //if (funnelSlice.DataPoint.Parent.Bevel)
                    funnelTopEllipse.StrokeThickness = 1.24;
                //else
                //    funnelTopEllipse.StrokeThickness = 0.24;

                funnelTopEllipse.Stroke = Graphics.GetBevelTopBrush(topSurfaceStroke, 0);

                visual.Children.Add(funnelTopEllipse);

                if (!isLightingGradientLayer)
                {
                    // Update faces for the DataPoint
                    faces = new Faces();
                    faces.VisualComponents.Add(path4Slice);
                    faces.VisualComponents.Add(funnelTopEllipse);

                    (path4Slice.Tag as ElementData).VisualElementName = "FunnelBase";
                    (funnelTopEllipse.Tag as ElementData).VisualElementName = "FunnelTop";

                    #region Creating Seperate BorderLine

                    GeometryGroup borderGeometryGroup = new GeometryGroup();

                    // PathGeometry for for a funnel slice path
                    PathGeometry leftRightBorderPathGeometry = new PathGeometry();

                    // LeftLine Border
                    PathFigure leftBorderPathFigure = new PathFigure() { StartPoint = pathFigure.StartPoint };
                    LineSegment leftBorderLineSegment = new LineSegment() { Point = new Point(topRadius - funnelSlice.BottomRadius, funnelSlice.Height) };
                    leftBorderPathFigure.Segments.Add(leftBorderLineSegment);

                    leftRightBorderPathGeometry.Figures.Add(leftBorderPathFigure);

                    // RightLine Border
                    PathGeometry rightRightBorderPathGeometry = new PathGeometry();
                    PathFigure rightBorderPathFigure = new PathFigure() { StartPoint = new Point(topRadius + funnelSlice.TopRadius, 0) };
                    LineSegment rightBorderLineSegment = new LineSegment() { Point = new Point(topRadius + funnelSlice.BottomRadius, funnelSlice.Height) };
                    rightBorderPathFigure.Segments.Add(rightBorderLineSegment);

                    rightRightBorderPathGeometry.Figures.Add(rightBorderPathFigure);

                    // Bottom _axisIndicatorBorderElement Ellipse
                    EllipseGeometry ellipseGeometryBorder = new EllipseGeometry();
                    ellipseGeometryBorder.Center = new Point(topRadius, funnelSlice.Height);
                    ellipseGeometryBorder.RadiusX = funnelSlice.BottomRadius;
                    ellipseGeometryBorder.RadiusY = yScaleBottom / 2;

                    borderGeometryGroup.Children.Add(ellipseGeometryBorder);

                    // Bottom _axisIndicatorBorderElement Ellipse
                    ellipseGeometryBorder = new EllipseGeometry();
                    ellipseGeometryBorder.Center = new Point(topRadius, 0);
                    ellipseGeometryBorder.RadiusX = funnelSlice.TopRadius;
                    ellipseGeometryBorder.RadiusY = yScaleTop / 2;

                    borderGeometryGroup.Children.Add(ellipseGeometryBorder);
                    borderGeometryGroup.Children.Add(leftRightBorderPathGeometry);
                    borderGeometryGroup.Children.Add(rightRightBorderPathGeometry);

                    Path borderPath = new Path() { Data = borderGeometryGroup, IsHitTestVisible = false };
                    borderPath.SetValue(Canvas.ZIndexProperty, (Int32)(-1));

                    visual.Children.Add(borderPath);
                    faces.BorderElements.Add(borderPath);
                    faces.BorderElements.Add(funnelTopEllipse);

                    #endregion
                    faces.Parts.Add(path4Slice);
                    faces.Parts.Add(funnelTopEllipse);
                    funnelSlice.DataPoint.Faces = faces;
                }
                else
                {
                    if (funnelSlice.FillType == FillType.Solid && funnelSlice.Index == 0)
                    {
                        path4Slice.SetValue(Canvas.ZIndexProperty, 1);
                        path4Slice.SetValue(Canvas.TopProperty, (-SOLID_FUNNEL_EDGE_THICKNESS));
                        funnelSlice.Height -= SOLID_FUNNEL_EDGE_THICKNESS;
                    }

                    path4Slice.IsHitTestVisible = false;
                    funnelTopEllipse.IsHitTestVisible = false;
                    funnelSlice.DataPoint.Faces.Parts.Add(path4Slice);
                    funnelSlice.DataPoint.Faces.Parts.Add(funnelTopEllipse);
                    funnelSlice.DataPoint.Faces.VisualComponents.Add(path4Slice);
                    funnelSlice.DataPoint.Faces.VisualComponents.Add(funnelTopEllipse);
                    (path4Slice.Tag as ElementData).VisualElementName = "Lighting";
                    (funnelTopEllipse.Tag as ElementData).VisualElementName = "FunnelTopLighting";
                }

                // Apply animation for the 3D funnel slice
                if (animationEnabled)
                {
                    funnelSlice.DataPoint.Parent.Storyboard = AnimationHelper.ApplyOpacityAnimation(funnelTopEllipse, funnelSlice.DataPoint.Parent, funnelSlice.DataPoint.Parent.Storyboard, 0, funnelSlice.DataPoint.InternalOpacity, 0, 1);
                    funnelSlice.DataPoint.Parent.Storyboard = AnimationHelper.ApplyOpacityAnimation(path4Slice, funnelSlice.DataPoint.Parent, funnelSlice.DataPoint.Parent.Storyboard, 0, funnelSlice.DataPoint.InternalOpacity, 0, 1);
                }

                #endregion
            }
            else
            {   
                // Points of a 2D funnel slice
                Point[] funnelCornerPoints = new Point[8];

                // Top line
                LineSegment lineSegment = new LineSegment() { Point = new Point(topRadius - funnelSlice.BottomRadius, funnelSlice.Height) };
                pathFigure.Segments.Add(lineSegment);
                funnelCornerPoints[3] = lineSegment.Point;

                // Right line
                lineSegment = new LineSegment() { Point = new Point(topRadius + funnelSlice.BottomRadius, funnelSlice.Height) };
                pathFigure.Segments.Add(lineSegment);
                funnelCornerPoints[2] = lineSegment.Point;

                // Bottom line
                lineSegment = new LineSegment() { Point = new Point(topRadius + funnelSlice.TopRadius, 0) };
                pathFigure.Segments.Add(lineSegment);
                funnelCornerPoints[1] = lineSegment.Point;

                // Left line
                lineSegment = new LineSegment() { Point = new Point(topRadius - funnelSlice.TopRadius, 0) };
                pathFigure.Segments.Add(lineSegment);
                funnelCornerPoints[0] = lineSegment.Point;

                // Apply animation for the 2D funnel slice
                if (animationEnabled)
                    funnelSlice.DataPoint.Parent.Storyboard = AnimationHelper.ApplyOpacityAnimation(path4Slice, funnelSlice.DataPoint.Parent, funnelSlice.DataPoint.Parent.Storyboard, 0, funnelSlice.DataPoint.InternalOpacity, 0, 1);

                if (!isLightingGradientLayer)
                {
                    // Update faces for the DataPoint
                    faces = new Faces();
                    faces.VisualComponents.Add(path4Slice);

                    (path4Slice.Tag as ElementData).VisualElementName = "FunnelBase";
                    faces.Parts.Add(path4Slice);

                    faces.BorderElements.Add(path4Slice);
                    funnelSlice.DataPoint.Faces = faces;

                    // Apply bevel effect for the 2D funnel Slice
                    if (funnelSlice.DataPoint.Parent.Bevel)
                    {
                        ApplyFunnelBevel(visual, funnelSlice, sideFillColor, funnelCornerPoints);
                    }
                }
                else
                {
                    path4Slice.IsHitTestVisible = false;
                    funnelSlice.DataPoint.Faces.VisualComponents.Add(path4Slice);
                    (path4Slice.Tag as ElementData).VisualElementName = "Lighting";
                }
            }

            if (isLightingGradientLayer)
            {
                visual.IsHitTestVisible = false;
            }
            else
            {
                // Drawing LabelLine
                Canvas labelLineCanvas = CreateLabelLine(funnelSlice, topRadius, animationEnabled);

                if (labelLineCanvas != null)
                {
                    sliceCanvas.Children.Add(labelLineCanvas);
                    faces.VisualComponents.Add(labelLineCanvas);
                }

                // Add label visual to the visual
                if ((Boolean)funnelSlice.DataPoint.LabelEnabled)
                {
                    Canvas labelCanvas = new Canvas();
                    labelCanvas.SetValue(Canvas.ZIndexProperty, (Int32)10);

                    faces.VisualComponents.Add(funnelSlice.DataPoint.LabelVisual);

                    // Label placement
                    funnelSlice.DataPoint.LabelVisual.SetValue(Canvas.TopProperty, funnelSlice.LabelLineEndPoint.Y - funnelSlice.DataPoint.LabelVisual.Height / 2);

                    if (funnelSlice.DataPoint.LabelStyle == LabelStyles.OutSide)
                    {
                        funnelSlice.DataPoint.LabelVisual.SetValue(Canvas.TopProperty, funnelSlice.LabelLineEndPoint.Y - funnelSlice.DataPoint.LabelVisual.Height / 2);
                        funnelSlice.DataPoint.LabelVisual.SetValue(Canvas.LeftProperty, funnelSlice.LabelLineEndPoint.X);
                    }
                    else
                    {
                        funnelSlice.DataPoint.LabelVisual.SetValue(Canvas.TopProperty, funnelSlice.LabelLineEndPoint.Y - funnelSlice.DataPoint.LabelVisual.Height / 2 + (is3D ? yScaleTop / 2 : 0));
                        funnelSlice.DataPoint.LabelVisual.SetValue(Canvas.LeftProperty, topRadius - funnelSlice.DataPoint.LabelVisual.Width / 2);
                    }

                    if (animationEnabled)
                        funnelSlice.DataPoint.Parent.Storyboard = AnimationHelper.ApplyOpacityAnimation(funnelSlice.DataPoint.LabelVisual, funnelSlice.DataPoint.Parent, funnelSlice.DataPoint.Parent.Storyboard, 1.2, 0.5, 0, 1);

                    labelCanvas.Children.Add(funnelSlice.DataPoint.LabelVisual);
                    sliceCanvas.Children.Add(labelCanvas);
                }
            }

            // if (!isLightingGradientLayer)
            //    faces.Visual = visual;

            sliceCanvas.Children.Add(visual);

            // sliceCanvas.Background = new SolidColorBrush(Color.FromArgb((byte)rand.Next(0,200),(byte)rand.Next(0,200),(byte)rand.Next(0,200),(byte)rand.Next(0,200)));

            return sliceCanvas;
        }
Example #6
0
        /// <summary>
        /// Returns a doughnut face
        /// </summary>
        /// <param name="doughnutParams">Doughnut parameters</param>
        /// <param name="centroid">Centroid</param>
        /// <param name="arcInnerStart">Arc inner dateTime point</param>
        /// <param name="arcInnerStop">Arc inner stop point</param>
        /// <param name="arcOuterStart">Arc outer dateTime point</param>
        /// <param name="arcOuterStop">Arc outer stop point</param>
        /// <param name="isTopFace">Whether a top face</param>
        /// <returns>Path</returns>
        private static Path GetDoughnutFace(SectorChartShapeParams doughnutParams, Point3D centroid, Point3D arcInnerStart, Point3D arcInnerStop, Point3D arcOuterStart, Point3D arcOuterStop, Boolean isTopFace)
        {
            Path pieFace = new Path() { Tag = new ElementData() { Element = doughnutParams.TagReference } };

            //pieFace.Fill = doughnutParams.Lighting ? Graphics.GetLightingEnabledBrush(doughnutParams.Background, -75, "Linear", new Double[] { 0.99, 0.854 }) : doughnutParams.Background;
            pieFace.Fill = Get3DFaceColor(RenderAs.Doughnut, doughnutParams.Lighting, doughnutParams.Background, PieFaceTypes.Top, Double.NaN, Double.NaN, Double.NaN);
           
           
            List<PathGeometryParams> pathGeometryList = new List<PathGeometryParams>();

            pathGeometryList.Add(new LineSegmentParams(new Point(arcOuterStop.X, arcOuterStop.Y)));
            pathGeometryList.Add(new ArcSegmentParams(new Size(doughnutParams.OuterRadius, doughnutParams.OuterRadius * doughnutParams.YAxisScaling), 0, doughnutParams.IsLargerArc, SweepDirection.Counterclockwise, new Point(arcOuterStart.X, arcOuterStart.Y)));
            pathGeometryList.Add(new LineSegmentParams(new Point(arcInnerStart.X, arcInnerStart.Y)));
            pathGeometryList.Add(new ArcSegmentParams(new Size(doughnutParams.InnerRadius, doughnutParams.InnerRadius * doughnutParams.YAxisScaling), 0, doughnutParams.IsLargerArc, SweepDirection.Clockwise, new Point(arcInnerStop.X, arcInnerStop.Y)));

            pieFace.Data = GetPathGeometryFromList(FillRule.Nonzero, new Point(arcInnerStop.X, arcInnerStop.Y), pathGeometryList, true);
            Point3D midPoint = GetFaceZIndex(arcInnerStart, arcInnerStop, arcOuterStart, arcOuterStop);
            if (isTopFace)
                pieFace.SetValue(Canvas.ZIndexProperty, (Int32)(doughnutParams.Height * 200));
            else
                pieFace.SetValue(Canvas.ZIndexProperty, (Int32)(-doughnutParams.Height * 200));
            return pieFace;
        }
Example #7
0
        /// <summary>
        /// Returns 3D Pie shapes
        /// </summary>
        /// <param name="faces">Pie faces</param>
        /// <param name="pieParams">Pie parameters</param>
        /// <param name="zindex">Zindex</param>
        /// <param name="unExplodedPoints">UnExploded dataPoints</param>
        /// <param name="explodedPoints">Exploded dataPoints</param>
        /// <param name="labelLinePath">Label line path</param>
        /// <param name="enabledDataPoints">List of enabled dataPoints</param>
        /// <returns>List of Shape</returns>
        private static List<Shape> GetPie3D(DataSeries currentDataSeries, ref Faces faces, SectorChartShapeParams pieParams, ref Int32 zindex, ref PieDoughnut3DPoints unExplodedPoints, ref PieDoughnut3DPoints explodedPoints, ref Path labelLinePath, List<DataPoint> enabledDataPoints)
        {
            List<Shape> pieFaces = new List<Shape>();

            Shape topFace = null, bottomFace = null, rightFace = null, leftFace = null;
            Point center = new Point();
            center.X = pieParams.Width / 2;
            center.Y = pieParams.Height / 2;

            // calculate 3d offsets
            Double yOffset = -pieParams.Depth / 2 * pieParams.ZAxisScaling;

            // calculate all points
            Point3D topFaceCenter = new Point3D();
            topFaceCenter.X = center.X;
            topFaceCenter.Y = center.Y + yOffset;
            topFaceCenter.Z = pieParams.OffsetY * Math.Sin(pieParams.StartAngle) * Math.Cos(pieParams.TiltAngle) + pieParams.Depth * Math.Cos(Math.PI / 2 - pieParams.TiltAngle);

            Point3D topArcStart = new Point3D();
            topArcStart.X = topFaceCenter.X + pieParams.OuterRadius * Math.Cos(pieParams.StartAngle);
            topArcStart.Y = topFaceCenter.Y + pieParams.OuterRadius * Math.Sin(pieParams.StartAngle) * pieParams.YAxisScaling;
            topArcStart.Z = (topFaceCenter.Y + pieParams.OuterRadius) * Math.Sin(pieParams.StartAngle) * Math.Cos(pieParams.TiltAngle) + pieParams.Depth * Math.Cos(Math.PI / 2 - pieParams.TiltAngle);

            Point3D topArcStop = new Point3D();
            topArcStop.X = topFaceCenter.X + pieParams.OuterRadius * Math.Cos(pieParams.StopAngle);
            topArcStop.Y = topFaceCenter.Y + pieParams.OuterRadius * Math.Sin(pieParams.StopAngle) * pieParams.YAxisScaling;
            topArcStop.Z = (topFaceCenter.Y + pieParams.OuterRadius) * Math.Sin(pieParams.StopAngle) * Math.Cos(pieParams.TiltAngle) + pieParams.Depth * Math.Cos(Math.PI / 2 - pieParams.TiltAngle);

            Point3D bottomFaceCenter = new Point3D();
            bottomFaceCenter.X = center.X;
            bottomFaceCenter.Y = center.Y - yOffset;
            bottomFaceCenter.Z = pieParams.OffsetY * Math.Sin(pieParams.StartAngle) * Math.Cos(pieParams.TiltAngle) - pieParams.Depth * Math.Cos(Math.PI / 2 - pieParams.TiltAngle);

            Point3D bottomArcStart = new Point3D();
            bottomArcStart.X = bottomFaceCenter.X + pieParams.OuterRadius * Math.Cos(pieParams.StartAngle);
            bottomArcStart.Y = bottomFaceCenter.Y + pieParams.OuterRadius * Math.Sin(pieParams.StartAngle) * pieParams.YAxisScaling;
            bottomArcStart.Z = (bottomFaceCenter.Y + pieParams.OuterRadius) * Math.Sin(pieParams.StartAngle) * Math.Cos(pieParams.TiltAngle) - pieParams.Depth * Math.Cos(Math.PI / 2 - pieParams.TiltAngle);

            Point3D bottomArcStop = new Point3D();
            bottomArcStop.X = bottomFaceCenter.X + pieParams.OuterRadius * Math.Cos(pieParams.StopAngle);
            bottomArcStop.Y = bottomFaceCenter.Y + pieParams.OuterRadius * Math.Sin(pieParams.StopAngle) * pieParams.YAxisScaling;
            bottomArcStop.Z = (bottomFaceCenter.Y + pieParams.OuterRadius) * Math.Sin(pieParams.StopAngle) * Math.Cos(pieParams.TiltAngle) - pieParams.Depth * Math.Cos(Math.PI / 2 - pieParams.TiltAngle);

            Point3D centroid = GetCentroid(topFaceCenter, topArcStart, topArcStop, bottomFaceCenter, bottomArcStart, bottomArcStop);

            UpdatePositionLabelInsidePie(pieParams, yOffset);

            if (pieParams.StartAngle == pieParams.StopAngle && pieParams.IsLargerArc || enabledDataPoints.Count == 1)
            {
                // draw singleton pie here
                topFace = new Ellipse() { Tag = new ElementData() { Element = pieParams.TagReference } };
                // topFace.Fill = pieParams.Lighting ? Graphics.GetLightingEnabledBrush(pieParams.Background, "Radial", new Double[] { 0.99, 0.745 }) : pieParams.Background;
                topFace.Fill = pieParams.Lighting ? Graphics.GetLightingEnabledBrush(pieParams.Background, "Linear", new Double[] { 0.99, 0.854 }) : pieParams.Background;

                topFace.Width = 2 * pieParams.OuterRadius;
                topFace.Height = 2 * pieParams.OuterRadius * pieParams.YAxisScaling;
                topFace.SetValue(Canvas.LeftProperty, (Double)(pieParams.Center.X - topFace.Width / 2));
                topFace.SetValue(Canvas.TopProperty, (Double)(pieParams.Center.Y - topFace.Height / 2 + yOffset));
                pieFaces.Add(topFace);
                faces.Parts.Add(topFace);

                bottomFace = new Ellipse() { Tag = new ElementData() { Element = pieParams.TagReference } };
                bottomFace.Fill = pieParams.Lighting ? Graphics.GetLightingEnabledBrush(pieParams.Background, "Radial", new Double[] { 0.99, 0.745 }) : pieParams.Background;

                bottomFace.Width = 2 * pieParams.OuterRadius;
                bottomFace.Height = 2 * pieParams.OuterRadius * pieParams.YAxisScaling;
                bottomFace.SetValue(Canvas.LeftProperty, (Double)(pieParams.Center.X - topFace.Width / 2));
                bottomFace.SetValue(Canvas.TopProperty, (Double)(pieParams.Center.Y - topFace.Height / 2 + yOffset));
                pieFaces.Add(bottomFace);
                faces.Parts.Add(bottomFace);
            }
            else
            {
                topFace = GetPieFace(pieParams, centroid, topFaceCenter, topArcStart, topArcStop);
                pieFaces.Add(topFace);
                faces.Parts.Add(topFace);

                bottomFace = GetPieFace(pieParams, centroid, bottomFaceCenter, bottomArcStart, bottomArcStop);
                pieFaces.Add(bottomFace);
                faces.Parts.Add(bottomFace);

                rightFace = GetPieSide(pieParams, centroid, topFaceCenter, bottomFaceCenter, topArcStart, bottomArcStart);
                pieFaces.Add(rightFace);
                faces.Parts.Add(rightFace);

                leftFace = GetPieSide(pieParams, centroid, topFaceCenter, bottomFaceCenter, topArcStop, bottomArcStop);
                pieFaces.Add(leftFace);
                faces.Parts.Add(leftFace);
            }

            labelLinePath = CreateLabelLine(currentDataSeries, pieParams, center, ref unExplodedPoints, ref explodedPoints);

            if ((pieParams.TagReference as DataPoint).InternalYValue == 0)
                return new List<Shape>();

            List<Shape> curvedSurface = GetPieOuterCurvedFace(pieParams, centroid, topFaceCenter, bottomFaceCenter);
            pieFaces.InsertRange(pieFaces.Count, curvedSurface.ToList());

            foreach (FrameworkElement fe in curvedSurface)
                faces.Parts.Add(fe);

            //Top face ZIndex
            topFace.SetValue(Canvas.ZIndexProperty, (Int32)(50000));

            //BottomFace ZIndex
            bottomFace.SetValue(Canvas.ZIndexProperty, (Int32)(-50000));

            if (pieParams.StartAngle == pieParams.StopAngle && pieParams.IsLargerArc)
            {

            }
            else
            {
                // ZIndex of curved face
                if (pieParams.StartAngle >= Math.PI && pieParams.StartAngle <= Math.PI * 2 && pieParams.StopAngle >= Math.PI && pieParams.StopAngle <= Math.PI * 2 && pieParams.IsLargerArc)
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, pieParams.StartAngle, pieParams.StartAngle));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[0], 0, Math.PI));
                    _elementPositionData.Add(new ElementPositionData(leftFace, pieParams.StopAngle, pieParams.StopAngle));
                    if (labelLinePath != null)
                        _elementPositionData.Add(new ElementPositionData(labelLinePath, 0, Math.PI));
                }
                else if (pieParams.StartAngle >= 0 && pieParams.StartAngle <= Math.PI && pieParams.StopAngle >= 0 && pieParams.StopAngle <= Math.PI && pieParams.IsLargerArc)
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, pieParams.StartAngle, pieParams.StartAngle));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[0], pieParams.StartAngle, Math.PI));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[1], 0, pieParams.StopAngle));
                    _elementPositionData.Add(new ElementPositionData(leftFace, pieParams.StopAngle, pieParams.StopAngle));
                    if (labelLinePath != null)
                        labelLinePath.SetValue(Canvas.ZIndexProperty, -50000);
                }
                else if (pieParams.StartAngle >= 0 && pieParams.StartAngle <= Math.PI && pieParams.StopAngle >= Math.PI && pieParams.StopAngle <= Math.PI * 2)
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, pieParams.StartAngle, pieParams.StartAngle));
                    
                    //  if (labelLinePath != null)
                    //      _elementPositionData.Add(new ElementPositionData(labelLinePath, pieParams.StartAngle, Math.PI));

                    //------------
                    if (labelLinePath != null)
                    {
                        if (pieParams.StartAngle >= Math.PI / 2 && pieParams.StopAngle <= Math.PI)
                            labelLinePath.SetValue(Canvas.ZIndexProperty, 50000);
                        else
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, pieParams.StartAngle, Math.PI));
                    }
                    //------------

                    _elementPositionData.Add(new ElementPositionData(leftFace, pieParams.StopAngle, pieParams.StopAngle));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[0], pieParams.StartAngle, Math.PI));
                }
                else if (pieParams.StartAngle >= Math.PI && pieParams.StartAngle <= Math.PI * 2 && pieParams.StopAngle >= 0 && pieParams.StopAngle <= Math.PI)
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, pieParams.StartAngle, pieParams.StartAngle));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[0], 0, pieParams.StopAngle));
                    _elementPositionData.Add(new ElementPositionData(leftFace, pieParams.StopAngle, pieParams.StopAngle));
                    if (labelLinePath != null)
                        _elementPositionData.Add(new ElementPositionData(labelLinePath, pieParams.StopAngle, pieParams.StopAngle));
                }
                else
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, pieParams.StartAngle, pieParams.StartAngle));
                    if (pieParams.StartAngle >= 0 && pieParams.StartAngle < Math.PI / 2 && pieParams.StopAngle >= 0 && pieParams.StopAngle < Math.PI / 2)
                    {
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, pieParams.StopAngle, pieParams.StopAngle));
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], pieParams.StartAngle, pieParams.StopAngle));
                    }
                    else if (pieParams.StartAngle >= 0 && pieParams.StartAngle < Math.PI / 2 && pieParams.StopAngle >= Math.PI / 2 && pieParams.StopAngle < Math.PI)
                    {
                        if (labelLinePath != null)
                            labelLinePath.SetValue(Canvas.ZIndexProperty, 40000);
                        curvedSurface[0].SetValue(Canvas.ZIndexProperty, 35000);
                    }
                    else if (pieParams.StartAngle >= Math.PI / 2 && pieParams.StartAngle < Math.PI && pieParams.StopAngle >= Math.PI / 2 && pieParams.StopAngle < Math.PI)
                    {
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, pieParams.StartAngle, pieParams.StartAngle));
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], pieParams.StartAngle, pieParams.StopAngle));
                    }
                    else if (pieParams.StartAngle >= Math.PI && pieParams.StartAngle < Math.PI * 1.5 && pieParams.StopAngle >= Math.PI && pieParams.StopAngle < Math.PI * 1.5)
                    {
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], pieParams.StartAngle, pieParams.StopAngle));
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, pieParams.StartAngle, pieParams.StartAngle));
                    }
                    else if (pieParams.StartAngle >= Math.PI * 1.5 && pieParams.StartAngle < Math.PI * 2 && pieParams.StopAngle >= Math.PI * 1.5 && pieParams.StopAngle < Math.PI * 2)
                    {
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], pieParams.StartAngle, pieParams.StopAngle));
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, pieParams.StartAngle, pieParams.StopAngle));
                    }
                    else
                    {
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, pieParams.StartAngle, pieParams.StartAngle));
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], pieParams.StartAngle, pieParams.StopAngle));
                    }

                    _elementPositionData.Add(new ElementPositionData(leftFace, pieParams.StopAngle, pieParams.StopAngle));
                }
            }

            return pieFaces;

        }
Example #8
0
        /// <summary>
        /// Draw segments and connect them together.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void DrawPathSegments_Clicked(object sender, RoutedEventArgs e)
        {
            // Create a path
            Path path = new Path();
            path.Stroke = new SolidColorBrush(Colors.Black);
            path.StrokeThickness = 2;

            var pathGeometry = new PathGeometry();

            //create segments
            PathSegmentCollection segmentCollection = new PathSegmentCollection();
            segmentCollection.Add(new LineSegment() { Point = new Point(300, 400) });
            segmentCollection.Add(new LineSegment() { Point = new Point(400, 300) });
            segmentCollection.Add(new LineSegment() { Point = new Point(500, 300) });

            //create path feature
            var pathFigure = new PathFigure() { Segments = segmentCollection };
            pathFigure.StartPoint = new Point(150, 10);
            pathGeometry.Figures = new PathFigureCollection() { pathFigure };

            path.Data = pathGeometry;

            //Add drag drop behavior.
            path.SetValue(DragDropBehavior.PlacementTarget, this.DrawCanvas);

            Canvas.SetLeft(path, 0);
            Canvas.SetTop(path, 0);
            this.DrawCanvas.Children.Add(path);
        }
Example #9
0
        /// <summary>
        /// Get visual object for area chart
        /// </summary>
        /// <param name="width">Width of the PlotArea</param>
        /// <param name="height">Height of the PlotArea</param>
        /// <param name="plotDetails">PlotDetails</param>
        /// <param name="seriesList">List of DataSeries with render as area chart</param>
        /// <param name="chart">Chart</param>
        /// <param name="plankDepth">PlankDepth</param>
        /// <param name="animationEnabled">Whether animation is enabled for chart</param>
        /// <returns>Area chart canvas</returns>
        internal static Canvas GetVisualObjectForAreaChart(Panel preExistingPanel, Double width, Double height, PlotDetails plotDetails, List<DataSeries> seriesList, Chart chart, Double plankDepth, bool animationEnabled)
        {   
            if (Double.IsNaN(width) || Double.IsNaN(height) || width <= 0 || height <= 0)
                return null;

            DataSeries series = seriesList[0] as DataSeries;

            if (animationEnabled)
            {
                if (series.Storyboard == null)
                    series.Storyboard = new Storyboard();
            }

            Canvas visual, labelCanvas, areaCanvas, areaFaceCanvas;
            RenderHelper.RepareCanvas4Drawing(preExistingPanel as Canvas, out visual, out labelCanvas, out areaCanvas, width, height);
            areaFaceCanvas = new Canvas() { Height = height, Width = width };

            Double depth3d = plankDepth / plotDetails.Layer3DCount * (chart.View3D ? 1 : 0);
            Double visualOffset = depth3d * (plotDetails.SeriesDrawingIndex[series] + 1);
            
            visual.SetValue(Canvas.TopProperty, visualOffset);
            visual.SetValue(Canvas.LeftProperty, -visualOffset);

            labelCanvas.SetValue(Canvas.TopProperty, (Double)0);
            labelCanvas.SetValue(Canvas.LeftProperty, (Double)0);

            areaFaceCanvas.SetValue(Canvas.TopProperty, (Double)0);
            areaFaceCanvas.SetValue(Canvas.LeftProperty, (Double)0);
            //areaFaceCanvas.SetValue(Canvas.ZIndexProperty, (Int32)1);
            DataSeries currentDataSeries;

            Double minimumXValue = Double.MaxValue;
            Double maximumXValue = Double.MinValue;

            if ((Boolean)series.Enabled)
            {   
                if (series.Storyboard == null)
                    series.Storyboard = new Storyboard();

                currentDataSeries = series;

                PlotGroup plotGroup = series.PlotGroup;

                Double limitingYValue = plotGroup.GetLimitingYValue();

                minimumXValue = Math.Min(minimumXValue, plotGroup.MinimumX);
                maximumXValue = Math.Max(maximumXValue, plotGroup.MaximumX);

                //List<DataPoint> enabledDataPoints = (from datapoint in series.InternalDataPoints where datapoint.Enabled == true select datapoint).ToList();

                Faces dataSeriesFaces = new Faces();
                dataSeriesFaces.FrontFacePaths = new List<Path>();
                dataSeriesFaces.Visual = areaFaceCanvas;
                dataSeriesFaces.LabelCanvas = labelCanvas;
                series.Faces = dataSeriesFaces;

                List<List<DataPoint>> brokenAreaDataPointsCollection = BrokenAreaDataPointsGroup(width, height, series);
                
                DataPoint currentDataPoint;
                DataPoint nextDataPoint;
                DataPoint previusDataPoint;

                Double plankYPos = Graphics.ValueToPixelPosition(height, 0, (Double)plotGroup.AxisY.InternalAxisMinimum, (Double)plotGroup.AxisY.InternalAxisMaximum, limitingYValue);

                foreach (List<DataPoint> dataPointList in brokenAreaDataPointsCollection)
                {   
                    if (dataPointList.Count <= 0)
                        continue;
                    
                    currentDataPoint = dataPointList[0];
                    previusDataPoint = currentDataPoint;
                    PointCollection points = new PointCollection();

                    List<DataPoint> dataPoints = new List<DataPoint>();
                    
                    Path frontFacePath = null;
                    PathGeometry frontFacePathGeometry;
                    PathFigure frontFacePathFigure = null;

                    Int32 maxZIndex = 0;

                    for (Int32 i = 0; i < dataPointList.Count - 1; i++)
                    {
                        Path areaBase = new Path();
                        Faces dataPointFaces;
                        Faces nextDataPointFaces = new Faces();

                        currentDataPoint = dataPointList[i];
                        currentDataPoint._parsedToolTipText = currentDataPoint.TextParser(currentDataPoint.ToolTipText);
                        nextDataPoint = dataPointList[i + 1];

                        if (currentDataPoint.Faces == null)
                        {   
                            dataPointFaces = new Faces();
                            currentDataPoint.Faces = dataPointFaces;
                        }
                        else
                            dataPointFaces = currentDataPoint.Faces;

                        nextDataPoint.Faces = nextDataPointFaces;

                        dataPointFaces.PreviousDataPoint = previusDataPoint;
                        dataPointFaces.NextDataPoint = nextDataPoint;

                        if (i == 0)
                        {   
                            // For the first DataPoint left and top face are drawn.
                            Double xPosDataPoint = Graphics.ValueToPixelPosition(0, width, (Double)plotGroup.AxisX.InternalAxisMinimum, (Double)plotGroup.AxisX.InternalAxisMaximum, currentDataPoint.InternalXValue);

                            if (chart.View3D)
                            {   
                                // Set points for left face
                                Area3DDataPointFace leftFace = new Area3DDataPointFace(depth3d);
                                leftFace.FrontFacePoints.Add(new Point(xPosDataPoint, plankYPos)); // Bottom Point
                                leftFace.FrontFacePoints.Add(currentDataPoint._visualPosition);    // Top Point
                                currentDataPoint.Faces.Area3DLeftFace = leftFace;

                                // Set points for top left face
                                Area3DDataPointFace topFace = new Area3DDataPointFace(depth3d);
                                topFace.FrontFacePoints.Add(currentDataPoint._visualPosition);   // Front Left Point
                                topFace.FrontFacePoints.Add(nextDataPoint._visualPosition);      // Front Right Point     
                                currentDataPoint.Faces.Area3DRightTopFace = topFace;
                                nextDataPointFaces.Area3DLeftTopFace = topFace;
                            }

                            // Start creating front face of 3D area
                            frontFacePath = new Path() { Opacity = currentDataPoint.Parent.Opacity };
                            //frontFacePath = new Path() { Opacity = 0.5 };
                            ApplyBorderProperties(frontFacePath, currentDataPoint.Parent);
                            dataSeriesFaces.FrontFacePaths.Add(frontFacePath);
                            frontFacePathGeometry = new PathGeometry();
                            frontFacePathFigure = new PathFigure() { StartPoint = new Point(xPosDataPoint, plankYPos), IsClosed = true };
                            frontFacePathGeometry.Figures.Add(frontFacePathFigure);
                            frontFacePath.Data = frontFacePathGeometry;
                            
                            // Area front face Line path from end point to first
                            LineSegment ls = new LineSegment() { Point = currentDataPoint._visualPosition };
                            frontFacePathFigure.Segments.Add(ls);
                            dataPointFaces.AreaFrontFaceLineSegment = ls; 
                        }
                        else
                        {
                            if (chart.View3D)
                            {   
                                // DataPoint which has two different top faces at the left and right side of it position.
                                Area3DDataPointFace topFace = new Area3DDataPointFace(depth3d);
                                topFace.FrontFacePoints.Add(currentDataPoint._visualPosition);  // Front Left Point
                                topFace.FrontFacePoints.Add(nextDataPoint._visualPosition);     // Front Right Point     

                                currentDataPoint.Faces.Area3DRightTopFace = topFace;
                                nextDataPointFaces.Area3DLeftTopFace = topFace;
                            }
                            else
                            {   
                                if(currentDataPoint.Parent.Bevel)
                                    CreateBevelFor2DArea(areaFaceCanvas, currentDataPoint, previusDataPoint,false, false); 
                            }

                            // Area front face Line path
                            LineSegment ls = new LineSegment() { Point = currentDataPoint._visualPosition };
                            frontFacePathFigure.Segments.Add(ls);
                            dataPointFaces.AreaFrontFaceLineSegment = ls; 
                        }

                        #region Create Marker

                        if (nextDataPoint.MarkerEnabled == true || nextDataPoint.LabelEnabled == true)
                        {
                            Double xPos, yPos;
                            // Create Marker
                            Marker marker = LineChart.CreateMarkerAForLineDataPoint(currentDataPoint, width, height, ref labelCanvas, out xPos, out yPos);

                            //if (marker != null)
                            //{
                            //    //LineChart.ApplyDefaultInteractivityForMarker(dataPoint);

                            //    //marker.AddToParent(labelCanvas, currentDataPoint._visualPosition.X, currentDataPoint._visualPosition.Y, new Point(0.5, 0.5));

                            //    // Apply marker animation
                            //    if (animationEnabled)
                            //    {
                            //        if (currentDataPoint.Parent.Storyboard == null)
                            //            currentDataPoint.Parent.Storyboard = new Storyboard();

                            //        // Apply marker animation
                            //        currentDataPoint.Parent.Storyboard = AnimationHelper.ApplyOpacityAnimation(marker, CurrentDataSeries, currentDataPoint.Parent.Storyboard, 1, currentDataPoint.Opacity * currentDataPoint.Parent.Opacity);
                            //    }
                            //}
                        }

                        #endregion

                        if (chart.View3D)
                        {
                            Int32 zindex = Draw3DArea(areaFaceCanvas, previusDataPoint, currentDataPoint, nextDataPoint, ref dataSeriesFaces, ref dataPointFaces, currentDataPoint.Parent, plankYPos);
                            maxZIndex = Math.Max(maxZIndex, zindex);
                        }
                        else
                        {   
                            //areaCanvas.Children.Add(Get2DArea(ref faces, areaParams));
                        }

                        if (i == dataPointList.Count - 2) // If next DataPoint is the last DataPoint
                        {   
                            if (chart.View3D)
                            {
                                DataPoint lastDataPoint = nextDataPoint;

                                Area3DDataPointFace rightFace = new Area3DDataPointFace(depth3d);
                                rightFace.FrontFacePoints.Add(nextDataPoint._visualPosition); // Front top point
                                rightFace.FrontFacePoints.Add(new Point(nextDataPoint._visualPosition.X, plankYPos));
                                nextDataPoint.Faces.Area3DRightFace = rightFace;

                                // Draw base of the 3d area
                                areaBase = new Path();
                                areaBase.Fill = (Boolean)dataPointList[0].Parent.LightingEnabled ? Graphics.GetTopFaceBrush(dataPointList[0].Parent.Color) : dataPointList[0].Parent.Color;
                                PathGeometry pg = new PathGeometry();
                                PathFigure pf = new PathFigure() { StartPoint = new Point(dataPointList[0]._visualPosition.X, plankYPos) };
                                pg.Figures.Add(pf);
                                pf.Segments.Add(new LineSegment() { Point = new Point(dataPointList[0]._visualPosition.X + depth3d, plankYPos - depth3d) });
                                pf.Segments.Add(new LineSegment() { Point = new Point(lastDataPoint._visualPosition.X + depth3d, plankYPos - depth3d) });
                                pf.Segments.Add(new LineSegment() { Point = new Point(lastDataPoint._visualPosition.X, plankYPos) });
                                areaBase.Data = pg;
                                areaBase.SetValue(Canvas.ZIndexProperty, (Int32) 1);
                                areaBase.Opacity = lastDataPoint.Parent.Opacity;
                                areaCanvas.Children.Add(areaBase);
                                dataSeriesFaces.FrontFacePaths.Add(areaBase);
                                series.Faces.VisualComponents.Add(areaBase);

                                // Animating AreaBase opacity
                                if (animationEnabled)
                                    series.Storyboard = AnimationHelper.ApplyOpacityAnimation(areaBase, series, series.Storyboard, 0.25, 1, 0, 1);
                            }
                            else
                            {   
                                if (nextDataPoint.Parent.Bevel)
                                    CreateBevelFor2DArea(areaFaceCanvas, nextDataPoint, currentDataPoint, false, false); 
                            }

                            // Front face for 3D and 2D both
                            LineSegment ls = new LineSegment() { Point = nextDataPoint._visualPosition };
                            frontFacePathFigure.Segments.Add(ls);
                            nextDataPointFaces.AreaFrontFaceLineSegment = ls;
                            ls = new LineSegment() { Point = new Point(nextDataPoint._visualPosition.X, plankYPos) };
                            frontFacePathFigure.Segments.Add(ls);
                            nextDataPointFaces.AreaFrontFaceBaseLineSegment = ls;

                            nextDataPointFaces.NextDataPoint = nextDataPoint;
                            
                            // Graphics.DrawPointAt(rightFace.FrontFacePoints[0], areaCanvas, Colors.Yellow);
                            if (chart.View3D)
                            {   
                                Int32 zindex = Draw3DArea(areaFaceCanvas, previusDataPoint, nextDataPoint, nextDataPoint, ref dataSeriesFaces, ref nextDataPointFaces, nextDataPoint.Parent, plankYPos);
                                maxZIndex = Math.Max(maxZIndex, zindex);
                            }
                            else
                            {   
                                // areaCanvas.Children.Add(Get2DArea(ref faces, areaParams));
                            }

                            if (nextDataPoint.MarkerEnabled == true || nextDataPoint.LabelEnabled == true)
                            {
                                Double xPos, yPos;
                                Marker marker = LineChart.CreateMarkerAForLineDataPoint(nextDataPoint, width, height, ref labelCanvas, out xPos, out yPos);
                            }

                            nextDataPoint._parsedToolTipText = nextDataPoint.TextParser(nextDataPoint.ToolTipText);

                        }

                        previusDataPoint = currentDataPoint;
                    }

                    if (frontFacePath != null)
                    {
                        if (chart.View3D)
                            frontFacePath.Fill = (Boolean)dataPointList[0].Parent.LightingEnabled ? Graphics.GetFrontFaceBrush(dataPointList[0].Parent.Color) : dataPointList[0].Parent.Color;
                        else
                            frontFacePath.Fill = (Boolean)dataPointList[0].Parent.LightingEnabled ? Graphics.GetLightingEnabledBrush(dataPointList[0].Parent.Color, "Linear", null) : dataPointList[0].Parent.Color;

                        series.Faces.VisualComponents.Add(frontFacePath);

                        frontFacePath.SetValue(Canvas.ZIndexProperty, maxZIndex);
                        areaFaceCanvas.Children.Add(frontFacePath);
                    }

                    foreach (FrameworkElement face in series.Faces.VisualComponents)
                        VisifireElement.AttachEvents2AreaVisual(currentDataPoint, currentDataPoint, face);
                }

                foreach (FrameworkElement face in series.Faces.VisualComponents)
                    VisifireElement.AttachEvents2AreaVisual(series, series, face);

                series.AttachAreaToolTip(chart, dataSeriesFaces.VisualComponents);

                areaFaceCanvas.Tag = null;

                Canvas plank = ColumnChart.CreateOrUpdatePlank(chart, series.PlotGroup.AxisY, areaCanvas, depth3d, Orientation.Horizontal);

                // apply area animation
                if (animationEnabled)
                {   
                    // if (series.Storyboard == null)
                    //  series.Storyboard = new Storyboard();

                    ScaleTransform scaleTransform = new ScaleTransform() { ScaleY = 0 };
                    areaFaceCanvas.RenderTransformOrigin = new Point(0.5, plankYPos / height);
                    areaFaceCanvas.RenderTransform = scaleTransform;

                    List<KeySpline> splines = AnimationHelper.GenerateKeySplineList
                        (
                        new Point(0, 0), new Point(1, 1),
                        new Point(0, 1), new Point(0.5, 1)
                        );

                    // Apply animation to the entire canvas that was used to create the area
                    series.Storyboard = AnimationHelper.ApplyPropertyAnimation(scaleTransform, "(ScaleTransform.ScaleY)", series, series.Storyboard, 1,
                        new Double[] { 0, 1 }, new Double[] { 0, 1 }, splines);

                    // Animating plank opacity
                    //series.Storyboard = AnimationHelper.ApplyOpacityAnimation(areaBase, series, series.Storyboard, 1.25, 1, 0, 1);

                    // Apply animation for label canvas
                    series.Storyboard = AnimationHelper.ApplyOpacityAnimation(labelCanvas, series, series.Storyboard, 1.25, 1, 0, 1);
                }
            }

            areaFaceCanvas.SetValue(Canvas.ZIndexProperty, (Int32)2);
            areaCanvas.Children.Add(areaFaceCanvas);

            // Remove old visual and add new visual in to the existing panel
            if (preExistingPanel != null)
            {
                visual.Children.RemoveAt(1);
                visual.Children.Add(areaCanvas);
            }
            else
            {
                labelCanvas.SetValue(Canvas.ZIndexProperty, 1);
                visual.Children.Add(labelCanvas);
                visual.Children.Add(areaCanvas);
            }

            RectangleGeometry clipRectangle = new RectangleGeometry();
            clipRectangle.Rect = new Rect(0, -depth3d - 4, width + depth3d, height + depth3d + chart.ChartArea.PLANK_THICKNESS + 10);
            areaCanvas.Clip = clipRectangle;

            // Clip the label canvas

            clipRectangle = new RectangleGeometry();

            Double clipLeft = 0;
            Double clipTop = -depth3d - 4;
            Double clipWidth = width + depth3d;
            Double clipHeight = height + depth3d + chart.ChartArea.PLANK_THICKNESS + 10;

            GetClipCoordinates(chart, ref clipLeft, ref clipTop, ref clipWidth, ref clipHeight, minimumXValue, maximumXValue);

            clipRectangle.Rect = new Rect(clipLeft, clipTop, clipWidth, clipHeight);

            labelCanvas.Clip = clipRectangle;
            return visual;
        }
Example #10
0
        /// <summary>
        /// Get visual of Area 3D
        /// </summary>
        /// <param name="faces">Faces</param>
        /// <param name="areaParams">AreaParams</param>
        /// <returns>ZIndex</returns>
        internal static Int32 Draw3DArea(Canvas parentVisual, DataPoint previusDataPoint, DataPoint dataPoint, DataPoint nextDataPoint, ref Faces dataSeriesFaces, ref Faces dataPointFaces, DataSeries dataSeries, Double plankYPos)
        {   
            Brush sideBrush = (Boolean) dataSeries.LightingEnabled ? Graphics.GetRightFaceBrush(dataSeries.Color) : dataSeries.Color;
            Brush topBrush = (Boolean)dataSeries.LightingEnabled ? Graphics.GetTopFaceBrush(dataSeries.Color) : dataSeries.Color;
            
            // Int32 pointIndexLimit = dataSeries.IsPositive ? areaParams.Points.Count - 1 : areaParams.Points.Count;

            Random rand = new Random(DateTime.Now.Millisecond);

            // parentVisual.Background = new SolidColorBrush(Colors.Green);

            Boolean isPositive2Negative = false;    // DataPoint at -ve, previous DataPoint is positive
            //Boolean isNegative2Positive = false;    // DataPoint at -ve, next DataPoint is positive

            //if (dataPoint.InternalYValue < 0 && previusDataPoint.InternalYValue > 0)
            //    isPositive2Negative = true;

            //if (dataPoint.InternalYValue > 0 && nextDataPoint.InternalYValue < 0)
            //    isNegative2Positive = true;

            Int32 zIndex = GetAreaZIndex(dataPoint._visualPosition.X, dataPoint._visualPosition.Y, dataPoint.InternalYValue > 0 || isPositive2Negative);            
            //dataPointFaces.da
            if (dataPointFaces.Area3DLeftFace != null)
            {   
                Area3DDataPointFace leftFace = dataPointFaces.Area3DLeftFace;
                leftFace.CalculateBackFacePoints();

                Path sides = new Path() { Tag = new ElementData() { Element = dataSeries } };
                sides.SetValue(Canvas.ZIndexProperty, zIndex);

                PathGeometry pg = new PathGeometry();
                PathFigure pf = new PathFigure() { IsClosed = true };
                pg.Figures.Add(pf);

                PointCollection facePoints = leftFace.GetFacePoints();
                pf.StartPoint = leftFace.FrontFacePoints[0];

                // Graphics.DrawPointAt(dataPointFaces.Area3DLeftFace.FrontPointLeft, parentVisual, Colors.Yellow);

                foreach (Point point in facePoints)
                {
                    LineSegment ls = new LineSegment() { Point = point };
                    pf.Segments.Add(ls);
                }

                sides.Data = pg;

                sides.Fill = sideBrush;
                sides.Opacity = dataPoint.Parent.Opacity;
                ApplyBorderProperties(sides, dataPoint.Parent);
                // sides.Fill = new SolidColorBrush(Color.FromArgb(255, (byte)rand.Next(155), (byte)rand.Next(200), (byte)rand.Next(126)));
                
                parentVisual.Children.Add(sides);

                leftFace.LeftFace = sides;

                //dataPointFaces.VisualComponents.Add(sides);
                //dataPointFaces.Parts.Add(sides);

                dataSeriesFaces.VisualComponents.Add(sides);

                //dataPointFaces.BorderElements.Add(sides);
            }

            if (dataPointFaces.Area3DLeftTopFace != null)
            {         
                Area3DDataPointFace topFace = dataPointFaces.Area3DLeftTopFace;

                if (isPositive2Negative)
                {
                    //Graphics.DrawPointAt(new Point(previusDataPoint._visualPosition.X, plankYPos), parentVisual, Colors.Red);
                    //Graphics.DrawPointAt(new Point(dataPoint._visualPosition.X, plankYPos), parentVisual, Colors.Red);

                    //Graphics.DrawPointAt(previusDataPoint._visualPosition, parentVisual, Colors.Red);
                    //Graphics.DrawPointAt(dataPoint._visualPosition, parentVisual, Colors.Red);

                    Point midPoint = new Point();

                    if (dataPointFaces.Area3DRightFace == null)
                    {
                        if (Graphics.IntersectionOfTwoStraightLines(new Point(previusDataPoint._visualPosition.X, plankYPos),
                            new Point(dataPoint._visualPosition.X, plankYPos),
                            previusDataPoint._visualPosition, dataPoint._visualPosition, ref midPoint))
                        {

                            topFace.FrontFacePoints[1] = midPoint;

                            //Graphics.DrawPointAt(midPoint, parentVisual, Colors.Green);
                        }
                    }


                    //Graphics.DrawPointAt(midPoint, parentVisual, Colors.Green);
                }

                //if (isNegative2Positive)
                //{   
                //    Graphics.DrawPointAt(new Point(previusDataPoint._visualPosition.X, plankYPos), parentVisual, Colors.Red);
                //    Graphics.DrawPointAt(new Point(dataPoint._visualPosition.X, plankYPos), parentVisual, Colors.Red);

                //    Graphics.DrawPointAt(previusDataPoint._visualPosition, parentVisual, Colors.Red);
                //    Graphics.DrawPointAt(dataPoint._visualPosition, parentVisual, Colors.Red);

                //    Point midPoint = new Point();

                //    if (Graphics.IntersectionOfTwoStraightLines(new Point(nextDataPoint._visualPosition.X, plankYPos),
                //        new Point(dataPoint._visualPosition.X, plankYPos),
                //        nextDataPoint._visualPosition, dataPoint._visualPosition, ref midPoint))
                //    {   
                //        topFace.FrontFacePoints[1] = midPoint;
                //    }

                //    Graphics.DrawPointAt(midPoint, parentVisual, Colors.Green);
                //}

                topFace.CalculateBackFacePoints();

                Path sides = new Path() { Tag = new ElementData() { Element = dataSeries } };
                sides.SetValue(Canvas.ZIndexProperty, zIndex);

                PathGeometry pg = new PathGeometry();
                PathFigure pf = new PathFigure() { IsClosed = true };
                pg.Figures.Add(pf);

                // Graphics.DrawPointAt(dataPointFaces.Area3DTopFace.FrontPointLeft, parentVisual, Colors.Yellow);

                pf.StartPoint = topFace.FrontFacePoints[0];

                PointCollection facePoints = topFace.GetFacePoints();

                foreach (Point point in facePoints)
                {   
                    LineSegment ls = new LineSegment() { Point = point };
                    pf.Segments.Add(ls);
                }
                
                sides.Data = pg;

                sides.Fill = topBrush;
                sides.Opacity = dataPoint.Parent.Opacity;
                ApplyBorderProperties(sides, dataPoint.Parent);
                // sides.Fill = new SolidColorBrush(Color.FromArgb(255, (byte)rand.Next(155), (byte)rand.Next(200), (byte)rand.Next(126))); //sideBrush;

                parentVisual.Children.Add(sides);

                topFace.TopFace = sides;
                // sides.Fill = new SolidColorBrush(Colors.Red);
                //dataPointFaces.VisualComponents.Add(sides);
                //dataPointFaces.Parts.Add(sides);
                dataSeriesFaces.VisualComponents.Add(sides);
                //dataPointFaces.BorderElements.Add(sides);

            }

            if (dataPointFaces.Area3DRightFace != null)
            {
                Area3DDataPointFace rightFace = dataPointFaces.Area3DRightFace;
                rightFace.CalculateBackFacePoints();

                Path sides = new Path() { Tag = new ElementData() { Element = dataSeries } };
                sides.SetValue(Canvas.ZIndexProperty, zIndex);

                PathGeometry pg = new PathGeometry();
                PathFigure pf = new PathFigure() { IsClosed = true };
                pg.Figures.Add(pf);

                PointCollection facePoints = rightFace.GetFacePoints();
                pf.StartPoint = rightFace.FrontFacePoints[0];

                // Graphics.DrawPointAt(dataPointFaces.Area3DLeftFace.FrontPointLeft, parentVisual, Colors.Yellow);
                // Graphics.DrawPointAt(dataPointFaces.Area3DLeftFace.FrontPointRight, parentVisual, Colors.Yellow);
                // Graphics.DrawPointAt(dataPointFaces.Area3DLeftFace.BackPointRight, parentVisual, Colors.Yellow);
                // Graphics.DrawPointAt(dataPointFaces.Area3DLeftFace.BackPointLeft, parentVisual, Colors.Yellow);

                foreach (Point point in facePoints)
                {
                    LineSegment ls = new LineSegment() { Point = point };
                    pf.Segments.Add(ls);
                }

                sides.Data = pg;

                sides.Fill = sideBrush;
                sides.Opacity = dataPoint.Parent.Opacity;
                ApplyBorderProperties(sides, dataPoint.Parent);
                // sides.Fill = new SolidColorBrush(Color.FromArgb(255, (byte)rand.Next(155), (byte)rand.Next(200), (byte)rand.Next(126)));

                parentVisual.Children.Add(sides);

                rightFace.RightFace = sides;
                
                ApplyBorderProperties(sides, dataSeries);

                //dataPointFaces.VisualComponents.Add(sides);
                //dataPointFaces.Parts.Add(sides);

                dataSeriesFaces.VisualComponents.Add(sides);

                //dataPointFaces.BorderElements.Add(sides);
            }

            return zIndex;
        }
Example #11
0
        /// <summary>
        /// 标记物
        /// </summary>
        public AInfoWindow()
        {
            parent = new Grid();
            _path = new Path();
            path1 = new Path();
            path2 = new Path();
            path3 = new Path();
            path4 = new Path();
            tileGird = new Grid();
            Anchor = new Point(5, 0);

            //  this.Tapped += ATip_Tapped;
            //this.DoubleTapped += ATip_DoubleTapped;
            ContentTextBlock = new TextBlock() { VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Left, TextWrapping = TextWrapping.Wrap, FontSize = 15, Margin = new Thickness(0, 0, 0, 0) };
            TitleTextBlock = new TextBlock() { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, FontSize = 22, Margin = new Thickness(0, 9, 0, 0) };
            ContentText = "";
            Title = "";

            ContentPanel = new StackPanel();
            TitlePanel = new StackPanel();

            TitleBackgroundColor = HexToColor("#FF2D2D2D");
            ContentBackgroundColor = HexToColor("#2F3236");
            SetBackgroundColor();
            parent.HorizontalAlignment = HorizontalAlignment.Stretch;
            parent.VerticalAlignment = VerticalAlignment.Stretch;
            parent.Margin = new Thickness(0, 0, 0, 0);
            this.Content = parent;

            parent.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(10) });
            parent.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            parent.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(10) });
            parent.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(40) });
            parent.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(59) });

            //左上边

            var pathGeometry = new PathGeometry();
            var figures = pathGeometry.Figures;
            PathFigure figure = new PathFigure();
            figure.StartPoint = new Point(0, 40);
            figure.Segments.Add(new LineSegment() { Point = new Point(0, 10) });
            figure.Segments.Add(new LineSegment() { Point = new Point(0, 0) });
            figure.Segments.Add(new LineSegment() { Point = new Point(10, 0) });
            // Can add other types, e.g. PolyLineSegment, PathSegment, ArcSegment, BezierSegment
            //figure.Segments.Add(new QuadraticBezierSegment() { Point1 = new Point(0, 0), Point2 = new Point(8, 0) });
            figure.Segments.Add(new LineSegment() { Point = new Point(10, 0) });
            figure.Segments.Add(new LineSegment() { Point = new Point(10, 40) });
            figure.IsClosed = true;
            figures.Add(figure);
            _path.Data = pathGeometry;
            // _path.Margin = new Thickness(0, 1, 0, -2);
            parent.Children.Add(_path);

            var pathGeometry1 = new PathGeometry();
            var figures1 = pathGeometry1.Figures;
            var figure1 = new PathFigure();
            figure1.StartPoint = new Point(10, 40);
            figure1.Segments.Add(new LineSegment() { Point = new Point(10, 10) });
            figure1.Segments.Add(new LineSegment() { Point = new Point(10, 0) });
            //figure1.Segments.Add(new QuadraticBezierSegment() { Point1 = new Point(10, 0), Point2 = new Point(2, 0) });
            figure1.Segments.Add(new LineSegment() { Point = new Point(0, 0) });
            figure1.Segments.Add(new LineSegment() { Point = new Point(0, 40) });
            figure1.IsClosed = true;
            figures1.Add(figure1);
            path1.Data = pathGeometry1;
            path1.SetValue(Grid.ColumnProperty, 2);
            // path1.Margin = new Thickness(0, 1, 0, -2);
            parent.Children.Add(path1);
            //标题
            TitlePanel.HorizontalAlignment = HorizontalAlignment.Stretch;
            TitlePanel.VerticalAlignment = VerticalAlignment.Stretch;
            TitlePanel.Children.Add(TitleTextBlock);
            tileGird.HorizontalAlignment = HorizontalAlignment.Stretch;
            tileGird.VerticalAlignment = VerticalAlignment.Stretch;
            tileGird.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
            tileGird.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(40) });
            tileGird.Children.Add(TitlePanel);
            tileGird.Margin = new Thickness(-1, 0, -1, -1);
            tileGird.SetValue(Grid.ColumnProperty, 1);

            parent.Children.Add(tileGird);

            var pathGeometry2 = new PathGeometry();
            var figures2 = pathGeometry2.Figures;
            var figure2 = new PathFigure();
            figure2.StartPoint = new Point(10, 0);
            figure2.Segments.Add(new LineSegment() { Point = new Point(0, 0) });
            figure2.Segments.Add(new LineSegment() { Point = new Point(0, 50) });
            //figure2.Segments.Add(new QuadraticBezierSegment() { Point1 = new Point(0, 50), Point2 = new Point(8, 50) });
            figure2.Segments.Add(new LineSegment() { Point = new Point(10, 50) });
            figure2.IsClosed = false;
            path2.StrokeThickness = 0;
            figures2.Add(figure2);
            path2.SetValue(Grid.RowProperty, 1);
            path2.Data = pathGeometry2;
            parent.Children.Add(path2);

            var pathGeometry3 = new PathGeometry();
            var figures3 = pathGeometry3.Figures;
            var figure3 = new PathFigure();
            figure3.StartPoint = new Point(0, 0);
            figure3.Segments.Add(new LineSegment() { Point = new Point(10, 0) });
            figure3.Segments.Add(new LineSegment() { Point = new Point(10, 50) });
            //figure3.Segments.Add(new QuadraticBezierSegment() { Point1 = new Point(10, 50), Point2 = new Point(2, 50) });
            figure3.Segments.Add(new LineSegment() { Point = new Point(0, 50) });
            figure3.IsClosed = false;
            figures3.Add(figure3);
            path3.StrokeThickness = 0;
            path3.SetValue(Grid.RowProperty, 1);
            path3.SetValue(Grid.ColumnProperty, 2);
            path3.VerticalAlignment = VerticalAlignment.Top;
            path3.Data = pathGeometry3;
            //path3.Margin = new Thickness(0, 0, 0, 0);
            parent.Children.Add(path3);

            ContentPanel.VerticalAlignment = VerticalAlignment.Center;

            ContentPanel.Margin = new Thickness(-1, 0, -1, 0);
            ContentPanel.Orientation = Orientation.Horizontal;
            ContentPanel.Children.Add(ContentTextBlock);
            ContentPanel.SetValue(Grid.RowProperty, 1);
            ContentPanel.SetValue(Grid.ColumnProperty, 1);
            ContentPanel.Height = 50;
            ContentPanel.VerticalAlignment = VerticalAlignment.Top;

            parent.Children.Add(ContentPanel);

            var pathGeometry4 = new PathGeometry();
            var figures4 = pathGeometry4.Figures;
            var figure4 = new PathFigure();
            figure4.StartPoint = new Point(0, 0);
            figure4.Segments.Add(new LineSegment() { Point = new Point(10, 10) });
            figure4.Segments.Add(new LineSegment() { Point = new Point(20, 0) });
            figure4.IsClosed = false;
            figures4.Add(figure4);
            path4.SetValue(Grid.RowProperty, 1);
            path4.SetValue(Grid.ColumnProperty, 1);
            path4.VerticalAlignment = VerticalAlignment.Bottom;
            path4.HorizontalAlignment = HorizontalAlignment.Center;
            path4.Data = pathGeometry4;
            parent.Children.Add(path4);
            SetBackgroundColor();
            SetCloseImage();
            this.Title = "";
            this.ContentText = "";


        }
Example #12
0
        private void CreateGridLinesOverPlank(Double height, Panel plank, Double plankDepth, Double plankThickness)
        {
            if (plank.Children.Contains(GridLineCanvas4VerticalPlank))
            {
                plank.Children.Remove(GridLineCanvas4VerticalPlank);
                GridLineCanvas4VerticalPlank.Children.Clear();
            }

            if (AxisY != null && AxisY.Grids.Count > 0)
            {
                GridLineCanvas4VerticalPlank = new Canvas();
                GridLineCanvas4VerticalPlank.Width = plank.Width;
                GridLineCanvas4VerticalPlank.Height = plank.Height;
                plank.Children.Add(GridLineCanvas4VerticalPlank);

                if ((Boolean)AxisY.Grids[0].Enabled)
                {
                    Decimal minVal = (Decimal)AxisY.Grids[0].Minimum;
                    Decimal maxVal = (Decimal)AxisY.Grids[0].Maximum;
                    Double interval = (Double)AxisY.Grids[0].Interval;
                    Decimal index = 0;
                    Double position = 0;
                    Double[] newYCoord = new Double[2];
                    Double[] prevYCoord = new Double[2];
                    Decimal gap = (Decimal)interval;
                    Int32 countRectangles = 0;

                    InterlacedLinesOverVerticalPlank = new List<Line>();
                    InterlacedPathsOverVerticalPlank = new List<System.Windows.Shapes.Path>();

                    Storyboard4PlankGridLines = new Storyboard();

                    if (minVal != maxVal)
                    {
                        for (Decimal xValue = minVal; xValue <= maxVal; )
                        {
                            Line line = new Line();

                            Brush lineBrush = AxisY.Grids[0].LineColor;

                            line.Stroke = lineBrush;
                            line.StrokeThickness = (Double)AxisY.Grids[0].LineThickness;
                            line.StrokeDashArray = ExtendedGraphics.GetDashArray(AxisY.Grids[0].LineStyle);

                            position = Graphics.ValueToPixelPosition(height, 0, AxisY.Grids[0].Minimum, AxisY.Grids[0].Maximum, (Double)xValue);

                            if (position == 0)
                                position += (Double)AxisY.Grids[0].LineThickness;

                            line.X1 = plankDepth;
                            line.X2 = 0;
                            line.Y1 = position - plankDepth;
                            line.Y2 = position - plankThickness;

                            newYCoord = new Double[] { position - plankDepth, position - plankThickness };

                            if (Chart._internalAnimationEnabled && AxisY.Grids[0].AnimationEnabled)
                            {
                                line.X2 = line.X1;
                                line.Y2 = line.Y1;
                                Storyboard4PlankGridLines.Children.Add(AxisY.Grids[0].CreateDoubleAnimation(line, "X2", plankDepth, 0, 0.75, 0.75));
                                Storyboard4PlankGridLines.Children.Add(AxisY.Grids[0].CreateDoubleAnimation(line, "Y2", position - plankDepth, position - plankThickness, 0.75, 0.75));
                            }

                            GridLineCanvas4VerticalPlank.Children.Add(line);
                            InterlacedLinesOverVerticalPlank.Add(line);

                            if (index % 2 == 1)
                            {
                                System.Windows.Shapes.Path path = new System.Windows.Shapes.Path();
                                path.StrokeThickness = 0;

                                if (Chart._internalAnimationEnabled && AxisY.Grids[0].AnimationEnabled)
                                {
                                    path.Opacity = 0;
                                    Storyboard4PlankGridLines.Children.Add(AxisY.Grids[0].CreateDoubleAnimation(path, "Opacity", 0, 1, 1, 0.75));
                                }

                                PointCollection col = new PointCollection();
                                col.Add(new Point(plankDepth, prevYCoord[0]));
                                col.Add(new Point(0, prevYCoord[1]));
                                col.Add(new Point(0, newYCoord[1]));
                                col.Add(new Point(plankDepth, newYCoord[0]));
                                col.Add(new Point(plankDepth, prevYCoord[0]));

                                path.Data = GetPathGeometry(col);

                                Brush interlacedBrush = AxisY.Grids[0].InterlacedColor;

                                countRectangles++;
                                path.Fill = interlacedBrush;
                                path.SetValue(Canvas.ZIndexProperty, 10);
                                GridLineCanvas4VerticalPlank.Children.Add(path);
                                InterlacedPathsOverVerticalPlank.Add(path);
                            }

                            index += (AxisY.SkipOffset + 1);
                            xValue = minVal + index * gap;

                            prevYCoord = new Double[] { position - plankDepth, position - plankThickness };
                        }
                    }
                }
            }
        }
Example #13
0
            private void SetZIndexOf3DLayers(ref Path path, Pyramid3dLayer pyramid3dFaceType)
            {
                switch (pyramid3dFaceType)
                {   
                    case Pyramid3dLayer.BackLayerLeft:
                        path.SetValue(Canvas.ZIndexProperty, -1);
                        break;

                    case Pyramid3dLayer.BackLayerRight:
                        path.SetValue(Canvas.ZIndexProperty, -1);
                        break;

                    case Pyramid3dLayer.BottomLayer:
                        path.SetValue(Canvas.ZIndexProperty, -2);
                        break;

                    case Pyramid3dLayer.FrontLayerLeft:
                        path.SetValue(Canvas.ZIndexProperty, 1);
                        break;

                    case Pyramid3dLayer.FrontLayerRight:
                        path.SetValue(Canvas.ZIndexProperty, 1);
                        break;

                    case Pyramid3dLayer.TopLayer:
                        path.SetValue(Canvas.ZIndexProperty, 2);
                        break;

                    case Pyramid3dLayer.LightingLayerFront:
                        path.SetValue(Canvas.ZIndexProperty, 2);

                        break;

                    case Pyramid3dLayer.LightingLayerLeft:
                        path.SetValue(Canvas.ZIndexProperty, 2);
                        break;

                    case Pyramid3dLayer.LightingLayerRight:
                        path.SetValue(Canvas.ZIndexProperty, 2);
                        break;
                }
            }
Example #14
0
        /// <summary>
        /// 界面中 添加管道,
        /// </summary>
        /// <param name="pipe"></param>
        /// <param name="line"></param>
        /// <returns>创建的path</returns>
        public Path AddPipe(Pipe pipe, VectorLine line)
        {
            Path path = new Path();
            path.Stroke = pipe.GetColorBrush();

            path.Data = DrawPipe(line.StartPoint , line.EndPoint);

            path.StrokeThickness = App.StrokeThinkness * 2 / 3;
            path.SetValue(Canvas.ZIndexProperty, -1);

            path.ToolTip = pipe;
            context.Children.Add(path);
            listpath.Add(path);

            return path;
        }
Example #15
0
 public void DrawRubberEdge(EdgeGeometry edgeGeometry)
 {
     if (RubberEdgePath != null)
         MainCanvas.Children.Remove(RubberEdgePath);
     RubberEdgePath = new Path() { Stroke = BlackBrush, StrokeThickness = 2.0 };
     PathFigure figure = Draw.CreateGraphicsPath(edgeGeometry.Curve);
     PathGeometry geometry = new PathGeometry();
     geometry.Figures.Add(figure);
     RubberEdgePath.Data = geometry;
     RubberEdgePath.SetValue(Canvas.LeftProperty, edgeGeometry.BoundingBox.Left);
     RubberEdgePath.SetValue(Canvas.TopProperty, edgeGeometry.BoundingBox.Bottom);
     geometry.Transform = new MatrixTransform() { Matrix = new Matrix(1.0, 0.0, 0.0, 1.0, -edgeGeometry.BoundingBox.Left, -edgeGeometry.BoundingBox.Bottom) };
     MainCanvas.Children.Add(RubberEdgePath);
 }
        private void DrawSegment(Point p1, Point p2, Point p3, Point p4, bool reflexangle, Color clr)
        {

            // Segment Geometry
            PathSegmentCollection segments = new PathSegmentCollection();

            // First line segment from pt p1 - pt p2
            segments.Add(new LineSegment() { Point = p2 });

            //Arc drawn from pt p2 - pt p3 with the RangeIndicatorRadius 
            segments.Add(new ArcSegment()
            {
                Size = new Size(arcradius2, arcradius2),
                Point = p3,
                SweepDirection = SweepDirection.Clockwise,
                IsLargeArc = reflexangle

            });

            // Second line segment from pt p3 - pt p4
            segments.Add(new LineSegment() { Point = p4 });

            //Arc drawn from pt p4 - pt p1 with the Radius of arcradius1 
            segments.Add(new ArcSegment()
            {
                Size = new Size(arcradius1, arcradius1),
                Point = p1,
                SweepDirection = SweepDirection.Counterclockwise,
                IsLargeArc = reflexangle

            });

            // Defining the segment path properties
            Color rangestrokecolor;
            if (clr == Colors.Transparent)
            {
                rangestrokecolor = clr;
            }
            else
                rangestrokecolor = Colors.White;



            rangeIndicator = new Path()
            {
                StrokeLineJoin = PenLineJoin.Round,
                Stroke = new SolidColorBrush(rangestrokecolor),
                //Color.FromArgb(0xFF, 0xF5, 0x9A, 0x86)
                Fill = new SolidColorBrush(clr),
                Opacity = 0.65,
                StrokeThickness = 0.25,
                Data = new PathGeometry()
                {
                    Figures = new PathFigureCollection()
                     {
                        new PathFigure()
                        {
                            IsClosed = true,
                            StartPoint = p1,
                            Segments = segments
                        }
                    }
                }
            };

            //Set Z index of range indicator
            rangeIndicator.SetValue(Canvas.ZIndexProperty, 150);
            // Adding the segment to the root grid 
            LayoutRoot.Children.Add(rangeIndicator);

        }
Example #17
0
        private void CreatePathOutline(Path path, String pathName)
        {
            path.Name = pathName;
            path.IsHitTestVisible = true;
            //TODO: Performance
            path.Height = Constants.BaseHexHeight * Game.CurrentViewLevel; //100 //Constants.BaseHexHeight * Game.CurrentViewLevel;
            path.Width = Constants.BaseHexWidth * Game.CurrentViewLevel; //120 //Constants.BaseHexWidth * Game.CurrentViewLevel;
            path.Stroke = new SolidColorBrush(Colors.Gray);
            path.StrokeThickness = 1;
            path.HorizontalAlignment = HorizontalAlignment.Stretch;
            path.VerticalAlignment = VerticalAlignment.Stretch;
            path.Margin = new Thickness(0);
            path.Stretch = Stretch.Fill;

            PathFigure pathFigure = new PathFigure();
            pathFigure.StartPoint = new Point(0, 8.660254);
            pathFigure.Segments.Add(new LineSegment { Point = new Point(5, 17.320508) });
            pathFigure.Segments.Add(new LineSegment { Point = new Point(15, 17.320508) });
            pathFigure.Segments.Add(new LineSegment { Point = new Point(20, 8.660254) });
            pathFigure.Segments.Add(new LineSegment { Point = new Point(15, 0) });
            pathFigure.Segments.Add(new LineSegment { Point = new Point(5, 0) });
            pathFigure.Segments.Add(new LineSegment { Point = new Point(0, 8.660254) });
            PathGeometry pathGeometry = new PathGeometry();
            pathGeometry.Figures.Add(pathFigure);
            path.Data = pathGeometry;
            path.SetValue(Canvas.TopProperty, 0.0);
            path.SetValue(Canvas.LeftProperty, 0.0);
        }
Example #18
0
        /// <summary>
        /// Draw multiple geometry at one time.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DrawPath_Clicked(object sender, RoutedEventArgs e)
        {
            // Create a path
            Path path = new Path();
            path.Stroke = new SolidColorBrush(Colors.BlueViolet);
            path.StrokeThickness = 3;

            // Create a line geometry
            LineGeometry blackLineGeometry = new LineGeometry();
            blackLineGeometry.StartPoint = new Point(20, 200);
            blackLineGeometry.EndPoint = new Point(300, 200);

            // Create an ellipse geometry
            EllipseGeometry blackEllipseGeometry = new EllipseGeometry();
            blackEllipseGeometry.Center = new Point(80, 150);
            blackEllipseGeometry.RadiusX = 50;
            blackEllipseGeometry.RadiusY = 50;

            // Create a rectangle geometry
            RectangleGeometry blackRectGeometry = new RectangleGeometry();
            Rect rct = new Rect();
            rct.X = 80;
            rct.Y = 167;
            rct.Width = 150;
            rct.Height = 30;
            blackRectGeometry.Rect = rct;

            // Add all the geometries to a GeometryGroup.
            GeometryGroup blueGeometryGroup = new GeometryGroup();
            blueGeometryGroup.Children.Add(blackLineGeometry);
            blueGeometryGroup.Children.Add(blackEllipseGeometry);
            blueGeometryGroup.Children.Add(blackRectGeometry);

            // Set Path.Data
            path.Data = blueGeometryGroup;

            //Add drag drop behavior.
            path.SetValue(DragDropBehavior.PlacementTarget, this.DrawCanvas);

            Canvas.SetLeft(path, 0);
            Canvas.SetTop(path, 0);
            this.DrawCanvas.Children.Add(path);
        }
 public void DrawBoard()
 {
     bool flip = true;
     for (float i = 0; i <= 7; i++)
     {
         for (float j = 0; j <= 7; j++)
         {
             GeometryGroup geometry = new GeometryGroup();
             RectangleGeometry rect = new RectangleGeometry();
             rect.Rect = new Rect(0, 0, size, size);
             Path path = new Path();
             SolidColorBrush color = new SolidColorBrush();
             if (flip)
             {
                 color.Color = Colors.Red;
             }
             else
             {
                 color.Color = Colors.White;
             }
             path.Fill = color;
             path.Stroke = new SolidColorBrush(Colors.Black);
             path.Stretch = Stretch.Fill;
             path.StrokeThickness = 2.0;
             path.SetValue(Canvas.LeftProperty, (double)(i * size));
             path.SetValue(Canvas.TopProperty, (double)(j * size));
             flip = ((j == 7) ? flip : ! flip);
             geometry.Children.Add(rect);
             EllipseGeometry ellipse = new EllipseGeometry();
             ellipse.Center = new Point(size/2, size/2);
             ellipse.RadiusX = size/4;
             ellipse.RadiusY = size/4;
             if (mCells[(int)i, (int)j])
             {
                 Queen q = new Queen((byte)i, (byte)j);
                 Int16 index = Exists(ref q);
                 if (index > 0)
                 {
                     if (Queens[index] != null)
                     {
                         if (! (CheckAll(index)))
                         {
                             geometry.Children.Add(ellipse);
                         }
                         else
                         {
                             geometry.Children.Add(ellipse);
                         }
                     }
                 }
                 else
                 {
                     geometry.Children.Add(ellipse);
                 }
             }
             path.Data = geometry;
             path.MouseLeftButtonDown += new MouseButtonEventHandler(ChessBoard_MouseDown);
             this.contentPanel.Children.Add(path);
         }
     }
 }
Example #20
0
        /// <summary>
        /// Returns 3D Doughnut shapes
        /// </summary>
        /// <param name="faces">Doughnut faces</param>
        /// <param name="doughnutParams">Doughnut parameters</param>
        /// <param name="unExplodedPoints">UnExploded dataPoints</param>
        /// <param name="explodedPoints">Exploded dataPoints</param>
        /// <param name="labelLinePath">Label line path</param>
        /// <param name="enabledDataPoints">List of enabled dataPoints</param>
        /// <returns>List of Shape</returns>
        private static List<Shape> GetDoughnut3D(DataSeries currentDataSeries, ref Faces faces, SectorChartShapeParams doughnutParams, ref PieDoughnut3DPoints unExplodedPoints, ref PieDoughnut3DPoints explodedPoints, ref Path labelLinePath, List<DataPoint> enabledDataPoints)
        {
            List<Shape> pieFaces = new List<Shape>();
            Shape topFace = null, bottomFace = null, rightFace = null, leftFace = null;

            // calculate 3d offsets
            Double yOffset = -doughnutParams.Depth / 2 * doughnutParams.ZAxisScaling;
            Point center = new Point();
            center.X += doughnutParams.Width / 2;
            center.Y += doughnutParams.Height / 2;

            // calculate all points
            Point3D topFaceCenter = new Point3D();
            topFaceCenter.X = center.X;
            topFaceCenter.Y = center.Y + yOffset;
            topFaceCenter.Z = doughnutParams.OffsetY * Math.Sin(doughnutParams.StartAngle) * Math.Cos(doughnutParams.TiltAngle) + doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D topOuterArcStart = new Point3D();
            topOuterArcStart.X = topFaceCenter.X + doughnutParams.OuterRadius * Math.Cos(doughnutParams.StartAngle);
            topOuterArcStart.Y = topFaceCenter.Y + doughnutParams.OuterRadius * Math.Sin(doughnutParams.StartAngle) * doughnutParams.YAxisScaling;
            topOuterArcStart.Z = (topFaceCenter.Y + doughnutParams.OuterRadius) * Math.Sin(doughnutParams.StartAngle) * Math.Cos(doughnutParams.TiltAngle) + doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D topOuterArcStop = new Point3D();
            topOuterArcStop.X = topFaceCenter.X + doughnutParams.OuterRadius * Math.Cos(doughnutParams.StopAngle);
            topOuterArcStop.Y = topFaceCenter.Y + doughnutParams.OuterRadius * Math.Sin(doughnutParams.StopAngle) * doughnutParams.YAxisScaling;
            topOuterArcStop.Z = (topFaceCenter.Y + doughnutParams.OuterRadius) * Math.Sin(doughnutParams.StopAngle) * Math.Cos(doughnutParams.TiltAngle) + doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D topInnerArcStart = new Point3D();
            topInnerArcStart.X = topFaceCenter.X + doughnutParams.InnerRadius * Math.Cos(doughnutParams.StartAngle);
            topInnerArcStart.Y = topFaceCenter.Y + doughnutParams.InnerRadius * Math.Sin(doughnutParams.StartAngle) * doughnutParams.YAxisScaling;
            topInnerArcStart.Z = (topFaceCenter.Y + doughnutParams.InnerRadius) * Math.Sin(doughnutParams.StartAngle) * Math.Cos(doughnutParams.TiltAngle) + doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D topInnerArcStop = new Point3D();
            topInnerArcStop.X = topFaceCenter.X + doughnutParams.InnerRadius * Math.Cos(doughnutParams.StopAngle);
            topInnerArcStop.Y = topFaceCenter.Y + doughnutParams.InnerRadius * Math.Sin(doughnutParams.StopAngle) * doughnutParams.YAxisScaling;
            topInnerArcStop.Z = (topFaceCenter.Y + doughnutParams.InnerRadius) * Math.Sin(doughnutParams.StopAngle) * Math.Cos(doughnutParams.TiltAngle) + doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D bottomFaceCenter = new Point3D();
            bottomFaceCenter.X = center.X;
            bottomFaceCenter.Y = center.Y - yOffset;
            bottomFaceCenter.Z = doughnutParams.OffsetY * Math.Sin(doughnutParams.StartAngle) * Math.Cos(doughnutParams.TiltAngle) - doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D bottomOuterArcStart = new Point3D();
            bottomOuterArcStart.X = bottomFaceCenter.X + doughnutParams.OuterRadius * Math.Cos(doughnutParams.StartAngle);
            bottomOuterArcStart.Y = bottomFaceCenter.Y + doughnutParams.OuterRadius * Math.Sin(doughnutParams.StartAngle) * doughnutParams.YAxisScaling;
            bottomOuterArcStart.Z = (bottomFaceCenter.Y + doughnutParams.OuterRadius) * Math.Sin(doughnutParams.StartAngle) * Math.Cos(doughnutParams.TiltAngle) - doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D bottomOuterArcStop = new Point3D();
            bottomOuterArcStop.X = bottomFaceCenter.X + doughnutParams.OuterRadius * Math.Cos(doughnutParams.StopAngle);
            bottomOuterArcStop.Y = bottomFaceCenter.Y + doughnutParams.OuterRadius * Math.Sin(doughnutParams.StopAngle) * doughnutParams.YAxisScaling;
            bottomOuterArcStop.Z = (bottomFaceCenter.Y + doughnutParams.OuterRadius) * Math.Sin(doughnutParams.StopAngle) * Math.Cos(doughnutParams.TiltAngle) - doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D bottomInnerArcStart = new Point3D();
            bottomInnerArcStart.X = bottomFaceCenter.X + doughnutParams.InnerRadius * Math.Cos(doughnutParams.StartAngle);
            bottomInnerArcStart.Y = bottomFaceCenter.Y + doughnutParams.InnerRadius * Math.Sin(doughnutParams.StartAngle) * doughnutParams.YAxisScaling;
            bottomInnerArcStart.Z = (bottomFaceCenter.Y + doughnutParams.InnerRadius) * Math.Sin(doughnutParams.StartAngle) * Math.Cos(doughnutParams.TiltAngle) - doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D bottomInnerArcStop = new Point3D();
            bottomInnerArcStop.X = bottomFaceCenter.X + doughnutParams.InnerRadius * Math.Cos(doughnutParams.StopAngle);
            bottomInnerArcStop.Y = bottomFaceCenter.Y + doughnutParams.InnerRadius * Math.Sin(doughnutParams.StopAngle) * doughnutParams.YAxisScaling;
            bottomInnerArcStop.Z = (bottomFaceCenter.Y + doughnutParams.InnerRadius) * Math.Sin(doughnutParams.StopAngle) * Math.Cos(doughnutParams.TiltAngle) - doughnutParams.Depth * Math.Cos(Math.PI / 2 - doughnutParams.TiltAngle);

            Point3D centroid = GetCentroid(topInnerArcStart, topInnerArcStop, topOuterArcStart, topOuterArcStop, bottomInnerArcStart, bottomInnerArcStop, bottomOuterArcStart, bottomOuterArcStop);

            UpdatePositionLabelInsidePie(doughnutParams, yOffset);

            if (doughnutParams.StartAngle == doughnutParams.StopAngle && doughnutParams.IsLargerArc || enabledDataPoints.Count == 1)
            {
                // draw singleton pie here
                topFace = new Ellipse() { Tag = new ElementData() { Element = doughnutParams.TagReference } };
                // topFace.Fill = doughnutParams.Lighting ? Graphics.GetLightingEnabledBrush(doughnutParams.Background, "Radial", new Double[] { 0.99, 0.745 }) : doughnutParams.Background;
                topFace.Fill = doughnutParams.Lighting ? Graphics.GetLightingEnabledBrush(doughnutParams.Background, "Linear", new Double[] { 0.99, 0.854 }) : doughnutParams.Background;
                
                topFace.Width = 2 * doughnutParams.OuterRadius;
                topFace.Height = 2 * doughnutParams.OuterRadius * doughnutParams.YAxisScaling;
                topFace.SetValue(Canvas.LeftProperty, (Double)(doughnutParams.Center.X - topFace.Width / 2));
                topFace.SetValue(Canvas.TopProperty, (Double)(doughnutParams.Center.Y - topFace.Height / 2 + yOffset));

                GeometryGroup gg = new GeometryGroup();
                gg.Children.Add(new EllipseGeometry() { Center = new Point(topFace.Width / 2, topFace.Height / 2), RadiusX = topFace.Width, RadiusY = topFace.Height });
                gg.Children.Add(new EllipseGeometry() { Center = new Point(topFace.Width / 2, topFace.Height / 2), RadiusX = doughnutParams.InnerRadius, RadiusY = topFace.Height - 2 * (doughnutParams.OuterRadius - doughnutParams.InnerRadius) });

                topFace.Clip = gg;
                pieFaces.Add(topFace);
                faces.Parts.Add(topFace);

                bottomFace = new Ellipse() { Tag = new ElementData() { Element = doughnutParams.TagReference } };
                bottomFace.Fill = doughnutParams.Lighting ? Graphics.GetLightingEnabledBrush(doughnutParams.Background, "Radial", new Double[] { 0.99, 0.745 }) : doughnutParams.Background;
                // topFace.Stroke = pieParams.Lighting ? Graphics.GetLightingEnabledBrush(pieParams.Background, "Radial", new Double[] { 0.99, 0.745 }) : pieParams.Background;
                bottomFace.Width = 2 * doughnutParams.OuterRadius;
                bottomFace.Height = 2 * doughnutParams.OuterRadius * doughnutParams.YAxisScaling;
                bottomFace.SetValue(Canvas.LeftProperty, (Double)(doughnutParams.Center.X - topFace.Width / 2));
                bottomFace.SetValue(Canvas.TopProperty, (Double)(doughnutParams.Center.Y - topFace.Height / 2));

                gg = new GeometryGroup();
                gg.Children.Add(new EllipseGeometry() { Center = new Point(topFace.Width / 2, topFace.Height / 2), RadiusX = topFace.Width, RadiusY = topFace.Height });
                gg.Children.Add(new EllipseGeometry() { Center = new Point(topFace.Width / 2, topFace.Height / 2), RadiusX = doughnutParams.InnerRadius, RadiusY = topFace.Height - 2 * (doughnutParams.OuterRadius - doughnutParams.InnerRadius) });

                bottomFace.Clip = gg;
                pieFaces.Add(bottomFace);
                faces.Parts.Add(bottomFace);
            }
            else
            {
                topFace = GetDoughnutFace(doughnutParams, centroid, topInnerArcStart, topInnerArcStop, topOuterArcStart, topOuterArcStop, true);
                pieFaces.Add(topFace);
                faces.Parts.Add(topFace);

                bottomFace = GetDoughnutFace(doughnutParams, centroid, bottomInnerArcStart, bottomInnerArcStop, bottomOuterArcStart, bottomOuterArcStop, false);
                pieFaces.Add(bottomFace);
                faces.Parts.Add(bottomFace);

                rightFace = GetPieSide(doughnutParams, centroid, topInnerArcStart, bottomInnerArcStart, topOuterArcStart, bottomOuterArcStart);
                pieFaces.Add(rightFace);
                faces.Parts.Add(rightFace);

                leftFace = GetPieSide(doughnutParams, centroid, topInnerArcStop, bottomInnerArcStop, topOuterArcStop, bottomOuterArcStop);
                pieFaces.Add(leftFace);
                faces.Parts.Add(leftFace);
            }

            List<Shape> curvedSurface = GetDoughnutCurvedFace(doughnutParams, centroid, topFaceCenter, bottomFaceCenter);
            pieFaces.InsertRange(pieFaces.Count, curvedSurface);

            foreach (FrameworkElement fe in curvedSurface)
                faces.Parts.Add(fe);

            labelLinePath = CreateLabelLine(currentDataSeries, doughnutParams, center, ref unExplodedPoints, ref explodedPoints);

            if ((doughnutParams.TagReference as DataPoint).InternalYValue == 0)
                return new List<Shape>();

            //Top face ZIndex
            topFace.SetValue(Canvas.ZIndexProperty, (Int32)(50000));
            //BottomFace ZIndex
            bottomFace.SetValue(Canvas.ZIndexProperty, (Int32)(-50000));

            if (!(doughnutParams.StartAngle == doughnutParams.StopAngle && doughnutParams.IsLargerArc))
            {
                // ZIndex of curved face
                if (doughnutParams.StartAngle >= Math.PI && doughnutParams.StartAngle <= Math.PI * 2 && doughnutParams.StopAngle >= Math.PI && doughnutParams.StopAngle <= Math.PI * 2 && doughnutParams.IsLargerArc)
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, doughnutParams.StartAngle, doughnutParams.StartAngle));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[0], 0, Math.PI));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[1], doughnutParams.StartAngle, 0));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[2], Math.PI, doughnutParams.StopAngle));
                    _elementPositionData.Add(new ElementPositionData(leftFace, doughnutParams.StopAngle, doughnutParams.StopAngle));
                    if (labelLinePath != null)
                        _elementPositionData.Add(new ElementPositionData(labelLinePath, 0, Math.PI));
                }
                else if (doughnutParams.StartAngle >= 0 && doughnutParams.StartAngle <= Math.PI && doughnutParams.StopAngle >= 0 && doughnutParams.StopAngle <= Math.PI && doughnutParams.IsLargerArc)
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, doughnutParams.StartAngle, doughnutParams.StartAngle));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[0], doughnutParams.StartAngle, Math.PI));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[1], Math.PI * 2, doughnutParams.StopAngle));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[2], Math.PI, Math.PI * 2));
                    _elementPositionData.Add(new ElementPositionData(leftFace, doughnutParams.StopAngle, doughnutParams.StopAngle));
                    if (labelLinePath != null)
                        labelLinePath.SetValue(Canvas.ZIndexProperty, -50000);
                }
                else if (doughnutParams.StartAngle >= 0 && doughnutParams.StartAngle <= Math.PI && doughnutParams.StopAngle >= Math.PI && doughnutParams.StopAngle <= Math.PI * 2)
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, doughnutParams.StartAngle, doughnutParams.StartAngle));
                    if (labelLinePath != null)
                        _elementPositionData.Add(new ElementPositionData(labelLinePath, doughnutParams.StartAngle, Math.PI));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[0], doughnutParams.StartAngle, Math.PI));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[1], Math.PI, doughnutParams.StopAngle));
                    _elementPositionData.Add(new ElementPositionData(leftFace, doughnutParams.StopAngle, doughnutParams.StopAngle));
                }
                else if (doughnutParams.StartAngle >= Math.PI && doughnutParams.StartAngle <= Math.PI * 2 && doughnutParams.StopAngle >= 0 && doughnutParams.StopAngle <= Math.PI)
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, doughnutParams.StartAngle, doughnutParams.StartAngle));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[0], 0, doughnutParams.StopAngle));
                    _elementPositionData.Add(new ElementPositionData(curvedSurface[1], doughnutParams.StartAngle, 0));
                    _elementPositionData.Add(new ElementPositionData(leftFace, doughnutParams.StopAngle, doughnutParams.StopAngle));
                    if (labelLinePath != null)
                        _elementPositionData.Add(new ElementPositionData(labelLinePath, doughnutParams.StopAngle, doughnutParams.StopAngle));
                }
                else
                {
                    _elementPositionData.Add(new ElementPositionData(rightFace, doughnutParams.StartAngle, doughnutParams.StartAngle));
                    if (doughnutParams.StartAngle >= 0 && doughnutParams.StartAngle < Math.PI / 2 && doughnutParams.StopAngle >= 0 && doughnutParams.StopAngle < Math.PI / 2)
                    {
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, doughnutParams.StopAngle, doughnutParams.StopAngle));
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], doughnutParams.StartAngle, doughnutParams.StopAngle));
                    }
                    else if (doughnutParams.StartAngle >= 0 && doughnutParams.StartAngle < Math.PI / 2 && doughnutParams.StopAngle >= Math.PI / 2 && doughnutParams.StopAngle < Math.PI)
                    {
                        if (labelLinePath != null)
                            labelLinePath.SetValue(Canvas.ZIndexProperty, 40000);
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], doughnutParams.StartAngle, doughnutParams.StopAngle));
                    }
                    else if (doughnutParams.StartAngle >= Math.PI / 2 && doughnutParams.StartAngle < Math.PI && doughnutParams.StopAngle >= Math.PI / 2 && doughnutParams.StopAngle < Math.PI)
                    {
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, doughnutParams.StartAngle, doughnutParams.StartAngle));
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], doughnutParams.StartAngle, doughnutParams.StopAngle));
                    }
                    else if (doughnutParams.StartAngle >= Math.PI && doughnutParams.StartAngle < Math.PI * 1.5 && doughnutParams.StopAngle >= Math.PI && doughnutParams.StopAngle < Math.PI * 1.5)
                    {
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], doughnutParams.StartAngle, doughnutParams.StopAngle));
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, doughnutParams.StartAngle, doughnutParams.StartAngle));
                    }
                    else if (doughnutParams.StartAngle >= Math.PI * 1.5 && doughnutParams.StartAngle < Math.PI * 2 && doughnutParams.StopAngle >= Math.PI * 1.5 && doughnutParams.StopAngle < Math.PI * 2)
                    {
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], doughnutParams.StartAngle, doughnutParams.StopAngle));
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, doughnutParams.StartAngle, doughnutParams.StopAngle));
                    }
                    else
                    {
                        if (labelLinePath != null)
                            _elementPositionData.Add(new ElementPositionData(labelLinePath, doughnutParams.StartAngle, doughnutParams.StartAngle));
                        _elementPositionData.Add(new ElementPositionData(curvedSurface[0], doughnutParams.StartAngle, doughnutParams.StopAngle));
                    }
                    _elementPositionData.Add(new ElementPositionData(leftFace, doughnutParams.StopAngle, doughnutParams.StopAngle));
                }
            }

            return pieFaces;
        }
Example #21
0
        /// <summary>
        /// Draw the provided hex map on the form's canvas
        /// </summary>
        private void DrawHexGrid(HexMap<SolidColorBrush> hexGrid)
        {
            const double strokeThickness = 1;

            foreach (var hex in hexGrid.Map)
            {
                var hexPath = new Path
                {
                    Data = hex.PathGeometry(),
                    Fill = hex.Value,
                    Stroke = new SolidColorBrush(Colors.Black),
                    StrokeThickness = strokeThickness
                };
                hexPath.SetValue(Canvas.LeftProperty, hex.X - (hexPath.Width / 2));
                hexPath.SetValue(Canvas.TopProperty, hex.Y - (hexPath.Height / 2));
                CenterCanvas.Children.Add(hexPath);
            }
        }
Example #22
0
        /// <summary>
        /// Returns a pie in a canvas
        /// </summary>
        /// <param name="faces">Pie faces</param>
        /// <param name="pieParams">Pie parameters</param>
        /// <param name="unExplodedPoints">UnExploded dataPoints</param>
        /// <param name="explodedPoints">Exploded dataPoints</param>
        /// <param name="labelLinePath">Label line path</param>
        /// <param name="enabledDataPoints">List of enabled dataPoints</param>
        /// <returns>Canvas</returns>
        private static Canvas GetPie2D(DataSeries currentDataSeries, ref Faces faces, SectorChartShapeParams pieParams, ref PieDoughnut2DPoints unExplodedPoints, ref PieDoughnut2DPoints explodedPoints, ref Path labelLinePath, List<DataPoint> enabledDataPoints)
        {
            var noOfNonZeroDataPoint = (from dp in enabledDataPoints where dp.InternalYValue != 0 select dp);

            Canvas visual = new Canvas();

            Double width = pieParams.OuterRadius * 2;
            Double height = pieParams.OuterRadius * 2;

            visual.Width = width;
            visual.Height = height;

            Point center = new Point(width / 2, height / 2);
            Double xOffset = pieParams.OuterRadius * pieParams.ExplodeRatio * Math.Cos(pieParams.MeanAngle);
            Double yOffset = pieParams.OuterRadius * pieParams.ExplodeRatio * Math.Sin(pieParams.MeanAngle);

            #region PieSlice

            if (pieParams.StartAngle != pieParams.StopAngle || !pieParams.IsZero)
            {
                Ellipse ellipse = new Ellipse() { Tag = new ElementData() { Element = pieParams.TagReference } };
                ellipse.Width = width;
                ellipse.Height = height;
                ellipse.Fill = pieParams.Lighting ? Graphics.GetLightingEnabledBrush(pieParams.Background, "Radial", new Double[] { 0.99, 0.745 }) : pieParams.Background;

                Point start = new Point();
                Point end = new Point();
                Point arcMidPoint = new Point();

                start.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.StartAngle);
                start.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.StartAngle);

                end.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.StopAngle);
                end.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.StopAngle);

                arcMidPoint.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.MeanAngle);
                arcMidPoint.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.MeanAngle);

                List<PathGeometryParams> clipPathGeometry = new List<PathGeometryParams>();
                clipPathGeometry.Add(new LineSegmentParams(start));
                clipPathGeometry.Add(new ArcSegmentParams(new Size(pieParams.OuterRadius, pieParams.OuterRadius), 0, ((pieParams.StopAngle - pieParams.StartAngle) > Math.PI) ? true : false, SweepDirection.Clockwise, pieParams.AnimationEnabled ? start : arcMidPoint));
                clipPathGeometry.Add(new ArcSegmentParams(new Size(pieParams.OuterRadius, pieParams.OuterRadius), 0, ((pieParams.StopAngle - pieParams.StartAngle) > Math.PI) ? true : false, SweepDirection.Clockwise, pieParams.AnimationEnabled ? start : end));
                clipPathGeometry.Add(new LineSegmentParams(center));
                ellipse.Clip = GetPathGeometryFromList(FillRule.Nonzero, center, clipPathGeometry, true);
                PathSegmentCollection segments = (ellipse.Clip as PathGeometry).Figures[0].Segments;

                // apply animation to the individual points that for the pie slice
                if (pieParams.AnimationEnabled)
                {
                    // apply animation to the points
                    pieParams.Storyboard = CreatePathSegmentAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, segments[1], center, pieParams.OuterRadius, currentDataSeries.InternalStartAngle, pieParams.MeanAngle);
                    pieParams.Storyboard = CreatePathSegmentAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, segments[2], center, pieParams.OuterRadius, currentDataSeries.InternalStartAngle, pieParams.StopAngle);
                    pieParams.Storyboard = CreatePathSegmentAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, segments[0], center, pieParams.OuterRadius, currentDataSeries.InternalStartAngle, pieParams.StartAngle);
                }

                faces.Parts.Add(ellipse);
                visual.Children.Add(ellipse);

                // set the un exploded points for interactivity
                unExplodedPoints.Center = center;
                unExplodedPoints.OuterArcStart = start;
                unExplodedPoints.OuterArcMid = arcMidPoint;
                unExplodedPoints.OuterArcEnd = end;

                // set the exploded points for interactivity
                explodedPoints.Center = new Point(center.X + xOffset, center.Y + yOffset);
                explodedPoints.OuterArcStart = new Point(start.X + xOffset, start.Y + yOffset);
                explodedPoints.OuterArcMid = new Point(arcMidPoint.X + xOffset, arcMidPoint.Y + yOffset);
                explodedPoints.OuterArcEnd = new Point(end.X + xOffset, end.Y + yOffset);

                if (enabledDataPoints.Count == 1 || noOfNonZeroDataPoint.Count() == 1)
                {
                    Ellipse borderEllipse = new Ellipse() { IsHitTestVisible = false, Height = ellipse.Height, Width = ellipse.Width };
                    borderEllipse.SetValue(Canvas.ZIndexProperty, (Int32)10000);
                    visual.Children.Add(borderEllipse);
                    faces.BorderElements.Add(borderEllipse);
                }
            }

            #endregion PieSlice

            #region Lighting

            if ((pieParams.TagReference as DataPoint).InternalYValue != 0 && pieParams.Lighting && (pieParams.StartAngle != pieParams.StopAngle || !pieParams.IsZero))
            {
                Ellipse lightingEllipse = new Ellipse() { Tag = new ElementData() { Element = pieParams.TagReference } };
                lightingEllipse.Width = width;
                lightingEllipse.Height = height;
                lightingEllipse.IsHitTestVisible = false;
                lightingEllipse.Fill = GetPieGradianceBrush();

                Point start = new Point();
                Point end = new Point();
                Point arcMidPoint = new Point();

                start.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.StartAngle);
                start.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.StartAngle);

                end.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.StopAngle);
                end.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.StopAngle);

                arcMidPoint.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.MeanAngle);
                arcMidPoint.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.MeanAngle);

                List<PathGeometryParams> clipPathGeometry = new List<PathGeometryParams>();
                clipPathGeometry.Add(new LineSegmentParams(start));
                clipPathGeometry.Add(new ArcSegmentParams(new Size(pieParams.OuterRadius, pieParams.OuterRadius), 0, ((pieParams.StopAngle - pieParams.StartAngle) > Math.PI) ? true : false, SweepDirection.Clockwise, pieParams.AnimationEnabled ? start : arcMidPoint));
                clipPathGeometry.Add(new ArcSegmentParams(new Size(pieParams.OuterRadius, pieParams.OuterRadius), 0, ((pieParams.StopAngle - pieParams.StartAngle) > Math.PI) ? true : false, SweepDirection.Clockwise, pieParams.AnimationEnabled ? start : end));
                clipPathGeometry.Add(new LineSegmentParams(center));
                lightingEllipse.Clip = GetPathGeometryFromList(FillRule.Nonzero, center, clipPathGeometry, true);
                PathSegmentCollection segments = (lightingEllipse.Clip as PathGeometry).Figures[0].Segments;

                // apply animation to the individual points that for the shape that
                // gives the lighting effect to the pie slice
                if (pieParams.AnimationEnabled)
                {
                    // apply animation to the points
                    pieParams.Storyboard = CreatePathSegmentAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, segments[1], center, pieParams.OuterRadius, currentDataSeries.InternalStartAngle, pieParams.MeanAngle);
                    pieParams.Storyboard = CreatePathSegmentAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, segments[2], center, pieParams.OuterRadius, currentDataSeries.InternalStartAngle, pieParams.StopAngle);
                    pieParams.Storyboard = CreatePathSegmentAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, segments[0], center, pieParams.OuterRadius, currentDataSeries.InternalStartAngle, pieParams.StartAngle);
                }
                visual.Children.Add(lightingEllipse);
            }

            #endregion Lighting

            #region LabelLine

            if (pieParams.LabelLineEnabled)
            {
                Path labelLine = new Path() { Tag = new ElementData() { Element = pieParams.TagReference } };
                Double meanAngle = pieParams.MeanAngle;
                labelLine.SetValue(Canvas.ZIndexProperty, -100000);
                Point piePoint = new Point();
                piePoint.X = center.X + pieParams.OuterRadius * Math.Cos(meanAngle);
                piePoint.Y = center.Y + pieParams.OuterRadius * Math.Sin(meanAngle);

                Point labelPoint = new Point();
                labelPoint.X = center.X + pieParams.LabelPoint.X - pieParams.Width / 2;
                labelPoint.Y = center.Y + pieParams.LabelPoint.Y - pieParams.Height / 2;

                Point midPoint = new Point();
                // midPoint.X = (labelPoint.X < center.X) ? labelPoint.X + 10 : labelPoint.X - 10;
                if (pieParams.LabelLineTargetToRight)
                    midPoint.X = labelPoint.X + 10;
                else
                    midPoint.X = labelPoint.X - 10;

                midPoint.Y = labelPoint.Y;


                List<PathGeometryParams> labelLinePathGeometry = new List<PathGeometryParams>();
                labelLinePathGeometry.Add(new LineSegmentParams(pieParams.AnimationEnabled ? piePoint : midPoint));
                labelLinePathGeometry.Add(new LineSegmentParams(pieParams.AnimationEnabled ? piePoint : labelPoint));
                labelLine.Data = GetPathGeometryFromList(FillRule.Nonzero, piePoint, labelLinePathGeometry, true);
                PathFigure figure = (labelLine.Data as PathGeometry).Figures[0];
                PathSegmentCollection segments = figure.Segments;
                figure.IsClosed = false;
                figure.IsFilled = false;

                // animate the label lines of the individual pie slices
                if (pieParams.AnimationEnabled)
                {
                    pieParams.Storyboard = CreateLabelLineAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, segments[0], piePoint, midPoint);
                    pieParams.Storyboard = CreateLabelLineAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, segments[1], piePoint, midPoint, labelPoint);
                }

                labelLine.Stroke = pieParams.LabelLineColor;
                labelLine.StrokeDashArray = pieParams.LabelLineStyle;
                labelLine.StrokeThickness = pieParams.LabelLineThickness;

                labelLinePath = labelLine;

                if ((pieParams.TagReference as DataPoint).InternalYValue == 0)
                {
                    Line zeroLine = new Line();
                    zeroLine.X1 = center.X;
                    zeroLine.Y1 = center.Y;

                    zeroLine.X2 = piePoint.X;
                    zeroLine.Y2 = piePoint.Y;
                    zeroLine.Stroke = pieParams.LabelLineColor;
                    zeroLine.StrokeThickness = 0.25;
                    zeroLine.IsHitTestVisible = false;
                    visual.Children.Add(zeroLine);

                    if (pieParams.AnimationEnabled)
                    {
                        pieParams.Storyboard = CreateOpacityAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, zeroLine, 2, zeroLine.Opacity, 0.5);
                        zeroLine.Opacity = 0;
                    }
                }

                visual.Children.Add(labelLine);

                // set the un exploded points for interactivity
                unExplodedPoints.LabelLineEndPoint = labelPoint;
                unExplodedPoints.LabelLineMidPoint = midPoint;
                unExplodedPoints.LabelLineStartPoint = piePoint;

                // set the exploded points for interactivity
                explodedPoints.LabelLineEndPoint = new Point(labelPoint.X, labelPoint.Y - yOffset);
                explodedPoints.LabelLineMidPoint = new Point(midPoint.X, midPoint.Y - yOffset);
                explodedPoints.LabelLineStartPoint = new Point(piePoint.X + xOffset, piePoint.Y + yOffset);

                if ((pieParams.TagReference as DataPoint).InternalYValue == 0)
                    labelLine.IsHitTestVisible = false;
            }

            #endregion LabelLine

            #region Create path for selecting a pie section

            Point startPoint = new Point();
            Point endPoint = new Point();

            startPoint.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.StartAngle);
            startPoint.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.StartAngle);

            endPoint.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.StopAngle);
            endPoint.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.StopAngle);

            List<PathGeometryParams> pathGeometry = new List<PathGeometryParams>();
            pathGeometry.Add(new LineSegmentParams(center));
            pathGeometry.Add(new LineSegmentParams(startPoint));
            pathGeometry.Add(new ArcSegmentParams(new Size(pieParams.OuterRadius, pieParams.OuterRadius), 0, pieParams.IsLargerArc, SweepDirection.Clockwise, endPoint));

            if ((pieParams.TagReference as DataPoint).InternalYValue != 0)
            {
                Path p = new Path() { IsHitTestVisible = false };
                p.SetValue(Canvas.ZIndexProperty, (Int32)10000);
                p.Data = GetPathGeometryFromList(FillRule.Nonzero, center, pathGeometry, true);
                visual.Children.Add(p);
                faces.BorderElements.Add(p);
            }
            #endregion

            #region Bevel

            if (pieParams.Bevel && Math.Abs(pieParams.StartAngle - pieParams.StopAngle) > 0.03 && (pieParams.StartAngle != pieParams.StopAngle))
            {
                //Point startPoint = new Point();
                //Point endPoint = new Point();

                //startPoint.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.StartAngle);
                //startPoint.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.StartAngle);

                //endPoint.X = center.X + pieParams.OuterRadius * Math.Cos(pieParams.StopAngle);
                //endPoint.Y = center.Y + pieParams.OuterRadius * Math.Sin(pieParams.StopAngle);

                Point bevelCenter = new Point();
                Point bevelStart = new Point();
                Point bevelEnd = new Point();
                Double bevelLength = 4;
                Double bevelOuterRadius = Math.Abs(pieParams.OuterRadius - bevelLength);

                bevelCenter.X = center.X + bevelLength * Math.Cos(pieParams.MeanAngle);
                bevelCenter.Y = center.Y + bevelLength * Math.Sin(pieParams.MeanAngle);

                bevelStart.X = center.X + bevelOuterRadius * Math.Cos(pieParams.StartAngle + 0.03);
                bevelStart.Y = center.Y + bevelOuterRadius * Math.Sin(pieParams.StartAngle + 0.03);

                bevelEnd.X = center.X + bevelOuterRadius * Math.Cos(pieParams.StopAngle - 0.03);
                bevelEnd.Y = center.Y + bevelOuterRadius * Math.Sin(pieParams.StopAngle - 0.03);

                pathGeometry = new List<PathGeometryParams>();
                pathGeometry.Add(new LineSegmentParams(center));
                pathGeometry.Add(new LineSegmentParams(startPoint));
                pathGeometry.Add(new LineSegmentParams(bevelStart));
                pathGeometry.Add(new LineSegmentParams(bevelCenter));

                Path path = new Path() { Tag = new ElementData() { Element = pieParams.TagReference } };

                path.Data = GetPathGeometryFromList(FillRule.Nonzero, bevelCenter, pathGeometry, true);

                if (pieParams.StartAngle > Math.PI * 0.5 && pieParams.StartAngle <= Math.PI * 1.5)
                {
                    path.Fill = GetDarkerBevelBrush(pieParams.Background, pieParams.StartAngle * 180 / Math.PI + 135);
                }
                else
                {
                    path.Fill = GetLighterBevelBrush(pieParams.Background, -pieParams.StartAngle * 180 / Math.PI);
                }

                // Apply animation to the beveling path
                if (pieParams.AnimationEnabled)
                {
                    pieParams.Storyboard = CreateOpacityAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, path, 1, 1, 1);
                    path.Opacity = 0;
                }

                faces.Parts.Add(path);
                visual.Children.Add(path);

                pathGeometry = new List<PathGeometryParams>();
                pathGeometry.Add(new LineSegmentParams(center));
                pathGeometry.Add(new LineSegmentParams(endPoint));
                pathGeometry.Add(new LineSegmentParams(bevelEnd));
                pathGeometry.Add(new LineSegmentParams(bevelCenter));

                path = new Path() { Tag = new ElementData() { Element = pieParams.TagReference } };
                path.Data = GetPathGeometryFromList(FillRule.Nonzero, bevelCenter, pathGeometry, true);
                if (pieParams.StopAngle > Math.PI * 0.5 && pieParams.StopAngle <= Math.PI * 1.5)
                {
                    path.Fill = GetLighterBevelBrush(pieParams.Background, pieParams.StopAngle * 180 / Math.PI + 135);
                }
                else
                {
                    path.Fill = GetDarkerBevelBrush(pieParams.Background, -pieParams.StopAngle * 180 / Math.PI);
                }

                // Apply animation to the beveling path
                if (pieParams.AnimationEnabled)
                {
                    pieParams.Storyboard = CreateOpacityAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, path, 1, 1, 1);
                    path.Opacity = 0;
                }

                faces.Parts.Add(path);
                visual.Children.Add(path);

                #region "Outer Bevel"
                Shape outerBevel;

                if (enabledDataPoints.Count == 1 || noOfNonZeroDataPoint.Count() == 1)
                {
                    outerBevel = new Ellipse() { Height = pieParams.OuterRadius * 2, Width = pieParams.OuterRadius * 2, Tag = new ElementData() { Element = pieParams.TagReference } };
                    GeometryGroup gg = new GeometryGroup();
                    gg.Children.Add(new EllipseGeometry() { Center = new Point(pieParams.OuterRadius, pieParams.OuterRadius), RadiusX = pieParams.OuterRadius, RadiusY = pieParams.OuterRadius });
                    gg.Children.Add(new EllipseGeometry() { Center = new Point(pieParams.OuterRadius, pieParams.OuterRadius), RadiusX = bevelOuterRadius, RadiusY = bevelOuterRadius });
                    outerBevel.Clip = gg;
                }
                else
                {
                    pathGeometry = new List<PathGeometryParams>();
                    pathGeometry.Add(new LineSegmentParams(endPoint));
                    pathGeometry.Add(new ArcSegmentParams(new Size(pieParams.OuterRadius, pieParams.OuterRadius), 0, pieParams.IsLargerArc, SweepDirection.Counterclockwise, startPoint));
                    pathGeometry.Add(new LineSegmentParams(bevelStart));
                    pathGeometry.Add(new ArcSegmentParams(new Size(bevelOuterRadius, bevelOuterRadius), 0, pieParams.IsLargerArc, SweepDirection.Clockwise, bevelEnd));

                    outerBevel = new Path() { Tag = new ElementData() { Element = pieParams.TagReference } };
                    (outerBevel as Path).Data = GetPathGeometryFromList(FillRule.Nonzero, bevelEnd, pathGeometry, true);
                }

                if (pieParams.MeanAngle > 0 && pieParams.MeanAngle < Math.PI)
                {
                    outerBevel.Fill = GetCurvedBevelBrush(pieParams.Background, pieParams.MeanAngle * 180 / Math.PI + 90, Graphics.GenerateDoubleCollection(-0.745, -0.85), Graphics.GenerateDoubleCollection(0, 1));
                }
                else
                {
                    outerBevel.Fill = GetCurvedBevelBrush(pieParams.Background, pieParams.MeanAngle * 180 / Math.PI + 90, Graphics.GenerateDoubleCollection(0.745, -0.99), Graphics.GenerateDoubleCollection(0, 1));
                }

                // Apply animation to the beveling path
                if (pieParams.AnimationEnabled)
                {
                    pieParams.Storyboard = CreateOpacityAnimation(currentDataSeries, pieParams.DataPoint, pieParams.Storyboard, outerBevel, 1, 1, 1);
                    outerBevel.Opacity = 0;
                }


                #endregion
                faces.Parts.Add(outerBevel);
                visual.Children.Add(outerBevel);
            }
            else
            {
                faces.Parts.Add(null);
                faces.Parts.Add(null);
                faces.Parts.Add(null);
            }

            #endregion LabelLine

            return visual;
        }
        /// <summary>
        /// Draws the Ruler
        /// </summary>
        /// <param name="g"></param>
        /// <param name="rect"></param>
        /// <param name="cX"></param>
        /// <param name="cY"></param>
        private void DrawCalibration()
        {
            if (m_MeterSize <= 0)
                return;

            int noOfParts = this.m_DivisionsCount + 1;
            int noOfIntermediates = this.m_SubDivisionsCount;
            double currentAngle_rad = GetRadian(m_FromAngle);
            double currentAngle = m_FromAngle;

            // отступ от края
            double offset = outerSize * 4;
            // Длина риски для основного значения
            double division_length = m_MeterSize / 40;
            // Внешний радиус для риски
            double division_outer_radius = m_MeterSize / 2 - offset;

            // Сектор в котором отображаются значения
            double totalAngle = m_ToAngle - m_FromAngle;
            // Угол между соседними рисками (основными или промежуточными)
            double incr = ((totalAngle) / ((noOfParts - 1) * (noOfIntermediates + 1)));
            double incr_rad = GetRadian(((totalAngle) / ((noOfParts - 1) * (noOfIntermediates + 1))));

            Brush divisionsBrush = new SolidColorBrush(Colors.Black);
            Brush subdivisionsBrush = new SolidColorBrush(Colors.Black);

            double rulerValue = m_MinValue;

            // Центр спидометра
            double cX = m_MeterSize / 2;
            double cY = m_MeterSize / 2;
            Point center = new Point(cX, cY);

            if (m_LowValue != double.MinValue && m_HeightValue != double.MinValue && m_LowValue <= m_HeightValue)
            {
                // Толщина линий
                double line_size = offset;
                // Внешний радиус для рисок - Смещаем риски ближе к центру
                division_outer_radius -= offset/2;
                // Дуги для допустимых значений
                double arc_radius = division_outer_radius;

                SolidColorBrush lowBrush;
                SolidColorBrush hiBrush;
                SolidColorBrush midBrush;
                // Дуга от MinValue до LoValue 
                if (this.m_LowToHigh)
                {
                    lowBrush = new SolidColorBrush(m_BadColor);
                    hiBrush = new SolidColorBrush(m_GoodColor);
                }
                else
                {
                    lowBrush = new SolidColorBrush(m_GoodColor);
                    hiBrush = new SolidColorBrush(m_BadColor);
                }
                midBrush = new SolidColorBrush(m_MiddleColor);

                // Дуга между минимумом и нижним значением
                Path low_path = new Path();
                low_path.StrokeThickness = line_size;
                low_path.Stroke = lowBrush;
                PathGeometry low_geometry = new PathGeometry();
                low_path.Data = low_geometry;
                PathFigure low_Figure = new PathFigure();
                low_Figure.StartPoint = CalculateRotation(center, GetAngleByValue(m_MinValue), arc_radius);
                low_geometry.Figures.Add(low_Figure);

                ArcSegment low_arc = new ArcSegment();
                double low_angle = GetAngleByValue(m_LowValue);
                low_arc.Point = CalculateRotation(center, low_angle, arc_radius);
                low_arc.Size = new Size(arc_radius, arc_radius);
                low_arc.SweepDirection = SweepDirection.Clockwise;
                low_arc.IsLargeArc = (low_angle - m_FromAngle) > 180;
                low_Figure.Segments.Add(low_arc);

                // Дуга между нижним значением и верхним значением
                Path mid_path = new Path();
                mid_path.StrokeThickness = line_size;
                mid_path.Stroke = midBrush;
                PathGeometry mid_geometry = new PathGeometry();
                mid_path.Data = mid_geometry;
                PathFigure mid_Figure = new PathFigure();
                mid_Figure.StartPoint = low_arc.Point;
                mid_geometry.Figures.Add(mid_Figure);

                ArcSegment mid_arc = new ArcSegment();
                double hi_angle = GetAngleByValue(m_HeightValue);
                mid_arc.Point = CalculateRotation(center, hi_angle, arc_radius);
                mid_arc.Size = new Size(arc_radius, arc_radius);
                mid_arc.SweepDirection = SweepDirection.Clockwise;
                mid_arc.IsLargeArc = (hi_angle - low_angle) > 180;
                mid_Figure.Segments.Add(mid_arc);

                // Дуга между верхним значением и максимумом
                Path hi_path = new Path();
                hi_path.StrokeThickness = line_size;
                hi_path.Stroke = hiBrush;
                PathGeometry hi_geometry = new PathGeometry();
                hi_path.Data = hi_geometry;
                PathFigure hi_Figure = new PathFigure();
                hi_Figure.StartPoint = mid_arc.Point;
                hi_geometry.Figures.Add(hi_Figure);

                ArcSegment hi_arc = new ArcSegment();
                hi_arc.Point = CalculateRotation(center, m_ToAngle, arc_radius);
                hi_arc.Size = new Size(arc_radius, arc_radius);
                hi_arc.SweepDirection = SweepDirection.Clockwise;
                hi_arc.IsLargeArc = (m_ToAngle - hi_angle) > 180;
                hi_Figure.Segments.Add(hi_arc);

                low_path.SetValue(Canvas.TopProperty, m_MeterTop);
                low_path.SetValue(Canvas.LeftProperty, m_MeterLeft);
                mid_path.SetValue(Canvas.TopProperty, m_MeterTop);
                mid_path.SetValue(Canvas.LeftProperty, m_MeterLeft);
                hi_path.SetValue(Canvas.TopProperty, m_MeterTop);
                hi_path.SetValue(Canvas.LeftProperty, m_MeterLeft);
                low_path.Effect = new System.Windows.Media.Effects.BlurEffect();
                mid_path.Effect = new System.Windows.Media.Effects.BlurEffect();
                hi_path.Effect = new System.Windows.Media.Effects.BlurEffect();
                LayoutRoot.Children.Add(low_path);
                LayoutRoot.Children.Add(mid_path);
                LayoutRoot.Children.Add(hi_path);
            }

            // Внутренний радиус для риски
            double division_inner_radius = division_outer_radius - division_length;
            double angle = m_FromAngle;
            for (int i = 0; i < noOfParts; i++)
            {
                // Рисуем риску
                Border border = new Border();
                border.BorderThickness = new Thickness(2);
                border.BorderBrush = divisionsBrush;
                border.Width = division_outer_radius - division_inner_radius;
                border.Height = 2;
                border.SetValue(Canvas.TopProperty, m_MeterTop + cY + division_outer_radius * Math.Sin(currentAngle_rad));
                border.SetValue(Canvas.LeftProperty, m_MeterLeft + cX + division_outer_radius * Math.Cos(currentAngle_rad));
                border.RenderTransform = new RotateTransform() { Angle = currentAngle + 180};
                border.Effect = new System.Windows.Media.Effects.DropShadowEffect();
                LayoutRoot.Children.Add(border);

                //Line divisionLine = new Line();
                //divisionLine.Stroke = divisionsBrush;
                //divisionLine.StrokeThickness = 2;
                //divisionLine.X1 = (m_MeterLeft + cX + division_outer_radius * Math.Cos(currentAngle));
                //divisionLine.Y1 = (m_MeterTop + cY + division_outer_radius * Math.Sin(currentAngle));
                //divisionLine.X2 = (m_MeterLeft + cX + division_inner_radius * Math.Cos(currentAngle));
                //divisionLine.Y2 = (m_MeterTop + cY + division_inner_radius * Math.Sin(currentAngle));
                //divisionLine.Effect = new System.Windows.Media.Effects.DropShadowEffect();
                //LayoutRoot.Children.Add(divisionLine);

                // Рисуем значение
                double text_radius = division_inner_radius - m_MeterSize * 0.08;
                double tx = (cX + text_radius * Math.Cos(currentAngle_rad));
                double ty = (cY + text_radius * Math.Sin(currentAngle_rad));

                if (i > 0)
                    rulerValue += (double)((m_MaxValue - m_MinValue) / (noOfParts - 1));
                double value = Math.Round(rulerValue, 2);

                TextBlock valueText = new TextBlock();
                valueText.Foreground = new SolidColorBrush(m_ForeColor);
                valueText.FontSize = m_MeterSize * 0.05;
                String num = rulerValue.ToString(DivisionsFormatString);
                if (HidePercentageInDivisions)
                {
                    num = num.Replace("%", String.Empty);
                }
                valueText.Text = num;

                LayoutRoot.Children.Add(valueText);
                // Центрируем значение - чтобы центр текста попал в вычисленную координату
                if (valueText.ActualWidth.CompareTo(double.NaN) != 0)
                {
                    valueText.SetValue(Canvas.LeftProperty, m_MeterLeft + tx - valueText.ActualWidth / 2);
                }
                else
                {
                    valueText.SetValue(Canvas.LeftProperty, m_MeterLeft + tx);
                }
                if (valueText.ActualHeight.CompareTo(double.NaN) != 0)
                {
                    valueText.SetValue(Canvas.TopProperty, m_MeterTop + ty - valueText.ActualHeight / 2);
                }
                else
                {
                    valueText.SetValue(Canvas.TopProperty, m_MeterTop + ty);
                }

                currentAngle_rad += incr_rad;
                currentAngle += incr;

                if (i == noOfParts - 1)
                    break;

                // Длина риски для промежуточного значения
                double subdivision_length = division_length / 2;
                // Внешний и внутренний радиус для риски
                double subdivision_outer_radius = division_outer_radius;
                double subdivision_inner_radius = subdivision_outer_radius - subdivision_length;

                // Рисуем промежуточные значения
                for (int j = 0; j <= noOfIntermediates; j++)
                {
                    if (j != 0)
                    {
                        currentAngle_rad += incr_rad;
                        currentAngle += incr;
                    }
                    
                    // Рисуем риску
                    Border sub_border = new Border();
                    sub_border.BorderThickness = new Thickness(2);
                    sub_border.BorderBrush = divisionsBrush;
                    sub_border.Width = subdivision_outer_radius - subdivision_inner_radius;
                    sub_border.Height = 2;
                    sub_border.SetValue(Canvas.TopProperty, m_MeterTop + cY + subdivision_outer_radius * Math.Sin(currentAngle_rad));
                    sub_border.SetValue(Canvas.LeftProperty, m_MeterLeft + cX + subdivision_outer_radius * Math.Cos(currentAngle_rad));
                    sub_border.RenderTransform = new RotateTransform() { Angle = currentAngle + 180 };
                    sub_border.Effect = new System.Windows.Media.Effects.DropShadowEffect();
                    LayoutRoot.Children.Add(sub_border);
                    
                    //// Рисуем риску
                    //Line subivisionLine = new Line();
                    //subivisionLine.Stroke = subdivisionsBrush;
                    //subivisionLine.StrokeEndLineCap = PenLineCap.Flat;
                    //subivisionLine.StrokeThickness = 2;
                    //subivisionLine.X1 = (m_MeterLeft + cX + subdivision_outer_radius * Math.Cos(currentAngle));
                    //subivisionLine.Y1 = (m_MeterTop + cY + subdivision_outer_radius * Math.Sin(currentAngle));
                    //subivisionLine.X2 = (m_MeterLeft + cX + subdivision_inner_radius * Math.Cos(currentAngle));
                    //subivisionLine.Y2 = (m_MeterTop + cY + subdivision_inner_radius * Math.Sin(currentAngle));
                    //subivisionLine.Effect = new System.Windows.Media.Effects.DropShadowEffect();
                    //LayoutRoot.Children.Add(subivisionLine);
                }
            }
        }