当前位置: 首页>>代码示例>>C#>>正文


C# System.Drawing.Drawing2D.Matrix.Rotate方法代码示例

本文整理汇总了C#中System.Drawing.Drawing2D.Matrix.Rotate方法的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.Drawing2D.Matrix.Rotate方法的具体用法?C# System.Drawing.Drawing2D.Matrix.Rotate怎么用?C# System.Drawing.Drawing2D.Matrix.Rotate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Drawing2D.Matrix的用法示例。


在下文中一共展示了System.Drawing.Drawing2D.Matrix.Rotate方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Area_Paint

        /// <summary>
        /// Draw all areas of the selected quest and highlight the selected area.
        /// </summary>
        private void Area_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.Clear(Area.BackColor);

            Matrix transformMatrix = new Matrix();
            transformMatrix.Rotate(90);
            transformMatrix.Multiply(new Matrix(-1, 0, 0, 1, 0, 0)); // Flip x-axis

            WoWQuestStep[] steps = ((QuestDisplayData)bsQuests.Current).Steps;

            float maxX = steps.Max(step => step.AreaPoints.Max(ap => ap.X));
            float maxY = steps.Max(step => step.AreaPoints.Max(ap => ap.Y));

            transformMatrix.Translate(-maxX - 5, -maxY - 5);

            e.Graphics.Transform = transformMatrix;

            // Draw all areas
            foreach (WoWQuestStep step in steps)
            {
                PointF[] drawPoints = ConvertToDrawingPoints(step.AreaPoints);
                if (drawPoints.Length < 3)
                {
                    foreach (PointF point in drawPoints)
                    {
                        // Draw a point 5x5 pixels
                        e.Graphics.FillEllipse(AREA_FILL, point.X - 2, point.Y - 2, 5F, 5F);
                        e.Graphics.DrawEllipse(AREA_BORDER, point.X - 2, point.Y - 2, 5F, 5F);
                    }
                }
                else
                {
                    e.Graphics.FillPolygon(AREA_FILL, drawPoints);
                    e.Graphics.DrawPolygon(AREA_BORDER, drawPoints);
                }
            }

            // Highlight selected area
            if (SelectedAreaPoints != null)
            {
                if (SelectedAreaPoints.Length < 3)
                {
                    foreach (PointF point in SelectedAreaPoints)
                    {
                        e.Graphics.FillEllipse(AREA_HIGHLIGHT, point.X - 2, point.Y - 2, 5F, 5F);
                        e.Graphics.DrawEllipse(AREA_BORDER, point.X - 2, point.Y - 2, 5F, 5F);
                    }
                }
                else
                {
                    e.Graphics.FillPolygon(AREA_HIGHLIGHT, this.SelectedAreaPoints);
                    e.Graphics.DrawPolygon(AREA_BORDER, this.SelectedAreaPoints);
                }
            }
        }
开发者ID:Sanjo,项目名称:Honorbuddy-QuestPOI,代码行数:58,代码来源:FormQuestView.cs

示例2: CalculateCalloutLocation

		public override bool CalculateCalloutLocation(out PointF location, out CoordinateSystem coordinateSystem)
		{
			if (this.Roi.Points.Count < 3 || string.IsNullOrEmpty(this.Callout.Text))
				base.Callout.Visible = false;
			else
				base.Callout.Visible = true;

			if (!base.Callout.Visible || _userMovedCallout)
				return base.CalculateCalloutLocation(out location, out coordinateSystem);

			SizeF calloutOffsetDestination = GetCalloutOffsetDestination();

			coordinateSystem = CoordinateSystem.Destination;
			base.AnnotationGraphic.CoordinateSystem = coordinateSystem;

			// first, move the callout by the same amount the vertex moved (if it moved at all).
			location = base.Callout.TextLocation + calloutOffsetDestination;

			PointF start = this.Roi.Points[0];
			PointF vertex = this.Roi.Points[1];
			PointF end = this.Roi.Points[2];

			base.AnnotationGraphic.ResetCoordinateSystem();

			double vectorAngle = -Vector.SubtendedAngle(start, vertex, end) / 2 + 180;

			PointF[] points = new PointF[] { start, end };

			using (Matrix rotation = new Matrix())
			{
				rotation.Rotate((float) vectorAngle);
				rotation.Translate(-vertex.X, -vertex.Y);
				rotation.TransformPoints(points);
			}

			float calloutMagnitude = new Vector3D(location.X - vertex.X, location.Y - vertex.Y, 0).Magnitude;

			Vector3D startVector = new Vector3D(points[0].X, points[0].Y, 0);
			if (FloatComparer.AreEqual(startVector.Magnitude, 0F, 0.01F))
				startVector = new Vector3D(-1, 0, 0);

			startVector = startVector / startVector.Magnitude * calloutMagnitude;

			location = new PointF(startVector.X + vertex.X, startVector.Y + vertex.Y);

			return true;
		}
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:47,代码来源:ProtractorRoiCalloutLocationStrategy.cs

