Esempio n. 1
0
        public bool NextDraw(Point pt, IDrawingContext dc, bool isFinal)
        {
            Points[1] = pt;

            double radius = Math.Atan((Points[1].X - Points[0].X) / (Points[0].Y - Points[1].Y));
            double degree = radius * 180 / Math.PI;

            if (degree < 0)
            {
                if (Points[1].X > Points[0].X)
                {
                    degree = 180 + degree;
                }
            }
            else
            {
                if (Points[1].X < Points[0].X)
                {
                    degree = 180 + degree;
                }
            }

            IPen pen = DrawingObjectFactory.CreatePen(MeasureColor, MeasureThickness);

            if (MeasureDashes != null)
            {
                pen.Dashes = MeasureDashes;
            }
            //Trace.WriteLine(radius + "," + degree);
            RotateTransform transferm = new RotateTransform()
            {
                Angle   = degree,
                CenterX = Points[0].X,
                CenterY = Points[0].Y
            };

            dc.PushTransform(transferm);
            Point pt1 = new Point(Points[0].X + 3, Points[0].Y);
            Point pt2 = new Point(Points[0].X - 3, Points[0].Y);

            dc.DrawLine(pen, pt1, pt2);

            double value = -Math.Sqrt(Math.Abs(Points[0].X - Points[1].X) * Math.Abs(Points[0].X - Points[1].X) + Math.Abs(Points[0].Y - Points[1].Y) * Math.Abs(Points[0].Y - Points[1].Y));
            Point  pt3   = new Point(Points[0].X, Points[0].Y + value);

            dc.DrawLine(pen, Points[0], pt3);

            pt1 = new Point(Points[0].X + 3, Points[0].Y + value);
            pt2 = new Point(Points[0].X - 3, Points[0].Y + value);
            dc.DrawLine(pen, pt1, pt2);

            dc.Pop();

            ITextFormat format = DrawingObjectFactory.CreateTextFormat(measureValue.ToString("P2"), FlowDirection, FontFamily, FontStyle, FontWeight, FontStretch, FontSize, Foreground);

            Point ptText = Points[1];

            ptText.Y -= format.Height;
            dc.DrawText(format, ptText);
            return(false);
        }
 private ITextFormat CreateDynamicScaleTextFormat(string text)
 {
     return(DrawingObjectFactory.CreateTextFormat(text,
                                                  FlowDirection, FontFamily, FontStyle, FontWeight, FontStretch, FontSize, Foreground));
 }