• 大小: 48KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-09
  • 语言: C#
  • 标签: 画线  C#画直线  

资源简介

C#实现在winform控件上画线。e.Graphics.DrawLine画直线。可调颜色,粗细

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void pictureBox1_Paint(object sender PaintEventArgs e)
        {
            // Create pen.(颜色、线条大小)
            Pen blackPen1 = new Pen(Color.Black 3);
            Pen blackPen2 = new Pen(Color.Green 8);

            // Create coordinates of points that define line.
            float x1 = 100.0F;
            float y1 = 100.0F;
            float x2 = 500.0F;
            float y2 = 100.0F;

            int x3 = 10;
            int y3 = 10;
            int x4 = 10;
            int y4 = 500;

            // Draw line to screen.
            e.Graphics.DrawLine(blackPen1 x1 y1 x2 y2);
            e.Graphics.DrawLine(blackPen2 x3 y3 x4 y4);

        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       9216  2014-07-22 19:59  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe

     文件      32256  2014-07-22 19:59  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb

     文件      11600  2014-07-22 19:59  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe

     文件        490  2010-03-17 22:39  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest

     文件       1097  2014-07-22 19:59  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs

     文件       2235  2014-07-22 19:59  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs

     文件       5817  2014-07-22 19:59  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\Form1.resx

     文件       4440  2014-07-21 16:15  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6493  2014-07-22 19:59  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        978  2014-07-22 19:59  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\GenerateResource.read.1.tlog

     文件       2290  2014-07-22 19:59  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\GenerateResource.write.1.tlog

     文件       7897  2014-07-21 16:16  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\ResolveAssemblyReference.cache

     文件       2957  2014-07-22 19:59  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt

     文件       9216  2014-07-22 19:59  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.exe

     文件        180  2014-07-22 19:59  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.Form1.resources

     文件      32256  2014-07-22 19:59  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.pdb

     文件        180  2014-07-22 19:57  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\WindowsFormsApplication1.Properties.Resources.resources

     文件        539  2014-07-21 11:07  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\Program.cs

     文件       1404  2014-07-21 10:41  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\Properties\AssemblyInfo.cs

     文件       2896  2014-07-21 10:41  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\Properties\Resources.Designer.cs

     文件       5612  2014-07-21 10:41  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\Properties\Resources.resx

     文件       1107  2014-07-21 10:41  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\Properties\Settings.Designer.cs

     文件        249  2014-07-21 10:41  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\Properties\Settings.settings

     文件       3707  2014-07-21 10:42  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\WindowsFormsApplication1.csproj

     文件        914  2014-07-21 10:41  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1.sln

    ..A..H.     21504  2014-07-22 19:59  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1.suo

     目录          0  2014-07-21 10:41  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug\TempPE

     目录          0  2014-07-22 19:59  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86\Debug

     目录          0  2014-07-21 10:42  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug

     目录          0  2014-07-21 10:41  在控件上画直线(例子)\WindowsFormsApplication1\WindowsFormsApplication1\obj\x86

............此处省略9个文件信息

评论

共有 条评论