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


C# Line.Draw方法代码示例

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


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

示例1: FillRectangle

 /// <summary>
 /// Fills a Rectangle.
 /// </summary>
 /// <param name="color">The Color.</param>
 /// <param name="rectangle">The Rectangle.</param>
 public void FillRectangle(Color color, Rectangle rectangle)
 {
     var line = new Line(_direct3D9Device) {Antialias = true, Width = rectangle.Height};
     line.Begin();
     line.Draw(
         DirectXHelper.ConvertToVertex(new Vector2(rectangle.X, rectangle.Center.Y),
             new Vector2(rectangle.X + rectangle.Width, rectangle.Center.Y)),
         DirectXHelper.ConvertColor(color));
     line.End();
 }
开发者ID:ThuCommix,项目名称:Sharpex2D,代码行数:15,代码来源:DirectXGraphics.cs

示例2: EndSceneHook


//.........这里部分代码省略.........
                                        new SlimDX.Vector2(_renderTarget.Description.Width - 1, _renderTarget.Description.Height - 1),
                                        new SlimDX.Vector2(0, _renderTarget.Description.Height - 1),
                                        new SlimDX.Vector2(_renderTarget.Description.Width - 1, 0),
                                        new SlimDX.Vector2(0, 0),
                                        new SlimDX.Vector2(0, _renderTarget.Description.Height - 1),
                                        new SlimDX.Vector2(_renderTarget.Description.Width - 1, _renderTarget.Description.Height - 1),
                                        new SlimDX.Vector2(_renderTarget.Description.Width - 1, 0),
                                    };
                                }
                                else
                                {
                                    _lineVectors = new SlimDX.Vector2[] { 
                                        new SlimDX.Vector2(this.Request.RegionToCapture.X, this.Request.RegionToCapture.Y),
                                        new SlimDX.Vector2(this.Request.RegionToCapture.Right, this.Request.RegionToCapture.Bottom),
                                        new SlimDX.Vector2(this.Request.RegionToCapture.X, this.Request.RegionToCapture.Bottom),
                                        new SlimDX.Vector2(this.Request.RegionToCapture.Right, this.Request.RegionToCapture.Y),
                                        new SlimDX.Vector2(this.Request.RegionToCapture.X, this.Request.RegionToCapture.Y),
                                        new SlimDX.Vector2(this.Request.RegionToCapture.X, this.Request.RegionToCapture.Bottom),
                                        new SlimDX.Vector2(this.Request.RegionToCapture.Right, this.Request.RegionToCapture.Bottom),
                                        new SlimDX.Vector2(this.Request.RegionToCapture.Right, this.Request.RegionToCapture.Y),
                                    };
                                }
                                #endregion

                                using (Surface backBuffer = device.GetBackBuffer(0, 0))
                                {
                                    // Create a super fast copy of the back buffer on our Surface
                                    device.GetRenderTargetData(backBuffer, _renderTarget);

                                    // We have the back buffer data and can now work on copying it to a bitmap
                                    ProcessRequest();
                                }
                            }
                            finally
                            {
                                // We have completed the request - mark it as null so we do not continue to try to capture the same request
                                // Note: If you are after high frame rates, consider implementing buffers here to capture more frequently
                                //         and send back to the host application as needed. The IPC overhead significantly slows down 
                                //         the whole process if sending frame by frame.
                                Request = null;
                            }
                            DateTime end = DateTime.Now;
                            this.DebugMessage("EndSceneHook: Capture time: " + (end - start).ToString());
                            _lastScreenshotTime = (end - start);
                        }
                    }
                    #endregion

                    #region Example: Draw Overlay (after screenshot so we don't capture overlay as well)

                    if (this.ShowOverlay)
                    {
                        #region Draw fading lines based on last screencapture request
                        if (_lastRequestTime != null && _lineVectors != null)
                        {
                            TimeSpan timeSinceRequest = DateTime.Now - _lastRequestTime.Value;
                            if (timeSinceRequest.TotalMilliseconds < 1000.0)
                            {
                                using (Line line = new Line(device))
                                {
                                    _lineAlpha = (float)((1000.0 - timeSinceRequest.TotalMilliseconds) / 1000.0); // This is our fade out
                                    line.Antialias = true;
                                    line.Width = 1.0f;
                                    line.Begin();
                                    line.Draw(_lineVectors, new SlimDX.Color4(_lineAlpha, 0.5f, 0.5f, 1.0f));
                                    line.End();
                                }
                            }
                            else
                            {
                                _lineVectors = null;
                            }
                        }
                        #endregion

                        #region Draw frame rate
                        using (SlimDX.Direct3D9.Font font = new SlimDX.Direct3D9.Font(device, new System.Drawing.Font("Times New Roman", 16.0f)))
                        {
                            if (_lastFrame != null)
                            {
                                font.DrawString(null, String.Format("{0:N1} fps", (1000.0 / (DateTime.Now - _lastFrame.Value).TotalMilliseconds)), 100, 100, System.Drawing.Color.Red);
                            }
                            _lastFrame = DateTime.Now;
                        }
                        #endregion
                    }

                    #endregion
                }
                catch(Exception e)
                {
                    // If there is an error we do not want to crash the hooked application, so swallow the exception
                    this.DebugMessage("EndSceneHook: Exeception: " + e.GetType().FullName + ": " + e.Message);
                }

                // EasyHook has already repatched the original EndScene - so calling EndScene against the SlimDX device will call the original
                // EndScene and bypass this hook. EasyHook will automatically reinstall the hook after this hook function exits.
                return device.EndScene().Code;
            }
        }
