Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Persistence Test/WinFormsUI/Docking/Helpers/DockHelper.cs @ 3962

Last change on this file since 3962 was 2134, checked in by gkronber, 15 years ago

Added up to date source of Weifen Luo dock panel suit in a separate project (and added strong name key). Removed binary versions of Weifen Luo dock panel suite and references to it. #687 (Update AdvancedOptimizationFrontend to use more recent version of Weifen Luo Docking library)

File size: 3.3 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      for (Control control = Win32Helper.ControlAtPoint(pt); control != null; control = control.Parent)
78      {
79        IDockContent content = control as IDockContent;
80        if (content != null && content.DockHandler.DockPanel == dockPanel)
81          return content.DockHandler.Pane;
82
83        DockPane pane = control as DockPane;
84        if (pane != null && pane.DockPanel == dockPanel)
85          return pane;
86      }
87
88      return null;
89    }
90
91    public static FloatWindow FloatWindowAtPoint(Point pt, DockPanel dockPanel)
92    {
93      for (Control control = Win32Helper.ControlAtPoint(pt); control != null; control = control.Parent)
94      {
95        FloatWindow floatWindow = control as FloatWindow;
96        if (floatWindow != null && floatWindow.DockPanel == dockPanel)
97          return floatWindow;
98      }
99
100      return null;
101    }
102  }
103}
Note: See TracBrowser for help on using the repository browser.