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


C# IGraphics.DrawLine方法代码示例

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


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

示例1: Draw

 public override void Draw(int size, int x, int y, IGraphics g, Pen pen, Brush brush)
 {
     int s2 = size/2;
     g.DrawLine(pen, x - s2, y, x + s2, y);
     g.DrawLine(pen, x, y - s2, x, y + s2);
     g.DrawLine(pen, x - s2, y - s2, x + s2, y + s2);
     g.DrawLine(pen, x + s2, y - s2, x - s2, y + s2);
 }
开发者ID:neuhauser,项目名称:compbio-base,代码行数:8,代码来源:SymbolTypeStar.cs

示例2: OnPaintBackground

 protected internal override void OnPaintBackground(IGraphics g, int width, int height)
 {
     Brush b = new SolidBrush(Color.FromArgb(236, 233, 216));
     g.FillRectangle(b, 0, 0, width, height);
     Pen p = new Pen(Color.FromArgb(172, 168, 153));
     g.DrawLine(p, 0, height - 1, width, height - 1);
     g.DrawLine(p, width - 1, 0, width - 1, height);
 }
开发者ID:neuhauser,项目名称:compbio-base,代码行数:8,代码来源:ScrollableControlSmallCornerView.cs

示例3: DrawStartCap

		protected override void DrawStartCap(IGraphics g, bool onScreen, Style style)
		{
			linePen.Color = style.RelationshipColor;
			linePen.Width = style.RelationshipWidth;

			g.FillEllipse(Brushes.White, -Radius, 0, Diameter, Diameter);
			g.DrawEllipse(linePen, -Radius, 0, Diameter, Diameter);
			g.DrawLine(linePen, 0, Radius - CrossSize / 2, 0, Radius + CrossSize / 2);
			g.DrawLine(linePen, -CrossSize / 2, Radius, CrossSize / 2, Radius);
		}
开发者ID:BachelorEric,项目名称:ModelFirst,代码行数:10,代码来源:Nesting.cs

示例4: BotBox

 public static void BotBox(IGraphics graphics, Pen pen, double X, double Y, double Heading)
 {
     var Corner1 = Geometry.MakePoint(X,Y).VectorProjection(Heading + 45, BotSize);
     var Corner2 = Geometry.MakePoint(X,Y).VectorProjection(Heading + 135, BotSize);
     var Corner3 = Geometry.MakePoint(X,Y).VectorProjection(Heading + 225, BotSize);
     var Corner4 = Geometry.MakePoint(X,Y).VectorProjection(Heading + 315, BotSize);
     graphics.DrawLine(pen, Corner1, Corner2);
     graphics.DrawLine(pen, Corner2, Corner3);
     graphics.DrawLine(pen, Corner3, Corner4);
     graphics.DrawLine(pen, Corner4, Corner1);
 }
开发者ID:KingLebron,项目名称:robocode,代码行数:11,代码来源:Paint.cs

示例5: OnPaint

        public override void OnPaint(IGraphics g)
        {
            // Draw a line from our robot to the scanned robot
            g.DrawLine(new Pen(Color.Red),  targetX, targetY, (int)X, (int)Y);

            // Draw a filled square on top of the scanned robot that covers it
            g.DrawRectangle(new Pen(Color.Red), targetX - 20, targetY - 20, 40, 40);
        }
开发者ID:stdcallua,项目名称:Robots,代码行数:8,代码来源:Dog.cs

示例6: DrawBulletTarget

 /// <summary>
 /// Method to draw half-transparent bullet-line & targeting-box (the size of a robot) on the battlefield. 
 /// The idea is to use this for visual debugging: Set start point to own robot's position, and end point 
 /// to where you mean the bullet to go. Then see if this really is where the bullet is heading: 
 /// 1) If the targeting-box is off the spot you wanted it, you got a bug in your target prediction code.
 /// 2) If the targeting-box is on the spot, but the bullet is off the line (and center of the box), you 
 ///    got a bug in your "gun turning and firing" code.
 /// </summary>
 public static void DrawBulletTarget(IGraphics graphics, Color drawColor, Point2D start, Point2D end)
 {
     // Set color to a semi-transparent one.
     Color halfTransparent = Color.FromArgb(128, drawColor);
     // Draw line and rectangle.
     graphics.DrawLine(new Pen(halfTransparent), (int)start.X, (int)start.Y, (int)end.X, (int)end.Y);
     graphics.FillRectangle(new SolidBrush(halfTransparent), (int)end.X - 18, (int)end.Y - 18, 36, 36);
 }
