-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathFmMDI.cs
136 lines (112 loc) · 4.1 KB
/
FmMDI.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
using System;
using System.Diagnostics;
using System.Windows.Forms;
using AhDung.WinForm;
namespace AhDung
{
public partial class FmMDI : Form
{
public FmMDI()
{
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 newChild_Click(object sender, EventArgs e)
{
new FmTestDrag { MdiParent = this }.Show();
}
private void newNormal_Click(object sender, EventArgs e)
{
new FmTestDrag().Show();
}
private void newModal_Click(object sender, EventArgs e)
{
new FmTestDrag().ShowDialog();
}
//private void btnShowMsgBox_Click(object sender, EventArgs e)
//{
// MessageBox.Show("拖我试试");
//}
//private void miOpenFileDialog_Click(object sender, EventArgs e)
//{
// new OpenFileDialog().ShowDialog();
//}
//private void miSaveFileDialog_Click(object sender, EventArgs e)
//{
// new SaveFileDialog().ShowDialog();
//}
//private void miFolderBrowserDialog_Click(object sender, EventArgs e)
//{
// new FolderBrowserDialog().ShowDialog();
//}
//private void miColorDialog_Click(object sender, EventArgs e)
//{
// new ColorDialog().ShowDialog();
//}
//private void miFontDialog_Click(object sender, EventArgs e)
//{
// new FontDialog().ShowDialog();
//}
//private void miPageSetupDialog_Click(object sender, EventArgs e)
//{
// new PageSetupDialog() { Document = new PrintDocument() }.ShowDialog();
//}
//private void miPrintDialog_Click(object sender, EventArgs e)
//{
// //todo 勾不到
// new PrintDialog() { UseEXDialog = true }.ShowDialog();
//}
}
}