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


C# Graphics.TransformPoints方法代码示例

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


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

示例1: getScreenBoundsInWorldCoordinates

 protected PointF[] getScreenBoundsInWorldCoordinates(Graphics g)
 {
     Rectangle screenBounds = canvas.ClientRectangle;
     PointF[] transformedPoints = new PointF[] { new PointF((float)screenBounds.X, (float)screenBounds.Y), new PointF((float)screenBounds.Width, (float)screenBounds.Height) };
     g.TransformPoints(CoordinateSpace.World, CoordinateSpace.Page, transformedPoints);
     return transformedPoints;
 }
开发者ID:Echo343,项目名称:Cartographer,代码行数:7,代码来源:Grid.cs

示例2: docToDeviceF

		internal static PointF docToDeviceF(Graphics g, PointF docPt)
		{
			PointF[] pts = new PointF[1] { docPt };
			g.TransformPoints(CoordinateSpace.Device,
				CoordinateSpace.World, pts);

			return pts[0];
		}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:8,代码来源:Utilities.cs

示例3: docToDevice

		internal static Point docToDevice(Graphics g, PointF docPt)
		{
			PointF[] pts = new PointF[1] { new PointF(docPt.X, docPt.Y) };
			g.TransformPoints(CoordinateSpace.Device,
				CoordinateSpace.World, pts);

			return new Point((int)Math.Round(pts[0].X), (int)Math.Round(pts[0].Y));
		}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:8,代码来源:Utilities.cs

示例4: ContainsPoint

 public override bool ContainsPoint(PointF point, Graphics g)
 {
     float x = point.X, y = point.Y;
     PointF[] pointF = { new PointF(Location.X, Location.Y) };
     g.TransformPoints(CoordinateSpace.World, CoordinateSpace.Device, pointF);
     if (x >= pointF[0].X && (x <= pointF[0].X + Size.Width) && y >= pointF[0].Y && (y <= pointF[0].Y + Size.Height))
     {
         return true;
     }
     return false;
 }
开发者ID:nmackay132,项目名称:COP4226_HW3,代码行数:11,代码来源:Rectangle.cs

示例5: DrawCurrentPage

        private void DrawCurrentPage(Graphics oGraphics, Rectangle oBounds)
        {
            Point[] oPoints = {
                new Point(oBounds.Left, oBounds.Top),
                new Point(oBounds.Right, oBounds.Bottom)
                };
            oGraphics.TransformPoints(CoordinateSpace.Device, CoordinateSpace.Page, oPoints);

            PrintRectangle oPrintRectangle = new PrintRectangle(oPoints[0].X, oPoints[0].Y, oPoints[1].X, oPoints[1].Y);

            RangeToFormat oRangeToFormat = new RangeToFormat();
            oRangeToFormat.hdc = oRangeToFormat.hdcTarget = oGraphics.GetHdc();
            oRangeToFormat.rc = oRangeToFormat.rcPage = oPrintRectangle;
            oRangeToFormat.chrg.cpMin = _iPosition;
            oRangeToFormat.chrg.cpMax = _iPrintEnd;

            _iPosition = _oScintillaControl.NativeInterface.FormatRange(true, ref oRangeToFormat);
            
        }
开发者ID:dbbotkin,项目名称:PrimeComm,代码行数:19,代码来源:PrintDocument.cs

示例6: transformRect

		internal static RectangleF transformRect(Graphics g,
			RectangleF r, CoordinateSpace destSpace, CoordinateSpace srcSpace)
		{
			PointF[] pts = new PointF[4];

			// get the corner points
			pts[0].X = r.Left;
			pts[0].Y = r.Top;
			pts[1].X = r.Right;
			pts[1].Y = r.Top;
			pts[2].X = r.Right;
			pts[2].Y = r.Bottom;
			pts[3].X = r.Left;
			pts[3].Y = r.Bottom;

			// get the device coordinates
			g.TransformPoints(destSpace, srcSpace, pts);

			// return rectangle in world coordinates
			return RectangleF.FromLTRB(pts[0].X, pts[0].Y, pts[2].X, pts[2].Y);
		}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:21,代码来源:Utilities.cs

