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


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

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


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

示例1: DrawRoundRect

        /// <summary>
        /// 绘制圆角
        /// </summary>
        /// <param name="g"></param>
        /// <param name="p"></param>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="radius"></param>
        public static void DrawRoundRect(Graphics g, Pen p, Brush brush,float X, float Y, float width, float height, float radius)
        {
            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();

            gp.AddLine(X + radius, Y, X + width - (radius * 2), Y);

            gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90);

            gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2));

            gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90);

            gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height);

            gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90);

            gp.AddLine(X, Y + height - (radius * 2), X, Y + radius);

            gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90);

            gp.CloseFigure();

            g.DrawPath(p, gp);

            g.FillPath(brush, gp);

            gp.Dispose();
        }
开发者ID:jyorin,项目名称:yinghe,代码行数:38,代码来源:绘图类.cs

示例2: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            _theGame.Draw(e.Graphics, _interp);

            // draw fps
            var path = new System.Drawing.Drawing2D.GraphicsPath();
            Pen p = new Pen(Color.Black, 2.0f);
            path.AddString(String.Format("FPS: {0}", _fpsCalc.Fps),
                           FontFamily.GenericSansSerif, 0, 24f,
                           Point.Empty, StringFormat.GenericTypographic);
            e.Graphics.DrawPath(p, path);
            e.Graphics.FillPath(Brushes.White, path);
            p.Dispose();
            path.Dispose();

            _fpsCalc.DrawFrame(); // used for calculating FPS
        }
开发者ID:jsnklpn,项目名称:JGame,代码行数:18,代码来源:Form1.cs

示例3: DrawCharactorsOutLines

        private void DrawCharactorsOutLines(ref Graphics g)
        {
            System.Drawing.Drawing2D.GraphicsPath oOutline = new System.Drawing.Drawing2D.GraphicsPath();
            int iSymbolIndex = 0;
            g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;

            for (int i = 0; i < 16; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    string sCharactor = new string(Convert.ToChar(iSymbolIndex++), 1);
                    oOutline = new System.Drawing.Drawing2D.GraphicsPath();
                    oOutline.AddString(sCharactor, this._curFont.FontFamily, (int)FontStyle.Regular, this._fontSize - 7, new Point(j * this._fontSize, i * this._fontSize), StringFormat.GenericDefault);
                    g.FillPath(new SolidBrush(Color.Black), oOutline);
                    oOutline.Dispose();
                    //g.DrawString(sCharactor, this._curFont, new SolidBrush(Color.Black), new RectangleF(j * this._fontSize , i * this._fontSize, this._fontSize, this._fontSize), StringFormat.GenericTypographic);
                }
            }
        }
开发者ID:uwitec,项目名称:gvms,代码行数:19,代码来源:SymbolSelector.cs

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

示例5: set_jimaku

        private void set_jimaku()
        {
            System.Drawing.Drawing2D.GraphicsPath path =
            new System.Drawing.Drawing2D.GraphicsPath();

            int style = 0;
            style += (text.Font.Bold) ? (int)FontStyle.Bold : (int)FontStyle.Regular;
            style += (text.Font.Italic) ? (int)FontStyle.Italic : (int)FontStyle.Regular;
            style += (text.Font.Underline) ? (int)FontStyle.Underline : (int)FontStyle.Regular;
            style += (text.Font.Strikeout) ? (int)FontStyle.Strikeout : (int)FontStyle.Regular;
            path.AddString(text.Text, text.Font.FontFamily,
                style,
                (float)(text.Font.SizeInPoints / 0.75), new Point(0, 0),
                StringFormat.GenericDefault);
            myForm.Region = new Region(path);
            myForm.BackColor = text.ForeColor;
            path.Dispose();
        }
开发者ID:kikakubu-ksg,项目名称:N-layerJimaku,代码行数:18,代码来源:main.cs

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

