-
大小: 37KB文件类型: .rar金币: 1下载: 0 次发布日期: 2021-06-08
- 语言: 其他
- 标签: picturebox
资源简介
T392419114 论坛问题的回答,画一个矩形,并且让矩形可以移动 https://bbs.csdn.net/topics/392419114
代码片段和文件信息
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 T392419114
{
public partial class Form1 : Form
{
private int x = 100;
private int y = 100;
private int w = 120;
private int h = 80;
public Form1()
{
InitializeComponent();
pictureBox1.Refresh();
}
int dx = 0;
int dy = 0;
private void pictureBox1_MouseMove(object sender MouseEventArgs e)
{
if (e.X >= x && e.X <= x + w && e.Y >= y && e.Y <= y + h)
{
this.Cursor = Cursors.Hand;
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
x = e.X - dx;
y = e.Y - dy;
pictureBox1.Refresh();
}
else
{
dx = e.X - x;
dy = e.Y - y;
}
}
else
{
if (e.Button == System.Windows.Forms.MouseButtons.None) this.Cursor = Cursors.Default;
}
}
private void pictureBox1_Paint(object sender PaintEventArgs e)
{
base.OnPaint(e);
Graphics sss = e.Graphics;
Pen testpen = new Pen(Color.Red 3);
sss.DrawRectangle(testpen x y w h);
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 9216 2018-07-22 23:42 T392419114\T392419114\bin\Debug\T392419114.exe
文件 26112 2018-07-22 23:42 T392419114\T392419114\bin\Debug\T392419114.pdb
文件 11600 2018-07-22 23:22 T392419114\T392419114\bin\Debug\T392419114.vshost.exe
文件 490 2018-04-12 07:35 T392419114\T392419114\bin\Debug\T392419114.vshost.exe.manifest
文件 1587 2018-07-22 23:42 T392419114\T392419114\Form1.cs
文件 2344 2018-07-22 23:31 T392419114\T392419114\Form1.Designer.cs
文件 5817 2018-07-22 23:31 T392419114\T392419114\Form1.resx
文件 2867 2018-07-22 23:22 T392419114\T392419114\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6414 2018-07-22 23:42 T392419114\T392419114\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 792 2018-07-22 23:29 T392419114\T392419114\obj\x86\Debug\T392419114.csproj.FileListAbsolute.txt
文件 975 2018-07-22 23:31 T392419114\T392419114\obj\x86\Debug\T392419114.csproj.GenerateResource.Cache
文件 9216 2018-07-22 23:42 T392419114\T392419114\obj\x86\Debug\T392419114.exe
文件 180 2018-07-22 23:31 T392419114\T392419114\obj\x86\Debug\T392419114.Form1.resources
文件 26112 2018-07-22 23:42 T392419114\T392419114\obj\x86\Debug\T392419114.pdb
文件 180 2018-07-22 23:24 T392419114\T392419114\obj\x86\Debug\T392419114.Properties.Resources.resources
文件 502 2018-07-22 23:22 T392419114\T392419114\Program.cs
文件 1432 2018-07-22 23:22 T392419114\T392419114\Properties\AssemblyInfo.cs
文件 2850 2018-07-22 23:22 T392419114\T392419114\Properties\Resources.Designer.cs
文件 5612 2018-07-22 23:22 T392419114\T392419114\Properties\Resources.resx
文件 1097 2018-07-22 23:22 T392419114\T392419114\Properties\Settings.Designer.cs
文件 249 2018-07-22 23:22 T392419114\T392419114\Properties\Settings.settings
文件 3679 2018-07-22 23:24 T392419114\T392419114\T392419114.csproj
文件 872 2018-07-22 23:22 T392419114\T392419114.sln
..A..H. 18944 2018-07-22 23:43 T392419114\T392419114.suo
目录 0 2018-07-22 23:22 T392419114\T392419114\obj\x86\Debug\TempPE
目录 0 2018-07-22 23:42 T392419114\T392419114\obj\x86\Debug
目录 0 2018-07-22 23:24 T392419114\T392419114\bin\Debug
目录 0 2018-07-22 23:22 T392419114\T392419114\obj\x86
目录 0 2018-07-22 23:22 T392419114\T392419114\bin
目录 0 2018-07-22 23:22 T392419114\T392419114\obj
............此处省略6个文件信息
评论
共有 条评论