Ejemplo n.º 1
0
        public override void RenderElement(IRenderable element, Graphics graphics, Render render)
        {
            ComplexLine complex = element as ComplexLine;

            if (complex.Points == null)
            {
                return;
            }

            PointF  location;
            PointF  reference;
            Segment segment = null;

            //Save the current region
            Region current = graphics.Clip;

            //Mask out each marker
            for (int i = 0; i < complex.Points.Count - 1; i++)
            {
                location  = (PointF)complex.Points[i];
                reference = (PointF)complex.Points[i + 1];

                segment = complex.Segments[i];

                //Mask out the start marker
                if (segment.Start.Marker != null && !segment.Start.Marker.DrawBackground)
                {
                    Region region = new Region(segment.Start.Marker.GetPath());
                    region.Transform(Link.GetMarkerTransform(segment.Start.Marker, location, reference, new Matrix()));
                    graphics.SetClip(region, CombineMode.Exclude);
                }
            }

            //Mask out final marker
            if (segment.End.Marker != null && !segment.End.Marker.DrawBackground)
            {
                location  = (PointF)complex.Points[complex.Points.Count - 1];
                reference = (PointF)complex.Points[complex.Points.Count - 2];

                Region region = new Region(segment.End.Marker.GetPath());
                region.Transform(Link.GetMarkerTransform(segment.End.Marker, location, reference, new Matrix()));
                graphics.SetClip(region, CombineMode.Exclude);
            }

            //Draw the path
            Pen pen = null;

            if (complex.CustomPen == null)
            {
                pen           = new Pen(complex.BorderColor, complex.BorderWidth);
                pen.DashStyle = complex.BorderStyle;

                //Check if winforms renderer and ajdust color as required
                pen.Color = render.AdjustColor(complex.BorderColor, complex.BorderWidth, complex.Opacity);
            }
            else
            {
                pen = complex.CustomPen;
            }
            graphics.DrawPath(pen, complex.GetPath());

            //Reset the clip
            graphics.Clip = current;

            //Render the segment items
            for (int i = 0; i < complex.Points.Count - 1; i++)
            {
                segment   = complex.Segments[i];
                location  = (PointF)complex.Points[i];
                reference = (PointF)complex.Points[i + 1];

                if (segment.Start.Marker != null)
                {
                    RenderMarker(segment.Start.Marker, location, reference, graphics, render);
                }

                //Render the segment image and annotation
                RenderSegment(complex, segment, location, reference, graphics, render);
            }

            //Render final marker
            if (segment.End.Marker != null)
            {
                location  = (PointF)complex.Points[complex.Points.Count - 1];
                reference = (PointF)complex.Points[complex.Points.Count - 2];
                RenderMarker(segment.End.Marker, location, reference, graphics, render);
            }
        }
