コード例 #1
0
ファイル: AreaChart.cs プロジェクト: tdhieu/openvss
 /// <summary>
 /// Get area parameters
 /// </summary>
 /// <param name="series">DataSeries</param>
 /// <param name="colorBrush">color</param>
 /// <param name="depth3d">3D depth</param>
 /// <returns>PolygonalChartShapeParams</returns>
 private static PolygonalChartShapeParams GetAreaParms(DataSeries series, Brush colorBrush, Double depth3d)
 {
     PolygonalChartShapeParams areaParams = new PolygonalChartShapeParams();
     areaParams.Background = colorBrush;
     areaParams.Lighting = (Boolean)series.LightingEnabled;
     areaParams.Shadow = series.ShadowEnabled;
     areaParams.Bevel = series.Bevel;
     areaParams.BorderColor = series.BorderColor;
     areaParams.BorderStyle = ExtendedGraphics.GetDashArray(series.BorderStyle);
     areaParams.BorderThickness = series.BorderThickness.Left;
     areaParams.Depth3D = depth3d;
     areaParams.TagReference = series;
     return areaParams;
 }
コード例 #2
0
ファイル: AreaChart.cs プロジェクト: tdhieu/openvss
        /// <summary>
        /// Get Stacked3DArea front face
        /// </summary>
        /// <param name="faces">Faces</param>
        /// <param name="areaParams">Area parameters</param>
        /// <returns>Canvas</returns>
        internal static Canvas GetStacked3DAreaFrontFace(ref Faces faces, PolygonalChartShapeParams areaParams)
        {
            Polygon polygon = new Polygon() { Tag = new ElementData() { Element = areaParams.TagReference, VisualElementName = "AreaBase" } };

            faces.Parts.Add(polygon);
            Point centroid = GetCentroid(areaParams.Points);
            Rect size = GetBounds(areaParams.Points);

            polygon.SetValue(Canvas.ZIndexProperty, (Int32)centroid.Y + 1000);
            polygon.Fill = areaParams.Lighting ? Graphics.GetFrontFaceBrush(areaParams.Background) : areaParams.Background;

            polygon.Stroke = areaParams.BorderColor;
            polygon.StrokeDashArray = areaParams.BorderStyle != null ? ExtendedGraphics.CloneCollection(areaParams.BorderStyle) : areaParams.BorderStyle;
            polygon.StrokeThickness = areaParams.BorderThickness;
            polygon.StrokeMiterLimit = 1;

            polygon.Points = areaParams.Points;

            polygon.Stretch = Stretch.Fill;
            polygon.Width = size.Width;
            polygon.Height = size.Height;
            polygon.SetValue(Canvas.TopProperty, areaParams.Depth3D);
            polygon.SetValue(Canvas.LeftProperty, 0.0);

            Canvas polygonSet = new Canvas() { Tag = new ElementData() { Element = areaParams.TagReference } };
            polygonSet.Width = size.Width + areaParams.Depth3D;
            polygonSet.Height = size.Height + areaParams.Depth3D;
            polygonSet.SetValue(Canvas.TopProperty, size.Top - areaParams.Depth3D);
            polygonSet.SetValue(Canvas.LeftProperty, size.Left);

            polygonSet.Children.Add(polygon);

            return polygonSet;
        }
コード例 #3
0
ファイル: AreaChart.cs プロジェクト: tdhieu/openvss
        /// <summary>
        /// Get Stacked3D side faces
        /// </summary>
        /// <param name="faces">Faces</param>
        /// <param name="areaParams">Area parameters</param>
        /// <returns>Canvas</returns>
        private static Canvas GetStacked3DSideFaces(ref Faces faces, PolygonalChartShapeParams areaParams)
        {
            Point centroid;
            Brush sideBrush = areaParams.Lighting ? Graphics.GetRightFaceBrush(areaParams.Background) : areaParams.Background;
            Brush topBrush = areaParams.Lighting ? Graphics.GetTopFaceBrush(areaParams.Background) : areaParams.Background;
            Int32 pointIndexLimit = areaParams.IsPositive ? areaParams.Points.Count - 1 : areaParams.Points.Count;

            Canvas polygonSet = new Canvas();
            Rect size = GetBounds(areaParams.Points);
            polygonSet.Width = size.Width + areaParams.Depth3D;
            polygonSet.Height = size.Height + areaParams.Depth3D;
            polygonSet.SetValue(Canvas.TopProperty, size.Top - areaParams.Depth3D);
            polygonSet.SetValue(Canvas.LeftProperty, size.Left);

            for (Int32 i = 0; i < pointIndexLimit; i++)
            {
                Polygon sides = new Polygon() { Tag = new ElementData() { Element = areaParams.TagReference } };
                PointCollection points = new PointCollection();
                Int32 index1 = i % areaParams.Points.Count;
                Int32 index2 = (i + 1) % areaParams.Points.Count;

                points.Add(areaParams.Points[index1]);
                points.Add(areaParams.Points[index2]);
                points.Add(new Point(areaParams.Points[index2].X + areaParams.Depth3D, areaParams.Points[index2].Y - areaParams.Depth3D));
                points.Add(new Point(areaParams.Points[index1].X + areaParams.Depth3D, areaParams.Points[index1].Y - areaParams.Depth3D));
                sides.Points = points;

                centroid = GetCentroid(points);
                Int32 zindex = GetAreaZIndex(centroid.X, centroid.Y, areaParams.IsPositive);
                sides.SetValue(Canvas.ZIndexProperty, zindex);

                if (i == (areaParams.Points.Count - 2))
                {
                    sides.Fill = sideBrush;
                    (sides.Tag as ElementData).VisualElementName = "Side";
                }
                else
                {
                    sides.Fill = topBrush;
                    (sides.Tag as ElementData).VisualElementName = "Top";
                }

                sides.Stroke = areaParams.BorderColor;
                sides.StrokeDashArray = areaParams.BorderStyle != null ? ExtendedGraphics.CloneCollection(areaParams.BorderStyle) : areaParams.BorderStyle;
                sides.StrokeThickness = areaParams.BorderThickness;
                sides.StrokeMiterLimit = 1;

                Rect sidesBounds = GetBounds(points);
                sides.Stretch = Stretch.Fill;
                sides.Width = sidesBounds.Width;
                sides.Height = sidesBounds.Height;
                sides.SetValue(Canvas.TopProperty, sidesBounds.Y - (size.Top - areaParams.Depth3D));
                sides.SetValue(Canvas.LeftProperty, sidesBounds.X - size.X);

                faces.Parts.Add(sides);
                polygonSet.Children.Add(sides);

            }

            return polygonSet;
        }
