C#实现GDI+基本图的缩放、拖拽、移动

C#实现GDI+基本图的缩放、拖拽、移动示例代码如下:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace R...
摘要由CSDN通过智能技术生成

C#实现GDI+基本图的缩放、拖拽、移动示例代码如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ResizableControls
{
public partial class MainForm : Form
{
/// <summary>
/// 有关鼠标样式的相关枚举
/// </summary>
private enum EnumMousePointPosition
{
MouseSizeNone = 0, //无
MouseSizeRight = 1, //拉伸右边框
MouseSizeLeft = 2, //拉伸左边框
MouseSizeBottom = 3, //拉伸下边框
MouseSizeTop = 4, //拉伸上边框
MouseSizeTopLeft = 5,//拉伸左上角
MouseSizeTopRight = 6,//拉伸右上角
MouseSizeBottomLeft = 7,//拉伸左下角
MouseSizeBottomRight = 8,//拉伸右下角
MouseDrag = 9 //鼠标拖动
}
const int Band = 5;//范围半径
const int MinWidth = 10;//最低宽度
const int MinHeight = 10;//最低高度
private EnumMousePointPosition m_MousePointPosition; //鼠标样式枚举
private Point m_lastPoint; //光标上次移动的位置
private Point m_endPoint; //光标移动的当前位置
public MainForm()
{
InitializeComponent();
//窗体中控件的事件晚期绑定
for (int i = 0; i < this.Controls.Count; i++)
{
this.Controls[i].MouseDown += new MouseEventHandler(MyMouseDown);
this.Controls[i].MouseLeave += new EventHandler(MyMouseLeave);
this.Controls[i].MouseMove += new MouseEventHandler(MyMouseMove);
}
}
//鼠标按下事件
private void MyMouseDown(object sender,MouseEventArgs e)
  • 3
    点赞
  • 36
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值