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


C# System.Drawing.Drawing2D.GraphicsPath.Transform方法代码示例

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


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

示例1: DrawCurves

        /// <summary>
        /// Draw curves on graphics with transform and given pen
        /// </summary>
        static void DrawCurves(
            Graphics graphics,
            List<PointF[]> curves,
            System.Drawing.Drawing2D.Matrix transform,
            Pen pen)
        {
            foreach( PointF[] curve in curves )
              {
            System.Drawing.Drawing2D.GraphicsPath gPath = new System.Drawing.Drawing2D.GraphicsPath();
            if( curve.Length == 0 )
            {
              break;
            }
            if( curve.Length == 1 )
            {
              gPath.AddArc( new RectangleF( curve[0], new SizeF( 0.5f, 0.5f ) ), 0.0f, (float) Math.PI );
            }
            else
            {
              gPath.AddLines( curve );
            }
            if( transform != null )
              gPath.Transform( transform );

            graphics.DrawPath( pen, gPath );
              }
        }
开发者ID:Nakyoung,项目名称:FramingXsecAnalyzer,代码行数:30,代码来源:GeoSnoop.cs

示例2: ToPoints

        public List<Point> ToPoints(
    float angle,
    Rectangle rect)
        {
            // Create a GraphicsPath.
            System.Drawing.Drawing2D.GraphicsPath path =
                new System.Drawing.Drawing2D.GraphicsPath();

            path.AddRectangle(rect);

            // Declare a matrix that will be used to rotate the text.
            System.Drawing.Drawing2D.Matrix rotateMatrix =
                new System.Drawing.Drawing2D.Matrix();

            // Set the rotation angle and starting point for the text.
            rotateMatrix.RotateAt(180.0F, new PointF(10.0F, 100.0F));

            // Transform the text with the matrix.
            path.Transform(rotateMatrix);

            List<Point> results = new List<Point>();
            foreach(PointF p in path.PathPoints)
            {
                results.Add(new Point((int)p.X, (int)p.Y));
            }

            path.Dispose();

            return results;
        }
开发者ID:renyh1013,项目名称:dp2,代码行数:30,代码来源:ClipControl.cs

示例3: DrawLabel

        /// <summary>
        /// Draws labels in a specified rectangle
        /// </summary>
        /// <param name="g">The graphics object to draw to</param>
        /// <param name="labelText">The label text to draw</param>
        /// <param name="labelBounds">The rectangle of the label</param>
        /// <param name="symb">the Label Symbolizer to use when drawing the label</param>
        private static void DrawLabel(Graphics g, string labelText, RectangleF labelBounds, ILabelSymbolizer symb)
        {
            //Sets up the brushes and such for the labeling
            Brush foreBrush = new SolidBrush(symb.FontColor);
            Font textFont = symb.GetFont();
            StringFormat format = new StringFormat();
            format.Alignment = symb.Alignment;
            Pen borderPen = new Pen(symb.BorderColor);
            Brush backBrush = new SolidBrush(symb.BackColor);
            Brush haloBrush = new SolidBrush(symb.HaloColor);
            Pen haloPen = new Pen(symb.HaloColor);
            haloPen.Width = 2;
            haloPen.Alignment = System.Drawing.Drawing2D.PenAlignment.Outset;
            Brush shadowBrush = new SolidBrush(symb.DropShadowColor);

            //Text graphics path
            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
            gp.AddString(labelText, textFont.FontFamily, (int)textFont.Style, textFont.SizeInPoints * 96F / 72F, labelBounds, format);

            //Draws the text outline
            if (symb.BackColorEnabled && symb.BackColor != Color.Transparent)
            {
                if (symb.FontColor == Color.Transparent)
                {
                    System.Drawing.Drawing2D.GraphicsPath backgroundGP = new System.Drawing.Drawing2D.GraphicsPath();
                    backgroundGP.AddRectangle(labelBounds);
                    backgroundGP.FillMode = System.Drawing.Drawing2D.FillMode.Alternate;
                    backgroundGP.AddPath(gp, true);
                    g.FillPath(backBrush, backgroundGP);
                    backgroundGP.Dispose();
                }
                else
                {
                    g.FillRectangle(backBrush, labelBounds);
                }
            }

            //Draws the border if its enabled
            if (symb.BorderVisible && symb.BorderColor != Color.Transparent)
                g.DrawRectangle(borderPen, labelBounds.X, labelBounds.Y, labelBounds.Width, labelBounds.Height);

            //Draws the drop shadow                      
            if (symb.DropShadowEnabled && symb.DropShadowColor != Color.Transparent)
            {
                System.Drawing.Drawing2D.Matrix gpTrans = new System.Drawing.Drawing2D.Matrix();
                gpTrans.Translate(symb.DropShadowPixelOffset.X, symb.DropShadowPixelOffset.Y);
                gp.Transform(gpTrans);
                g.FillPath(shadowBrush, gp);
                gpTrans = new System.Drawing.Drawing2D.Matrix();
                gpTrans.Translate(-symb.DropShadowPixelOffset.X, -symb.DropShadowPixelOffset.Y);
                gp.Transform(gpTrans);
            }

            //Draws the text halo
            if (symb.HaloEnabled && symb.HaloColor != Color.Transparent)
                g.DrawPath(haloPen, gp);

            //Draws the text if its not transparent
            if (symb.FontColor != Color.Transparent)
                g.FillPath(foreBrush, gp);

            //Cleans up the rest of the drawing objects
            shadowBrush.Dispose();
            borderPen.Dispose();
            foreBrush.Dispose();
            backBrush.Dispose();
            haloBrush.Dispose();
            haloPen.Dispose();
        }