示例7: DrawRoundedRectangleOutlined

 public static void DrawRoundedRectangleOutlined(Graphics gfxObj, Pen penObj, float X, float Y, float RectWidth, float RectHeight, float CornerRadius)
 {
     RectWidth--;
     RectHeight--;
     System.Drawing.Drawing2D.GraphicsPath gfxPath = new System.Drawing.Drawing2D.GraphicsPath();
     gfxPath.AddLine(X + CornerRadius, Y, X + RectWidth - (CornerRadius * 2), Y);
     gfxPath.AddArc(X + RectWidth - (CornerRadius * 2), Y, CornerRadius * 2, CornerRadius * 2, 270, 90);
     gfxPath.AddLine(X + RectWidth, Y + CornerRadius, X + RectWidth, Y + RectHeight - (CornerRadius * 2));
     gfxPath.AddArc(X + RectWidth - (CornerRadius * 2), Y + RectHeight - (CornerRadius * 2), CornerRadius * 2, CornerRadius * 2, 0, 90);
     gfxPath.AddLine(X + RectWidth - (CornerRadius * 2), Y + RectHeight, X + CornerRadius, Y + RectHeight);
     gfxPath.AddArc(X, Y + RectHeight - (CornerRadius * 2), CornerRadius * 2, CornerRadius * 2, 90, 90);
     gfxPath.AddLine(X, Y + RectHeight - (CornerRadius * 2), X, Y + CornerRadius);
     gfxPath.AddArc(X, Y, CornerRadius * 2, CornerRadius * 2, 180, 90);
     gfxPath.CloseFigure();
     gfxObj.DrawPath(penObj, gfxPath);
     gfxPath.Dispose();
 }
开发者ID:alandoherty,项目名称:dermadesignerb,代码行数:17,代码来源:Derma.cs

示例8: DrawRoundRect

        // Zeichnet das Rechteck mit abgerundeten Ecken der Termindetails
        public void DrawRoundRect(Graphics g, Pen p, float x, float y, float width, float height, float radius)
        {
            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();

            gp.AddLine(x + radius, y, x + width - (radius * 2), y); // Line
            gp.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90); // Corner
            gp.AddLine(x + width, y + radius, x + width, y + height - (radius * 2)); // Line
            gp.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90); // Corner
            gp.AddLine(x + width - (radius * 2), y + height, x + radius, y + height); // Line
            gp.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90); // Corner
            gp.AddLine(x, y + height - (radius * 2), x, y + radius); // Line
            gp.AddArc(x, y, radius * 2, radius * 2, 180, 90); // Corner
            gp.CloseFigure();

            g.DrawPath(p, gp);
            gp.Dispose();
        }
开发者ID:Totti1987,项目名称:Terminverwaltung,代码行数:18,代码来源:Terminansicht.cs

示例9: Carte_Paint


//.........这里部分代码省略.........
                    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));
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();
                            page.FillPath(brosse_texte, texte_epaisseur);

                        }
                        else if (cosx <= 0 && sinx >= 0)
                        {
                            angle = 180f - 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 + (encombrement.Height) * sinx),(float)( -0.5f * encombrement.Width * sinx + (encombrement.Height) * cosx));
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();

                            page.FillPath(brosse_texte, texte_epaisseur);

                        }
                        else 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));
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();

                            page.FillPath(brosse_texte, texte_epaisseur);
                        }
                        else if (cosx <= 0 && sinx <= 0)
                        {
                            angle = 180 + 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 + (encombrement.Height) * sinx),(float)( -0.5f * encombrement.Width * sinx + (encombrement.Height) * cosx));
                            texte_epaisseur.Transform(trans);
                            texte_epaisseur.CloseFigure();

                            page.FillPath(brosse_texte, texte_epaisseur);
                        }

                    }
                    epaisseur.Dispose();
                    texte_epaisseur.Dispose();
                }

            }
            /*        for (i = 0; i < projet.reseaux[nproj].nodes.Count; i++)
            {
                if (projet.reseaux[nproj].nodes[i].i != 0)
                {
                    //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());
                    page.FillRectangle(brosse, (res.nodes[i].x - res.xl) * delta, (res.yu - res.nodes[i].y) * delta, 30f, 20f);
                    page.DrawRectangle(stylo, (res.nodes[i].x - res.xl) * delta, (res.yu - res.nodes[i].y) * delta, 30f, 20f);
                    page.DrawString(res.nodes[i].i.ToString(), fonte, Brushes.Black, new RectangleF((res.nodes[i].x - res.xl) * delta, (res.yu - res.nodes[i].y) * delta, 30f, 20f));
                }
            }*/
        }
