コード例 #1
0
        public static Stroke PositionsToCircle(Point startPoint, Point endPoint)
        {
            StylusPointCollection stp = new StylusPointCollection();

            stp.Add(new StylusPoint(startPoint.X, startPoint.Y));
            stp.Add(new StylusPoint(endPoint.X, endPoint.Y));
            return(InkTransformerHelper.StrokeToCircle(new Stroke(stp)));
        }
コード例 #2
0
        private void UpdateStart()
        {
            Rect        entityBoundingBox = this.SourceEntity.GetBounds(2);
            StylusPoint finalPoint        = new StylusPoint();


            Point SeCenter = new Point(
                entityBoundingBox.Left + entityBoundingBox.Width * 0.5,
                entityBoundingBox.Top + entityBoundingBox.Height * 0.5)
            ;

            Point TeCenter = new Point(this.Stroke.StylusPoints[this.Stroke.StylusPoints.Count - 1].X, this.Stroke.StylusPoints[this.Stroke.StylusPoints.Count - 1].Y);

            if (this.TargetEntity != null)
            {
                Rect targetEntityBoundingBox = this.TargetEntity.GetBounds(2);
                TeCenter = new Point(
                    targetEntityBoundingBox.Left + targetEntityBoundingBox.Width * 0.5,
                    targetEntityBoundingBox.Top + targetEntityBoundingBox.Height * 0.5)
                ;
            }

            int LR = 0;

            if ((SeCenter.X - TeCenter.X) < -(entityBoundingBox.Width * 0.8))
            {
                LR = 1;
            }
            else if ((SeCenter.X - TeCenter.X) > (entityBoundingBox.Width * 0.8))
            {
                LR = -1;
            }
            else
            {
                LR = 0;
            }

            int UD = 0;

            if ((SeCenter.Y - TeCenter.Y) < -(entityBoundingBox.Width * 0.8))
            {
                UD = -1;
            }
            else if ((SeCenter.Y - TeCenter.Y) > (entityBoundingBox.Width * 0.8))
            {
                UD = 1;
            }
            else
            {
                UD = 0;
            }

            if (LR == -1)
            {
                finalPoint.X = entityBoundingBox.Left - 2;
            }
            else if (LR == 1)
            {
                finalPoint.X = entityBoundingBox.Right + 2;
            }
            else if (LR == 0)
            {
                finalPoint.X = SeCenter.X;
            }

            if (UD == -1)
            {
                finalPoint.Y = entityBoundingBox.Bottom + 2;
            }
            else if (UD == 1)
            {
                finalPoint.Y = entityBoundingBox.Top - 2;
            }
            else if (UD == 0)
            {
                finalPoint.Y = SeCenter.Y;
            }

            this.Stroke.StylusPoints[0] = finalPoint;

            if (this.ArrowMode == StrokeArrowMode.Double)
            {
                this.Stroke.StylusPoints.RemoveAt(this.Stroke.StylusPoints.Count - 2);
                this.Stroke.StylusPoints.RemoveAt(this.Stroke.StylusPoints.Count - 2);
                this.Stroke.StylusPoints.RemoveAt(this.Stroke.StylusPoints.Count - 2);
                this.Stroke.StylusPoints.RemoveAt(this.Stroke.StylusPoints.Count - 2);

                for (int i = 0; i < 4; i++)
                {
                    this.Stroke.StylusPoints.RemoveAt(1);
                }

                this.Stroke = InkTransformerHelper.LineToDoubleArrow(this.Stroke);
            }
            this.Stroke.DrawingAttributes.Height         = 2;
            this.Stroke.DrawingAttributes.Width          = 2;
            this.Stroke.DrawingAttributes.IgnorePressure = true;
        }