开发者ID:spazzarama,项目名称:Afterglow,代码行数:101,代码来源:DXHookD3D9.cs

示例3: DrawRectangle

        /// <summary>
        /// Draws a Rectangle.
        /// </summary>
        /// <param name="pen">The Pen.</param>
        /// <param name="rectangle">The Rectangle.</param>
        public void DrawRectangle(Pen pen, Rectangle rectangle)
        {
            var dxPen = pen.Instance as DirectXPen;
            if (dxPen == null) throw new ArgumentException("DirectX9 expects a DirectXPen as resource.");

            var line = new Line(_direct3D9Device) {Antialias = true, Width = dxPen.Width};
            line.Begin();

            line.Draw(
                DirectXHelper.ConvertToVertex(
                    new Vector2(rectangle.X, rectangle.Y),
                    new Vector2(rectangle.X + rectangle.Width, rectangle.Y),
                    new Vector2(rectangle.X, rectangle.Y + rectangle.Height),
                    new Vector2(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height),
                    new Vector2(rectangle.X, rectangle.Y),
                    new Vector2(rectangle.X, rectangle.Y + rectangle.Height),
                    new Vector2(rectangle.X + rectangle.Width, rectangle.Y),
                    new Vector2(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height)),
                DirectXHelper.ConvertColor(dxPen.Color));

            line.End();
        }
开发者ID:ThuCommix,项目名称:Sharpex2D,代码行数:27,代码来源:DirectXGraphics.cs

示例4: FillEllipse

        /// <summary>
        /// Fills a Ellipse.
        /// </summary>
        /// <param name="color">The Color.</param>
        /// <param name="ellipse">The Ellipse.</param>
        public void FillEllipse(Color color, Ellipse ellipse)
        {
            var line = new Line(_direct3D9Device) {Antialias = false, Width = 2};
            line.Begin();

            line.Draw(DirectXHelper.ConvertToVertex(ellipse.Points), DirectXHelper.ConvertColor(color));

            line.End();
        }
开发者ID:ThuCommix,项目名称:Sharpex2D,代码行数:14,代码来源:DirectXGraphics.cs

