国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

winfrom-繪制十字線

2019-11-11 04:52:51
字體:
供稿:網(wǎng)友

using System;using System.Collections.Generic;using System.Drawing;using System.Drawing.Drawing2D;using System.Windows.Forms;namespace crossline{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();            ResizeRedraw = true; //改變大小重繪            DoubleBuffered = true;            SetStyle(ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);            this.Paint += new PaintEventHandler(Form1_Paint);            this.MouseClick += new MouseEventHandler(Form1_MouseClick);            this.MouseMove += new MouseEventHandler(Form1_MouseMove);            this.Resize += new EventHandler(this.Form1_Resize);        }        PRivate void Form1_Paint(object sender, PaintEventArgs e)        {            Pen pen = new Pen(Color.Black);            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;            e.Graphics.Clear(SystemColors.Control);            foreach (var p in dicPoint)            {                e.Graphics.DrawLine(pen, p[0], p[1]);                e.Graphics.DrawLine(pen, p[2], p[3]);            }            var lineP = GetPoint();            e.Graphics.DrawLine(pen, lineP[0], lineP[1]);            e.Graphics.DrawLine(pen, lineP[2], lineP[3]);            if (clickTag)            {                dicPoint.Add(lineP);                clickTag = false; //重置標(biāo)記            }        }        private Point[] GetPoint()        {            Point[] p = new Point[4];            var w = this.Width;            var h = this.Height;            p[0] = new Point(0, clickTag ? clickPoint.Y : mousePoint.Y);            p[1] = new Point(w, clickTag ? clickPoint.Y : mousePoint.Y);            p[2] = new Point(clickTag ? clickPoint.X : mousePoint.X, 0);            p[3] = new Point(clickTag ? clickPoint.X : mousePoint.X, h);            return p;        }        bool clickTag = false;        Point clickPoint, mousePoint;        readonly List<Point[]> dicPoint = new List<Point[]>();        private void Form1_MouseClick(object sender, MouseEventArgs e)        {            //if (e.Button == MouseButtons.Left)            clickTag = true;            clickPoint = new Point(e.X, e.Y);        }        private void Form1_Resize(object sender, EventArgs e)        {            this.label1.Text = string.Format("{0},{1}", Width, Height);            foreach (var p in dicPoint)            {                p[1].X = this.Width;                p[3].Y = this.Height;            }        }        private void Form1_MouseMove(object sender, MouseEventArgs e)        {            mousePoint = e.Location;            Invalidate();        }        //...    }}


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 外汇| 余庆县| 娄烦县| 梓潼县| 福建省| 潜江市| 东兴市| 阿坝县| 商丘市| 盐池县| 盱眙县| 获嘉县| 静乐县| 阜南县| 平昌县| 正镶白旗| 厦门市| 北辰区| 涿州市| 商都县| 廉江市| 全椒县| 乌兰浩特市| 琼结县| 古蔺县| 淮北市| 白玉县| 通州市| 区。| 平定县| 鸡西市| 云南省| 瑞昌市| 东城区| 武城县| 监利县| 静海县| 南通市| 黄山市| 夏津县| 仪陇县|