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


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

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


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

示例1: 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

示例2: 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

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