示例7: deviceToDoc

		/// <summary>
		/// Inherited from Flowchart source
		/// </summary>
		/// <param name="g"></param>
		/// <param name="r"></param>
		/// <returns></returns>
		public static RectangleF deviceToDoc(Graphics g, RectangleF r)
		{
			PointF[] pts = new PointF[4];

			// get the corner points
			pts[0].X = r.Left;
			pts[0].Y = r.Top;
			pts[1].X = r.Right;
			pts[1].Y = r.Top;
			pts[2].X = r.Right;
			pts[2].Y = r.Bottom;
			pts[3].X = r.Left;
			pts[3].Y = r.Bottom;

			// get the world coordinates
			g.TransformPoints(CoordinateSpace.World,
				CoordinateSpace.Device, pts);

			// return rectangle in world coordinates
			return RectangleF.FromLTRB(
				pts[0].X, pts[0].Y, pts[2].X, pts[2].Y);
		}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:28,代码来源:DxfHelper.cs

示例8: GetRealPageBounds

 // Get real printer page bounds in units of 1/100th of an inch
 static Rectangle GetRealPageBounds(Graphics g)
 {
     RectangleF vpb = g.VisibleClipBounds;
     PointF[] bottomRight = { new PointF(vpb.Size.Width, vpb.Size.Height) };
     g.TransformPoints(CoordinateSpace.Device, CoordinateSpace.Page, bottomRight);
     float dpiX = g.DpiX;
     float dpiY = g.DpiY;
     return new Rectangle(0, 0, (int)(bottomRight[0].X * 100 / dpiX), (int)(bottomRight[0].Y * 100 / dpiY));
 }
开发者ID:stankela,项目名称:bilten,代码行数:10,代码来源:PreviewDialog.cs

示例9: DrawCurrentPage

        private void DrawCurrentPage(Graphics gr, Rectangle bounds)
        {
            Point[] oPoints = {
                new Point(bounds.Left, bounds.Top),
                new Point(bounds.Right, bounds.Bottom)
                };
            gr.TransformPoints(CoordinateSpace.Device, CoordinateSpace.Page, oPoints);

            PrintRectangle oPrintRectangle = new PrintRectangle(oPoints[0].X, oPoints[0].Y, oPoints[1].X, oPoints[1].Y);

            RangeToFormat oRangeToFormat = new RangeToFormat();
            oRangeToFormat.hdc = oRangeToFormat.hdcTarget = gr.GetHdc();
            oRangeToFormat.rc = oRangeToFormat.rcPage = oPrintRectangle;
            oRangeToFormat.chrg.Min = _iPosition;
            oRangeToFormat.chrg.Max = _iPrintEnd;
            _iPosition = sci.FormatRange(true, ref oRangeToFormat);
        }
开发者ID:rizwan3d,项目名称:elalang,代码行数:17,代码来源:ScintillaPrintDocument.cs

示例10: DocToScreen

		/// <summary>
		/// Converts overview's document's coordinates to screen coordinates.
		/// </summary>
		internal Point DocToScreen(Graphics g, PointF pt)
		{
			PointF[] points = new PointF[1] { pt };
			g.TransformPoints(CoordinateSpace.Device, CoordinateSpace.World, points);
			return new Point((int)points[0].X, (int)points[0].Y);
		}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:9,代码来源:Overview.cs

