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


C# Graphics.DrawLine方法代码示例

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


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

示例1: RepertoryImage

        public static void RepertoryImage(Graphics drawDestination)
        {
            StringFormat itemStringFormat = new StringFormat();
            RectangleF itemBox = new RectangleF(10, 30, 42, 10);
            RectangleF itemBox2 = new RectangleF(60, 48, 10, 10);
            itemStringFormat.Alignment = StringAlignment.Center;
            itemStringFormat.LineAlignment = StringAlignment.Far;
            drawDestination.DrawLine(Pens.LightGray,10,10,10,70);
            if (mMscStyle == MscStyle.SDL){
                PointF[] capPolygon = new PointF[3];
                capPolygon[0] = new PointF(61, 40);
                capPolygon[1] = new PointF(53, 44);
                capPolygon[2] = new PointF(53, 36);
                drawDestination.FillPolygon(Brushes.Black,capPolygon);
                drawDestination.DrawString("Lost",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
                drawDestination.DrawString("g",new Font("Arial",8),Brushes.Black,itemBox2,itemStringFormat);
                drawDestination.DrawLine(Pens.Black,10, 40, 60,40);
                drawDestination.FillEllipse(Brushes.Black, new RectangleF(60,35, 10,10));
            }
            else if(mMscStyle == MscStyle.UML2){

                drawDestination.DrawString("Lost",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat);
                drawDestination.DrawString("g",new Font("Arial",8),Brushes.Black,itemBox2,itemStringFormat);
                drawDestination.DrawLine(Pens.Black,10, 40, 60,40);
                drawDestination.DrawLine(Pens.Black,60, 40, 54,43);
                drawDestination.DrawLine(Pens.Black,60, 40, 54,37);
                drawDestination.FillEllipse(Brushes.Black, new RectangleF(60,35, 10,10));

            }
            itemStringFormat.Dispose();
        }
开发者ID:xueliu,项目名称:MSC_Generator,代码行数:31,代码来源:LostMessageExtension.cs

示例2: PaintThisProgress

		/// <summary></summary>
		/// <param name="box"></param>
		/// <param name="g"></param>
		protected override void PaintThisProgress(Rectangle box, Graphics g) {
			try {
				box.Width -= 1;
				box.Height -= 1;
			} catch {}
			if (box.Width <= 1) {
				return;
			}

			g.FillRectangle(brush, box);
			Rectangle innerBox = box;
			innerBox.Inflate(-1, -1);
			g.DrawRectangle(inner, innerBox);
			g.DrawLine(outer, box.X, box.Y, box.Right, box.Y);
			g.DrawLine(outer, box.X, box.Y, box.X, box.Bottom);
			g.DrawLine(edge, box.X, box.Bottom, box.Right, box.Bottom);

			if (gloss != null) {
				gloss.PaintGloss(box, g);
			}

			if (showEdge) {
				g.DrawLine(edge, box.Right, box.Y, box.Right, box.Bottom);
			}
		}
开发者ID:hoeness2,项目名称:mcebuddy2,代码行数:28,代码来源:RarProgressPainter.cs

示例3: Draw

        protected override void Draw(Graphics g)
        {
            if (points.Count > 2)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;

                if (Config.UseDimming)
                {
                    using (Region region = new Region(regionFillPath))
                    {
                        g.Clip = region;
                        g.FillRectangle(lightBackgroundBrush, ScreenRectangle0Based);
                        g.ResetClip();
                    }
                }

                g.DrawPath(borderPen, regionFillPath);
                g.DrawPath(borderDotPen, regionFillPath);
                g.DrawLine(borderPen, points[points.Count - 1], points[0]);
                g.DrawLine(borderDotPen, points[points.Count - 1], points[0]);
                g.DrawRectangleProper(borderPen, currentArea);
            }

            base.Draw(g);
        }
开发者ID:andre-d,项目名称:ShareXYZ,代码行数:25,代码来源:FreeHandRegion.cs