コード例 #4
0
ファイル: AreaChart.cs プロジェクト: tdhieu/openvss
        /// <summary>
        /// Get visual for StackedArea 2D
        /// </summary>
        /// <param name="faces">Faces</param>
        /// <param name="areaParams">Area parameters</param>
        /// <returns>Canvas</returns>
        internal static Canvas GetStacked2DArea(ref Faces faces, PolygonalChartShapeParams areaParams)
        {
            if (faces.Parts == null)
                faces.Parts = new List<DependencyObject>();

            Canvas visual = new Canvas();

            visual.Width = areaParams.Size.Width;
            visual.Height = areaParams.Size.Height;

            Polygon polygon = new Polygon() { Tag = new ElementData() { Element = areaParams.TagReference, VisualElementName = "AreaBase" } };

            faces.Parts.Add(polygon);

            polygon.Fill = areaParams.Lighting ? Graphics.GetLightingEnabledBrush(areaParams.Background, "Linear", null) : areaParams.Background;

            polygon.Stroke = areaParams.BorderColor;
            polygon.StrokeDashArray = areaParams.BorderStyle != null ? ExtendedGraphics.CloneCollection(areaParams.BorderStyle) : areaParams.BorderStyle;
            polygon.StrokeThickness = areaParams.BorderThickness;
            polygon.StrokeMiterLimit = 1;

            polygon.Points = areaParams.Points;

            Rect polygonBounds = GetBounds(areaParams.Points);
            polygon.Stretch = Stretch.Fill;
            polygon.Width = polygonBounds.Width;
            polygon.Height = polygonBounds.Height;
            polygon.SetValue(Canvas.TopProperty, polygonBounds.Y);
            polygon.SetValue(Canvas.LeftProperty, polygonBounds.X);

            visual.Children.Add(polygon);

            if (areaParams.Bevel)
            {
                for (int i = 0; i < areaParams.Points.Count - 1; i++)
                {
                    if (areaParams.Points[i].X == areaParams.Points[i + 1].X)
                        continue;

                    Double m = GetSlope(areaParams.Points[i].X, areaParams.Points[i].Y, areaParams.Points[i + 1].X, areaParams.Points[i + 1].Y);
                    Double c = GetIntercept(areaParams.Points[i].X, areaParams.Points[i].Y, areaParams.Points[i + 1].X, areaParams.Points[i + 1].Y);
                    c = c + (areaParams.IsPositive ? 1 : -1) * 4;
                    Point newPt1 = new Point(areaParams.Points[i].X, m * areaParams.Points[i].X + c);
                    Point newPt2 = new Point(areaParams.Points[i + 1].X, m * areaParams.Points[i + 1].X + c);

                    PointCollection points = new PointCollection();
                    points.Add(areaParams.Points[i]);
                    points.Add(areaParams.Points[i + 1]);
                    points.Add(newPt2);
                    points.Add(newPt1);

                    Polygon bevel = new Polygon() { Tag = new ElementData() { Element = areaParams.TagReference, VisualElementName = "Bevel" } };
                    bevel.Points = points;
                    bevel.Fill = Graphics.GetBevelTopBrush(areaParams.Background);

                    faces.Parts.Add(bevel);
                    visual.Children.Add(bevel);
                }
            }

            return visual;
        }