开发者ID:OleVedeler,项目名称:RoboCode,代码行数:16,代码来源:RoboHelpers.cs

示例7: DrawControlLine

        public static void DrawControlLine(IGraphics g, Color c, DashStyle style, Coordinates loc1, Coordinates loc2, WorldTransform wt)
        {
            float pw = 1.25f / wt.Scale;

            using (IPen p = g.CreatePen()) {
                p.Color = c;
                p.Width = pw;
                p.DashStyle = style;

                g.DrawLine(p, Utility.ToPointF(loc1), Utility.ToPointF(loc2));
            }
        }
开发者ID:anand-ajmera,项目名称:cornell-urban-challenge,代码行数:12,代码来源:DrawingUtility.cs

示例8: draw

        public override void draw(IGraphics graphics)
        {
            // This will force the hotspot to be computed if it isn't
              FinalPoint hotspot = getScreenHotspot();
              int width = getParentSystem().getWidth();

              // Draw the staff lines
              for (int y = 0; y <= 20; y += 5)
            graphics.DrawLine(hotspot.x, hotspot.y + y,
              hotspot.x + width, hotspot.y + y);

              // Draw all time slices.
              for (int i = 0; i < getMeasureStartCount(); ++i)
            getMeasureStart(i).draw(graphics);
        }
开发者ID:svejdo1,项目名称:niffty,代码行数:15,代码来源:Staff.cs

示例9: DrawArrow

        public static void DrawArrow(IGraphics g, Coordinates startingLoc, Coordinates direction, double len, double headSize, Color lineColor, WorldTransform wt)
        {
            Coordinates endingLoc = startingLoc + direction.Normalize(len);
            Coordinates headPt0 = endingLoc + direction.Rotate(135*Math.PI/180.0).Normalize(headSize);
            Coordinates headPt1 = endingLoc + direction.Rotate(-135*Math.PI/180.0).Normalize(headSize);

            IPen pen = g.CreatePen();
            pen.Width = 3/wt.Scale;
            pen.Color = Color.White;

            PointF ptfStart = Utility.ToPointF(startingLoc);
            PointF ptfEnd = Utility.ToPointF(endingLoc);
            PointF ptfHeadPt0 = Utility.ToPointF(headPt0);
            PointF ptfHeadPt1 = Utility.ToPointF(headPt1);

            PointF[] headPts = new PointF[] { ptfHeadPt0, ptfEnd, ptfHeadPt1 };
            g.DrawLine(pen, ptfStart, ptfEnd);
            g.DrawLines(pen, headPts);

            pen.Width = 1/wt.Scale;
            pen.Color = lineColor;
            g.DrawLine(pen, ptfStart, ptfEnd);
            g.DrawLines(pen, headPts);
        }
开发者ID:anand-ajmera,项目名称:cornell-urban-challenge,代码行数:24,代码来源:DrawingUtility.cs

示例10: draw

        public override void draw(IGraphics graphics)
        {
            if (getStaffCount() == 0)
            // Nothing to draw
            return;

              // Debug: should check for multistaff barline tags
              FinalPoint top = getScreenHotspot();
              int bottomY =
            getStaff(getStaffCount() - 1).getScreenHotspot().y +
            Notehead.staffStepOffsetY(0);
              graphics.DrawLine(top.x, top.y, top.x, bottomY);

              for (int i = 0; i < getStaffCount(); ++i)
            getStaff(i).draw(graphics);
        }
开发者ID:svejdo1,项目名称:niffty,代码行数:16,代码来源:StaffSystem.cs

