Beispiel #1
0
        private void DrawStraight(Graphics canvas, IImageToViewportTransformer transformer, Pen penEdges, Point start, Point end)
        {
            if (styleHelper.LineShape == LineShape.Squiggle)
            {
                canvas.DrawSquigglyLine(penEdges, start, end);
            }
            else if (styleHelper.LineShape == LineShape.Dash)
            {
                penEdges.DashStyle = DashStyle.Dash;
                canvas.DrawLine(penEdges, start, end);
            }
            else
            {
                canvas.DrawLine(penEdges, start, end);
            }

            labelMeasure.SetAttach(GetMiddlePoint(), true);

            if (styleHelper.LineEnding == LineEnding.StartArrow || styleHelper.LineEnding == LineEnding.DoubleArrow)
            {
                ArrowHelper.Draw(canvas, penEdges, start, end);
            }

            if (styleHelper.LineEnding == LineEnding.EndArrow || styleHelper.LineEnding == LineEnding.DoubleArrow)
            {
                ArrowHelper.Draw(canvas, penEdges, end, start);
            }
        }
Beispiel #2
0
        private void DrawDistorted(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, Pen penEdges, Brush brush, Point start, Point end)
        {
            List <PointF> curve            = distorter.DistortLine(points["a"], points["b"]);
            List <Point>  transformedCurve = transformer.Transform(curve);

            if (styleHelper.LineShape == LineShape.Squiggle)
            {
                canvas.DrawSquigglyLine(penEdges, start, end);
            }
            else if (styleHelper.LineShape == LineShape.Dash)
            {
                DashStyle oldDashStyle = penEdges.DashStyle;
                penEdges.DashStyle = DashStyle.Dash;
                canvas.DrawCurve(penEdges, transformedCurve.ToArray());
                penEdges.DashStyle = oldDashStyle;
            }
            else
            {
                canvas.DrawCurve(penEdges, transformedCurve.ToArray());
            }

            miniLabel.SetAttach(curve[curve.Count / 2], true);

            if (styleHelper.LineEnding == LineEnding.StartArrow || styleHelper.LineEnding == LineEnding.DoubleArrow)
            {
                ArrowHelper.Draw(canvas, penEdges, start, end);
            }

            if (styleHelper.LineEnding == LineEnding.EndArrow || styleHelper.LineEnding == LineEnding.DoubleArrow)
            {
                ArrowHelper.Draw(canvas, penEdges, end, start);
            }
        }