示例11: DrawTick

		/// <summary>
		/// Draw a single tick and its associated value string (TickText)
		/// </summary>
		/// <param name="g">The graphics surface on which to draw.</param>
		/// <param name="world">The tick origin in world coordinates.</param>
		/// <param name="size">The physical size of the tick (pixels)</param>
		/// <param name="text">The text (value) associated with the tick</param>
		/// <param name="clearance">out: overall perpendicular clearance from Axis</param>
		/// <param name="bounds">out: tick and tickText bounds</param>
		public virtual void DrawTick(
			Graphics g,
			double world,
			float size,
			string text,
			out float clearance,
			out Rectangle bounds)
		{
			// initialise clearance and bounds
			clearance = 0;
			bounds = Rectangle.Empty;

			if (size <= 0) { return; }		// just to be safe

			// determine physical origin of tick on axis
			PointF physical = WorldToPhysical(world, true);

			// evaluate tick start and end points
			float tickSize = size * ScaleFactor;
			float tickStart = 0;
			float tickEnd = tickSize;

			// translate points if TicksCrossAxis
			if(ticksCrossAxis){
				tickStart -= tickSize/2;
				tickEnd -= tickSize/2;
			}

			// measure tickText string, which is drawn by default with text topLeft at the origin
			SizeF sz = g.MeasureString(text, tickTextFontScaled);

			// calculate the projection of tickText rectangle onto tick vector line
			float delta = tickTextAngle - tickAngle;	// angle between tick and text (degrees)
			double r = delta * Math.PI / 180;			// convert to radians for Sin() and Cos()
			double projection = 0;
			if(!TickTextHidden){
				projection =  Math.Abs(sz.Width*Math.Cos(r)) + Math.Abs(sz.Height*Math.Sin(r));
			}

			// define centre of tickText, and overall clearance, for various tick/text scenarios
			float centre = 0;
			if(textAtTickOrigin){
				centre = tickStart - (float)projection/2;
				clearance = centre - (float)projection/2;
			}
			else{
				centre = tickEnd + (float)projection/2;
				clearance = centre + (float)projection/2;
			}

			// define tickOrigin and tickVector points along the reference X-axis
			PointF tickOrigin = new PointF(tickStart, 0);
			PointF tickVector = new PointF(tickEnd, 0);

			// set up rotation by (tickAngle+axisAngle) and translation to final position.
			// this partial transform is common to (and retained for) drawing the tickText
			g.ResetTransform();
			g.TranslateTransform(physical.X, physical.Y);	// done last (MatrixOrder.Prepend)
			g.RotateTransform(-tickAngle-physicalAngle);	// done first

			// draw tick line
			g.DrawLine(linePen, tickOrigin, tickVector);

			// Set up and transform tick extents to define initial bounds
			PointF[] tickX = new PointF[2];

			tickX[0] = tickOrigin;
			tickX[1] = tickVector;
			g.TransformPoints(CoordinateSpace.Device, CoordinateSpace.World, tickX);

			// adjust clearance because of tick rotation 
			clearance = clearance * (float)Math.Abs( Math.Sin(tickAngle * Math.PI/180) );

			// set initial bounds to rectangle enclosing tick
			bounds = Rectangle.Round( Utils.NormalisedRectangleF( tickX[0], tickX[1]) );

			if(text == "" || TickTextHidden){ return; }		// return now if no tickText to draw

			// add further graphic transforms (in reverse order) to align and draw tickText
			g.TranslateTransform(centre, 0);					// (3) translate to text centre
			g.RotateTransform(-delta);							// (2) align with tick vector
			g.TranslateTransform(-sz.Width/2, -sz.Height/2);	// (1) centre text prior to rotation
 
			// draw label at the origin (0,0) using accumulated transforms
			g.DrawString(text, tickTextFontScaled, tickTextBrush, PointF.Empty);

			// Set up tickText rectangle extents to define overall bounds
			PointF[] textX = new PointF[4];

			textX[0] = new PointF(0, 0);					// origin of rectangle
			textX[1] = new PointF(sz.Width, sz.Height);		// bottom Right corner
//.........这里部分代码省略.........
开发者ID:hwthomas,项目名称:XwPlot,代码行数:101,代码来源:Axis2014.cs

示例12: DrawCurrentPage

        private void DrawCurrentPage(Graphics oGraphics, Rectangle oBounds) {
            Point[] oPoints = {
                new Point(oBounds.Left, oBounds.Top),
                new Point(oBounds.Right, oBounds.Bottom)
                };
            oGraphics.TransformPoints(CoordinateSpace.Device, CoordinateSpace.Page, oPoints);

            PrintRectangle oPrintRectangle = new PrintRectangle(oPoints[0].X, oPoints[0].Y, oPoints[1].X, oPoints[1].Y);

            RangeToFormat oRangeToFormat = new RangeToFormat();
            oRangeToFormat.hdc = oRangeToFormat.hdcTarget = oGraphics.GetHdc();
            oRangeToFormat.rc = oRangeToFormat.rcPage = oPrintRectangle;
            oRangeToFormat.chrg.cpMin = m_iLastPrintPosition;
            oRangeToFormat.chrg.cpMax = m_iTextLength;

            m_iLastPrintPosition += FormatRange(oRangeToFormat);
        }
开发者ID:zcnet4,项目名称:lua-tilde,代码行数:17,代码来源:PrintDocument.cs

示例13: TranslateBounds

 // Translate from units of 1/100th of an inch to page units
 static RectangleF TranslateBounds(Graphics g, Rectangle bounds)
 {
     float dpiX = g.DpiX;
     float dpiY = g.DpiY;
     PointF[] pts = new PointF[2];
     // Translate from units of 1/100th of an inch to device units
     pts[0] = new PointF(bounds.X * dpiX / 100, bounds.Y * dpiY / 100);
     pts[1] = new PointF(bounds.Width * dpiX / 100, bounds.Height * dpiX / 100);
     // Translate from device units to page units
     g.TransformPoints(CoordinateSpace.Page, CoordinateSpace.Device, pts);
     return new RectangleF(pts[0].X, pts[0].Y, pts[1].X, pts[1].Y);
 }
开发者ID:stankela,项目名称:bilten,代码行数:13,代码来源:PreviewDialog.cs

示例14: Draw

        public void Draw(Graphics g)
        {
            ptCurva = new Point[2];
            ptCurva[0] = new Point((int)x, (int)y);

            float incX, incY;
            g.TranslateTransform(x, y);
            g.RotateTransform(angle);

            double rad = angle * Math.PI / 180f;
            if(speed > 0)
            {
                if (Math.Abs(WheelAngle) < 0.0001f)
                {
                    incX = (float)Math.Cos(rad);
                    incY = (float)Math.Sin(rad);
                    x += incX * speed;
                    y += incY * speed;
                    g.TranslateTransform(incX, incY);
                }
                else
                {
                    Point[] pts = { new Point(0, 0) };
                    float newRadius = (float)(radius * Math.Tan((90 - WheelAngle) * Math.PI / 180f));
                    float totalAngle = (float)((360 * speed) / (2 * Math.PI * newRadius));
                    g.TranslateTransform(0, newRadius);
                    g.RotateTransform(totalAngle);
                    g.TranslateTransform(0, -newRadius);
                    g.TransformPoints(CoordinateSpace.Page, CoordinateSpace.World, pts);

                    x = pts[0].X;
                    y = pts[0].Y;
                    angle = (angle + totalAngle) % 360f;
                }
            }
            Pen p = new Pen(Color.Red);
            g.DrawLine(p, -50f, 0, 70f, 0);
            g.DrawLine(p, 0, -5f, 0, 5f);
            g.TranslateTransform(-(widthW / 2 + distFB), -width/2);
            foreach (Wheel w in wheels)
            {
                w.Draw(g);
            }
            g.DrawRectangle(new Pen(Color.Blue), 0, 0, length, width);
            g.ResetTransform();
            ptCurva[1] = new Point((int)x, (int)y);
        }
开发者ID:ceverdeen7,项目名称:oppa-facens,代码行数:47,代码来源:Car.cs

示例15: TransformsTestDraw

		private void TransformsTestDraw(Graphics g)
		{
			g.FillRectangle(SystemBrushes.Control, tabPage15.ClientRectangle);
			boundsX = boundsY = boundsPad;
			using (Pen p = new Pen(Color.Blue))
			{

				int mid = (Height-50)/2;
				if (mid > (Width-10)/2)
					mid = (Width-10)/2;
				
				PointF[] f = (PointF[])transformTestPoints.Clone();
				g.RotateTransform(transformRotation);
				g.TranslateTransform(transformX, transformY);
				g.ScaleTransform(transformScaleX, transformScaleY);
				g.TransformPoints(CoordinateSpace.Page,
					CoordinateSpace.World,
					f);

				using (Brush b = new SolidBrush(Color.CadetBlue))
				{
					g.FillEllipse(b, -20, -20, 20, 10);
					g.DrawString("Hello", Font, b, 0, 0);
				}
				g.ResetTransform();

				if (transformX < -200 || transformX > 200)
				{
					transformXOffset = -transformXOffset;
					transformScaleXOffset = -transformScaleXOffset;
				}

				if (transformY < -200 || transformY > 200)
				{
					transformYOffset = -transformYOffset;
					transformScaleYOffset = -transformScaleYOffset;
				}

				for (int i = 0; i < transformTestPoints.Length; i+=2)
					g.DrawLine(p, f[i].X + mid, f[i].Y + mid, f[i+1].X + mid, f[i+1].Y + mid);

				transformX += transformXOffset;
				transformY += transformYOffset;
				transformRotation += transformRotationOffSet;
				transformScaleX += transformScaleXOffset;
				transformScaleY += transformScaleYOffset;

				/*				Font f = new Font("Arial", 6);
				
								Rectangle b = NextBounds(g, "Rectangle");
								Rectangle b1 = new Rectangle(b.Left + 5, b.Top + 5, b.Width - 10, b.Height - 10);
								g.DrawRectangle(p, b1);
				
								g.RotateTransform(45);
								b = NextBounds(g, "RotateTransform(45)");
								b1 = new Rectangle(b.Left + 5, b.Top + 5, b.Width - 10, b.Height - 10);
								g.DrawRectangle(p, b1);
				*/				

			}
			
		}
开发者ID:hitswa,项目名称:winforms,代码行数:62,代码来源:FormsTest.cs


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