示例4: Draw

		internal override void Draw(Graphics g)
		{
			IsInvalidated = false;

			Rectangle r = BaseElement.GetUnsignedRectangle(new Rectangle(location, size));

			Point[] points = new Point[5];
			points[0] = new Point(r.X + 0, r.Y + 0);
			points[1] = new Point(r.X + 0, r.Y + r.Height);
			points[2] = new Point(r.X + r.Width, r.Y + r.Height);

			//Fold
			points[3] = new Point(r.X + r.Width, r.Y + foldSize.Height);
			points[4] = new Point(r.X + r.Width - foldSize.Width, r.Y + 0);

			//foreach(Point p in points) p.Offset(location.X, location.Y);

			g.FillPolygon(GetBrush(r), points, FillMode.Alternate);
			g.DrawPolygon(new Pen(borderColor, borderWidth), points);

			g.DrawLine(new Pen(borderColor, borderWidth),
			           new Point(r.X + r.Width - foldSize.Width, r.Y + foldSize.Height),
			           new Point(r.X + r.Width, r.Y + foldSize.Height));

			g.DrawLine(new Pen(borderColor, borderWidth),
			           new Point(r.X + r.Width - foldSize.Width, r.Y + 0),
			           new Point(r.X + r.Width - foldSize.Width, r.Y + 0 + foldSize.Height));
		}
开发者ID:froggy96,项目名称:diagramnet,代码行数:28,代码来源:CommentBoxElement.cs

示例5: Draw

        protected override void Draw(Graphics g)
        {
            if (points.Count > 2)
            {
                g.SmoothingMode = SmoothingMode.HighQuality;

                borderDotPen.DashOffset = (float)timer.Elapsed.TotalSeconds * 10;
                borderDotPen2.DashOffset = 5 + (float)timer.Elapsed.TotalSeconds * 10;

                using (Region region = new Region(regionFillPath))
                {
                    g.Clip = region;
                    g.FillRectangle(lightBackgroundBrush, ScreenRectangle0Based);
                    g.ResetClip();
                }

                g.DrawPath(borderDotPen, regionFillPath);
                g.DrawPath(borderDotPen2, regionFillPath);
                g.DrawLine(borderDotPen, points[points.Count - 1], points[0]);
                g.DrawLine(borderDotPen2, points[points.Count - 1], points[0]);
                g.DrawRectangleProper(borderPen, currentArea);
            }

            base.Draw(g);
        }
开发者ID:TreeSeed,项目名称:ShareX,代码行数:25,代码来源:FreeHandRegion.cs

示例6: PaintLinearBench

        private void PaintLinearBench(Graphics g)
        {
            int radius = (int) circleRadius;
            DrawCircle(g, Pens.Blue, new Point(), radius);

            // draw the optical border
            g.DrawLine(new Pen(Color.Black, 4.0f), new Point(-radius, 0), new Point(radius, 0));

            double eta = Bench.RefractiveIndexAir / Bench.RefractiveIndexGlass;
            double criticalAngle = (eta > 1.0) ? Math.PI + Math.Asin(1 / eta) : Math.Asin(eta);
            SphericLens.Vector criticalAngleVector = new SphericLens.Vector() { Phi = criticalAngle, Radius = radius };
            Point criticalAnglePoint = SphericPointToFormsPoint(SphericLens.Point.FromVector(-criticalAngleVector));
            g.DrawLine(Pens.Red, new Point(), criticalAnglePoint);
            criticalAnglePoint.X *= -1;
            g.DrawLine(Pens.Red, new Point(), criticalAnglePoint);

            // draw the normal
            g.DrawLine(Pens.Brown, new Point(), new Point(0, (int)Bench.Normal.Radius));

            // draw the incomint ray
            g.DrawLine(Pens.Green, new Point(), SphericPointToFormsPoint(SphericLens.Point.FromVector(Bench.Direction)));

            // draw the refracted ray
            g.DrawLine(Pens.Blue, new Point(), SphericPointToFormsPoint(SphericLens.Point.FromVector(Bench.RefractedDirection)));
        }
开发者ID:bzamecnik,项目名称:bokehlab,代码行数:25,代码来源:Form1.cs

