Changeset 4068 for trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.WinFormsUI/2.3.1/WinFormsUI-2.3.1/Docking/DockContent.cs
- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.WinFormsUI/2.3.1/WinFormsUI-2.3.1/Docking/DockContent.cs
r2645 r4068 1 1 using System; 2 2 using System.ComponentModel; 3 using System.Diagnostics.CodeAnalysis; 3 4 using System.Drawing; 4 5 using System.Windows.Forms; 5 using System.Runtime.InteropServices; 6 using System.Diagnostics.CodeAnalysis; 7 8 namespace WeifenLuo.WinFormsUI.Docking 9 { 10 public class DockContent : Form, IDockContent 11 { 12 public DockContent() 13 { 14 m_dockHandler = new DockContentHandler(this, new GetPersistStringCallback(GetPersistString)); 15 m_dockHandler.DockStateChanged += new EventHandler(DockHandler_DockStateChanged); 16 //Suggested as a fix by bensty regarding form resize 17 this.ParentChanged += new EventHandler(DockContent_ParentChanged); 18 } 19 20 //Suggested as a fix by bensty regarding form resize 21 private void DockContent_ParentChanged(object Sender, EventArgs e) 22 { 23 if (this.Parent != null) 24 this.Font = this.Parent.Font; 25 } 26 27 private DockContentHandler m_dockHandler = null; 28 [Browsable(false)] 29 public DockContentHandler DockHandler 30 { 31 get { return m_dockHandler; } 32 } 33 34 [LocalizedCategory("Category_Docking")] 35 [LocalizedDescription("DockContent_AllowEndUserDocking_Description")] 36 [DefaultValue(true)] 37 public bool AllowEndUserDocking 38 { 39 get { return DockHandler.AllowEndUserDocking; } 40 set { DockHandler.AllowEndUserDocking = value; } 41 } 42 43 [LocalizedCategory("Category_Docking")] 44 [LocalizedDescription("DockContent_DockAreas_Description")] 45 [DefaultValue(DockAreas.DockLeft|DockAreas.DockRight|DockAreas.DockTop|DockAreas.DockBottom|DockAreas.Document|DockAreas.Float)] 46 public DockAreas DockAreas 47 { 48 get { return DockHandler.DockAreas; } 49 set { DockHandler.DockAreas = value; } 50 } 51 52 [LocalizedCategory("Category_Docking")] 53 [LocalizedDescription("DockContent_AutoHidePortion_Description")] 54 [DefaultValue(0.25)] 55 public double AutoHidePortion 56 { 57 get { return DockHandler.AutoHidePortion; } 58 set { DockHandler.AutoHidePortion = value; } 59 } 60 61 [Localizable(true)] 62 [LocalizedCategory("Category_Docking")] 63 [LocalizedDescription("DockContent_TabText_Description")] 64 [DefaultValue(null)] 65 private string m_tabText = null; 66 public string TabText 67 { 68 get { return m_tabText; } 69 set { DockHandler.TabText = m_tabText = value; } 70 } 71 private bool ShouldSerializeTabText() 72 { 73 return (m_tabText != null); 74 } 75 76 [LocalizedCategory("Category_Docking")] 77 [LocalizedDescription("DockContent_CloseButton_Description")] 78 [DefaultValue(true)] 79 public bool CloseButton 80 { 81 get { return DockHandler.CloseButton; } 82 set { DockHandler.CloseButton = value; } 83 } 84 85 [LocalizedCategory("Category_Docking")] 86 [LocalizedDescription("DockContent_CloseButtonVisible_Description")] 87 [DefaultValue(true)] 88 public bool CloseButtonVisible 89 { 90 get { return DockHandler.CloseButtonVisible; } 91 set { DockHandler.CloseButtonVisible = value; } 92 } 93 94 [Browsable(false)] 95 public DockPanel DockPanel 96 { 97 get { return DockHandler.DockPanel; } 98 set { DockHandler.DockPanel = value; } 99 } 100 101 [Browsable(false)] 102 public DockState DockState 103 { 104 get { return DockHandler.DockState; } 105 set { DockHandler.DockState = value; } 106 } 107 108 [Browsable(false)] 109 public DockPane Pane 110 { 111 get { return DockHandler.Pane; } 112 set { DockHandler.Pane = value; } 113 } 114 115 [Browsable(false)] 116 public bool IsHidden 117 { 118 get { return DockHandler.IsHidden; } 119 set { DockHandler.IsHidden = value; } 120 } 121 122 [Browsable(false)] 123 public DockState VisibleState 124 { 125 get { return DockHandler.VisibleState; } 126 set { DockHandler.VisibleState = value; } 127 } 128 129 [Browsable(false)] 130 public bool IsFloat 131 { 132 get { return DockHandler.IsFloat; } 133 set { DockHandler.IsFloat = value; } 134 } 135 136 [Browsable(false)] 137 public DockPane PanelPane 138 { 139 get { return DockHandler.PanelPane; } 140 set { DockHandler.PanelPane = value; } 141 } 142 143 [Browsable(false)] 144 public DockPane FloatPane 145 { 146 get { return DockHandler.FloatPane; } 147 set { DockHandler.FloatPane = value; } 148 } 149 150 [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] 151 protected virtual string GetPersistString() 152 { 153 return GetType().ToString(); 154 } 155 156 [LocalizedCategory("Category_Docking")] 157 [LocalizedDescription("DockContent_HideOnClose_Description")] 158 [DefaultValue(false)] 159 public bool HideOnClose 160 { 161 get { return DockHandler.HideOnClose; } 162 set { DockHandler.HideOnClose = value; } 163 } 164 165 [LocalizedCategory("Category_Docking")] 166 [LocalizedDescription("DockContent_ShowHint_Description")] 167 [DefaultValue(DockState.Unknown)] 168 public DockState ShowHint 169 { 170 get { return DockHandler.ShowHint; } 171 set { DockHandler.ShowHint = value; } 172 } 173 174 [Browsable(false)] 175 public bool IsActivated 176 { 177 get { return DockHandler.IsActivated; } 178 } 179 180 public bool IsDockStateValid(DockState dockState) 181 { 182 return DockHandler.IsDockStateValid(dockState); 183 } 184 185 [LocalizedCategory("Category_Docking")] 186 [LocalizedDescription("DockContent_TabPageContextMenu_Description")] 187 [DefaultValue(null)] 188 public ContextMenu TabPageContextMenu 189 { 190 get { return DockHandler.TabPageContextMenu; } 191 set { DockHandler.TabPageContextMenu = value; } 192 } 193 194 [LocalizedCategory("Category_Docking")] 195 [LocalizedDescription("DockContent_TabPageContextMenuStrip_Description")] 196 [DefaultValue(null)] 197 public ContextMenuStrip TabPageContextMenuStrip 198 { 199 get { return DockHandler.TabPageContextMenuStrip; } 200 set { DockHandler.TabPageContextMenuStrip = value; } 201 } 202 203 [Localizable(true)] 204 [Category("Appearance")] 205 [LocalizedDescription("DockContent_ToolTipText_Description")] 206 [DefaultValue(null)] 207 public string ToolTipText 208 { 209 get { return DockHandler.ToolTipText; } 210 set { DockHandler.ToolTipText = value; } 211 } 212 213 public new void Activate() 214 { 215 DockHandler.Activate(); 216 } 217 218 public new void Hide() 219 { 220 DockHandler.Hide(); 221 } 222 223 public new void Show() 224 { 225 DockHandler.Show(); 226 } 227 228 public void Show(DockPanel dockPanel) 229 { 230 DockHandler.Show(dockPanel); 231 } 232 233 public void Show(DockPanel dockPanel, DockState dockState) 234 { 235 DockHandler.Show(dockPanel, dockState); 236 } 237 238 [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters")] 239 public void Show(DockPanel dockPanel, Rectangle floatWindowBounds) 240 { 241 DockHandler.Show(dockPanel, floatWindowBounds); 242 } 243 244 public void Show(DockPane pane, IDockContent beforeContent) 245 { 246 DockHandler.Show(pane, beforeContent); 247 } 248 249 public void Show(DockPane previousPane, DockAlignment alignment, double proportion) 250 { 251 DockHandler.Show(previousPane, alignment, proportion); 252 } 253 254 [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters")] 255 public void FloatAt(Rectangle floatWindowBounds) 256 { 257 DockHandler.FloatAt(floatWindowBounds); 258 } 259 260 public void DockTo(DockPane paneTo, DockStyle dockStyle, int contentIndex) 261 { 262 DockHandler.DockTo(paneTo, dockStyle, contentIndex); 263 } 264 265 public void DockTo(DockPanel panel, DockStyle dockStyle) 266 { 267 DockHandler.DockTo(panel, dockStyle); 268 } 269 270 #region IDockContent Members 271 void IDockContent.OnActivated(EventArgs e) 272 { 273 this.OnActivated(e); 274 } 275 276 void IDockContent.OnDeactivate(EventArgs e) 277 { 278 this.OnDeactivate(e); 279 } 280 #endregion 281 282 #region Events 283 private void DockHandler_DockStateChanged(object sender, EventArgs e) 284 { 285 OnDockStateChanged(e); 286 } 287 288 private static readonly object DockStateChangedEvent = new object(); 289 [LocalizedCategory("Category_PropertyChanged")] 290 [LocalizedDescription("Pane_DockStateChanged_Description")] 291 public event EventHandler DockStateChanged 292 { 293 add { Events.AddHandler(DockStateChangedEvent, value); } 294 remove { Events.RemoveHandler(DockStateChangedEvent, value); } 295 } 296 protected virtual void OnDockStateChanged(EventArgs e) 297 { 298 EventHandler handler = (EventHandler)Events[DockStateChangedEvent]; 299 if (handler != null) 300 handler(this, e); 301 } 302 #endregion 303 } 6 7 namespace WeifenLuo.WinFormsUI.Docking { 8 public class DockContent : Form, IDockContent { 9 public DockContent() { 10 m_dockHandler = new DockContentHandler(this, new GetPersistStringCallback(GetPersistString)); 11 m_dockHandler.DockStateChanged += new EventHandler(DockHandler_DockStateChanged); 12 //Suggested as a fix by bensty regarding form resize 13 this.ParentChanged += new EventHandler(DockContent_ParentChanged); 14 } 15 16 //Suggested as a fix by bensty regarding form resize 17 private void DockContent_ParentChanged(object Sender, EventArgs e) { 18 if (this.Parent != null) 19 this.Font = this.Parent.Font; 20 } 21 22 private DockContentHandler m_dockHandler = null; 23 [Browsable(false)] 24 public DockContentHandler DockHandler { 25 get { return m_dockHandler; } 26 } 27 28 [LocalizedCategory("Category_Docking")] 29 [LocalizedDescription("DockContent_AllowEndUserDocking_Description")] 30 [DefaultValue(true)] 31 public bool AllowEndUserDocking { 32 get { return DockHandler.AllowEndUserDocking; } 33 set { DockHandler.AllowEndUserDocking = value; } 34 } 35 36 [LocalizedCategory("Category_Docking")] 37 [LocalizedDescription("DockContent_DockAreas_Description")] 38 [DefaultValue(DockAreas.DockLeft | DockAreas.DockRight | DockAreas.DockTop | DockAreas.DockBottom | DockAreas.Document | DockAreas.Float)] 39 public DockAreas DockAreas { 40 get { return DockHandler.DockAreas; } 41 set { DockHandler.DockAreas = value; } 42 } 43 44 [LocalizedCategory("Category_Docking")] 45 [LocalizedDescription("DockContent_AutoHidePortion_Description")] 46 [DefaultValue(0.25)] 47 public double AutoHidePortion { 48 get { return DockHandler.AutoHidePortion; } 49 set { DockHandler.AutoHidePortion = value; } 50 } 51 52 [Localizable(true)] 53 [LocalizedCategory("Category_Docking")] 54 [LocalizedDescription("DockContent_TabText_Description")] 55 [DefaultValue(null)] 56 private string m_tabText = null; 57 public string TabText { 58 get { return m_tabText; } 59 set { DockHandler.TabText = m_tabText = value; } 60 } 61 private bool ShouldSerializeTabText() { 62 return (m_tabText != null); 63 } 64 65 [LocalizedCategory("Category_Docking")] 66 [LocalizedDescription("DockContent_CloseButton_Description")] 67 [DefaultValue(true)] 68 public bool CloseButton { 69 get { return DockHandler.CloseButton; } 70 set { DockHandler.CloseButton = value; } 71 } 72 73 [LocalizedCategory("Category_Docking")] 74 [LocalizedDescription("DockContent_CloseButtonVisible_Description")] 75 [DefaultValue(true)] 76 public bool CloseButtonVisible { 77 get { return DockHandler.CloseButtonVisible; } 78 set { DockHandler.CloseButtonVisible = value; } 79 } 80 81 [Browsable(false)] 82 public DockPanel DockPanel { 83 get { return DockHandler.DockPanel; } 84 set { DockHandler.DockPanel = value; } 85 } 86 87 [Browsable(false)] 88 public DockState DockState { 89 get { return DockHandler.DockState; } 90 set { DockHandler.DockState = value; } 91 } 92 93 [Browsable(false)] 94 public DockPane Pane { 95 get { return DockHandler.Pane; } 96 set { DockHandler.Pane = value; } 97 } 98 99 [Browsable(false)] 100 public bool IsHidden { 101 get { return DockHandler.IsHidden; } 102 set { DockHandler.IsHidden = value; } 103 } 104 105 [Browsable(false)] 106 public DockState VisibleState { 107 get { return DockHandler.VisibleState; } 108 set { DockHandler.VisibleState = value; } 109 } 110 111 [Browsable(false)] 112 public bool IsFloat { 113 get { return DockHandler.IsFloat; } 114 set { DockHandler.IsFloat = value; } 115 } 116 117 [Browsable(false)] 118 public DockPane PanelPane { 119 get { return DockHandler.PanelPane; } 120 set { DockHandler.PanelPane = value; } 121 } 122 123 [Browsable(false)] 124 public DockPane FloatPane { 125 get { return DockHandler.FloatPane; } 126 set { DockHandler.FloatPane = value; } 127 } 128 129 [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] 130 protected virtual string GetPersistString() { 131 return GetType().ToString(); 132 } 133 134 [LocalizedCategory("Category_Docking")] 135 [LocalizedDescription("DockContent_HideOnClose_Description")] 136 [DefaultValue(false)] 137 public bool HideOnClose { 138 get { return DockHandler.HideOnClose; } 139 set { DockHandler.HideOnClose = value; } 140 } 141 142 [LocalizedCategory("Category_Docking")] 143 [LocalizedDescription("DockContent_ShowHint_Description")] 144 [DefaultValue(DockState.Unknown)] 145 public DockState ShowHint { 146 get { return DockHandler.ShowHint; } 147 set { DockHandler.ShowHint = value; } 148 } 149 150 [Browsable(false)] 151 public bool IsActivated { 152 get { return DockHandler.IsActivated; } 153 } 154 155 public bool IsDockStateValid(DockState dockState) { 156 return DockHandler.IsDockStateValid(dockState); 157 } 158 159 [LocalizedCategory("Category_Docking")] 160 [LocalizedDescription("DockContent_TabPageContextMenu_Description")] 161 [DefaultValue(null)] 162 public ContextMenu TabPageContextMenu { 163 get { return DockHandler.TabPageContextMenu; } 164 set { DockHandler.TabPageContextMenu = value; } 165 } 166 167 [LocalizedCategory("Category_Docking")] 168 [LocalizedDescription("DockContent_TabPageContextMenuStrip_Description")] 169 [DefaultValue(null)] 170 public ContextMenuStrip TabPageContextMenuStrip { 171 get { return DockHandler.TabPageContextMenuStrip; } 172 set { DockHandler.TabPageContextMenuStrip = value; } 173 } 174 175 [Localizable(true)] 176 [Category("Appearance")] 177 [LocalizedDescription("DockContent_ToolTipText_Description")] 178 [DefaultValue(null)] 179 public string ToolTipText { 180 get { return DockHandler.ToolTipText; } 181 set { DockHandler.ToolTipText = value; } 182 } 183 184 public new void Activate() { 185 DockHandler.Activate(); 186 } 187 188 public new void Hide() { 189 DockHandler.Hide(); 190 } 191 192 public new void Show() { 193 DockHandler.Show(); 194 } 195 196 public void Show(DockPanel dockPanel) { 197 DockHandler.Show(dockPanel); 198 } 199 200 public void Show(DockPanel dockPanel, DockState dockState) { 201 DockHandler.Show(dockPanel, dockState); 202 } 203 204 [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters")] 205 public void Show(DockPanel dockPanel, Rectangle floatWindowBounds) { 206 DockHandler.Show(dockPanel, floatWindowBounds); 207 } 208 209 public void Show(DockPane pane, IDockContent beforeContent) { 210 DockHandler.Show(pane, beforeContent); 211 } 212 213 public void Show(DockPane previousPane, DockAlignment alignment, double proportion) { 214 DockHandler.Show(previousPane, alignment, proportion); 215 } 216 217 [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters")] 218 public void FloatAt(Rectangle floatWindowBounds) { 219 DockHandler.FloatAt(floatWindowBounds); 220 } 221 222 public void DockTo(DockPane paneTo, DockStyle dockStyle, int contentIndex) { 223 DockHandler.DockTo(paneTo, dockStyle, contentIndex); 224 } 225 226 public void DockTo(DockPanel panel, DockStyle dockStyle) { 227 DockHandler.DockTo(panel, dockStyle); 228 } 229 230 #region IDockContent Members 231 void IDockContent.OnActivated(EventArgs e) { 232 this.OnActivated(e); 233 } 234 235 void IDockContent.OnDeactivate(EventArgs e) { 236 this.OnDeactivate(e); 237 } 238 #endregion 239 240 #region Events 241 private void DockHandler_DockStateChanged(object sender, EventArgs e) { 242 OnDockStateChanged(e); 243 } 244 245 private static readonly object DockStateChangedEvent = new object(); 246 [LocalizedCategory("Category_PropertyChanged")] 247 [LocalizedDescription("Pane_DockStateChanged_Description")] 248 public event EventHandler DockStateChanged { 249 add { Events.AddHandler(DockStateChangedEvent, value); } 250 remove { Events.RemoveHandler(DockStateChangedEvent, value); } 251 } 252 protected virtual void OnDockStateChanged(EventArgs e) { 253 EventHandler handler = (EventHandler)Events[DockStateChangedEvent]; 254 if (handler != null) 255 handler(this, e); 256 } 257 #endregion 258 } 304 259 }
Note: See TracChangeset
for help on using the changeset viewer.