示例11: PaintIndicator

 private void PaintIndicator(IGraphics g, int width, int height)
 {
     Brush2 indicatorBrush = new Brush2(IndicatorColor);
     Pen2 indicatorPen = new Pen2(ForeColor);
     float len = GetDeltaIndicator(GetLength(width, height));
     if (IsHorizontal()){
         if (len >= 1){
             g.FillRectangle(indicatorBrush, GetMinIndicator(GetLength(width, height)), 0, len, height - 1);
             g.DrawRectangle(indicatorPen, GetMinIndicator(GetLength(width, height)), 0, len, height - 1);
         } else{
             g.DrawLine(indicatorPen, GetMinIndicator(GetLength(width, height)), 0, GetMinIndicator(GetLength(width, height)),
                 height - 1);
         }
     } else{
         if (len >= 1){
             g.FillRectangle(indicatorBrush, 0, GetMinIndicator(GetLength(width, height)), width - 1, len);
             g.DrawRectangle(indicatorPen, 0, GetMinIndicator(GetLength(width, height)), width - 1, len);
         } else{
             g.DrawLine(indicatorPen, 0, GetMinIndicator(GetLength(width, height)), width - 1,
                 GetMinIndicator(GetLength(width, height)));
         }
     }
 }
开发者ID:JurgenCox,项目名称:compbio-base,代码行数:23,代码来源:NumericAxisView.cs

示例12: OnPaintBackground

 protected internal override void OnPaintBackground(IGraphics g, int width, int height)
 {
     Pen p = new Pen(Color.FromArgb(172, 168, 153));
     g.DrawLine(p, 0, height - 1, width, height - 1);
     int[] start = new[]{243, 241, 236};
     int[] end = new[]{254, 254, 251};
     int[][] rgbs = FormUtil.InterpolateRgb(start, end, CompoundScrollableControl.scrollBarWidth - 2);
     for (int i = 0; i < CompoundScrollableControl.scrollBarWidth - 2; i++){
         p = new Pen(Color.FromArgb(rgbs[0][i], rgbs[1][i], rgbs[2][i]));
         g.DrawLine(p, 0, i + 1, width, i + 1);
     }
     p = new Pen(Color.FromArgb(238, 237, 229));
     g.DrawLine(p, 0, 0, width, 0);
     g.DrawLine(p, 0, height - 2, width, height - 2);
 }
开发者ID:neuhauser,项目名称:compbio-base,代码行数:15,代码来源:HorizontalScrollBarView.cs

示例13: Render