Beispiel #3
0
        public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp)
        {
            double opacity = infosFading.GetOpacityFactor(currentTimestamp);

            if (opacity <= 0)
            {
                return;
            }

            //int backgroundOpacity = editing ? 255 : 192;
            int backgroundOpacity = 255;

            using (SolidBrush brushBack = styleHelper.GetBackgroundBrush((int)(opacity * backgroundOpacity)))
                using (SolidBrush brushText = styleHelper.GetForegroundBrush((int)(opacity * 255)))
                    using (Pen pen = styleHelper.GetPen(backgroundOpacity))
                        using (Font fontText = styleHelper.GetFont((float)transformer.Scale))
                        {
                            SizeF textSize   = canvas.MeasureString(text, fontText);
                            Point bgLocation = transformer.Transform(background.Rectangle.Location);
                            Size  bgSize     = new Size((int)textSize.Width, (int)textSize.Height);

                            SizeF untransformed = transformer.Untransform(textSize);
                            background.Rectangle = new RectangleF(background.Rectangle.Location, untransformed);

                            Rectangle rect           = new Rectangle(bgLocation, bgSize);
                            int       roundingRadius = fontText.Height / 4;

                            if (showArrow)
                            {
                                pen.Color = brushBack.Color;
                                pen.Width = fontText.Height / 4;
                                Point arrowStartInScreen = rect.Center();
                                Point arrowEndInScreen   = transformer.Transform(arrowEnd);
                                canvas.DrawLine(pen, arrowStartInScreen, arrowEndInScreen);
                                ArrowHelper.Draw(canvas, pen, arrowEndInScreen, arrowStartInScreen);
                            }

                            RoundedRectangle.Draw(canvas, rect, brushBack, roundingRadius, false, false, null);

                            if (!editing)
                            {
                                canvas.DrawString(text, fontText, brushText, rect.Location);
                            }
                        }
        }
        private void DrawSegments(Pen penEdge, Color basePenEdgeColor, int alpha, Graphics canvas, IImageToViewportTransformer transformer, List <Point> points)
        {
            foreach (GenericPostureSegment segment in genericPosture.Segments)
            {
                if (!IsActive(segment.OptionGroup))
                {
                    continue;
                }

                penEdge.Width     = segment.Width;
                penEdge.DashStyle = Convert(segment.Style);
                penEdge.Color     = segment.Color == Color.Transparent ? basePenEdgeColor : Color.FromArgb(alpha, segment.Color);

                if (segment.ArrowBegin)
                {
                    penEdge.StartCap = LineCap.ArrowAnchor;
                }
                if (segment.ArrowEnd)
                {
                    penEdge.EndCap = LineCap.ArrowAnchor;
                }

                PointF start = segment.Start >= 0 ? points[segment.Start] : GetComputedPoint(segment.Start, transformer);
                PointF end   = segment.End >= 0 ? points[segment.End] : GetComputedPoint(segment.End, transformer);

                canvas.DrawLine(penEdge, start, end);

                if (segment.ArrowBegin)
                {
                    ArrowHelper.Draw(canvas, penEdge, start.ToPoint(), end.ToPoint());
                }

                if (segment.ArrowEnd)
                {
                    ArrowHelper.Draw(canvas, penEdge, end.ToPoint(), start.ToPoint());
                }
            }

            penEdge.Color    = basePenEdgeColor;
            penEdge.StartCap = LineCap.NoAnchor;
            penEdge.EndCap   = LineCap.NoAnchor;
        }
Beispiel #5
0
        public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp)
        {
            double opacityFactor = infosFading.GetOpacityFactor(currentTimestamp);

            if (tracking)
            {
                opacityFactor = 1.0;
            }

            if (opacityFactor <= 0)
            {
                return;
            }

            if (points.Count < 2)
            {
                return;
            }

            Point[] pointList = transformer.Transform(points.Values).ToArray();

            using (Pen penEdges = styleHelper.GetPen((int)(opacityFactor * 255), transformer.Scale))
            {
                PointF danglingStart;
                PointF danglingEnd;

                if (initializing)
                {
                    danglingStart = pointList[pointList.Length - 2];
                    danglingEnd   = pointList[pointList.Length - 1];

                    penEdges.DashStyle = DashStyle.Dot;
                    canvas.DrawLine(penEdges, danglingStart, danglingEnd);

                    if (pointList.Length > 2)
                    {
                        Point[] path = pointList.TakeWhile((p, i) => i <= pointList.Length - 2).ToArray();
                        DrawPath(canvas, penEdges, path);
                    }
                }
                else
                {
                    Point[] path = pointList.ToArray();
                    DrawPath(canvas, penEdges, path);
                }

                if (styleHelper.LineEnding == LineEnding.StartArrow || styleHelper.LineEnding == LineEnding.DoubleArrow)
                {
                    ArrowHelper.Draw(canvas, penEdges, pointList[0], pointList[1]);
                }

                if (styleHelper.LineEnding == LineEnding.EndArrow || styleHelper.LineEnding == LineEnding.DoubleArrow)
                {
                    ArrowHelper.Draw(canvas, penEdges, pointList[pointList.Length - 1], pointList[pointList.Length - 2]);
                }

                // Handlers
                if (selected)
                {
                    penEdges.Width = 2;
                    foreach (PointF p in pointList)
                    {
                        canvas.FillEllipse(penEdges.Brush, p.Box(3));
                    }
                }
            }
        }