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


C# Pen.SetLineCap方法代码示例

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


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

示例1: DrawCompass

 public DrawCompass(Panel _panel)
     : base(_panel, _panel.Height / 2 - 20, _panel.Height / 10)
 {
     arrowPen = new Pen(Color.DarkGreen, 3.0f);
     LineCap lineCap = LineCap.ArrowAnchor;
     arrowPen.SetLineCap(lineCap, LineCap.Flat, DashCap.Flat);
 }
开发者ID:slgrobotics,项目名称:TrackRoamer,代码行数:7,代码来源:DrawCompass.cs

示例2: pnl_painter_MouseMove

        private void pnl_painter_MouseMove(object sender, MouseEventArgs e)
        {
            Brush brush1 = new SolidBrush(Color.Black);
            if (rdo_black.Checked) color = "black";
            else if (rdo_blue.Checked) color = "blue";
            else if (rdo_red.Checked) color = "red";
            switch (color)
            {
                case "black": brush1 = new SolidBrush(Color.Black); break;
                case "blue": brush1 = new SolidBrush(Color.Blue); break;
                case "red": brush1 = new SolidBrush(Color.Red); break;
            }
            if (rdo_small.Checked) size = 4;
            else if (rdo_middle.Checked) size = 8;
            else if (rdo_large.Checked) size = 12;

            x2 = e.X;
            y2 = e.Y;

            Pen pen1 = new Pen(brush1, size);
            pen1.SetLineCap(System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.DashCap.Flat);
            //pen1.LineJoin = System.Drawing.Drawing2D.LineJoin.Round;
            if (shouldPaint)
            {
                Graphics graphics = pnl_painter.CreateGraphics();
                //graphics.FillEllipse(brush1, e.X, e.Y, size, size);
                graphics.DrawLine(pen1, x1, y1, x2, y2);
                graphics.Dispose();
            }

            x1 = e.X;
            y1 = e.Y;
        }
开发者ID:maxzhx,项目名称:DrawingBoard,代码行数:33,代码来源:Form1.cs

示例3: OpenObject

 public OpenObject(Form1 theForm)
 {
     callerForm = theForm;
     alphaPen = new Pen(Color.Purple, 10);
     alphaPen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Flat);
     InitializeComponent();
 }
开发者ID:hanjae,项目名称:VISPJ,代码行数:7,代码来源:OpenObject.cs

示例4: GetPen

 public Pen GetPen()
 {
     Pen p = new Pen(this.Brush.GetBrush(), this.Width);
     p.SetLineCap(this.StartCap, this.EndCap, this.DashCap);
     p.DashStyle = this.DashStyle;
     p.LineJoin = this.LineJoin;
     return p;
 }
开发者ID:ToughBill,项目名称:NanCrm,代码行数:8,代码来源:BrushPenData.cs

