我在MouseMove事件中Graphics graphics = this.CreateGraphics();
Pen myPen = new Pen(Color.Red, 2);
graphics.DrawRectangle(myPen, ptStart.X, ptStart.Y, e.X - ptStart.X, e.Y - ptStart.Y);
使用画矩形框,一点反应也没有,请问怎么实现我的目的呢?private void pb_InqImagePart_MouseDown(object sender, MouseEventArgs e)
{
pictureOperation = PICTURE_OPERATION.START;
ptStart = new Point(e.X, e.Y);
} private void pb_InqImagePart_MouseMove(object sender, MouseEventArgs e)
{
if (pictureOperation == PICTURE_OPERATION.START)
{
pictureOperation = PICTURE_OPERATION.WORKING;
Graphics graphics = this.CreateGraphics();
Pen myPen = new Pen(Color.Red, 2);
graphics.DrawRectangle(myPen, ptStart.X, ptStart.Y, e.X - ptStart.X, e.Y - ptStart.Y);
}
} private void pb_InqImagePart_MouseUp(object sender, MouseEventArgs e)
{
if (pictureOperation == PICTURE_OPERATION.WORKING)
{
ptEnd = new Point(e.X, e.Y);
RectangleF rect = new RectangleF(ptStart.X / pb_InqImagePart.Width, ptStart.Y / pb_InqImagePart.Height,
(ptEnd.X - ptStart.X) / pb_InqImagePart.Width,
(ptEnd.Y - ptStart.Y) / pb_InqImagePart.Height);
if (selectInquireNode!=null)
{
selectInquireNode.CloneImage(rect, System.Drawing.Imaging.PixelFormat.DontCare);
}
pictureOperation = PICTURE_OPERATION.IDLE;
}
}
Pen myPen = new Pen(Color.Red, 2);
graphics.DrawRectangle(myPen, ptStart.X, ptStart.Y, e.X - ptStart.X, e.Y - ptStart.Y);
使用画矩形框,一点反应也没有,请问怎么实现我的目的呢?private void pb_InqImagePart_MouseDown(object sender, MouseEventArgs e)
{
pictureOperation = PICTURE_OPERATION.START;
ptStart = new Point(e.X, e.Y);
} private void pb_InqImagePart_MouseMove(object sender, MouseEventArgs e)
{
if (pictureOperation == PICTURE_OPERATION.START)
{
pictureOperation = PICTURE_OPERATION.WORKING;
Graphics graphics = this.CreateGraphics();
Pen myPen = new Pen(Color.Red, 2);
graphics.DrawRectangle(myPen, ptStart.X, ptStart.Y, e.X - ptStart.X, e.Y - ptStart.Y);
}
} private void pb_InqImagePart_MouseUp(object sender, MouseEventArgs e)
{
if (pictureOperation == PICTURE_OPERATION.WORKING)
{
ptEnd = new Point(e.X, e.Y);
RectangleF rect = new RectangleF(ptStart.X / pb_InqImagePart.Width, ptStart.Y / pb_InqImagePart.Height,
(ptEnd.X - ptStart.X) / pb_InqImagePart.Width,
(ptEnd.Y - ptStart.Y) / pb_InqImagePart.Height);
if (selectInquireNode!=null)
{
selectInquireNode.CloneImage(rect, System.Drawing.Imaging.PixelFormat.DontCare);
}
pictureOperation = PICTURE_OPERATION.IDLE;
}
}
解决方案 »
- 请问一个关于接口的问题
- 系统接口的使用
- datagridview 和 dataset的应用
- 在DataGridView中,如何统计修改了的数据
- 听人说,在系统中使用接口,可以减少组件间的联系程度(耦合度)和增加扩展性,我没体会到,谁能帮我解释一下,用接口有什么好处,不用接口有什么
- 急急急呀::创建的代码文件在生成时总是出现程序“D:\mypro\CSPro3\Proj\obj\Debug\Proj.exe”未定义入口点
- 泛型的高级应用,求解
- 简单问题!连接字符串怎么写?!
- 如何在繁體中文中使用簡體的Visual Studio.net
- 怎样才能在DataGrid的某一列中用checkbox等控件(在线等待)
- 请问如何将一个01字符串转换为数字
- DataTable dataTable = SystemTools.ConvertDataReaderToDataTable(GetDirectorys());
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 ERP
{
public partial class Form13 : Form
{
public Form13()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
}
Point start = new Point();
bool state = false;
private void Form13_MouseDown(object sender, MouseEventArgs e)
{
start.X = e.X;
start.Y = e.Y;
state = true;
} private void Form13_MouseMove(object sender, MouseEventArgs e)
{
if (state)
{
Graphics gs = this.CreateGraphics();
gs.Clear(Color.Red);
Rectangle Rect = new Rectangle();
Rect.X = start.X;
Rect.Y = start.Y;
Rect.Height = e.Y - start.Y;
Rect.Width = e.X - start.X;
gs.DrawRectangle(Pens.Purple, Rect);
}
} private void Form13_MouseUp(object sender, MouseEventArgs e)
{
state = false;
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WindowsApplication236
{
public partial class Form1 : Form
{
Point StartPoint; public Form1()
{
InitializeComponent(); this.MouseMove += new MouseEventHandler(Form1_MouseMove); } void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
StartPoint = e.Location;
else using (Graphics G = this.CreateGraphics())
{
G.Clear(this.BackColor);
G.DrawRectangle(Pens.Red, new Rectangle(StartPoint, new Size(e.X - StartPoint.X, e.Y - StartPoint.Y)));
}
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WindowsApplication236
{
public partial class Form1 : Form
{
Point StartPoint; public Form1()
{
InitializeComponent(); this.MouseMove += new MouseEventHandler(Form1_MouseMove); } void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
StartPoint = e.Location;
else using (Graphics G = this.CreateGraphics())
{
Point Start = StartPoint;
Point End = e.Location;
int Width = e.X - Start.X;
int Height = e.Y - Start.Y; if (Width < 0)
{
Start.X += Width;
End.X -= Width;
}
if (Height < 0)
{
Start.Y += Height;
End.Y -= Height;
} G.Clear(this.BackColor); G.DrawRectangle(Pens.Red, new Rectangle(Start, new Size(Math.Abs(Width), Math.Abs(Height))));
}
}
}
}