Ejemplo n.º 2
0
        public override void RenderShadow(IRenderable element, Graphics graphics, Render render)
        {
            ComplexLine complex = element as ComplexLine;

            if (complex.Points == null)
            {
                return;
            }

            PointF  location;
            PointF  reference;
            Segment segment = null;

            Layer        layer      = complex.Layer;
            Pen          shadowPen  = new Pen(layer.ShadowColor);
            GraphicsPath shadowPath = complex.GetPath();

            shadowPen.Color = render.AdjustColor(layer.ShadowColor, 0, complex.Opacity);

            //Save the current region
            Region current = graphics.Clip;

            //Mask out each marker
            for (int i = 0; i < complex.Points.Count - 1; i++)
            {
                location  = (PointF)complex.Points[i];
                reference = (PointF)complex.Points[i + 1];

                segment = complex.Segments[i];

                //Mask out the start marker
                if (segment.Start.Marker != null)
                {
                    Region region = new Region(segment.Start.Marker.GetPath());
                    region.Transform(Link.GetMarkerTransform(segment.Start.Marker, location, reference, new Matrix()));
                    region.Translate(layer.ShadowOffset.X, layer.ShadowOffset.Y);
                    graphics.SetClip(region, CombineMode.Exclude);
                }
            }

            //Mask out final marker
            if (segment.End.Marker != null)
            {
                location  = (PointF)complex.Points[complex.Points.Count - 1];
                reference = (PointF)complex.Points[complex.Points.Count - 2];

                Region region = new Region(segment.End.Marker.GetPath());
                region.Transform(Link.GetMarkerTransform(segment.End.Marker, location, reference, new Matrix()));
                region.Translate(layer.ShadowOffset.X, layer.ShadowOffset.Y);
                graphics.SetClip(region, CombineMode.Exclude);
            }

            //Draw the path
            graphics.TranslateTransform(layer.ShadowOffset.X, layer.ShadowOffset.Y);
            graphics.DrawPath(shadowPen, shadowPath);

            //Reset the clip
            graphics.Clip = current;

            //Render the markers
            for (int i = 0; i < complex.Points.Count - 1; i++)
            {
                segment   = complex.Segments[i];
                location  = (PointF)complex.Points[i];
                reference = (PointF)complex.Points[i + 1];

                if (segment.Start.Marker != null)
                {
                    RenderMarkerShadow(segment.Start.Marker, location, reference, graphics, render);
                }
            }

            //Render final marker
            if (segment.End.Marker != null)
            {
                location  = (PointF)complex.Points[complex.Points.Count - 1];
                reference = (PointF)complex.Points[complex.Points.Count - 2];
                RenderMarkerShadow(segment.End.Marker, location, reference, graphics, render);
            }

            graphics.TranslateTransform(-layer.ShadowOffset.X, -layer.ShadowOffset.Y);
        }
Ejemplo n.º 3
0
        public override void RenderAction(IRenderable element, Graphics graphics, ControlRender render)
        {
            ComplexLine complex = element as ComplexLine;

            if (complex.Points == null)
            {
                return;
            }

            PointF  location;
            PointF  reference;
            Segment segment = null;

            //Save the current region
            Region current = graphics.Clip;

            //Mask out each marker
            for (int i = 0; i < complex.Points.Count - 1; i++)
            {
                location  = (PointF)complex.Points[i];
                reference = (PointF)complex.Points[i + 1];

                segment = complex.Segments[i];

                //Mask out the start marker
                if (segment.Start.Marker != null)
                {
                    Region region = new Region(segment.Start.Marker.GetPath());
                    region.Transform(Link.GetMarkerTransform(segment.Start.Marker, location, reference, new Matrix()));
                    graphics.SetClip(region, CombineMode.Exclude);
                }
            }

            //Mask out final marker
            if (segment.End.Marker != null)
            {
                location  = (PointF)complex.Points[complex.Points.Count - 1];
                reference = (PointF)complex.Points[complex.Points.Count - 2];

                Region region = new Region(segment.End.Marker.GetPath());
                region.Transform(Link.GetMarkerTransform(segment.End.Marker, location, reference, new Matrix()));
                graphics.SetClip(region, CombineMode.Exclude);
            }

            //Draw the path
            GraphicsPath path = complex.GetPath();

            if (path == null)
            {
                return;
            }

            if (render.ActionStyle == ActionStyle.Default)
            {
                Pen pen = new Pen(render.AdjustColor(complex.BorderColor, complex.BorderWidth, complex.Opacity));
                pen.Width = complex.BorderWidth;
                graphics.DrawPath(pen, path);
            }
            else
            {
                graphics.DrawPath(Singleton.Instance.ActionPen, path);
            }

            //Reset the clip
            graphics.Clip = current;

            //Render the markers
            for (int i = 0; i < complex.Points.Count - 1; i++)
            {
                segment   = complex.Segments[i];
                location  = (PointF)complex.Points[i];
                reference = (PointF)complex.Points[i + 1];

                if (segment.Start.Marker != null)
                {
                    RenderMarkerAction(segment.Start.Marker, location, reference, graphics, render);
                }
            }

            //Render final marker
            if (segment.End.Marker != null)
            {
                location  = (PointF)complex.Points[complex.Points.Count - 1];
                reference = (PointF)complex.Points[complex.Points.Count - 2];
                RenderMarkerAction(segment.End.Marker, location, reference, graphics, render);
            }
        }