示例7: Draw

        public override void Draw(Graphics g)
        {
            if (this.lineComponent.IsSelected)
            {
                g.DrawLine(ViewFactory.BoundingBoxPen, this.lineComponent.StartPoint.X, this.lineComponent.StartPoint.Y, this.lineComponent.ControlPoint1.X, this.lineComponent.ControlPoint1.Y);
                g.DrawLine(ViewFactory.BoundingBoxPen, this.lineComponent.EndPoint.X, this.lineComponent.EndPoint.Y, this.lineComponent.ControlPoint2.X, this.lineComponent.ControlPoint2.Y);
            }
            if (this.lineComponent.ParentMoving)
            {
                g.DrawBezier(ViewFactory.LinePen,
                    this.lineComponent.StartPoint.MakePointF(),
                    this.lineComponent.ControlPoint1.MakePointF(),
                    this.lineComponent.ControlPoint2.MakePointF(),
                    this.lineComponent.EndPoint.MakePointF());
            }
            else
            {
                g.DrawLines(ViewFactory.LinePen, this.lineComponent.points.ToArray());
                /*DrawPoint(g, new FlowChartPoint(points[points.Count/2].X,points[points.Count/2].Y), 
                    GraphicsSettings.LabelPen, GraphicsSettings.EdgeBoxWidth);*/
            }

            DrawArrow(g, this.lineComponent.EndPoint, this.lineComponent.ControlPoint2,
                ViewFactory.ArrowBrush,
                ViewFactory.ArrowPen,
                ViewFactory.ArrowLength);

            if (this.lineComponent.IsSelected)
            {
                DrawPoint(g, this.lineComponent.ControlPoint1, ViewFactory.EdgePen, ViewFactory.EdgeBoxWidth);
                DrawPoint(g, this.lineComponent.ControlPoint2, ViewFactory.EdgePen, ViewFactory.EdgeBoxWidth);
            }
            base.Draw(g);
        }
开发者ID:JackWangCUMT,项目名称:FlowChart,代码行数:34,代码来源:CurvedLineView.cs

示例8: Draw

        public void Draw(Graphics g)
        {
            g.Clear(Color.Gray);

            PointF cellSize = new PointF((float)Size.X / (ChessGameField.FIELD_SIZE), (float)Size.Y / (ChessGameField.FIELD_SIZE));

            for (int i = 0; i <= ChessGameField.FIELD_SIZE; ++i)
            {
                g.DrawLine(Pens.Black, Pos.X + i * cellSize.X, Pos.Y, Pos.X + i * cellSize.X, Pos.Y + Size.Y);
            }

            for (int i = 0; i <= ChessGameField.FIELD_SIZE; ++i)
            {
                g.DrawLine(Pens.Black, Pos.X, Pos.Y + i * cellSize.Y, Pos.X + Size.X, Pos.Y + i * cellSize.Y);
            }

            Field.ForEachCell((pos, cell) => { if (cell.figure != null) cell.figure.Draw(g, GetColor(cell.figure.GetOwner()), GetCellPos(pos, cellSize), cellSize); return true; });

            if (State == ActionState.Selected)
            {
                PointF pos = GetCellPos(SelectedPoint, cellSize);
                Pen pen = new Pen(Brushes.Green, 2);
                int border = 4;
                g.DrawRectangle(pen, new Rectangle((int)pos.X + border + 1, (int)pos.Y + border + 1, (int)cellSize.X - border*2, (int)cellSize.Y - border*2));
            }
        }
开发者ID:RuWhyNot,项目名称:chess-client,代码行数:26,代码来源:ChessFieldView.cs

