上面一种方法没停止控制啊!
没MouseUp怎么判断停止?
没MouseUp怎么判断停止?
解决方案 »
- 【关于TLV数据报的构造与解析,望前辈指点】
- C/S模式求助?谢谢~
- [有难度!]windows有没有对应用程序的打开和关闭情况进行记录?没有的话用C#怎么干?
- 如何通过在C#中利用按钮的单击事件,运行“outlook”?请给代码
- ASP.NET2.0 网站问题
- 救命!如何用C#在SqlServer2000的安全性-->登录中新建登录?
- vbs转换成c#,请帮忙改一下
- 请教高手关于C#套打打印功能怎么实现,能有源码学习更好
- 跪求vs.net2003 msdn的那三张盘!!
- DataSet中存在多个表,要把多个表中的记录存放在一个DataGrid中该如何操作?
- 求大虾们给我些深入点的C#教程啊
- 求Datatable与string[]之间的转换代码
public partial class Form1 : Form
{
System.Drawing.Region r = new Region(new Rectangle(0, 0, 50, 50));
GraphicsPath myPath;
Region myRegion;
bool IsMouseDown = false;
int EntryX, EntryY;
int StartPosX, StartPosY;
int tempX, tempY;
Bitmap image1 = (Bitmap)Image.FromFile(@"C:\Documents and Settings\Adiministrater\My Documents\Visual Studio 2008\Projects\testGDI+\testGDI+\Resources\TutorLogo.jpg", true);
TextureBrush Tb;
int posX, posY;
public Form1()
{
Tb= new TextureBrush(image1);
Tb.WrapMode = WrapMode.Clamp;
tempX = StartPosX = 60;
tempY = StartPosY = 60;
tempX = StartPosX;
tempY = StartPosY;
myPath = new GraphicsPath();
myPath.AddEllipse(StartPosX, StartPosY, 30, 30);
myRegion = new Region(myPath);
Tb.TranslateTransform(StartPosX, StartPosY);
InitializeComponent();
this.AutoScrollMinSize = new Size(1280,1024);
} private void Form1_Load(object sender, EventArgs e)
{
} protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics; //平移坐标系
g.TranslateTransform(this.AutoScrollPosition.X, this.AutoScrollPosition.Y);
this.BackgroundImage = Properties.Resources.IMAGE_01副本;
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.FillRegion(Tb, myRegion);
Tb.TranslateTransform(EntryX - posX, EntryY - posY);
}
private void Form1_MouseClick(object sender, MouseEventArgs e)
{
MessageBox.Show(e.X.ToString() + " " + e.Y.ToString());
} private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if(myRegion.IsVisible(new Point(e.X, e.Y)))
this.IsMouseDown = true;
if (e.Button == MouseButtons.Left)
{
EntryX = e.X;
EntryY = e.Y; //MessageBox.Show(EntryX.ToString() + " " + EntryY.ToString());
}
} private void Form1_MouseUp(object sender, MouseEventArgs e)
{
this.IsMouseDown = false;
StartPosX = tempX;
StartPosY = tempY; } private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (IsMouseDown && e.Button == MouseButtons.Left)
{
tempX = StartPosX;
tempY = StartPosY;
tempX += (e.X - EntryX);
tempY += (e.Y - EntryY);
posX = e.X;
posY = e.Y;
myPath = new GraphicsPath();
myPath.AddEllipse(tempX, tempY, 30, 30);
myRegion = new Region(myPath);
Tb.TranslateTransform(e.X - EntryX, e.Y - EntryY);
pictureBox1.Invalidate();
}
}
这是改过的能用的,之前写的那个Form1_MouseMove就不行,为什么