开发者ID:crocovert,项目名称:musliw,代码行数:101,代码来源:Carte.cs

示例10: drawQuadTex

 void drawQuadTex(Graphics g, Bitmap tex, PointF[] quad) {
     System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
     gp.AddPolygon(new PointF[] { quad[0], quad[1], quad[3] });
     g.SetClip(gp, System.Drawing.Drawing2D.CombineMode.Replace);
     g.DrawImage(tex, new PointF[] { quad[0], quad[1], quad[3] });
     gp.Reset();
     gp.AddPolygon(new PointF[] { quad[2], quad[3], quad[1] });
     g.SetClip(gp, System.Drawing.Drawing2D.CombineMode.Replace);
     tex.RotateFlip(RotateFlipType.Rotate180FlipNone);
     g.DrawImage(tex, new PointF[] { quad[2], quad[3], quad[1] });
     tex.RotateFlip(RotateFlipType.Rotate180FlipNone);
     gp.Dispose();
     g.ResetClip();
 }
开发者ID:nastys,项目名称:Uwizard,代码行数:14,代码来源:Form1.cs

示例11: Paint

        /// <summary>
        /// Repaints the form with cool background and stuff
        /// </summary>
        /// <param name="graph">The graphics object to paint to, the element will be drawn to 0,0</param>
        public virtual void Paint(Graphics graph)
        {
            //Sets up the colors to use
            Pen outlinePen = new Pen(MapWindow.Main.Global.ColorFromHSL(Color.GetHue(), Color.GetSaturation(), Color.GetBrightness() * 0.6 * Highlight), 1.75F);
            Color gradientTop = MapWindow.Main.Global.ColorFromHSL(Color.GetHue(), Color.GetSaturation(), Color.GetBrightness() * 0.7 * Highlight);
            Color gradientBottom = MapWindow.Main.Global.ColorFromHSL(Color.GetHue(), Color.GetSaturation(), Color.GetBrightness() * 1.0 * Highlight);

            //The path used for drop shadows
            System.Drawing.Drawing2D.GraphicsPath shadowPath = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Drawing2D.ColorBlend colorBlend = new System.Drawing.Drawing2D.ColorBlend(3);
            colorBlend.Colors = new Color[] { Color.Transparent, Color.FromArgb(180, Color.DarkGray), Color.FromArgb(180, Color.DimGray) };
            colorBlend.Positions = new float[] { 0f, 0.125f,1f};

            //Draws Rectangular Shapes
            if (Shape == ModelShapes.Rectangle)
            {
                //Draws the shadow
                shadowPath.AddPath(GetRoundedRect(new Rectangle(5, 5, this.Width, this.Height), 10), true);
                System.Drawing.Drawing2D.PathGradientBrush shadowBrush = new System.Drawing.Drawing2D.PathGradientBrush(shadowPath);
                shadowBrush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
                shadowBrush.InterpolationColors = colorBlend;
                graph.FillPath(shadowBrush, shadowPath);

                //Draws the basic shape
                System.Drawing.Rectangle fillRectange = new Rectangle(0, 0, this.Width - 5, this.Height - 5);
                System.Drawing.Drawing2D.GraphicsPath fillArea = GetRoundedRect(fillRectange, 5);
                System.Drawing.Drawing2D.LinearGradientBrush myBrush = new System.Drawing.Drawing2D.LinearGradientBrush(fillRectange, gradientBottom, gradientTop, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
                graph.FillPath(myBrush, fillArea);
                graph.DrawPath(outlinePen, fillArea);
                
                //Draws the status light
                drawStatusLight(graph);
                
                //Draws the text
                SizeF textSize = graph.MeasureString(Name, Font, this.Width);
                RectangleF textRect;
                if ((textSize.Width < this.Width) || (textSize.Height < this.Height))
                    textRect = new RectangleF((this.Width - textSize.Width) / 2, (this.Height - textSize.Height) / 2, textSize.Width, textSize.Height);
                else
                    textRect = new RectangleF(0, (this.Height - textSize.Height) / 2, this.Width, textSize.Height);
                graph.DrawString(Name, Font, new SolidBrush(Color.FromArgb(50, Color.Black)), textRect);
                textRect.X = textRect.X - 1;
                textRect.Y = textRect.Y - 1;
                graph.DrawString(Name, Font, System.Drawing.Brushes.Black, textRect);

                //Garbage collection
                fillArea.Dispose();
                myBrush.Dispose();
            }

            //Draws Ellipse Shapes
            if (_shape == ModelShapes.Ellipse)
            {
                //Draws the shadow
                shadowPath.AddEllipse(0, 5, this.Width+5, this.Height);
                System.Drawing.Drawing2D.PathGradientBrush shadowBrush = new System.Drawing.Drawing2D.PathGradientBrush(shadowPath);
                shadowBrush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
                shadowBrush.InterpolationColors = colorBlend;
                graph.FillPath(shadowBrush, shadowPath);

                //Draws the Ellipse
                System.Drawing.Rectangle fillArea = new Rectangle(0, 0, this.Width, this.Height);
                System.Drawing.Drawing2D.LinearGradientBrush myBrush = new System.Drawing.Drawing2D.LinearGradientBrush(fillArea, gradientBottom, gradientTop, System.Drawing.Drawing2D.LinearGradientMode.Vertical);
                graph.FillEllipse(myBrush, 1, 1, this.Width - 5, this.Height - 5);
                graph.DrawEllipse(outlinePen, 1, 1, this.Width - 5, this.Height - 5);

                //Draws the text
                SizeF textSize = graph.MeasureString(_name, _font, this.Width);
                RectangleF textRect;
                if ((textSize.Width < this.Width) || (textSize.Height < this.Height))
                    textRect = new RectangleF((this.Width - textSize.Width) / 2, (this.Height - textSize.Height) / 2, textSize.Width, textSize.Height);
                else
                    textRect = new RectangleF(0, (this.Height - textSize.Height) / 2, this.Width, textSize.Height);
                graph.DrawString(Name, Font, new SolidBrush(Color.FromArgb(50, Color.Black)), textRect);
                textRect.X = textRect.X - 1;
                textRect.Y = textRect.Y - 1;
                graph.DrawString(Name, Font, System.Drawing.Brushes.Black, textRect);

                //Garbage collection
                myBrush.Dispose();
            }

            //Draws Triangular Shapes
            if (_shape == ModelShapes.Triangle)
            {
                //Draws the shadow
                Point[] ptShadow = new Point[4];
                ptShadow[0] = new Point(5, 5);
                ptShadow[1] = new Point(this.Width + 5, ((this.Height - 5) / 2) + 5);
                ptShadow[2] = new Point(5, this.Height+2);
                ptShadow[3] = new Point(5, 5);
                shadowPath.AddLines(ptShadow);
                System.Drawing.Drawing2D.PathGradientBrush shadowBrush = new System.Drawing.Drawing2D.PathGradientBrush(shadowPath);
                shadowBrush.WrapMode = System.Drawing.Drawing2D.WrapMode.Clamp;
                shadowBrush.InterpolationColors = colorBlend;
                graph.FillPath(shadowBrush, shadowPath);
//.........这里部分代码省略.........
开发者ID:zhongshuiyuan,项目名称:mapwindowsix,代码行数:101,代码来源:ModelElement.cs

示例12: UnderLine

        public ActionResult UnderLine()
        {
            string sVirtualPath = @"/Content/File/UnderLine/";

            //web请求
            HttpServerUtility httpServerUtility = System.Web.HttpContext.Current.Server;
            if (!Directory.Exists(httpServerUtility.MapPath(sVirtualPath)))
            {
                //按虚拟路径创建所有目录和子目录
                Directory.CreateDirectory(@httpServerUtility.MapPath(sVirtualPath));
            }

            string index = "1";
            string reIndex = Request["index"];
            if (!string.IsNullOrEmpty(reIndex))
            {
                int n;
                index = int.TryParse(reIndex, out n) ? n.ToString() : "1";
            }

            lock (temp)
            {
                string dFilePath = Server.MapPath(sVirtualPath + "UnderLine" + index + ".png");

                //判断图片是否存在
                #region 验证空格图片是否存在
                if (System.IO.File.Exists(dFilePath))
                {
                    Response.ClearContent(); //需要输出图象信息 要修改HTTP头
                    Response.ContentType = "image/Png";
                    Response.BinaryWrite(System.IO.File.ReadAllBytes(dFilePath));
                    Response.End();
                }
                #endregion

                #region 创建新空格图片
                else
                {
                    string filePath = Server.MapPath(sVirtualPath + "UnderLine.gif");
                    Bitmap bgImg = (Bitmap)Bitmap.FromFile(filePath);

                    int width = 36;
                    int height = 18;

                    Bitmap theBitmap = new Bitmap(width, height);
                    Graphics theGraphics = Graphics.FromImage(theBitmap);
                    theGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                    theGraphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                    theGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                    theGraphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                    //  白色背景
                    //theGraphics.Clear(Color.White);
                    theGraphics.DrawImage(bgImg, new Rectangle(0, 0, width, height), new Rectangle(0, 0, bgImg.Width, bgImg.Height), GraphicsUnit.Pixel);
                    //13pt的字体
                    float fontSize = height * 1.0f / 1.38f;
                    Font theFont = new Font("Arial", fontSize);
                    System.Drawing.Drawing2D.GraphicsPath gp = null;

                    int indLen = index.Length;

                    Point thePos = new Point((int)(fontSize - (indLen > 1 ? indLen * 2.5 : indLen * 2)), 2);
                    gp = new System.Drawing.Drawing2D.GraphicsPath();
                    gp.AddString(index, theFont.FontFamily, 0, fontSize, thePos, new StringFormat());

                    theGraphics.DrawPath(new Pen(Color.White, 2f), gp);
                    theGraphics.FillPath(new SolidBrush(Color.Red), gp);
                    theGraphics.ResetTransform();

                    if (gp != null) gp.Dispose();

                    //  将生成的图片发回客户端
                    MemoryStream ms = new MemoryStream();
                    theBitmap.Save(ms, ImageFormat.Png);

                    //保存文件
                    theBitmap.Save(dFilePath);

                    Response.ClearContent(); //需要输出图象信息 要修改HTTP头
                    Response.ContentType = "image/Png";
                    Response.BinaryWrite(ms.ToArray());
                    theGraphics.Dispose();
                    theBitmap.Dispose();
                    Response.End();
                }
                #endregion
            }

            return View();
        }
开发者ID:kaiss78,项目名称:online-exam-shihuang,代码行数:89,代码来源:SharedController.cs

示例13: DrawRoundRect

 private void DrawRoundRect(Graphics g, float x, float y, float width, float height, float radius, Color color)
 {
     System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
     gp.AddLine(x + radius, y, x + width - (radius * 2), y); //追加线段
     gp.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90);  //追加椭圆弧
     gp.AddLine(x + width, y + radius, x + width, y + height - (radius * 2));
     gp.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90);
     gp.AddLine(x + width - (radius * 2), y + height, x + radius, y + height);
     gp.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90);
     gp.AddLine(x, y + height - (radius * 2), x, y + radius);
     gp.AddArc(x, y, radius * 2, radius * 2, 180, 90);
     gp.CloseFigure();
     Pen pen = new System.Drawing.Pen(ColorTranslator.FromHtml("#CCCCCC"), 1);
     g.DrawPath(pen, gp);
     Rectangle rec = new Rectangle((int)x, (int)y, (int)width, (int)height);
     Brush brush = new System.Drawing.SolidBrush(color);
     g.FillPath(brush, gp);
     gp.Dispose();
 }
开发者ID:sunpander,项目名称:VSDT,代码行数:19,代码来源:ListControl.cs


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