• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Pen类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Pen的典型用法代码示例。如果您正苦于以下问题:C# Pen类的具体用法?C# Pen怎么用?C# Pen使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Pen类属于命名空间,在下文中一共展示了Pen类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Player

        /// <summary>
        ///     Initializes a new Player class.
        /// </summary>
        /// <param name="texture">The Texture.</param>
        /// <param name="texture2">The ErasedTexture.</param>
        public Player(Texture2D texture, Texture2D texture2)
        {
            _erased = texture2;
            Bounds = new Polygon(new Vector2(1, 6), new Vector2(5, 4), new Vector2(11, 0), new Vector2(22, 0), new Vector2(28, 6),
                new Vector2(28, 11), new Vector2(31, 15), new Vector2(28, 21), new Vector2(19, 21), new Vector2(18, 23),
                new Vector2(9, 23), new Vector2(0, 13), new Vector2(1, 7));
            _pen = new Pen(Color.White, 1);
            _spriteSheet = new AnimatedSpriteSheet(texture) {AutoUpdate = true};
            _spriteSheet.Add(new Keyframe(new Rectangle(0, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(32, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(64, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(96, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(128, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(160, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(192, 0, 32, 24), 100));

            _spriteSheet.Add(new Keyframe(new Rectangle(224, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(256, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(288, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(320, 0, 32, 24), 100));
            _spriteSheet.Add(new Keyframe(new Rectangle(352, 0, 32, 24), 100));

            Position = new Vector2(300, 230);
            Velocity = new Vector2(0, 0);
        }
开发者ID:ThuCommix,项目名称:Sharpex2D,代码行数:30,代码来源:Player.cs


示例2: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     Response.Clear();
     Response.ContentType = "image/bmp";
     string st = "",s="";
     Random rnd = new Random();
     Int32 num=0,ch=0;
     for (int i = 0; i < 5; i++)
     {
         ch=rnd.Next(2);
         if (ch == 0)
             num = rnd.Next(65, 91);
         if (ch == 0)
             num = rnd.Next(97, 122);
         else
             num = rnd.Next(48, 57);
         s += (Convert.ToChar(num)).ToString();
         st += (Convert.ToChar(num)).ToString() + " ";
     }
     Session.Add("captcha", s);
     Bitmap bmp = new Bitmap(210, 80);
     Graphics g = Graphics.FromImage(bmp);
     Pen p = new Pen(Color.Aqua);
     HatchBrush br = new HatchBrush(HatchStyle.DottedGrid, Color.Aqua, Color.LightGray);
     SolidBrush b = new SolidBrush(Color.Goldenrod);
     Font f = new Font("Chillar", 36);
     g.FillRectangle(br, new Rectangle(0, 0, 210, 80));
     g.DrawString(st, f, b, new Point(5, 5));
     bmp.Save(Response.OutputStream, ImageFormat.Bmp);
     g.DrawLine(p, 20, 10, 210, 80);
 }
开发者ID:rrumelaroy,项目名称:E-JOURNAL,代码行数:31,代码来源:ejourn_captcha.aspx.cs


示例3: setPen

    public Pen setPen(Cell cell, string side)
    {
        Pen myPen = new Pen(Brushes.Gray, 3);
        if (side == "right" && cell.rightSideIsHighlighted == true)
        {
            myPen.Color = Color.Orange;
            myPen.Width = 6;
        }
        if (side == "bottom" && cell.bottomSideIsHighlighted == true)
        {
            myPen.Color = Color.Orange;
            myPen.Width = 6;
        }

        if (side == "right" && cell.hasRightWall == true)
        {
            myPen.Color = Color.Black;
            myPen.Width = 6;
        }

        if (side == "bottom" && cell.hasBottomWall == true)
        {
            myPen.Color = Color.Black;
            myPen.Width = 6;
        }

        return myPen;
    }
开发者ID:Beansy,项目名称:NickLevelDesigner,代码行数:28,代码来源:Drawer.cs


示例4: Star

    public Star(int x, int y, int width, int height)
    {
        Pen pen = new Pen (Color.Black);

        int numPoints = 5;
        Point[] pts = new Point[numPoints];
        double rx = width / 2;
        double ry = height / 2;
        double cx = x + rx;
        double cy = y + ry;

        double theta = -Math.PI / 2;
        double dtheta = 4 * Math.PI / numPoints;
        int i;
        for (i = 0; i < numPoints; i++)
        {
            pts [i] = new Point (Convert.ToInt32(cx + rx * Math.Cos (theta)),
                                 Convert.ToInt32(cy + ry * Math.Sin (theta)));
            theta += dtheta;
        }

        for (i = 0; i < numPoints; i++)
        {
            Geo l;
            Geometrie.Add(l = new Line(pts[i].X,
                                        pts[i].Y,
                                        pts[(i+1) % numPoints].X,
                                        pts[(i+1) % numPoints].Y));
        }
    }
开发者ID:bramboomen,项目名称:mso4,代码行数:30,代码来源:Star.cs


示例5: CreateImage

    private void CreateImage()
    {
        string code = GetRandomText();

        Bitmap bitmap = new Bitmap(200, 50, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

        Graphics g = Graphics.FromImage(bitmap);
        Pen pen = new Pen(Color.Yellow);
        Rectangle rect = new Rectangle(0, 0, 200, 50);

        SolidBrush b = new SolidBrush(Color.Black);
        SolidBrush blue = new SolidBrush(Color.Blue);

        int counter = 0;

        g.DrawRectangle(pen, rect);
        g.FillRectangle(b, rect);

        for (int i = 0; i < code.Length; i++)
        {
            g.DrawString(code[i].ToString(), new Font("Verdena", 10 + rand.Next(14, 18)), blue, new PointF(10 + counter, 10));
            counter += 20;
        }

        DrawRandomLines(g);

        bitmap.Save(Response.OutputStream, ImageFormat.Gif);

        g.Dispose();
        bitmap.Dispose();
    }
开发者ID:karimkhanp,项目名称:Online_Education_Examinations,代码行数:31,代码来源:CaptchaControl.aspx.cs


示例6: DrawLine

 public static void DrawLine(this ICanvas canvas, Point start, Point end, Pen pen)
 {
     var p = new Path { Pen = pen };
     p.MoveTo(start,false);
     p.LineTo(end);
     p.Draw(canvas);
 }
开发者ID:JoshuaNovak919,项目名称:NGraphics,代码行数:7,代码来源:ICanvas.cs


示例7: RenderRectangle

        protected internal override void RenderRectangle(Bitmap bmp, Pen pen, int x, int y, int width, int height)
        {
            Color outlineColor = (pen != null) ? pen.Color : (Color)0x0;
            ushort outlineThickness = (pen != null) ? pen.Thickness : (ushort)0;

            int x1, y1;
            int x2, y2;

            switch (MappingMode)
            {
                case BrushMappingMode.RelativeToBoundingBox:
                    x1 = x + (int)((long)(width - 1) * StartX / RelativeBoundingBoxSize);
                    y1 = y + (int)((long)(height - 1) * StartY / RelativeBoundingBoxSize);
                    x2 = x + (int)((long)(width - 1) * EndX / RelativeBoundingBoxSize);
                    y2 = y + (int)((long)(height - 1) * EndY / RelativeBoundingBoxSize);
                    break;
                default: //case BrushMappingMode.Absolute:
                    x1 = StartX;
                    y1 = StartY;
                    x2 = EndX;
                    y2 = EndY;
                    break;
            }

            bmp.DrawRectangle((MSMedia.Color)outlineColor, outlineThickness, x, y, width, height, 0, 0, (MSMedia.Color)StartColor, x1, y1, (MSMedia.Color)EndColor, x2, y2, Opacity);
        }
开发者ID:KonstantinKolesnik,项目名称:Typhoon,代码行数:26,代码来源:LinearGradientBrush.cs


示例8: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     //新建一个Bitmap对象
     using (Bitmap image = new Bitmap(300, 200))
     {
         //根据Bitmap对象创建一个相关的Graphics对象,用于绘制。
         using (Graphics g = Graphics.FromImage(image))
         {
             //调用Graphics的FillRectangle方法来绘制一个矩形。
             g.FillRectangle(Brushes.White, 1, 1, 295, 195);
             //初始化一个字体
             Font font = new Font("Verdana",20, FontStyle.Regular|FontStyle.Bold);
             Pen pen = new Pen(Brushes.Black, 8);
             Rectangle rec=new Rectangle(10, 60, 220, 100);
             //设置SmoothingMode为支持抗锯齿功能
             g.SmoothingMode = SmoothingMode.AntiAlias;
             //为文字添加防锯齿效果
             g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
             g.DrawEllipse(pen,rec);
             g.FillEllipse(Brushes.Green, rec);
             //调用DrawingString方法在画布上绘制文本。
             g.DrawString("使用GDI+绘图", font, Brushes.Silver, 5, 2);
             Image icon = Image.FromFile(Server.MapPath("~/Images/A001.bmp"));
             g.DrawImage(icon, 210, 10, 80, 50);
             //将图像以Gif格式保存到指定的输入二进制流中
             image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
         }
     }
 }
开发者ID:AJLoveChina,项目名称:workAtQmm,代码行数:29,代码来源:SmoothImage.aspx.cs


示例9: SetLineCap

		public void SetLineCap (Pen widget, PenLineCap lineCap)
		{
			var pen = widget.ToSD ();
			pen.StartCap = pen.EndCap = lineCap.ToSD ();
			pen.DashCap = lineCap == PenLineCap.Round ? sd2.DashCap.Round : sd2.DashCap.Flat;
			SetDashStyle (widget, widget.DashStyle);
		}
开发者ID:JohnACarruthers,项目名称:Eto,代码行数:7,代码来源:PenHandler.cs


示例10: pensAreEqual

        private static Boolean pensAreEqual(Pen p1, Pen p2)
        {
            if (ReferenceEquals(p1, p2))
            {
                return true;
            }

            if (p1 == null || p2 == null)
            {
                return false;
            }

            if (p1.Alignment != p2.Alignment) return false;
            if (!brushesAreEqual(p1.Brush, p2.Brush)) return false;
            if (p1.Color != p2.Color) return false;
            if (!elementsAreEqual(p1.CompoundArray, p2.CompoundArray)) return false;
            if (p1.DashStyle == DashStyle.Custom && p1.CustomEndCap != p2.CustomEndCap) return false;
            if (p1.DashStyle == DashStyle.Custom && p1.CustomStartCap != p2.CustomStartCap) return false;
            if (p1.DashCap != p2.DashCap) return false;
            if (p1.DashOffset != p2.DashOffset) return false;
            if (p1.DashStyle == DashStyle.Custom && !elementsAreEqual(p1.DashPattern, p2.DashPattern)) return false;
            if (p1.DashStyle != p2.DashStyle) return false;
            if (p1.EndCap != p2.EndCap) return false;
            if (p1.LineJoin != p2.LineJoin) return false;
            if (p1.MiterLimit != p2.MiterLimit) return false;
            if (p1.PenType != p2.PenType) return false;
            if (p1.StartCap != p2.StartCap) return false;
            if (!elementsAreEqual(p1.Transform.Elements, p2.Transform.Elements)) return false;
            if (p1.Width != p2.Width) return false;

            return true;
        }
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:32,代码来源:GdiVectorRendererTests.cs


示例11: OnPaint

    protected override void OnPaint(PaintEventArgs pevent)
    {
        var g = pevent.Graphics;
        g.SmoothingMode = SmoothingMode.AntiAlias;
        g.Clear(Parent.BackColor);

        var checkMarkLine = new Rectangle(1, 1, 16, 16);
        var checkmarkPath = DrawHelper.CreateRoundRect(1, 1, 17, 17, 1);

        EnabledCheckedColor = HexColor;
        SolidBrush BG = new SolidBrush(Enabled ? Checked ? EnabledCheckedColor : EnabledUnCheckedColor : DisabledColor);
        Pen Pen = new Pen(BG.Color);

        g.FillPath(BG, checkmarkPath);
        g.DrawPath(Pen, checkmarkPath);

        g.SmoothingMode = SmoothingMode.None;
        g.FillRectangle(new SolidBrush(Color.White), PointAnimationNum, PointAnimationNum, SizeAnimationNum, SizeAnimationNum);
        g.SmoothingMode = SmoothingMode.AntiAlias;
      
        //CheckMark
        g.DrawImageUnscaledAndClipped(CheckMarkBitmap(), checkMarkLine);
        
        //CheckBox Text
        g.DrawString(Text, font.Roboto_Medium10, new SolidBrush(Enabled ? EnabledStringColor : DisabledStringColor), 21, 0);
    }
开发者ID:mr-amini,项目名称:ComU,代码行数:26,代码来源:LollipopCheckBox.cs


示例12: Element

 public Element(Pen pen, BaseBrush brush)
 {
     Id = Guid.NewGuid().ToString();
     Pen = pen;
     Brush = brush;
     Transform = Transform.Identity;
 }
开发者ID:JoshuaNovak919,项目名称:NGraphics,代码行数:7,代码来源:Element.cs


示例13: DrawCircle

    /// <summary>
    /// Draws a circle
    /// </summary>
    /// <param name="x">The x coordinate of the square containing this circle</param>
    /// <param name="y">The y coordinate of the square containing this circle</param>
    /// <param name="s">The size (or weight/height) of the circle</param>
    /// <param name="color">The color of the circle border</param>
    public override void DrawCircle(int x, int y, int s, Color color)
    {
        //Create a pen
        Pen pen = new Pen(color);

        Canvas.DrawEllipse(pen, x, y, s, s);
    }
开发者ID:Tyskai,项目名称:ShapesOpdracht3,代码行数:14,代码来源:VisualGraphic.cs


示例14: DrawLine

    /// <summary>
    /// Draws a rectangle
    /// </summary>
    /// <param name="p1">The starting point of the line</param>
    /// <param name="p2">The end point of the line</param>
    /// <param name="color">The color of the line</param>
    public override void DrawLine(Point p1, Point p2, Color color)
    {
        //Create a pen
        Pen pen = new Pen(color);

        Canvas.DrawLine(pen, p1, p2);
    }
开发者ID:Tyskai,项目名称:ShapesOpdracht3,代码行数:13,代码来源:VisualGraphic.cs


示例15: CreateImage

    private void CreateImage()
    {
        Session["captcha.guid"] = Guid.NewGuid().ToString ("N");
        string code = GetRandomText();

        Bitmap bitmap = new Bitmap(WIDTH,HEIGHT,System.Drawing.Imaging.PixelFormat.Format32bppArgb);

        Graphics g = Graphics.FromImage(bitmap);
        Pen pen = new Pen(Color.DarkSlateGray);
        Rectangle rect = new Rectangle(0,0,WIDTH,HEIGHT);

        SolidBrush background = new SolidBrush(Color.AntiqueWhite);
        SolidBrush textcolor = new SolidBrush(Color.DarkSlateGray);

        int counter = 0;

        g.DrawRectangle(pen, rect);
        g.FillRectangle(background, rect);

        for (int i = 0; i < code.Length; i++)
        {
            g.DrawString(code[i].ToString(),
                         new Font("Verdana", 10 + rand.Next(6, 14)),
                         textcolor,
                         new PointF(10 + counter, 10));
            counter += 25;
        }

        DrawRandomLines(g);

        bitmap.Save(Response.OutputStream,ImageFormat.Gif);

        g.Dispose();
        bitmap.Dispose();
    }
开发者ID:nageshverma2003,项目名称:TrackProtectSource,代码行数:35,代码来源:CaptchaControl.aspx.cs


示例16: CreateImage

    /// <summary>
    /// ����ͼƬ
    /// </summary>
    /// <param name="checkCode">�����</param>
    private void CreateImage(string checkCode)
    {
        int iwidth = (int)(checkCode.Length * 11.5);//����������趨ͼƬ���
        Bitmap image = new Bitmap(iwidth, 20);//����һ������
        Graphics g = Graphics.FromImage(image);//�ڻ����϶����ͼ��ʵ��
        Font f = new Font("Arial",10,FontStyle.Bold);//���壬��С����ʽ
        Brush b = new SolidBrush(Color.Black);//������ɫ
        //g.FillRectangle(new System.Drawing.SolidBrush(Color.Blue),0,0,image.Width, image.Height);
        g.Clear(Color.White);//������ɫ
        g.DrawString(checkCode, f, b, 3, 3);

        Pen blackPen = new Pen(Color.Black, 0);
        Random rand = new Random();
        /*�����
        for (int i = 0; i < 5; i++)
        {
            int y = rand.Next(image.Height);
            g.DrawLine(blackPen, 0, y, image.Width, y);
        }
        */
        System.IO.MemoryStream ms = new System.IO.MemoryStream();
        image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
        Response.ClearContent();
        Response.ContentType = "image/Jpeg";
        Response.BinaryWrite(ms.ToArray());
        g.Dispose();
        image.Dispose();
    }
开发者ID:vtmer,项目名称:NewStudent,代码行数:32,代码来源:checkCode.aspx.cs


示例17: Run

        public static void Run()
        {
            // ExStart:DrawingUsingGraphics
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_DrawingAndFormattingImages() + "SampleImage_out.bmp";

            // Create an instance of BmpOptions and set its various properties
            BmpOptions imageOptions = new BmpOptions();
            imageOptions.BitsPerPixel = 24;

            // Create an instance of FileCreateSource and assign it to Source property 
            imageOptions.Source = new FileCreateSource(dataDir, false);
            using (var image =  Image.Create(imageOptions, 500, 500))
            {
                var graphics = new Graphics(image);

                // Clear the image surface with white color and Create and initialize a Pen object with blue color
                graphics.Clear(Color.White);                
                var pen = new Pen(Color.Blue);

                // Draw Ellipse by defining the bounding rectangle of width 150 and height 100 also Draw a polygon using the LinearGradientBrush
                graphics.DrawEllipse(pen, new Rectangle(10, 10, 150, 100));
                using (var linearGradientBrush = new LinearGradientBrush(image.Bounds, Color.Red, Color.White, 45f))
                {
                    graphics.FillPolygon(linearGradientBrush, new[] { new Point(200, 200), new Point(400, 200), new Point(250, 350) });
                }
                image.Save();
            }
            // ExEnd:DrawingUsingGraphics
        }
开发者ID:aspose-imaging,项目名称:Aspose.Imaging-for-.NET,代码行数:30,代码来源:DrawingUsingGraphics.cs


示例18: Draw

    public static Rectangle Draw(Pen pen, Form parent)
    {
        sPen = pen;
            // Record the start point
            mPos = parent.PointToClient(Control.MousePosition);
            // Create a transparent form on top of  the parent form
            mMask = new Form();
            mMask.FormBorderStyle = FormBorderStyle.None;
            mMask.BackColor = Color.Magenta;
            mMask.TransparencyKey = mMask.BackColor;

            mMask.ShowInTaskbar = false;
            mMask.StartPosition = FormStartPosition.Manual;
            mMask.Size = parent.ClientSize;
            mMask.Location = parent.PointToScreen(Point.Empty);
            mMask.MouseMove += MouseMove;
            mMask.MouseUp += MouseUp;
            mMask.Paint += PaintRectangle;
            mMask.Load += DoCapture;
            // Display the overlay
            mMask.ShowDialog(parent);
            // Clean-up and calculate return value
            mMask.Dispose();
            mMask = null;
            Point pos = parent.PointToClient(Control.MousePosition);
            int x = Math.Min(mPos.X, pos.X);
            int y = Math.Min(mPos.Y, pos.Y);
            int w = Math.Abs(mPos.X - pos.X);
            int h = Math.Abs(mPos.Y - pos.Y);

            return new Rectangle(x, y, w, h);
    }
开发者ID:Khanchai,项目名称:Paint,代码行数:32,代码来源:EllipseTools.cs


示例19: Pencil

 public Pencil(uint colorref)
 {
     fColor = colorref;
     //fPen = new Pen(Guid.NewGuid(), colorref, PenStyle.Solid, PenType.Cosmetic, PenJoinStyle.Round, PenEndCap.Round, 1);
     fPen = new CosmeticPen(PenStyle.Solid, fColor, Guid.NewGuid());
     fDrawingBounds = RECT.Empty;
 }
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:7,代码来源:Pencil.cs


示例20: SetDashStyle

		public void SetDashStyle (Pen widget, DashStyle dashStyle)
		{
			var swmpen = (swm.Pen)widget.ControlObject;
			if (dashStyle == null || dashStyle.IsSolid)
				swmpen.DashStyle = swm.DashStyles.Solid;
			else {
				var dashes = dashStyle.Dashes;
				double[] wpfdashes;
				if (swmpen.DashCap == swm.PenLineCap.Flat)
					wpfdashes = Array.ConvertAll (dashStyle.Dashes, x => (double)x);
				else {
					wpfdashes = new double[dashes.Length];
					for (int i = 0; i < wpfdashes.Length; i++) {
						var dash = (double)dashes[i];
						if ((i % 2) == 1) {
							// gap must include square/round thickness
							dash += 1;
						} else {
							// dash must exclude square/round thickness
							dash -= 1;
						}
						wpfdashes[i] = dash;
					}
				}
				swmpen.DashStyle = new swm.DashStyle (wpfdashes, dashStyle.Offset);
			}
		}
开发者ID:JohnACarruthers,项目名称:Eto,代码行数:27,代码来源:PenHandler.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# People类代码示例发布时间:2022-05-24
下一篇:
C# PeerBase类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap