C# 鼠标拖放图片透明缩略图效果实现思路
来源:互联网 发布:云计算的架构和类型 编辑:程序博客网 时间:2024/05/01 13:32
int x = 0, y = 0;
Form2 objFrm = null;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
int inttTemp = Cursor.Position.X;
x = e.X;
y = e.Y;
int x1 = Cursor.Position.X;
int y1 = Cursor.Position.Y;
objFrm = new Form2(pictureBox1.Image);
objFrm.Top = x1;
objFrm.Left = y1 - e.X;
objFrm.Visible = false;
objFrm.Show();
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
objFrm.Visible = true;
objFrm.Location = new Point(Cursor.Position.X, Cursor.Position.Y);
}
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
objFrm = null;
}
#region "自定义在窗体背景中显示被拖放的图片的方法"
private void SetDragImageToForm(PictureBox pb, DragEventArgs e)
{
e.Effect = DragDropEffects.Copy;//设置拖放操作中目标放置类型为复制
string[] str_Drop = (string[])e.Data.GetData(DataFormats.FileDrop, true);
//检索数据格式相管理的数据
string tempstr;
Bitmap bkImage;//定义Bitmap变量
tempstr = str_Drop[0];//获取拖放文件的目录
try
{
bkImage = new Bitmap(tempstr);//存储拖放的图片
pb.Size = new Size(bkImage.Width + 6, bkImage.Height + 33);
//根据图片设置窗体的大小
pb.BackgroundImage = bkImage;//在窗体背景中显示图片
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
#endregion
Image objImage = null;
public Form2(Image img)
{
InitializeComponent();
this.BackgroundImage = img;
objImage = img;
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form2_Paint);
}
void Form2_Paint(object sender,PaintEventArgs e)
{
using (Bitmap objBitmap = new Bitmap(objImage, this.Width, this.Height))
{
e.Graphics.DrawImage(objImage, e.ClipRectangle);
}
}
private void Form2_Load(object sender, EventArgs e)
{
}
private void Form2_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
intX = e.X;
intY = e.Y;
}
}
private void Form2_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.Top = Control.MousePosition.Y - intY - SystemInformation.FrameBorderSize.Height;
this.Left = Control.MousePosition.X - intX - SystemInformation.FrameBorderSize.Width;
}
}
int intX = 0, intY = 0;
private void Form2_MouseUp(object sender, MouseEventArgs e)
{
this.Close();
}
- C# 鼠标拖放图片透明缩略图效果实现思路
- 图片鼠标透明效果
- c#实现图片生成缩略图
- c#实现图片生成缩略图
- Js实现图片透明效果
- j2me实现图片透明效果
- C#鼠标拖放问题
- JavaScript中通过鼠标事件实现模拟拖放效果
- C# 实现渐变透明图片
- flex4.6实现图片放大缩小及鼠标拖放事件
- c# 实现透明窗体,透明图片,透明按钮
- 缩略图实现思路
- CSS实现PNG图片背景透明效果
- 关于图片透明效果的实现
- SWT实现的图片透明效果
- SWT实现的图片透明效果
- 如何实现鼠标拖放文件
- 如何实现鼠标拖放文件
- 快乐指南:程序员版
- SurfaceView显示Camera拍摄的画面
- “小苏有朋”马宁,一种解释不出的穿透力或杀伤力的视觉震憾
- How to pass the value to the function when clicking on the UIButton
- C++函数指针
- C# 鼠标拖放图片透明缩略图效果实现思路
- 1014. Specialized Four-Dig
- 如何防止代码腐烂
- 问题Re-installation failed due to different application signatures.解决
- perl: symbol lookup error: /usr/local/lib/libtdsodbc.so: undefined symbol: libiconv_open的解决办法
- 1007. To and Fro
- S3C6410启动模式介绍
- Android2.2.1广播大全
- 验证 text 文本 输入正整数