-
Notifications
You must be signed in to change notification settings - Fork 12
/
FmTestDrag.cs
89 lines (75 loc) · 2.69 KB
/
FmTestDrag.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System;
using System.Diagnostics;
using System.Windows.Forms;
using AhDung.WinForm;
namespace AhDung
{
public partial class FmTestDrag : Form
{
public FmTestDrag()
{
InitializeComponent();
FormDragger.Dragging += FormDragger_Dragging;
FormDragger.EnabledChanged += FormDragger_EnabledChanged;
//例外方式一:将控件添加进例外列表
//FormDragger.ExcludeControls.Add(pictureBox1);
}
void FormDragger_Dragging(object sender, FormDraggingCancelEventArgs e)
{
//例外方式二:在FormDragging事件中令Cancel = true
//if (e.Control == pictureBox1)
//{
// e.Cancel = true;
//}
statusBarPanel1.Text = string.Format("{0}, {1}:{2}",
e.Control.GetType().Name, e.IsClientArea ? "客户区坐标" : "屏幕坐标", e.MousePosition);
}
//图片点击事件。仅当该控件处于例外或关闭整个拖拽器时会触发
private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
{
VisitAuthorHome();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
//拖拽器开关
FormDragger.Enabled = toolStripCheckBox1.Checked;
}
void FormDragger_EnabledChanged(object sender, EventArgs e)
{
//放心这里不会造成来回触发,因为Enabled内部有重入处理
if (FormDragger.Enabled)
{
toolStripCheckBox1.Checked = true;
toolStripCheckBox1.Text = "拖拽:开";
}
else
{
toolStripCheckBox1.Checked = false;
toolStripCheckBox1.Text = "拖拽:关";
}
}
private void FmMDI_Load(object sender, EventArgs e)
{
linkLabel1.Links.Add(2, 5, "AAA");
linkLabel1.Links.Add(8, 6, "BBB").Enabled = false;
treeView1.ExpandAll();
this.ContextMenu = contextMenu1;
}
private void VisitAuthorHome()
{
Process.Start("http://www.cnblogs.com/ahdung/p/FormDragger.html");
}
private void btnAbout_Click(object sender, EventArgs e)
{
VisitAuthorHome();
}
private void newNormal_Click(object sender, EventArgs e)
{
new FmTestDrag().Show();
}
private void newModal_Click(object sender, EventArgs e)
{
new FmTestDrag().ShowDialog();
}
}
}