示例5: DrawPolygon

        /// <summary>
        /// Draws a Polygon.
        /// </summary>
        /// <param name="pen">The Pen.</param>
        /// <param name="polygon">The Polygon.</param>
        public void DrawPolygon(Pen pen, Polygon polygon)
        {
            var dxPen = pen.Instance as DirectXPen;
            if (dxPen == null) throw new ArgumentException("DirectX9 expects a DirectXPen as resource.");

            var line = new Line(_direct3D9Device) {Antialias = true, Width = dxPen.Width};
            line.Begin();
            line.Draw(DirectXHelper.ConvertToVertex(polygon.Points), DirectXHelper.ConvertColor(dxPen.Color));
            line.End();
        }
开发者ID:ThuCommix,项目名称:Sharpex2D,代码行数:15,代码来源:DirectXGraphics.cs

示例6: DrawLine

 /// <summary>
 /// Draws a line.
 /// </summary>
 /// <param name="token">The token.</param>
 /// <param name="startPoint">The start point.</param>
 /// <param name="endPoint">The end point.</param>
 public void DrawLine(char token, Coordinate startPoint, Coordinate endPoint)
 {
     var line = new Line(startPoint, endPoint, token);
     line.Draw(this);
 }
开发者ID:dineshkummarc,项目名称:FlagConsole,代码行数:11,代码来源:GraphicBuffer.cs

