• 大小: 38KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-29
  • 语言: C#
  • 标签: 自绘箭头  

资源简介

C#绘制箭头和PDF里面的箭头一样,并不是用系统自带的箭头画的。

资源截图

代码片段和文件信息

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;
using System.Drawing.Drawing2D;

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

        private void Form1_Load(object sender EventArgs e)
        {

        }

        private void Form1_Paint(object sender PaintEventArgs e)
        {
            
            Arrow(e.Graphics 20 20 200 220 50);
        }
        /// 
        /// 
        /// 

        /// 
        /// 起点X
        /// 起点Y
        /// 终点X
        /// 终点Y
        /// 箭头大小
        public void Arrow(Graphics Pic float X0 float Y0 float X1 float Y1 float ArrowLen)
        {
            Pic.SmoothingMode = SmoothingMode.AntiAlias;
            float Xa;
            float Ya;
            float Xb;
            float Yb;
            float D;
            Pen p = new Pen(Color.Black 3);
            D = (float)Math.Sqrt((Y1 - Y0) * (Y1 - Y0) + (X1 - X0) * (X1 - X0));
            if (D > 0.0000000001)
            {
                Xa = X1 + ArrowLen * ((X0 - X1) + (Y0 - Y1) / (float)2) / D;
                Ya = Y1 + ArrowLen * ((Y0 - Y1) - (X0 - X1) / (float)2) / D;
                Xb = X1 + ArrowLen * ((X0 - X1) - (Y0 - Y1) / (float)2) / D;
                Yb = Y1 + ArrowLen * ((Y0 - Y1) + (X0 - X1) / (float)2) / D;


                Pic.DrawLine(p Xa Ya X1 Y1);
               // Pic.Line(Xa Ya);/* TODO ERROR: Skipped SkippedTokensTrivia *//* TODO ERROR: Skipped SkippedTokensTrivia */
                //Pic.Line(Xb Yb);/* TODO ERROR: Skipped SkippedTokensTrivia *//* TODO ERROR: Skipped SkippedTokensTrivia */
                Pic.DrawLine(p Xb Yb X1 Y1);
               // Pic.Line(X0 Y0);/* TODO ERROR: Skipped SkippedTokensTrivia *//* TODO ERROR: Skipped SkippedTokensTrivia */ // 如果仅画箭头,此句可删除
                Pic.DrawLine(p X0 Y0 X1 Y1);
            }
        }

    }
}

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

     文件       9216  2018-11-13 13:34  WindowsFormsApplication32\WindowsFormsApplication32\bin\Debug\WindowsFormsApplication32.exe

     文件      26112  2018-11-13 13:34  WindowsFormsApplication32\WindowsFormsApplication32\bin\Debug\WindowsFormsApplication32.pdb

     文件      11600  2018-11-13 13:33  WindowsFormsApplication32\WindowsFormsApplication32\bin\Debug\WindowsFormsApplication32.vshost.exe

     文件        490  2012-06-06 02:06  WindowsFormsApplication32\WindowsFormsApplication32\bin\Debug\WindowsFormsApplication32.vshost.exe.manifest

     文件       2369  2018-11-13 13:34  WindowsFormsApplication32\WindowsFormsApplication32\Form1.cs

     文件       1569  2018-11-13 13:08  WindowsFormsApplication32\WindowsFormsApplication32\Form1.Designer.cs

     文件       5817  2018-11-13 13:08  WindowsFormsApplication32\WindowsFormsApplication32\Form1.resx

     文件       2867  2018-11-13 13:07  WindowsFormsApplication32\WindowsFormsApplication32\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6411  2018-11-13 13:34  WindowsFormsApplication32\WindowsFormsApplication32\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        890  2018-11-13 13:33  WindowsFormsApplication32\WindowsFormsApplication32\obj\x86\Debug\WindowsFormsApplication32.csproj.FileListAbsolute.txt

     文件        975  2018-11-13 13:09  WindowsFormsApplication32\WindowsFormsApplication32\obj\x86\Debug\WindowsFormsApplication32.csproj.GenerateResource.Cache

     文件       9216  2018-11-13 13:34  WindowsFormsApplication32\WindowsFormsApplication32\obj\x86\Debug\WindowsFormsApplication32.exe

     文件        180  2018-11-13 13:09  WindowsFormsApplication32\WindowsFormsApplication32\obj\x86\Debug\WindowsFormsApplication32.Form1.resources

     文件      26112  2018-11-13 13:34  WindowsFormsApplication32\WindowsFormsApplication32\obj\x86\Debug\WindowsFormsApplication32.pdb

     文件        180  2018-11-13 13:09  WindowsFormsApplication32\WindowsFormsApplication32\obj\x86\Debug\WindowsFormsApplication32.Properties.Resources.resources

     文件        506  2018-11-13 13:07  WindowsFormsApplication32\WindowsFormsApplication32\Program.cs

     文件       1400  2018-11-13 13:07  WindowsFormsApplication32\WindowsFormsApplication32\Properties\AssemblyInfo.cs

     文件       2902  2018-11-13 13:07  WindowsFormsApplication32\WindowsFormsApplication32\Properties\Resources.Designer.cs

     文件       5612  2018-11-13 13:07  WindowsFormsApplication32\WindowsFormsApplication32\Properties\Resources.resx

     文件       1112  2018-11-13 13:07  WindowsFormsApplication32\WindowsFormsApplication32\Properties\Settings.Designer.cs

     文件        249  2018-11-13 13:07  WindowsFormsApplication32\WindowsFormsApplication32\Properties\Settings.settings

     文件       3709  2018-11-13 13:09  WindowsFormsApplication32\WindowsFormsApplication32\WindowsFormsApplication32.csproj

     文件        917  2018-11-13 13:07  WindowsFormsApplication32\WindowsFormsApplication32.sln

    ..A..H.      9216  2018-11-13 13:22  WindowsFormsApplication32\WindowsFormsApplication32.suo

     目录          0  2018-11-13 13:07  WindowsFormsApplication32\WindowsFormsApplication32\obj\x86\Debug\TempPE

     目录          0  2018-11-13 13:34  WindowsFormsApplication32\WindowsFormsApplication32\obj\x86\Debug

     目录          0  2018-11-13 13:09  WindowsFormsApplication32\WindowsFormsApplication32\bin\Debug

     目录          0  2018-11-13 13:07  WindowsFormsApplication32\WindowsFormsApplication32\obj\x86

     目录          0  2018-11-13 13:07  WindowsFormsApplication32\WindowsFormsApplication32\bin

     目录          0  2018-11-13 13:07  WindowsFormsApplication32\WindowsFormsApplication32\obj

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

评论

共有 条评论

相关资源