开发者ID:zhongshuiyuan,项目名称:mapwindowsix,代码行数:76,代码来源:MapLabelLayer.cs

示例4: Carte_Paint

        private void Carte_Paint(object sender, PaintEventArgs e)
        {
            int i;
            double w, h;
            //projet = ((Musliw.MusliW)(this.MdiParent)).projet;
            Graphics page = e.Graphics;

            //page.Clear(this.BackColor);

            w = this.Width;
            h = this.Height;

            Pen stylo = new Pen(fen.stylo_couleur, (int)fen.epaisseur);
            Font fonte = new Font(FontFamily.GenericSansSerif, 7,FontStyle.Bold);
            this.ForeColor = Color.Black;
            Brush brosse =new SolidBrush(fen.brosse_couleur);
            Brush brosse_texte = new SolidBrush(fen.couleur_texte);
            double dx = w / (projet.reseaux[nproj].xu - projet.reseaux[nproj].xl);
            double dy = h / (projet.reseaux[nproj].yu - projet.reseaux[nproj].yl);
            double deltax,deltay,voldeltax,voldeltay;
            double cx = 0.5f * (projet.reseaux[nproj].xu + projet.reseaux[nproj].xl);
            double cy = 0.5f * (projet.reseaux[nproj].yu + projet.reseaux[nproj].yl);

            //MessageBox.Show(xl.ToString() + " " + yu.ToString());
            PointF p1=new PointF();
            PointF p2 = new PointF();
            PointF p3 = new PointF();
            PointF p4 = new PointF();
            PointF p5 = new PointF();

            PointF[] points = new PointF[4] ;
               double angle=0,norme=0;
            double sinx = 0, cosx = 1;
            if (fen.volume_echelle < 1e-6f)
            {
                fen.volume_echelle = 1e-6f;
            }
            for (i = 0; i < projet.reseaux[nproj].links.Count; i++)
            {
                norme = fen.norme(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur);
                if ((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].is_visible == true && projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].is_visible == true && norme > 0) && (projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].is_valid == true && projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].is_valid == true))
                {

                    //page.DrawRectangle(stylo, 0f, 0f, 200, 200);
                    //MessageBox.Show(((res.nodes[i].x - res.xl) * delta).ToString() + " " + ((res.yu - res.nodes[i].y) * delta).ToString()+" "+w.ToString()+" "+h.ToString());
                deltax = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart+0.5f*fen.epaisseur);
                deltay = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart+0.5f*fen.epaisseur);
                cosx = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, 1);
                sinx = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, 1);

                    voldeltax = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur + projet.reseaux[projet.reseau_actif].links[i].volau / fen.volume_echelle);
                    voldeltay = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur + projet.reseaux[projet.reseau_actif].links[i].volau / fen.volume_echelle);
                    page.DrawLine(stylo, (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + deltay), (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + deltax),(float) (((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + deltay),(float) (((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + deltax));

                    p1.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + deltay);
                    p1.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + deltax);
                    p2.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + voldeltay);
                    p2.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + voldeltax);
                    p3.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + voldeltay);
                    p3.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + voldeltax);
                    p4.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + deltay);
                    p4.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + deltax);

                    System.Drawing.Drawing2D.GraphicsPath epaisseur = new System.Drawing.Drawing2D.GraphicsPath();
                    System.Drawing.Drawing2D.GraphicsPath texte_epaisseur = new System.Drawing.Drawing2D.GraphicsPath();
                    epaisseur.StartFigure();
                    points[0] = p1;
                    points[1] = p2;
                    points[2] = p3;
                    points[3] = p4;

                    epaisseur.AddPolygon(points);
                    epaisseur.CloseFigure();
                    //page.FillPath(brosse, epaisseur);
                    //page.FillPolygon(brosse, points);
                    //page.DrawPolygon(stylo,points);
                    epaisseur.Reset();
                    texte_epaisseur.StartFigure();
                    p5.X = 0.5f * (p3.X + p2.X);
                    p5.Y = 0.5f * (p3.Y + p2.Y);
                    texte_epaisseur.AddString(projet.reseaux[projet.reseau_actif].links[i].volau.ToString("0"), FontFamily.GenericSansSerif, 0, (float)fen.taille_texte, new PointF(p5.X, p5.Y), StringFormat.GenericDefault);
                    RectangleF encombrement = texte_epaisseur.GetBounds();
                    // texte_epaisseur.AddRectangle(encombrement);
                    //texte_epaisseur.AddPie(p5.X,p5.Y,2,2,0,360);

                    page.FillPolygon(brosse, points);
                    page.DrawPolygon(stylo, points);

                    if (encombrement.Width < fen.norme(p1.X, p4.X, p1.Y, p4.Y, 1) && projet.reseaux[projet.reseau_actif].links[i].volau > 0)
                    {
                        System.Drawing.Drawing2D.Matrix rotation = new System.Drawing.Drawing2D.Matrix();

                        if (cosx >= 0 && sinx <= 0)
                        {
                            angle = 180f * ((float)Math.Acos(cosx) / (float)Math.PI);
                            rotation.RotateAt((float)angle, p5);
                            rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
                            System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
                            texte_epaisseur.Transform(rotation);
                            trans.Translate((float)(-0.5f * encombrement.Width * cosx),(float)( 0.5f * encombrement.Width * sinx));
//.........这里部分代码省略.........
开发者ID:crocovert,项目名称:musliw,代码行数:101,代码来源:Carte.cs


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