示例9: wypelniony

        private void wypelniony()
        {
           
            bmp = new Bitmap((int)pbWIDTH, (int)pbHEIGHT);
            

            Point p1 = new Point((int)(pbWIDTH / 6), (int)(pbHEIGHT / 2));
            Point p2 = new Point((int)(pbWIDTH * 5 / 6), (int)(pbHEIGHT / 2));
            Point p1_25 = new Point(pbWIDTH / 3, pbHEIGHT / 4 * 3);
            Point p2_25 = new Point((int)(pbWIDTH / 3 * 2), (int)(pbHEIGHT / 4 * 3));
            Point p1_75 = new Point((int)(pbWIDTH / 3), (int)(pbHEIGHT / 4));
            Point p2_75 = new Point((int)(pbWIDTH / 3 * 2), (int)(pbHEIGHT / 4));
            Pen pen1 = new Pen(Brushes.Black, width_pen1);
            Pen pen2 = new Pen(Brushes.Black, width_pen2);

            

            g = Graphics.FromImage(bmp);
            g.Clear(Color.CornflowerBlue);
            g.FillRectangle(Brushes.White, new Rectangle(0, 0, pbWIDTH, pbHEIGHT - (int)(pbComplete * pbUnit)));
            g.DrawRectangle(pen1, 0, 0, pbWIDTH, pbHEIGHT);
            g.DrawLine(pen2, p1, p2);
            g.DrawLine(pen2, p1_25, p2_25);
            g.DrawLine(pen2, p1_75, p2_75);
            //g.DrawString(pbComplete + "%", new Font("Arial", pbHEIGHT / 5),Brushes.Black,new PointF(pbWIDTH/12,pbHEIGHT/4));
            this.Image = bmp;
            //return bmp;
        }
开发者ID:rwalicki,项目名称:inteligentny_dom,代码行数:28,代码来源:WPAZbiornik.cs

示例10: PaindCircleWithUpArrows

		public static void PaindCircleWithUpArrows(Graphics g, Rectangle rect, float thickness, Color color)
		{
			using (Pen pen = new Pen(color, thickness))
			{
				g.DrawEllipse(pen, rect);
				rect.Inflate(1, 1);
				int x = rect.Width;
				int y = rect.Height;
				Point p1 = new Point();
				Point p2 = new Point();

				p1.X = (3*x)/8;
				p1.Y = y/2;
				p2.X = x/2;
				p2.Y = y/4;
				g.DrawLine(pen, p1, p2);


				p1.X = (5*x)/8;
				p1.Y = y/2;
				g.DrawLine(pen, p2, p1);

				p1.X = (3*x)/8;
				p1.Y = (3*y)/4;
				p2.X = x/2;
				p2.Y = y/2;
				g.DrawLine(pen, p1, p2);


				p1.X = (5*x)/8;
				p1.Y = 3*y/4;
				g.DrawLine(pen, p2, p1);
			}
		}
开发者ID:ViniciusConsultor,项目名称:ecustomsgs1,代码行数:34,代码来源:GDIHelper.cs

示例11: DrawCross

        public void DrawCross(Graphics g)
        {
            if (this.IsMouseOver)
            {
                Color fill = this.renderer.ColorTable.ButtonSelectedHighlight;

                g.FillRectangle(new SolidBrush(fill), this.Rect);

                Rectangle borderRect = this.Rect;

                borderRect.Width--;
                borderRect.Height--;

                g.DrawRectangle(SystemPens.Highlight, borderRect);
            }

            using (Pen pen = new Pen(Color.Black, 1f))
            {
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
                g.DrawLine(pen, this.Rect.Left + 3, this.Rect.Top + 4,
                    this.Rect.Right - 6, this.Rect.Bottom - 4);
                g.DrawLine(pen, this.Rect.Left + 4, this.Rect.Top + 4,
                    this.Rect.Right - 5, this.Rect.Bottom - 4);

                g.DrawLine(pen, this.Rect.Right - 6, this.Rect.Top + 4,
                    this.Rect.Left + 3, this.Rect.Bottom - 4);
                g.DrawLine(pen, this.Rect.Right - 5, this.Rect.Top + 4,
                    this.Rect.Left + 4, this.Rect.Bottom - 4);
            }
        }
开发者ID:RSchwoerer,项目名称:Terminals,代码行数:30,代码来源:TabControlCloseButton.cs