示例5: Draw

		public override void Draw(Graphics graphics)
		{
			if (graphics == null) {
				throw new ArgumentNullException("graphics");
			}
			using (Pen p = new Pen(this.ForeColor,this.Thickness)) {
				p.SetLineCap(this.StartLineCap,this.EndLineCap,this.DashLineCap);
				graphics.DrawLine(p,this.fromPoint,this.toPoint);
			}
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:10,代码来源:BaseLine.cs

示例6: Draw

		public override void Draw(Graphics graphics)
		{
			if (graphics == null) {
				throw new ArgumentNullException("graphics");
			}
			using (var p = new Pen(ForeColor,Thickness)) {
				p.SetLineCap(StartLineCap,EndLineCap,DashLineCap);
				graphics.DrawLine(p,fromPoint,toPoint);
			}
		}
开发者ID:krunalc,项目名称:SharpDevelop,代码行数:10,代码来源:BaseLineItem.cs

示例7: Form1

        public Form1()
        {
            InitializeComponent();

            koef.Text = k.ToString();

            x0 = 0;
            y0 = 0;
            bmp = new Bitmap(pictureBox1.Width,pictureBox1.Height);
            bmp.MakeTransparent(Color.Black);
            pictureBox1.Image = bmp;

            MyPen = new System.Drawing.Pen(Color.Violet, 4);
            MyPen.SetLineCap(System.Drawing.Drawing2D.LineCap.Round, System.Drawing.
                Drawing2D.LineCap.Round, System.Drawing.Drawing2D.DashCap.Round);

            time = System.DateTime.Now;
        }
开发者ID:siamezzze,项目名称:FantasyPen,代码行数:18,代码来源:Form1.cs

示例8: OnRender

        protected override void OnRender(Graphics g, Point offset)
        {
            lock (this)
            {
                float ourSize = UI.ScaleWidth(Math.Min(Width, Height));
                g.SmoothingMode = SmoothingMode.AntiAlias;
                g.TranslateTransform(-offset.X, -offset.Y, MatrixOrder.Append);

                PointF ptF = (PointF)this.Location;

                ptF = Utility.TransformOnePoint(this.transform, ptF);

                ptF.X *= (float)OwnerList.ScaleFactor.Ratio;
                ptF.Y *= (float)OwnerList.ScaleFactor.Ratio;

                PointF[] pts = new PointF[8] 
                                         { 
                                             new PointF(-1, -1), // up+left
                                             new PointF(+1, -1), // up+right
                                             new PointF(+1, +1), // down+right
                                             new PointF(-1, +1), // down+left

                                             new PointF(-1, 0),  // left
                                             new PointF(+1, 0),  // right
                                             new PointF(0, -1),  // up
                                             new PointF(0, +1)   // down
                                         };

                Utility.RotateVectors(pts, this.transformAngle);
                Utility.NormalizeVectors(pts);

                using (Pen white = new Pen(Color.FromArgb(this.alpha, Color.White), -1.0f),
                           black = new Pen(Color.FromArgb(this.alpha, Color.Black), -1.0f))
                {
                    PixelOffsetMode oldPOM = g.PixelOffsetMode;
                    g.PixelOffsetMode = PixelOffsetMode.None;

                    if (this.shape != MoveNubShape.Circle)
                    {
                        PointF[] outer = new PointF[4]
                        {
                            Utility.AddVectors(ptF, Utility.MultiplyVector(pts[0], ourSize)),
                            Utility.AddVectors(ptF, Utility.MultiplyVector(pts[1], ourSize)),
                            Utility.AddVectors(ptF, Utility.MultiplyVector(pts[2], ourSize)),
                            Utility.AddVectors(ptF, Utility.MultiplyVector(pts[3], ourSize))
                        };

                        PointF[] middle = new PointF[4]
                        {
                            Utility.AddVectors(ptF, Utility.MultiplyVector(pts[0], ourSize - 1)),
                            Utility.AddVectors(ptF, Utility.MultiplyVector(pts[1], ourSize - 1)),
                            Utility.AddVectors(ptF, Utility.MultiplyVector(pts[2], ourSize - 1)),
                            Utility.AddVectors(ptF, Utility.MultiplyVector(pts[3], ourSize - 1))
                        };

                        PointF[] inner = new PointF[4] 
                        {
                            Utility.AddVectors(ptF, Utility.MultiplyVector(pts[0], ourSize - 2)),
                            Utility.AddVectors(ptF, Utility.MultiplyVector(pts[1], ourSize - 2)),
                            Utility.AddVectors(ptF, Utility.MultiplyVector(pts[2], ourSize - 2)),
                            Utility.AddVectors(ptF, Utility.MultiplyVector(pts[3], ourSize - 2))
                        };

                        g.DrawPolygon(white, outer);
                        g.DrawPolygon(black, middle);
                        g.DrawPolygon(white, inner);
                    }
                    else if (this.shape == MoveNubShape.Circle)
                    {
                        RectangleF rect = new RectangleF(ptF, new SizeF(0, 0));
                        rect.Inflate(ourSize - 1, ourSize - 1);
                        g.DrawEllipse(white, rect);
                        rect.Inflate(-1.0f, -1.0f);
                        g.DrawEllipse(black, rect);
                        rect.Inflate(-1.0f, -1.0f);
                        g.DrawEllipse(white, rect);
                    }

                    if (this.shape == MoveNubShape.Compass)
                    {
                        black.SetLineCap(LineCap.Round, LineCap.DiamondAnchor, DashCap.Flat);
                        black.EndCap = LineCap.ArrowAnchor;
                        black.StartCap = LineCap.ArrowAnchor;
                        white.SetLineCap(LineCap.Round, LineCap.DiamondAnchor, DashCap.Flat);
                        white.EndCap = LineCap.ArrowAnchor;
                        white.StartCap = LineCap.ArrowAnchor;

                        PointF ul = Utility.AddVectors(ptF, Utility.MultiplyVector(pts[0], ourSize - 1));
                        PointF ur = Utility.AddVectors(ptF, Utility.MultiplyVector(pts[1], ourSize - 1));
                        PointF lr = Utility.AddVectors(ptF, Utility.MultiplyVector(pts[2], ourSize - 1));
                        PointF ll = Utility.AddVectors(ptF, Utility.MultiplyVector(pts[3], ourSize - 1));

                        PointF top = Utility.MultiplyVector(Utility.AddVectors(ul, ur), 0.5f);
                        PointF left = Utility.MultiplyVector(Utility.AddVectors(ul, ll), 0.5f);
                        PointF right = Utility.MultiplyVector(Utility.AddVectors(ur, lr), 0.5f);
                        PointF bottom = Utility.MultiplyVector(Utility.AddVectors(ll, lr), 0.5f);

                        using (SolidBrush whiteBrush = new SolidBrush(white.Color))
                        {
                            PointF[] poly = new PointF[] { ul, ur, lr, ll };
//.........这里部分代码省略.........
开发者ID:metadeta96,项目名称:openpdn,代码行数:101,代码来源:MoveNubRenderer.cs

示例9: Begin

 public void Begin()
 {
     m_pen = new Pen(System.Drawing.Color.Black, 2f);
     m_pen.SetLineCap(System.Drawing.Drawing2D.LineCap.Square, System.Drawing.Drawing2D.LineCap.Square, System.Drawing.Drawing2D.DashCap.Flat);
 }
开发者ID:csuffyy,项目名称:circuitdiagram,代码行数:5,代码来源:EMFRenderer.cs

示例10: CreateSolidPen

        // Create a solid pen
        public static Pen CreateSolidPen(Color color, float thickness, LineStyle style)
        {
            #if false
            Pen pen = new Pen(new SolidColorBrush(color), thickness);
            if (style == LineStyle.Rounded) {
                pen.StartLineCap = pen.EndLineCap = PenLineCap.Round;
                pen.LineJoin = PenLineJoin.Round;
            }
            else if (style == LineStyle.Beveled) {
                pen.StartLineCap = pen.EndLineCap = PenLineCap.Flat;
                pen.LineJoin = PenLineJoin.Bevel;
            }
            else if (style == LineStyle.Mitered) {
                pen.StartLineCap = pen.EndLineCap = PenLineCap.Flat;
                pen.LineJoin = PenLineJoin.Miter;
                pen.MiterLimit = MITER_LIMIT;
            }
            else if (style == LineStyle.FlatRounded) {
                pen.StartLineCap = pen.EndLineCap = PenLineCap.Flat;
                pen.LineJoin = PenLineJoin.Round;
            }

            pen.Freeze();
            return pen;
            #else
            Pen pen = new Pen(color, thickness);
            if (style == LineStyle.Rounded) {
                pen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Flat);
                pen.LineJoin = LineJoin.Round;
            }
            else if (style == LineStyle.Beveled) {
                pen.SetLineCap(LineCap.Flat, LineCap.Flat, DashCap.Flat);
                pen.LineJoin = LineJoin.Bevel;
            }
            else if (style == LineStyle.Mitered) {
                pen.SetLineCap(LineCap.Flat, LineCap.Flat, DashCap.Flat);
                pen.LineJoin = LineJoin.Miter;
                pen.MiterLimit = MITER_LIMIT;
            }
            else if (style == LineStyle.FlatRounded) {
                pen.SetLineCap(LineCap.Flat, LineCap.Flat, DashCap.Flat);
                pen.LineJoin = LineJoin.Round;
            }

            return pen;
            #endif
        }
开发者ID:jonc,项目名称:carto,代码行数:48,代码来源:GraphicsTarget.cs

示例11: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            var g = e.Graphics;

            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.CompositingQuality = CompositingQuality.HighQuality;

            Pen p = new Pen(Brush, 4);
            p.SetLineCap(LineCap.Flat, LineCap.Flat, DashCap.Flat);

            var gp = new GraphicsPath();
            gp.AddLine(4, 10, 4, 40);
            gp.AddArc(4, 5, 10, 10, 180, 90);
            gp.AddLine(9, 5, 12, 5);
            gp.AddArc(12, 5, 10, 10, 270, 90);
            gp.AddLine(22, 10, 22, 30);
            gp.AddArc(12, 34, 10, 10, 0, 90);
            gp.AddLine(16, 44, 12, 44);
            gp.AddArc(4, 34, 10, 10, 90, 90);

            g.DrawPath(p, gp);

            bool on = Value > 0.5;
            if (Invert)
                on = !on;

            if (Mode == SwitchMode.Toggle)
                on = on && MouseIsDown;

            if(on)
                g.FillRectangle(Brush, 9, 10, 8, 10);
            else
                g.FillRectangle(OffBrush, 9, 29, 8, 10);
        }
开发者ID:ValdemarOrn,项目名称:AudioLib,代码行数:34,代码来源:Switch.cs

示例12: PaintLine

        private void PaintLine(Graphics g, SnapshotIcon icon, SnapshotIcon child, bool highlight)
        {
            if (child.Index == -1)
                return;

            try
            {
                Rectangle leftItemBounds = icon.GetBounds(ItemBoundsPortion.Entire);
                Rectangle rightItemBounds = child.GetBounds(ItemBoundsPortion.Entire);
                leftItemBounds.Size = icon.DefaultSize;
                rightItemBounds.Size = child.DefaultSize;


                int left = leftItemBounds.Right + 6;
                int right = rightItemBounds.Left;
                int mid = (left + right) / 2;
                Point start = new Point(left, (leftItemBounds.Bottom + leftItemBounds.Top) / 2);
                Point end = new Point(right, (rightItemBounds.Top + rightItemBounds.Bottom) / 2);
                Point curveStart = start;
                curveStart.Offset(straightLineLength, 0);
                Point curveEnd = end;
                curveEnd.Offset(-straightLineLength, 0);
                Point control1 = new Point(mid + straightLineLength, start.Y);
                Point control2 = new Point(mid - straightLineLength, end.Y);

                Color lineColor = LinkLineColor;
                float lineWidth = LinkLineWidth;
                if (highlight)
                {
                    lineColor = Color.ForestGreen;
                    lineWidth = 2.5f;
                }
                using (Pen p = new Pen(lineColor, lineWidth))
                {
                    p.SetLineCap(LineCap.Round, LineCap.Custom, DashCap.Flat);
                    p.CustomEndCap = linkLineArrow;

                    g.SmoothingMode = SmoothingMode.AntiAlias;
                    GraphicsPath path = new GraphicsPath();
                    path.AddLine(start, curveStart);
                    path.AddBezier(curveStart, control1, control2, curveEnd);
                    path.AddLine(curveEnd, end);
                    g.DrawPath(p, path);
                }
            }
            catch (Exception)
            {
                //Debugger.Break();
            }
        }
开发者ID:huizh,项目名称:xenadmin,代码行数:50,代码来源:SnapshotTreeView.cs

示例13: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics g = e.Graphics;
            Rectangle rcClient = ClientRectangle;
            rcClient.Inflate(-4, -4);

            Region originalClip = g.Clip;
            g.Clip = new Region(rcClient);
            g.SmoothingMode = SmoothingMode.AntiAlias;

            Size szSpace = new Size(4, 3);
            Rectangle rcItem;
            Rectangle rcText = new Rectangle(0, 0, 0, 0);
            Rectangle rcIcon = new Rectangle(0, 0, 0, 0);

            StringFormat iconTextFormat = new StringFormat();
            iconTextFormat.Alignment = StringAlignment.Center;
            iconTextFormat.LineAlignment = StringAlignment.Center;

            Color color1 = Color.White;
            Color color2 = Color.White;
            Brush textBrush = Brushes.Black;
            Brush iconBrush = Brushes.White;

            //First determine if the data will fit without the scrollbar
            rcItem = new Rectangle(rcClient.X, rcClient.Y + mCurrentY, rcClient.Width - szSpace.Width, 0);
            for (int i = 0; i < Items.Count; i++) {
                ListItem item = Items[i];
                if (item.Icon != null) {
                    rcIcon = new Rectangle(ItemPadding.Left + rcItem.X, 0, item.Icon.Width, item.Icon.Height);
                    rcText.X = rcIcon.Right + szSpace.Width;
                    rcText.Width = rcItem.Width - (szSpace.Width + rcIcon.Width + ItemPadding.Left + ItemPadding.Right);
                } else {
                    rcIcon = new Rectangle(0, 0, 0, 0);
                    rcText.X = ItemPadding.Left + rcItem.X;
                    rcText.Width = rcItem.Width - (ItemPadding.Left + ItemPadding.Right);
                }

                Size sz = g.MeasureString(item.Text, Font, rcText.Width).ToSize();
                rcItem.Height = ((item.Icon != null && sz.Height < rcIcon.Height) ? rcIcon.Height : sz.Height) + (szSpace.Height * 2) + ItemPadding.Top + ItemPadding.Bottom;
                item.Size = rcItem.Size;
                item.Location.X = rcItem.Location.X;
                item.Location.Y = rcItem.Location.Y + mCurrentY;
                rcText.Height = rcItem.Height;
                rcText.Y = rcItem.Y;
                rcIcon.Y = rcItem.Y + ((rcItem.Height - rcIcon.Height) / 2);

                rcItem.Offset(0, rcItem.Height + szSpace.Height);
            }

            mMaxScroll = ((rcItem.Bottom + mDefaultY) - (Height + mCurrentY));
            if (mMaxScroll < 0) { // No scrolling needed
                mMaxScroll = 0;
                mCurrentY = mDefaultY;
                mScrollBar = new Rectangle(0, 0, 0, 0);
            } else {
                mScrollBar = new Rectangle(rcClient.Right - 30, rcClient.Y, 30, rcClient.Height);
                RoundRectPath thumbPath = new RoundRectPath(mScrollBar, mRounding, mRounding);
                using (LinearGradientBrush b = new LinearGradientBrush(mScrollBar, Color.White, Color.LightGray, LinearGradientMode.Vertical)) {
                    b.WrapMode = WrapMode.TileFlipX;
                    g.FillPath(b, thumbPath);
                }

                using (Pen p = new Pen(Color.DarkGray, 3)) {
                    p.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);
                    g.DrawLine(p, new Point(mScrollBar.X + 6, 18), new Point(mScrollBar.X + 15, 8));
                    g.DrawLine(p, new Point(mScrollBar.X + 24, 18), new Point(mScrollBar.X + 15, 8));
                    g.DrawLine(p, new Point(mScrollBar.X + 6, mScrollBar.Bottom - 18), new Point(mScrollBar.X + 15, mScrollBar.Bottom - 8));
                    g.DrawLine(p, new Point(mScrollBar.X + 24, mScrollBar.Bottom - 18), new Point(mScrollBar.X + 15, mScrollBar.Bottom - 8));
                }

                for (int l = 24; l < rcClient.Height - 24; l += 4) {
                    g.DrawLine(Pens.DarkGray, new Point(mScrollBar.Location.X + 6, l), new Point(mScrollBar.Location.X + 24, l));
                }
                g.DrawPath(Pens.Black, thumbPath);
                thumbPath.Dispose();
            }

            rcItem = new Rectangle(rcClient.X, rcClient.Y + mCurrentY, rcClient.Width - ((mScrollBar.Width > 0) ? mScrollBar.Width + szSpace.Width : 0), 0);
            for (int i = 0; i < Items.Count; i++) {
                ListItem item = Items[i];

                if (item.Icon != null) {
                    rcIcon = new Rectangle(ItemPadding.Left + rcItem.X, 0, item.Icon.Width, item.Icon.Height);
                    rcText.X = rcIcon.Right + szSpace.Width;
                    rcText.Width = rcItem.Width - (szSpace.Width + rcIcon.Width + ItemPadding.Left + ItemPadding.Right);
                } else {
                    rcIcon = new Rectangle(0, 0, 0, 0);
                    rcText.X = ItemPadding.Left + rcItem.X;
                    rcText.Width = rcItem.Width - (ItemPadding.Left + ItemPadding.Right);
                }

                Size sz = g.MeasureString(item.Text, Font, rcText.Width).ToSize();
                rcItem.Height = ((item.Icon != null && sz.Height < rcIcon.Height) ? rcIcon.Height : sz.Height) + (szSpace.Height * 2) + ItemPadding.Top + ItemPadding.Bottom;
                item.Size = rcItem.Size;
                item.Location.X = rcItem.Location.X;
                item.Location.Y = rcItem.Location.Y + mCurrentY;
                rcText.Height = rcItem.Height;
//.........这里部分代码省略.........
开发者ID:eprimo,项目名称:Linc-Reporting-Service,代码行数:101,代码来源:ListBase.cs

示例14: Draw

        public void Draw(Graphics g)
        {
            g.SmoothingMode = SmoothingMode.AntiAlias;

            using (Pen axisPen = new Pen(AxisColor, AxisWidth))
            using (Pen majorPen = new Pen(AxisColor, MajorTickWidth))
            using (Pen minorPen = new Pen(AxisColor, MinorTickWidth))
            using (Brush labelBrush = new SolidBrush(LabelColor))
            {
                axisPen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);
                majorPen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);
                minorPen.SetLineCap(LineCap.Round, LineCap.Round, DashCap.Round);

                try
                {
                    g.DrawPath(axisPen, m_arcPath);
                    g.DrawPath(majorPen, m_majorTicksPath);
                    g.DrawPath(minorPen, m_minorTicksPath);
                    g.FillPath(labelBrush, m_labelPath);
                }
                catch { }
            }

            //now these areas need to be redrawn if they change
            m_redrawRegion.Dispose();
            m_redrawRegion = new Region();
            m_redrawRegion.Union(m_arcPath);
            m_redrawRegion.Union(m_labelPath);
            m_redrawRegion.Union(m_majorTicksPath);
            m_redrawRegion.Union(m_minorTicksPath);
        }
开发者ID:yahiafarghaly,项目名称:wcontrols,代码行数:31,代码来源:CircularAxis.cs

示例15: SetLineCap_InvalidEndCap

		public void SetLineCap_InvalidEndCap ()
		{
			using (Pen p = new Pen (Brushes.Red)) {
				p.SetLineCap (LineCap.Flat, (LineCap)Int32.MinValue, DashCap.Flat);
				// no exception :( (reported as FDBK50057)
				Assert.AreEqual (LineCap.Flat, p.StartCap, "StartCap");
				Assert.AreEqual (Int32.MinValue, (int)p.EndCap, "EndCap");
				Assert.AreEqual (DashCap.Flat, p.DashCap, "DashCap");
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:PenTest.cs


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