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


C# IGraphics.TranslateTransform方法代码示例

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


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

示例1: DrawCaps

		private void DrawCaps(IGraphics g, bool onScreen, Style style)
		{
			Matrix transformState = g.Transform;
			g.TranslateTransform(routeCache[0].X, routeCache[0].Y);
			g.RotateTransform(GetAngle(routeCache[0], routeCache[1]));
			DrawStartCap(g, onScreen, style);
			g.Transform = transformState;

			int last = routeCache.Count - 1;
			g.TranslateTransform(routeCache[last].X, routeCache[last].Y);
			g.RotateTransform(GetAngle(routeCache[last], routeCache[last - 1]));
			DrawEndCap(g, onScreen, style);
			g.Transform = transformState;
		}
开发者ID:BachelorEric,项目名称:ModelFirst,代码行数:14,代码来源:Connection.cs

示例2: DrawSurface

		private void DrawSurface(IGraphics g, bool onScreen, Style style)
		{
			// Update graphical objects
			backgroundBrush.Color = style.CommentBackColor;
			borderPen.Color = style.CommentBorderColor;
			borderPen.Width = style.CommentBorderWidth;
			if (style.IsCommentBorderDashed)
				borderPen.DashPattern = borderDashPattern;
			else
				borderPen.DashStyle = DashStyle.Solid;

			// Create shape pattern
			GraphicsPath path = new GraphicsPath();
			path.AddLine(Left, Top, Right - PaddingSize, Top);
			path.AddLine(Right, Top + PaddingSize, Right, Bottom);
			path.AddLine(Right, Bottom, Left, Bottom);
			path.CloseFigure();

			// Draw shadow first
			if ((!onScreen || !IsSelected) && !style.ShadowOffset.IsEmpty)
			{
				shadowBrush.Color = style.ShadowColor;
				g.TranslateTransform(style.ShadowOffset.Width, style.ShadowOffset.Height);
				g.FillPath(shadowBrush, path);
				g.TranslateTransform(-style.ShadowOffset.Width, -style.ShadowOffset.Height);
			}

			// Draw borders & background
			g.FillPath(backgroundBrush, path);
			g.DrawPath(borderPen, path);

			// Draw earmark
			path.Reset();
			path.AddLine(Right - PaddingSize, Top, Right - PaddingSize, Top + PaddingSize);
			path.AddLine(Right - PaddingSize, Top + PaddingSize, Right, Top + PaddingSize);
			g.DrawPath(borderPen, path);

			path.Dispose();
		}
开发者ID:gbaychev,项目名称:NClass,代码行数:39,代码来源:CommentShape.cs

示例3: OnPaintBackground

 public override void OnPaintBackground(IGraphics g, int width, int height)
 {
     if (widths == null){
         InitSizes(width, height);
     }
     for (int row = 0; row < RowCount; row++){
         for (int col = 0; col < ColumnCount; col++){
             Tuple<int, int> key = new Tuple<int, int>(row, col);
             if (components.ContainsKey(key)){
                 BasicView v = components[key];
                 g.TranslateTransform(xpos[col], ypos[row]);
                 v.OnPaintBackground(g, widths[col], heights[row]);
                 g.ResetTransform();
             }
         }
     }
 }
开发者ID:JurgenCox,项目名称:compbio-base,代码行数:17,代码来源:BasicTableLayoutView.cs

示例4: Render

        private void Render(IGraphics ig)
        {
            string s = cbWhat.Text;

            if (s == "Clipping")
            {
                Pen pn = new Pen(Color.LightGray, 5);
                Pen pn2 = new Pen(Color.Yellow);

                ig.Clear(Color.Black);

                GraphicsContainer cnt = ig.BeginContainer();

                ig.SmoothingMode = SmoothingMode.HighQuality;

                ig.SetClip(new Rectangle(35,35,120,120));

                ig.DrawRectangle(pn, 5,5,45,70);
                ig.DrawRectangle(pn, 15,25,90,120);
                ig.DrawRectangle(pn, 50,30,100,170);
                ig.DrawRectangle(pn, 5,80,180,30);
                ig.DrawRectangle(pn, 75,10,40,160);

                ig.EndContainer(cnt);

                ig.DrawRectangle(pn2, 5,5,45,70);
                ig.DrawRectangle(pn2, 15,25,90,120);
                ig.DrawRectangle(pn2, 50,30,100,170);
                ig.DrawRectangle(pn2, 5,80,180,30);
                ig.DrawRectangle(pn2, 75,10,40,160);
            }
            else if (s == "Transforms")
            {

                ig.Clear(Color.Black);

                ig.RotateTransform(15);
                ig.DrawRectangle(new Pen(Color.Red,2), 260,80,50,40);
                ig.ResetTransform();
                ig.DrawRectangle(new Pen(Color.Red,2), 260,80,50,40);

                ig.TranslateTransform(15,-5);

                GraphicsContainer cnt = ig.BeginContainer();

                    ig.SmoothingMode = SmoothingMode.HighQuality;

                    ig.RotateTransform(5);
                    ig.FillEllipse(new SolidBrush(Color.Orange), 100,100,80,40);
                    ig.DrawRectangle(new Pen(Color.Orange,2), 60,80,40,40);

                    GraphicsContainer cnt2  = ig.BeginContainer();

                        ig.SmoothingMode = SmoothingMode.None;

                        ig.RotateTransform(5);
                        ig.ScaleTransform(1.1f, 1.2f);

                        ig.FillEllipse(new SolidBrush(Color.YellowGreen), 130,180,80,40);
                        ig.DrawRectangle(new Pen(Color.YellowGreen,2), 62,80,40,40);

                        GraphicsContainer cnt3  = ig.BeginContainer();

                            ig.SmoothingMode = SmoothingMode.HighQuality;

                            Matrix mm = new Matrix();
                            mm.Shear(0.3f, 0f);
                            ig.Transform = mm;

                            ig.FillEllipse(new SolidBrush(Color.Green), 180,120,80,40);
                            ig.DrawRectangle(new Pen(Color.Green,2), 62,84,40,40);

                        ig.EndContainer(cnt3);

                    ig.EndContainer(cnt2);

                    ig.FillEllipse(new SolidBrush(Color.Blue), 120,150,80,40);
                    ig.DrawRectangle(new Pen(Color.Blue,2), 64,80,40,40);

                ig.EndContainer(cnt);

                ig.FillEllipse(new SolidBrush(Color.Indigo), 80,210,80,40);
                ig.DrawRectangle(new Pen(Color.Indigo,2), 66,80,40,40);

                ig.DrawRectangle(new Pen(Color.White,2), 270,30,50,40);
                ig.ResetTransform();
                ig.DrawRectangle(new Pen(Color.White,2), 270,30,50,40);

            }
            else if (s == "Lines")
            {
                ig.SmoothingMode = SmoothingMode.AntiAlias;

                Pen ow = new Pen(Color.Purple, 12);
                ow.EndCap = LineCap.Round;
                ow.StartCap = LineCap.Round;
                ow.MiterLimit = 6f;
                ow.LineJoin = LineJoin.Miter;

                ig.SmoothingMode = SmoothingMode.None;
//.........这里部分代码省略.........
开发者ID:luizcorreia,项目名称:SvgNet,代码行数:101,代码来源:Form1.cs

示例5: OnPaint

 protected internal override void OnPaint(IGraphics g, int width, int height)
 {
     if (widths == null){
         InitSizes(width, height);
     }
     PaintSplitters(g, width, height);
     for (int row = 0; row < RowCount; row++){
         for (int col = 0; col < ColumnCount; col++){
             Tuple<int, int> key = new Tuple<int, int>(row, col);
             if (components.ContainsKey(key)){
                 BasicView v = components[key];
                 g.SetClip(new Rectangle(xpos[col], ypos[row], widths[col], heights[row]));
                 g.TranslateTransform(xpos[col], ypos[row]);
                 v.OnPaint(g, widths[col], heights[row]);
                 g.ResetTransform();
                 g.ResetClip();
             }
         }
     }
 }
开发者ID:neuhauser,项目名称:compbio-base,代码行数:20,代码来源:BasicTableLayoutView.cs

示例6: DrawLines

        void DrawLines(IGraphics g, List<PointF> points, DrawingMode mode)
        {
            const int count = 5;
            const float offsetY = 40;

            if (points != null)
            {
                using (Pen pen = new Pen(_signalColor, 0.0f))
                {
                    switch (mode)
                    {
                        case DrawingMode.DrawLines:
                            {
                                var pointsArray = points.ToArray();
                                for (int j = 0; j < count; j++)
                                {
                                    g.TranslateTransform(0, offsetY);
                                    g.DrawLines(pen, pointsArray);
                                }
                            } break;
                        case DrawingMode.GdiPlusDrawLine:
                            {
                                var gdip = ((GDIGraphics)g).Graphics;
                                for (int j = 0; j < count; j++)
                                {
                                    g.TranslateTransform(0, offsetY);
                                    for (int i = 1; i < points.Count; i++)
                                        gdip.DrawLine(pen, points[i - 1], points[i]);
                                }
                            } break;
                        case DrawingMode.Gdi32:
                            {
                                var gdip = ((GDIGraphics)g).Graphics;
                                for (int j = 0; j < count; j++)
                                {
                                    g.TranslateTransform(0, offsetY);
                                    gdip.DrawLinesGdi32(pen, points);
                                }
                            } break;
                        default:
                            break;
                    }
                }
            }
        }
开发者ID:filipkunc,项目名称:GLGraphics,代码行数:45,代码来源:Form1.cs

示例7: DrawRoundedSurface

        private void DrawRoundedSurface(IGraphics g, bool onScreen, Style style)
        {
            int diameter = GetRoundingSize(style) * 2;

            GraphicsPath borderPath = new GraphicsPath();
            borderPath.AddArc(Left, Top, diameter, diameter, 180, 90);
            borderPath.AddArc(Right - diameter, Top, diameter, diameter, 270, 90);
            borderPath.AddArc(Right - diameter, Bottom - diameter, diameter, diameter, 0, 90);
            borderPath.AddArc(Left, Bottom - diameter, diameter, diameter, 90, 90);
            borderPath.CloseFigure();

            // Draw shadow
            if ((!onScreen || !IsSelected) && !style.ShadowOffset.IsEmpty)
            {
                shadowBrush.Color = style.ShadowColor;
                g.TranslateTransform(style.ShadowOffset.Width, style.ShadowOffset.Height);
                g.FillPath(shadowBrush, borderPath);
                g.TranslateTransform(-style.ShadowOffset.Width, -style.ShadowOffset.Height);
            }

            // Draw background
            g.FillPath(backgroundBrush, borderPath);

            // Draw header background
            Region oldClip = g.Clip;
            g.SetClip(borderPath, CombineMode.Intersect);
            DrawHeaderBackground(g, style);
            g.Clip.Dispose();
            g.Clip = oldClip;

            // Draw border
            g.DrawPath(borderPen, borderPath);

            borderPath.Dispose();
        }
开发者ID:BachelorEric,项目名称:ModelFirst,代码行数:35,代码来源:TypeShape.cs

示例8: SetTransformMatrix

 /// <summary>
 /// Setup the Transform Matrix to handle drawing of this <see cref="XAxis"/>
 /// </summary>
 /// <param name="g">
 /// A graphic device object to be drawn into.  This is normally e.Graphics from the
 /// PaintEventArgs argument to the Paint() method.
 /// </param>
 /// <param name="pane">
 /// A reference to the <see cref="GraphPane"/> object that is the parent or
 /// owner of this object.
 /// </param>
 /// <param name="scaleFactor">
 /// The scaling factor to be used for rendering objects.  This is calculated and
 /// passed down by the parent <see cref="GraphPane"/> object using the
 /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
 /// font sizes, etc. according to the actual size of the graph.
 /// </param>
 public override void SetTransformMatrix( IGraphics g, GraphPane pane, float scaleFactor )
 {
     // Move the origin to the BottomLeft of the ChartRect, which is the left
     // side of the X axis (facing from the label side)
     g.TranslateTransform( pane.Chart._rect.Left, pane.Chart._rect.Bottom );
 }
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:23,代码来源:XAxis.cs

示例9: Draw

        /// <summary>
        /// Render this object to the specified <see cref="Graphics"/> device.
        /// </summary>
        /// <remarks>
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="GraphObjList"/> collection object.
        /// </remarks>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="PaneBase"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public override void Draw( IGraphics g, PaneBase pane, float scaleFactor )
        {
            // Convert the arrow coordinates from the user coordinate system
            // to the screen coordinate system
            PointF pix1 = this.Location.TransformTopLeft( pane );
            PointF pix2 = this.Location.TransformBottomRight( pane );

            if ( pix1.X > -10000 && pix1.X < 100000 && pix1.Y > -100000 && pix1.Y < 100000 &&
                pix2.X > -10000 && pix2.X < 100000 && pix2.Y > -100000 && pix2.Y < 100000 )
            {
                // calculate the length and the angle of the arrow "vector"
                double dy = pix2.Y - pix1.Y;
                double dx = pix2.X - pix1.X;
                float angle = (float)Math.Atan2( dy, dx ) * 180.0F / (float)Math.PI;
                float length = (float)Math.Sqrt( dx * dx + dy * dy );

                // Save the old transform matrix
                Matrix transform = g.Transform;
                // Move the coordinate system so it is located at the starting point
                // of this arrow
                g.TranslateTransform( pix1.X, pix1.Y );
                // Rotate the coordinate system according to the angle of this arrow
                // about the starting point
                g.RotateTransform( angle );

                // get a pen according to this arrow properties
                using ( Pen pen = _line.GetPen( pane, scaleFactor ) )
                //new Pen( _line._color, pane.ScaledPenWidth( _line._width, scaleFactor ) ) )
                {
                    //pen.DashStyle = _style;

                    g.DrawLine( pen, 0, 0, length, 0 );
                }

                // Restore the transform matrix back to its original state
                g.Transform = transform;
            }
        }
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:59,代码来源:LineObj.cs

示例10: DrawRectangleSurface

        private void DrawRectangleSurface(IGraphics g, bool onScreen, Style style)
        {
            // Draw shadow
            if ((!onScreen || !IsSelected) && !style.ShadowOffset.IsEmpty)
            {
                shadowBrush.Color = style.ShadowColor;
                g.TranslateTransform(style.ShadowOffset.Width, style.ShadowOffset.Height);
                g.FillRectangle(shadowBrush, BorderRectangle);
                g.TranslateTransform(-style.ShadowOffset.Width, -style.ShadowOffset.Height);
            }

            // Draw background
            backgroundBrush.Color = GetBackColor(style);
            g.FillRectangle(backgroundBrush, BorderRectangle);

            // Draw header background
            DrawHeaderBackground(g, style);

            // Draw border
            g.DrawRectangle(borderPen, BorderRectangle);
        }
开发者ID:BachelorEric,项目名称:ModelFirst,代码行数:21,代码来源:TypeShape.cs

示例11: DrawLabel

        public void DrawLabel(IGraphics g, PointF labelPoint, PointF offset, Font font, Color forecolor,
                                     Brush backcolor, Pen halo, float rotation, string text, Map map,
                                     LabelStyle.HorizontalAlignmentEnum alignment = LabelStyle.HorizontalAlignmentEnum.Left,
                                     PointF? rotationPoint = null)
        {
            //Calculate the size of the text
            var labelSize = RendererHelper.SizeOfString(g, text, font);

            //Add label offset
            labelPoint.X += offset.X;
            labelPoint.Y += offset.Y;

            //Translate alignment to stringalignment
            StringAlignment salign;
            switch (alignment)
            {
                case LabelStyle.HorizontalAlignmentEnum.Left:
                    salign = StringAlignment.Near;
                    break;
                case LabelStyle.HorizontalAlignmentEnum.Center:
                    salign = StringAlignment.Center;
                    break;
                default:
                    salign = StringAlignment.Far;
                    break;
            }

            if (rotation != 0 && !float.IsNaN(rotation))
            {
                rotationPoint = rotationPoint ?? labelPoint;

                PointF pt = rotationPoint.Value;
                g.FillEllipse(Brushes.LawnGreen, (int)(pt.X - 1), (int)(pt.Y - 1), 2, 2);

                var t = g.Transform.Clone();
                g.TranslateTransform(pt.X, pt.Y);
                g.RotateTransform(rotation);
                //g.TranslateTransform(-labelSize.Width/2, -labelSize.Height/2);

                labelPoint = new PointF(labelPoint.X - pt.X,
                                        labelPoint.Y - pt.Y);

                //labelSize = new SizeF(labelSize.Width*0.74f + 1f, labelSize.Height*0.74f);
                if (backcolor != null && backcolor != Brushes.Transparent)
                    g.FillRectangle(backcolor,
                        (int)labelPoint.X, (int)labelPoint.Y,
                        (int)labelSize.Width, (int)labelSize.Height);

                var path = new GraphicsPath();
                path.AddString(text, font.FontFamily, (int)font.Style, font.Size,
                               new RectangleF(labelPoint, labelSize) /* labelPoint*/,
                               new StringFormat { Alignment = salign } /*null*/);
                if (halo != null)
                    g.DrawPath(halo, path);

                g.FillPath(new SolidBrush(forecolor), path);
                //g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), 0, 0);        
                g.Transform = t;
            }
            else
            {
                if (backcolor != null && backcolor != Brushes.Transparent)
                    g.FillRectangle(backcolor,
                        (int)labelPoint.X, (int)labelPoint.Y,
                        (int)labelSize.Width, (int)labelSize.Height);

                var path = new GraphicsPath();
                path.AddString(text, font.FontFamily, (int)font.Style, font.Size,
                               new RectangleF(labelPoint, labelSize) /* labelPoint*/,
                               new StringFormat { Alignment = salign } /*null*/);
                if (halo != null)
                    g.DrawPath(halo, path);
                g.FillPath(new SolidBrush(forecolor), path);
                //g.DrawString(text, font, new System.Drawing.SolidBrush(forecolor), LabelPoint.X, LabelPoint.Y);
            }
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:76,代码来源:VectorRenderer.cs

示例12: SetTransformMatrix

 /// <summary>
 /// Setup the Transform Matrix to handle drawing of this <see cref="Y2Axis"/>
 /// </summary>
 /// <param name="g">
 /// A graphic device object to be drawn into.  This is normally e.Graphics from the
 /// PaintEventArgs argument to the Paint() method.
 /// </param>
 /// <param name="pane">
 /// A reference to the <see cref="GraphPane"/> object that is the parent or
 /// owner of this object.
 /// </param>
 /// <param name="scaleFactor">
 /// The scaling factor to be used for rendering objects.  This is calculated and
 /// passed down by the parent <see cref="GraphPane"/> object using the
 /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
 /// font sizes, etc. according to the actual size of the graph.
 /// </param>
 public override void SetTransformMatrix( IGraphics g, GraphPane pane, float scaleFactor )
 {
     // Move the origin to the BottomRight of the ChartRect, which is the left
     // side of the Y2 axis (facing from the label side)
     g.TranslateTransform( pane.Chart._rect.Right, pane.Chart._rect.Bottom );
     // rotate so this axis is in the left-right direction
     g.RotateTransform( -90 );
 }
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:25,代码来源:Y2Axis.cs

示例13: DrawSymbol

        /// <summary>
        /// Draw the <see cref="Symbol"/> to the specified <see cref="Graphics"/> device
        /// at the specified location.  This routine draws a single symbol.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="x">The x position of the center of the symbol in
        /// pixel units</param>
        /// <param name="y">The y position of the center of the symbol in
        /// pixel units</param>
        /// <param name="path">A <see cref="GraphicsPath"/> previously constructed by
        /// <see cref="MakePath"/> for this symbol</param>
        /// <param name="pen">A <see cref="Pen"/> class representing the standard pen for this symbol</param>
        /// <param name="brush">A <see cref="Brush"/> class representing a default solid brush for this symbol
        /// If this symbol uses a <see cref="LinearGradientBrush"/>, it will be created on the fly for
        /// each point, since it has to be scaled to the individual point coordinates.</param>
        private void DrawSymbol( IGraphics g, int x, int y, GraphicsPath path,
							Pen pen, Brush brush )
        {
            // Only draw if the symbol is visible
            if ( _isVisible &&
                    this.Type != SymbolType.None &&
                    x < 100000 && x > -100000 &&
                    y < 100000 && y > -100000 )
            {
                Matrix saveMatrix = g.Transform;
                g.TranslateTransform( x, y );

                // Fill or draw the symbol as required
                if ( _fill.IsVisible )
                    g.FillPath( brush, path );
                //FillPoint( g, x, y, scaleFactor, pen, brush );

                if ( _border.IsVisible )
                    g.DrawPath( pen, path );
                //DrawPoint( g, x, y, scaleFactor, pen );

                g.Transform = saveMatrix;
            }
        }
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:42,代码来源:Symbol.cs

示例14: Draw

        /// <summary>
        /// Render this object to the specified <see cref="Graphics"/> device.
        /// </summary>
        /// <remarks>
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="GraphObjList"/> collection object.
        /// </remarks>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="PaneBase"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public override void Draw( IGraphics g, PaneBase pane, float scaleFactor )
        {
            // Convert the arrow coordinates from the user coordinate system
            // to the screen coordinate system
            PointF pix1 = this.Location.TransformTopLeft( pane );
            PointF pix2 = this.Location.TransformBottomRight( pane );

            if ( pix1.X > -10000 && pix1.X < 100000 && pix1.Y > -100000 && pix1.Y < 100000 &&
                pix2.X > -10000 && pix2.X < 100000 && pix2.Y > -100000 && pix2.Y < 100000 )
            {
                // get a scaled size for the arrowhead
                float scaledSize = (float)( _size * scaleFactor );

                // calculate the length and the angle of the arrow "vector"
                double dy = pix2.Y - pix1.Y;
                double dx = pix2.X - pix1.X;
                float angle = (float)Math.Atan2( dy, dx ) * 180.0F / (float)Math.PI;
                float length = (float)Math.Sqrt( dx * dx + dy * dy );

                // Save the old transform matrix
                Matrix transform = g.Transform;
                // Move the coordinate system so it is located at the starting point
                // of this arrow
                g.TranslateTransform( pix1.X, pix1.Y );
                // Rotate the coordinate system according to the angle of this arrow
                // about the starting point
                g.RotateTransform( angle );

                // get a pen according to this arrow properties
                using ( Pen pen = _line.GetPen( pane, scaleFactor ) )
                    //new Pen( _color, pane.ScaledPenWidth( _penWidth, scaleFactor ) ) )
                {
                    //pen.DashStyle = _style;

                    // Only show the arrowhead if required
                    if ( _isArrowHead )
                    {
                        // Draw the line segment for this arrow
                        g.DrawLine( pen, 0, 0, length - scaledSize + 1, 0 );

                        // Create a polygon representing the arrowhead based on the scaled
                        // size
                        PointF[] polyPt = new PointF[4];
                        float hsize = scaledSize / 3.0F;
                        polyPt[0].X = length;
                        polyPt[0].Y = 0;
                        polyPt[1].X = length - scaledSize;
                        polyPt[1].Y = hsize;
                        polyPt[2].X = length - scaledSize;
                        polyPt[2].Y = -hsize;
                        polyPt[3] = polyPt[0];

                        using ( SolidBrush brush = new SolidBrush( _line._color ) )
                            // render the arrowhead
                            g.FillPolygon( brush, polyPt );
                    }
                    else
                        g.DrawLine( pen, 0, 0, length, 0 );
                }

                // Restore the transform matrix back to its original state
                g.Transform = transform;
            }
        }
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:85,代码来源:ArrowObj.cs

示例15: SetTransformMatrix

 /// <summary>
 /// Setup the Transform Matrix to handle drawing of this <see cref="X2Axis"/>
 /// </summary>
 /// <param name="g">
 /// A graphic device object to be drawn into.  This is normally e.Graphics from the
 /// PaintEventArgs argument to the Paint() method.
 /// </param>
 /// <param name="pane">
 /// A reference to the <see cref="GraphPane"/> object that is the parent or
 /// owner of this object.
 /// </param>
 /// <param name="scaleFactor">
 /// The scaling factor to be used for rendering objects.  This is calculated and
 /// passed down by the parent <see cref="GraphPane"/> object using the
 /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
 /// font sizes, etc. according to the actual size of the graph.
 /// </param>
 public override void SetTransformMatrix( IGraphics g, GraphPane pane, float scaleFactor )
 {
     // Move the origin to the TopLeft of the ChartRect, which is the left
     // side of the X2 axis (facing from the label side)
     g.TranslateTransform( pane.Chart._rect.Right, pane.Chart._rect.Top );
     //g.ScaleTransform( 1.0f, -1.0f );
     // rotate so this axis is in the right-left direction
     g.RotateTransform( 180 );
 }
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:26,代码来源:X2Axis.cs


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