示例3: TestMatrix2

            public void TestMatrix2()
            {
                System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix();
                mat.Rotate(30);
                mat.Translate(-20, 20);

                var at = new AffineCoordinateTransformation2D(mat);
                var atInv = at.Inverse();

                var p0 = new double[] { 50d, 50d };
                var pt = at.Transform(p0);
                at.Invert();
                var p1 = at.Transform(pt);
                NUnit.Framework.Assert.LessOrEqual(System.Math.Abs(p1[0] - p0[0]), 0.01d);
                NUnit.Framework.Assert.LessOrEqual(System.Math.Abs(p1[1] - p0[1]), 0.01d);
                var p2 = atInv.Transform(pt);
                NUnit.Framework.Assert.LessOrEqual(System.Math.Abs(p2[0] - p0[0]), 0.01d);
                NUnit.Framework.Assert.LessOrEqual(System.Math.Abs(p2[1] - p0[1]), 0.01d);

                System.Drawing.PointF[] pts = new System.Drawing.PointF[] { new System.Drawing.PointF(50, 50) };

                mat.TransformPoints(pts);
                System.Diagnostics.Debug.WriteLine(string.Format("POINT ({0} {1})", pts[0].X, pts[0].Y));
                System.Drawing.PointF ptt = pts[0];
                System.Drawing.PointF[] ptts = new System.Drawing.PointF[] { new System.Drawing.PointF(ptt.X, ptt.Y) };
                System.Drawing.Drawing2D.Matrix inv = mat.Clone();
                inv.Invert();
                inv.TransformPoints(ptts);
                NUnit.Framework.Assert.LessOrEqual(System.Math.Abs(ptts[0].X - 50f), 0.01);
                NUnit.Framework.Assert.LessOrEqual(System.Math.Abs(ptts[0].Y - 50f), 0.01);
            }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:31,代码来源:ProjectionExamples.cs

示例4: TestMatrix

            public void TestMatrix()
            {
                SharpMap.Geometries.Point p = new Point(10, 10);
                var b = p.AsBinary();

                System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix();
                mat.Rotate(30);
                mat.Translate(-20, 20);
                System.Drawing.PointF[] pts = new System.Drawing.PointF[] { new System.Drawing.PointF(50, 50) };

                mat.TransformPoints(pts);
                System.Diagnostics.Debug.WriteLine(string.Format("POINT ({0} {1})", pts[0].X, pts[0].Y));
                System.Drawing.PointF ptt = pts[0];
                System.Drawing.PointF[] ptts = new System.Drawing.PointF[] { new System.Drawing.PointF(ptt.X, ptt.Y) };
                System.Drawing.Drawing2D.Matrix inv = mat.Clone();
                inv.Invert();
                inv.TransformPoints(ptts);
                NUnit.Framework.Assert.LessOrEqual(System.Math.Abs(ptts[0].X - 50f), 0.01);
                NUnit.Framework.Assert.LessOrEqual(System.Math.Abs(ptts[0].Y - 50f), 0.01);
            }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:20,代码来源:ProjectionExamples.cs

示例5: GetCurrentPosteriorVector

		private static Vector3D GetCurrentPosteriorVector(Vector3D imagePosterior, int sourceWidth, float adjustedSourceHeight, int rotation, float scaleX, float scaleY, bool flipX, bool flipY)
		{
			// figure out where the posterior direction went
			using (var transform = new Matrix())
			{
				var points = new[] {new PointF(sourceWidth*imagePosterior.X, adjustedSourceHeight*imagePosterior.Y)};
				transform.Rotate(rotation);
				transform.Scale(scaleX*(flipY ? -1 : 1), scaleY*(flipX ? -1 : 1));
				transform.TransformPoints(points);
				return new Vector3D(points[0].X, points[0].Y, 0);
			}
		}
开发者ID:jasper-yeh,项目名称:ClearCanvas,代码行数:12,代码来源:MammographyImageSpatialTransform.cs

