Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/HeuristicLab.ExtLibs/HeuristicLab.WinFormsUI/2.7.0/WinFormsUI-2.7.0/Docking/Helpers/DockHelper.cs @ 15682

Last change on this file since 15682 was 8616, checked in by mkommend, 12 years ago

#1939: Added DockPanelSuite 2.7.0 to ExtLibs.

File size: 3.5 KB
Line 
1using System;
2using System.Drawing;
3using System.Windows.Forms;
4
5namespace WeifenLuo.WinFormsUI.Docking
6{
7  internal static class DockHelper
8  {
9    public static bool IsDockStateAutoHide(DockState dockState)
10    {
11      if (dockState == DockState.DockLeftAutoHide ||
12        dockState == DockState.DockRightAutoHide ||
13        dockState == DockState.DockTopAutoHide ||
14        dockState == DockState.DockBottomAutoHide)
15        return true;
16      else
17        return false;
18    }
19
20    public static bool IsDockStateValid(DockState dockState, DockAreas dockableAreas)
21    {
22      if (((dockableAreas & DockAreas.Float) == 0) &&
23        (dockState == DockState.Float))
24        return false;
25      else if (((dockableAreas & DockAreas.Document) == 0) &&
26        (dockState == DockState.Document))
27        return false;
28      else if (((dockableAreas & DockAreas.DockLeft) == 0) &&
29        (dockState == DockState.DockLeft || dockState == DockState.DockLeftAutoHide))
30        return false;
31      else if (((dockableAreas & DockAreas.DockRight) == 0) &&
32        (dockState == DockState.DockRight || dockState == DockState.DockRightAutoHide))
33        return false;
34      else if (((dockableAreas & DockAreas.DockTop) == 0) &&
35        (dockState == DockState.DockTop || dockState == DockState.DockTopAutoHide))
36        return false;
37      else if (((dockableAreas & DockAreas.DockBottom) == 0) &&
38        (dockState == DockState.DockBottom || dockState == DockState.DockBottomAutoHide))
39        return false;
40      else
41        return true;
42    }
43
44    public static bool IsDockWindowState(DockState state)
45    {
46      if (state == DockState.DockTop || state == DockState.DockBottom || state == DockState.DockLeft ||
47        state == DockState.DockRight || state == DockState.Document)
48        return true;
49      else
50        return false;
51    }
52
53    public static DockState ToggleAutoHideState(DockState state)
54    {
55      if (state == DockState.DockLeft)
56        return DockState.DockLeftAutoHide;
57      else if (state == DockState.DockRight)
58        return DockState.DockRightAutoHide;
59      else if (state == DockState.DockTop)
60        return DockState.DockTopAutoHide;
61      else if (state == DockState.DockBottom)
62        return DockState.DockBottomAutoHide;
63      else if (state == DockState.DockLeftAutoHide)
64        return DockState.DockLeft;
65      else if (state == DockState.DockRightAutoHide)
66        return DockState.DockRight;
67      else if (state == DockState.DockTopAutoHide)
68        return DockState.DockTop;
69      else if (state == DockState.DockBottomAutoHide)
70        return DockState.DockBottom;
71      else
72        return state;
73    }
74
75    public static DockPane PaneAtPoint(Point pt, DockPanel dockPanel)
76    {
77            if (!Win32Helper.IsRunningOnMono)
78          for (Control control = Win32Helper.ControlAtPoint(pt); control != null; control = control.Parent)
79          {
80            IDockContent content = control as IDockContent;
81            if (content != null && content.DockHandler.DockPanel == dockPanel)
82              return content.DockHandler.Pane;
83
84            DockPane pane = control as DockPane;
85            if (pane != null && pane.DockPanel == dockPanel)
86              return pane;
87          }
88
89      return null;
90    }
91
92    public static FloatWindow FloatWindowAtPoint(Point pt, DockPanel dockPanel)
93    {
94            if (!Win32Helper.IsRunningOnMono)
95          for (Control control = Win32Helper.ControlAtPoint(pt); control != null; control = control.Parent)
96          {
97            FloatWindow floatWindow = control as FloatWindow;
98            if (floatWindow != null && floatWindow.DockPanel == dockPanel)
99              return floatWindow;
100          }
101
102      return null;
103    }
104  }
105}
Note: See TracBrowser for help on using the repository browser.