Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/WinFormsUI/Docking/DockAreasEditor.cs @ 2636

Last change on this file since 2636 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: 4.6 KB
RevLine 
[2134]1using System;
2using System.ComponentModel;
3using System.Drawing;
4using System.Drawing.Design;
5using System.Windows.Forms;
6using System.Windows.Forms.Design;
7
8namespace WeifenLuo.WinFormsUI.Docking
9{
10  internal class DockAreasEditor : UITypeEditor
11  {
12    private class DockAreasEditorControl : System.Windows.Forms.UserControl
13    {
14      private CheckBox checkBoxFloat;
15      private CheckBox checkBoxDockLeft;
16      private CheckBox checkBoxDockRight;
17      private CheckBox checkBoxDockTop;
18      private CheckBox checkBoxDockBottom;
19      private CheckBox checkBoxDockFill;
20      private DockAreas m_oldDockAreas;
21
22      public DockAreas DockAreas
23      {
24        get
25        {
26          DockAreas dockAreas = 0;
27          if (checkBoxFloat.Checked)
28            dockAreas |= DockAreas.Float;
29          if (checkBoxDockLeft.Checked)
30            dockAreas |= DockAreas.DockLeft;
31          if (checkBoxDockRight.Checked)
32            dockAreas |= DockAreas.DockRight;
33          if (checkBoxDockTop.Checked)
34            dockAreas |= DockAreas.DockTop;
35          if (checkBoxDockBottom.Checked)
36            dockAreas |= DockAreas.DockBottom;
37          if (checkBoxDockFill.Checked)
38            dockAreas |= DockAreas.Document;
39
40          if (dockAreas == 0)
41            return m_oldDockAreas;
42          else
43            return dockAreas;
44        }
45      }
46
47      public DockAreasEditorControl()
48      {
49        checkBoxFloat = new CheckBox();
50        checkBoxDockLeft = new CheckBox();
51        checkBoxDockRight = new CheckBox();
52        checkBoxDockTop = new CheckBox();
53        checkBoxDockBottom = new CheckBox();
54        checkBoxDockFill = new CheckBox();
55
56        SuspendLayout();
57
58        checkBoxFloat.Appearance = Appearance.Button;
59        checkBoxFloat.Dock = DockStyle.Top;
60        checkBoxFloat.Height = 24;
61        checkBoxFloat.Text = Strings.DockAreaEditor_FloatCheckBoxText;
62        checkBoxFloat.TextAlign = ContentAlignment.MiddleCenter;
63        checkBoxFloat.FlatStyle = FlatStyle.System;
64     
65        checkBoxDockLeft.Appearance = System.Windows.Forms.Appearance.Button;
66        checkBoxDockLeft.Dock = System.Windows.Forms.DockStyle.Left;
67        checkBoxDockLeft.Width = 24;
68        checkBoxDockLeft.FlatStyle = FlatStyle.System;
69
70        checkBoxDockRight.Appearance = System.Windows.Forms.Appearance.Button;
71        checkBoxDockRight.Dock = System.Windows.Forms.DockStyle.Right;
72        checkBoxDockRight.Width = 24;
73        checkBoxDockRight.FlatStyle = FlatStyle.System;
74
75        checkBoxDockTop.Appearance = System.Windows.Forms.Appearance.Button;
76        checkBoxDockTop.Dock = System.Windows.Forms.DockStyle.Top;
77        checkBoxDockTop.Height = 24;
78        checkBoxDockTop.FlatStyle = FlatStyle.System;
79
80        checkBoxDockBottom.Appearance = System.Windows.Forms.Appearance.Button;
81        checkBoxDockBottom.Dock = System.Windows.Forms.DockStyle.Bottom;
82        checkBoxDockBottom.Height = 24;
83        checkBoxDockBottom.FlatStyle = FlatStyle.System;
84     
85        checkBoxDockFill.Appearance = System.Windows.Forms.Appearance.Button;
86        checkBoxDockFill.Dock = System.Windows.Forms.DockStyle.Fill;
87        checkBoxDockFill.FlatStyle = FlatStyle.System;
88
89        this.Controls.AddRange(new Control[] {
90                             checkBoxDockFill,
91                             checkBoxDockBottom,
92                             checkBoxDockTop,
93                             checkBoxDockRight,
94                             checkBoxDockLeft,
95                             checkBoxFloat});
96
97        Size = new System.Drawing.Size(160, 144);
98        BackColor = SystemColors.Control;
99        ResumeLayout();
100      }
101
102      public void SetStates(DockAreas dockAreas)
103      {
104        m_oldDockAreas = dockAreas;
105        if ((dockAreas & DockAreas.DockLeft) != 0)
106          checkBoxDockLeft.Checked = true;
107        if ((dockAreas & DockAreas.DockRight) != 0)
108          checkBoxDockRight.Checked = true;
109        if ((dockAreas & DockAreas.DockTop) != 0)
110          checkBoxDockTop.Checked = true;
111        if ((dockAreas & DockAreas.DockTop) != 0)
112          checkBoxDockTop.Checked = true;
113        if ((dockAreas & DockAreas.DockBottom) != 0)
114          checkBoxDockBottom.Checked = true;
115        if ((dockAreas & DockAreas.Document) != 0)
116          checkBoxDockFill.Checked = true;
117        if ((dockAreas & DockAreas.Float) != 0)
118          checkBoxFloat.Checked = true;
119      }
120    }
121
122    private DockAreasEditor.DockAreasEditorControl m_ui = null;
123
124    public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
125    {
126      return UITypeEditorEditStyle.DropDown;
127    }
128
129    public override object EditValue(ITypeDescriptorContext context, IServiceProvider sp, object value)
130    {
131      if (m_ui == null)
132        m_ui = new DockAreasEditor.DockAreasEditorControl();
133
134      m_ui.SetStates((DockAreas)value);
135
136            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)sp.GetService(typeof(IWindowsFormsEditorService));
137      edSvc.DropDownControl(m_ui);
138
139      return m_ui.DockAreas;
140    }
141  }
142}
Note: See TracBrowser for help on using the repository browser.