示例6: BisectAngle

			/// <summary>
			/// Bisects the inner angle formed by <paramref name="point1"/> <paramref name="point2"/> <paramref name="point3"/>.
			/// </summary>
			/// <remarks>
			/// <para>
			/// Based largely on <see cref="ProtractorRoiCalloutLocationStrategy"/>.
			/// </para>
			/// <para>
			/// The return value is a point within the angle such that the line segment
			/// from this point to <paramref name="point2"/> has the specified <paramref name="magnitude"/> and bisects the angle
			/// <paramref name="point1"/> <paramref name="point2"/> <paramref name="point3"/>.
			/// </para>
			/// </remarks>
			private static PointF BisectAngle(PointF point1, PointF point2, PointF point3, float magnitude)
			{
				PointF[] points = new PointF[] {point1, point3};
				using (Matrix2D rotation = new Matrix2D())
				{
					rotation.Rotate((float) (-Vector.SubtendedAngle(point1, point2, point3)/2 + 180));
					rotation.Translate(-point2.X, -point2.Y);
					rotation.TransformPoints(points);
				}

				Vector3D result = new Vector3D(points[0].X, points[0].Y, 0);
				if (FloatComparer.AreEqual(result.Magnitude, 0F, 0.01F))
					result = new Vector3D(-1, 0, 0);
				result = result/result.Magnitude*magnitude;

				return new PointF(point2.X - result.X, point2.Y - result.Y);
			}
开发者ID:nhannd,项目名称:Xian,代码行数:30,代码来源:ShowAnglesToolGraphic.cs

