當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。