//.........这里部分代码省略.........

                        ig.EndContainer(cnt3);

                    ig.EndContainer(cnt2);

                    ig.FillEllipse(new SolidBrush(Color.Blue), 120,150,80,40);
                    ig.DrawRectangle(new Pen(Color.Blue,2), 64,80,40,40);

                ig.EndContainer(cnt);

                ig.FillEllipse(new SolidBrush(Color.Indigo), 80,210,80,40);
                ig.DrawRectangle(new Pen(Color.Indigo,2), 66,80,40,40);

                ig.DrawRectangle(new Pen(Color.White,2), 270,30,50,40);
                ig.ResetTransform();
                ig.DrawRectangle(new Pen(Color.White,2), 270,30,50,40);

            }
            else if (s == "Lines")
            {
                ig.SmoothingMode = SmoothingMode.AntiAlias;

                Pen ow = new Pen(Color.Purple, 12);
                ow.EndCap = LineCap.Round;
                ow.StartCap = LineCap.Round;
                ow.MiterLimit = 6f;
                ow.LineJoin = LineJoin.Miter;

                ig.SmoothingMode = SmoothingMode.None;

                Pen tp = new Pen(Color.Red, 2);
                tp.DashStyle = DashStyle.DashDot;

                ig.DrawLine(tp, 70,20,190,20);

                tp.DashStyle = DashStyle.Dash;

                ig.DrawLine(tp, 70,30,190,30);

                tp.DashStyle = DashStyle.Custom;
                tp.DashPattern = new float[] {1,8,2,2};

                ig.DrawLine(tp, 70,40,190,40);

                ig.SmoothingMode = SmoothingMode.AntiAlias;

                PointF[] pts = new PointF[4];
                pts[0] = new PointF(20,50);
                pts[1] = new PointF(30,90);
                pts[2] = new PointF(65,60);
                pts[3] = new PointF(50,40);
                ig.DrawLines(ow, pts);

                Point[] polly = new Point[]
                {
                new Point(200, 40),
                new Point(220, 140),
                new Point(240, 100),
                new Point(290, 70),
                new Point(230, 10)
                };

                ig.DrawPolygon(tp, polly);

                //arrows
                Pen arr = new Pen(Color.DarkGoldenrod, 5);
开发者ID:luizcorreia,项目名称:SvgNet,代码行数:67,代码来源:Form1.cs

示例14: Draw

        public void Draw(IGraphics g)
        {
            g.BeginEntity (this);

            var now = DateTime.Now;

            var r = Math.Min (Width / 2, Height / 2);
            var center = new System.Drawing.PointF (Width / 2, Height / 2);

            //
            // Draw the face
            //
            g.SetColor (BackColor);
            g.FillOval (center.X - r, center.Y - r, 2 * r, 2 * r);
            g.SetColor (BorderColor);
            g.DrawOval (center.X - r + 4, center.Y - r + 4, 2 * r - 8, 2 * r - 8, 8);

            g.SetColor (FaceColor);
            for (var i = 0; i < 12; i++) {
                var angle = (i / 12.0) * 2 * Math.PI;
                g.DrawLine (
                    center.X + 0.75f * r * (float)Math.Cos (angle),
                    center.Y + 0.75f * r * (float)Math.Sin (angle),
                    center.X + 0.9f * r * (float)Math.Cos (angle),
                    center.Y + 0.9f * r * (float)Math.Sin (angle),
                    7);
            }
            g.SetFont (LabelFont);
            var textWidth = g.GetFontMetrics ().StringWidth ("Cross Graphics");
            g.DrawString ("Cross Graphics", center.X - textWidth / 2, center.Y + 0.25f * r);

            //
            // Draw the hour hand
            //
            g.SetColor (Colors.DarkGray);
            var h = now.Hour + now.Minute / 60.0;
            var hAngle = h > 12 ?
                ((h - 12) / 12.0 * 2 * Math.PI - Math.PI /2) :
                (h / 12.0 * 2 * Math.PI - Math.PI / 2);
            g.DrawLine (
                center.X + -0.1f * r * (float)Math.Cos (hAngle),
                center.Y + -0.1f * r * (float)Math.Sin (hAngle),
                center.X + 0.65f * r * (float)Math.Cos (hAngle),
                center.Y + 0.65f * r * (float)Math.Sin (hAngle),
                7);

            //
            // Draw the minute hand
            //
            g.SetColor (Colors.DarkGray);
            var m = now.Minute + now.Second / 60.0;
            var mAngle = (m / 60.0) * 2 * Math.PI - Math.PI / 2;
            g.DrawLine (
                center.X + -0.15f * r * (float)Math.Cos (mAngle),
                center.Y + -0.15f * r * (float)Math.Sin (mAngle),
                center.X + 0.85f * r * (float)Math.Cos (mAngle),
                center.Y + 0.85f * r * (float)Math.Sin (mAngle),
                5);

            //
            // Draw the second hand
            //
            g.SetColor (Colors.Red);
            var sAngle = (now.Second / 60.0) * 2 * Math.PI - Math.PI / 2;
            g.DrawLine (
                center.X + -0.15f * r * (float)Math.Cos (sAngle),
                center.Y + -0.15f * r * (float)Math.Sin (sAngle),
                center.X + 0.85f * r * (float)Math.Cos (sAngle),
                center.Y + 0.85f * r * (float)Math.Sin (sAngle),
                1);

            //
            // Draw the pin
            //
            g.SetColor (Colors.Black);
            g.FillOval (center.X - 5, center.Y - 5, 10, 10);
        }
开发者ID:JoeStrout,项目名称:CrossGraphics,代码行数:77,代码来源:Clock.cs

示例15: OnPaint

 // Called in order to paint graphics for this robot.
 // "Paint" button on the robot console window for this robot must be
 // enabled in order to see the paintings.
 public override void OnPaint(IGraphics g)
 {
     // Draw a red cross hair with the center at the current aim
     // coordinate (x,y)
     g.DrawEllipse(Pens.Red, aimX - 15, aimY - 15, 30, 30);
     g.DrawLine(Pens.Red, aimX, aimY - 4, aimX, aimY + 4);
     g.DrawLine(Pens.Red, aimX - 4, aimY, aimX + 4, aimY);
 }
开发者ID:markthor,项目名称:robocode,代码行数:11,代码来源:Interactive.cs


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