示例7: DrawFillPattern

        private void DrawFillPattern(Graphics g)
        {
            Stopwatch sw = Stopwatch.StartNew();
            float matrixScale;
            var fillPattern = FillPattern;
            if (fillPattern == null)
                return;

            if (fillPattern.Target == FillPatternTarget.Model)
                matrixScale = Scale;
            else
                matrixScale = Scale * 10;

            try
            {
                var width =
                    (ActualWidth == 0 ? Width : ActualWidth) == 0
                    ? 100
                    : (ActualWidth == 0 ? Width : ActualWidth);

                if (double.IsNaN(width))
                    width = 100;

                var height =
                    (ActualHeight == 0 ? Height : ActualHeight) == 0
                    ? 30
                    : (ActualHeight == 0 ? Height : ActualHeight);

                if (double.IsNaN(height))
                    height = 30;

                var viewRect = new Rectangle(0, 0,
                                             (int)width, (int)height);

                var centerX = (viewRect.Left + viewRect.Left
                               + viewRect.Width) / 2;

                var centerY = (viewRect.Top + viewRect.Top
                               + viewRect.Height) / 2;

                g.TranslateTransform(centerX, centerY);

                var rectF = new Rectangle(-1, -1, 2, 2);
                g.FillRectangle(Brushes.Blue, rectF); //draw a small rectangle in the center of the image

                g.ResetTransform();

                var fillGrids = fillPattern.GetFillGrids();

                Debug.Print(new string('-', 100));
                Debug.Print("FilPattern name: {0}", fillPattern.Name);
                if (fillPattern.Target == FillPatternTarget.Model)
                    Debug.Print("FillPattern type: Model");
                else
                    Debug.Print("FillPattern type: Drafting");
                Debug.Print("Matrix scale: {0}", matrixScale);
                Debug.Print("Grids count: {0}", fillGrids.Count);
                Debug.Print("Len\\Area: {0}", fillPattern.LengthPerArea);
                Debug.Print("Lines\\Len: {0}", fillPattern.LinesPerLength);
                Debug.Print("Strokes\\Area: {0}", fillPattern.StrokesPerArea);

                foreach (var fillGrid in fillGrids)
                {
                    var degreeAngle = (float)RadianToGradus(fillGrid.Angle);
                    Debug.Print(new string('-', 50));
                    Debug.Print("Origin: U:{0} V:{1}",
                                fillGrid.Origin.U, fillGrid.Origin.V);
                    Debug.Print("Offset: {0}", fillGrid.Offset);
                    Debug.Print("Angle: {0}", degreeAngle);
                    Debug.Print("Shift: {0}", fillGrid.Shift);

                    var pen = new Pen(System.Drawing.Color.Black)
                    {
                        Width = 1f / matrixScale
                    };

                    float dashLength = 1;
                    var segments = fillGrid.GetSegments();

                    if (segments.Count > 0)
                    {
                        pen.DashPattern = segments
                            .Select(Convert.ToSingle)
                            .ToArray();

                        Debug.Print("\tSegments:");
                        foreach (var segment in segments)
                        {
                            Debug.Print("\t\t{0}", segment);
                        }

                        dashLength = pen.DashPattern.Sum();
                    }

                    g.ResetTransform();
                    var rotateMatrix = new Matrix();
                    rotateMatrix.Rotate(degreeAngle);
                    var matrix = new Matrix(1, 0,
                                            0, -1,
                                            centerX, centerY); //-1 reflects about x-axis
//.........这里部分代码省略.........
开发者ID:kfpopeye,项目名称:AddMaterials,代码行数:101,代码来源:FillPatternViewerControlWpf.xaml.cs

示例8: getBounds

        //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
        public override void getBounds(System.Drawing.Drawing2D.Matrix transform, ref System.Drawing.Rectangle r, ref System.Drawing.PointF position)
        {
            System.Drawing.Rectangle a = new System.Drawing.Rectangle();
            double x, y;

            x = (double)position.X - System.Math.Cos(SupportClass.DegreesToRadians(startAngle)) * xRadius;
            y = (double)position.Y - System.Math.Sin(SupportClass.DegreesToRadians(startAngle)) * yRadius;

            //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1042_3"'
            a.X = (int)(x - xRadius);
            //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1042_3"'
            a.Y = (int)(y - yRadius);
            //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1042_3"'
            a.Width = (int)System.Math.Ceiling(x + xRadius) - a.X;
            //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1042_3"'
            a.Height = (int)System.Math.Ceiling(y + yRadius) - a.Y;

            System.Drawing.Drawing2D.Matrix temp_Matrix;
            temp_Matrix = new System.Drawing.Drawing2D.Matrix();
            temp_Matrix.Rotate((float)(rotation * (180 / System.Math.PI)));
            //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
            a = Util.transform(Util.multiply(transform, temp_Matrix), ref a);

            //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
            Util.combine(ref r, ref a);

            //UPGRADE_NOTE: ref keyword was added to struct-type parameters. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1303_3"'
            System.Drawing.PointF endPoint = calcPoint(1.0, ref position);

            position.X = (float)endPoint.X;
            position.Y = (float)endPoint.Y;
        }
开发者ID:agustinsantos,项目名称:mogregis3d,代码行数:33,代码来源:ArcSegment.cs

示例9: ConvertInvariantToDestination

		private PointF ConvertInvariantToDestination(PointF invariantPoint)
		{
			PointF xVector = new PointF(100, 0);
			SizeF xVectorTransformed = base.SpatialTransform.ConvertToDestination(new SizeF(xVector));

			//figure out where the source x-axis went in destination
			int rotation = (int)Math.Round(Vector.SubtendedAngle(xVectorTransformed.ToPointF(), PointF.Empty, xVector));
			if (rotation < 0)
				rotation += 360;

			Matrix m = new Matrix();
			m.Rotate(rotation);
			PointF[] pt = { invariantPoint };
			m.TransformPoints(pt);
			m.Dispose();

			return new PointF(base.Location.X + pt[0].X, base.Location.Y + pt[0].Y);
		}
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:18,代码来源:InvariantBoundablePrimitive.cs

示例10: HardFit

        private void HardFit()
        {
            /*
             * Rotate the rectangle so that top-left is centered at the top with bot-right at the bottom center. This angle is BaseTheta
             * Find the min/max x/y
             * Use those and find the efficiency of that ellipse
             * Rotate by PI/2/ANGLETRYCOUNT for PI/2 rad's (90 degs), running this same algorithm for each rotation
             * Use the most efficient, using -(BaseTheta+Theta) as the rotation of the ellipse
             */

            PointF[] Pts = (PointF[])mImgSec.PixelsUsed().SelectMany(p => new PointF[]{new PointF((float)p.X, (float)p.Y)});
            System.Drawing.Drawing2D.Matrix BaseRotator = new System.Drawing.Drawing2D.Matrix(), StepRotate = new System.Drawing.Drawing2D.Matrix();
            // |\ = ATan(Width/Height)  so |\   |
            // | \                         | \  |
            // |  \                        |  \ |
            // |___\                       |___\| = -Atan(W/H)

            float BaseTheta = (float)(-Math.Atan((double)mImgSec.Width / (double)mImgSec.Height));
            BaseRotator.Rotate(BaseTheta);
            StepRotate.Rotate((float)Math.PI / 2f / (float)ANGLETRYCOUNT);
            BaseRotator.TransformPoints(Pts);
            double BestFit = 0d,temp;
            int BestChoice = -1;
            SizeF BestDim = new SizeF(),tempDim;
            for(int i = 0; i < ANGLETRYCOUNT - 1; i++, StepRotate.TransformPoints(Pts))
            {
                if((temp = GetFit(Pts, out tempDim)) > BestFit)
                {BestChoice = i; BestFit = temp;BestDim = tempDim;}
            }

            mRotation = -(BaseTheta+BestChoice*Math.PI / 2d / (double)ANGLETRYCOUNT);
            mEllWidth = BestDim.Width;
            mEllHeight = BestDim.Height;
            return;
        }
开发者ID:scnerd,项目名称:Picasso,代码行数:35,代码来源:Ellipse.cs

示例11: PointToObject

        public System.Drawing.PointF PointToObject(System.Drawing.PointF pt)
        {
            System.Drawing.Drawing2D.Matrix	matrix;
            System.Drawing.RectangleF		rc;
            System.Drawing.PointF[]			rgPts;

            rc = this.BoundingBox;

            rgPts = new System.Drawing.PointF[1];
            rgPts[0].X = pt.X;
            rgPts[0].Y = pt.Y;

            matrix = new System.Drawing.Drawing2D.Matrix();
            matrix.Translate(-this.xOffset, -this.yOffset);
            matrix.TransformPoints(rgPts);

            matrix.Reset();
            matrix.Translate(-(rc.Left + rc.Right) / 2, -(rc.Top + rc.Bottom) / 2);
            matrix.TransformPoints(rgPts);

            matrix.Reset();
            matrix.Rotate(-this.rotation);
            matrix.TransformPoints(rgPts);

            matrix.Reset();
            matrix.Translate((rc.Left + rc.Right) / 2, (rc.Top + rc.Bottom) / 2);
            matrix.TransformPoints(rgPts);

            return rgPts[0];
        }
开发者ID:sanyaade-g2g-repos,项目名称:quickdiagram,代码行数:30,代码来源:GOM_Object.cs

示例12: AddKeyPoint

        /// <summary>
        /// Add a key point into this polyline link.
        /// </summary>
        /// <param name="x">X coordinate of the key point.</param>
        /// <param name="y">Y coordinate of the key point.</param>
        /// <param name="rgObjs">GOM object collection.</param>
        public void AddKeyPoint(float x, float y, GOM_Objects rgObjs)
        {
            if ( m_linkingStyle != GOM_Linking_Style.Polyline )
            {
                return;
            }

            System.Drawing.Drawing2D.Matrix	matrix;
            System.Drawing.PointF[]			rgPts, rgAllPts;
            System.Drawing.PointF			startPt, endPt;
            startPt	= StartPointInCanvas(rgObjs);
            endPt	= EndPointInCanvas(rgObjs);

            rgPts = new System.Drawing.PointF[2];
            rgAllPts = new System.Drawing.PointF[m_keyPts.Count+2];

            rgAllPts[0].X = startPt.X;
            rgAllPts[0].Y = startPt.Y;
            for(int i=0; i<m_keyPts.Count; i++)
            {
                rgAllPts[1+i].X = m_keyPts[i].x;
                rgAllPts[1+i].Y = m_keyPts[i].y;
            }
            rgAllPts[rgAllPts.Length-1].X = endPt.X;
            rgAllPts[rgAllPts.Length-1].Y = endPt.Y;

            for(int i=0; i<(rgAllPts.Length-1); i++)
            {
                rgPts[0].X = rgAllPts[i+1].X;
                rgPts[0].Y = rgAllPts[i+1].Y;
                rgPts[1].X = x;
                rgPts[1].Y = y;

                matrix = new System.Drawing.Drawing2D.Matrix();
                matrix.Translate(-rgAllPts[i].X, -rgAllPts[i].Y);
                matrix.TransformPoints(rgPts);

                float angle = (float)(System.Math.Atan2(rgAllPts[i+1].Y - rgAllPts[i].Y, rgAllPts[i+1].X - rgAllPts[i].X) / System.Math.PI) * 180;

                matrix.Reset();
                matrix.Rotate(-angle);
                matrix.TransformPoints(rgPts);

                if ((Math.Abs(rgPts[1].Y) < 2) && (-2 < rgPts[1].X) && (rgPts[1].X < rgPts[0].X + 2))
                {
                    GOM_Point point = new GOM_Point();
                    point.x = x;
                    point.y = y;
                    m_keyPts.Insert(i, point);
                    return;
                }
            }
        }
开发者ID:sanyaade-g2g-repos,项目名称:quickdiagram,代码行数:59,代码来源:GOM_Link.cs

示例13: IsPointOnLink

        /// <summary>
        /// Indicates whether a given point is on this link.
        /// </summary>
        /// <param name="x">X coordinate of the given point.</param>
        /// <param name="y">Y coordinate of the given point.</param>
        /// <param name="rgObjs">GOM object collection.</param>
        /// <returns>Whether a given point is on this link.</returns>
        public bool IsPointOnLink(float x, float y, GOM_Objects rgObjs)
        {
            switch (m_linkingStyle)
            {
                case GOM_Linking_Style.Line:
                {
                    System.Drawing.Drawing2D.Matrix	matrix;
                    System.Drawing.PointF[]			rgPts;
                    System.Drawing.PointF			startPt, endPt;

                    startPt	= StartPointInCanvas(rgObjs);
                    endPt	= EndPointInCanvas(rgObjs);

                    rgPts = new System.Drawing.PointF[2];
                    rgPts[0].X = endPt.X;
                    rgPts[0].Y = endPt.Y;
                    rgPts[1].X = x;
                    rgPts[1].Y = y;

                    matrix = new System.Drawing.Drawing2D.Matrix();
                    matrix.Translate(-startPt.X, -startPt.Y);
                    matrix.TransformPoints(rgPts);

                    float angle = (float)(System.Math.Atan2(endPt.Y - startPt.Y, endPt.X - startPt.X) / System.Math.PI) * 180;

                    matrix.Reset();
                    matrix.Rotate(-angle);
                    matrix.TransformPoints(rgPts);

                    if ((Math.Abs(rgPts[1].Y) < 2) && (-2 < rgPts[1].X) && (rgPts[1].X < rgPts[0].X + 2))
                    {
                        return true;
                    }

                    break;
                }
                case GOM_Linking_Style.Polyline:
                {
                    System.Drawing.Drawing2D.Matrix	matrix;
                    System.Drawing.PointF[]			rgPts, rgAllPts;
                    System.Drawing.PointF			startPt, endPt;
                    startPt	= StartPointInCanvas(rgObjs);
                    endPt	= EndPointInCanvas(rgObjs);

                    rgPts = new System.Drawing.PointF[2];
                    rgAllPts = new System.Drawing.PointF[m_keyPts.Count+2];

                    rgAllPts[0].X = startPt.X;
                    rgAllPts[0].Y = startPt.Y;
                    for(int i=0; i<m_keyPts.Count; i++)
                    {
                        rgAllPts[1+i].X = m_keyPts[i].x;
                        rgAllPts[1+i].Y = m_keyPts[i].y;
                    }
                    rgAllPts[rgAllPts.Length-1].X = endPt.X;
                    rgAllPts[rgAllPts.Length-1].Y = endPt.Y;

                    for(int i=0; i<(rgAllPts.Length-1); i++)
                    {
                        rgPts[0].X = rgAllPts[i+1].X;
                        rgPts[0].Y = rgAllPts[i+1].Y;
                        rgPts[1].X = x;
                        rgPts[1].Y = y;

                        matrix = new System.Drawing.Drawing2D.Matrix();
                        matrix.Translate(-rgAllPts[i].X, -rgAllPts[i].Y);
                        matrix.TransformPoints(rgPts);

                        float angle = (float)(System.Math.Atan2(rgAllPts[i+1].Y - rgAllPts[i].Y, rgAllPts[i+1].X - rgAllPts[i].X) / System.Math.PI) * 180;

                        matrix.Reset();
                        matrix.Rotate(-angle);
                        matrix.TransformPoints(rgPts);

                        if ((Math.Abs(rgPts[1].Y) < 2) && (-2 < rgPts[1].X) && (rgPts[1].X < rgPts[0].X + 2))
                        {
                            return true;
                        }
                    }

                    break;
                }
                case GOM_Linking_Style.Curve:
                {
                    break;
                }
                default:
                    System.Diagnostics.Debug.Assert(false, "Unknown link style.");
                    break;
            }

            return false;
        }
开发者ID:sanyaade-g2g-repos,项目名称:quickdiagram,代码行数:100,代码来源:GOM_Link.cs


注:本文中的System.Drawing.Drawing2D.Matrix.Rotate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。