示例12: Draw

        public void Draw(Histogram hist, Graphics gr, Rectangle bounds)
        {
            var w = bounds.Width;
            var kx = 1f / bounds.Width;
            var ky = 1f * bounds.Height;
            var cy = bounds.Top + bounds.Height;
            var cx = bounds.Left;

            var ddd = hist[1f];

            var max = 0f;

            for (float i = 0; i <= 1; i += 1f / w)
            {
                var v = hist[i];
                if (v > max)
                    max = v;
            }

            ky = bounds.Height / max;

            using (var pen = new Pen(ForeColor))
                for (float i = 0; i <= 1; i += 1f/w)
                {
                    var x = i * w;
                    var y = hist[i] * ky;
                    gr.DrawLine(pen, cx + x, cy, cx + x, cy - y);
                }

            using (var pen = new Pen(ForeColor))
                gr.DrawLine(pen, cx, cy, cx + w, cy);
        }
开发者ID:MihanEntalpo,项目名称:HOLO,代码行数:32,代码来源:HistogramDrawer.cs

示例13: DrawInto

        public void DrawInto(Graphics g)
        {
            int cellWidth = Width / puzzle.Size;
            int cellHeight = Height / puzzle.Size;

            g.Clear(Color.White);

            for (int x = 1; x <= puzzle.Size - 1; x++)
            {
                g.DrawLine(Pens.Black, new Point(cellWidth * x, 0), new Point(cellWidth * x, Height));
                g.DrawLine(Pens.Black, new Point(0, cellHeight * x), new Point(Width, cellHeight * x));
            }

            for (int i = 0; i < puzzle.Size; i++)
            {
                for (int j = 0; j < puzzle.Size; j++)
                {
                    float y = cellHeight * i + cellHeight / 2 - font.Height / 2;
                    float x = cellWidth * j + cellWidth / 2 - font.Size / 2;

                    if (showSolution && puzzle.IsSolution(j, i))
                        g.FillRectangle(new SolidBrush(Color.FromArgb(100, Color.Yellow)), new Rectangle(new Point(cellWidth * j, cellHeight * i), new Size(cellWidth, cellHeight)));

                    g.DrawString(puzzle[i, j].ToString(), font, Brushes.Black, new PointF(x, y));
                }
            }
        }
开发者ID:lekararikoldprojects,项目名称:PuzzleMaker,代码行数:27,代码来源:PuzzlePanel.cs

示例14: Draw

        /// <summary>
        /// Draw rectangle
        /// </summary>
        /// <param name="g"></param>
        public override void Draw(Graphics g)
        {
            Pen pen = new Pen(Color, PenWidth);

            Rectangle _rect = new Rectangle();
            _rect = DrawRectangle.GetNormalizedRectangle(Rectangle);

            int x = _rect.X;
            int y = _rect.Y;
            int w = _rect.Width;
            int h = _rect.Height;
            int wArc = (w/6);
            int wArc2 = wArc * 2;
            int wReta = w - wArc;

            // g.DrawArc(pen, DrawRectangle.GetNormalizedRectangle(Rectangle), -270, 180);
            g.DrawArc(pen, x - wArc, y, wArc2, h, 270, 180);
            g.DrawArc(pen, x - wArc + wReta, y, wArc2, h, 270, 180);

            Point SE = new Point(x, y);          //SuperiorEsquerdo
            Point SD = new Point(x + wReta, y);             //SuperiorDireito

            Point IE = new Point(x, y + h);      //InferioriEsquerdo
            Point ID = new Point(x + wReta, y + h);         //InferiorDireito

            g.DrawLine(pen, SE, SD);
            g.DrawLine(pen, IE, ID);

            //g.DrawRectangle(pen, x, y, w, h);

            pen.Dispose();
        }
开发者ID:CoolBatchPopulator,项目名称:CoolBatchPopulator,代码行数:36,代码来源:DrawFile.cs

示例15: Draw

        public void Draw(Graphics g)
        {
            Pen p = new Pen(Color.Green, 1f);

            g.DrawLine(p, 0, height / 2, width, height / 2);
            g.DrawLine(p, width / 2, 0, width / 2, height);
        }
开发者ID:ElmarXCV,项目名称:ComputerGraphics,代码行数:7,代码来源:Axis.cs


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