Line | |
---|
1 | using System;
|
---|
2 | using System.Collections;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Drawing;
|
---|
5 | using System.Windows.Forms;
|
---|
6 |
|
---|
7 | namespace WeifenLuo.WinFormsUI.Docking
|
---|
8 | {
|
---|
9 | internal class SplitterBase : Control
|
---|
10 | {
|
---|
11 | public SplitterBase()
|
---|
12 | {
|
---|
13 | SetStyle(ControlStyles.Selectable, false);
|
---|
14 | }
|
---|
15 |
|
---|
16 | public override DockStyle Dock
|
---|
17 | {
|
---|
18 | get { return base.Dock; }
|
---|
19 | set
|
---|
20 | {
|
---|
21 | SuspendLayout();
|
---|
22 | base.Dock = value;
|
---|
23 |
|
---|
24 | if (Dock == DockStyle.Left || Dock == DockStyle.Right)
|
---|
25 | Width = SplitterSize;
|
---|
26 | else if (Dock == DockStyle.Top || Dock == DockStyle.Bottom)
|
---|
27 | Height = SplitterSize;
|
---|
28 | else
|
---|
29 | Bounds = Rectangle.Empty;
|
---|
30 |
|
---|
31 | if (Dock == DockStyle.Left || Dock == DockStyle.Right)
|
---|
32 | Cursor = Cursors.VSplit;
|
---|
33 | else if (Dock == DockStyle.Top || Dock == DockStyle.Bottom)
|
---|
34 | Cursor = Cursors.HSplit;
|
---|
35 | else
|
---|
36 | Cursor = Cursors.Default;
|
---|
37 |
|
---|
38 | ResumeLayout();
|
---|
39 | }
|
---|
40 | }
|
---|
41 |
|
---|
42 | protected virtual int SplitterSize
|
---|
43 | {
|
---|
44 | get { return 0; }
|
---|
45 | }
|
---|
46 |
|
---|
47 | protected override void OnMouseDown(MouseEventArgs e)
|
---|
48 | {
|
---|
49 | base.OnMouseDown(e);
|
---|
50 |
|
---|
51 | if (e.Button != MouseButtons.Left)
|
---|
52 | return;
|
---|
53 |
|
---|
54 | StartDrag();
|
---|
55 | }
|
---|
56 |
|
---|
57 | protected virtual void StartDrag()
|
---|
58 | {
|
---|
59 | }
|
---|
60 |
|
---|
61 | protected override void WndProc(ref Message m)
|
---|
62 | {
|
---|
63 | // eat the WM_MOUSEACTIVATE message
|
---|
64 | if (m.Msg == (int)Win32.Msgs.WM_MOUSEACTIVATE)
|
---|
65 | return;
|
---|
66 |
|
---|
67 | base.WndProc(ref m);
|
---|
68 | }
|
---|
69 | }
|
---|
70 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.