Exemplo n.º 1
0
        /// <summary>
        /// Draw the shaded region as an approximated polygon and return the polygon
        /// The Zindex, Top, and Left attributes will also be set and the shading will be added to the drawing.
        /// </summary>
        /// <param name="drawing">The current drawing</param>
        /// <param name="shadingBrush">The brush to shade the region with</param>
        /// <returns>The graphical representation of the region.</returns>
        public UIElement Draw(Drawing drawing, Brush shadingBrush)
        {
            //Create the polygon with the correct physical points
            Shading = new System.Windows.Shapes.Polygon();
            SetPolygonPoints(Shading, drawing.CoordinateSystem);

            //Color the polygon
            Shading.Fill            = shadingBrush;
            Shading.Stroke          = new SolidColorBrush(Colors.DarkGray);
            Shading.StrokeThickness = 1;

            //Orient the polygon
            Canvas.SetTop(Shading, 0);
            Canvas.SetLeft(Shading, 0);
            Canvas.SetZIndex(Shading, (int)ZOrder.Shading);

            //Add to the drawing
            drawing.AddRegionShading(this);

            return(Shading);
        }