コード例 #5
0
ファイル: AreaChart.cs プロジェクト: tdhieu/openvss
        /// <summary>
        /// Get visual of Area 3D
        /// </summary>
        /// <param name="faces">Faces</param>
        /// <param name="areaParams">AreaParams</param>
        /// <returns>Canvas</returns>
        internal static Canvas Get3DArea(DataSeries currentDataSeries,  ref Faces faces, PolygonalChartShapeParams areaParams)
        {
            Canvas visual = new Canvas();

            visual.Width = areaParams.Size.Width;
            visual.Height = areaParams.Size.Height;

            Point centroid;
            Brush sideBrush = areaParams.Lighting ? Graphics.GetRightFaceBrush(areaParams.Background) : areaParams.Background;
            Brush topBrush = areaParams.Lighting ? Graphics.GetTopFaceBrush(areaParams.Background) : areaParams.Background;
            Int32 pointIndexLimit = areaParams.IsPositive ? areaParams.Points.Count - 1 : areaParams.Points.Count;

            Canvas polygonSet = new Canvas();
            Rect size = GetBounds(areaParams.Points);
            polygonSet.Width = size.Width + areaParams.Depth3D;
            polygonSet.Height = size.Height + areaParams.Depth3D;
            polygonSet.SetValue(Canvas.TopProperty, size.Top - areaParams.Depth3D);
            polygonSet.SetValue(Canvas.LeftProperty, size.Left);
            visual.Children.Add(polygonSet);

            for (Int32 i = 0; i < pointIndexLimit; i++)
            {
                Polygon sides = new Polygon() { Tag = new ElementData() { Element = areaParams.TagReference } };
                PointCollection points = new PointCollection();
                Int32 index1 = i % areaParams.Points.Count;
                Int32 index2 = (i + 1) % areaParams.Points.Count;

                points.Add(areaParams.Points[index1]);
                points.Add(areaParams.Points[index2]);
                points.Add(new Point(areaParams.Points[index2].X + areaParams.Depth3D, areaParams.Points[index2].Y - areaParams.Depth3D));
                points.Add(new Point(areaParams.Points[index1].X + areaParams.Depth3D, areaParams.Points[index1].Y - areaParams.Depth3D));
                sides.Points = points;

                centroid = GetCentroid(points);
                Int32 zindex = GetAreaZIndex(centroid.X, centroid.Y, areaParams.IsPositive);
                sides.SetValue(Canvas.ZIndexProperty, zindex);

                if (i == (areaParams.Points.Count - 2))
                {
                    sides.Fill = sideBrush;
                    (sides.Tag as ElementData).VisualElementName = "Side";
                }
                else
                {
                    sides.Fill = topBrush;
                    (sides.Tag as ElementData).VisualElementName = "Top";
                }

                sides.Stroke = areaParams.BorderColor;
                sides.StrokeDashArray = areaParams.BorderStyle != null ? ExtendedGraphics.CloneCollection(areaParams.BorderStyle) : areaParams.BorderStyle;
                sides.StrokeThickness = areaParams.BorderThickness;
                sides.StrokeMiterLimit = 1;

                Rect sidesBounds = GetBounds(points);
                sides.Stretch = Stretch.Fill;
                sides.Width = sidesBounds.Width;
                sides.Height = sidesBounds.Height;
                sides.SetValue(Canvas.TopProperty, sidesBounds.Y - (size.Top - areaParams.Depth3D));
                sides.SetValue(Canvas.LeftProperty, sidesBounds.X - size.X);

                faces.Parts.Add(sides);
                polygonSet.Children.Add(sides);

            }

            Polygon polygon = new Polygon() { Tag = new ElementData() { Element = areaParams.TagReference, VisualElementName = "AreaBase" } };

            faces.Parts.Add(polygon);
            centroid = GetCentroid(areaParams.Points);

            polygon.SetValue(Canvas.ZIndexProperty, (Int32)centroid.Y + 1000);
            polygon.Fill = areaParams.Lighting ? Graphics.GetFrontFaceBrush(areaParams.Background) : areaParams.Background;

            polygon.Stroke = areaParams.BorderColor;
            polygon.StrokeDashArray = areaParams.BorderStyle != null ? ExtendedGraphics.CloneCollection(areaParams.BorderStyle) : areaParams.BorderStyle;
            polygon.StrokeThickness = areaParams.BorderThickness;
            polygon.StrokeMiterLimit = 1;

            polygon.Points = areaParams.Points;

            polygon.Stretch = Stretch.Fill;
            polygon.Width = size.Width;
            polygon.Height = size.Height;
            polygon.SetValue(Canvas.TopProperty, areaParams.Depth3D);
            polygon.SetValue(Canvas.LeftProperty, 0.0);

            // apply area animation
            if (areaParams.AnimationEnabled)
            {
                // apply animation to the entire canvas that was used to create the area
                areaParams.Storyboard = ApplyAreaAnimation(currentDataSeries, polygonSet, areaParams.Storyboard, areaParams.IsPositive, 0);

            }

            polygonSet.Children.Add(polygon);

            return visual;
        }