示例7: RenderEngine

        private void RenderEngine(object obj)
        {
            SolidBrush Background = new SolidBrush(Color.White);

            int Ticks_1000ms = Environment.TickCount;
            int Ticks_50ms = Environment.TickCount;
            Point Acceleration = new Point(0, 1); // 10 px down
            Point No_Acceleration = new Point(-Acceleration.X * 2, -Acceleration.Y * 2);
            Pen Arrow = new Pen(new SolidBrush(Color.Green), 2f);
            Pen TestPoints = new Pen(new SolidBrush(Color.Red), 1f);
            Pen TestCutts = new Pen(new SolidBrush(Color.Lime), 1f);
            Font fps_font = new Font("Arial", 12);
            SolidBrush fps_brush = new SolidBrush(Color.Black);

            Bitmap RenderedFrame = new Bitmap(Paint_Area.Width, Paint_Area.Height);
            Graphics f_Handle = Graphics.FromImage(RenderedFrame);
            //Obstacle Obs = new Obstacle(new Point())

            //TestCut = new Point(Paint_Area.Width / 2, Paint_Area.Height / 2);

            Cross Test = new Cross(new Point(Paint_Area.Width / 2, Paint_Area.Height / 2)); // centered test point
            Test.Color = Color.Green;

            Line Mirror = new Line();
            Mirror.Start = new Point(Paint_Area.Width / 2 - 100, Paint_Area.Height / 2 - 100);
            Mirror.End = new Point(Paint_Area.Width / 2 + 100, Paint_Area.Height / 2 + 100);
            Mirror.Color = Color.Gray;

            Line Exit = new Line();
            Exit.Color = Color.Red;
            Exit.Start = Test.Position;

            int fps = 0;
            int frames_rendered = 0;
            string info = "";
            double Angle = 45;
            double Length = 300;

            while(true)
            {
                // draw background
                f_Handle.FillRectangle(Background, Paint_Area);

                /*
                // draw balls
                foreach(Ball ball in Balls)
                {
                    ball.Draw(f_Handle);
                }

                // draw lines
                foreach(Obstacle obs in Lines)
                {
                    obs.Draw(f_Handle);
                }

                // draw arrow
                if (ShowArrow)
                {
                    f_Handle.DrawLine(Arrow, ArrowStart, ArrowEnd);

                    // calculate angle and arrow
                }*/

                f_Handle.DrawString(fps.ToString() + "fps", fps_font, fps_brush, 0, 0);

                // draw crosses
                Test.Draw(f_Handle, Paint_Area.Height);
                Actual.Draw(f_Handle, Paint_Area.Height);

                The.Start = Actual.Position;
                The.End = Test.Position;
                The.Draw(f_Handle, Paint_Area.Height);
                Mirror.Draw(f_Handle, Paint_Area.Height);

                // calculate end
                double beta = Mirror.Angle - The.Angle;
                double c = The.Lenght * Math.Cos(beta / 360 * 2 * Math.PI);

                Exit.End = new Point((int)(2 * c * Math.Cos(Mirror.Angle / 360 * 2 * Math.PI) + The.Start.X), (int)(2 * c * Math.Sin(Mirror.Angle / 360 * 2 * Math.PI) + The.Start.Y));
                Exit.Draw(f_Handle, Paint_Area.Height);

                // draw info
                info = "beta: " + beta.ToString() + "\n";
                info += "c: " + c.ToString();

                f_Handle.DrawString(info, fps_font, fps_brush, 0, 50);

                // draw line

                /*
                // testpoints
                f_Handle.DrawLine(TestPoints, TestStart.X - 10, TestStart.Y, TestStart.X + 10, TestStart.Y);
                f_Handle.DrawLine(TestPoints, TestStart.X, TestStart.Y - 10, TestStart.X, TestStart.Y + 10);
                f_Handle.DrawLine(TestPoints, TestEnd.X - 10, TestEnd.Y, TestEnd.X + 10, TestEnd.Y);
                f_Handle.DrawLine(TestPoints, TestEnd.X, TestEnd.Y - 10, TestEnd.X, TestEnd.Y + 10);
                f_Handle.DrawLine(TestCutts, TestCut.X - 10, TestCut.Y, TestCut.X + 10, TestCut.Y);
                f_Handle.DrawLine(TestCutts, TestCut.X, TestCut.Y - 10, TestCut.X, TestCut.Y + 10);*/

                // draw on screen
//.........这里部分代码省略.........
开发者ID:Al90,项目名称:Project,代码行数:101,代码来源:Engine.cs

示例8: DrawRectangle

 public static void DrawRectangle(System.Drawing.Rectangle rect, long color, bool fill)
 {
     if (fill)
       {
     System.Drawing.Rectangle[] regions = new System.Drawing.Rectangle[1]
     {
       rect
     };
     GUIGraphicsContext.DX9Device.Clear(ClearFlags.Target, (int)color, 1f, 0, regions);
       }
       else
       {
     Vector2[] vertexList = new Vector2[2];
     vertexList[0].X = (float)rect.Left;
     vertexList[0].Y = (float)rect.Top;
     vertexList[1].X = (float)(rect.Left + rect.Width);
     vertexList[1].Y = (float)rect.Top;
     using (Line line = new Line(GUIGraphicsContext.DX9Device))
     {
       line.Begin();
       line.Draw(vertexList, (int)color);
       vertexList[0].X = (float)(rect.Left + rect.Width);
       vertexList[0].Y = (float)rect.Top;
       vertexList[1].X = (float)(rect.Left + rect.Width);
       vertexList[1].Y = (float)(rect.Top + rect.Height);
       line.Draw(vertexList, (int)color);
       vertexList[0].X = (float)(rect.Left + rect.Width);
       vertexList[0].Y = (float)(rect.Top + rect.Width);
       vertexList[1].X = (float)rect.Left;
       vertexList[1].Y = (float)(rect.Top + rect.Height);
       line.Draw(vertexList, (int)color);
       vertexList[0].X = (float)rect.Left;
       vertexList[0].Y = (float)(rect.Top + rect.Height);
       vertexList[1].X = (float)rect.Left;
       vertexList[1].Y = (float)rect.Top;
       line.Draw(vertexList, (int)color);
       line.End();
     }
       }
 }
开发者ID:GuzziMP,项目名称:my-films,代码行数:40,代码来源:Picture.cs

示例9: DrawLine

 public static void DrawLine(int x1, int y1, int x2, int y2, long color)
 {
     Vector2[] vertexList = new Vector2[2];
       vertexList[0].X = (float)x1;
       vertexList[0].Y = (float)y1;
       vertexList[1].X = (float)x2;
       vertexList[1].Y = (float)y2;
       using (Line line = new Line(GUIGraphicsContext.DX9Device))
       {
     line.Begin();
     line.Draw(vertexList, (int)color);
     line.End();
       }
 }
开发者ID:GuzziMP,项目名称:my-films,代码行数:14,代码来源:Picture.cs


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