C# 绘制50000个矩形框
来源:互联网 发布:英迈零售软件 编辑:程序博客网 时间:2024/05/30 23:02
using System;using System.Collections.Generic;using System.Drawing;using System.Linq;using System.Windows.Forms;namespace WindowsFormsApplication3{ public class LineControl : Control { public LineControl() { base.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); } Bitmap bmp = null; protected override void OnSizeChanged(EventArgs e) { Random rnd = new Random(100); bmp = new Bitmap(this.Width, this.Height); Graphics g = Graphics.FromImage(bmp); System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); for (int i = 0; i < 5000; i++) { Rectangle rect = new Rectangle(); rect.Width = 10; rect.Height = 10; rect.X = rnd.Next(0, this.Width); rect.Y = rnd.Next(0, this.Height); gp.AddRectangle(rect); } g.DrawPath(Pens.Red, gp); base.OnSizeChanged(e); this.Invalidate(); } public Point pt = Point.Empty; protected override void OnMouseMove(MouseEventArgs e) { pt = e.Location; this.Invalidate(); base.OnMouseMove(e); } protected override void OnPaint(PaintEventArgs e) { e.Graphics.DrawImage(bmp, 0, 0, this.Width, this.Height); e.Graphics.DrawLine(Pens.RoyalBlue, pt.X, 0, pt.X, this.Height); e.Graphics.DrawLine(Pens.RoyalBlue, 0, pt.Y, this.Width, pt.Y); base.OnPaint(e); } }}
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 WindowsFormsApplication3{ public partial class Form1 : Form { public Form1() { InitializeComponent(); base.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); } protected override void OnMouseMove(MouseEventArgs e) { this.Invalidate(); base.OnMouseMove(e); } }}
namespace WindowsFormsApplication3{ partial class Form1 { /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// 清理所有正在使用的资源。 /// </summary> /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 /// </summary> private void InitializeComponent() { this.lineControl1 = new WindowsFormsApplication3.LineControl(); this.SuspendLayout(); // // lineControl1 // this.lineControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.lineControl1.Location = new System.Drawing.Point(12, 1); this.lineControl1.Name = "lineControl1"; this.lineControl1.Size = new System.Drawing.Size(941, 474); this.lineControl1.TabIndex = 0; this.lineControl1.Text = "lineControl1"; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(965, 487); this.Controls.Add(this.lineControl1); this.Name = "Form1"; this.Text = "Form1"; this.ResumeLayout(false); } #endregion private LineControl lineControl1; }}
阅读全文
0 0
- C# 绘制50000个矩形框
- C#绘制浮点矩形
- C#绘制圆角矩形
- 绘制矩形框 OpenCV
- C# GDI+ 绘制圆角实心矩形
- c# winfrom 在panel上绘制矩形
- C# 图形的绘制矩形椭圆
- 用js绘制矩形框
- 用js绘制矩形框
- MFC 鼠标绘制矩形框
- 绘制矩形
- C#用鼠标在控件上绘制虚线框,并且获取矩形。
- Raphael使用g元素绘制多个矩形
- C++(11):OpenGL坐标系及绘制多个矩形
- c#画笔使用复合数组绘制单个矩形
- 矩形框绘制_运动检测_OpenCV
- 矩形框绘制_运动检测_OpenCV
- win32 sdk绘制矩形选择框
- LeetCode:Combination Sum
- 记201607-201707实习收获
- 涂鸦电话面试一面
- js设计模式--观察者模(发布订阅模式)
- TCP 的那些事儿
- C# 绘制50000个矩形框
- Android 判断当前的网络状态
- Unity 2D游戏制作
- 安装maven后,运行mvn help:system报Non-parseable错误
- AngularJS杂记4----模型 ng-model
- Java Web学习总结53:Web应用中使用JavaMail发送邮件
- yarn使用cgroup隔离cpu资源
- 翻转单链表
- php curl模拟登录discuz并模拟发帖的实现方法